Bug 68195 - piglit tests vs-struct-pad and fs-struct-pad both fail
Summary: piglit tests vs-struct-pad and fs-struct-pad both fail
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Ian Romanick
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-16 17:50 UTC by Ian Romanick
Modified: 2013-08-27 23:47 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Ian Romanick 2013-08-16 17:50:05 UTC
Adding some instrumentation to shader_runner shows that the compiler tells the application the correct offsets of 0, 4, 8, and 12 for s.s1.r, s.s2.g, s.s2.b, and s.s2.a, respectively.  However, the IR generated is full of madness:

GLSL IR for native vertex shader 3:
(
(declare (uniform ) S@0x20bdb90 s)
(declare (shader_out ) vec4 gl_Position)
(declare (shader_in ) vec4 vertex)
(declare (shader_out ) vec4 v)
(function main
  (signature void
    (parameters
    )
    (
      (assign  (xyzw) (var_ref gl_Position)  (var_ref vertex) ) 
      (declare (temporary ) vec4 vec_ctor)
      (assign  (x) (var_ref vec_ctor)  (expression float ubo_load (constant uint (0)) (constant uint (0)) ) ) 
      (assign  (y) (var_ref vec_ctor)  (expression float ubo_load (constant uint (0)) (constant uint (16)) ) ) 
      (assign  (z) (var_ref vec_ctor)  (expression float ubo_load (constant uint (0)) (constant uint (32)) ) ) 
      (assign  (w) (var_ref vec_ctor)  (expression float ubo_load (constant uint (0)) (constant uint (32)) ) ) 
      (assign  (xyzw) (var_ref v)  (var_ref vec_ctor) ) 
    ))

)


)
Comment 1 Ian Romanick 2013-08-16 17:50:57 UTC
Also, the tests are currently broken because they try to declare structures inside the uniform block.  This is explicitly forbidden by the spec.
Comment 2 Ian Romanick 2013-08-27 23:47:28 UTC
commit 574e4843e9e26aa6affa31c80ac42f745b68268b
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Sat Aug 17 00:27:43 2013 -0700

    glsl: Use alignment of container record for its first field
    
    The first field of a record in a UBO has the aligment of the record
    itself.
    
    Fixes piglit vs-struct-pad, fs-struct-pad, and (with the patch posted to
    the piglit list that extends the test) layout-std140.
    
    NOTE: The bit of strangeness with the version of visit_field without the
    record_type poitner is because that method is pure virtual in the base
    class.  The original implementation of the class did this to ensure
    derived classes remembered to implement that flavor.  Now they can
    implement either flavor but not both.  I don't know a C++ way to enforce
    that.
    
    Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
    Reviewed-by: Paul Berry <stereotype441@gmail.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=68195
    Cc: "9.2 9.1" mesa-stable@lists.freedesktop.org


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.