Commit 6e72fdda by LoopDawg

Add HLSL memory barrier intrinsics, fix dst, add lit & EvaluateAttributeSnapped

parent 19b92fff
......@@ -1405,6 +1405,10 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpMemoryBarrierImage:
case glslang::EOpMemoryBarrierShared:
case glslang::EOpGroupMemoryBarrier:
case glslang::EOpAllMemoryBarrierWithGroupSync:
case glslang::EOpGroupMemoryBarrierWithGroupSync:
case glslang::EOpWorkgroupMemoryBarrier:
case glslang::EOpWorkgroupMemoryBarrierWithGroupSync:
noReturnValue = true;
// These all have 0 operands and will naturally finish up in the code below for 0 operands
break;
......@@ -3986,6 +3990,21 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op)
case glslang::EOpGroupMemoryBarrier:
builder.createMemoryBarrier(spv::ScopeDevice, spv::MemorySemanticsCrossWorkgroupMemoryMask);
return 0;
case glslang::EOpAllMemoryBarrierWithGroupSync:
// Control barrier with non-"None" semantic is also a memory barrier.
builder.createControlBarrier(spv::ScopeDevice, spv::ScopeDevice, spv::MemorySemanticsAllMemory);
return 0;
case glslang::EOpGroupMemoryBarrierWithGroupSync:
// Control barrier with non-"None" semantic is also a memory barrier.
builder.createControlBarrier(spv::ScopeDevice, spv::ScopeDevice, spv::MemorySemanticsCrossWorkgroupMemoryMask);
return 0;
case glslang::EOpWorkgroupMemoryBarrier:
builder.createMemoryBarrier(spv::ScopeWorkgroup, spv::MemorySemanticsWorkgroupMemoryMask);
return 0;
case glslang::EOpWorkgroupMemoryBarrierWithGroupSync:
// Control barrier with non-"None" semantic is also a memory barrier.
builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup, spv::MemorySemanticsWorkgroupMemoryMask);
return 0;
default:
logger->missingFunctionality("unknown operation with no arguments");
return 0;
......
hlsl.intrinsics.barriers.comp
Shader version: 450
local_size = (1, 1, 1)
0:? Sequence
0:14 Function Definition: ComputeShaderFunction( (temp float)
0:3 Function Parameters:
0:? Sequence
0:4 MemoryBarrier (global void)
0:5 AllMemoryBarrierWithGroupSync (global void)
0:6 GroupMemoryBarrier (global void)
0:7 GroupMemoryBarrierWithGroupSync (global void)
0:8 WorkgroupMemoryBarrier (global void)
0:9 WorkgroupMemoryBarrierWithGroupSync (global void)
0:11 Branch: Return with expression
0:11 Constant:
0:11 0.000000
0:? Linker Objects
Linked compute stage:
Shader version: 450
local_size = (1, 1, 1)
0:? Sequence
0:14 Function Definition: ComputeShaderFunction( (temp float)
0:3 Function Parameters:
0:? Sequence
0:4 MemoryBarrier (global void)
0:5 AllMemoryBarrierWithGroupSync (global void)
0:6 GroupMemoryBarrier (global void)
0:7 GroupMemoryBarrierWithGroupSync (global void)
0:8 WorkgroupMemoryBarrier (global void)
0:9 WorkgroupMemoryBarrierWithGroupSync (global void)
0:11 Branch: Return with expression
0:11 Constant:
0:11 0.000000
0:? Linker Objects
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 15
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "ComputeShaderFunction"
ExecutionMode 4 LocalSize 1 1 1
Source HLSL 450
Name 4 "ComputeShaderFunction"
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: 6(int) Constant 1
8: 6(int) Constant 4048
9: 6(int) Constant 512
10: 6(int) Constant 2
11: 6(int) Constant 256
12: TypeFloat 32
13: 12(float) Constant 0
4(ComputeShaderFunction): 2 Function None 3
5: Label
MemoryBarrier 7 8
ControlBarrier 7 7 8
MemoryBarrier 7 9
ControlBarrier 7 7 9
MemoryBarrier 10 11
ControlBarrier 10 10 11
ReturnValue 13
FunctionEnd
hlsl.intrinsics.evalfns.frag
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:11 Function Definition: main(f1;vf2;vf3;vf4;vi2; (temp void)
0:3 Function Parameters:
0:3 'inF1' (in float)
0:3 'inF2' (in 2-component vector of float)
0:3 'inF3' (in 3-component vector of float)
0:3 'inF4' (in 4-component vector of float)
0:3 'inI2' (in 2-component vector of int)
0:? Sequence
0:4 interpolateAtOffset (temp float)
0:4 'inF1' (in float)
0:? Constant:
0:? -0.500000
0:? -0.062500
0:5 interpolateAtOffset (temp 2-component vector of float)
0:5 'inF2' (in 2-component vector of float)
0:? Constant:
0:? 0.000000
0:? 0.062500
0:6 interpolateAtOffset (temp 3-component vector of float)
0:6 'inF3' (in 3-component vector of float)
0:? Constant:
0:? 0.187500
0:? -0.375000
0:7 interpolateAtOffset (temp 4-component vector of float)
0:7 'inF4' (in 4-component vector of float)
0:? Constant:
0:? 0.437500
0:? -0.500000
0:9 interpolateAtOffset (temp float)
0:9 'inF1' (in float)
0:9 vector-scale (temp 2-component vector of float)
0:9 Convert int to float (temp 2-component vector of float)
0:9 right-shift (temp 2-component vector of int)
0:9 left-shift (temp 2-component vector of int)
0:9 'inI2' (in 2-component vector of int)
0:9 Constant:
0:9 28 (const int)
0:9 Constant:
0:9 28 (const int)
0:9 Constant:
0:9 0.062500
0:? Linker Objects
Linked fragment stage:
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:11 Function Definition: main(f1;vf2;vf3;vf4;vi2; (temp void)
0:3 Function Parameters:
0:3 'inF1' (in float)
0:3 'inF2' (in 2-component vector of float)
0:3 'inF3' (in 3-component vector of float)
0:3 'inF4' (in 4-component vector of float)
0:3 'inI2' (in 2-component vector of int)
0:? Sequence
0:4 interpolateAtOffset (temp float)
0:4 'inF1' (in float)
0:? Constant:
0:? -0.500000
0:? -0.062500
0:5 interpolateAtOffset (temp 2-component vector of float)
0:5 'inF2' (in 2-component vector of float)
0:? Constant:
0:? 0.000000
0:? 0.062500
0:6 interpolateAtOffset (temp 3-component vector of float)
0:6 'inF3' (in 3-component vector of float)
0:? Constant:
0:? 0.187500
0:? -0.375000
0:7 interpolateAtOffset (temp 4-component vector of float)
0:7 'inF4' (in 4-component vector of float)
0:? Constant:
0:? 0.437500
0:? -0.500000
0:9 interpolateAtOffset (temp float)
0:9 'inF1' (in float)
0:9 vector-scale (temp 2-component vector of float)
0:9 Convert int to float (temp 2-component vector of float)
0:9 right-shift (temp 2-component vector of int)
0:9 left-shift (temp 2-component vector of int)
0:9 'inI2' (in 2-component vector of int)
0:9 Constant:
0:9 28 (const int)
0:9 Constant:
0:9 28 (const int)
0:9 Constant:
0:9 0.062500
0:? Linker Objects
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 46
Capability Shader
Capability InterpolationFunction
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 15 22 29 36
ExecutionMode 4 OriginUpperLeft
Source HLSL 450
Name 4 "main"
Name 8 "inF1"
Name 15 "inF2"
Name 22 "inF3"
Name 29 "inF4"
Name 36 "inI2"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Input 6(float)
8(inF1): 7(ptr) Variable Input
9: TypeVector 6(float) 2
10: 6(float) Constant 3204448256
11: 6(float) Constant 3179282432
12: 9(fvec2) ConstantComposite 10 11
14: TypePointer Input 9(fvec2)
15(inF2): 14(ptr) Variable Input
16: 6(float) Constant 0
17: 6(float) Constant 1031798784
18: 9(fvec2) ConstantComposite 16 17
20: TypeVector 6(float) 3
21: TypePointer Input 20(fvec3)
22(inF3): 21(ptr) Variable Input
23: 6(float) Constant 1044381696
24: 6(float) Constant 3200253952
25: 9(fvec2) ConstantComposite 23 24
27: TypeVector 6(float) 4
28: TypePointer Input 27(fvec4)
29(inF4): 28(ptr) Variable Input
30: 6(float) Constant 1054867456
31: 9(fvec2) ConstantComposite 30 10
33: TypeInt 32 1
34: TypeVector 33(int) 2
35: TypePointer Input 34(ivec2)
36(inI2): 35(ptr) Variable Input
38: 33(int) Constant 28
4(main): 2 Function None 3
5: Label
13: 6(float) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 8(inF1) 12
19: 9(fvec2) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 15(inF2) 18
26: 20(fvec3) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 22(inF3) 25
32: 27(fvec4) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 29(inF4) 31
37: 34(ivec2) Load 36(inI2)
39: 34(ivec2) CompositeConstruct 38 38
40: 34(ivec2) ShiftLeftLogical 37 39
41: 34(ivec2) CompositeConstruct 38 38
42: 34(ivec2) ShiftRightArithmetic 40 41
43: 9(fvec2) ConvertSToF 42
44: 9(fvec2) VectorTimesScalar 43 17
45: 6(float) ExtInst 1(GLSL.std.450) 78(InterpolateAtOffset) 8(inF1) 44
Return
FunctionEnd
hlsl.intrinsics.f1632.frag
ERROR: 0:3: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 0:16: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 0:23: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 0:30: 'f32tof16' : unimplemented intrinsic: handle natively
ERROR: 4 compilation errors. No code generated.
Shader version: 450
gl_FragCoord origin is upper left
ERROR: node is still EOpNull!
0:8 Function Definition: PixelShaderFunction(f1; (temp float)
0:2 Function Parameters:
0:2 'inF0' (in float)
0:? Sequence
0:3 ERROR: Bad unary op
(global uint)
0:3 'inF0' (in float)
0:5 Branch: Return with expression
0:5 Constant:
0:5 0.000000
0:14 Function Definition: PixelShaderFunction(vf1; (temp 1-component vector of float)
0:9 Function Parameters:
0:9 'inF0' (in 1-component vector of float)
0:? Sequence
0:11 Branch: Return with expression
0:11 Constant:
0:11 0.000000
0:21 Function Definition: PixelShaderFunction(vf2; (temp 2-component vector of float)
0:15 Function Parameters:
0:15 'inF0' (in 2-component vector of float)
0:? Sequence
0:16 ERROR: Bad unary op
(global 2-component vector of uint)
0:16 'inF0' (in 2-component vector of float)
0:18 Branch: Return with expression
0:? Constant:
0:? 1.000000
0:? 2.000000
0:28 Function Definition: PixelShaderFunction(vf3; (temp 3-component vector of float)
0:22 Function Parameters:
0:22 'inF0' (in 3-component vector of float)
0:? Sequence
0:23 ERROR: Bad unary op
(global 3-component vector of uint)
0:23 'inF0' (in 3-component vector of float)
0:25 Branch: Return with expression
0:? Constant:
0:? 1.000000
0:? 2.000000
0:? 3.000000
0:35 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:29 Function Parameters:
0:29 'inF0' (in 4-component vector of float)
0:? Sequence
0:30 ERROR: Bad unary op
(global 4-component vector of uint)
0:30 'inF0' (in 4-component vector of float)
0:32 Branch: Return with expression
0:? Constant:
0:? 1.000000
0:? 2.000000
0:? 3.000000
0:? 4.000000
0:? Linker Objects
Linked fragment stage:
Shader version: 450
gl_FragCoord origin is upper left
ERROR: node is still EOpNull!
0:8 Function Definition: PixelShaderFunction(f1; (temp float)
0:2 Function Parameters:
0:2 'inF0' (in float)
0:? Sequence
0:3 ERROR: Bad unary op
(global uint)
0:3 'inF0' (in float)
0:5 Branch: Return with expression
0:5 Constant:
0:5 0.000000
0:14 Function Definition: PixelShaderFunction(vf1; (temp 1-component vector of float)
0:9 Function Parameters:
0:9 'inF0' (in 1-component vector of float)
0:? Sequence
0:11 Branch: Return with expression
0:11 Constant:
0:11 0.000000
0:21 Function Definition: PixelShaderFunction(vf2; (temp 2-component vector of float)
0:15 Function Parameters:
0:15 'inF0' (in 2-component vector of float)
0:? Sequence
0:16 ERROR: Bad unary op
(global 2-component vector of uint)
0:16 'inF0' (in 2-component vector of float)
0:18 Branch: Return with expression
0:? Constant:
0:? 1.000000
0:? 2.000000
0:28 Function Definition: PixelShaderFunction(vf3; (temp 3-component vector of float)
0:22 Function Parameters:
0:22 'inF0' (in 3-component vector of float)
0:? Sequence
0:23 ERROR: Bad unary op
(global 3-component vector of uint)
0:23 'inF0' (in 3-component vector of float)
0:25 Branch: Return with expression
0:? Constant:
0:? 1.000000
0:? 2.000000
0:? 3.000000
0:35 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
0:29 Function Parameters:
0:29 'inF0' (in 4-component vector of float)
0:? Sequence
0:30 ERROR: Bad unary op
(global 4-component vector of uint)
0:30 'inF0' (in 4-component vector of float)
0:32 Branch: Return with expression
0:? Constant:
0:? 1.000000
0:? 2.000000
0:? 3.000000
0:? 4.000000
0:? Linker Objects
SPIR-V is not generated for failed compile or link
hlsl.intrinsics.lit.frag
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:5 Function Definition: PixelShaderFunction(f1;f1;f1; (temp void)
0:2 Function Parameters:
0:2 'n_dot_l' (in float)
0:2 'n_dot_h' (in float)
0:2 'm' (in float)
0:? Sequence
0:3 move second child to first child (temp 4-component vector of float)
0:3 'r0' (temp 4-component vector of float)
0:3 Construct vec4 (temp 4-component vector of float)
0:3 Constant:
0:3 1.000000
0:3 max (temp float)
0:3 'n_dot_l' (in float)
0:3 Constant:
0:3 0.000000
0:3 Test condition and select (temp float)
0:3 Condition
0:3 Compare Less Than (temp bool)
0:3 min (temp float)
0:3 'n_dot_l' (in float)
0:3 'n_dot_h' (in float)
0:3 Constant:
0:3 0.000000
0:3 true case
0:3 Constant:
0:3 0.000000
0:3 false case
0:3 component-wise multiply (temp float)
0:3 'n_dot_h' (in float)
0:3 'm' (in float)
0:3 Constant:
0:3 1.000000
0:? Linker Objects
Linked fragment stage:
Shader version: 450
gl_FragCoord origin is upper left
0:? Sequence
0:5 Function Definition: PixelShaderFunction(f1;f1;f1; (temp void)
0:2 Function Parameters:
0:2 'n_dot_l' (in float)
0:2 'n_dot_h' (in float)
0:2 'm' (in float)
0:? Sequence
0:3 move second child to first child (temp 4-component vector of float)
0:3 'r0' (temp 4-component vector of float)
0:3 Construct vec4 (temp 4-component vector of float)
0:3 Constant:
0:3 1.000000
0:3 max (temp float)
0:3 'n_dot_l' (in float)
0:3 Constant:
0:3 0.000000
0:3 Test condition and select (temp float)
0:3 Condition
0:3 Compare Less Than (temp bool)
0:3 min (temp float)
0:3 'n_dot_l' (in float)
0:3 'n_dot_h' (in float)
0:3 Constant:
0:3 0.000000
0:3 true case
0:3 Constant:
0:3 0.000000
0:3 false case
0:3 component-wise multiply (temp float)
0:3 'n_dot_h' (in float)
0:3 'm' (in float)
0:3 Constant:
0:3 1.000000
0:? Linker Objects
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 33
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "PixelShaderFunction" 12 19 28
ExecutionMode 4 OriginUpperLeft
Source HLSL 450
Name 4 "PixelShaderFunction"
Name 9 "r0"
Name 12 "n_dot_l"
Name 19 "n_dot_h"
Name 28 "m"
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: 6(float) Constant 1065353216
11: TypePointer Input 6(float)
12(n_dot_l): 11(ptr) Variable Input
14: 6(float) Constant 0
16: TypePointer Function 6(float)
19(n_dot_h): 11(ptr) Variable Input
22: TypeBool
28(m): 11(ptr) Variable Input
4(PixelShaderFunction): 2 Function None 3
5: Label
9(r0): 8(ptr) Variable Function
17: 16(ptr) Variable Function
13: 6(float) Load 12(n_dot_l)
15: 6(float) ExtInst 1(GLSL.std.450) 40(FMax) 13 14
18: 6(float) Load 12(n_dot_l)
20: 6(float) Load 19(n_dot_h)
21: 6(float) ExtInst 1(GLSL.std.450) 37(FMin) 18 20
23: 22(bool) FOrdLessThan 21 14
SelectionMerge 25 None
BranchConditional 23 24 26
24: Label
Store 17 14
Branch 25
26: Label
27: 6(float) Load 19(n_dot_h)
29: 6(float) Load 28(m)
30: 6(float) FMul 27 29
Store 17 30
Branch 25
25: Label
31: 6(float) Load 17
32: 7(fvec4) CompositeConstruct 10 15 31 10
Store 9(r0) 32
Return
FunctionEnd
hlsl.intrinsics.negative.vert
ERROR: 0:18: 'AllMemoryBarrier' : no matching overloaded function found
ERROR: 0:19: 'AllMemoryBarrierWithGroupSync' : no matching overloaded function found
ERROR: 0:20: 'asdouble' : no matching overloaded function found
ERROR: 0:21: 'CheckAccessFullyMapped' : no matching overloaded function found
ERROR: 0:22: 'CheckAccessFullyMapped' : no matching overloaded function found
......@@ -6,6 +8,8 @@ ERROR: 0:23: 'clip' : no matching overloaded function found
ERROR: 0:24: 'countbits' : no matching overloaded function found
ERROR: 0:25: 'cross' : no matching overloaded function found
ERROR: 0:26: 'D3DCOLORtoUBYTE4' : no matching overloaded function found
ERROR: 0:27: 'DeviceMemoryBarrier' : no matching overloaded function found
ERROR: 0:28: 'DeviceMemoryBarrierWithGroupSync' : no matching overloaded function found
ERROR: 0:29: 'ddx' : no matching overloaded function found
ERROR: 0:30: 'ddx_coarse' : no matching overloaded function found
ERROR: 0:31: 'ddx_fine' : no matching overloaded function found
......@@ -35,6 +39,8 @@ ERROR: 0:54: 'InterlockedOr' : no matching overloaded function found
ERROR: 0:55: 'InterlockedOr' : no matching overloaded function found
ERROR: 0:56: 'InterlockedXor' : no matching overloaded function found
ERROR: 0:57: 'InterlockedXor' : no matching overloaded function found
ERROR: 0:58: 'GroupMemoryBarrier' : no matching overloaded function found
ERROR: 0:59: 'GroupMemoryBarrierWithGroupSync' : no matching overloaded function found
ERROR: 0:60: 'length' : no matching overloaded function found
ERROR: 0:61: 'msad4' : no matching overloaded function found
ERROR: 0:62: 'normalize' : no matching overloaded function found
......@@ -226,7 +232,7 @@ ERROR: 0:270: 'normalize' : no matching overloaded function found
ERROR: 0:270: 'reflect' : no matching overloaded function found
ERROR: 0:270: 'refract' : no matching overloaded function found
ERROR: 0:270: 'reversebits' : no matching overloaded function found
ERROR: 227 compilation errors. No code generated.
ERROR: 233 compilation errors. No code generated.
Shader version: 450
......@@ -238,6 +244,10 @@ ERROR: node is still EOpNull!
0:15 'inF2' (in float)
0:15 'inI0' (in int)
0:? Sequence
0:18 Constant:
0:18 0.000000
0:19 Constant:
0:19 0.000000
0:20 Constant:
0:20 0.000000
0:21 Constant:
......@@ -252,6 +262,10 @@ ERROR: node is still EOpNull!
0:25 0.000000
0:26 Constant:
0:26 0.000000
0:27 Constant:
0:27 0.000000
0:28 Constant:
0:28 0.000000
0:29 Constant:
0:29 0.000000
0:30 Constant:
......@@ -310,6 +324,10 @@ ERROR: node is still EOpNull!
0:56 0.000000
0:57 Constant:
0:57 0.000000
0:58 Constant:
0:58 0.000000
0:59 Constant:
0:59 0.000000
0:60 Constant:
0:60 0.000000
0:61 Constant:
......@@ -821,6 +839,10 @@ ERROR: node is still EOpNull!
0:15 'inF2' (in float)
0:15 'inI0' (in int)
0:? Sequence
0:18 Constant:
0:18 0.000000
0:19 Constant:
0:19 0.000000
0:20 Constant:
0:20 0.000000
0:21 Constant:
......@@ -835,6 +857,10 @@ ERROR: node is still EOpNull!
0:25 0.000000
0:26 Constant:
0:26 0.000000
0:27 Constant:
0:27 0.000000
0:28 Constant:
0:28 0.000000
0:29 Constant:
0:29 0.000000
0:30 Constant:
......@@ -893,6 +919,10 @@ ERROR: node is still EOpNull!
0:56 0.000000
0:57 Constant:
0:57 0.000000
0:58 Constant:
0:58 0.000000
0:59 Constant:
0:59 0.000000
0:60 Constant:
0:60 0.000000
0:61 Constant:
......
float ComputeShaderFunction()
{
AllMemoryBarrier();
AllMemoryBarrierWithGroupSync();
DeviceMemoryBarrier();
DeviceMemoryBarrierWithGroupSync();
GroupMemoryBarrier();
GroupMemoryBarrierWithGroupSync();
return 0.0;
}
void main(float inF1, float2 inF2, float3 inF3, float4 inF4, int2 inI2) : COLOR
{
EvaluateAttributeSnapped(inF1, int2(8,15));
EvaluateAttributeSnapped(inF2, int2(0,1));
EvaluateAttributeSnapped(inF3, int2(3,10));
EvaluateAttributeSnapped(inF4, int2(7,8));
EvaluateAttributeSnapped(inF1, inI2);
}
float PixelShaderFunction(float inF0)
{
f32tof16(inF0);
return 0.0;
}
float1 PixelShaderFunction(float1 inF0)
{
// TODO: ... add when float1 prototypes are generated
return 0.0;
}
float2 PixelShaderFunction(float2 inF0)
{
f32tof16(inF0);
return float2(1,2);
}
float3 PixelShaderFunction(float3 inF0)
{
f32tof16(inF0);
return float3(1,2,3);
}
float4 PixelShaderFunction(float4 inF0)
{
f32tof16(inF0);
return float4(1,2,3,4);
}
void PixelShaderFunction(float n_dot_l, float n_dot_h, float m)
{
float4 r0 = lit(n_dot_l, n_dot_h, m);
}
......@@ -15,8 +15,8 @@ float VertexShaderFunction(float inF0, float inF1, float inF2, int inI0)
{
uint out_u1;
// AllMemoryBarrier(); // invalid in fragment stage TODO: parser currently crashes on empty arg list
// AllMemoryBarrierWithGroupSync(); // invalid in fragment stage TODO: parser currently crashes on empty arg list
AllMemoryBarrier(); // expected error: only valid in compute stage
AllMemoryBarrierWithGroupSync(); // expected error: only valid in compute stage
asdouble(inF0, inF1); // expected error: only integer inputs
CheckAccessFullyMapped(3.0); // expected error: only valid on integers
CheckAccessFullyMapped(3); // expected error: only valid in pixel & compute stages
......@@ -24,8 +24,8 @@ float VertexShaderFunction(float inF0, float inF1, float inF2, int inI0)
countbits(inF0); // expected error: only integer inputs
cross(inF0, inF1); // expected error: only on float3 inputs
D3DCOLORtoUBYTE4(inF0); // expected error: only on float4 inputs
// DeviceMemoryBarrier(); // TODO: expected error: only valid in pixel & compute stages
// DeviceMemoryBarrierWithGroupSync(); // TODO: expected error: only valid in compute stage
DeviceMemoryBarrier(); // expected error: only valid in pixel & compute stages
DeviceMemoryBarrierWithGroupSync(); // expected error: only valid in compute stage
ddx(inF0); // expected error: only valid in pixel stage
ddx_coarse(inF0); // expected error: only valid in pixel stage
ddx_fine(inF0); // expected error: only valid in pixel stage
......@@ -55,8 +55,8 @@ float VertexShaderFunction(float inF0, float inF1, float inF2, int inI0)
InterlockedOr(gs_ua, gs_ub, out_u1); // expected error: only valid in pixel stage
InterlockedXor(gs_ua, gs_ub); // expected error: only valid in pixel stage
InterlockedXor(gs_ua, gs_ub, out_u1); // expected error: only valid in pixel stage
// GroupMemoryBarrier(); // TODO: expected error: only valid in compute stage
// GroupMemoryBarrierWithGroupSync(); // TODO: expected error: only valid in compute stage
GroupMemoryBarrier(); // expected error: only valid in compute stage
GroupMemoryBarrierWithGroupSync(); // expected error: only valid in compute stage
length(inF0); // expect error: invalid on scalars
msad4(inF0, float2(0), float4(0)); // expected error: only integer inputs
normalize(inF0); // expect error: invalid on scalars
......
......@@ -515,7 +515,14 @@ enum TOperator {
EOpInterlockedMin, // ...
EOpInterlockedOr, // ...
EOpInterlockedXor, // ...
EOpAllMemoryBarrierWithGroupSync, // memory barriers without non-hlsl AST equivalents
EOpGroupMemoryBarrierWithGroupSync, // ...
EOpWorkgroupMemoryBarrier, // ...
EOpWorkgroupMemoryBarrierWithGroupSync, // ...
EOpEvaluateAttributeSnapped, // InterpolateAtOffset with int position on 16x16 grid
EOpF32tof16, // HLSL conversion: half of a PackHalf2x16
EOpF16tof32, // HLSL conversion: half of an UnpackHalf2x16
EOpLit, // HLSL lighting coefficient vector
};
class TIntermTraverser;
......
......@@ -543,6 +543,11 @@ bool TOutputTraverser::visitAggregate(TVisit /* visit */, TIntermAggregate* node
case EOpSinCos: out.debug << "sincos"; break;
case EOpGenMul: out.debug << "mul"; break;
case EOpAllMemoryBarrierWithGroupSync: out.debug << "AllMemoryBarrierWithGroupSync"; break;
case EOpGroupMemoryBarrierWithGroupSync: out.debug << "GroupMemoryBarrierWithGroupSync"; break;
case EOpWorkgroupMemoryBarrier: out.debug << "WorkgroupMemoryBarrier"; break;
case EOpWorkgroupMemoryBarrierWithGroupSync: out.debug << "WorkgroupMemoryBarrierWithGroupSync"; break;
default: out.debug.message(EPrefixError, "Bad aggregation op");
}
......
......@@ -81,8 +81,12 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.float4.frag", "PixelShaderFunction"},
{"hlsl.forLoop.frag", "PixelShaderFunction"},
{"hlsl.if.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.barriers.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.evalfns.frag", "main"},
{"hlsl.intrinsics.f1632.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.lit.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.negative.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.negative.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.negative.vert", "VertexShaderFunction"},
......
......@@ -967,6 +967,7 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
dst->getSequence().push_back(handleBinaryMath(loc, "mul", EOpMul, src0y, src1y));
dst->getSequence().push_back(src0z);
dst->getSequence().push_back(src1w);
dst->setType(TType(EbtFloat, EvqTemporary, 4));
dst->setLoc(loc);
node = dst;
......@@ -1028,6 +1029,90 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
break;
}
case EOpEvaluateAttributeSnapped:
{
// SPIR-V InterpolateAtOffset uses float vec2 offset in pixels
// HLSL uses int2 offset on a 16x16 grid in [-8..7] on x & y:
// iU = (iU<<28)>>28
// fU = ((float)iU)/16
// Targets might handle this natively, in which case they can disable
// decompositions.
TIntermTyped* arg0 = argAggregate->getSequence()[0]->getAsTyped(); // value
TIntermTyped* arg1 = argAggregate->getSequence()[1]->getAsTyped(); // offset
TIntermTyped* i28 = intermediate.addConstantUnion(28, loc, true);
TIntermTyped* iU = handleBinaryMath(loc, ">>", EOpRightShift,
handleBinaryMath(loc, "<<", EOpLeftShift, arg1, i28),
i28);
TIntermTyped* recip16 = intermediate.addConstantUnion((1.0/16.0), EbtFloat, loc, true);
TIntermTyped* floatOffset = handleBinaryMath(loc, "mul", EOpMul,
intermediate.addConversion(EOpConstructFloat,
TType(EbtFloat, EvqTemporary, 2), iU),
recip16);
TIntermAggregate* interp = new TIntermAggregate(EOpInterpolateAtOffset);
interp->getSequence().push_back(arg0);
interp->getSequence().push_back(floatOffset);
interp->setLoc(loc);
interp->setType(arg0->getType());
interp->getWritableType().getQualifier().makeTemporary();
node = interp;
break;
}
case EOpLit:
{
TIntermTyped* n_dot_l = argAggregate->getSequence()[0]->getAsTyped();
TIntermTyped* n_dot_h = argAggregate->getSequence()[1]->getAsTyped();
TIntermTyped* m = argAggregate->getSequence()[2]->getAsTyped();
TIntermAggregate* dst = new TIntermAggregate(EOpConstructVec4);
// Ambient
dst->getSequence().push_back(intermediate.addConstantUnion(1.0, EbtFloat, loc, true));
// Diffuse:
TIntermTyped* zero = intermediate.addConstantUnion(0.0, EbtFloat, loc, true);
TIntermAggregate* diffuse = new TIntermAggregate(EOpMax);
diffuse->getSequence().push_back(n_dot_l);
diffuse->getSequence().push_back(zero);
diffuse->setLoc(loc);
diffuse->setType(TType(EbtFloat));
dst->getSequence().push_back(diffuse);
// Specular:
TIntermAggregate* min_ndot = new TIntermAggregate(EOpMin);
min_ndot->getSequence().push_back(n_dot_l);
min_ndot->getSequence().push_back(n_dot_h);
min_ndot->setLoc(loc);
min_ndot->setType(TType(EbtFloat));
TIntermTyped* compare = handleBinaryMath(loc, "<", EOpLessThan, min_ndot, zero);
TIntermTyped* n_dot_h_m = handleBinaryMath(loc, "mul", EOpMul, n_dot_h, m); // n_dot_h * m
dst->getSequence().push_back(intermediate.addSelection(compare, zero, n_dot_h_m, loc));
// One:
dst->getSequence().push_back(intermediate.addConstantUnion(1.0, EbtFloat, loc, true));
dst->setLoc(loc);
dst->setType(TType(EbtFloat, EvqTemporary, 4));
node = dst;
break;
}
case EOpF16tof32:
case EOpF32tof16:
{
// Temporary until decomposition is available.
error(loc, "unimplemented intrinsic: handle natively", "f32tof16", "");
break;
}
default:
break; // most pass through unchanged
}
......
......@@ -283,7 +283,7 @@ void TBuiltInParseablesHlsl::initialize(int version, EProfile profile, const Spv
// { "errorf", "-", "-", "", "", EShLangAll }, TODO: varargs
{ "EvaluateAttributeAtCentroid", nullptr, nullptr, "SVM", "F", EShLangFragmentMask },
{ "EvaluateAttributeAtSample", nullptr, nullptr, "SVM,S", "F,U", EShLangFragmentMask },
{ "EvaluateAttributeSnapped", nullptr, nullptr, "SVM,V2", "F,F", EShLangFragmentMask },
{ "EvaluateAttributeSnapped", nullptr, nullptr, "SVM,V2", "F,I", EShLangFragmentMask },
{ "exp", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "exp2", nullptr, nullptr, "SVM", "F", EShLangAll },
{ "f16tof32", nullptr, "F", "SV", "U", EShLangAll },
......@@ -519,8 +519,8 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int version, EProfile profile, con
symbolTable.relateToOperator("abs", EOpAbs);
symbolTable.relateToOperator("acos", EOpAcos);
symbolTable.relateToOperator("all", EOpAll);
// symbolTable.relateToOperator("AllMemoryBarrier");
// symbolTable.relateToOperator("AllMemoryBarrierWithGroupSync");
symbolTable.relateToOperator("AllMemoryBarrier", EOpMemoryBarrier);
symbolTable.relateToOperator("AllMemoryBarrierWithGroupSync", EOpAllMemoryBarrierWithGroupSync);
symbolTable.relateToOperator("any", EOpAny);
symbolTable.relateToOperator("asdouble", EOpUint64BitsToDouble);
symbolTable.relateToOperator("asfloat", EOpIntBitsToFloat);
......@@ -546,19 +546,19 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int version, EProfile profile, con
symbolTable.relateToOperator("ddy_fine", EOpDPdyFine);
symbolTable.relateToOperator("degrees", EOpDegrees);
symbolTable.relateToOperator("determinant", EOpDeterminant);
// symbolTable.relateToOperator("DeviceMemoryBarrier");
// symbolTable.relateToOperator("DeviceMemoryBarrierWithGroupSync");
symbolTable.relateToOperator("DeviceMemoryBarrier", EOpGroupMemoryBarrier); // == ScopeDevice+CrossWorkGroup
symbolTable.relateToOperator("DeviceMemoryBarrierWithGroupSync", EOpGroupMemoryBarrierWithGroupSync); // ...
symbolTable.relateToOperator("distance", EOpDistance);
symbolTable.relateToOperator("dot", EOpDot);
symbolTable.relateToOperator("dst", EOpDst);
// symbolTable.relateToOperator("errorf");
// symbolTable.relateToOperator("errorf", EOpErrorf);
symbolTable.relateToOperator("EvaluateAttributeAtCentroid", EOpInterpolateAtCentroid);
symbolTable.relateToOperator("EvaluateAttributeAtSample", EOpInterpolateAtSample);
// symbolTable.relateToOperator("EvaluateAttributeSnapped"); // TODO: hsnflr positions. new op?
symbolTable.relateToOperator("EvaluateAttributeSnapped", EOpEvaluateAttributeSnapped);
symbolTable.relateToOperator("exp", EOpExp);
symbolTable.relateToOperator("exp2", EOpExp2);
// symbolTable.relateToOperator("f16tof32");
// symbolTable.relateToOperator("f32tof16");
symbolTable.relateToOperator("f16tof32", EOpF16tof32);
symbolTable.relateToOperator("f32tof16", EOpF32tof16);
symbolTable.relateToOperator("faceforward", EOpFaceForward);
symbolTable.relateToOperator("firstbithigh", EOpFindMSB);
symbolTable.relateToOperator("firstbitlow", EOpFindLSB);
......@@ -570,8 +570,8 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int version, EProfile profile, con
symbolTable.relateToOperator("fwidth", EOpFwidth);
// symbolTable.relateToOperator("GetRenderTargetSampleCount");
// symbolTable.relateToOperator("GetRenderTargetSamplePosition");
// symbolTable.relateToOperator("GroupMemoryBarrier");
// symbolTable.relateToOperator("GroupMemoryBarrierWithGroupSync");
symbolTable.relateToOperator("GroupMemoryBarrier", EOpWorkgroupMemoryBarrier);
symbolTable.relateToOperator("GroupMemoryBarrierWithGroupSync", EOpWorkgroupMemoryBarrierWithGroupSync);
symbolTable.relateToOperator("InterlockedAdd", EOpInterlockedAdd);
symbolTable.relateToOperator("InterlockedAnd", EOpInterlockedAnd);
symbolTable.relateToOperator("InterlockedCompareExchange", EOpInterlockedCompareExchange);
......@@ -586,7 +586,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int version, EProfile profile, con
symbolTable.relateToOperator("isnan", EOpIsNan);
symbolTable.relateToOperator("ldexp", EOpLdexp);
symbolTable.relateToOperator("length", EOpLength);
// symbolTable.relateToOperator("lit");
symbolTable.relateToOperator("lit", EOpLit);
symbolTable.relateToOperator("log", EOpLog);
symbolTable.relateToOperator("log10", EOpLog10);
symbolTable.relateToOperator("log2", EOpLog2);
......@@ -599,7 +599,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int version, EProfile profile, con
// symbolTable.relateToOperator("noise", EOpNoise); // TODO: check return type
symbolTable.relateToOperator("normalize", EOpNormalize);
symbolTable.relateToOperator("pow", EOpPow);
// symbolTable.relateToOperator("printf");
// symbolTable.relateToOperator("printf", EOpPrintf);
// symbolTable.relateToOperator("Process2DQuadTessFactorsAvg");
// symbolTable.relateToOperator("Process2DQuadTessFactorsMax");
// symbolTable.relateToOperator("Process2DQuadTessFactorsMin");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment