diff options
| author | 2019-01-06 22:36:51 -0300 | |
|---|---|---|
| committer | 2019-01-30 19:10:11 -0300 | |
| commit | 3bbaa98c78da8a45227fcd7abd82532f6f49851b (patch) | |
| tree | 09ab4453d0673e61ea5d179d3b10211e4a52d56f /src/video_core | |
| parent | gl_rasterizer: Use DSA for textures (diff) | |
| download | yuzu-3bbaa98c78da8a45227fcd7abd82532f6f49851b.tar.gz yuzu-3bbaa98c78da8a45227fcd7abd82532f6f49851b.tar.xz yuzu-3bbaa98c78da8a45227fcd7abd82532f6f49851b.zip | |
gl_state: Use DSA and multi bind to update texture bindings
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index b7ba59350..997325efc 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -462,24 +462,38 @@ void OpenGLState::ApplyPolygonOffset() const { | |||
| 462 | } | 462 | } |
| 463 | 463 | ||
| 464 | void OpenGLState::ApplyTextures() const { | 464 | void OpenGLState::ApplyTextures() const { |
| 465 | bool has_delta{}; | ||
| 466 | std::size_t first{}, last{}; | ||
| 467 | std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> textures; | ||
| 468 | |||
| 465 | for (std::size_t i = 0; i < std::size(texture_units); ++i) { | 469 | for (std::size_t i = 0; i < std::size(texture_units); ++i) { |
| 466 | const auto& texture_unit = texture_units[i]; | 470 | const auto& texture_unit = texture_units[i]; |
| 467 | const auto& cur_state_texture_unit = cur_state.texture_units[i]; | 471 | const auto& cur_state_texture_unit = cur_state.texture_units[i]; |
| 472 | textures[i] = texture_unit.texture; | ||
| 468 | 473 | ||
| 469 | if (texture_unit.texture != cur_state_texture_unit.texture) { | 474 | if (textures[i] != cur_state_texture_unit.texture) { |
| 470 | glActiveTexture(TextureUnits::MaxwellTexture(static_cast<int>(i)).Enum()); | 475 | if (!has_delta) { |
| 471 | glBindTexture(texture_unit.target, texture_unit.texture); | 476 | first = i; |
| 477 | has_delta = true; | ||
| 478 | } | ||
| 479 | last = i; | ||
| 472 | } | 480 | } |
| 481 | |||
| 473 | // Update the texture swizzle | 482 | // Update the texture swizzle |
| 474 | if (texture_unit.swizzle.r != cur_state_texture_unit.swizzle.r || | 483 | if (textures[i] != 0 && (texture_unit.swizzle.r != cur_state_texture_unit.swizzle.r || |
| 475 | texture_unit.swizzle.g != cur_state_texture_unit.swizzle.g || | 484 | texture_unit.swizzle.g != cur_state_texture_unit.swizzle.g || |
| 476 | texture_unit.swizzle.b != cur_state_texture_unit.swizzle.b || | 485 | texture_unit.swizzle.b != cur_state_texture_unit.swizzle.b || |
| 477 | texture_unit.swizzle.a != cur_state_texture_unit.swizzle.a) { | 486 | texture_unit.swizzle.a != cur_state_texture_unit.swizzle.a)) { |
| 478 | std::array<GLint, 4> mask = {texture_unit.swizzle.r, texture_unit.swizzle.g, | 487 | std::array<GLint, 4> mask = {texture_unit.swizzle.r, texture_unit.swizzle.g, |
| 479 | texture_unit.swizzle.b, texture_unit.swizzle.a}; | 488 | texture_unit.swizzle.b, texture_unit.swizzle.a}; |
| 480 | glTexParameteriv(texture_unit.target, GL_TEXTURE_SWIZZLE_RGBA, mask.data()); | 489 | glTextureParameteriv(texture_unit.texture, GL_TEXTURE_SWIZZLE_RGBA, mask.data()); |
| 481 | } | 490 | } |
| 482 | } | 491 | } |
| 492 | |||
| 493 | if (has_delta) { | ||
| 494 | glBindTextures(static_cast<GLuint>(first), static_cast<GLsizei>(last - first + 1), | ||
| 495 | textures.data()); | ||
| 496 | } | ||
| 483 | } | 497 | } |
| 484 | 498 | ||
| 485 | void OpenGLState::ApplySamplers() const { | 499 | void OpenGLState::ApplySamplers() const { |