Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu> --- Unfortunately a generic implementation isn't possible since this has to deal with multisampled textures, where the storage format isn't well-defined. Maybe we can assume that in each case it will be a certain amount of width/height increase and create PIPE_CAP's? Probably not worth it, since each driver will want to provide an accelerated version.
Christoph also suggested that maybe we should abuse the clear_render_target interface -- that's how I've implemented nv50 internally. But I don't think we can really guarantee that all drivers would work that way. Is clear_resource the right thing to call it, or should it be clear_surface and take a pipe_surface? I was concerned that it might not be legal to create a pipe_surface with a texture format that's non-renderable-to. src/gallium/include/pipe/p_context.h | 9 +++++++++ src/mesa/state_tracker/st_cb_texture.c | 23 +++++++++++++++++++++++ src/mesa/state_tracker/st_extensions.c | 3 +++ 3 files changed, 35 insertions(+) diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 0702729..ab4c198 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -291,6 +291,15 @@ struct pipe_context { void (*blit)(struct pipe_context *pipe, const struct pipe_blit_info *info); + /** + * Clear the resource with the specified texel. Not guaranteed to be a + * renderable format. Data provided in the resource's format. + */ + void (*clear_resource)(struct pipe_context *pipe, + struct pipe_resource *res, + const struct pipe_box *box, + const void *data); + /*@}*/ /** diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index f0bf374..1cb9efb 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1746,6 +1746,28 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target, } } +static void +st_ClearTexSubImage(struct gl_context *ctx, + struct gl_texture_image *texImage, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + const GLubyte *clearValue, GLsizeiptr clearValueSize) +{ + struct st_texture_image *stImage = st_texture_image(texImage); + struct pipe_resource *pt = stImage->pt; + struct st_context *st = st_context(ctx); + struct pipe_context *pipe = st->pipe; + struct pipe_box box; + + /* XXX need to handle data stored in stImage->TexData? */ + if (!pt) + return; + + u_box_3d(xoffset, yoffset, zoffset, width, height, depth, &box); + + pipe->clear_resource(pipe, pt, &box, clearValue); +} + void st_init_texture_functions(struct dd_function_table *functions) @@ -1777,4 +1799,5 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TestProxyTexImage = st_TestProxyTexImage; functions->AllocTextureStorage = st_AllocTextureStorage; + functions->ClearTexSubImage = st_ClearTexSubImage; } diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 18ddd4e..bda3127 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -797,4 +797,7 @@ void st_init_extensions(struct st_context *st) } if (ctx->Const.MaxProgramTextureGatherComponents > 0) ctx->Extensions.ARB_texture_gather = GL_TRUE; + + if (st->pipe->clear_resource) + ctx->Extensions.ARB_clear_texture = GL_TRUE; } -- 1.8.3.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev