<div dir="ltr">I will take a look soon.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 16, 2014 at 7:52 AM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ping.  Could someone review this GL_ARB_get_texture_sub_image series?<span class="HOEnZb"><font color="#888888"><br>
<br>
-Brian</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On 12/13/2014 07:42 AM, Brian Paul wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In preparation for getting texture sub images.<br>
---<br>
  src/mesa/drivers/common/meta.c                 | 88 +++++++++++++++++---------<br>
  src/mesa/drivers/common/meta.h                 |  4 ++<br>
  src/mesa/drivers/common/meta_<u></u>generate_mipmap.c |  4 +-<br>
  3 files changed, 64 insertions(+), 32 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/common/<u></u>meta.c b/src/mesa/drivers/common/<u></u>meta.c<br>
index 87532c1..a84e512 100644<br>
--- a/src/mesa/drivers/common/<u></u>meta.c<br>
+++ b/src/mesa/drivers/common/<u></u>meta.c<br>
@@ -2450,30 +2450,53 @@ _mesa_meta_Bitmap(struct gl_context *ctx,<br>
<br>
  /**<br>
   * Compute the texture coordinates for the four vertices of a quad for<br>
- * drawing a 2D texture image or slice of a cube/3D texture.<br>
+ * drawing a 2D texture image or slice of a cube/3D texture.  The offset<br>
+ * and width, height specify a sub-region of the 2D image.<br>
+ *<br>
   * \param faceTarget  GL_TEXTURE_1D/2D/3D or cube face name<br>
   * \param slice  slice of a 1D/2D array texture or 3D texture<br>
- * \param width  width of the texture image<br>
- * \param height  height of the texture image<br>
+ * \param xoffset  X position of sub texture<br>
+ * \param yoffset  Y position of sub texture<br>
+ * \param width  width of the sub texture image<br>
+ * \param height  height of the sub texture image<br>
+ * \param total_width  total width of the texture image<br>
+ * \param total_height  total height of the texture image<br>
+ * \param total_depth  total depth of the texture image<br>
   * \param coords0/1/2/3  returns the computed texcoords<br>
   */<br>
  void<br>
  _mesa_meta_setup_texture_<u></u>coords(GLenum faceTarget,<br>
                                  GLint slice,<br>
+                                GLint xoffset,<br>
+                                GLint yoffset,<br>
                                  GLint width,<br>
                                  GLint height,<br>
-                                GLint depth,<br>
+                                GLint total_width,<br>
+                                GLint total_height,<br>
+                                GLint total_depth,<br>
                                  GLfloat coords0[4],<br>
                                  GLfloat coords1[4],<br>
                                  GLfloat coords2[4],<br>
                                  GLfloat coords3[4])<br>
  {<br>
-   static const GLfloat st[4][2] = {<br>
-      {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}<br>
-   };<br>
+   float st[4][2];<br>
     GLuint i;<br>
+   const float s0 = (float) xoffset / (float) total_width;<br>
+   const float s1 = (float) (xoffset + width) / (float) total_width;<br>
+   const float t0 = (float) yoffset / (float) total_height;<br>
+   const float t1 = (float) (yoffset + height) / (float) total_height;<br>
     GLfloat r;<br>
<br>
+   /* setup the reference texcoords */<br>
+   st[0][0] = s0;<br>
+   st[0][1] = t0;<br>
+   st[1][0] = s1;<br>
+   st[1][1] = t0;<br>
+   st[2][0] = s1;<br>
+   st[2][1] = t1;<br>
+   st[3][0] = s0;<br>
+   st[3][1] = t1;<br>
+<br>
     if (faceTarget == GL_TEXTURE_CUBE_MAP_ARRAY)<br>
        faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + slice % 6;<br>
<br>
@@ -2490,52 +2513,52 @@ _mesa_meta_setup_texture_<u></u>coords(GLenum faceTarget,<br>
     case GL_TEXTURE_3D:<br>
     case GL_TEXTURE_2D_ARRAY:<br>
        if (faceTarget == GL_TEXTURE_3D) {<br>
-         assert(slice < depth);<br>
-         assert(depth >= 1);<br>
-         r = (slice + 0.5f) / depth;<br>
+         assert(slice < total_depth);<br>
+         assert(total_depth >= 1);<br>
+         r = (slice + 0.5f) / total_depth;<br>
        }<br>
        else if (faceTarget == GL_TEXTURE_2D_ARRAY)<br>
           r = (float) slice;<br>
        else<br>
           r = 0.0F;<br>
-      coords0[0] = 0.0F; /* s */<br>
-      coords0[1] = 0.0F; /* t */<br>
+      coords0[0] = st[0][0]; /* s */<br>
+      coords0[1] = st[0][1]; /* t */<br>
        coords0[2] = r; /* r */<br>
-      coords1[0] = 1.0F;<br>
-      coords1[1] = 0.0F;<br>
+      coords1[0] = st[1][0];<br>
+      coords1[1] = st[1][1];<br>
        coords1[2] = r;<br>
-      coords2[0] = 1.0F;<br>
-      coords2[1] = 1.0F;<br>
+      coords2[0] = st[2][0];<br>
+      coords2[1] = st[2][1];<br>
        coords2[2] = r;<br>
-      coords3[0] = 0.0F;<br>
-      coords3[1] = 1.0F;<br>
+      coords3[0] = st[3][0];<br>
+      coords3[1] = st[3][1];<br>
        coords3[2] = r;<br>
        break;<br>
     case GL_TEXTURE_RECTANGLE_ARB:<br>
-      coords0[0] = 0.0F; /* s */<br>
-      coords0[1] = 0.0F; /* t */<br>
+      coords0[0] = (float) xoffset; /* s */<br>
+      coords0[1] = (float) yoffset; /* t */<br>
        coords0[2] = 0.0F; /* r */<br>
-      coords1[0] = (float) width;<br>
-      coords1[1] = 0.0F;<br>
+      coords1[0] = (float) (xoffset + width);<br>
+      coords1[1] = (float) yoffset;<br>
        coords1[2] = 0.0F;<br>
-      coords2[0] = (float) width;<br>
-      coords2[1] = (float) height;<br>
+      coords2[0] = (float) (xoffset + width);<br>
+      coords2[1] = (float) (yoffset + height);<br>
        coords2[2] = 0.0F;<br>
-      coords3[0] = 0.0F;<br>
-      coords3[1] = (float) height;<br>
+      coords3[0] = (float) xoffset;<br>
+      coords3[1] = (float) (yoffset + height);<br>
        coords3[2] = 0.0F;<br>
        break;<br>
     case GL_TEXTURE_1D_ARRAY:<br>
-      coords0[0] = 0.0F; /* s */<br>
+      coords0[0] = st[0][0]; /* s */<br>
        coords0[1] = (float) slice; /* t */<br>
        coords0[2] = 0.0F; /* r */<br>
-      coords1[0] = 1.0f;<br>
+      coords1[0] = st[1][0];<br>
        coords1[1] = (float) slice;<br>
        coords1[2] = 0.0F;<br>
-      coords2[0] = 1.0F;<br>
+      coords2[0] = st[2][0];<br>
        coords2[1] = (float) slice;<br>
        coords2[2] = 0.0F;<br>
-      coords3[0] = 0.0F;<br>
+      coords3[0] = st[3][0];<br>
        coords3[1] = (float) slice;<br>
        coords3[2] = 0.0F;<br>
        break;<br>
@@ -3069,7 +3092,10 @@ decompress_texture_image(<u></u>struct gl_context *ctx,<br>
     /* Silence valgrind warnings about reading uninitialized stack. */<br>
     memset(verts, 0, sizeof(verts));<br>
<br>
-   _mesa_meta_setup_texture_<u></u>coords(faceTarget, slice, width, height, depth,<br>
+   _mesa_meta_setup_texture_<u></u>coords(faceTarget, slice,<br>
+                                   0, 0, width, height,<br>
+                                   texImage->Width, texImage->Height,<br>
+                                   texImage->Depth,<br>
                                     verts[0].tex,<br>
                                     verts[1].tex,<br>
                                     verts[2].tex,<br>
diff --git a/src/mesa/drivers/common/<u></u>meta.h b/src/mesa/drivers/common/<u></u>meta.h<br>
index 6ecf3c0..03e5191 100644<br>
--- a/src/mesa/drivers/common/<u></u>meta.h<br>
+++ b/src/mesa/drivers/common/<u></u>meta.h<br>
@@ -569,9 +569,13 @@ _mesa_meta_alloc_texture(<u></u>struct temp_texture *tex,<br>
  void<br>
  _mesa_meta_setup_texture_<u></u>coords(GLenum faceTarget,<br>
                                  GLint slice,<br>
+                                GLint xoffset,<br>
+                                GLint yoffset,<br>
                                  GLint width,<br>
                                  GLint height,<br>
                                  GLint depth,<br>
+                                GLint total_width,<br>
+                                GLint total_height,<br>
                                  GLfloat coords0[4],<br>
                                  GLfloat coords1[4],<br>
                                  GLfloat coords2[4],<br>
diff --git a/src/mesa/drivers/common/<u></u>meta_generate_mipmap.c b/src/mesa/drivers/common/<u></u>meta_generate_mipmap.c<br>
index 8ffd8da..58b9a53 100644<br>
--- a/src/mesa/drivers/common/<u></u>meta_generate_mipmap.c<br>
+++ b/src/mesa/drivers/common/<u></u>meta_generate_mipmap.c<br>
@@ -317,7 +317,9 @@ _mesa_meta_GenerateMipmap(<u></u>struct gl_context *ctx, GLenum target,<br>
           /* Setup texture coordinates */<br>
           _mesa_meta_setup_texture_<u></u>coords(faceTarget,<br>
                                           layer,<br>
-                                         0, 0, 1, /* width, height never used here */<br>
+                                         0, 0, /* xoffset, yoffset */<br>
+                                         srcWidth, srcHeight, /* img size */<br>
+                                         srcWidth, srcHeight, srcDepth,<br>
                                           verts[0].tex,<br>
                                           verts[1].tex,<br>
                                           verts[2].tex,<br>
<br>
</blockquote>
<br></div></div><div class="HOEnZb"><div class="h5">
______________________________<u></u>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div></div>