mirror of https://github.com/mgba-emu/mgba.git
GBA Video: Bump OpenGL requirement to 3.3 (closes #2425)
This commit is contained in:
parent
ddca55347e
commit
1f53174270
|
@ -166,8 +166,6 @@ struct GBAVideoGLRenderer {
|
|||
struct GBAVideoGLShader windowShader;
|
||||
struct GBAVideoGLShader finalizeShader;
|
||||
|
||||
bool useBindFragData;
|
||||
|
||||
GBARegisterDISPCNT dispcnt;
|
||||
|
||||
unsigned target1Obj;
|
||||
|
|
|
@ -67,12 +67,6 @@ static const GLchar* const _gles3Header =
|
|||
"precision highp isampler2D;\n";
|
||||
|
||||
static const GLchar* const _gl3Header =
|
||||
"#version 140 core\n"
|
||||
"#define OUT(n)\n"
|
||||
PALETTE_ENTRY
|
||||
"precision highp float;\n";
|
||||
|
||||
static const GLchar* const _gl33Header =
|
||||
"#version 330 core\n"
|
||||
"#define OUT(n) layout(location = n)\n"
|
||||
PALETTE_ENTRY
|
||||
|
@ -690,7 +684,7 @@ void GBAVideoGLRendererCreate(struct GBAVideoGLRenderer* renderer) {
|
|||
renderer->scale = 1;
|
||||
}
|
||||
|
||||
static void _compileShader(struct GBAVideoGLRenderer* glRenderer, struct GBAVideoGLShader* shader, const char** shaderBuffer, int shaderBufferLines, GLuint vs, const struct GBAVideoGLUniform* uniforms, const char* const* outFrags, char* log) {
|
||||
static void _compileShader(struct GBAVideoGLRenderer* glRenderer, struct GBAVideoGLShader* shader, const char** shaderBuffer, int shaderBufferLines, GLuint vs, const struct GBAVideoGLUniform* uniforms, char* log) {
|
||||
GLuint program = glCreateProgram();
|
||||
shader->program = program;
|
||||
|
||||
|
@ -703,12 +697,6 @@ static void _compileShader(struct GBAVideoGLRenderer* glRenderer, struct GBAVide
|
|||
if (log[0]) {
|
||||
mLOG(GBA_VIDEO, ERROR, "Fragment shader compilation failure: %s", log);
|
||||
}
|
||||
size_t i;
|
||||
if (glRenderer->useBindFragData) {
|
||||
for (i = 0; outFrags[i]; ++i) {
|
||||
glBindFragDataLocation(program, i, outFrags[i]);
|
||||
}
|
||||
}
|
||||
glLinkProgram(program);
|
||||
glGetProgramInfoLog(program, 2048, 0, log);
|
||||
if (log[0]) {
|
||||
|
@ -723,6 +711,7 @@ static void _compileShader(struct GBAVideoGLRenderer* glRenderer, struct GBAVide
|
|||
glEnableVertexAttribArray(positionLocation);
|
||||
glVertexAttribPointer(positionLocation, 2, GL_INT, GL_FALSE, 0, NULL);
|
||||
|
||||
size_t i;
|
||||
for (i = 0; uniforms[i].name; ++i) {
|
||||
shader->uniforms[uniforms[i].type] = glGetUniformLocation(program, uniforms[i].name);
|
||||
}
|
||||
|
@ -827,15 +816,9 @@ void GBAVideoGLRendererInit(struct GBAVideoRenderer* renderer) {
|
|||
|
||||
char log[2048];
|
||||
const GLchar* shaderBuffer[4];
|
||||
glRenderer->useBindFragData = false;
|
||||
const GLubyte* version = glGetString(GL_VERSION);
|
||||
if (strncmp((const char*) version, "OpenGL ES ", strlen("OpenGL ES ")) != 0) {
|
||||
if (strncmp((const char*) version, "3.3 ", strlen("3.3 ")) == 0 || strncmp((const char*) version, "4.", strlen("4.")) == 0) {
|
||||
shaderBuffer[0] = _gl33Header;
|
||||
} else {
|
||||
shaderBuffer[0] = _gl3Header;
|
||||
glRenderer->useBindFragData = true;
|
||||
}
|
||||
shaderBuffer[0] = _gl3Header;
|
||||
} else {
|
||||
shaderBuffer[0] = _gles3Header;
|
||||
}
|
||||
|
@ -848,53 +831,47 @@ void GBAVideoGLRendererInit(struct GBAVideoRenderer* renderer) {
|
|||
if (log[0]) {
|
||||
mLOG(GBA_VIDEO, ERROR, "Vertex shader compilation failure: %s", log);
|
||||
}
|
||||
|
||||
const char* const noWindow[] = {"color", "flags", NULL};
|
||||
const char* const window[] = {"color", "flags", "window", NULL};
|
||||
const char* const onlyWindow[] = {"window", NULL};
|
||||
const char* const onlyColor[] = {"color", NULL};
|
||||
|
||||
shaderBuffer[1] = _renderMode0;
|
||||
|
||||
shaderBuffer[2] = _renderTile16;
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[0], shaderBuffer, 3, vs, _uniformsMode0, noWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[0], shaderBuffer, 3, vs, _uniformsMode0, log);
|
||||
|
||||
shaderBuffer[2] = _renderTile256;
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[1], shaderBuffer, 3, vs, _uniformsMode0, noWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[1], shaderBuffer, 3, vs, _uniformsMode0, log);
|
||||
|
||||
shaderBuffer[1] = _renderMode2;
|
||||
shaderBuffer[2] = _interpolate;
|
||||
|
||||
shaderBuffer[3] = _fetchTileOverflow;
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[2], shaderBuffer, 4, vs, _uniformsMode2, noWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[2], shaderBuffer, 4, vs, _uniformsMode2, log);
|
||||
|
||||
shaderBuffer[3] = _fetchTileNoOverflow;
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[3], shaderBuffer, 4, vs, _uniformsMode2, noWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[3], shaderBuffer, 4, vs, _uniformsMode2, log);
|
||||
|
||||
shaderBuffer[1] = _renderMode4;
|
||||
shaderBuffer[2] = _interpolate;
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[4], shaderBuffer, 3, vs, _uniformsMode4, noWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[4], shaderBuffer, 3, vs, _uniformsMode4, log);
|
||||
|
||||
shaderBuffer[1] = _renderMode35;
|
||||
shaderBuffer[2] = _interpolate;
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[5], shaderBuffer, 3, vs, _uniformsMode35, noWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->bgShader[5], shaderBuffer, 3, vs, _uniformsMode35, log);
|
||||
|
||||
shaderBuffer[1] = _renderObj;
|
||||
|
||||
shaderBuffer[2] = _renderTile16;
|
||||
_compileShader(glRenderer, &glRenderer->objShader[0], shaderBuffer, 3, vs, _uniformsObj, window, log);
|
||||
_compileShader(glRenderer, &glRenderer->objShader[0], shaderBuffer, 3, vs, _uniformsObj, log);
|
||||
|
||||
shaderBuffer[2] = _renderTile256;
|
||||
_compileShader(glRenderer, &glRenderer->objShader[1], shaderBuffer, 3, vs, _uniformsObj, window, log);
|
||||
_compileShader(glRenderer, &glRenderer->objShader[1], shaderBuffer, 3, vs, _uniformsObj, log);
|
||||
|
||||
shaderBuffer[1] = _renderObjPriority;
|
||||
_compileShader(glRenderer, &glRenderer->objShader[2], shaderBuffer, 2, vs, _uniformsObjPriority, noWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->objShader[2], shaderBuffer, 2, vs, _uniformsObjPriority, log);
|
||||
|
||||
shaderBuffer[1] = _renderWindow;
|
||||
_compileShader(glRenderer, &glRenderer->windowShader, shaderBuffer, 2, vs, _uniformsWindow, onlyWindow, log);
|
||||
_compileShader(glRenderer, &glRenderer->windowShader, shaderBuffer, 2, vs, _uniformsWindow, log);
|
||||
|
||||
shaderBuffer[1] = _finalize;
|
||||
_compileShader(glRenderer, &glRenderer->finalizeShader, shaderBuffer, 2, vs, _uniformsFinalize, onlyColor, log);
|
||||
_compileShader(glRenderer, &glRenderer->finalizeShader, shaderBuffer, 2, vs, _uniformsFinalize, log);
|
||||
|
||||
glBindVertexArray(0);
|
||||
glDeleteShader(vs);
|
||||
|
|
|
@ -35,7 +35,7 @@ Display* Display::create(QWidget* parent) {
|
|||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES) {
|
||||
format.setVersion(2, 0);
|
||||
} else {
|
||||
format.setVersion(3, 2);
|
||||
format.setVersion(3, 3);
|
||||
}
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
if (DisplayGL::supportsFormat(format)) {
|
||||
|
|
Loading…
Reference in New Issue