Mesa (master): meta: Expand the vertex structure for the GenerateMipmap and decompress paths

Eric Anholt anholt at kemper.freedesktop.org
Tue Feb 11 22:24:44 UTC 2014


Module: Mesa
Branch: master
Commit: 83c90c9239404412dc61aa3b0229ebd56a1406cf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=83c90c9239404412dc61aa3b0229ebd56a1406cf

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sat Dec 14 00:57:06 2013 -0800

meta: Expand the vertex structure for the GenerateMipmap and decompress paths

Final intermediate step leading to some code sharing.  Note that the new
GemerateMipmap and decompress vertex structures are the same as the new vertex
structure in BlitFramebuffer and the others.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/mesa/drivers/common/meta.c |   29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index e56440f..0c5c63d 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3249,10 +3249,10 @@ setup_texture_coords(GLenum faceTarget,
                      GLint width,
                      GLint height,
                      GLint depth,
-                     GLfloat coords0[3],
-                     GLfloat coords1[3],
-                     GLfloat coords2[3],
-                     GLfloat coords3[3])
+                     GLfloat coords0[4],
+                     GLfloat coords1[4],
+                     GLfloat coords2[4],
+                     GLfloat coords3[4])
 {
    static const GLfloat st[4][2] = {
       {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f}
@@ -3260,6 +3260,13 @@ setup_texture_coords(GLenum faceTarget,
    GLuint i;
    GLfloat r;
 
+   /* Currently all texture targets want the W component to be 1.0.
+    */
+   coords0[3] = 1.0F;
+   coords1[3] = 1.0F;
+   coords2[3] = 1.0F;
+   coords3[3] = 1.0F;
+
    switch (faceTarget) {
    case GL_TEXTURE_1D:
    case GL_TEXTURE_2D:
@@ -3396,7 +3403,7 @@ static void
 setup_ff_generate_mipmap(struct gen_mipmap_state *mipmap)
 {
    struct vertex {
-      GLfloat x, y, tex[3];
+      GLfloat x, y, z, tex[4];
    };
 
    if (mipmap->VAO == 0) {
@@ -3473,7 +3480,7 @@ setup_glsl_generate_mipmap(struct gl_context *ctx,
                            GLenum target)
 {
    struct vertex {
-      GLfloat x, y, tex[3];
+      GLfloat x, y, z, tex[4];
    };
    struct glsl_sampler *sampler;
    const char *vs_source;
@@ -3619,7 +3626,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
 {
    struct gen_mipmap_state *mipmap = &ctx->Meta->Mipmap;
    struct vertex {
-      GLfloat x, y, tex[3];
+      GLfloat x, y, z, tex[4];
    };
    struct vertex verts[4];
    const GLuint baseLevel = texObj->BaseLevel;
@@ -3709,6 +3716,9 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
    else
       assert(!genMipmapSave);
 
+   /* Silence valgrind warnings about reading uninitialized stack. */
+   memset(verts, 0, sizeof(verts));
+
    /* Setup texture coordinates */
    setup_texture_coords(faceTarget,
                         slice,
@@ -4018,7 +4028,7 @@ decompress_texture_image(struct gl_context *ctx,
    const GLenum target = texObj->Target;
    GLenum faceTarget;
    struct vertex {
-      GLfloat x, y, tex[3];
+      GLfloat x, y, z, tex[4];
    };
    struct vertex verts[4];
    GLuint fboDrawSave, fboReadSave;
@@ -4127,6 +4137,9 @@ decompress_texture_image(struct gl_context *ctx,
       _mesa_BindSampler(ctx->Texture.CurrentUnit, decompress->Sampler);
    }
 
+   /* Silence valgrind warnings about reading uninitialized stack. */
+   memset(verts, 0, sizeof(verts));
+
    setup_texture_coords(faceTarget, slice, width, height, depth,
                         verts[0].tex,
                         verts[1].tex,




More information about the mesa-commit mailing list