mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-26 16:52:46 +01:00
Merge pull request #3354 from ReinUsesLisp/depth-stencil
gl_texture_cache: Properly implement depth/stencil sampling
This commit is contained in:
commit
bea6327d74
1 changed files with 27 additions and 4 deletions
|
@ -176,6 +176,19 @@ GLint GetSwizzleSource(SwizzleSource source) {
|
||||||
return GL_NONE;
|
return GL_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLenum GetComponent(PixelFormat format, bool is_first) {
|
||||||
|
switch (format) {
|
||||||
|
case PixelFormat::Z24S8:
|
||||||
|
case PixelFormat::Z32FS8:
|
||||||
|
return is_first ? GL_DEPTH_COMPONENT : GL_STENCIL_INDEX;
|
||||||
|
case PixelFormat::S8Z24:
|
||||||
|
return is_first ? GL_STENCIL_INDEX : GL_DEPTH_COMPONENT;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return GL_DEPTH_COMPONENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) {
|
void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) {
|
||||||
if (params.IsBuffer()) {
|
if (params.IsBuffer()) {
|
||||||
return;
|
return;
|
||||||
|
@ -416,11 +429,21 @@ void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_sou
|
||||||
if (new_swizzle == swizzle)
|
if (new_swizzle == swizzle)
|
||||||
return;
|
return;
|
||||||
swizzle = new_swizzle;
|
swizzle = new_swizzle;
|
||||||
const std::array<GLint, 4> gl_swizzle = {GetSwizzleSource(x_source), GetSwizzleSource(y_source),
|
const std::array gl_swizzle = {GetSwizzleSource(x_source), GetSwizzleSource(y_source),
|
||||||
GetSwizzleSource(z_source),
|
GetSwizzleSource(z_source), GetSwizzleSource(w_source)};
|
||||||
GetSwizzleSource(w_source)};
|
|
||||||
const GLuint handle = GetTexture();
|
const GLuint handle = GetTexture();
|
||||||
|
const PixelFormat format = surface.GetSurfaceParams().pixel_format;
|
||||||
|
switch (format) {
|
||||||
|
case PixelFormat::Z24S8:
|
||||||
|
case PixelFormat::Z32FS8:
|
||||||
|
case PixelFormat::S8Z24:
|
||||||
|
glTextureParameteri(handle, GL_DEPTH_STENCIL_TEXTURE_MODE,
|
||||||
|
GetComponent(format, x_source == SwizzleSource::R));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data());
|
glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLTextureView CachedSurfaceView::CreateTextureView() const {
|
OGLTextureView CachedSurfaceView::CreateTextureView() const {
|
||||||
|
|
Loading…
Reference in a new issue