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.
126 lines
4.7 KiB
Plaintext
126 lines
4.7 KiB
Plaintext
hlsl.identifier.sample.frag
|
|
Shader version: 450
|
|
gl_FragCoord origin is upper left
|
|
0:? Sequence
|
|
0:9 Function Definition: sample(i1; (temp int)
|
|
0:9 Function Parameters:
|
|
0:9 'x' (in int)
|
|
0:? Sequence
|
|
0:9 Branch: Return with expression
|
|
0:9 'x' (in int)
|
|
0:12 Function Definition: main( (temp 4-component vector of float)
|
|
0:12 Function Parameters:
|
|
0:? Sequence
|
|
0:15 Sequence
|
|
0:15 move second child to first child (temp 4-component vector of float)
|
|
0:15 'sample' (temp 4-component vector of float)
|
|
0:? Constant:
|
|
0:? 3.000000
|
|
0:? 4.000000
|
|
0:? 5.000000
|
|
0:? 6.000000
|
|
0:17 Sequence
|
|
0:17 move second child to first child (temp 4-component vector of float)
|
|
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
|
|
0:17 vector swizzle (temp 4-component vector of float)
|
|
0:17 'sample' (temp 4-component vector of float)
|
|
0:17 Sequence
|
|
0:17 Constant:
|
|
0:17 0 (const int)
|
|
0:17 Constant:
|
|
0:17 1 (const int)
|
|
0:17 Constant:
|
|
0:17 2 (const int)
|
|
0:17 Constant:
|
|
0:17 3 (const int)
|
|
0:17 Branch: Return
|
|
0:? Linker Objects
|
|
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
|
|
|
|
|
|
Linked fragment stage:
|
|
|
|
|
|
Shader version: 450
|
|
gl_FragCoord origin is upper left
|
|
0:? Sequence
|
|
0:9 Function Definition: sample(i1; (temp int)
|
|
0:9 Function Parameters:
|
|
0:9 'x' (in int)
|
|
0:? Sequence
|
|
0:9 Branch: Return with expression
|
|
0:9 'x' (in int)
|
|
0:12 Function Definition: main( (temp 4-component vector of float)
|
|
0:12 Function Parameters:
|
|
0:? Sequence
|
|
0:15 Sequence
|
|
0:15 move second child to first child (temp 4-component vector of float)
|
|
0:15 'sample' (temp 4-component vector of float)
|
|
0:? Constant:
|
|
0:? 3.000000
|
|
0:? 4.000000
|
|
0:? 5.000000
|
|
0:? 6.000000
|
|
0:17 Sequence
|
|
0:17 move second child to first child (temp 4-component vector of float)
|
|
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
|
|
0:17 vector swizzle (temp 4-component vector of float)
|
|
0:17 'sample' (temp 4-component vector of float)
|
|
0:17 Sequence
|
|
0:17 Constant:
|
|
0:17 0 (const int)
|
|
0:17 Constant:
|
|
0:17 1 (const int)
|
|
0:17 Constant:
|
|
0:17 2 (const int)
|
|
0:17 Constant:
|
|
0:17 3 (const int)
|
|
0:17 Branch: Return
|
|
0:? Linker Objects
|
|
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
|
|
|
|
// Module Version 10000
|
|
// Generated by (magic number): 80001
|
|
// Id's are bound by 28
|
|
|
|
Capability Shader
|
|
1: ExtInstImport "GLSL.std.450"
|
|
MemoryModel Logical GLSL450
|
|
EntryPoint Fragment 4 "main" 25
|
|
ExecutionMode 4 OriginUpperLeft
|
|
Name 4 "main"
|
|
Name 10 "sample(i1;"
|
|
Name 9 "x"
|
|
Name 18 "sample"
|
|
Name 25 "@entryPointOutput"
|
|
Decorate 25(@entryPointOutput) Location 0
|
|
2: TypeVoid
|
|
3: TypeFunction 2
|
|
6: TypeInt 32 1
|
|
7: TypePointer Function 6(int)
|
|
8: TypeFunction 6(int) 7(ptr)
|
|
15: TypeFloat 32
|
|
16: TypeVector 15(float) 4
|
|
17: TypePointer Function 16(fvec4)
|
|
19: 15(float) Constant 1077936128
|
|
20: 15(float) Constant 1082130432
|
|
21: 15(float) Constant 1084227584
|
|
22: 15(float) Constant 1086324736
|
|
23: 16(fvec4) ConstantComposite 19 20 21 22
|
|
24: TypePointer Output 16(fvec4)
|
|
25(@entryPointOutput): 24(ptr) Variable Output
|
|
4(main): 2 Function None 3
|
|
5: Label
|
|
18(sample): 17(ptr) Variable Function
|
|
Store 18(sample) 23
|
|
26: 16(fvec4) Load 18(sample)
|
|
Store 25(@entryPointOutput) 26
|
|
Return
|
|
FunctionEnd
|
|
10(sample(i1;): 6(int) Function None 8
|
|
9(x): 7(ptr) FunctionParameter
|
|
11: Label
|
|
12: 6(int) Load 9(x)
|
|
ReturnValue 12
|
|
FunctionEnd
|