[Mesa-dev] [PATCH] st/mesa: Factorize duplicate code in st_BlitFramebuffer()

Marek Olšák maraeo at gmail.com
Wed Mar 14 19:27:53 UTC 2018


Pushed! Thanks.

Marek

On Tue, Feb 20, 2018 at 8:30 AM, Guillaume Charifi
<guillaume.charifi at sfr.fr> wrote:
> ---
>  src/mesa/state_tracker/st_cb_blit.c | 76 +++++++++++++------------------------
>  1 file changed, 26 insertions(+), 50 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
> index 8aa849b3fc..564ad66665 100644
> --- a/src/mesa/state_tracker/st_cb_blit.c
> +++ b/src/mesa/state_tracker/st_cb_blit.c
> @@ -174,53 +174,29 @@ st_BlitFramebuffer(struct gl_context *ctx,
>     if (mask & GL_COLOR_BUFFER_BIT) {
>        struct gl_renderbuffer_attachment *srcAtt =
>           &readFB->Attachment[readFB->_ColorReadBufferIndex];
> +      GLuint i;
>
>        blit.mask = PIPE_MASK_RGBA;
>
>        if (srcAtt->Type == GL_TEXTURE) {
>           struct st_texture_object *srcObj = st_texture_object(srcAtt->Texture);
> -         GLuint i;
>
>           if (!srcObj || !srcObj->pt) {
>              return;
>           }
>
> -         for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) {
> -            struct st_renderbuffer *dstRb =
> -               st_renderbuffer(drawFB->_ColorDrawBuffers[i]);
> +         blit.src.resource = srcObj->pt;
> +         blit.src.level = srcAtt->TextureLevel;
> +         blit.src.box.z = srcAtt->Zoffset + srcAtt->CubeMapFace;
> +         blit.src.format = srcObj->pt->format;
>
> -            if (dstRb) {
> -               struct pipe_surface *dstSurf;
> -
> -               st_update_renderbuffer_surface(st, dstRb);
> -
> -               dstSurf = dstRb->surface;
> -
> -               if (dstSurf) {
> -                  blit.dst.resource = dstSurf->texture;
> -                  blit.dst.level = dstSurf->u.tex.level;
> -                  blit.dst.box.z = dstSurf->u.tex.first_layer;
> -                  blit.dst.format = dstSurf->format;
> -
> -                  blit.src.resource = srcObj->pt;
> -                  blit.src.level = srcAtt->TextureLevel;
> -                  blit.src.box.z = srcAtt->Zoffset + srcAtt->CubeMapFace;
> -                  blit.src.format = srcObj->pt->format;
> -
> -                  if (!ctx->Color.sRGBEnabled)
> -                     blit.src.format = util_format_linear(blit.src.format);
> -
> -                  st->pipe->blit(st->pipe, &blit);
> -                  dstRb->defined = true; /* front buffer tracking */
> -               }
> -            }
> -         }
> +         if (!ctx->Color.sRGBEnabled)
> +            blit.src.format = util_format_linear(blit.src.format);
>        }
>        else {
>           struct st_renderbuffer *srcRb =
>              st_renderbuffer(readFB->_ColorReadBuffer);
>           struct pipe_surface *srcSurf;
> -         GLuint i;
>
>           if (!srcRb)
>              return;
> @@ -232,31 +208,31 @@ st_BlitFramebuffer(struct gl_context *ctx,
>
>           srcSurf = srcRb->surface;
>
> -         for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) {
> -            struct st_renderbuffer *dstRb =
> -               st_renderbuffer(drawFB->_ColorDrawBuffers[i]);
> +         blit.src.resource = srcSurf->texture;
> +         blit.src.level = srcSurf->u.tex.level;
> +         blit.src.box.z = srcSurf->u.tex.first_layer;
> +         blit.src.format = srcSurf->format;
> +      }
>
> -            if (dstRb) {
> -               struct pipe_surface *dstSurf;
> +      for (i = 0; i < drawFB->_NumColorDrawBuffers; i++) {
> +         struct st_renderbuffer *dstRb =
> +            st_renderbuffer(drawFB->_ColorDrawBuffers[i]);
>
> -               st_update_renderbuffer_surface(st, dstRb);
> +         if (dstRb) {
> +            struct pipe_surface *dstSurf;
>
> -               dstSurf = dstRb->surface;
> +            st_update_renderbuffer_surface(st, dstRb);
>
> -               if (dstSurf) {
> -                  blit.dst.resource = dstSurf->texture;
> -                  blit.dst.level = dstSurf->u.tex.level;
> -                  blit.dst.box.z = dstSurf->u.tex.first_layer;
> -                  blit.dst.format = dstSurf->format;
> +            dstSurf = dstRb->surface;
>
> -                  blit.src.resource = srcSurf->texture;
> -                  blit.src.level = srcSurf->u.tex.level;
> -                  blit.src.box.z = srcSurf->u.tex.first_layer;
> -                  blit.src.format = srcSurf->format;
> +            if (dstSurf) {
> +               blit.dst.resource = dstSurf->texture;
> +               blit.dst.level = dstSurf->u.tex.level;
> +               blit.dst.box.z = dstSurf->u.tex.first_layer;
> +               blit.dst.format = dstSurf->format;
>
> -                  st->pipe->blit(st->pipe, &blit);
> -                  dstRb->defined = true; /* front buffer tracking */
> -               }
> +               st->pipe->blit(st->pipe, &blit);
> +               dstRb->defined = true; /* front buffer tracking */
>              }
>           }
>        }
> --
> 2.14.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list