<div dir="ltr"><div>The test passes here. I wouldn't push a commit that doesn't pass. It looks like v3d can't blit stencil.</div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 11, 2019 at 6:29 AM apinheiro <<a href="mailto:apinheiro@igalia.com">apinheiro@igalia.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi, the following piglit test:<br>
<br>
./bin/fbo-stencil copypixels GL_DEPTH32F_STENCIL8 -auto -fbo<br>
<br>
regressed after this patch landed master with the v3d driver. So Marek <br>
and anyone reading this email, could you execute that test and confirms <br>
if only regress with v3d?<br>
<br>
Thanks in advance.<br>
<br>
On 25/6/19 2:12, Marek Olšák wrote:<br>
> From: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>><br>
><br>
> ---<br>
>   src/mesa/state_tracker/st_cb_drawpixels.c | 58 +++++++++++++++--------<br>
>   1 file changed, 38 insertions(+), 20 deletions(-)<br>
><br>
> diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c<br>
> index 59868d3ff1d..26d3cc33e5c 100644<br>
> --- a/src/mesa/state_tracker/st_cb_drawpixels.c<br>
> +++ b/src/mesa/state_tracker/st_cb_drawpixels.c<br>
> @@ -1508,35 +1508,35 @@ static GLboolean<br>
>   blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,<br>
>                    GLsizei width, GLsizei height,<br>
>                    GLint dstx, GLint dsty, GLenum type)<br>
>   {<br>
>      struct st_context *st = st_context(ctx);<br>
>      struct pipe_context *pipe = st->pipe;<br>
>      struct pipe_screen *screen = pipe->screen;<br>
>      struct gl_pixelstore_attrib pack, unpack;<br>
>      GLint readX, readY, readW, readH, drawX, drawY, drawW, drawH;<br>
>   <br>
> -   if (type == GL_COLOR &&<br>
> -       ctx->Pixel.ZoomX == 1.0 &&<br>
> +   if (ctx->Pixel.ZoomX == 1.0 &&<br>
>          ctx->Pixel.ZoomY == 1.0 &&<br>
> -       ctx->_ImageTransferState == 0x0 &&<br>
> -       !ctx->Color.BlendEnabled &&<br>
> -       !ctx->Color.AlphaEnabled &&<br>
> -       (!ctx->Color.ColorLogicOpEnabled || ctx->Color.LogicOp == GL_COPY) &&<br>
> -       !ctx->Depth.Test &&<br>
> -       !ctx->Fog.Enabled &&<br>
> -       !ctx->Stencil.Enabled &&<br>
> -       !ctx->FragmentProgram.Enabled &&<br>
> -       !ctx->VertexProgram.Enabled &&<br>
> -       !ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT] &&<br>
> -       !_mesa_ati_fragment_shader_enabled(ctx) &&<br>
> -       ctx->DrawBuffer->_NumColorDrawBuffers == 1 &&<br>
> +       (type != GL_COLOR ||<br>
> +        (ctx->_ImageTransferState == 0x0 &&<br>
> +         !ctx->Color.BlendEnabled &&<br>
> +         !ctx->Color.AlphaEnabled &&<br>
> +         (!ctx->Color.ColorLogicOpEnabled || ctx->Color.LogicOp == GL_COPY) &&<br>
> +         !ctx->Depth.Test &&<br>
> +         !ctx->Fog.Enabled &&<br>
> +         !ctx->Stencil.Enabled &&<br>
> +         !ctx->FragmentProgram.Enabled &&<br>
> +         !ctx->VertexProgram.Enabled &&<br>
> +         !ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT] &&<br>
> +         !_mesa_ati_fragment_shader_enabled(ctx) &&<br>
> +         ctx->DrawBuffer->_NumColorDrawBuffers == 1)) &&<br>
>          !ctx->Query.CondRenderQuery &&<br>
>          !ctx->Query.CurrentOcclusionObject) {<br>
>         struct st_renderbuffer *rbRead, *rbDraw;<br>
>   <br>
>         /*<br>
>          * Clip the read region against the src buffer bounds.<br>
>          * We'll still allocate a temporary buffer/texture for the original<br>
>          * src region size but we'll only read the region which is on-screen.<br>
>          * This may mean that we draw garbage pixels into the dest region, but<br>
>          * that's expected.<br>
> @@ -1555,22 +1555,32 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,<br>
>         unpack = pack;<br>
>         if (!_mesa_clip_drawpixels(ctx, &drawX, &drawY, &readW, &readH, &unpack))<br>
>            return GL_TRUE; /* all done */<br>
>   <br>
>         readX = readX - pack.SkipPixels + unpack.SkipPixels;<br>
>         readY = readY - pack.SkipRows + unpack.SkipRows;<br>
>   <br>
>         drawW = readW;<br>
>         drawH = readH;<br>
>   <br>
> -      rbRead = st_get_color_read_renderbuffer(ctx);<br>
> -      rbDraw = st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);<br>
> +      if (type == GL_COLOR) {<br>
> +         rbRead = st_get_color_read_renderbuffer(ctx);<br>
> +         rbDraw = st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);<br>
> +      } else if (type == GL_DEPTH || type == GL_DEPTH_STENCIL) {<br>
> +         rbRead = st_renderbuffer(ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer);<br>
> +         rbDraw = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer);<br>
> +      } else if (type == GL_STENCIL) {<br>
> +         rbRead = st_renderbuffer(ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer);<br>
> +         rbDraw = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer);<br>
> +      } else {<br>
> +         return false;<br>
> +      }<br>
>   <br>
>         /* Flip src/dst position depending on the orientation of buffers. */<br>
>         if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {<br>
>            readY = rbRead->Base.Height - readY;<br>
>            readH = -readH;<br>
>         }<br>
>   <br>
>         if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {<br>
>            /* We can't flip the destination for pipe->blit, so we only adjust<br>
>             * its position and flip the source.<br>
> @@ -1597,23 +1607,31 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,<br>
>            blit.src.box.depth = 1;<br>
>            blit.dst.resource = rbDraw->texture;<br>
>            blit.dst.level = rbDraw->surface->u.tex.level;<br>
>            blit.dst.format = rbDraw->texture->format;<br>
>            blit.dst.box.x = drawX;<br>
>            blit.dst.box.y = drawY;<br>
>            blit.dst.box.z = rbDraw->surface->u.tex.first_layer;<br>
>            blit.dst.box.width = drawW;<br>
>            blit.dst.box.height = drawH;<br>
>            blit.dst.box.depth = 1;<br>
> -         blit.mask = PIPE_MASK_RGBA;<br>
>            blit.filter = PIPE_TEX_FILTER_NEAREST;<br>
>   <br>
> +         if (type == GL_COLOR)<br>
> +            blit.mask |= PIPE_MASK_RGBA;<br>
> +         if (type == GL_DEPTH)<br>
> +            blit.mask |= PIPE_MASK_Z;<br>
> +         if (type == GL_STENCIL)<br>
> +            blit.mask |= PIPE_MASK_S;<br>
> +         if (type == GL_DEPTH_STENCIL)<br>
> +            blit.mask |= PIPE_MASK_ZS;<br>
> +<br>
>            if (ctx->DrawBuffer != ctx->WinSysDrawBuffer)<br>
>               st_window_rectangles_to_blit(ctx, &blit);<br>
>   <br>
>            if (screen->is_format_supported(screen, blit.src.format,<br>
>                                            blit.src.resource->target,<br>
>                                            blit.src.resource->nr_samples,<br>
>                                            blit.src.resource->nr_storage_samples,<br>
>                                            PIPE_BIND_SAMPLER_VIEW) &&<br>
>                screen->is_format_supported(screen, blit.dst.format,<br>
>                                            blit.dst.resource->target,<br>
> @@ -1650,36 +1668,36 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,<br>
>      GLint readX, readY, readW, readH;<br>
>      struct gl_pixelstore_attrib pack = ctx->DefaultPacking;<br>
>   <br>
>      _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);<br>
>   <br>
>      st_flush_bitmap_cache(st);<br>
>      st_invalidate_readpix_cache(st);<br>
>   <br>
>      st_validate_state(st, ST_PIPELINE_META);<br>
>   <br>
> +   if (blit_copy_pixels(ctx, srcx, srcy, width, height, dstx, dsty, type))<br>
> +      return;<br>
> +<br>
>      if (type == GL_DEPTH_STENCIL) {<br>
>         /* XXX make this more efficient */<br>
>         st_CopyPixels(ctx, srcx, srcy, width, height, dstx, dsty, GL_STENCIL);<br>
>         st_CopyPixels(ctx, srcx, srcy, width, height, dstx, dsty, GL_DEPTH);<br>
>         return;<br>
>      }<br>
>   <br>
>      if (type == GL_STENCIL) {<br>
>         /* can't use texturing to do stencil */<br>
>         copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty);<br>
>         return;<br>
>      }<br>
>   <br>
> -   if (blit_copy_pixels(ctx, srcx, srcy, width, height, dstx, dsty, type))<br>
> -      return;<br>
> -<br>
>      /*<br>
>       * The subsequent code implements glCopyPixels by copying the source<br>
>       * pixels into a temporary texture that's then applied to a textured quad.<br>
>       * When we draw the textured quad, all the usual per-fragment operations<br>
>       * are handled.<br>
>       */<br>
>   <br>
>      st_make_passthrough_vertex_shader(st);<br>
>   <br>
>      /*<br>
</blockquote></div>