diff options
author | bunnei <bunneidev@gmail.com> | 2015-08-11 17:19:45 -0400 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-08-11 17:19:45 -0400 |
commit | 93f607f5497a5fee142a0d2010881444a4ff0c80 (patch) | |
tree | 3728be088656eed0f4d53fde0f4ca194d640bf82 /src/video_core/renderer_opengl/gl_state.cpp | |
parent | df25b047f870d84bf7d37ccbbaf9bfb88a2ccd7f (diff) | |
parent | 254582aa35306c7bdebb90b0cd2dda88fe188087 (diff) |
Merge pull request #1023 from yuriks/gl-state-bugs
OpenGL: Fix state tracking in situations with reused object handles
Diffstat (limited to 'src/video_core/renderer_opengl/gl_state.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 9efc1533..87132401 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -40,7 +40,6 @@ OpenGLState::OpenGLState() { logic_op = GL_COPY; for (auto& texture_unit : texture_units) { - texture_unit.enabled_2d = false; texture_unit.texture_2d = 0; } @@ -147,16 +146,9 @@ void OpenGLState::Apply() { // Textures for (unsigned texture_index = 0; texture_index < ARRAY_SIZE(texture_units); ++texture_index) { - if (texture_units[texture_index].enabled_2d != cur_state.texture_units[texture_index].enabled_2d || - texture_units[texture_index].texture_2d != cur_state.texture_units[texture_index].texture_2d) { - + if (texture_units[texture_index].texture_2d != cur_state.texture_units[texture_index].texture_2d) { glActiveTexture(GL_TEXTURE0 + texture_index); - - if (texture_units[texture_index].enabled_2d) { - glBindTexture(GL_TEXTURE_2D, texture_units[texture_index].texture_2d); - } else { - glBindTexture(GL_TEXTURE_2D, 0); - } + glBindTexture(GL_TEXTURE_2D, texture_units[texture_index].texture_2d); } } @@ -182,3 +174,35 @@ void OpenGLState::Apply() { cur_state = *this; } + +void OpenGLState::ResetTexture(GLuint id) { + for (auto& unit : cur_state.texture_units) { + if (unit.texture_2d == id) { + unit.texture_2d = 0; + } + } +} + +void OpenGLState::ResetProgram(GLuint id) { + if (cur_state.draw.shader_program == id) { + cur_state.draw.shader_program = 0; + } +} + +void OpenGLState::ResetBuffer(GLuint id) { + if (cur_state.draw.vertex_buffer == id) { + cur_state.draw.vertex_buffer = 0; + } +} + +void OpenGLState::ResetVertexArray(GLuint id) { + if (cur_state.draw.vertex_array == id) { + cur_state.draw.vertex_array = 0; + } +} + +void OpenGLState::ResetFramebuffer(GLuint id) { + if (cur_state.draw.framebuffer == id) { + cur_state.draw.framebuffer = 0; + } +} |