[Mesa-dev] [PATCH 2/2] u_blitter: add integer clear support

Marek Olšák maraeo at gmail.com
Sat Oct 8 15:41:52 PDT 2011


On Sat, Oct 8, 2011 at 7:07 PM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> We need add a new set of fragment shader variants, along with new vertex
> elements for signed and unsigned clears.
>
> The new fragment shader variants are due to the integers values requiring
> CONSTANT interpolation. The new vertex element descriptions are for passing
> the clear color as an unsigned or signed integer value.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/gallium/auxiliary/util/u_blitter.c |   86 ++++++++++++++++++++++++-------
>  src/gallium/auxiliary/util/u_blitter.h |    1 +
>  src/gallium/drivers/r300/r300_blit.c   |    3 +-
>  src/gallium/drivers/r600/r600_blit.c   |    6 +-
>  4 files changed, 72 insertions(+), 24 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
> index 1500aa4..5c87489 100644
> --- a/src/gallium/auxiliary/util/u_blitter.c
> +++ b/src/gallium/auxiliary/util/u_blitter.c
> @@ -68,6 +68,7 @@ struct blitter_context_priv
>    /* Fragment shaders. */
>    /* The shader at index i outputs color to color buffers 0,1,...,i-1. */
>    void *fs_col[PIPE_MAX_COLOR_BUFS+1];
> +   void *fs_col_int[PIPE_MAX_COLOR_BUFS+1];
>
>    /* FS which outputs a color from a texture,
>       where the index is PIPE_TEXTURE_* to be sampled. */
> @@ -88,6 +89,8 @@ struct blitter_context_priv
>    void *dsa_keep_depth_write_stencil;
>
>    void *velem_state;
> +   void *velem_uint_state;
> +   void *velem_sint_state;
>
>    /* Sampler state for clamping to a miplevel. */
>    void *sampler_state[PIPE_MAX_TEXTURE_LEVELS * 2];
> @@ -208,6 +211,27 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
>    }
>    ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
>
> +   memset(&velem[0], 0, sizeof(velem[0]) * 2);
> +   for (i = 0; i < 2; i++) {
> +      velem[i].src_offset = i * 4 * sizeof(float);
> +      if (i == 0) {
> +         velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
> +      } else {
> +         velem[i].src_format = PIPE_FORMAT_R32G32B32A32_SINT;
> +      }
> +   }
> +   ctx->velem_sint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
> +
> +   memset(&velem[0], 0, sizeof(velem[0]) * 2);
> +   for (i = 0; i < 2; i++) {
> +      velem[i].src_offset = i * 4 * sizeof(float);
> +      if (i == 0) {
> +         velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
> +      } else {
> +         velem[i].src_format = PIPE_FORMAT_R32G32B32A32_UINT;
> +      }
> +   }
> +   ctx->velem_uint_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]);
>    /* fragment shaders are created on-demand */
>
>    /* vertex shader */
> @@ -250,6 +274,8 @@ void util_blitter_destroy(struct blitter_context *blitter)
>    pipe->delete_rasterizer_state(pipe, ctx->rs_state);
>    pipe->delete_vs_state(pipe, ctx->vs);
>    pipe->delete_vertex_elements_state(pipe, ctx->velem_state);
> +   pipe->delete_vertex_elements_state(pipe, ctx->velem_sint_state);
> +   pipe->delete_vertex_elements_state(pipe, ctx->velem_uint_state);
>
>    for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) {
>       if (ctx->fs_texfetch_col[i])
> @@ -261,6 +287,8 @@ void util_blitter_destroy(struct blitter_context *blitter)
>    for (i = 0; i <= PIPE_MAX_COLOR_BUFS; i++)
>       if (ctx->fs_col[i])
>          pipe->delete_fs_state(pipe, ctx->fs_col[i]);
> +      if (ctx->fs_col_int[i])
> +         pipe->delete_fs_state(pipe, ctx->fs_col_int[i]);

I guess you wanted to enclose the loop body in { }.

With that fixed, this is:

Reviewed-by: Marek Olšák <maraeo at gmail.com>

I wonder what happens if cb[0] is FLOAT, cb[1] is UINT, and cb[2] is SINT.

Marek


More information about the mesa-dev mailing list