[Mesa-dev] [PATCH 1/5] st/mesa: use pipe_context::clear for D24S8 textures when appropriate
Marek Olšák
maraeo at gmail.com
Sat Aug 14 08:47:31 PDT 2010
If PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE is not advertised and there is
a D24S8 texture bound and the mask is BUFFER_BIT_DEPTH|BUFFER_BIT_STENCIL,
the state tracker always cleared the texture with a quad instead of using
pipe_context::clear.
---
src/mesa/state_tracker/st_cb_clear.c | 14 ++++++++++----
src/mesa/state_tracker/st_cb_fbo.c | 33 ++++++++++++++++++++-------------
src/mesa/state_tracker/st_cb_fbo.h | 4 ++++
3 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 246ab2e..a9b0ab2 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -452,13 +452,19 @@ st_Clear(GLcontext *ctx, GLbitfield mask)
static const GLbitfield BUFFER_BITS_DS
= (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
struct st_context *st = st_context(ctx);
+ struct gl_renderbuffer_attachment *depth
+ = &ctx->DrawBuffer->Attachment[BUFFER_DEPTH];
+ struct gl_renderbuffer_attachment *stencil
+ = &ctx->DrawBuffer->Attachment[BUFFER_STENCIL];
struct gl_renderbuffer *depthRb
- = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ = depth->Renderbuffer;
struct gl_renderbuffer *stencilRb
- = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ = stencil->Renderbuffer;
GLbitfield quad_buffers = 0x0;
GLbitfield clear_buffers = 0x0;
GLuint i;
+ boolean depth_stencil_combined
+ = st_is_depth_stencil_combined(depth, stencil);
/* This makes sure the pipe has the latest scissor, etc values */
st_validate_state( st );
@@ -487,7 +493,7 @@ st_Clear(GLcontext *ctx, GLbitfield mask)
}
}
- if ((mask & BUFFER_BITS_DS) == BUFFER_BITS_DS && depthRb == stencilRb) {
+ if ((mask & BUFFER_BITS_DS) == BUFFER_BITS_DS && depth_stencil_combined) {
/* clearing combined depth + stencil */
struct st_renderbuffer *strb = st_renderbuffer(depthRb);
@@ -543,7 +549,7 @@ st_Clear(GLcontext *ctx, GLbitfield mask)
*/
if ((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) &&
((clear_buffers & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) &&
- (depthRb == stencilRb) &&
+ depth_stencil_combined &&
(ctx->DrawBuffer->Visual.depthBits == 0 ||
ctx->DrawBuffer->Visual.stencilBits == 0))
clear_buffers |= PIPE_CLEAR_DEPTHSTENCIL;
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 13119ce..41255a1 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -446,6 +446,24 @@ st_validate_attachment(struct pipe_screen *screen,
stObj->pt->nr_samples, bindings, 0);
}
+boolean
+st_is_depth_stencil_combined(const struct gl_renderbuffer_attachment *depth,
+ const struct gl_renderbuffer_attachment *stencil)
+{
+ assert(depth && stencil);
+
+ if (depth->Type == stencil->Type) {
+ if (depth->Type == GL_RENDERBUFFER_EXT &&
+ depth->Renderbuffer == stencil->Renderbuffer)
+ return TRUE;
+
+ if (depth->Type == GL_TEXTURE &&
+ depth->Texture == stencil->Texture)
+ return TRUE;
+ }
+
+ return FALSE;
+}
/**
* Check that the framebuffer configuration is valid in terms of what
@@ -464,19 +482,8 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
&fb->Attachment[BUFFER_STENCIL];
GLuint i;
- if (depth->Type && stencil->Type && depth->Type != stencil->Type) {
- fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
- return;
- }
- if (depth->Type == GL_RENDERBUFFER_EXT &&
- stencil->Type == GL_RENDERBUFFER_EXT &&
- depth->Renderbuffer != stencil->Renderbuffer) {
- fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
- return;
- }
- if (depth->Type == GL_TEXTURE &&
- stencil->Type == GL_TEXTURE &&
- depth->Texture != stencil->Texture) {
+ if (depth->Type && stencil->Type &&
+ !st_is_depth_stencil_combined(depth, stencil)) {
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
return;
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h
index 62a9bbc..0b214db 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -87,5 +87,9 @@ extern struct pipe_sampler_view *
st_get_renderbuffer_sampler_view(struct st_renderbuffer *rb,
struct pipe_context *pipe);
+extern boolean
+st_is_depth_stencil_combined(const struct gl_renderbuffer_attachment *depth,
+ const struct gl_renderbuffer_attachment *stencil);
+
#endif /* ST_CB_FBO_H */
--
1.7.0.4
More information about the mesa-dev
mailing list