summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-01-26 17:11:49 -0300
committerGravatar ReinUsesLisp2020-01-26 21:44:08 -0300
commitd17dfa610418e2057e65b2fd3ab28a46249f4b83 (patch)
tree9d6e927970f1ee4d8a49a9932f5d439b3fb61d38 /src
parentMerge pull request #3343 from FearlessTobi/ui-tab (diff)
downloadyuzu-d17dfa610418e2057e65b2fd3ab28a46249f4b83.tar.gz
yuzu-d17dfa610418e2057e65b2fd3ab28a46249f4b83.tar.xz
yuzu-d17dfa610418e2057e65b2fd3ab28a46249f4b83.zip
gl_texture_cache: Properly implement depth/stencil sampling
This addresses the long standing issue of compatibility vs. core profiles on OpenGL, properly implementing depth vs. stencil sampling depending on the texture swizzle.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index e95eb069e..d9aae6dff 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -176,6 +176,19 @@ GLint GetSwizzleSource(SwizzleSource source) {
176 return GL_NONE; 176 return GL_NONE;
177} 177}
178 178
179GLenum GetComponent(PixelFormat format, bool is_first) {
180 switch (format) {
181 case PixelFormat::Z24S8:
182 case PixelFormat::Z32FS8:
183 return is_first ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX;
184 case PixelFormat::S8Z24:
185 return is_first ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
186 default:
187 UNREACHABLE();
188 return GL_DEPTH_COMPONENT;
189 }
190}
191
179void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) { 192void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) {
180 if (params.IsBuffer()) { 193 if (params.IsBuffer()) {
181 return; 194 return;
@@ -416,11 +429,21 @@ void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_sou
416 if (new_swizzle == swizzle) 429 if (new_swizzle == swizzle)
417 return; 430 return;
418 swizzle = new_swizzle; 431 swizzle = new_swizzle;
419 const std::array<GLint, 4> gl_swizzle = {GetSwizzleSource(x_source), GetSwizzleSource(y_source), 432 const std::array gl_swizzle = {GetSwizzleSource(x_source), GetSwizzleSource(y_source),
420 GetSwizzleSource(z_source), 433 GetSwizzleSource(z_source), GetSwizzleSource(w_source)};
421 GetSwizzleSource(w_source)};
422 const GLuint handle = GetTexture(); 434 const GLuint handle = GetTexture();
423 glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data()); 435 const PixelFormat format = surface.GetSurfaceParams().pixel_format;
436 switch (format) {
437 case PixelFormat::Z24S8:
438 case PixelFormat::Z32FS8:
439 case PixelFormat::S8Z24:
440 glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE,
441 GetComponent(format, x_source == SwizzleSource::R));
442 break;
443 default:
444 glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data());
445 break;
446 }
424} 447}
425 448
426OGLTextureView CachedSurfaceView::CreateTextureView() const { 449OGLTextureView CachedSurfaceView::CreateTextureView() const {