HLSL: Handle "." for structure dereference and swizzle.
This commit is contained in:
parent
5aa59e2044
commit
93a162a857
@ -2,15 +2,24 @@ hlsl.struct.frag
|
|||||||
Shader version: 450
|
Shader version: 450
|
||||||
gl_FragCoord origin is upper left
|
gl_FragCoord origin is upper left
|
||||||
0:? Sequence
|
0:? Sequence
|
||||||
0:39 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
|
0:40 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
|
||||||
0:31 Function Parameters:
|
0:31 Function Parameters:
|
||||||
0:31 'input' (in 4-component vector of float)
|
0:31 'input' (in 4-component vector of float)
|
||||||
0:? Sequence
|
0:? Sequence
|
||||||
0:36 Compare Equal (temp bool)
|
0:36 Compare Equal (temp bool)
|
||||||
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
||||||
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
||||||
0:38 Branch: Return with expression
|
0:37 move second child to first child (temp 4-component vector of float)
|
||||||
0:38 'input' (in 4-component vector of float)
|
0:37 i: direct index for structure (temp 4-component vector of float)
|
||||||
|
0:37 's2' (temp structure{temp 4-component vector of float i})
|
||||||
|
0:37 Constant:
|
||||||
|
0:37 0 (const int)
|
||||||
|
0:37 ff4: direct index for structure (temp 4-component vector of float FragCoord)
|
||||||
|
0:37 's4' (temp structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float FragCoord ff4})
|
||||||
|
0:37 Constant:
|
||||||
|
0:37 7 (const int)
|
||||||
|
0:39 Branch: Return with expression
|
||||||
|
0:39 'input' (in 4-component vector of float)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
|
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
|
||||||
0:? 's2' (temp structure{temp 4-component vector of float i})
|
0:? 's2' (temp structure{temp 4-component vector of float i})
|
||||||
@ -23,15 +32,24 @@ Linked fragment stage:
|
|||||||
Shader version: 450
|
Shader version: 450
|
||||||
gl_FragCoord origin is upper left
|
gl_FragCoord origin is upper left
|
||||||
0:? Sequence
|
0:? Sequence
|
||||||
0:39 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
|
0:40 Function Definition: PixelShaderFunction(vf4; (temp 4-component vector of float)
|
||||||
0:31 Function Parameters:
|
0:31 Function Parameters:
|
||||||
0:31 'input' (in 4-component vector of float)
|
0:31 'input' (in 4-component vector of float)
|
||||||
0:? Sequence
|
0:? Sequence
|
||||||
0:36 Compare Equal (temp bool)
|
0:36 Compare Equal (temp bool)
|
||||||
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
||||||
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
0:36 's3' (temp structure{temp 3-component vector of bool b3})
|
||||||
0:38 Branch: Return with expression
|
0:37 move second child to first child (temp 4-component vector of float)
|
||||||
0:38 'input' (in 4-component vector of float)
|
0:37 i: direct index for structure (temp 4-component vector of float)
|
||||||
|
0:37 's2' (temp structure{temp 4-component vector of float i})
|
||||||
|
0:37 Constant:
|
||||||
|
0:37 0 (const int)
|
||||||
|
0:37 ff4: direct index for structure (temp 4-component vector of float FragCoord)
|
||||||
|
0:37 's4' (temp structure{smooth in 4-component vector of float a, flat temp bool b, centroid noperspective temp 1-component vector of float c, centroid sample temp 2-component vector of float d, temp bool Face ff1, temp bool ff2, temp bool ff3, temp 4-component vector of float FragCoord ff4})
|
||||||
|
0:37 Constant:
|
||||||
|
0:37 7 (const int)
|
||||||
|
0:39 Branch: Return with expression
|
||||||
|
0:39 'input' (in 4-component vector of float)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
|
0:? 's1' (temp structure{temp bool b, temp bool c, temp 4-component vector of float a, temp 4-component vector of float d})
|
||||||
0:? 's2' (temp structure{temp 4-component vector of float i})
|
0:? 's2' (temp structure{temp 4-component vector of float i})
|
||||||
@ -39,40 +57,40 @@ gl_FragCoord origin is upper left
|
|||||||
|
|
||||||
// Module Version 10000
|
// Module Version 10000
|
||||||
// Generated by (magic number): 80001
|
// Generated by (magic number): 80001
|
||||||
// Id's are bound by 33
|
// Id's are bound by 40
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
1: ExtInstImport "GLSL.std.450"
|
1: ExtInstImport "GLSL.std.450"
|
||||||
MemoryModel Logical GLSL450
|
MemoryModel Logical GLSL450
|
||||||
EntryPoint Fragment 4 "PixelShaderFunction" 20
|
EntryPoint Fragment 4 "PixelShaderFunction" 34
|
||||||
ExecutionMode 4 OriginUpperLeft
|
ExecutionMode 4 OriginUpperLeft
|
||||||
Source HLSL 450
|
Source HLSL 450
|
||||||
Name 4 "PixelShaderFunction"
|
Name 4 "PixelShaderFunction"
|
||||||
Name 8 "FS"
|
Name 8 "FS"
|
||||||
MemberName 8(FS) 0 "b3"
|
MemberName 8(FS) 0 "b3"
|
||||||
Name 10 "s3"
|
Name 10 "s3"
|
||||||
Name 20 "input"
|
Name 19 ""
|
||||||
Name 23 "myS"
|
MemberName 19 0 "i"
|
||||||
MemberName 23(myS) 0 "b"
|
Name 21 "s2"
|
||||||
MemberName 23(myS) 1 "c"
|
Name 25 ""
|
||||||
MemberName 23(myS) 2 "a"
|
MemberName 25 0 "a"
|
||||||
MemberName 23(myS) 3 "d"
|
MemberName 25 1 "b"
|
||||||
Name 25 "s1"
|
MemberName 25 2 "c"
|
||||||
Name 26 ""
|
MemberName 25 3 "d"
|
||||||
MemberName 26 0 "i"
|
MemberName 25 4 "ff1"
|
||||||
Name 28 "s2"
|
MemberName 25 5 "ff2"
|
||||||
Name 30 ""
|
MemberName 25 6 "ff3"
|
||||||
MemberName 30 0 "a"
|
MemberName 25 7 "ff4"
|
||||||
MemberName 30 1 "b"
|
Name 27 "s4"
|
||||||
MemberName 30 2 "c"
|
Name 34 "input"
|
||||||
MemberName 30 3 "d"
|
Name 37 "myS"
|
||||||
MemberName 30 4 "ff1"
|
MemberName 37(myS) 0 "b"
|
||||||
MemberName 30 5 "ff2"
|
MemberName 37(myS) 1 "c"
|
||||||
MemberName 30 6 "ff3"
|
MemberName 37(myS) 2 "a"
|
||||||
MemberName 30 7 "ff4"
|
MemberName 37(myS) 3 "d"
|
||||||
Name 32 "s4"
|
Name 39 "s1"
|
||||||
MemberDecorate 30 4 BuiltIn FrontFacing
|
MemberDecorate 25 4 BuiltIn FrontFacing
|
||||||
MemberDecorate 30 7 BuiltIn FragCoord
|
MemberDecorate 25 7 BuiltIn FragCoord
|
||||||
2: TypeVoid
|
2: TypeVoid
|
||||||
3: TypeFunction 2
|
3: TypeFunction 2
|
||||||
6: TypeBool
|
6: TypeBool
|
||||||
@ -81,27 +99,35 @@ gl_FragCoord origin is upper left
|
|||||||
9: TypePointer Function 8(FS)
|
9: TypePointer Function 8(FS)
|
||||||
17: TypeFloat 32
|
17: TypeFloat 32
|
||||||
18: TypeVector 17(float) 4
|
18: TypeVector 17(float) 4
|
||||||
19: TypePointer Input 18(fvec4)
|
19: TypeStruct 18(fvec4)
|
||||||
20(input): 19(ptr) Variable Input
|
20: TypePointer Function 19(struct)
|
||||||
23(myS): TypeStruct 6(bool) 6(bool) 18(fvec4) 18(fvec4)
|
22: TypeInt 32 1
|
||||||
24: TypePointer Function 23(myS)
|
23: 22(int) Constant 0
|
||||||
26: TypeStruct 18(fvec4)
|
24: TypeVector 17(float) 2
|
||||||
27: TypePointer Function 26(struct)
|
25: TypeStruct 18(fvec4) 6(bool) 17(float) 24(fvec2) 6(bool) 6(bool) 6(bool) 18(fvec4)
|
||||||
29: TypeVector 17(float) 2
|
26: TypePointer Function 25(struct)
|
||||||
30: TypeStruct 18(fvec4) 6(bool) 17(float) 29(fvec2) 6(bool) 6(bool) 6(bool) 18(fvec4)
|
28: 22(int) Constant 7
|
||||||
31: TypePointer Function 30(struct)
|
29: TypePointer Function 18(fvec4)
|
||||||
|
33: TypePointer Input 18(fvec4)
|
||||||
|
34(input): 33(ptr) Variable Input
|
||||||
|
37(myS): TypeStruct 6(bool) 6(bool) 18(fvec4) 18(fvec4)
|
||||||
|
38: TypePointer Function 37(myS)
|
||||||
4(PixelShaderFunction): 2 Function None 3
|
4(PixelShaderFunction): 2 Function None 3
|
||||||
5: Label
|
5: Label
|
||||||
10(s3): 9(ptr) Variable Function
|
10(s3): 9(ptr) Variable Function
|
||||||
25(s1): 24(ptr) Variable Function
|
21(s2): 20(ptr) Variable Function
|
||||||
28(s2): 27(ptr) Variable Function
|
27(s4): 26(ptr) Variable Function
|
||||||
32(s4): 31(ptr) Variable Function
|
39(s1): 38(ptr) Variable Function
|
||||||
11: 8(FS) Load 10(s3)
|
11: 8(FS) Load 10(s3)
|
||||||
12: 8(FS) Load 10(s3)
|
12: 8(FS) Load 10(s3)
|
||||||
13: 7(bvec3) CompositeExtract 11 0
|
13: 7(bvec3) CompositeExtract 11 0
|
||||||
14: 7(bvec3) CompositeExtract 12 0
|
14: 7(bvec3) CompositeExtract 12 0
|
||||||
15: 7(bvec3) LogicalEqual 13 14
|
15: 7(bvec3) LogicalEqual 13 14
|
||||||
16: 6(bool) All 15
|
16: 6(bool) All 15
|
||||||
21: 18(fvec4) Load 20(input)
|
30: 29(ptr) AccessChain 27(s4) 28
|
||||||
ReturnValue 21
|
31: 18(fvec4) Load 30
|
||||||
|
32: 29(ptr) AccessChain 21(s2) 23
|
||||||
|
Store 32 31
|
||||||
|
35: 18(fvec4) Load 34(input)
|
||||||
|
ReturnValue 35
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|||||||
113
Test/baseResults/hlsl.swizzle.frag.out
Executable file
113
Test/baseResults/hlsl.swizzle.frag.out
Executable file
@ -0,0 +1,113 @@
|
|||||||
|
hlsl.swizzle.frag
|
||||||
|
Shader version: 450
|
||||||
|
gl_FragCoord origin is upper left
|
||||||
|
0:? Sequence
|
||||||
|
0:1 move second child to first child (temp 4-component vector of float)
|
||||||
|
0:1 'AmbientColor' (temp 4-component vector of float)
|
||||||
|
0:? Constant:
|
||||||
|
0:? 1.000000
|
||||||
|
0:? 0.500000
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 1.000000
|
||||||
|
0:7 Function Definition: ShaderFunction(vf4; (temp 4-component vector of float)
|
||||||
|
0:4 Function Parameters:
|
||||||
|
0:4 'input' (in 4-component vector of float)
|
||||||
|
0:? Sequence
|
||||||
|
0:5 Branch: Return with expression
|
||||||
|
0:5 component-wise multiply (temp 4-component vector of float)
|
||||||
|
0:5 vector swizzle (temp 4-component vector of float)
|
||||||
|
0:5 'input' (in 4-component vector of float)
|
||||||
|
0:5 Sequence
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 3 (const int)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 3 (const int)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 1 (const int)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 0 (const int)
|
||||||
|
0:5 Construct vec4 (temp 4-component vector of float)
|
||||||
|
0:5 direct index (temp float)
|
||||||
|
0:5 'AmbientColor' (temp 4-component vector of float)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 2 (const int)
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 'AmbientColor' (temp 4-component vector of float)
|
||||||
|
|
||||||
|
|
||||||
|
Linked fragment stage:
|
||||||
|
|
||||||
|
|
||||||
|
Shader version: 450
|
||||||
|
gl_FragCoord origin is upper left
|
||||||
|
0:? Sequence
|
||||||
|
0:1 move second child to first child (temp 4-component vector of float)
|
||||||
|
0:1 'AmbientColor' (temp 4-component vector of float)
|
||||||
|
0:? Constant:
|
||||||
|
0:? 1.000000
|
||||||
|
0:? 0.500000
|
||||||
|
0:? 0.000000
|
||||||
|
0:? 1.000000
|
||||||
|
0:7 Function Definition: ShaderFunction(vf4; (temp 4-component vector of float)
|
||||||
|
0:4 Function Parameters:
|
||||||
|
0:4 'input' (in 4-component vector of float)
|
||||||
|
0:? Sequence
|
||||||
|
0:5 Branch: Return with expression
|
||||||
|
0:5 component-wise multiply (temp 4-component vector of float)
|
||||||
|
0:5 vector swizzle (temp 4-component vector of float)
|
||||||
|
0:5 'input' (in 4-component vector of float)
|
||||||
|
0:5 Sequence
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 3 (const int)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 3 (const int)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 1 (const int)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 0 (const int)
|
||||||
|
0:5 Construct vec4 (temp 4-component vector of float)
|
||||||
|
0:5 direct index (temp float)
|
||||||
|
0:5 'AmbientColor' (temp 4-component vector of float)
|
||||||
|
0:5 Constant:
|
||||||
|
0:5 2 (const int)
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 'AmbientColor' (temp 4-component vector of float)
|
||||||
|
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80001
|
||||||
|
// Id's are bound by 25
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint Fragment 4 "PixelShaderFunction"
|
||||||
|
ExecutionMode 4 OriginUpperLeft
|
||||||
|
Source HLSL 450
|
||||||
|
Name 4 "PixelShaderFunction"
|
||||||
|
Name 11 "ShaderFunction(vf4;"
|
||||||
|
Name 10 "input"
|
||||||
|
Name 15 "AmbientColor"
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeFloat 32
|
||||||
|
7: TypeVector 6(float) 4
|
||||||
|
8: TypePointer Function 7(fvec4)
|
||||||
|
9: TypeFunction 7(fvec4) 8(ptr)
|
||||||
|
16: TypeInt 32 0
|
||||||
|
17: 16(int) Constant 2
|
||||||
|
18: TypePointer Function 6(float)
|
||||||
|
4(PixelShaderFunction): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
FunctionEnd
|
||||||
|
11(ShaderFunction(vf4;): 7(fvec4) Function None 9
|
||||||
|
10(input): 8(ptr) FunctionParameter
|
||||||
|
12: Label
|
||||||
|
15(AmbientColor): 8(ptr) Variable Function
|
||||||
|
13: 7(fvec4) Load 10(input)
|
||||||
|
14: 7(fvec4) VectorShuffle 13 13 3 3 1 0
|
||||||
|
19: 18(ptr) AccessChain 15(AmbientColor) 17
|
||||||
|
20: 6(float) Load 19
|
||||||
|
21: 7(fvec4) CompositeConstruct 20 20 20 20
|
||||||
|
22: 7(fvec4) FMul 14 21
|
||||||
|
ReturnValue 22
|
||||||
|
FunctionEnd
|
||||||
@ -34,6 +34,7 @@ float4 PixelShaderFunction(float4 input) : COLOR0
|
|||||||
} s3;
|
} s3;
|
||||||
|
|
||||||
s3 == s3;
|
s3 == s3;
|
||||||
|
s2.i = s4.ff4;
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
6
Test/hlsl.swizzle.frag
Normal file
6
Test/hlsl.swizzle.frag
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
float4 AmbientColor = float4(1, 0.5, 0, 1);
|
||||||
|
|
||||||
|
float4 ShaderFunction(float4 input) : COLOR0
|
||||||
|
{
|
||||||
|
return input.wwyx * float4(AmbientColor.z);
|
||||||
|
}
|
||||||
@ -93,6 +93,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
{"hlsl.scope.frag", "PixelShaderFunction"},
|
{"hlsl.scope.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.sin.frag", "PixelShaderFunction"},
|
{"hlsl.sin.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.struct.frag", "PixelShaderFunction"},
|
{"hlsl.struct.frag", "PixelShaderFunction"},
|
||||||
|
{"hlsl.swizzle.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
|
{"hlsl.whileLoop.frag", "PixelShaderFunction"},
|
||||||
{"hlsl.void.frag", "PixelShaderFunction"},
|
{"hlsl.void.frag", "PixelShaderFunction"},
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -1097,8 +1097,16 @@ bool HlslGrammar::acceptPostfixExpression(TIntermTyped*& node)
|
|||||||
// We have a valid post-unary operator, process it.
|
// We have a valid post-unary operator, process it.
|
||||||
switch (postOp) {
|
switch (postOp) {
|
||||||
case EOpIndexDirectStruct:
|
case EOpIndexDirectStruct:
|
||||||
// todo
|
{
|
||||||
|
// includes swizzles
|
||||||
|
HlslToken field;
|
||||||
|
if (! acceptIdentifier(field)) {
|
||||||
|
expected("swizzle or member");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
node = parseContext.handleDotDereference(field.loc, node, *field.string);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case EOpIndexIndirect:
|
case EOpIndexIndirect:
|
||||||
{
|
{
|
||||||
TIntermTyped* indexNode = nullptr;
|
TIntermTyped* indexNode = nullptr;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user