Bug 38987 - sampler allowed as non-uniform / non-function parameters
Summary: sampler allowed as non-uniform / non-function parameters
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: Paul Berry
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-05 15:17 UTC by Ian Romanick
Modified: 2011-07-21 14:36 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Test case (314 bytes, text/plain)
2011-07-05 15:17 UTC, Ian Romanick
Details

Description Ian Romanick 2011-07-05 15:17:08 UTC
Created attachment 48790 [details]
Test case

While writing a GLSL shader, I discovered that Mesa's compiler allows samplers to be declared as global variables without being uniforms.  GLSL has always required that samplers be either uniforms or function parameters.

That attached piglit test case fails.
Comment 1 Ian Romanick 2011-07-21 14:36:48 UTC
This is fixed on master by the commits below.  These have been cherry picked to 7.11 (f80ae99) and 7.10 (0a838d1).

commit f07221056e1822187546b76387714b3172f9b2c5
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Jul 12 12:03:02 2011 -0700

    glsl: Ensure that sampler declarations are always uniform or "in" parameters
    
    This brings us into compliance with page 17 (page 22 of the PDF) of
    the GLSL 1.20 spec:
    
        "[Sampler types] can only be declared as function parameters or
        uniform variables (see Section 4.3.5 "Uniform"). ... [Samplers]
        cannot be used as out or inout function parameters."
    
    The spec isn't explicit about whether this rule applies to
    structs/arrays containing shaders, but the intent seems to be to
    ensure that it can always be determined at compile time which sampler
    is being used in each texture lookup.  So to avoid creating a
    loophole, the rule needs to apply to structs/arrays containing shaders
    as well.
    
    Fixes piglit tests spec/glsl-1.10/compiler/samplers/*.frag, and fixes
    bug 38987.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38987
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>

commit ddc1c96390b685bb95f7431e862c3a64fcefa085
Author: Paul Berry <stereotype441@gmail.com>
Date:   Mon Jul 11 16:44:13 2011 -0700

    glsl: Move type_contains_sampler() into glsl_type for later reuse.
    
    The new location, as a member function of glsl_type, is more
    consistent with queries like is_sampler(), is_boolean(), is_float(),
    etc.  Placing the function inside glsl_type also makes it available to
    any code that uses glsl_types.


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.