From ab60414122184851415a27ae8bcacb4aab0504b6 Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 16 Jun 2017 14:00:15 +0300 Subject: gl_rasterizer/lighting: fix LUT interpolation --- src/video_core/renderer_opengl/gl_state.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_state.cpp') diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index bf837a7fb..40d7cee96 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -52,9 +52,7 @@ OpenGLState::OpenGLState() { texture_unit.sampler = 0; } - for (auto& lut : lighting_luts) { - lut.texture_1d = 0; - } + lighting_lut.texture_buffer = 0; fog_lut.texture_1d = 0; @@ -194,11 +192,9 @@ void OpenGLState::Apply() const { } // Lighting LUTs - for (unsigned i = 0; i < ARRAY_SIZE(lighting_luts); ++i) { - if (lighting_luts[i].texture_1d != cur_state.lighting_luts[i].texture_1d) { - glActiveTexture(GL_TEXTURE3 + i); - glBindTexture(GL_TEXTURE_1D, lighting_luts[i].texture_1d); - } + if (lighting_lut.texture_buffer != cur_state.lighting_lut.texture_buffer) { + glActiveTexture(GL_TEXTURE15); + glBindTexture(GL_TEXTURE_BUFFER, cur_state.lighting_lut.texture_buffer); } // Fog LUT -- cgit v1.2.3 From be9e952bdc33b6763618ee66046ce84c0ff18a34 Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 16 Jun 2017 16:16:28 +0300 Subject: gl_rasterizer: manage texture ids in one place --- src/video_core/renderer_opengl/gl_state.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_state.cpp') diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 40d7cee96..6ef6d6c4c 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -183,7 +183,7 @@ void OpenGLState::Apply() const { // Textures for (unsigned i = 0; i < ARRAY_SIZE(texture_units); ++i) { if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) { - glActiveTexture(GL_TEXTURE0 + i); + glActiveTexture(TextureUnits::PicaTexture(i).Enum()); glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d); } if (texture_units[i].sampler != cur_state.texture_units[i].sampler) { @@ -193,43 +193,43 @@ void OpenGLState::Apply() const { // Lighting LUTs if (lighting_lut.texture_buffer != cur_state.lighting_lut.texture_buffer) { - glActiveTexture(GL_TEXTURE15); + glActiveTexture(TextureUnits::LightingLUT.Enum()); glBindTexture(GL_TEXTURE_BUFFER, cur_state.lighting_lut.texture_buffer); } // Fog LUT if (fog_lut.texture_1d != cur_state.fog_lut.texture_1d) { - glActiveTexture(GL_TEXTURE9); + glActiveTexture(TextureUnits::FogLUT.Enum()); glBindTexture(GL_TEXTURE_1D, fog_lut.texture_1d); } // ProcTex Noise LUT if (proctex_noise_lut.texture_1d != cur_state.proctex_noise_lut.texture_1d) { - glActiveTexture(GL_TEXTURE10); + glActiveTexture(TextureUnits::ProcTexNoiseLUT.Enum()); glBindTexture(GL_TEXTURE_1D, proctex_noise_lut.texture_1d); } // ProcTex Color Map if (proctex_color_map.texture_1d != cur_state.proctex_color_map.texture_1d) { - glActiveTexture(GL_TEXTURE11); + glActiveTexture(TextureUnits::ProcTexColorMap.Enum()); glBindTexture(GL_TEXTURE_1D, proctex_color_map.texture_1d); } // ProcTex Alpha Map if (proctex_alpha_map.texture_1d != cur_state.proctex_alpha_map.texture_1d) { - glActiveTexture(GL_TEXTURE12); + glActiveTexture(TextureUnits::ProcTexAlphaMap.Enum()); glBindTexture(GL_TEXTURE_1D, proctex_alpha_map.texture_1d); } // ProcTex LUT if (proctex_lut.texture_1d != cur_state.proctex_lut.texture_1d) { - glActiveTexture(GL_TEXTURE13); + glActiveTexture(TextureUnits::ProcTexLUT.Enum()); glBindTexture(GL_TEXTURE_1D, proctex_lut.texture_1d); } // ProcTex Diff LUT if (proctex_diff_lut.texture_1d != cur_state.proctex_diff_lut.texture_1d) { - glActiveTexture(GL_TEXTURE14); + glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum()); glBindTexture(GL_TEXTURE_1D, proctex_diff_lut.texture_1d); } -- cgit v1.2.3 From 457659fe01891122881d8020da79c11732820913 Mon Sep 17 00:00:00 2001 From: wwylele Date: Fri, 16 Jun 2017 22:22:24 +0300 Subject: gl_state: reset 1d textures --- src/video_core/renderer_opengl/gl_state.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/video_core/renderer_opengl/gl_state.cpp') diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 6ef6d6c4c..14e63115c 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -270,6 +270,20 @@ void OpenGLState::ResetTexture(GLuint handle) { unit.texture_2d = 0; } } + if (cur_state.lighting_lut.texture_buffer == handle) + cur_state.lighting_lut.texture_buffer = 0; + if (cur_state.fog_lut.texture_1d == handle) + cur_state.fog_lut.texture_1d = 0; + if (cur_state.proctex_noise_lut.texture_1d == handle) + cur_state.proctex_noise_lut.texture_1d = 0; + if (cur_state.proctex_color_map.texture_1d == handle) + cur_state.proctex_color_map.texture_1d = 0; + if (cur_state.proctex_alpha_map.texture_1d == handle) + cur_state.proctex_alpha_map.texture_1d = 0; + if (cur_state.proctex_lut.texture_1d == handle) + cur_state.proctex_lut.texture_1d = 0; + if (cur_state.proctex_diff_lut.texture_1d == handle) + cur_state.proctex_diff_lut.texture_1d = 0; } void OpenGLState::ResetSampler(GLuint handle) { -- cgit v1.2.3