Bug 101378 - interpolateAtSample check for input parameter is too strict
Summary: interpolateAtSample check for input parameter is too strict
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: 17.0
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-11 09:38 UTC by freedesktop
Modified: 2017-11-03 15:53 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description freedesktop 2017-06-11 09:38:59 UTC
The following code snippet fails on Mesa 17.0.3 with the following error:

    in GeometryToPixel
    {
	vec3 color;
	vec2 uv;
    } gs2ps;

   out vec4 Color;

   void main ()
   {
	Color = vec4(gs2ps.color, 1);

	if (length(interpolateAtSample(gs2ps.uv, gl_SampleID))>1) {
		discard;
	}
    }

This is the error:

    0:10(1): error: if a fragment input is (or contains) an integer, then it must be qualified with 'flat'
    0:10(8): error: `gl_SampleID' redeclared
    0:18(33): error: parameter `interpolant` must be a shader input
    0:18(6): error: no matching function for call to `length(error)'; candidates are:
    0:18(6): error:    float length(float)
    0:18(6): error:    float length(vec2)
    0:18(6): error:    float length(vec3)
    0:18(6): error:    float length(vec4)
    0:18(6): error:    double length(double)
    0:18(6): error:    double length(dvec2)
    0:18(6): error:    double length(dvec3)
    0:18(6): error:    double length(dvec4)
    0:18(6): error: operands to relational operators must be scalar and numeric
    0:18(6): error: if-statement condition must be scalar boolean

Changing the shader to use:

    in	vec3 icolor;
    in	vec2 iuv;

fixes the problem. This seems to be related to https://patchwork.freedesktop.org/patch/15298/, but the input variable check is too strict. It should work with an input block as well, which is for instance used by the G-Truc samples: https://github.com/g-truc/ogl-samples/blob/655559499c23b9566ac432cc2af33cde6646271c/data/gl-400/fbo-multisample-interpolate.frag

Code in question works fine on AMD desktop drivers.
Comment 1 freedesktop 2017-06-11 09:41:00 UTC
Sorry, copy/paste error, the first two lines are from another unrelated error. The correct error message is just this part:

    0:18(33): error: parameter `interpolant` must be a shader input
    0:18(6): error: no matching function for call to `length(error)'; candidates are:
    0:18(6): error:    float length(float)
    0:18(6): error:    float length(vec2)
    0:18(6): error:    float length(vec3)
    0:18(6): error:    float length(vec4)
    0:18(6): error:    double length(double)
    0:18(6): error:    double length(dvec2)
    0:18(6): error:    double length(dvec3)
    0:18(6): error:    double length(dvec4)
    0:18(6): error: operands to relational operators must be scalar and numeric
    0:18(6): error: if-statement condition must be scalar boolean
Comment 2 Nicolai Hähnle 2017-06-13 10:24:36 UTC
Thanks for the report. It does indeed look like this should be valid GLSL. I'm looking into it.
Comment 3 freedesktop 2017-06-13 16:09:34 UTC
Thanks a lot, couldn't have wished for another person to look into this :)
Comment 4 Matias N. Goldberg 2017-09-24 06:45:55 UTC
+1 to this bug.

I just hit it after our refactor allowed our OpenGL backend to use more advanced MSAA functionalities.

Our code in question (heavily cut):
in block
{
	flat uint drawId;
		
	vec3 pos;
	vec3 normal;
					
	vec2 uv0;
	
	vec4 posL0;
	vec4 posL1;
	vec4 posL2;
	float depth;
	float2 zwDepth;
} inPs;

vec2 pixelDepthZW;
pixelDepthZW = interpolateAtSample( inPs.zwDepth, 0 );

Mesa complains this is invalid (error: parameter `interpolant` must be a shader input), though to the best of my knowledge, it should be. AMD Windows drivers accept this fine, Windows propietary drivers only complain if I write interpolateAtSample( inPs.zwDepth.y, 0 ) which I was surprised to learn the spec kind of disallows it.

I'm glad someone already reported it.

I'm using git 57c8ead0cd
Comment 5 Nicolai Hähnle 2017-09-24 07:08:40 UTC
Thanks for the reminder. There were some related spec issues that we cleared up with the GL and ES working groups, but I have a set of patches that is almost ready to go in.
Comment 6 Nicolai Hähnle 2017-11-03 15:53:21 UTC
Finally fixed in master, commit ca63a5ed3e9efb2bd645b425f7393089f4e132a6.


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.