[Mesa-dev] [PATCH 01/13] st/mesa: remove st_renderbuffer::format
Jose Fonseca
jfonseca at vmware.com
Mon Feb 13 08:41:14 PST 2012
----- Original Message -----
> We only used it in a few places that can implemented differently.
> ---
> src/mesa/state_tracker/st_cb_drawpixels.c | 13 +++++++------
> src/mesa/state_tracker/st_cb_fbo.c | 13 +++----------
> src/mesa/state_tracker/st_cb_fbo.h | 1 -
> 3 files changed, 10 insertions(+), 17 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c
> b/src/mesa/state_tracker/st_cb_drawpixels.c
> index 386eed2..88e57b8 100644
> --- a/src/mesa/state_tracker/st_cb_drawpixels.c
> +++ b/src/mesa/state_tracker/st_cb_drawpixels.c
> @@ -842,12 +842,14 @@ draw_stencil_pixels(struct gl_context *ctx,
> GLint x, GLint y,
> y = ctx->DrawBuffer->Height - y - height;
> }
>
> - if(format != GL_DEPTH_STENCIL &&
> - util_format_get_component_bits(strb->format,
> - UTIL_FORMAT_COLORSPACE_ZS, 0)
> != 0)
> + if (format == GL_STENCIL_INDEX &&
> + _mesa_is_format_packed_depth_stencil(strb->Base.Format)) {
> + /* writing stencil to a combined depth+stencil buffer */
> usage = PIPE_TRANSFER_READ_WRITE;
> - else
> + }
> + else {
> usage = PIPE_TRANSFER_WRITE;
> + }
>
> pt = pipe_get_transfer(pipe, strb->texture,
> strb->rtt_level, strb->rtt_face +
> strb->rtt_slice,
> @@ -1209,8 +1211,7 @@ copy_stencil_pixels(struct gl_context *ctx,
> GLint srcx, GLint srcy,
> }
> }
>
> - if (util_format_get_component_bits(rbDraw->format,
> - UTIL_FORMAT_COLORSPACE_ZS, 0)
> != 0)
> + if (_mesa_is_format_packed_depth_stencil(rbDraw->Base.Format))
> usage = PIPE_TRANSFER_READ_WRITE;
> else
> usage = PIPE_TRANSFER_WRITE;
Not related with this change, but in a follow on change we could do
usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE
to tell the driver that not only we will not read the previous values, but also that we don't care for the previous values, therefore need to DMA them from the VRAM.
And when writing the whole buffer, it should also have PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE.
But then again, stencil without depth is probably pretty rare, so maybe not worth the trouble...
Jose
> diff --git a/src/mesa/state_tracker/st_cb_fbo.c
> b/src/mesa/state_tracker/st_cb_fbo.c
> index 1cbc0d6..85086bb 100644
> --- a/src/mesa/state_tracker/st_cb_fbo.c
> +++ b/src/mesa/state_tracker/st_cb_fbo.c
> @@ -97,7 +97,6 @@ st_renderbuffer_alloc_storage(struct gl_context *
> ctx,
> strb->Base.Height = height;
> strb->Base.Format = st_pipe_format_to_mesa_format(format);
> strb->Base._BaseFormat = _mesa_base_fbo_format(ctx,
> internalFormat);
> - strb->format = format;
>
> strb->defined = GL_FALSE; /* undefined contents now */
>
> @@ -106,10 +105,8 @@ st_renderbuffer_alloc_storage(struct gl_context
> * ctx,
>
> free(strb->data);
>
> - assert(strb->format != PIPE_FORMAT_NONE);
> -
> - strb->stride = util_format_get_stride(strb->format, width);
> - size = util_format_get_2d_size(strb->format, strb->stride,
> height);
> + strb->stride = util_format_get_stride(format, width);
> + size = util_format_get_2d_size(format, strb->stride, height);
>
> strb->data = malloc(size);
>
> @@ -206,7 +203,6 @@ st_new_renderbuffer(struct gl_context *ctx,
> GLuint name)
> _mesa_init_renderbuffer(&strb->Base, name);
> strb->Base.Delete = st_renderbuffer_delete;
> strb->Base.AllocStorage = st_renderbuffer_alloc_storage;
> - strb->format = PIPE_FORMAT_NONE;
> return &strb->Base;
> }
> return NULL;
> @@ -233,7 +229,6 @@ st_new_renderbuffer_fb(enum pipe_format format,
> int samples, boolean sw)
> strb->Base.NumSamples = samples;
> strb->Base.Format = st_pipe_format_to_mesa_format(format);
> strb->Base._BaseFormat =
> _mesa_get_format_base_format(strb->Base.Format);
> - strb->format = format;
> strb->software = sw;
>
> switch (format) {
> @@ -401,8 +396,6 @@ st_render_texture(struct gl_context *ctx,
> strb->texture,
> &surf_tmpl);
>
> - strb->format = pt->format;
> -
> strb->Base.Format = st_pipe_format_to_mesa_format(pt->format);
>
> /*
> @@ -650,7 +643,7 @@ st_MapRenderbuffer(struct gl_context *ctx,
> GLubyte *map = (GLubyte *) strb->data;
> if (strb->data) {
> map += strb->stride * y;
> - map += util_format_get_blocksize(strb->format) * x;
> + map += _mesa_get_format_bytes(strb->Base.Format) * x;
> *mapOut = map;
> *rowStrideOut = strb->stride;
> }
> diff --git a/src/mesa/state_tracker/st_cb_fbo.h
> b/src/mesa/state_tracker/st_cb_fbo.h
> index 1be0173..7a2d4d8 100644
> --- a/src/mesa/state_tracker/st_cb_fbo.h
> +++ b/src/mesa/state_tracker/st_cb_fbo.h
> @@ -48,7 +48,6 @@ struct st_renderbuffer
> struct gl_renderbuffer Base;
> struct pipe_resource *texture;
> struct pipe_surface *surface; /* temporary view into texture */
> - enum pipe_format format; /** preferred format, or
> PIPE_FORMAT_NONE */
> GLboolean defined; /**< defined contents? */
>
> struct pipe_transfer *transfer; /**< only used when mapping the
> resource */
> --
> 1.7.3.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list