[Mesa-stable] [Mesa-dev] [PATCH] st/mesa: use the texture view's format for render-to-texture

Ilia Mirkin imirkin at alum.mit.edu
Fri Mar 18 23:15:24 UTC 2016


Seems reasonable to me... check to make sure that Unreal Engine 4
keeps working, it uses texture views.

FWIW I made a misstep when implementing texture views in that I reused
the ->surface_format thing, which was probably wrong. Perhaps I should
have added a strb->rtt_format or something... dunno. That might be the
wrong layer to do it at.

Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>

  -ilia

On Fri, Mar 18, 2016 at 7:10 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Aside from the bug below, it fixes a simplistic test I've written locally,
> and I see no regression in Piglit for radeonsi.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94595
> Cc: mesa-stable at lists.freedesktop.org
> ---
>  src/mesa/state_tracker/st_cb_fbo.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
> index 82ab914..ff570e0 100644
> --- a/src/mesa/state_tracker/st_cb_fbo.c
> +++ b/src/mesa/state_tracker/st_cb_fbo.c
> @@ -387,6 +387,7 @@ st_update_renderbuffer_surface(struct st_context *st,
>  {
>     struct pipe_context *pipe = st->pipe;
>     struct pipe_resource *resource = strb->texture;
> +   struct st_texture_object *stTexObj = NULL;
>     unsigned rtt_width = strb->Base.Width;
>     unsigned rtt_height = strb->Base.Height;
>     unsigned rtt_depth = strb->Base.Depth;
> @@ -398,9 +399,18 @@ st_update_renderbuffer_surface(struct st_context *st,
>      */
>     boolean enable_srgb = (st->ctx->Color.sRGBEnabled &&
>           _mesa_get_format_color_encoding(strb->Base.Format) == GL_SRGB);
> -   enum pipe_format format = (enable_srgb) ?
> -      util_format_srgb(resource->format) :
> -      util_format_linear(resource->format);
> +   enum pipe_format format = resource->format;
> +
> +   if (strb->is_rtt) {
> +      stTexObj = st_texture_object(strb->Base.TexImage->TexObject);
> +      if (stTexObj->surface_based)
> +         format = stTexObj->surface_format;
> +   }
> +
> +   format = (enable_srgb) ?
> +      util_format_srgb(format) :
> +      util_format_linear(format);
> +
>     unsigned first_layer, last_layer, level;
>
>     if (resource->target == PIPE_TEXTURE_1D_ARRAY) {
> @@ -431,8 +441,8 @@ st_update_renderbuffer_surface(struct st_context *st,
>
>     /* Adjust for texture views */
>     if (strb->is_rtt && resource->array_size > 1 &&
> -       strb->Base.TexImage->TexObject->Immutable) {
> -      struct gl_texture_object *tex = strb->Base.TexImage->TexObject;
> +       stTexObj->base.Immutable) {
> +      struct gl_texture_object *tex = &stTexObj->base;
>        first_layer += tex->MinLayer;
>        if (!strb->rtt_layered)
>           last_layer += tex->MinLayer;
> @@ -492,8 +502,6 @@ st_render_texture(struct gl_context *ctx,
>
>     st_update_renderbuffer_surface(st, strb);
>
> -   strb->Base.Format = st_pipe_format_to_mesa_format(pt->format);
> -
>     /* Invalidate buffer state so that the pipe's framebuffer state
>      * gets updated.
>      * That's where the new renderbuffer (which we just created) gets
> --
> 2.5.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-stable mailing list