diff options
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 2e8a422a8..8eced0480 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -181,28 +181,31 @@ void OpenGLState::Apply() const { | |||
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | // Textures | 183 | // Textures |
| 184 | for (int i = 0; i < std::size(texture_units); ++i) { | 184 | for (std::size_t i = 0; i < std::size(texture_units); ++i) { |
| 185 | if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) { | 185 | const auto& texture_unit = texture_units[i]; |
| 186 | glActiveTexture(TextureUnits::MaxwellTexture(i).Enum()); | 186 | const auto& cur_state_texture_unit = cur_state.texture_units[i]; |
| 187 | glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d); | 187 | |
| 188 | if (texture_unit.texture_2d != cur_state_texture_unit.texture_2d) { | ||
| 189 | glActiveTexture(TextureUnits::MaxwellTexture(static_cast<int>(i)).Enum()); | ||
| 190 | glBindTexture(GL_TEXTURE_2D, texture_unit.texture_2d); | ||
| 188 | } | 191 | } |
| 189 | if (texture_units[i].sampler != cur_state.texture_units[i].sampler) { | 192 | if (texture_unit.sampler != cur_state_texture_unit.sampler) { |
| 190 | glBindSampler(static_cast<GLuint>(i), texture_units[i].sampler); | 193 | glBindSampler(static_cast<GLuint>(i), texture_unit.sampler); |
| 191 | } | 194 | } |
| 192 | // Update the texture swizzle | 195 | // Update the texture swizzle |
| 193 | if (texture_units[i].swizzle.r != cur_state.texture_units[i].swizzle.r || | 196 | if (texture_unit.swizzle.r != cur_state_texture_unit.swizzle.r || |
| 194 | texture_units[i].swizzle.g != cur_state.texture_units[i].swizzle.g || | 197 | texture_unit.swizzle.g != cur_state_texture_unit.swizzle.g || |
| 195 | texture_units[i].swizzle.b != cur_state.texture_units[i].swizzle.b || | 198 | texture_unit.swizzle.b != cur_state_texture_unit.swizzle.b || |
| 196 | texture_units[i].swizzle.a != cur_state.texture_units[i].swizzle.a) { | 199 | texture_unit.swizzle.a != cur_state_texture_unit.swizzle.a) { |
| 197 | std::array<GLint, 4> mask = {texture_units[i].swizzle.r, texture_units[i].swizzle.g, | 200 | std::array<GLint, 4> mask = {texture_unit.swizzle.r, texture_unit.swizzle.g, |
| 198 | texture_units[i].swizzle.b, texture_units[i].swizzle.a}; | 201 | texture_unit.swizzle.b, texture_unit.swizzle.a}; |
| 199 | glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, mask.data()); | 202 | glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, mask.data()); |
| 200 | } | 203 | } |
| 201 | } | 204 | } |
| 202 | 205 | ||
| 203 | // Constbuffers | 206 | // Constbuffers |
| 204 | for (u32 stage = 0; stage < draw.const_buffers.size(); ++stage) { | 207 | for (std::size_t stage = 0; stage < draw.const_buffers.size(); ++stage) { |
| 205 | for (u32 buffer_id = 0; buffer_id < draw.const_buffers[stage].size(); ++buffer_id) { | 208 | for (std::size_t buffer_id = 0; buffer_id < draw.const_buffers[stage].size(); ++buffer_id) { |
| 206 | auto& current = cur_state.draw.const_buffers[stage][buffer_id]; | 209 | auto& current = cur_state.draw.const_buffers[stage][buffer_id]; |
| 207 | auto& new_state = draw.const_buffers[stage][buffer_id]; | 210 | auto& new_state = draw.const_buffers[stage][buffer_id]; |
| 208 | if (current.enabled != new_state.enabled || current.bindpoint != new_state.bindpoint || | 211 | if (current.enabled != new_state.enabled || current.bindpoint != new_state.bindpoint || |