mirror of
https://github.com/RPCS3/glslang.git
synced 2024-12-03 16:41:30 +00:00
a64ed3eba0
Unlike other qualifiers, HLSL allows "sample" to be either a qualifier keyword or an identifier (e.g, a variable or function name). A fix to allow this was made a while ago, but that fix was insufficient when 'sample' was used in an expression. The problem was around the initial ambiguity between: sample float a; // "sample" is part of a fully specified type and sample.xyz; // sample is a keyword in a dot expression Both start the same. The "sample" was being accepted as a qualifier before enough further parsing was done to determine we were not a declaration after all. This consumed the token, causing it to fail for its real purpose. Now, when accepting a fully specified type, the token is pushed back onto the stack if the thing is not a fully specified type. This leaves it available for subsequent purposes. Changed the "hlsl.identifier.sample.frag" test to exercise this situation, distilled down from a production shaders.
19 lines
478 B
GLSL
19 lines
478 B
GLSL
|
|
struct MyStruct {
|
|
sample float a;
|
|
noperspective float b;
|
|
linear float c;
|
|
centroid float d;
|
|
};
|
|
|
|
int sample(int x) { return x; } // HLSL allows this as an identifier as well.
|
|
|
|
float4 main() : SV_Target0
|
|
{
|
|
// HLSL allows this as an identifier as well.
|
|
// However, this is not true of other qualifier keywords such as "linear".
|
|
float4 sample = float4(3,4,5,6);
|
|
|
|
return sample.rgba; // 'sample' can participate in an expression.
|
|
}
|