diff options
author | bunnei <bunneidev@gmail.com> | 2019-02-07 02:17:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-07 02:17:59 +0100 |
commit | 40ac0585574499bc0dee47c4bef354c8e5676695 (patch) | |
tree | 096b8e8c32f4affbd791386daa4b1feac2d9bedc /src/video_core/renderer_opengl/gl_state.cpp | |
parent | Merge pull request #2057 from FearlessTobi/port-4586 (diff) | |
parent | gl_rasterizer_cache: Fixup test clause (diff) | |
download | yuzu-40ac0585574499bc0dee47c4bef354c8e5676695.tar yuzu-40ac0585574499bc0dee47c4bef354c8e5676695.tar.gz yuzu-40ac0585574499bc0dee47c4bef354c8e5676695.tar.bz2 yuzu-40ac0585574499bc0dee47c4bef354c8e5676695.tar.lz yuzu-40ac0585574499bc0dee47c4bef354c8e5676695.tar.xz yuzu-40ac0585574499bc0dee47c4bef354c8e5676695.tar.zst yuzu-40ac0585574499bc0dee47c4bef354c8e5676695.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_state.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index b7ba59350..81af803bc 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -462,29 +462,35 @@ void OpenGLState::ApplyPolygonOffset() const { } void OpenGLState::ApplyTextures() const { + bool has_delta{}; + std::size_t first{}; + std::size_t last{}; + std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> textures; + for (std::size_t i = 0; i < std::size(texture_units); ++i) { const auto& texture_unit = texture_units[i]; const auto& cur_state_texture_unit = cur_state.texture_units[i]; + textures[i] = texture_unit.texture; - if (texture_unit.texture != cur_state_texture_unit.texture) { - glActiveTexture(TextureUnits::MaxwellTexture(static_cast<int>(i)).Enum()); - glBindTexture(texture_unit.target, texture_unit.texture); - } - // Update the texture swizzle - if (texture_unit.swizzle.r != cur_state_texture_unit.swizzle.r || - texture_unit.swizzle.g != cur_state_texture_unit.swizzle.g || - texture_unit.swizzle.b != cur_state_texture_unit.swizzle.b || - texture_unit.swizzle.a != cur_state_texture_unit.swizzle.a) { - std::array<GLint, 4> mask = {texture_unit.swizzle.r, texture_unit.swizzle.g, - texture_unit.swizzle.b, texture_unit.swizzle.a}; - glTexParameteriv(texture_unit.target, GL_TEXTURE_SWIZZLE_RGBA, mask.data()); + if (textures[i] != cur_state_texture_unit.texture) { + if (!has_delta) { + first = i; + has_delta = true; + } + last = i; } } + + if (has_delta) { + glBindTextures(static_cast<GLuint>(first), static_cast<GLsizei>(last - first + 1), + textures.data()); + } } void OpenGLState::ApplySamplers() const { bool has_delta{}; - std::size_t first{}, last{}; + std::size_t first{}; + std::size_t last{}; std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> samplers; for (std::size_t i = 0; i < std::size(samplers); ++i) { samplers[i] = texture_units[i].sampler; |