glsl: avoid calling base_alignment when samplers are involved
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 23 Mar 2015 10:32:08 +0000 (06:32 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Tue, 24 Mar 2015 14:10:13 +0000 (10:10 -0400)
Earlier commit 53bf7c8fd2e changed the logic to always call
base_alignment on structs. 1ec715ce8b12 hacked the function to return 0
for sampler fields, but didn't handle sampler arrays. Instead of
extending the hack, avoid calling base_alignment in the first place on
non-UBO uniforms.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89726
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tapani Palli <tapani.palli@intel.com>
src/glsl/glsl_types.cpp
src/glsl/link_uniforms.cpp

index 38b37a6a94bddd9620c210d002b84945151c056f..be87b0a2d24140d57110433a0beb091fe9e7f3d7 100644 (file)
@@ -1077,15 +1077,6 @@ glsl_type::std140_base_alignment(bool row_major) const
       return base_alignment;
    }
 
-   /* A sampler may never occur in a UBO (without bindless of some sort),
-    * however it is convenient to use this alignment function even with
-    * regular uniforms. This allows use of this function on uniform structs
-    * that contain samplers.
-    */
-   if (this->is_sampler()) {
-      return 0;
-   }
-
    assert(!"not reached");
    return -1;
 }
index 799c74bb9e6f591f679f96f03ae9242620aa2966..59adc298b913fe3fe0dfceb6f5c956c3c1d7bcbb 100644 (file)
@@ -547,6 +547,8 @@ private:
    virtual void enter_record(const glsl_type *type, const char *name,
                              bool row_major) {
       assert(type->is_record());
+      if (this->ubo_block_index == -1)
+         return;
       this->ubo_byte_offset = glsl_align(
             this->ubo_byte_offset, type->std140_base_alignment(row_major));
    }
@@ -554,6 +556,8 @@ private:
    virtual void leave_record(const glsl_type *type, const char *name,
                              bool row_major) {
       assert(type->is_record());
+      if (this->ubo_block_index == -1)
+         return;
       this->ubo_byte_offset = glsl_align(
             this->ubo_byte_offset, type->std140_base_alignment(row_major));
    }