Mesa (master): Revert "glsl: set vector_elements to 1 for samplers"

Matt Turner mattst88 at kemper.freedesktop.org
Fri Apr 28 18:49:06 UTC 2017


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Fri Apr 28 11:48:29 2017 -0700

Revert "glsl: set vector_elements to 1 for samplers"

This reverts commit 75a31a20af269c047661af33e28f793269537b79.

This breaks thousands of tests on i965 with malloc corruption.

---

 src/compiler/glsl_types.cpp     |  7 ++++++-
 src/mesa/main/uniform_query.cpp | 15 ++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index bf078ad614..0480bef80e 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -95,7 +95,12 @@ glsl_type::glsl_type(GLenum gl_type, glsl_base_type base_type,
 
    memset(& fields, 0, sizeof(fields));
 
-   matrix_columns = vector_elements = 1;
+   if (is_sampler()) {
+      /* Samplers take no storage whatsoever. */
+      matrix_columns = vector_elements = 0;
+   } else {
+      matrix_columns = vector_elements = 1;
+   }
 }
 
 glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 114f6fb5be..e400d0eb00 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -321,7 +321,8 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
    }
 
    {
-      unsigned elements = uni->type->components();
+      unsigned elements = (uni->type->is_sampler())
+	 ? 1 : uni->type->components();
       const int dmul = uni->type->is_64bit() ? 2 : 1;
       const int rmul = glsl_base_type_is_64bit(returnType) ? 2 : 1;
 
@@ -647,8 +648,10 @@ _mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni,
 {
    unsigned i;
 
-   const unsigned components = uni->type->vector_elements;
-   const unsigned vectors = uni->type->matrix_columns;
+   /* vector_elements and matrix_columns can be 0 for samplers.
+    */
+   const unsigned components = MAX2(1, uni->type->vector_elements);
+   const unsigned vectors = MAX2(1, uni->type->matrix_columns);
    const int dmul = uni->type->is_64bit() ? 2 : 1;
 
    /* Store the data in the driver's requested type in the driver's storage
@@ -800,7 +803,8 @@ validate_uniform(GLint location, GLsizei count, const GLvoid *values,
    }
 
    /* Verify that the types are compatible. */
-   const unsigned components = uni->type->vector_elements;
+   const unsigned components = uni->type->is_sampler()
+      ? 1 : uni->type->vector_elements;
 
    if (components != src_components) {
       /* glUniformN() must match float/vecN type */
@@ -921,7 +925,8 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid *values,
          return;
    }
 
-   const unsigned components = uni->type->vector_elements;
+   const unsigned components = uni->type->is_sampler()
+      ? 1 : uni->type->vector_elements;
 
    /* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
     *




More information about the mesa-commit mailing list