From 0191570f024ba787799ca2bccd46549a8af74aa9 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 20 Nov 2007 08:30:10 -0700 Subject: [PATCH] initial support for PIPE_FORMAT_Z24_S8 --- src/mesa/pipe/p_format.h | 2 ++ src/mesa/state_tracker/st_cb_clear.c | 8 ++++---- src/mesa/state_tracker/st_cb_readpixels.c | 9 +++++++++ src/mesa/state_tracker/st_format.c | 9 +++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/mesa/pipe/p_format.h b/src/mesa/pipe/p_format.h index d478a6c..f42f987 100644 --- a/src/mesa/pipe/p_format.h +++ b/src/mesa/pipe/p_format.h @@ -171,6 +171,7 @@ static INLINE uint pf_get(pipe_format_rgbazs_t f, uint shift, uint mask) #define _PIPE_FORMAT_RRRG _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G ) #define _PIPE_FORMAT_Z000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 ) #define _PIPE_FORMAT_SZ00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 ) +#define _PIPE_FORMAT_ZS00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 ) #define _PIPE_FORMAT_S000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 ) /** @@ -222,6 +223,7 @@ static INLINE uint pf_rev(pipe_format_ycbcr_t f) #define PIPE_FORMAT_U_Z32 _PIPE_FORMAT_RGBAZS_8N( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ) /**< uint Z/depth */ #define PIPE_FORMAT_F_Z32 _PIPE_FORMAT_RGBAZS_8N( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ) /**< float Z/depth */ #define PIPE_FORMAT_S8_Z24 _PIPE_FORMAT_RGBAZS_8N( _PIPE_FORMAT_SZ00, 1, 3, 0, 0, PIPE_FORMAT_TYPE_UNORM ) /**< 8-bit stencil + 24-bit Z */ +#define PIPE_FORMAT_Z24_S8 _PIPE_FORMAT_RGBAZS_8N( _PIPE_FORMAT_ZS00, 3, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM ) /**< 24-bit Z + 8-bit stencil */ #define PIPE_FORMAT_U_S8 _PIPE_FORMAT_RGBAZS_8N( _PIPE_FORMAT_S000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ) /**< 8-bit stencil */ #define PIPE_FORMAT_R64_FLOAT _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_R000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ) #define PIPE_FORMAT_R64G64_FLOAT _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RG00, 1, 1, 0, 0, PIPE_FORMAT_TYPE_FLOAT ) diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 3e59117..219a5af 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -91,6 +91,8 @@ depth_value(GLuint pipeFormat, GLfloat value) return (uint) (value * 0xffffffff); case PIPE_FORMAT_S8_Z24: return (uint) (value * 0xffffff); + case PIPE_FORMAT_Z24_S8: + return ((uint) (value * 0xffffff)) << 8; default: assert(0); return 0; @@ -103,7 +105,7 @@ is_depth_stencil_format(GLuint pipeFormat) { switch (pipeFormat) { case PIPE_FORMAT_S8_Z24: - /*case PIPE_FORMAT_Z24_S8:*/ + case PIPE_FORMAT_Z24_S8: return GL_TRUE; default: return GL_FALSE; @@ -521,11 +523,9 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) case PIPE_FORMAT_S8_Z24: clearValue |= ctx->Stencil.Clear << 24; break; -#if 0 case PIPE_FORMAT_Z24_S8: - clearValue = (clearValue << 8) | clearVal; + clearValue |= clearValue | ctx->Stencil.Clear; break; -#endif default: assert(0); } diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index c347a0b..2e7c016 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -100,6 +100,15 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } } break; + case PIPE_FORMAT_Z24_S8: + { + const uint *src = (uint *) stmap + srcY * ps->region->pitch + x; + GLint k; + for (k = 0; k < width; k++) { + values[k] = src[k] & 0xff; + } + } + break; default: assert(0); } diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index ddba650..c6b5bc9 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -320,6 +320,9 @@ default_depth_format( if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) { return PIPE_FORMAT_S8_Z24; } + if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 )) { + return PIPE_FORMAT_Z24_S8; + } return PIPE_FORMAT_NONE; } @@ -486,6 +489,8 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_DEPTH_COMPONENT24: if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; + if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 )) + return PIPE_FORMAT_Z24_S8; /* fall-through */ case GL_DEPTH_COMPONENT32: if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 )) @@ -503,12 +508,16 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, return PIPE_FORMAT_U_S8; if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; + if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 )) + return PIPE_FORMAT_Z24_S8; return PIPE_FORMAT_NONE; case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; + if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 )) + return PIPE_FORMAT_Z24_S8; return PIPE_FORMAT_NONE; default: -- 2.7.4