From a474ad443a2fb1f7a50c09a8f42c26730b77b2f0 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 21 Mar 2017 00:30:06 -0700 Subject: [PATCH] meta: Fix ClearTexture with GL_DEPTH_COMPONENT. We only handled unpacking for GL_DEPTH_STENCIL formats. Cemu was hitting _mesa_problem() for an unsupported format in _mesa_unpack_float_32_uint_24_8_depth_stencil_row(), because the format was depth-only, rather than depth-stencil. --- src/mesa/drivers/common/meta.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index d8deaaf3713..fa7bfcd1f11 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -3491,15 +3491,20 @@ cleartexsubimage_depth_stencil(struct gl_context *ctx, /* Convert the clearValue from whatever format it's in to a floating * point value for the depth and an integer value for the stencil index */ - _mesa_unpack_float_32_uint_24_8_depth_stencil_row(texImage->TexFormat, - 1, /* n */ - clearValue, - depthStencilValue); + if (texImage->_BaseFormat == GL_DEPTH_STENCIL) { + _mesa_unpack_float_32_uint_24_8_depth_stencil_row(texImage->TexFormat, + 1, /* n */ + clearValue, + depthStencilValue); + stencilValue = depthStencilValue[1] & 0xff; + } else { + _mesa_unpack_float_z_row(texImage->TexFormat, 1 /* n */, + clearValue, depthStencilValue); + } /* We need a memcpy here instead of a cast because we need to * reinterpret the bytes as a float rather than converting it */ memcpy(&depthValue, depthStencilValue, sizeof depthValue); - stencilValue = depthStencilValue[1] & 0xff; } else { depthValue = 0.0f; stencilValue = 0; -- 2.12.0