SPV: When passing structs of opaque types, flatten and pass the members instead.
This avoids either A) needing uniformConstant struct, or B) initializing a struct with opaque members, as writing them is not allowed.
This commit is contained in:
297
Test/baseResults/hlsl.flattenOpaque.frag.out
Executable file
297
Test/baseResults/hlsl.flattenOpaque.frag.out
Executable file
@@ -0,0 +1,297 @@
|
||||
hlsl.flattenOpaque.frag
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:15 Function Definition: osCall1(struct-os-p11; ( temp 4-component vector of float)
|
||||
0:15 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? Sequence
|
||||
0:16 Branch: Return with expression
|
||||
0:16 texture ( temp 4-component vector of float)
|
||||
0:16 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:16 'tex' ( uniform texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:20 Function Definition: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
|
||||
0:20 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:20 'f2' ( in 2-component vector of float)
|
||||
0:? Sequence
|
||||
0:21 Branch: Return with expression
|
||||
0:21 texture ( temp 4-component vector of float)
|
||||
0:21 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:21 'tex' ( uniform texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:21 'f2' ( in 2-component vector of float)
|
||||
0:25 Function Definition: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
|
||||
0:25 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:? Sequence
|
||||
0:26 Branch: Return with expression
|
||||
0:26 texture ( temp 4-component vector of float)
|
||||
0:26 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:30 Function Definition: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
|
||||
0:30 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:30 'f2' ( in 2-component vector of float)
|
||||
0:? Sequence
|
||||
0:31 Branch: Return with expression
|
||||
0:31 texture ( temp 4-component vector of float)
|
||||
0:31 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:31 'f2' ( in 2-component vector of float)
|
||||
0:35 Function Definition: @main( ( temp 4-component vector of float)
|
||||
0:35 Function Parameters:
|
||||
0:? Sequence
|
||||
0:39 Branch: Return with expression
|
||||
0:38 add ( temp 4-component vector of float)
|
||||
0:37 add ( temp 4-component vector of float)
|
||||
0:36 add ( temp 4-component vector of float)
|
||||
0:36 Function Call: osCall1(struct-os-p11; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:37 Function Call: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:38 Function Call: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:? 'tex' ( uniform texture2D)
|
||||
0:39 Function Call: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:? 'tex' ( uniform texture2D)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:35 Function Definition: main( ( temp void)
|
||||
0:35 Function Parameters:
|
||||
0:? Sequence
|
||||
0:35 move second child to first child ( temp 4-component vector of float)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:35 Function Call: @main( ( temp 4-component vector of float)
|
||||
0:? Linker Objects
|
||||
0:? 'tex' ( uniform texture2D)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:15 Function Definition: osCall1(struct-os-p11; ( temp 4-component vector of float)
|
||||
0:15 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? Sequence
|
||||
0:16 Branch: Return with expression
|
||||
0:16 texture ( temp 4-component vector of float)
|
||||
0:16 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:16 'tex' ( uniform texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:20 Function Definition: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
|
||||
0:20 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:20 'f2' ( in 2-component vector of float)
|
||||
0:? Sequence
|
||||
0:21 Branch: Return with expression
|
||||
0:21 texture ( temp 4-component vector of float)
|
||||
0:21 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:21 'tex' ( uniform texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:21 'f2' ( in 2-component vector of float)
|
||||
0:25 Function Definition: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
|
||||
0:25 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:? Sequence
|
||||
0:26 Branch: Return with expression
|
||||
0:26 texture ( temp 4-component vector of float)
|
||||
0:26 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:30 Function Definition: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
|
||||
0:30 Function Parameters:
|
||||
0:? 's2D' ( in sampler)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:30 'f2' ( in 2-component vector of float)
|
||||
0:? Sequence
|
||||
0:31 Branch: Return with expression
|
||||
0:31 texture ( temp 4-component vector of float)
|
||||
0:31 Construct combined texture-sampler ( temp sampler2D)
|
||||
0:? 'tex' ( in texture2D)
|
||||
0:? 's2D' ( in sampler)
|
||||
0:31 'f2' ( in 2-component vector of float)
|
||||
0:35 Function Definition: @main( ( temp 4-component vector of float)
|
||||
0:35 Function Parameters:
|
||||
0:? Sequence
|
||||
0:39 Branch: Return with expression
|
||||
0:38 add ( temp 4-component vector of float)
|
||||
0:37 add ( temp 4-component vector of float)
|
||||
0:36 add ( temp 4-component vector of float)
|
||||
0:36 Function Call: osCall1(struct-os-p11; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:37 Function Call: osCall2(struct-os-p11;vf2; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:38 Function Call: os2Call1(struct-os2-p1-t211; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:? 'tex' ( uniform texture2D)
|
||||
0:39 Function Call: os2Call2(struct-os2-p1-t211;vf2; ( temp 4-component vector of float)
|
||||
0:? 's2D' ( uniform sampler)
|
||||
0:? 'tex' ( uniform texture2D)
|
||||
0:? Constant:
|
||||
0:? 0.200000
|
||||
0:? 0.300000
|
||||
0:35 Function Definition: main( ( temp void)
|
||||
0:35 Function Parameters:
|
||||
0:? Sequence
|
||||
0:35 move second child to first child ( temp 4-component vector of float)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
0:35 Function Call: @main( ( temp 4-component vector of float)
|
||||
0:? Linker Objects
|
||||
0:? 'tex' ( uniform texture2D)
|
||||
0:? '@entryPointOutput' (layout( location=0) out 4-component vector of float)
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80001
|
||||
// Id's are bound by 85
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 83
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source HLSL 500
|
||||
Name 4 "main"
|
||||
Name 12 "osCall1(struct-os-p11;"
|
||||
Name 11 "s2D"
|
||||
Name 19 "osCall2(struct-os-p11;vf2;"
|
||||
Name 17 "s2D"
|
||||
Name 18 "f2"
|
||||
Name 26 "os2Call1(struct-os2-p1-t211;"
|
||||
Name 24 "s2D"
|
||||
Name 25 "tex"
|
||||
Name 32 "os2Call2(struct-os2-p1-t211;vf2;"
|
||||
Name 29 "s2D"
|
||||
Name 30 "tex"
|
||||
Name 31 "f2"
|
||||
Name 35 "@main("
|
||||
Name 37 "tex"
|
||||
Name 68 "s2D"
|
||||
Name 70 "param"
|
||||
Name 73 "s2D"
|
||||
Name 74 "tex"
|
||||
Name 77 "param"
|
||||
Name 83 "@entryPointOutput"
|
||||
Decorate 37(tex) DescriptorSet 0
|
||||
Decorate 68(s2D) DescriptorSet 0
|
||||
Decorate 73(s2D) DescriptorSet 0
|
||||
Decorate 74(tex) DescriptorSet 0
|
||||
Decorate 83(@entryPointOutput) Location 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeSampler
|
||||
7: TypePointer UniformConstant 6
|
||||
8: TypeFloat 32
|
||||
9: TypeVector 8(float) 4
|
||||
10: TypeFunction 9(fvec4) 7(ptr)
|
||||
14: TypeVector 8(float) 2
|
||||
15: TypePointer Function 14(fvec2)
|
||||
16: TypeFunction 9(fvec4) 7(ptr) 15(ptr)
|
||||
21: TypeImage 8(float) 2D sampled format:Unknown
|
||||
22: TypePointer UniformConstant 21
|
||||
23: TypeFunction 9(fvec4) 7(ptr) 22(ptr)
|
||||
28: TypeFunction 9(fvec4) 7(ptr) 22(ptr) 15(ptr)
|
||||
34: TypeFunction 9(fvec4)
|
||||
37(tex): 22(ptr) Variable UniformConstant
|
||||
40: TypeSampledImage 21
|
||||
42: 8(float) Constant 1045220557
|
||||
43: 8(float) Constant 1050253722
|
||||
44: 14(fvec2) ConstantComposite 42 43
|
||||
68(s2D): 7(ptr) Variable UniformConstant
|
||||
73(s2D): 7(ptr) Variable UniformConstant
|
||||
74(tex): 22(ptr) Variable UniformConstant
|
||||
82: TypePointer Output 9(fvec4)
|
||||
83(@entryPointOutput): 82(ptr) Variable Output
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
84: 9(fvec4) FunctionCall 35(@main()
|
||||
Store 83(@entryPointOutput) 84
|
||||
Return
|
||||
FunctionEnd
|
||||
12(osCall1(struct-os-p11;): 9(fvec4) Function None 10
|
||||
11(s2D): 7(ptr) FunctionParameter
|
||||
13: Label
|
||||
38: 21 Load 37(tex)
|
||||
39: 6 Load 11(s2D)
|
||||
41: 40 SampledImage 38 39
|
||||
45: 9(fvec4) ImageSampleImplicitLod 41 44
|
||||
ReturnValue 45
|
||||
FunctionEnd
|
||||
19(osCall2(struct-os-p11;vf2;): 9(fvec4) Function None 16
|
||||
17(s2D): 7(ptr) FunctionParameter
|
||||
18(f2): 15(ptr) FunctionParameter
|
||||
20: Label
|
||||
48: 21 Load 37(tex)
|
||||
49: 6 Load 17(s2D)
|
||||
50: 40 SampledImage 48 49
|
||||
51: 14(fvec2) Load 18(f2)
|
||||
52: 9(fvec4) ImageSampleImplicitLod 50 51
|
||||
ReturnValue 52
|
||||
FunctionEnd
|
||||
26(os2Call1(struct-os2-p1-t211;): 9(fvec4) Function None 23
|
||||
24(s2D): 7(ptr) FunctionParameter
|
||||
25(tex): 22(ptr) FunctionParameter
|
||||
27: Label
|
||||
55: 21 Load 25(tex)
|
||||
56: 6 Load 24(s2D)
|
||||
57: 40 SampledImage 55 56
|
||||
58: 9(fvec4) ImageSampleImplicitLod 57 44
|
||||
ReturnValue 58
|
||||
FunctionEnd
|
||||
32(os2Call2(struct-os2-p1-t211;vf2;): 9(fvec4) Function None 28
|
||||
29(s2D): 7(ptr) FunctionParameter
|
||||
30(tex): 22(ptr) FunctionParameter
|
||||
31(f2): 15(ptr) FunctionParameter
|
||||
33: Label
|
||||
61: 21 Load 30(tex)
|
||||
62: 6 Load 29(s2D)
|
||||
63: 40 SampledImage 61 62
|
||||
64: 14(fvec2) Load 31(f2)
|
||||
65: 9(fvec4) ImageSampleImplicitLod 63 64
|
||||
ReturnValue 65
|
||||
FunctionEnd
|
||||
35(@main(): 9(fvec4) Function None 34
|
||||
36: Label
|
||||
70(param): 15(ptr) Variable Function
|
||||
77(param): 15(ptr) Variable Function
|
||||
69: 9(fvec4) FunctionCall 12(osCall1(struct-os-p11;) 68(s2D)
|
||||
Store 70(param) 44
|
||||
71: 9(fvec4) FunctionCall 19(osCall2(struct-os-p11;vf2;) 68(s2D) 70(param)
|
||||
72: 9(fvec4) FAdd 69 71
|
||||
75: 9(fvec4) FunctionCall 26(os2Call1(struct-os2-p1-t211;) 73(s2D) 74(tex)
|
||||
76: 9(fvec4) FAdd 72 75
|
||||
Store 77(param) 44
|
||||
78: 9(fvec4) FunctionCall 32(os2Call2(struct-os2-p1-t211;vf2;) 73(s2D) 74(tex) 77(param)
|
||||
79: 9(fvec4) FAdd 76 78
|
||||
ReturnValue 79
|
||||
FunctionEnd
|
||||
40
Test/hlsl.flattenOpaque.frag
Normal file
40
Test/hlsl.flattenOpaque.frag
Normal file
@@ -0,0 +1,40 @@
|
||||
struct os {
|
||||
sampler2D s2D;
|
||||
};
|
||||
|
||||
struct os2 {
|
||||
sampler2D s2D;
|
||||
Texture2D tex;
|
||||
};
|
||||
|
||||
Texture2D tex;
|
||||
os s;
|
||||
os2 s2;
|
||||
|
||||
float4 osCall1(os s)
|
||||
{
|
||||
return tex.Sample(s.s2D, float2(0.2, 0.3));
|
||||
}
|
||||
|
||||
float4 osCall2(os s, float2 f2)
|
||||
{
|
||||
return tex.Sample(s.s2D, f2);
|
||||
}
|
||||
|
||||
float4 os2Call1(os2 s)
|
||||
{
|
||||
return s.tex.Sample(s.s2D, float2(0.2, 0.3));
|
||||
}
|
||||
|
||||
float4 os2Call2(os2 s, float2 f2)
|
||||
{
|
||||
return s.tex.Sample(s.s2D, f2);
|
||||
}
|
||||
|
||||
float4 main() : SV_TARGET0
|
||||
{
|
||||
return osCall1(s) +
|
||||
osCall2(s, float2(0.2, 0.3)) +
|
||||
os2Call1(s2) +
|
||||
os2Call2(s2, float2(0.2, 0.3));
|
||||
}
|
||||
Reference in New Issue
Block a user