SPIR-V requires that any instruction using the result of an OpSampledImage instruction be in the same block as the OpSampledImage. This is hard to guarantee in code generation but easy to fix after the fact, by simply inserting a new OpSampledImage before the user of its result if needed, with the new instruction having the same operands as the original OpSampledImage. This change adds a new pass to spv::Builder::postProcess that does this. This might leave the original OpSampledImage instructions "orphaned" with no users of their result ID, but dead code elimination would take care of those further down the line.
94 lines
4.6 KiB
Text
94 lines
4.6 KiB
Text
spv.sampledImageBlock.frag
|
|
// Module Version 10000
|
|
// Generated by (magic number): 8000b
|
|
// Id's are bound by 55
|
|
|
|
Capability Shader
|
|
1: ExtInstImport "GLSL.std.450"
|
|
MemoryModel Logical GLSL450
|
|
EntryPoint Fragment 4 "main" 36 45
|
|
ExecutionMode 4 OriginUpperLeft
|
|
Source GLSL 450
|
|
Name 4 "main"
|
|
Name 9 "texel"
|
|
Name 12 "tex0"
|
|
Name 16 "samp0"
|
|
Name 21 "ParamBuffer"
|
|
MemberName 21(ParamBuffer) 0 "cond"
|
|
Name 23 "paramBuffer"
|
|
Name 36 "texCoord"
|
|
Name 45 "fragColor"
|
|
Decorate 12(tex0) DescriptorSet 0
|
|
Decorate 12(tex0) Binding 0
|
|
Decorate 16(samp0) DescriptorSet 0
|
|
Decorate 16(samp0) Binding 1
|
|
MemberDecorate 21(ParamBuffer) 0 Offset 0
|
|
Decorate 21(ParamBuffer) Block
|
|
Decorate 23(paramBuffer) DescriptorSet 0
|
|
Decorate 23(paramBuffer) Binding 2
|
|
Decorate 36(texCoord) Flat
|
|
Decorate 36(texCoord) Location 0
|
|
Decorate 45(fragColor) Location 0
|
|
2: TypeVoid
|
|
3: TypeFunction 2
|
|
6: TypeFloat 32
|
|
7: TypeVector 6(float) 4
|
|
8: TypePointer Function 7(fvec4)
|
|
10: TypeImage 6(float) 2D sampled format:Unknown
|
|
11: TypePointer UniformConstant 10
|
|
12(tex0): 11(ptr) Variable UniformConstant
|
|
14: TypeSampler
|
|
15: TypePointer UniformConstant 14
|
|
16(samp0): 15(ptr) Variable UniformConstant
|
|
18: TypeSampledImage 10
|
|
20: TypeInt 32 1
|
|
21(ParamBuffer): TypeStruct 20(int)
|
|
22: TypePointer Uniform 21(ParamBuffer)
|
|
23(paramBuffer): 22(ptr) Variable Uniform
|
|
24: 20(int) Constant 0
|
|
25: TypePointer Uniform 20(int)
|
|
28: TypeBool
|
|
30: TypeVector 20(int) 2
|
|
31: TypePointer Function 30(ivec2)
|
|
35: TypePointer Input 30(ivec2)
|
|
36(texCoord): 35(ptr) Variable Input
|
|
44: TypePointer Output 7(fvec4)
|
|
45(fragColor): 44(ptr) Variable Output
|
|
46: TypeVector 6(float) 3
|
|
49: 6(float) Constant 1065353216
|
|
4(main): 2 Function None 3
|
|
5: Label
|
|
9(texel): 8(ptr) Variable Function
|
|
32: 31(ptr) Variable Function
|
|
13: 10 Load 12(tex0)
|
|
17: 14 Load 16(samp0)
|
|
19: 18 SampledImage 13 17
|
|
26: 25(ptr) AccessChain 23(paramBuffer) 24
|
|
27: 20(int) Load 26
|
|
29: 28(bool) IEqual 27 24
|
|
SelectionMerge 34 None
|
|
BranchConditional 29 33 38
|
|
33: Label
|
|
37: 30(ivec2) Load 36(texCoord)
|
|
Store 32 37
|
|
Branch 34
|
|
38: Label
|
|
39: 30(ivec2) Load 36(texCoord)
|
|
40: 30(ivec2) VectorShuffle 39 39 1 0
|
|
Store 32 40
|
|
Branch 34
|
|
34: Label
|
|
41: 30(ivec2) Load 32
|
|
54: 18 SampledImage 13 17
|
|
42: 10 Image 54
|
|
43: 7(fvec4) ImageFetch 42 41 Lod 24
|
|
Store 9(texel) 43
|
|
47: 7(fvec4) Load 9(texel)
|
|
48: 46(fvec3) VectorShuffle 47 47 0 1 2
|
|
50: 6(float) CompositeExtract 48 0
|
|
51: 6(float) CompositeExtract 48 1
|
|
52: 6(float) CompositeExtract 48 2
|
|
53: 7(fvec4) CompositeConstruct 50 51 52 49
|
|
Store 45(fragColor) 53
|
|
Return
|
|
FunctionEnd
|