diff --git a/Test/baseResults/hlsl.conditional.frag.out b/Test/baseResults/hlsl.conditional.frag.out index e1606817..47c7877a 100644 --- a/Test/baseResults/hlsl.conditional.frag.out +++ b/Test/baseResults/hlsl.conditional.frag.out @@ -216,33 +216,98 @@ gl_FragCoord origin is upper left 0:39 Convert int to float ( temp float) 0:39 'd' ( temp int) 0:39 'input' ( in 4-component vector of float) -0:41 Branch: Return with expression -0:40 add ( temp 4-component vector of float) -0:40 add ( temp 4-component vector of float) -0:40 add ( temp 4-component vector of float) -0:40 add ( temp 4-component vector of float) -0:40 vector-scale ( temp 4-component vector of float) -0:40 Convert int to float ( temp float) -0:40 'e' ( temp int) -0:40 'ret' ( temp 4-component vector of float) -0:40 'f' ( temp 4-component vector of float) -0:40 Function Call: vectorCond( ( temp 4-component vector of float) -0:40 Function Call: scalarCond( ( temp 4-component vector of float) -0:41 Construct vec4 ( temp 4-component vector of float) -0:41 Function Call: fbSelect(vb2;vf2;vf2; ( temp 2-component vector of float) +0:40 Sequence +0:40 move second child to first child ( temp uint) +0:40 'g' ( temp uint) +0:40 Test condition and select ( temp uint): no shortcircuit +0:40 Condition +0:40 Compare Greater Than ( temp bool) +0:40 Convert int to float ( temp float) +0:40 'd' ( temp int) +0:40 Constant: +0:40 0.000000 +0:40 true case +0:40 Constant: +0:40 21 (const uint) +0:40 false case +0:40 Constant: +0:40 0 (const uint) +0:41 Sequence +0:41 move second child to first child ( temp uint) +0:41 'h' ( temp uint) +0:41 Test condition and select ( temp uint): no shortcircuit +0:41 Condition +0:41 Compare Greater Than ( temp bool) +0:41 Convert uint to float ( temp float) +0:41 'g' ( temp uint) 0:41 Constant: -0:41 true (const bool) -0:41 false (const bool) -0:41 Constant: -0:41 1.000000 -0:41 2.000000 -0:41 Constant: -0:41 3.000000 -0:41 4.000000 +0:41 0.000000 +0:41 true case 0:41 Constant: -0:41 10.000000 +0:41 63 (const uint) +0:41 false case 0:41 Constant: -0:41 10.000000 +0:41 0 (const uint) +0:42 Sequence +0:42 move second child to first child ( temp uint) +0:42 'i' ( temp uint) +0:42 Test condition and select ( temp uint): no shortcircuit +0:42 Condition +0:42 Compare Greater Than ( temp bool) +0:42 Convert uint to float ( temp float) +0:42 'h' ( temp uint) +0:42 Constant: +0:42 0.000000 +0:42 true case +0:42 Constant: +0:42 5 (const uint) +0:42 false case +0:42 Constant: +0:42 1 (const uint) +0:43 Sequence +0:43 move second child to first child ( temp uint) +0:43 'j' ( temp uint) +0:43 Convert int to uint ( temp uint) +0:43 Test condition and select ( temp int): no shortcircuit +0:43 Condition +0:43 Compare Greater Than ( temp bool) +0:43 Convert uint to float ( temp float) +0:43 'i' ( temp uint) +0:43 Constant: +0:43 0.000000 +0:43 true case +0:43 Constant: +0:43 43981 (const int) +0:43 false case +0:43 Constant: +0:43 48346 (const int) +0:45 Branch: Return with expression +0:44 add ( temp 4-component vector of float) +0:44 add ( temp 4-component vector of float) +0:44 add ( temp 4-component vector of float) +0:44 add ( temp 4-component vector of float) +0:44 vector-scale ( temp 4-component vector of float) +0:44 Convert int to float ( temp float) +0:44 'e' ( temp int) +0:44 'ret' ( temp 4-component vector of float) +0:44 'f' ( temp 4-component vector of float) +0:44 Function Call: vectorCond( ( temp 4-component vector of float) +0:44 Function Call: scalarCond( ( temp 4-component vector of float) +0:45 Construct vec4 ( temp 4-component vector of float) +0:45 Function Call: fbSelect(vb2;vf2;vf2; ( temp 2-component vector of float) +0:45 Constant: +0:45 true (const bool) +0:45 false (const bool) +0:45 Constant: +0:45 1.000000 +0:45 2.000000 +0:45 Constant: +0:45 3.000000 +0:45 4.000000 +0:45 Constant: +0:45 10.000000 +0:45 Constant: +0:45 10.000000 0:27 Function Definition: PixelShaderFunction( ( temp void) 0:27 Function Parameters: 0:? Sequence @@ -479,33 +544,98 @@ gl_FragCoord origin is upper left 0:39 Convert int to float ( temp float) 0:39 'd' ( temp int) 0:39 'input' ( in 4-component vector of float) -0:41 Branch: Return with expression -0:40 add ( temp 4-component vector of float) -0:40 add ( temp 4-component vector of float) -0:40 add ( temp 4-component vector of float) -0:40 add ( temp 4-component vector of float) -0:40 vector-scale ( temp 4-component vector of float) -0:40 Convert int to float ( temp float) -0:40 'e' ( temp int) -0:40 'ret' ( temp 4-component vector of float) -0:40 'f' ( temp 4-component vector of float) -0:40 Function Call: vectorCond( ( temp 4-component vector of float) -0:40 Function Call: scalarCond( ( temp 4-component vector of float) -0:41 Construct vec4 ( temp 4-component vector of float) -0:41 Function Call: fbSelect(vb2;vf2;vf2; ( temp 2-component vector of float) +0:40 Sequence +0:40 move second child to first child ( temp uint) +0:40 'g' ( temp uint) +0:40 Test condition and select ( temp uint): no shortcircuit +0:40 Condition +0:40 Compare Greater Than ( temp bool) +0:40 Convert int to float ( temp float) +0:40 'd' ( temp int) +0:40 Constant: +0:40 0.000000 +0:40 true case +0:40 Constant: +0:40 21 (const uint) +0:40 false case +0:40 Constant: +0:40 0 (const uint) +0:41 Sequence +0:41 move second child to first child ( temp uint) +0:41 'h' ( temp uint) +0:41 Test condition and select ( temp uint): no shortcircuit +0:41 Condition +0:41 Compare Greater Than ( temp bool) +0:41 Convert uint to float ( temp float) +0:41 'g' ( temp uint) 0:41 Constant: -0:41 true (const bool) -0:41 false (const bool) -0:41 Constant: -0:41 1.000000 -0:41 2.000000 -0:41 Constant: -0:41 3.000000 -0:41 4.000000 +0:41 0.000000 +0:41 true case 0:41 Constant: -0:41 10.000000 +0:41 63 (const uint) +0:41 false case 0:41 Constant: -0:41 10.000000 +0:41 0 (const uint) +0:42 Sequence +0:42 move second child to first child ( temp uint) +0:42 'i' ( temp uint) +0:42 Test condition and select ( temp uint): no shortcircuit +0:42 Condition +0:42 Compare Greater Than ( temp bool) +0:42 Convert uint to float ( temp float) +0:42 'h' ( temp uint) +0:42 Constant: +0:42 0.000000 +0:42 true case +0:42 Constant: +0:42 5 (const uint) +0:42 false case +0:42 Constant: +0:42 1 (const uint) +0:43 Sequence +0:43 move second child to first child ( temp uint) +0:43 'j' ( temp uint) +0:43 Convert int to uint ( temp uint) +0:43 Test condition and select ( temp int): no shortcircuit +0:43 Condition +0:43 Compare Greater Than ( temp bool) +0:43 Convert uint to float ( temp float) +0:43 'i' ( temp uint) +0:43 Constant: +0:43 0.000000 +0:43 true case +0:43 Constant: +0:43 43981 (const int) +0:43 false case +0:43 Constant: +0:43 48346 (const int) +0:45 Branch: Return with expression +0:44 add ( temp 4-component vector of float) +0:44 add ( temp 4-component vector of float) +0:44 add ( temp 4-component vector of float) +0:44 add ( temp 4-component vector of float) +0:44 vector-scale ( temp 4-component vector of float) +0:44 Convert int to float ( temp float) +0:44 'e' ( temp int) +0:44 'ret' ( temp 4-component vector of float) +0:44 'f' ( temp 4-component vector of float) +0:44 Function Call: vectorCond( ( temp 4-component vector of float) +0:44 Function Call: scalarCond( ( temp 4-component vector of float) +0:45 Construct vec4 ( temp 4-component vector of float) +0:45 Function Call: fbSelect(vb2;vf2;vf2; ( temp 2-component vector of float) +0:45 Constant: +0:45 true (const bool) +0:45 false (const bool) +0:45 Constant: +0:45 1.000000 +0:45 2.000000 +0:45 Constant: +0:45 3.000000 +0:45 4.000000 +0:45 Constant: +0:45 10.000000 +0:45 Constant: +0:45 10.000000 0:27 Function Definition: PixelShaderFunction( ( temp void) 0:27 Function Parameters: 0:? Sequence @@ -523,12 +653,12 @@ gl_FragCoord origin is upper left // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 206 +// Id's are bound by 233 Capability Shader 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Fragment 4 "PixelShaderFunction" 199 202 + EntryPoint Fragment 4 "PixelShaderFunction" 226 229 ExecutionMode 4 OriginUpperLeft Source HLSL 500 Name 4 "PixelShaderFunction" @@ -555,13 +685,17 @@ gl_FragCoord origin is upper left Name 117 "ret" Name 137 "e" Name 150 "f" - Name 186 "param" - Name 187 "param" - Name 188 "param" - Name 197 "input" - Name 199 "input" - Name 202 "@entryPointOutput" - Name 203 "param" + Name 169 "g" + Name 175 "h" + Name 181 "i" + Name 187 "j" + Name 213 "param" + Name 214 "param" + Name 215 "param" + Name 224 "input" + Name 226 "input" + Name 229 "@entryPointOutput" + Name 230 "param" MemberDecorate 29($Global) 0 Offset 0 MemberDecorate 29($Global) 1 Offset 16 MemberDecorate 29($Global) 2 Offset 32 @@ -570,8 +704,8 @@ gl_FragCoord origin is upper left Decorate 29($Global) Block Decorate 31 DescriptorSet 0 Decorate 31 Binding 0 - Decorate 199(input) Location 0 - Decorate 202(@entryPointOutput) Location 0 + Decorate 226(input) Location 0 + Decorate 229(@entryPointOutput) Location 0 2: TypeVoid 3: TypeFunction 2 6: TypeFloat 32 @@ -611,29 +745,35 @@ gl_FragCoord origin is upper left 148: 32(int) Constant 11 151: TypePointer Function 6(float) 154: 139(int) Constant 1 - 178: 13(bool) ConstantTrue - 179: 13(bool) ConstantFalse - 180: 14(bvec2) ConstantComposite 178 179 - 181: 6(float) Constant 1073741824 - 182: 16(fvec2) ConstantComposite 96 181 - 183: 6(float) Constant 1077936128 - 184: 6(float) Constant 1082130432 - 185: 16(fvec2) ConstantComposite 183 184 - 190: 6(float) Constant 1092616192 - 198: TypePointer Input 7(fvec4) - 199(input): 198(ptr) Variable Input - 201: TypePointer Output 7(fvec4) -202(@entryPointOutput): 201(ptr) Variable Output + 168: TypePointer Function 139(int) + 173: 139(int) Constant 21 + 179: 139(int) Constant 63 + 185: 139(int) Constant 5 + 191: 32(int) Constant 43981 + 192: 32(int) Constant 48346 + 205: 13(bool) ConstantTrue + 206: 13(bool) ConstantFalse + 207: 14(bvec2) ConstantComposite 205 206 + 208: 6(float) Constant 1073741824 + 209: 16(fvec2) ConstantComposite 96 208 + 210: 6(float) Constant 1077936128 + 211: 6(float) Constant 1082130432 + 212: 16(fvec2) ConstantComposite 210 211 + 217: 6(float) Constant 1092616192 + 225: TypePointer Input 7(fvec4) + 226(input): 225(ptr) Variable Input + 228: TypePointer Output 7(fvec4) +229(@entryPointOutput): 228(ptr) Variable Output 4(PixelShaderFunction): 2 Function None 3 5: Label - 197(input): 24(ptr) Variable Function - 203(param): 24(ptr) Variable Function - 200: 7(fvec4) Load 199(input) - Store 197(input) 200 - 204: 7(fvec4) Load 197(input) - Store 203(param) 204 - 205: 7(fvec4) FunctionCall 27(@PixelShaderFunction(vf4;) 203(param) - Store 202(@entryPointOutput) 205 + 224(input): 24(ptr) Variable Function + 230(param): 24(ptr) Variable Function + 227: 7(fvec4) Load 226(input) + Store 224(input) 227 + 231: 7(fvec4) Load 224(input) + Store 230(param) 231 + 232: 7(fvec4) FunctionCall 27(@PixelShaderFunction(vf4;) 230(param) + Store 229(@entryPointOutput) 232 Return FunctionEnd 9(vectorCond(): 7(fvec4) Function None 8 @@ -720,9 +860,13 @@ gl_FragCoord origin is upper left 117(ret): 24(ptr) Variable Function 137(e): 109(ptr) Variable Function 150(f): 24(ptr) Variable Function - 186(param): 15(ptr) Variable Function - 187(param): 17(ptr) Variable Function - 188(param): 17(ptr) Variable Function + 169(g): 168(ptr) Variable Function + 175(h): 168(ptr) Variable Function + 181(i): 168(ptr) Variable Function + 187(j): 168(ptr) Variable Function + 213(param): 15(ptr) Variable Function + 214(param): 17(ptr) Variable Function + 215(param): 17(ptr) Variable Function Store 110(a) 111 Store 112(b) 113 Store 114(c) 115 @@ -776,23 +920,44 @@ gl_FragCoord origin is upper left 166: 43(bvec4) CompositeConstruct 157 157 157 157 167: 7(fvec4) Select 166 161 165 Store 150(f) 167 - 168: 32(int) Load 137(e) - 169: 6(float) ConvertSToF 168 - 170: 7(fvec4) Load 117(ret) - 171: 7(fvec4) VectorTimesScalar 170 169 - 172: 7(fvec4) Load 150(f) - 173: 7(fvec4) FAdd 171 172 - 174: 7(fvec4) FunctionCall 9(vectorCond() - 175: 7(fvec4) FAdd 173 174 - 176: 7(fvec4) FunctionCall 11(scalarCond() - 177: 7(fvec4) FAdd 175 176 - Store 186(param) 180 - Store 187(param) 182 - Store 188(param) 185 - 189: 16(fvec2) FunctionCall 22(fbSelect(vb2;vf2;vf2;) 186(param) 187(param) 188(param) - 191: 6(float) CompositeExtract 189 0 - 192: 6(float) CompositeExtract 189 1 - 193: 7(fvec4) CompositeConstruct 191 192 190 190 - 194: 7(fvec4) FAdd 177 193 - ReturnValue 194 + 170: 32(int) Load 116(d) + 171: 6(float) ConvertSToF 170 + 172: 13(bool) FOrdGreaterThan 171 44 + 174: 139(int) Select 172 173 140 + Store 169(g) 174 + 176: 139(int) Load 169(g) + 177: 6(float) ConvertUToF 176 + 178: 13(bool) FOrdGreaterThan 177 44 + 180: 139(int) Select 178 179 140 + Store 175(h) 180 + 182: 139(int) Load 175(h) + 183: 6(float) ConvertUToF 182 + 184: 13(bool) FOrdGreaterThan 183 44 + 186: 139(int) Select 184 185 154 + Store 181(i) 186 + 188: 139(int) Load 181(i) + 189: 6(float) ConvertUToF 188 + 190: 13(bool) FOrdGreaterThan 189 44 + 193: 32(int) Select 190 191 192 + 194: 139(int) Bitcast 193 + Store 187(j) 194 + 195: 32(int) Load 137(e) + 196: 6(float) ConvertSToF 195 + 197: 7(fvec4) Load 117(ret) + 198: 7(fvec4) VectorTimesScalar 197 196 + 199: 7(fvec4) Load 150(f) + 200: 7(fvec4) FAdd 198 199 + 201: 7(fvec4) FunctionCall 9(vectorCond() + 202: 7(fvec4) FAdd 200 201 + 203: 7(fvec4) FunctionCall 11(scalarCond() + 204: 7(fvec4) FAdd 202 203 + Store 213(param) 207 + Store 214(param) 209 + Store 215(param) 212 + 216: 16(fvec2) FunctionCall 22(fbSelect(vb2;vf2;vf2;) 213(param) 214(param) 215(param) + 218: 6(float) CompositeExtract 216 0 + 219: 6(float) CompositeExtract 216 1 + 220: 7(fvec4) CompositeConstruct 218 219 217 217 + 221: 7(fvec4) FAdd 204 220 + ReturnValue 221 FunctionEnd diff --git a/Test/baseResults/hlsl.numericsuffixes.frag.out b/Test/baseResults/hlsl.numericsuffixes.frag.out index 02f7d2a1..05be4230 100644 --- a/Test/baseResults/hlsl.numericsuffixes.frag.out +++ b/Test/baseResults/hlsl.numericsuffixes.frag.out @@ -2,94 +2,124 @@ hlsl.numericsuffixes.frag Shader version: 500 gl_FragCoord origin is upper left 0:? Sequence -0:5 Function Definition: @main( ( temp structure{ temp 4-component vector of float color}) -0:5 Function Parameters: +0:8 Function Definition: @main( ( temp structure{ temp 4-component vector of float color}) +0:8 Function Parameters: 0:? Sequence -0:7 Sequence -0:7 move second child to first child ( temp float) -0:7 'r00' ( temp float) -0:7 Constant: -0:7 1.000000 -0:8 Sequence -0:8 move second child to first child ( temp uint) -0:8 'r01' ( temp uint) -0:8 Constant: -0:8 1 (const uint) -0:9 Sequence -0:9 move second child to first child ( temp uint) -0:9 'r02' ( temp uint) -0:9 Constant: -0:9 2 (const uint) 0:10 Sequence -0:10 move second child to first child ( temp uint) -0:10 'r03' ( temp uint) +0:10 move second child to first child ( temp float) +0:10 'r00' ( temp float) 0:10 Constant: -0:10 2748 (const uint) +0:10 1.000000 0:11 Sequence 0:11 move second child to first child ( temp uint) -0:11 'r04' ( temp uint) +0:11 'r01' ( temp uint) 0:11 Constant: -0:11 2748 (const uint) +0:11 1 (const uint) 0:12 Sequence -0:12 move second child to first child ( temp int) -0:12 'r05' ( temp int) +0:12 move second child to first child ( temp uint) +0:12 'r02' ( temp uint) 0:12 Constant: -0:12 5 (const int) +0:12 2 (const uint) 0:13 Sequence -0:13 move second child to first child ( temp int) -0:13 'r06' ( temp int) +0:13 move second child to first child ( temp uint) +0:13 'r03' ( temp uint) 0:13 Constant: -0:13 6 (const int) +0:13 2748 (const uint) 0:14 Sequence -0:14 move second child to first child ( temp int) -0:14 'r07' ( temp int) +0:14 move second child to first child ( temp uint) +0:14 'r04' ( temp uint) 0:14 Constant: -0:14 57 (const int) +0:14 2748 (const uint) 0:15 Sequence -0:15 move second child to first child ( temp uint) -0:15 'r08' ( temp uint) +0:15 move second child to first child ( temp int) +0:15 'r05' ( temp int) 0:15 Constant: -0:15 58 (const uint) +0:15 5 (const int) 0:16 Sequence -0:16 move second child to first child ( temp float) -0:16 'r09' ( temp float) +0:16 move second child to first child ( temp int) +0:16 'r06' ( temp int) 0:16 Constant: -0:16 1.000000 +0:16 6 (const int) 0:17 Sequence -0:17 move second child to first child ( temp float) -0:17 'r10' ( temp float) +0:17 move second child to first child ( temp int) +0:17 'r07' ( temp int) 0:17 Constant: -0:17 1.000000 +0:17 57 (const int) 0:18 Sequence -0:18 move second child to first child ( temp float) -0:18 'r11' ( temp float) +0:18 move second child to first child ( temp uint) +0:18 'r08' ( temp uint) 0:18 Constant: -0:18 1.100000 +0:18 58 (const uint) 0:19 Sequence 0:19 move second child to first child ( temp float) -0:19 'r12' ( temp float) +0:19 'r09' ( temp float) 0:19 Constant: -0:19 1.100000 -0:22 move second child to first child ( temp 4-component vector of float) -0:22 color: direct index for structure ( temp 4-component vector of float) -0:22 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:19 1.000000 +0:20 Sequence +0:20 move second child to first child ( temp float) +0:20 'r10' ( temp float) +0:20 Constant: +0:20 1.000000 +0:21 Sequence +0:21 move second child to first child ( temp float) +0:21 'r11' ( temp float) +0:21 Constant: +0:21 1.100000 +0:22 Sequence +0:22 move second child to first child ( temp float) +0:22 'r12' ( temp float) 0:22 Constant: -0:22 0 (const int) -0:22 Construct vec4 ( temp 4-component vector of float) -0:22 Convert int to float ( temp float) -0:22 'r07' ( temp int) -0:23 Branch: Return with expression -0:23 'ps_output' ( temp structure{ temp 4-component vector of float color}) -0:5 Function Definition: main( ( temp void) -0:5 Function Parameters: +0:22 1.100000 +0:23 Sequence +0:23 move second child to first child ( temp uint) +0:23 'r13' ( temp uint) +0:23 Constant: +0:23 1 (const uint) +0:24 Sequence +0:24 move second child to first child ( temp uint) +0:24 'r14' ( temp uint) +0:24 Constant: +0:24 2 (const uint) +0:25 Sequence +0:25 move second child to first child ( temp int) +0:25 'r15' ( temp int) +0:25 Constant: +0:25 3 (const int) +0:26 Sequence +0:26 move second child to first child ( temp int) +0:26 'r16' ( temp int) +0:26 Constant: +0:26 4 (const int) +0:27 Sequence +0:27 move second child to first child ( temp uint) +0:27 'r17' ( temp uint) +0:27 Constant: +0:27 1 (const uint) +0:28 Sequence +0:28 move second child to first child ( temp int) +0:28 'r18' ( temp int) +0:28 Constant: +0:28 3 (const int) +0:31 move second child to first child ( temp 4-component vector of float) +0:31 color: direct index for structure ( temp 4-component vector of float) +0:31 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:31 Constant: +0:31 0 (const int) +0:31 Construct vec4 ( temp 4-component vector of float) +0:31 Convert int to float ( temp float) +0:31 'r07' ( temp int) +0:32 Branch: Return with expression +0:32 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:8 Function Definition: main( ( temp void) +0:8 Function Parameters: 0:? Sequence -0:5 Sequence -0:5 move second child to first child ( temp 4-component vector of float) +0:8 Sequence +0:8 move second child to first child ( temp 4-component vector of float) 0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) -0:5 color: direct index for structure ( temp 4-component vector of float) -0:5 Function Call: @main( ( temp structure{ temp 4-component vector of float color}) -0:5 Constant: -0:5 0 (const int) +0:8 color: direct index for structure ( temp 4-component vector of float) +0:8 Function Call: @main( ( temp structure{ temp 4-component vector of float color}) +0:8 Constant: +0:8 0 (const int) 0:? Linker Objects 0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) @@ -100,105 +130,135 @@ Linked fragment stage: Shader version: 500 gl_FragCoord origin is upper left 0:? Sequence -0:5 Function Definition: @main( ( temp structure{ temp 4-component vector of float color}) -0:5 Function Parameters: +0:8 Function Definition: @main( ( temp structure{ temp 4-component vector of float color}) +0:8 Function Parameters: 0:? Sequence -0:7 Sequence -0:7 move second child to first child ( temp float) -0:7 'r00' ( temp float) -0:7 Constant: -0:7 1.000000 -0:8 Sequence -0:8 move second child to first child ( temp uint) -0:8 'r01' ( temp uint) -0:8 Constant: -0:8 1 (const uint) -0:9 Sequence -0:9 move second child to first child ( temp uint) -0:9 'r02' ( temp uint) -0:9 Constant: -0:9 2 (const uint) 0:10 Sequence -0:10 move second child to first child ( temp uint) -0:10 'r03' ( temp uint) +0:10 move second child to first child ( temp float) +0:10 'r00' ( temp float) 0:10 Constant: -0:10 2748 (const uint) +0:10 1.000000 0:11 Sequence 0:11 move second child to first child ( temp uint) -0:11 'r04' ( temp uint) +0:11 'r01' ( temp uint) 0:11 Constant: -0:11 2748 (const uint) +0:11 1 (const uint) 0:12 Sequence -0:12 move second child to first child ( temp int) -0:12 'r05' ( temp int) +0:12 move second child to first child ( temp uint) +0:12 'r02' ( temp uint) 0:12 Constant: -0:12 5 (const int) +0:12 2 (const uint) 0:13 Sequence -0:13 move second child to first child ( temp int) -0:13 'r06' ( temp int) +0:13 move second child to first child ( temp uint) +0:13 'r03' ( temp uint) 0:13 Constant: -0:13 6 (const int) +0:13 2748 (const uint) 0:14 Sequence -0:14 move second child to first child ( temp int) -0:14 'r07' ( temp int) +0:14 move second child to first child ( temp uint) +0:14 'r04' ( temp uint) 0:14 Constant: -0:14 57 (const int) +0:14 2748 (const uint) 0:15 Sequence -0:15 move second child to first child ( temp uint) -0:15 'r08' ( temp uint) +0:15 move second child to first child ( temp int) +0:15 'r05' ( temp int) 0:15 Constant: -0:15 58 (const uint) +0:15 5 (const int) 0:16 Sequence -0:16 move second child to first child ( temp float) -0:16 'r09' ( temp float) +0:16 move second child to first child ( temp int) +0:16 'r06' ( temp int) 0:16 Constant: -0:16 1.000000 +0:16 6 (const int) 0:17 Sequence -0:17 move second child to first child ( temp float) -0:17 'r10' ( temp float) +0:17 move second child to first child ( temp int) +0:17 'r07' ( temp int) 0:17 Constant: -0:17 1.000000 +0:17 57 (const int) 0:18 Sequence -0:18 move second child to first child ( temp float) -0:18 'r11' ( temp float) +0:18 move second child to first child ( temp uint) +0:18 'r08' ( temp uint) 0:18 Constant: -0:18 1.100000 +0:18 58 (const uint) 0:19 Sequence 0:19 move second child to first child ( temp float) -0:19 'r12' ( temp float) +0:19 'r09' ( temp float) 0:19 Constant: -0:19 1.100000 -0:22 move second child to first child ( temp 4-component vector of float) -0:22 color: direct index for structure ( temp 4-component vector of float) -0:22 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:19 1.000000 +0:20 Sequence +0:20 move second child to first child ( temp float) +0:20 'r10' ( temp float) +0:20 Constant: +0:20 1.000000 +0:21 Sequence +0:21 move second child to first child ( temp float) +0:21 'r11' ( temp float) +0:21 Constant: +0:21 1.100000 +0:22 Sequence +0:22 move second child to first child ( temp float) +0:22 'r12' ( temp float) 0:22 Constant: -0:22 0 (const int) -0:22 Construct vec4 ( temp 4-component vector of float) -0:22 Convert int to float ( temp float) -0:22 'r07' ( temp int) -0:23 Branch: Return with expression -0:23 'ps_output' ( temp structure{ temp 4-component vector of float color}) -0:5 Function Definition: main( ( temp void) -0:5 Function Parameters: +0:22 1.100000 +0:23 Sequence +0:23 move second child to first child ( temp uint) +0:23 'r13' ( temp uint) +0:23 Constant: +0:23 1 (const uint) +0:24 Sequence +0:24 move second child to first child ( temp uint) +0:24 'r14' ( temp uint) +0:24 Constant: +0:24 2 (const uint) +0:25 Sequence +0:25 move second child to first child ( temp int) +0:25 'r15' ( temp int) +0:25 Constant: +0:25 3 (const int) +0:26 Sequence +0:26 move second child to first child ( temp int) +0:26 'r16' ( temp int) +0:26 Constant: +0:26 4 (const int) +0:27 Sequence +0:27 move second child to first child ( temp uint) +0:27 'r17' ( temp uint) +0:27 Constant: +0:27 1 (const uint) +0:28 Sequence +0:28 move second child to first child ( temp int) +0:28 'r18' ( temp int) +0:28 Constant: +0:28 3 (const int) +0:31 move second child to first child ( temp 4-component vector of float) +0:31 color: direct index for structure ( temp 4-component vector of float) +0:31 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:31 Constant: +0:31 0 (const int) +0:31 Construct vec4 ( temp 4-component vector of float) +0:31 Convert int to float ( temp float) +0:31 'r07' ( temp int) +0:32 Branch: Return with expression +0:32 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:8 Function Definition: main( ( temp void) +0:8 Function Parameters: 0:? Sequence -0:5 Sequence -0:5 move second child to first child ( temp 4-component vector of float) +0:8 Sequence +0:8 move second child to first child ( temp 4-component vector of float) 0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) -0:5 color: direct index for structure ( temp 4-component vector of float) -0:5 Function Call: @main( ( temp structure{ temp 4-component vector of float color}) -0:5 Constant: -0:5 0 (const int) +0:8 color: direct index for structure ( temp 4-component vector of float) +0:8 Function Call: @main( ( temp structure{ temp 4-component vector of float color}) +0:8 Constant: +0:8 0 (const int) 0:? Linker Objects 0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) // Module Version 10000 // Generated by (magic number): 8000b -// Id's are bound by 54 +// Id's are bound by 62 Capability Shader 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 - EntryPoint Fragment 4 "main" 51 + EntryPoint Fragment 4 "main" 59 ExecutionMode 4 OriginUpperLeft Source HLSL 500 Name 4 "main" @@ -218,9 +278,15 @@ gl_FragCoord origin is upper left Name 35 "r10" Name 36 "r11" Name 38 "r12" - Name 40 "ps_output" - Name 51 "@entryPointOutput.color" - Decorate 51(@entryPointOutput.color) Location 0 + Name 39 "r13" + Name 40 "r14" + Name 41 "r15" + Name 43 "r16" + Name 45 "r17" + Name 46 "r18" + Name 48 "ps_output" + Name 59 "@entryPointOutput.color" + Decorate 59(@entryPointOutput.color) Location 0 2: TypeVoid 3: TypeFunction 2 6: TypeFloat 32 @@ -241,16 +307,18 @@ gl_FragCoord origin is upper left 31: 24(int) Constant 57 33: 15(int) Constant 58 37: 6(float) Constant 1066192077 - 39: TypePointer Function 8(PS_OUTPUT) - 41: 24(int) Constant 0 - 45: TypePointer Function 7(fvec4) - 50: TypePointer Output 7(fvec4) -51(@entryPointOutput.color): 50(ptr) Variable Output + 42: 24(int) Constant 3 + 44: 24(int) Constant 4 + 47: TypePointer Function 8(PS_OUTPUT) + 49: 24(int) Constant 0 + 53: TypePointer Function 7(fvec4) + 58: TypePointer Output 7(fvec4) +59(@entryPointOutput.color): 58(ptr) Variable Output 4(main): 2 Function None 3 5: Label - 52:8(PS_OUTPUT) FunctionCall 10(@main() - 53: 7(fvec4) CompositeExtract 52 0 - Store 51(@entryPointOutput.color) 53 + 60:8(PS_OUTPUT) FunctionCall 10(@main() + 61: 7(fvec4) CompositeExtract 60 0 + Store 59(@entryPointOutput.color) 61 Return FunctionEnd 10(@main():8(PS_OUTPUT) Function None 9 @@ -268,7 +336,13 @@ gl_FragCoord origin is upper left 35(r10): 12(ptr) Variable Function 36(r11): 12(ptr) Variable Function 38(r12): 12(ptr) Variable Function - 40(ps_output): 39(ptr) Variable Function + 39(r13): 16(ptr) Variable Function + 40(r14): 16(ptr) Variable Function + 41(r15): 25(ptr) Variable Function + 43(r16): 25(ptr) Variable Function + 45(r17): 16(ptr) Variable Function + 46(r18): 25(ptr) Variable Function + 48(ps_output): 47(ptr) Variable Function Store 13(r00) 14 Store 17(r01) 18 Store 19(r02) 20 @@ -282,11 +356,17 @@ gl_FragCoord origin is upper left Store 35(r10) 14 Store 36(r11) 37 Store 38(r12) 37 - 42: 24(int) Load 30(r07) - 43: 6(float) ConvertSToF 42 - 44: 7(fvec4) CompositeConstruct 43 43 43 43 - 46: 45(ptr) AccessChain 40(ps_output) 41 - Store 46 44 - 47:8(PS_OUTPUT) Load 40(ps_output) - ReturnValue 47 + Store 39(r13) 18 + Store 40(r14) 20 + Store 41(r15) 42 + Store 43(r16) 44 + Store 45(r17) 18 + Store 46(r18) 42 + 50: 24(int) Load 30(r07) + 51: 6(float) ConvertSToF 50 + 52: 7(fvec4) CompositeConstruct 51 51 51 51 + 54: 53(ptr) AccessChain 48(ps_output) 49 + Store 54 52 + 55:8(PS_OUTPUT) Load 48(ps_output) + ReturnValue 55 FunctionEnd diff --git a/Test/baseResults/hlsl.numericsuffixes.negative.frag.out b/Test/baseResults/hlsl.numericsuffixes.negative.frag.out new file mode 100644 index 00000000..60d63e9f --- /dev/null +++ b/Test/baseResults/hlsl.numericsuffixes.negative.frag.out @@ -0,0 +1,109 @@ +hlsl.numericsuffixes.negative.frag +ERROR: 0:7: '' : bad digit in binary literal +ERROR: 0:8: '' : binary literal too big +ERROR: 0:9: '' : bad digit in hexadecimal literal +ERROR: 0:10: '' : hexadecimal literal too big +ERROR: 4 compilation errors. No code generated. + + +Shader version: 500 +gl_FragCoord origin is upper left +ERROR: node is still EOpNull! +0:5 Function Definition: @main( ( temp structure{ temp 4-component vector of float color}) +0:5 Function Parameters: +0:? Sequence +0:7 Sequence +0:7 move second child to first child ( temp uint) +0:7 'r01' ( temp uint) +0:7 Constant: +0:7 0 (const uint) +0:8 Sequence +0:8 move second child to first child ( temp uint) +0:8 'r02' ( temp uint) +0:8 Constant: +0:8 4294967295 (const uint) +0:10 Sequence +0:9 move second child to first child ( temp uint) +0:9 'r03' ( temp uint) +0:9 Constant: +0:9 0 (const uint) +0:10 move second child to first child ( temp uint) +0:10 'r04' ( temp uint) +0:10 Constant: +0:10 4294967295 (const uint) +0:13 move second child to first child ( temp 4-component vector of float) +0:13 color: direct index for structure ( temp 4-component vector of float) +0:13 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:13 Constant: +0:13 0 (const int) +0:13 Construct vec4 ( temp 4-component vector of float) +0:13 Convert uint to float ( temp float) +0:13 'r01' ( temp uint) +0:14 Branch: Return with expression +0:14 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:5 Function Definition: main( ( temp void) +0:5 Function Parameters: +0:? Sequence +0:5 Sequence +0:5 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) +0:5 color: direct index for structure ( temp 4-component vector of float) +0:5 Function Call: @main( ( temp structure{ temp 4-component vector of float color}) +0:5 Constant: +0:5 0 (const int) +0:? Linker Objects +0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) + + +Linked fragment stage: + + +Shader version: 500 +gl_FragCoord origin is upper left +ERROR: node is still EOpNull! +0:5 Function Definition: @main( ( temp structure{ temp 4-component vector of float color}) +0:5 Function Parameters: +0:? Sequence +0:7 Sequence +0:7 move second child to first child ( temp uint) +0:7 'r01' ( temp uint) +0:7 Constant: +0:7 0 (const uint) +0:8 Sequence +0:8 move second child to first child ( temp uint) +0:8 'r02' ( temp uint) +0:8 Constant: +0:8 4294967295 (const uint) +0:10 Sequence +0:9 move second child to first child ( temp uint) +0:9 'r03' ( temp uint) +0:9 Constant: +0:9 0 (const uint) +0:10 move second child to first child ( temp uint) +0:10 'r04' ( temp uint) +0:10 Constant: +0:10 4294967295 (const uint) +0:13 move second child to first child ( temp 4-component vector of float) +0:13 color: direct index for structure ( temp 4-component vector of float) +0:13 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:13 Constant: +0:13 0 (const int) +0:13 Construct vec4 ( temp 4-component vector of float) +0:13 Convert uint to float ( temp float) +0:13 'r01' ( temp uint) +0:14 Branch: Return with expression +0:14 'ps_output' ( temp structure{ temp 4-component vector of float color}) +0:5 Function Definition: main( ( temp void) +0:5 Function Parameters: +0:? Sequence +0:5 Sequence +0:5 move second child to first child ( temp 4-component vector of float) +0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) +0:5 color: direct index for structure ( temp 4-component vector of float) +0:5 Function Call: @main( ( temp structure{ temp 4-component vector of float color}) +0:5 Constant: +0:5 0 (const int) +0:? Linker Objects +0:? '@entryPointOutput.color' (layout( location=0) out 4-component vector of float) + +SPIR-V is not generated for failed compile or link diff --git a/Test/baseResults/tokenLength.vert.out b/Test/baseResults/tokenLength.vert.out index 8c31da92..5f108301 100644 --- a/Test/baseResults/tokenLength.vert.out +++ b/Test/baseResults/tokenLength.vert.out @@ -27,7 +27,8 @@ ERROR: 0:62: 'preprocessor evaluation' : undefined macro in expression not allow ERROR: 0:67: '' : numeric literal too long ERROR: 0:70: '' : name too long ERROR: 0:70: 'preprocessor evaluation' : undefined macro in expression not allowed in es profile A000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -ERROR: 26 compilation errors. No code generated. +ERROR: 0:74: '' : syntax error, unexpected IDENTIFIER, expecting COMMA or SEMICOLON +ERROR: 27 compilation errors. No code generated. Shader version: 300 @@ -56,7 +57,7 @@ ERROR: node is still EOpNull! 0:14 move second child to first child ( temp highp int) 0:14 'HE' ( global highp int) 0:14 Constant: -0:14 -1 (const int) +0:14 180150000 (const int) 0:17 Sequence 0:17 move second child to first child ( temp highp float) 0:17 'F' ( global highp float) @@ -119,6 +120,7 @@ ERROR: node is still EOpNull! 0:? 'superO' ( global highp int) 0:? 'superI' ( global highp int) 0:? 'superF' ( global highp float) +0:? 'BE' ( global highp int) 0:? 'gl_VertexID' ( gl_VertexId highp int VertexId) 0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) @@ -152,7 +154,7 @@ ERROR: node is still EOpNull! 0:14 move second child to first child ( temp highp int) 0:14 'HE' ( global highp int) 0:14 Constant: -0:14 -1 (const int) +0:14 180150000 (const int) 0:17 Sequence 0:17 move second child to first child ( temp highp float) 0:17 'F' ( global highp float) @@ -215,6 +217,7 @@ ERROR: node is still EOpNull! 0:? 'superO' ( global highp int) 0:? 'superI' ( global highp int) 0:? 'superF' ( global highp float) +0:? 'BE' ( global highp int) 0:? 'gl_VertexID' ( gl_VertexId highp int VertexId) 0:? 'gl_InstanceID' ( gl_InstanceId highp int InstanceId) diff --git a/Test/hlsl.conditional.frag b/Test/hlsl.conditional.frag index 91f75eec..7b6eb7bd 100644 --- a/Test/hlsl.conditional.frag +++ b/Test/hlsl.conditional.frag @@ -37,6 +37,10 @@ float4 PixelShaderFunction(float4 input) : COLOR0 e = a = b ? c = d : 10, b = a ? d = c : 11; float4 f; f = ret.x < input.y ? c * input : d * input; + uint g = d > 0.0 ? 0b010101u : 0u; + uint h = g > 0.0 ? 0B111111u : 0u; + uint i = h > 0.0 ? 0b0101u : 0B01; + uint j = i > 0.0 ? 0xabcd : 0xbcda; return e * ret + f + vectorCond() + scalarCond() + float4(fbSelect(bool2(true, false), float2(1.0, 2.0), float2(3.0, 4.0)), 10.0, 10.0); } diff --git a/Test/hlsl.numericsuffixes.frag b/Test/hlsl.numericsuffixes.frag index bccb786d..e16d374d 100644 --- a/Test/hlsl.numericsuffixes.frag +++ b/Test/hlsl.numericsuffixes.frag @@ -1,6 +1,9 @@ struct PS_OUTPUT { float4 color : SV_Target0; }; +#define BIN_UINT 0b00001u +#define BIN_INT 0b00011 + PS_OUTPUT main() { // Test numeric suffixes @@ -8,7 +11,7 @@ PS_OUTPUT main() uint r01 = 1u; // lower uint uint r02 = 2U; // upper uint uint r03 = 0xabcu; // lower hex uint - uint r04 = 0xABCU; // upper hex uint (upper 0X is not accepted) + uint r04 = 0XABCU; // upper hex uint int r05 = 5l; // lower long int int r06 = 6L; // upper long int int r07 = 071; // octal @@ -17,6 +20,12 @@ PS_OUTPUT main() float r10 = 1.H; // half float r11 = 1.1h; // half float r12 = 1.1H; // half + uint r13 = 0b00001u;// lower binary uint + uint r14 = 0B00010U;// upper binary uint + int r15 = 0b00011; // lower binary int + int r16 = 0B00100; // upper binary int + uint r17 = BIN_UINT;// lower binart define uint + int r18 = BIN_INT; // lower binart define int PS_OUTPUT ps_output; ps_output.color = r07; // gets 71 octal = 57 decimal diff --git a/Test/hlsl.numericsuffixes.negative.frag b/Test/hlsl.numericsuffixes.negative.frag new file mode 100644 index 00000000..ce512fd0 --- /dev/null +++ b/Test/hlsl.numericsuffixes.negative.frag @@ -0,0 +1,15 @@ + +struct PS_OUTPUT { float4 color : SV_Target0; }; + +PS_OUTPUT main() +{ + // Test numeric suffixes + uint r01 = 0bERROR321u; // Bad digit + uint r02 = 0b11111111111111111111111111111111111111111111111111111111111111111u; // To big + uint r03 = 0xTESTu // Bad digit + uint r04 = 0xFFFFFFFFFFFFFFFFFFu; // To big + + PS_OUTPUT ps_output; + ps_output.color = r01; + return ps_output; +} diff --git a/Test/tokenLength.vert b/Test/tokenLength.vert index 21d446fa..325fbcbc 100644 --- a/Test/tokenLength.vert +++ b/Test/tokenLength.vert @@ -70,3 +70,5 @@ float superF = 1.012345678901234567890123456789012345678901234567890123456789012 #if A000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 #error in super long macro #if #endif + +int BE = 0b01u; // ERROR (not supported by GLSL) diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp index d4d4de9f..25b9bbd0 100644 --- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp +++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp @@ -3,6 +3,7 @@ // Copyright (C) 2013 LunarG, Inc. // Copyright (C) 2017 ARM Limited. // Copyright (C) 2015-2018 Google, Inc. +// Copyright (c) 2023, Mobica Limited // // All rights reserved. // @@ -549,7 +550,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ival = 0; do { - if (len < MaxTokenLength && ival <= 0x0fffffffffffffffull) { + if (len < MaxTokenLength && ival <= 0x7fffffffffffffffull) { ppToken->name[len++] = (char)ch; if (ch >= '0' && ch <= '9') { ii = ch - '0'; @@ -639,6 +640,110 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken) ppToken->ival = (int)ival; return isUnsigned ? PpAtomConstUint : PpAtomConstInt; } + } else if ((ch == 'b' || ch == 'B') && pp->parseContext.intermediate.getSource() == EShSourceHlsl) { + // must be binary + bool isUnsigned = false; + bool isInt64 = false; + bool isInt16 = false; + ppToken->name[len++] = (char)ch; + ch = getch(); + + // Check value + if ((ch == '0' || ch == '1')) + { + ival = 0; + do { + if (len < MaxTokenLength && ival <= 0x7fffffffffffffffull) { + ppToken->name[len++] = (char)ch; + if (ch == '0' || ch == '1') { + ii = ch - '0'; + } else { + pp->parseContext.ppError(ppToken->loc, "bad digit in binary literal", "", ""); + } + ival = (ival << 1) | ii; + } + else + { + if (! AlreadyComplained) { + if(len < MaxTokenLength) + pp->parseContext.ppError(ppToken->loc, "binary literal too big", "", ""); + else + pp->parseContext.ppError(ppToken->loc, "binary literal too long", "", ""); + AlreadyComplained = 1; + } + ival = 0xffffffffffffffffull; + } + ch = getch(); + } while (ch == '0' || ch == '1'); + } + else + { + pp->parseContext.ppError(ppToken->loc, "bad digit in binary literal", "", ""); + } + + // check type + if (ch == 'u' || ch == 'U') { + if (len < MaxTokenLength) + ppToken->name[len++] = (char)ch; + isUnsigned = true; + +#ifndef GLSLANG_WEB + int nextCh = getch(); + if (nextCh == 'l' || nextCh == 'L') { + if (len < MaxTokenLength) + ppToken->name[len++] = (char)nextCh; + isInt64 = true; + } else + ungetch(); + + nextCh = getch(); + if ((nextCh == 's' || nextCh == 'S') && + pp->parseContext.intermediate.getSource() == EShSourceGlsl) { + if (len < MaxTokenLength) + ppToken->name[len++] = (char)nextCh; + isInt16 = true; + } else + ungetch(); + } else if (ch == 'l' || ch == 'L') { + if (len < MaxTokenLength) + ppToken->name[len++] = (char)ch; + isInt64 = true; + } else if ((ch == 's' || ch == 'S') && + pp->parseContext.intermediate.getSource() == EShSourceGlsl) { + if (len < MaxTokenLength) + ppToken->name[len++] = (char)ch; + isInt16 = true; +#endif + } else { + ungetch(); + } + ppToken->name[len] = '\0'; + + // Assign value + if (isInt64 && pp->parseContext.intermediate.getSource() == EShSourceGlsl) { + if (pp->ifdepth == 0) { + pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile, + "64-bit binary literal"); + pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, + Num_Int64_Extensions, Int64_Extensions, "64-bit binary literal"); + } + ppToken->i64val = ival; + return isUnsigned ? PpAtomConstUint64 : PpAtomConstInt64; + } else if (isInt16) { + if (pp->ifdepth == 0) { + if (pp->parseContext.intermediate.getSource() == EShSourceGlsl) { + pp->parseContext.requireProfile(ppToken->loc, ~EEsProfile, + "16-bit binary literal"); + pp->parseContext.profileRequires(ppToken->loc, ~EEsProfile, 0, + Num_Int16_Extensions, Int16_Extensions, "16-bit binary literal"); + } + } + ppToken->ival = (int)ival; + return isUnsigned ? PpAtomConstUint16 : PpAtomConstInt16; + } else { + ppToken->ival = (int)ival; + return isUnsigned ? PpAtomConstUint : PpAtomConstInt; + } } else { // could be octal integer or floating point, speculative pursue octal until it must be floating point diff --git a/gtests/Hlsl.FromFile.cpp b/gtests/Hlsl.FromFile.cpp index 294472d9..db882feb 100644 --- a/gtests/Hlsl.FromFile.cpp +++ b/gtests/Hlsl.FromFile.cpp @@ -313,6 +313,7 @@ INSTANTIATE_TEST_SUITE_P( {"hlsl.matrixindex.frag", "main"}, {"hlsl.nonstaticMemberFunction.frag", "main"}, {"hlsl.numericsuffixes.frag", "main"}, + {"hlsl.numericsuffixes.negative.frag", "main"}, {"hlsl.numthreads.comp", "main_aux2"}, {"hlsl.overload.frag", "PixelShaderFunction"}, {"hlsl.opaque-type-bug.frag", "main"},