Fix OpImageRead result type when compiling HLSL (#2706)

Fix OpImageRead result type when compiling HLSL

- Per the Vulkan spec, OpImageRead must return a 4-component vector always. When compiling HLSL, loads from a RWTexture of a template type with < 4 components would incorrectly generate an OpImageRead with a < 4 component result, resulting in validation errors.
- This was previously fixed for OpImageFetch in commit 4425f24; this commit does the same thing for OpImageRead.
- Added associated tests and expanded existing image fetch tests to check all the different types of textures, in both float and int incarnations, for completeness.
- Update other HLSL tests involving OpImageRead
This commit is contained in:
Nathan Reed
2021-07-28 08:29:17 -07:00
committed by GitHub
parent 4a12ee1ae3
commit fc9897d1ba
10 changed files with 2907 additions and 1673 deletions

View File

@@ -1,15 +1,14 @@
spv.rw.autoassign.frag
Validation failed
// Module Version 10000
// Generated by (magic number): 8000a
// Id's are bound by 42
// Id's are bound by 45
Capability Shader
Capability Image1D
Capability ImageBuffer
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 39
EntryPoint Fragment 4 "main" 42
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
@@ -18,15 +17,15 @@ Validation failed
Name 10 "@main("
Name 13 "r00"
Name 16 "g_tTex1df1"
Name 23 "r01"
Name 26 "g_tBuf1du1"
Name 30 "psout"
Name 39 "@entryPointOutput.Color"
Name 24 "r01"
Name 27 "g_tBuf1du1"
Name 33 "psout"
Name 42 "@entryPointOutput.Color"
Decorate 16(g_tTex1df1) DescriptorSet 0
Decorate 16(g_tTex1df1) Binding 20
Decorate 26(g_tBuf1du1) DescriptorSet 0
Decorate 26(g_tBuf1du1) Binding 21
Decorate 39(@entryPointOutput.Color) Location 0
Decorate 27(g_tBuf1du1) DescriptorSet 0
Decorate 27(g_tBuf1du1) Binding 21
Decorate 42(@entryPointOutput.Color) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -39,37 +38,40 @@ Validation failed
16(g_tTex1df1): 15(ptr) Variable UniformConstant
18: TypeInt 32 1
19: 18(int) Constant 0
21: TypeInt 32 0
22: TypePointer Function 21(int)
24: TypeImage 21(int) Buffer nonsampled format:R32ui
25: TypePointer UniformConstant 24
26(g_tBuf1du1): 25(ptr) Variable UniformConstant
29: TypePointer Function 8(PS_OUTPUT)
31: 6(float) Constant 0
32: 7(fvec4) ConstantComposite 31 31 31 31
33: TypePointer Function 7(fvec4)
38: TypePointer Output 7(fvec4)
39(@entryPointOutput.Color): 38(ptr) Variable Output
22: TypeInt 32 0
23: TypePointer Function 22(int)
25: TypeImage 22(int) Buffer nonsampled format:R32ui
26: TypePointer UniformConstant 25
27(g_tBuf1du1): 26(ptr) Variable UniformConstant
29: TypeVector 22(int) 4
32: TypePointer Function 8(PS_OUTPUT)
34: 6(float) Constant 0
35: 7(fvec4) ConstantComposite 34 34 34 34
36: TypePointer Function 7(fvec4)
41: TypePointer Output 7(fvec4)
42(@entryPointOutput.Color): 41(ptr) Variable Output
4(main): 2 Function None 3
5: Label
40:8(PS_OUTPUT) FunctionCall 10(@main()
41: 7(fvec4) CompositeExtract 40 0
Store 39(@entryPointOutput.Color) 41
43:8(PS_OUTPUT) FunctionCall 10(@main()
44: 7(fvec4) CompositeExtract 43 0
Store 42(@entryPointOutput.Color) 44
Return
FunctionEnd
10(@main():8(PS_OUTPUT) Function None 9
11: Label
13(r00): 12(ptr) Variable Function
23(r01): 22(ptr) Variable Function
30(psout): 29(ptr) Variable Function
24(r01): 23(ptr) Variable Function
33(psout): 32(ptr) Variable Function
17: 14 Load 16(g_tTex1df1)
20: 6(float) ImageRead 17 19
Store 13(r00) 20
27: 24 Load 26(g_tBuf1du1)
28: 21(int) ImageRead 27 19
Store 23(r01) 28
34: 33(ptr) AccessChain 30(psout) 19
Store 34 32
35:8(PS_OUTPUT) Load 30(psout)
ReturnValue 35
20: 7(fvec4) ImageRead 17 19
21: 6(float) CompositeExtract 20 0
Store 13(r00) 21
28: 25 Load 27(g_tBuf1du1)
30: 29(ivec4) ImageRead 28 19
31: 22(int) CompositeExtract 30 0
Store 24(r01) 31
37: 36(ptr) AccessChain 33(psout) 19
Store 37 35
38:8(PS_OUTPUT) Load 33(psout)
ReturnValue 38
FunctionEnd