summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar wwylele2017-06-16 16:16:28 +0300
committerGravatar wwylele2017-06-21 23:13:06 +0300
commitbe9e952bdc33b6763618ee66046ce84c0ff18a34 (patch)
tree61c048fc5e0e8808b2d992cc2ee2bc627672a70e /src
parentgl_rasterizer/lighting: fix LUT interpolation (diff)
downloadyuzu-be9e952bdc33b6763618ee66046ce84c0ff18a34.tar.gz
yuzu-be9e952bdc33b6763618ee66046ce84c0ff18a34.tar.xz
yuzu-be9e952bdc33b6763618ee66046ce84c0ff18a34.zip
gl_rasterizer: manage texture ids in one place
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp47
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp16
-rw-r--r--src/video_core/renderer_opengl/gl_state.h23
3 files changed, 55 insertions, 31 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index c73e1d6e2..c018afbcc 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -102,7 +102,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
102 glBufferData(GL_TEXTURE_BUFFER, 102 glBufferData(GL_TEXTURE_BUFFER,
103 sizeof(GLfloat) * 2 * 256 * Pica::LightingRegs::NumLightingSampler, nullptr, 103 sizeof(GLfloat) * 2 * 256 * Pica::LightingRegs::NumLightingSampler, nullptr,
104 GL_DYNAMIC_DRAW); 104 GL_DYNAMIC_DRAW);
105 glActiveTexture(GL_TEXTURE15); 105 glActiveTexture(TextureUnits::LightingLUT.Enum());
106 glTexBuffer(GL_TEXTURE_BUFFER, GL_RG32F, lighting_lut_buffer.handle); 106 glTexBuffer(GL_TEXTURE_BUFFER, GL_RG32F, lighting_lut_buffer.handle);
107 107
108 // Setup the LUT for the fog 108 // Setup the LUT for the fog
@@ -112,7 +112,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
112 } 112 }
113 state.Apply(); 113 state.Apply();
114 114
115 glActiveTexture(GL_TEXTURE9); 115 glActiveTexture(TextureUnits::FogLUT.Enum());
116 glTexImage1D(GL_TEXTURE_1D, 0, GL_R32UI, 128, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, nullptr); 116 glTexImage1D(GL_TEXTURE_1D, 0, GL_R32UI, 128, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, nullptr);
117 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 117 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
118 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 118 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -121,7 +121,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
121 proctex_noise_lut.Create(); 121 proctex_noise_lut.Create();
122 state.proctex_noise_lut.texture_1d = proctex_noise_lut.handle; 122 state.proctex_noise_lut.texture_1d = proctex_noise_lut.handle;
123 state.Apply(); 123 state.Apply();
124 glActiveTexture(GL_TEXTURE10); 124 glActiveTexture(TextureUnits::ProcTexNoiseLUT.Enum());
125 glTexImage1D(GL_TEXTURE_1D, 0, GL_RG32F, 128, 0, GL_RG, GL_FLOAT, nullptr); 125 glTexImage1D(GL_TEXTURE_1D, 0, GL_RG32F, 128, 0, GL_RG, GL_FLOAT, nullptr);
126 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 126 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
127 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 127 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -130,7 +130,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
130 proctex_color_map.Create(); 130 proctex_color_map.Create();
131 state.proctex_color_map.texture_1d = proctex_color_map.handle; 131 state.proctex_color_map.texture_1d = proctex_color_map.handle;
132 state.Apply(); 132 state.Apply();
133 glActiveTexture(GL_TEXTURE11); 133 glActiveTexture(TextureUnits::ProcTexColorMap.Enum());
134 glTexImage1D(GL_TEXTURE_1D, 0, GL_RG32F, 128, 0, GL_RG, GL_FLOAT, nullptr); 134 glTexImage1D(GL_TEXTURE_1D, 0, GL_RG32F, 128, 0, GL_RG, GL_FLOAT, nullptr);
135 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 135 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
136 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 136 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -139,7 +139,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
139 proctex_alpha_map.Create(); 139 proctex_alpha_map.Create();
140 state.proctex_alpha_map.texture_1d = proctex_alpha_map.handle; 140 state.proctex_alpha_map.texture_1d = proctex_alpha_map.handle;
141 state.Apply(); 141 state.Apply();
142 glActiveTexture(GL_TEXTURE12); 142 glActiveTexture(TextureUnits::ProcTexAlphaMap.Enum());
143 glTexImage1D(GL_TEXTURE_1D, 0, GL_RG32F, 128, 0, GL_RG, GL_FLOAT, nullptr); 143 glTexImage1D(GL_TEXTURE_1D, 0, GL_RG32F, 128, 0, GL_RG, GL_FLOAT, nullptr);
144 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 144 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
145 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 145 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -148,7 +148,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
148 proctex_lut.Create(); 148 proctex_lut.Create();
149 state.proctex_lut.texture_1d = proctex_lut.handle; 149 state.proctex_lut.texture_1d = proctex_lut.handle;
150 state.Apply(); 150 state.Apply();
151 glActiveTexture(GL_TEXTURE13); 151 glActiveTexture(TextureUnits::ProcTexLUT.Enum());
152 glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 256, 0, GL_RGBA, GL_FLOAT, nullptr); 152 glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 256, 0, GL_RGBA, GL_FLOAT, nullptr);
153 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 153 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
154 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 154 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -157,7 +157,7 @@ RasterizerOpenGL::RasterizerOpenGL() : shader_dirty(true) {
157 proctex_diff_lut.Create(); 157 proctex_diff_lut.Create();
158 state.proctex_diff_lut.texture_1d = proctex_diff_lut.handle; 158 state.proctex_diff_lut.texture_1d = proctex_diff_lut.handle;
159 state.Apply(); 159 state.Apply();
160 glActiveTexture(GL_TEXTURE14); 160 glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum());
161 glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 256, 0, GL_RGBA, GL_FLOAT, nullptr); 161 glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 256, 0, GL_RGBA, GL_FLOAT, nullptr);
162 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 162 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
163 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 163 glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -1185,55 +1185,55 @@ void RasterizerOpenGL::SetShader() {
1185 // Set the texture samplers to correspond to different texture units 1185 // Set the texture samplers to correspond to different texture units
1186 GLuint uniform_tex = glGetUniformLocation(shader->shader.handle, "tex[0]"); 1186 GLuint uniform_tex = glGetUniformLocation(shader->shader.handle, "tex[0]");
1187 if (uniform_tex != -1) { 1187 if (uniform_tex != -1) {
1188 glUniform1i(uniform_tex, 0); 1188 glUniform1i(uniform_tex, TextureUnits::PicaTexture(0).id);
1189 } 1189 }
1190 uniform_tex = glGetUniformLocation(shader->shader.handle, "tex[1]"); 1190 uniform_tex = glGetUniformLocation(shader->shader.handle, "tex[1]");
1191 if (uniform_tex != -1) { 1191 if (uniform_tex != -1) {
1192 glUniform1i(uniform_tex, 1); 1192 glUniform1i(uniform_tex, TextureUnits::PicaTexture(1).id);
1193 } 1193 }
1194 uniform_tex = glGetUniformLocation(shader->shader.handle, "tex[2]"); 1194 uniform_tex = glGetUniformLocation(shader->shader.handle, "tex[2]");
1195 if (uniform_tex != -1) { 1195 if (uniform_tex != -1) {
1196 glUniform1i(uniform_tex, 2); 1196 glUniform1i(uniform_tex, TextureUnits::PicaTexture(2).id);
1197 } 1197 }
1198 1198
1199 // Set the texture samplers to correspond to different lookup table texture units 1199 // Set the texture samplers to correspond to different lookup table texture units
1200 GLuint uniform_lut = glGetUniformLocation(shader->shader.handle, "lighting_lut"); 1200 GLuint uniform_lut = glGetUniformLocation(shader->shader.handle, "lighting_lut");
1201 if (uniform_lut != -1) { 1201 if (uniform_lut != -1) {
1202 glUniform1i(uniform_lut, 15); 1202 glUniform1i(uniform_lut, TextureUnits::LightingLUT.id);
1203 } 1203 }
1204 1204
1205 GLuint uniform_fog_lut = glGetUniformLocation(shader->shader.handle, "fog_lut"); 1205 GLuint uniform_fog_lut = glGetUniformLocation(shader->shader.handle, "fog_lut");
1206 if (uniform_fog_lut != -1) { 1206 if (uniform_fog_lut != -1) {
1207 glUniform1i(uniform_fog_lut, 9); 1207 glUniform1i(uniform_fog_lut, TextureUnits::FogLUT.id);
1208 } 1208 }
1209 1209
1210 GLuint uniform_proctex_noise_lut = 1210 GLuint uniform_proctex_noise_lut =
1211 glGetUniformLocation(shader->shader.handle, "proctex_noise_lut"); 1211 glGetUniformLocation(shader->shader.handle, "proctex_noise_lut");
1212 if (uniform_proctex_noise_lut != -1) { 1212 if (uniform_proctex_noise_lut != -1) {
1213 glUniform1i(uniform_proctex_noise_lut, 10); 1213 glUniform1i(uniform_proctex_noise_lut, TextureUnits::ProcTexNoiseLUT.id);
1214 } 1214 }
1215 1215
1216 GLuint uniform_proctex_color_map = 1216 GLuint uniform_proctex_color_map =
1217 glGetUniformLocation(shader->shader.handle, "proctex_color_map"); 1217 glGetUniformLocation(shader->shader.handle, "proctex_color_map");
1218 if (uniform_proctex_color_map != -1) { 1218 if (uniform_proctex_color_map != -1) {
1219 glUniform1i(uniform_proctex_color_map, 11); 1219 glUniform1i(uniform_proctex_color_map, TextureUnits::ProcTexColorMap.id);
1220 } 1220 }
1221 1221
1222 GLuint uniform_proctex_alpha_map = 1222 GLuint uniform_proctex_alpha_map =
1223 glGetUniformLocation(shader->shader.handle, "proctex_alpha_map"); 1223 glGetUniformLocation(shader->shader.handle, "proctex_alpha_map");
1224 if (uniform_proctex_alpha_map != -1) { 1224 if (uniform_proctex_alpha_map != -1) {
1225 glUniform1i(uniform_proctex_alpha_map, 12); 1225 glUniform1i(uniform_proctex_alpha_map, TextureUnits::ProcTexAlphaMap.id);
1226 } 1226 }
1227 1227
1228 GLuint uniform_proctex_lut = glGetUniformLocation(shader->shader.handle, "proctex_lut"); 1228 GLuint uniform_proctex_lut = glGetUniformLocation(shader->shader.handle, "proctex_lut");
1229 if (uniform_proctex_lut != -1) { 1229 if (uniform_proctex_lut != -1) {
1230 glUniform1i(uniform_proctex_lut, 13); 1230 glUniform1i(uniform_proctex_lut, TextureUnits::ProcTexLUT.id);
1231 } 1231 }
1232 1232
1233 GLuint uniform_proctex_diff_lut = 1233 GLuint uniform_proctex_diff_lut =
1234 glGetUniformLocation(shader->shader.handle, "proctex_diff_lut"); 1234 glGetUniformLocation(shader->shader.handle, "proctex_diff_lut");
1235 if (uniform_proctex_diff_lut != -1) { 1235 if (uniform_proctex_diff_lut != -1) {
1236 glUniform1i(uniform_proctex_diff_lut, 14); 1236 glUniform1i(uniform_proctex_diff_lut, TextureUnits::ProcTexDiffLUT.id);
1237 } 1237 }
1238 1238
1239 current_shader = shader_cache.emplace(config, std::move(shader)).first->second.get(); 1239 current_shader = shader_cache.emplace(config, std::move(shader)).first->second.get();
@@ -1363,7 +1363,7 @@ void RasterizerOpenGL::SyncFogLUT() {
1363 1363
1364 if (new_data != fog_lut_data) { 1364 if (new_data != fog_lut_data) {
1365 fog_lut_data = new_data; 1365 fog_lut_data = new_data;
1366 glActiveTexture(GL_TEXTURE9); 1366 glActiveTexture(TextureUnits::FogLUT.Enum());
1367 glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 128, GL_RED_INTEGER, GL_UNSIGNED_INT, 1367 glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 128, GL_RED_INTEGER, GL_UNSIGNED_INT,
1368 fog_lut_data.data()); 1368 fog_lut_data.data());
1369 } 1369 }
@@ -1402,17 +1402,18 @@ static void SyncProcTexValueLUT(const std::array<Pica::State::ProcTex::ValueEntr
1402} 1402}
1403 1403
1404void RasterizerOpenGL::SyncProcTexNoiseLUT() { 1404void RasterizerOpenGL::SyncProcTexNoiseLUT() {
1405 SyncProcTexValueLUT(Pica::g_state.proctex.noise_table, proctex_noise_lut_data, GL_TEXTURE10); 1405 SyncProcTexValueLUT(Pica::g_state.proctex.noise_table, proctex_noise_lut_data,
1406 TextureUnits::ProcTexNoiseLUT.Enum());
1406} 1407}
1407 1408
1408void RasterizerOpenGL::SyncProcTexColorMap() { 1409void RasterizerOpenGL::SyncProcTexColorMap() {
1409 SyncProcTexValueLUT(Pica::g_state.proctex.color_map_table, proctex_color_map_data, 1410 SyncProcTexValueLUT(Pica::g_state.proctex.color_map_table, proctex_color_map_data,
1410 GL_TEXTURE11); 1411 TextureUnits::ProcTexColorMap.Enum());
1411} 1412}
1412 1413
1413void RasterizerOpenGL::SyncProcTexAlphaMap() { 1414void RasterizerOpenGL::SyncProcTexAlphaMap() {
1414 SyncProcTexValueLUT(Pica::g_state.proctex.alpha_map_table, proctex_alpha_map_data, 1415 SyncProcTexValueLUT(Pica::g_state.proctex.alpha_map_table, proctex_alpha_map_data,
1415 GL_TEXTURE12); 1416 TextureUnits::ProcTexAlphaMap.Enum());
1416} 1417}
1417 1418
1418void RasterizerOpenGL::SyncProcTexLUT() { 1419void RasterizerOpenGL::SyncProcTexLUT() {
@@ -1427,7 +1428,7 @@ void RasterizerOpenGL::SyncProcTexLUT() {
1427 1428
1428 if (new_data != proctex_lut_data) { 1429 if (new_data != proctex_lut_data) {
1429 proctex_lut_data = new_data; 1430 proctex_lut_data = new_data;
1430 glActiveTexture(GL_TEXTURE13); 1431 glActiveTexture(TextureUnits::ProcTexLUT.Enum());
1431 glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RGBA, GL_FLOAT, proctex_lut_data.data()); 1432 glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RGBA, GL_FLOAT, proctex_lut_data.data());
1432 } 1433 }
1433} 1434}
@@ -1444,7 +1445,7 @@ void RasterizerOpenGL::SyncProcTexDiffLUT() {
1444 1445
1445 if (new_data != proctex_diff_lut_data) { 1446 if (new_data != proctex_diff_lut_data) {
1446 proctex_diff_lut_data = new_data; 1447 proctex_diff_lut_data = new_data;
1447 glActiveTexture(GL_TEXTURE14); 1448 glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum());
1448 glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RGBA, GL_FLOAT, proctex_diff_lut_data.data()); 1449 glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 256, GL_RGBA, GL_FLOAT, proctex_diff_lut_data.data());
1449 } 1450 }
1450} 1451}
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 {
183 // Textures 183 // Textures
184 for (unsigned i = 0; i < ARRAY_SIZE(texture_units); ++i) { 184 for (unsigned i = 0; i < ARRAY_SIZE(texture_units); ++i) {
185 if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) { 185 if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) {
186 glActiveTexture(GL_TEXTURE0 + i); 186 glActiveTexture(TextureUnits::PicaTexture(i).Enum());
187 glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d); 187 glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d);
188 } 188 }
189 if (texture_units[i].sampler != cur_state.texture_units[i].sampler) { 189 if (texture_units[i].sampler != cur_state.texture_units[i].sampler) {
@@ -193,43 +193,43 @@ void OpenGLState::Apply() const {
193 193
194 // Lighting LUTs 194 // Lighting LUTs
195 if (lighting_lut.texture_buffer != cur_state.lighting_lut.texture_buffer) { 195 if (lighting_lut.texture_buffer != cur_state.lighting_lut.texture_buffer) {
196 glActiveTexture(GL_TEXTURE15); 196 glActiveTexture(TextureUnits::LightingLUT.Enum());
197 glBindTexture(GL_TEXTURE_BUFFER, cur_state.lighting_lut.texture_buffer); 197 glBindTexture(GL_TEXTURE_BUFFER, cur_state.lighting_lut.texture_buffer);
198 } 198 }
199 199
200 // Fog LUT 200 // Fog LUT
201 if (fog_lut.texture_1d != cur_state.fog_lut.texture_1d) { 201 if (fog_lut.texture_1d != cur_state.fog_lut.texture_1d) {
202 glActiveTexture(GL_TEXTURE9); 202 glActiveTexture(TextureUnits::FogLUT.Enum());
203 glBindTexture(GL_TEXTURE_1D, fog_lut.texture_1d); 203 glBindTexture(GL_TEXTURE_1D, fog_lut.texture_1d);
204 } 204 }
205 205
206 // ProcTex Noise LUT 206 // ProcTex Noise LUT
207 if (proctex_noise_lut.texture_1d != cur_state.proctex_noise_lut.texture_1d) { 207 if (proctex_noise_lut.texture_1d != cur_state.proctex_noise_lut.texture_1d) {
208 glActiveTexture(GL_TEXTURE10); 208 glActiveTexture(TextureUnits::ProcTexNoiseLUT.Enum());
209 glBindTexture(GL_TEXTURE_1D, proctex_noise_lut.texture_1d); 209 glBindTexture(GL_TEXTURE_1D, proctex_noise_lut.texture_1d);
210 } 210 }
211 211
212 // ProcTex Color Map 212 // ProcTex Color Map
213 if (proctex_color_map.texture_1d != cur_state.proctex_color_map.texture_1d) { 213 if (proctex_color_map.texture_1d != cur_state.proctex_color_map.texture_1d) {
214 glActiveTexture(GL_TEXTURE11); 214 glActiveTexture(TextureUnits::ProcTexColorMap.Enum());
215 glBindTexture(GL_TEXTURE_1D, proctex_color_map.texture_1d); 215 glBindTexture(GL_TEXTURE_1D, proctex_color_map.texture_1d);
216 } 216 }
217 217
218 // ProcTex Alpha Map 218 // ProcTex Alpha Map
219 if (proctex_alpha_map.texture_1d != cur_state.proctex_alpha_map.texture_1d) { 219 if (proctex_alpha_map.texture_1d != cur_state.proctex_alpha_map.texture_1d) {
220 glActiveTexture(GL_TEXTURE12); 220 glActiveTexture(TextureUnits::ProcTexAlphaMap.Enum());
221 glBindTexture(GL_TEXTURE_1D, proctex_alpha_map.texture_1d); 221 glBindTexture(GL_TEXTURE_1D, proctex_alpha_map.texture_1d);
222 } 222 }
223 223
224 // ProcTex LUT 224 // ProcTex LUT
225 if (proctex_lut.texture_1d != cur_state.proctex_lut.texture_1d) { 225 if (proctex_lut.texture_1d != cur_state.proctex_lut.texture_1d) {
226 glActiveTexture(GL_TEXTURE13); 226 glActiveTexture(TextureUnits::ProcTexLUT.Enum());
227 glBindTexture(GL_TEXTURE_1D, proctex_lut.texture_1d); 227 glBindTexture(GL_TEXTURE_1D, proctex_lut.texture_1d);
228 } 228 }
229 229
230 // ProcTex Diff LUT 230 // ProcTex Diff LUT
231 if (proctex_diff_lut.texture_1d != cur_state.proctex_diff_lut.texture_1d) { 231 if (proctex_diff_lut.texture_1d != cur_state.proctex_diff_lut.texture_1d) {
232 glActiveTexture(GL_TEXTURE14); 232 glActiveTexture(TextureUnits::ProcTexDiffLUT.Enum());
233 glBindTexture(GL_TEXTURE_1D, proctex_diff_lut.texture_1d); 233 glBindTexture(GL_TEXTURE_1D, proctex_diff_lut.texture_1d);
234 } 234 }
235 235
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index d524d0625..bb0218708 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -6,6 +6,29 @@
6 6
7#include <glad/glad.h> 7#include <glad/glad.h>
8 8
9namespace TextureUnits {
10
11struct TextureUnit {
12 GLint id;
13 constexpr GLenum Enum() const {
14 return static_cast<GLenum>(GL_TEXTURE0 + id);
15 }
16};
17
18constexpr TextureUnit PicaTexture(int unit) {
19 return TextureUnit{unit};
20}
21
22constexpr TextureUnit LightingLUT{3};
23constexpr TextureUnit FogLUT{4};
24constexpr TextureUnit ProcTexNoiseLUT{5};
25constexpr TextureUnit ProcTexColorMap{6};
26constexpr TextureUnit ProcTexAlphaMap{7};
27constexpr TextureUnit ProcTexLUT{8};
28constexpr TextureUnit ProcTexDiffLUT{9};
29
30} // namespace TextureUnits
31
9class OpenGLState { 32class OpenGLState {
10public: 33public:
11 struct { 34 struct {