<div dir="ltr">Ah, now that I looked at your other patch I see why you have image_height.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 25, 2015 at 5:33 PM, Laura Ekstrand <span dir="ltr"><<a href="mailto:laura@jlekstrand.net" target="_blank">laura@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This was an unfortunate artifact of rebasing; I fixed the 1D array bug before figuring out a robust fix for the 2D array bug (7a49f2e).  I think that you are right, although I'm confused what you are doing with the variable image_height that you added.  It seems like you should be able to get rid of image_height here. (But that's just a quick gut feeling.)<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 25, 2015 at 8:19 AM, Neil Roberts <span dir="ltr"><<a href="mailto:neil@linux.intel.com" target="_blank">neil@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sorry for the late review.<br>
<br>
Can you explain what this patch does? The previous code was doing a blit<br>
like this:<br>
<span><br>
      _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,<br>
</span><span>                                 0, z * height, width, (z + 1) * height,<br>
</span>                                 xoffset, yoffset,<br>
<span>                                 xoffset + width, yoffset + height,<br>
</span>                                 GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
<br>
However, it was first setting the height to 1 so that would end up like<br>
this:<br>
<span><br>
      _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,<br>
</span>                                 0, z * 1, width, (z + 1) * 1,<br>
                                 xoffset, yoffset,<br>
<span>                                 xoffset + width, yoffset + 1,<br>
</span>                                 GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
<br>
The patch makes it do this:<br>
<span><br>
         _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,<br>
</span><span>                                    0, z, width, z + 1,<br>
</span>                                    xoffset, yoffset,<br>
<span>                                    xoffset + width, yoffset + 1,<br>
</span>                                    GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
<br>
This looks like it would have exactly the same result.<br>
<br>
The patch doesn't modify the blit call for slice 0 which looks wrong to<br>
me.<br>
<br>
Neither the version with or without the patch appears to handle the<br>
yoffset correctly because for the 1D array case this needs to be<br>
interpreted as a slice offset.<br>
<br>
I'm attaching a patch which I think fixes it, although I haven't managed<br>
to test it with the arb_direct_state_access/gettextureimage-targets test<br>
so I don't know if I'm misunderstanding something. It is also not<br>
complete because it doesn't touch GetTexSubImage. I have tested it with<br>
the texsubimage test which does use the yoffset, but in order to use<br>
that test the code path first needs to be able to accept the<br>
IMAGE_HEIGHT packing option which I will also post a patch for.<br>
<br>
Regards,<br>
- Neil<br>
<br>
------- >8 --------------- (use git am --scissors to automatically chop here)<br>
Subject: meta: Fix the y offset for 1D_ARRAY in _mesa_meta_pbo_TexSubImage<br>
<br>
This partially reverts 546aba143d13ba3f99 and brings back the if<br>
statement to move the height over to the depth. However it<br>
additionally moves the yoffset to the zoffset. This fixes texsubimage<br>
array pbo for 1D_ARRAY textures.<br>
<br>
The previous fix in 546aba143 wasn't taking into account the yoffset<br>
correctly because it needs to be used to alter the selected layer.<br>
---<br>
 src/mesa/drivers/common/meta_tex_subimage.c | 36 ++++++++++++++---------------<br>
 1 file changed, 18 insertions(+), 18 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c<br>
index 3965d31..be89102 100644<br>
--- a/src/mesa/drivers/common/meta_tex_subimage.c<br>
+++ b/src/mesa/drivers/common/meta_tex_subimage.c<br>
@@ -138,7 +138,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims,<br>
<span>    struct gl_texture_image *pbo_tex_image;<br>
    GLenum status;<br>
    bool success = false;<br>
</span>-   int z, iters;<br>
+   int z;<br>
<span><br>
    /* XXX: This should probably be passed in from somewhere */<br>
    const char *where = "_mesa_meta_pbo_TexSubImage";<br>
</span>@@ -193,6 +193,16 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims,<br>
<span>    _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]);<br>
    _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, fbos[1]);<br>
<br>
</span><span>+   if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) {<br>
</span>+      assert(depth == 1);<br>
+      assert(zoffset == 0);<br>
+      depth = height;<br>
+      height = 1;<br>
+      image_height = 1;<br>
+      zoffset = yoffset;<br>
+      yoffset = 0;<br>
<span>+   }<br>
+<br>
    _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
                              pbo_tex_image, 0);<br>
    /* If this passes on the first layer it should pass on the others */<br>
</span>@@ -216,28 +226,18 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims,<br>
                                   GL_COLOR_BUFFER_BIT, GL_NEAREST))<br>
       goto fail;<br>
<br>
<span>-   iters = tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY ?<br>
</span>-           height : depth;<br>
-<br>
-   for (z = 1; z < iters; z++) {<br>
+   for (z = 1; z < depth; z++) {<br>
       _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,<br>
                                 tex_image, zoffset + z);<br>
<br>
       _mesa_update_state(ctx);<br>
<span><br>
-      if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY)<br>
</span><span>-         _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,<br>
</span><span>-                                    0, z, width, z + 1,<br>
</span>-                                    xoffset, yoffset,<br>
-                                    xoffset + width, yoffset + 1,<br>
-                                    GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
-      else<br>
<span>-         _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,<br>
</span>-                                    0, z * image_height,<br>
-                                    width, z * image_height + height,<br>
<span>-                                    xoffset, yoffset,<br>
-                                    xoffset + width, yoffset + height,<br>
-                                    GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
</span><span>+      _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,<br>
</span>+                                 0, z * image_height,<br>
+                                 width, z * image_height + height,<br>
<div><div>+                                 xoffset, yoffset,<br>
+                                 xoffset + width, yoffset + height,<br>
+                                 GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
    }<br>
<br>
    success = true;<br>
</div></div><span><font color="#888888">--<br>
1.9.3<br>
<br>
<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>