<div dir="ltr">Yeah, I'm trying to get some bug fixes finished for meta_tex_subimage.c.  The original doesn't handle array textures properly.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 24, 2015 at 8:31 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"><div class="HOEnZb"><div class="h5">Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>> writes:<br>
<br>
> using a flag passed in as function parameter. This will enable<br>
> _mesa_meta_pbo_GetTexSubImage to be used for reading in to<br>
> non-pbo buffers.<br>
><br>
> This will be useful to support reading from YF/YS tiled surfaces<br>
> in Skylake.<br>
><br>
> Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br>
> ---<br>
>  src/mesa/drivers/common/meta.h               |  1 +<br>
>  src/mesa/drivers/common/meta_tex_subimage.c  | 18 ++++++++++++++++--<br>
>  src/mesa/drivers/dri/i965/intel_pixel_read.c |  9 ++++-----<br>
>  src/mesa/drivers/dri/i965/intel_tex_image.c  |  3 ++-<br>
>  4 files changed, 23 insertions(+), 8 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h<br>
> index e7d894d..3de0d87 100644<br>
> --- a/src/mesa/drivers/common/meta.h<br>
> +++ b/src/mesa/drivers/common/meta.h<br>
> @@ -542,6 +542,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,<br>
>                                int xoffset, int yoffset, int zoffset,<br>
>                                int width, int height, int depth,<br>
>                                GLenum format, GLenum type, const void *pixels,<br>
> +                              bool create_pbo,<br>
>                                const struct gl_pixelstore_attrib *packing);<br>
><br>
>  extern void<br>
> diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c<br>
> index 68c8273..cd87a72 100644<br>
> --- a/src/mesa/drivers/common/meta_tex_subimage.c<br>
> +++ b/src/mesa/drivers/common/meta_tex_subimage.c<br>
> @@ -34,6 +34,7 @@<br>
>  #include "macros.h"<br>
>  #include "meta.h"<br>
>  #include "pbo.h"<br>
> +#include "readpix.h"<br>
>  #include "shaderapi.h"<br>
>  #include "state.h"<br>
>  #include "teximage.h"<br>
> @@ -246,6 +247,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,<br>
>                                int xoffset, int yoffset, int zoffset,<br>
>                                int width, int height, int depth,<br>
>                                GLenum format, GLenum type, const void *pixels,<br>
> +                              bool create_pbo,<br>
>                                const struct gl_pixelstore_attrib *packing)<br>
>  {<br>
>     GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 };<br>
> @@ -257,7 +259,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,<br>
>     /* XXX: This should probably be passed in from somewhere */<br>
>     const char *where = "_mesa_meta_pbo_GetTexSubImage";<br>
><br>
> -   if (!_mesa_is_bufferobj(packing->BufferObj))<br>
> +   if (!_mesa_is_bufferobj(packing->BufferObj) && !create_pbo)<br>
>        return false;<br>
><br>
>     if (format == GL_DEPTH_COMPONENT ||<br>
> @@ -282,7 +284,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,<br>
>        return true;<br>
>     }<br>
><br>
> -   pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER,<br>
> +   pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, GL_PIXEL_PACK_BUFFER,<br>
>                                            width, height, depth,<br>
>                                            format, type, pixels, packing,<br>
>                                            &pbo, &pbo_tex);<br>
> @@ -348,6 +350,18 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims,<br>
>                                   GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
>     }<br>
><br>
> +   /* If we created a temporary pbo in meta to read the pixel data, that<br>
> +    * data will now get copied to memory allocated by client.<br>
> +    */<br>
> +   if (create_pbo) {<br>
<br>
</div></div>I think this should be changed to something like the below:<br>
<br>
 if (create_pbo && !_mesa_is_bufferobj(packing->BufferObj))<br>
<br>
It looks like the meaning of create_pbo in create_texture_for_pbo is<br>
‘create pbo unless there is already a pbo’. With this patch<br>
_mesa_meta_pbo_GetTexSubImage seems to interpret it to mean that it will<br>
always create the pbo and if there already was a pbo it would end up<br>
clobbering the state.<br>
<span class=""><br>
> +      /* Unbind the pbo from pack binding. */<br>
> +      _mesa_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);<br>
<br>
</span>I don't think this unbind is necessary. create_texture_for_pbo is<br>
careful not to modify the PBO binding state and once that function is<br>
finished the PBO is only accessed via the texture so we shouldn't need<br>
to touch the PBO binding.<br>
<span class=""><br>
> +      _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[1]);<br>
> +      _mesa_update_state(ctx);<br>
> +      _mesa_readpixels(ctx, 0, 0, width, height, format, type,<br>
> +                       packing, (void *) pixels);<br>
<br>
</span>Doesn't this only read the last slice of the texture? Maybe this patch<br>
should wait until this patch from Laura Ekstrand is landed:<br>
<br>
<a href="http://lists.freedesktop.org/archives/mesa-dev/2015-February/077487.html" target="_blank">http://lists.freedesktop.org/archives/mesa-dev/2015-February/077487.html</a><br>
<br>
Regards,<br>
- Neil<br>
<br>_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<br></blockquote></div><br></div>