gl_rasterizer_cache: Move swizzling to textures instead of state

This commit is contained in:
ReinUsesLisp
2019-01-06 23:02:27 -03:00
parent 3bbaa98c78
commit 704744bb72
6 changed files with 35 additions and 28 deletions

View File

@@ -463,7 +463,8 @@ void OpenGLState::ApplyPolygonOffset() const {
void OpenGLState::ApplyTextures() 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> textures;
for (std::size_t i = 0; i < std::size(texture_units); ++i) {
@@ -478,16 +479,6 @@ void OpenGLState::ApplyTextures() const {
}
last = i;
}
// Update the texture swizzle
if (textures[i] != 0 && (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};
glTextureParameteriv(texture_unit.texture, GL_TEXTURE_SWIZZLE_RGBA, mask.data());
}
}
if (has_delta) {
@@ -498,7 +489,8 @@ void OpenGLState::ApplyTextures() const {
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;