HLSL: cast non-int types to uint on Load/Store indexes

Some texture and SB operations can take non-integer indexes, which should be
cast to integers before use if they are not already.  This adds makeIntegerIndex()
for the purpose.  Int types are left alone.

(This was done before for operator[], but needs to apply to some other things
too, hence its extraction into common function now)
This commit is contained in:
steve-lunarg
2017-04-20 09:00:56 -06:00
parent 670271890d
commit f8203a0acd
6 changed files with 453 additions and 91 deletions

View File

@@ -1,12 +1,12 @@
spv.ssbo.autoassign.frag
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 95
// Id's are bound by 99
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 88 91
EntryPoint Fragment 4 "main" 92 95
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
@@ -23,13 +23,13 @@ spv.ssbo.autoassign.frag
MemberName 26(TestCB) 0 "W"
MemberName 26(TestCB) 1 "H"
Name 28 ""
Name 55 "SB1"
MemberName 55(SB1) 0 "@data"
Name 57 "SB1"
Name 86 "pos"
Name 88 "pos"
Name 91 "@entryPointOutput"
Name 92 "param"
MemberName 57(SB1) 0 "@data"
Name 59 "SB1"
Name 90 "pos"
Name 92 "pos"
Name 95 "@entryPointOutput"
Name 96 "param"
MemberDecorate 14(BufType) 0 NonWritable
MemberDecorate 14(BufType) 0 Offset 0
MemberDecorate 14(BufType) 1 NonWritable
@@ -45,13 +45,13 @@ spv.ssbo.autoassign.frag
Decorate 26(TestCB) Block
Decorate 28 DescriptorSet 0
Decorate 28 Binding 15
Decorate 54 ArrayStride 32
MemberDecorate 55(SB1) 0 Offset 0
Decorate 55(SB1) BufferBlock
Decorate 57(SB1) DescriptorSet 0
Decorate 57(SB1) Binding 31
Decorate 88(pos) Location 0
Decorate 91(@entryPointOutput) Location 0
Decorate 56 ArrayStride 32
MemberDecorate 57(SB1) 0 Offset 0
Decorate 57(SB1) BufferBlock
Decorate 59(SB1) DescriptorSet 0
Decorate 59(SB1) Binding 31
Decorate 92(pos) Location 0
Decorate 95(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@@ -73,26 +73,26 @@ spv.ssbo.autoassign.frag
28: 27(ptr) Variable Uniform
29: TypePointer Uniform 21(int)
34: 21(int) Constant 0
38: TypePointer Uniform 7(fvec4)
50: 19(int) Constant 1
54: TypeRuntimeArray 14(BufType)
55(SB1): TypeStruct 54
56: TypePointer Uniform 55(SB1)
57(SB1): 56(ptr) Variable Uniform
87: TypePointer Input 7(fvec4)
88(pos): 87(ptr) Variable Input
90: TypePointer Output 7(fvec4)
91(@entryPointOutput): 90(ptr) Variable Output
39: TypePointer Uniform 7(fvec4)
52: 19(int) Constant 1
56: TypeRuntimeArray 14(BufType)
57(SB1): TypeStruct 56
58: TypePointer Uniform 57(SB1)
59(SB1): 58(ptr) Variable Uniform
91: TypePointer Input 7(fvec4)
92(pos): 91(ptr) Variable Input
94: TypePointer Output 7(fvec4)
95(@entryPointOutput): 94(ptr) Variable Output
4(main): 2 Function None 3
5: Label
86(pos): 8(ptr) Variable Function
92(param): 8(ptr) Variable Function
89: 7(fvec4) Load 88(pos)
Store 86(pos) 89
93: 7(fvec4) Load 86(pos)
Store 92(param) 93
94: 7(fvec4) FunctionCall 11(@main(vf4;) 92(param)
Store 91(@entryPointOutput) 94
90(pos): 8(ptr) Variable Function
96(param): 8(ptr) Variable Function
93: 7(fvec4) Load 92(pos)
Store 90(pos) 93
97: 7(fvec4) Load 90(pos)
Store 96(param) 97
98: 7(fvec4) FunctionCall 11(@main(vf4;) 96(param)
Store 95(@entryPointOutput) 98
Return
FunctionEnd
11(@main(vf4;): 7(fvec4) Function None 9
@@ -108,47 +108,51 @@ spv.ssbo.autoassign.frag
35: 23(ptr) AccessChain 10(pos) 34
36: 6(float) Load 35
37: 6(float) FAdd 33 36
39: 38(ptr) AccessChain 18(SB0) 20 37 20
40: 7(fvec4) Load 39
41: 23(ptr) AccessChain 10(pos) 22
42: 6(float) Load 41
43: 29(ptr) AccessChain 28 20
44: 21(int) Load 43
45: 6(float) ConvertUToF 44
46: 6(float) FMul 42 45
47: 23(ptr) AccessChain 10(pos) 34
48: 6(float) Load 47
49: 6(float) FAdd 46 48
51: 38(ptr) AccessChain 18(SB0) 20 49 50
52: 7(fvec4) Load 51
53: 7(fvec4) FAdd 40 52
Store 13(vTmp) 53
58: 23(ptr) AccessChain 10(pos) 22
59: 6(float) Load 58
60: 29(ptr) AccessChain 28 20
61: 21(int) Load 60
62: 6(float) ConvertUToF 61
63: 6(float) FMul 59 62
64: 23(ptr) AccessChain 10(pos) 34
65: 6(float) Load 64
66: 6(float) FAdd 63 65
67: 38(ptr) AccessChain 57(SB1) 20 66 20
68: 7(fvec4) Load 67
69: 23(ptr) AccessChain 10(pos) 22
70: 6(float) Load 69
71: 29(ptr) AccessChain 28 20
72: 21(int) Load 71
73: 6(float) ConvertUToF 72
74: 6(float) FMul 70 73
75: 23(ptr) AccessChain 10(pos) 34
76: 6(float) Load 75
77: 6(float) FAdd 74 76
78: 38(ptr) AccessChain 57(SB1) 20 77 50
79: 7(fvec4) Load 78
80: 7(fvec4) FAdd 68 79
81: 7(fvec4) Load 13(vTmp)
82: 7(fvec4) FAdd 81 80
Store 13(vTmp) 82
83: 7(fvec4) Load 13(vTmp)
ReturnValue 83
38: 21(int) ConvertFToU 37
40: 39(ptr) AccessChain 18(SB0) 20 38 20
41: 7(fvec4) Load 40
42: 23(ptr) AccessChain 10(pos) 22
43: 6(float) Load 42
44: 29(ptr) AccessChain 28 20
45: 21(int) Load 44
46: 6(float) ConvertUToF 45
47: 6(float) FMul 43 46
48: 23(ptr) AccessChain 10(pos) 34
49: 6(float) Load 48
50: 6(float) FAdd 47 49
51: 21(int) ConvertFToU 50
53: 39(ptr) AccessChain 18(SB0) 20 51 52
54: 7(fvec4) Load 53
55: 7(fvec4) FAdd 41 54
Store 13(vTmp) 55
60: 23(ptr) AccessChain 10(pos) 22
61: 6(float) Load 60
62: 29(ptr) AccessChain 28 20
63: 21(int) Load 62
64: 6(float) ConvertUToF 63
65: 6(float) FMul 61 64
66: 23(ptr) AccessChain 10(pos) 34
67: 6(float) Load 66
68: 6(float) FAdd 65 67
69: 21(int) ConvertFToU 68
70: 39(ptr) AccessChain 59(SB1) 20 69 20
71: 7(fvec4) Load 70
72: 23(ptr) AccessChain 10(pos) 22
73: 6(float) Load 72
74: 29(ptr) AccessChain 28 20
75: 21(int) Load 74
76: 6(float) ConvertUToF 75
77: 6(float) FMul 73 76
78: 23(ptr) AccessChain 10(pos) 34
79: 6(float) Load 78
80: 6(float) FAdd 77 79
81: 21(int) ConvertFToU 80
82: 39(ptr) AccessChain 59(SB1) 20 81 52
83: 7(fvec4) Load 82
84: 7(fvec4) FAdd 71 83
85: 7(fvec4) Load 13(vTmp)
86: 7(fvec4) FAdd 85 84
Store 13(vTmp) 86
87: 7(fvec4) Load 13(vTmp)
ReturnValue 87
FunctionEnd