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:
parent
670271890d
commit
f8203a0acd
326
Test/baseResults/hlsl.structbuffer.floatidx.comp.out
Normal file
326
Test/baseResults/hlsl.structbuffer.floatidx.comp.out
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
hlsl.structbuffer.floatidx.comp
|
||||||
|
Shader version: 500
|
||||||
|
local_size = (1, 1, 1)
|
||||||
|
0:? Sequence
|
||||||
|
0:13 Function Definition: @main(vu3; ( temp void)
|
||||||
|
0:13 Function Parameters:
|
||||||
|
0:13 'nThreadId' ( in 3-component vector of uint)
|
||||||
|
0:? Sequence
|
||||||
|
0:14 Sequence
|
||||||
|
0:14 move second child to first child ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 'data' ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 indirect index (layout( row_major std430) buffer structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 @data: direct index for structure (layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 'csb' (layout( binding=1 row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId} @data})
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 0 (const uint)
|
||||||
|
0:14 add ( temp uint)
|
||||||
|
0:14 AtomicAdd ( temp uint)
|
||||||
|
0:14 @count: direct index for structure ( temp int)
|
||||||
|
0:14 'csb@count' (layout( row_major std430) buffer block{layout( row_major std430) buffer int @count})
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 0 (const int)
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 -1 (const int)
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 -1 (const int)
|
||||||
|
0:15 Sequence
|
||||||
|
0:15 move second child to first child ( temp 2-component vector of float)
|
||||||
|
0:15 'coord' ( temp 2-component vector of float)
|
||||||
|
0:15 Convert uint to float ( temp 2-component vector of float)
|
||||||
|
0:15 vector swizzle ( temp 2-component vector of uint)
|
||||||
|
0:15 threadId: direct index for structure ( temp 2-component vector of uint)
|
||||||
|
0:15 'data' ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:15 Constant:
|
||||||
|
0:15 1 (const int)
|
||||||
|
0:15 Sequence
|
||||||
|
0:15 Constant:
|
||||||
|
0:15 0 (const int)
|
||||||
|
0:15 Constant:
|
||||||
|
0:15 1 (const int)
|
||||||
|
0:16 Sequence
|
||||||
|
0:16 move second child to first child ( temp 4-component vector of float)
|
||||||
|
0:16 'storeTemp' ( temp 4-component vector of float)
|
||||||
|
0:16 color: direct index for structure ( temp 4-component vector of float)
|
||||||
|
0:16 'data' ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:16 Constant:
|
||||||
|
0:16 0 (const int)
|
||||||
|
0:16 imageStore ( temp void)
|
||||||
|
0:16 'outtx' (layout( rgba32f) uniform image2D)
|
||||||
|
0:16 Convert float to uint ( temp 2-component vector of uint)
|
||||||
|
0:16 'coord' ( temp 2-component vector of float)
|
||||||
|
0:16 'storeTemp' ( temp 4-component vector of float)
|
||||||
|
0:16 'storeTemp' ( temp 4-component vector of float)
|
||||||
|
0:18 move second child to first child ( temp 4-component vector of float)
|
||||||
|
0:18 indirect index (layout( row_major std430) buffer 4-component vector of float)
|
||||||
|
0:18 @data: direct index for structure (layout( row_major std430) buffer implicitly-sized array of 4-component vector of float)
|
||||||
|
0:18 'rwsb' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of 4-component vector of float @data})
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 0 (const uint)
|
||||||
|
0:18 Convert float to uint ( temp uint)
|
||||||
|
0:18 direct index ( temp float)
|
||||||
|
0:18 'coord' ( temp 2-component vector of float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 0 (const int)
|
||||||
|
0:18 indirect index (layout( row_major std430) buffer 4-component vector of float)
|
||||||
|
0:18 @data: direct index for structure (layout( row_major std430) buffer implicitly-sized array of 4-component vector of float)
|
||||||
|
0:18 'rwsb' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of 4-component vector of float @data})
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 0 (const uint)
|
||||||
|
0:18 Convert float to uint ( temp uint)
|
||||||
|
0:18 direct index ( temp float)
|
||||||
|
0:18 'coord' ( temp 2-component vector of float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 1 (const int)
|
||||||
|
0:13 Function Definition: main( ( temp void)
|
||||||
|
0:13 Function Parameters:
|
||||||
|
0:? Sequence
|
||||||
|
0:13 move second child to first child ( temp 3-component vector of uint)
|
||||||
|
0:? 'nThreadId' ( temp 3-component vector of uint)
|
||||||
|
0:? 'nThreadId' ( in 3-component vector of uint GlobalInvocationID)
|
||||||
|
0:13 Function Call: @main(vu3; ( temp void)
|
||||||
|
0:? 'nThreadId' ( temp 3-component vector of uint)
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 'outtx' (layout( rgba32f) uniform image2D)
|
||||||
|
0:? 'csb' (layout( binding=1 row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId} @data})
|
||||||
|
0:? 'csb@count' (layout( row_major std430) buffer block{layout( row_major std430) buffer int @count})
|
||||||
|
0:? 'rwsb' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of 4-component vector of float @data})
|
||||||
|
0:? 'nThreadId' ( in 3-component vector of uint GlobalInvocationID)
|
||||||
|
|
||||||
|
|
||||||
|
Linked compute stage:
|
||||||
|
|
||||||
|
|
||||||
|
Shader version: 500
|
||||||
|
local_size = (1, 1, 1)
|
||||||
|
0:? Sequence
|
||||||
|
0:13 Function Definition: @main(vu3; ( temp void)
|
||||||
|
0:13 Function Parameters:
|
||||||
|
0:13 'nThreadId' ( in 3-component vector of uint)
|
||||||
|
0:? Sequence
|
||||||
|
0:14 Sequence
|
||||||
|
0:14 move second child to first child ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 'data' ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 indirect index (layout( row_major std430) buffer structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 @data: direct index for structure (layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:14 'csb' (layout( binding=1 row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId} @data})
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 0 (const uint)
|
||||||
|
0:14 add ( temp uint)
|
||||||
|
0:14 AtomicAdd ( temp uint)
|
||||||
|
0:14 @count: direct index for structure ( temp int)
|
||||||
|
0:14 'csb@count' (layout( row_major std430) buffer block{layout( row_major std430) buffer int @count})
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 0 (const int)
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 -1 (const int)
|
||||||
|
0:14 Constant:
|
||||||
|
0:14 -1 (const int)
|
||||||
|
0:15 Sequence
|
||||||
|
0:15 move second child to first child ( temp 2-component vector of float)
|
||||||
|
0:15 'coord' ( temp 2-component vector of float)
|
||||||
|
0:15 Convert uint to float ( temp 2-component vector of float)
|
||||||
|
0:15 vector swizzle ( temp 2-component vector of uint)
|
||||||
|
0:15 threadId: direct index for structure ( temp 2-component vector of uint)
|
||||||
|
0:15 'data' ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:15 Constant:
|
||||||
|
0:15 1 (const int)
|
||||||
|
0:15 Sequence
|
||||||
|
0:15 Constant:
|
||||||
|
0:15 0 (const int)
|
||||||
|
0:15 Constant:
|
||||||
|
0:15 1 (const int)
|
||||||
|
0:16 Sequence
|
||||||
|
0:16 move second child to first child ( temp 4-component vector of float)
|
||||||
|
0:16 'storeTemp' ( temp 4-component vector of float)
|
||||||
|
0:16 color: direct index for structure ( temp 4-component vector of float)
|
||||||
|
0:16 'data' ( temp structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId})
|
||||||
|
0:16 Constant:
|
||||||
|
0:16 0 (const int)
|
||||||
|
0:16 imageStore ( temp void)
|
||||||
|
0:16 'outtx' (layout( rgba32f) uniform image2D)
|
||||||
|
0:16 Convert float to uint ( temp 2-component vector of uint)
|
||||||
|
0:16 'coord' ( temp 2-component vector of float)
|
||||||
|
0:16 'storeTemp' ( temp 4-component vector of float)
|
||||||
|
0:16 'storeTemp' ( temp 4-component vector of float)
|
||||||
|
0:18 move second child to first child ( temp 4-component vector of float)
|
||||||
|
0:18 indirect index (layout( row_major std430) buffer 4-component vector of float)
|
||||||
|
0:18 @data: direct index for structure (layout( row_major std430) buffer implicitly-sized array of 4-component vector of float)
|
||||||
|
0:18 'rwsb' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of 4-component vector of float @data})
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 0 (const uint)
|
||||||
|
0:18 Convert float to uint ( temp uint)
|
||||||
|
0:18 direct index ( temp float)
|
||||||
|
0:18 'coord' ( temp 2-component vector of float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 0 (const int)
|
||||||
|
0:18 indirect index (layout( row_major std430) buffer 4-component vector of float)
|
||||||
|
0:18 @data: direct index for structure (layout( row_major std430) buffer implicitly-sized array of 4-component vector of float)
|
||||||
|
0:18 'rwsb' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of 4-component vector of float @data})
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 0 (const uint)
|
||||||
|
0:18 Convert float to uint ( temp uint)
|
||||||
|
0:18 direct index ( temp float)
|
||||||
|
0:18 'coord' ( temp 2-component vector of float)
|
||||||
|
0:18 Constant:
|
||||||
|
0:18 1 (const int)
|
||||||
|
0:13 Function Definition: main( ( temp void)
|
||||||
|
0:13 Function Parameters:
|
||||||
|
0:? Sequence
|
||||||
|
0:13 move second child to first child ( temp 3-component vector of uint)
|
||||||
|
0:? 'nThreadId' ( temp 3-component vector of uint)
|
||||||
|
0:? 'nThreadId' ( in 3-component vector of uint GlobalInvocationID)
|
||||||
|
0:13 Function Call: @main(vu3; ( temp void)
|
||||||
|
0:? 'nThreadId' ( temp 3-component vector of uint)
|
||||||
|
0:? Linker Objects
|
||||||
|
0:? 'outtx' (layout( rgba32f) uniform image2D)
|
||||||
|
0:? 'csb' (layout( binding=1 row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of structure{ temp 4-component vector of float color, temp 2-component vector of uint threadId} @data})
|
||||||
|
0:? 'csb@count' (layout( row_major std430) buffer block{layout( row_major std430) buffer int @count})
|
||||||
|
0:? 'rwsb' (layout( row_major std430) buffer block{layout( row_major std430) buffer implicitly-sized array of 4-component vector of float @data})
|
||||||
|
0:? 'nThreadId' ( in 3-component vector of uint GlobalInvocationID)
|
||||||
|
|
||||||
|
// Module Version 10000
|
||||||
|
// Generated by (magic number): 80001
|
||||||
|
// Id's are bound by 84
|
||||||
|
|
||||||
|
Capability Shader
|
||||||
|
1: ExtInstImport "GLSL.std.450"
|
||||||
|
MemoryModel Logical GLSL450
|
||||||
|
EntryPoint GLCompute 4 "main" 79
|
||||||
|
ExecutionMode 4 LocalSize 1 1 1
|
||||||
|
Source HLSL 500
|
||||||
|
Name 4 "main"
|
||||||
|
Name 11 "@main(vu3;"
|
||||||
|
Name 10 "nThreadId"
|
||||||
|
Name 16 "sb_t"
|
||||||
|
MemberName 16(sb_t) 0 "color"
|
||||||
|
MemberName 16(sb_t) 1 "threadId"
|
||||||
|
Name 18 "data"
|
||||||
|
Name 19 "sb_t"
|
||||||
|
MemberName 19(sb_t) 0 "color"
|
||||||
|
MemberName 19(sb_t) 1 "threadId"
|
||||||
|
Name 21 "csb"
|
||||||
|
MemberName 21(csb) 0 "@data"
|
||||||
|
Name 23 "csb"
|
||||||
|
Name 26 "csb@count"
|
||||||
|
MemberName 26(csb@count) 0 "@count"
|
||||||
|
Name 28 "csb@count"
|
||||||
|
Name 48 "coord"
|
||||||
|
Name 52 "storeTemp"
|
||||||
|
Name 57 "outtx"
|
||||||
|
Name 63 "rwsb"
|
||||||
|
MemberName 63(rwsb) 0 "@data"
|
||||||
|
Name 65 "rwsb"
|
||||||
|
Name 77 "nThreadId"
|
||||||
|
Name 79 "nThreadId"
|
||||||
|
Name 81 "param"
|
||||||
|
MemberDecorate 19(sb_t) 0 Offset 0
|
||||||
|
MemberDecorate 19(sb_t) 1 Offset 16
|
||||||
|
Decorate 20 ArrayStride 32
|
||||||
|
MemberDecorate 21(csb) 0 Offset 0
|
||||||
|
Decorate 21(csb) BufferBlock
|
||||||
|
Decorate 23(csb) DescriptorSet 0
|
||||||
|
Decorate 23(csb) Binding 1
|
||||||
|
MemberDecorate 26(csb@count) 0 Offset 0
|
||||||
|
Decorate 26(csb@count) BufferBlock
|
||||||
|
Decorate 28(csb@count) DescriptorSet 0
|
||||||
|
Decorate 57(outtx) DescriptorSet 0
|
||||||
|
Decorate 62 ArrayStride 16
|
||||||
|
MemberDecorate 63(rwsb) 0 Offset 0
|
||||||
|
Decorate 63(rwsb) BufferBlock
|
||||||
|
Decorate 65(rwsb) DescriptorSet 0
|
||||||
|
Decorate 79(nThreadId) BuiltIn GlobalInvocationId
|
||||||
|
2: TypeVoid
|
||||||
|
3: TypeFunction 2
|
||||||
|
6: TypeInt 32 0
|
||||||
|
7: TypeVector 6(int) 3
|
||||||
|
8: TypePointer Function 7(ivec3)
|
||||||
|
9: TypeFunction 2 8(ptr)
|
||||||
|
13: TypeFloat 32
|
||||||
|
14: TypeVector 13(float) 4
|
||||||
|
15: TypeVector 6(int) 2
|
||||||
|
16(sb_t): TypeStruct 14(fvec4) 15(ivec2)
|
||||||
|
17: TypePointer Function 16(sb_t)
|
||||||
|
19(sb_t): TypeStruct 14(fvec4) 15(ivec2)
|
||||||
|
20: TypeRuntimeArray 19(sb_t)
|
||||||
|
21(csb): TypeStruct 20
|
||||||
|
22: TypePointer Uniform 21(csb)
|
||||||
|
23(csb): 22(ptr) Variable Uniform
|
||||||
|
24: TypeInt 32 1
|
||||||
|
25: 24(int) Constant 0
|
||||||
|
26(csb@count): TypeStruct 24(int)
|
||||||
|
27: TypePointer Uniform 26(csb@count)
|
||||||
|
28(csb@count): 27(ptr) Variable Uniform
|
||||||
|
29: TypePointer Uniform 24(int)
|
||||||
|
31: 24(int) Constant 4294967295
|
||||||
|
32: 6(int) Constant 1
|
||||||
|
33: 6(int) Constant 0
|
||||||
|
36: TypePointer Uniform 19(sb_t)
|
||||||
|
40: TypePointer Function 14(fvec4)
|
||||||
|
43: 24(int) Constant 1
|
||||||
|
44: TypePointer Function 15(ivec2)
|
||||||
|
46: TypeVector 13(float) 2
|
||||||
|
47: TypePointer Function 46(fvec2)
|
||||||
|
55: TypeImage 13(float) 2D nonsampled format:Rgba32f
|
||||||
|
56: TypePointer UniformConstant 55
|
||||||
|
57(outtx): 56(ptr) Variable UniformConstant
|
||||||
|
62: TypeRuntimeArray 14(fvec4)
|
||||||
|
63(rwsb): TypeStruct 62
|
||||||
|
64: TypePointer Uniform 63(rwsb)
|
||||||
|
65(rwsb): 64(ptr) Variable Uniform
|
||||||
|
66: TypePointer Function 13(float)
|
||||||
|
73: TypePointer Uniform 14(fvec4)
|
||||||
|
78: TypePointer Input 7(ivec3)
|
||||||
|
79(nThreadId): 78(ptr) Variable Input
|
||||||
|
4(main): 2 Function None 3
|
||||||
|
5: Label
|
||||||
|
77(nThreadId): 8(ptr) Variable Function
|
||||||
|
81(param): 8(ptr) Variable Function
|
||||||
|
80: 7(ivec3) Load 79(nThreadId)
|
||||||
|
Store 77(nThreadId) 80
|
||||||
|
82: 7(ivec3) Load 77(nThreadId)
|
||||||
|
Store 81(param) 82
|
||||||
|
83: 2 FunctionCall 11(@main(vu3;) 81(param)
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
||||||
|
11(@main(vu3;): 2 Function None 9
|
||||||
|
10(nThreadId): 8(ptr) FunctionParameter
|
||||||
|
12: Label
|
||||||
|
18(data): 17(ptr) Variable Function
|
||||||
|
48(coord): 47(ptr) Variable Function
|
||||||
|
52(storeTemp): 40(ptr) Variable Function
|
||||||
|
30: 29(ptr) AccessChain 28(csb@count) 25
|
||||||
|
34: 6(int) AtomicIAdd 30 32 33 31
|
||||||
|
35: 6(int) IAdd 34 31
|
||||||
|
37: 36(ptr) AccessChain 23(csb) 25 35
|
||||||
|
38: 19(sb_t) Load 37
|
||||||
|
39: 14(fvec4) CompositeExtract 38 0
|
||||||
|
41: 40(ptr) AccessChain 18(data) 25
|
||||||
|
Store 41 39
|
||||||
|
42: 15(ivec2) CompositeExtract 38 1
|
||||||
|
45: 44(ptr) AccessChain 18(data) 43
|
||||||
|
Store 45 42
|
||||||
|
49: 44(ptr) AccessChain 18(data) 43
|
||||||
|
50: 15(ivec2) Load 49
|
||||||
|
51: 46(fvec2) ConvertUToF 50
|
||||||
|
Store 48(coord) 51
|
||||||
|
53: 40(ptr) AccessChain 18(data) 25
|
||||||
|
54: 14(fvec4) Load 53
|
||||||
|
Store 52(storeTemp) 54
|
||||||
|
58: 55 Load 57(outtx)
|
||||||
|
59: 46(fvec2) Load 48(coord)
|
||||||
|
60: 15(ivec2) ConvertFToU 59
|
||||||
|
61: 14(fvec4) Load 52(storeTemp)
|
||||||
|
ImageWrite 58 60 61
|
||||||
|
67: 66(ptr) AccessChain 48(coord) 33
|
||||||
|
68: 13(float) Load 67
|
||||||
|
69: 6(int) ConvertFToU 68
|
||||||
|
70: 66(ptr) AccessChain 48(coord) 32
|
||||||
|
71: 13(float) Load 70
|
||||||
|
72: 6(int) ConvertFToU 71
|
||||||
|
74: 73(ptr) AccessChain 65(rwsb) 25 72
|
||||||
|
75: 14(fvec4) Load 74
|
||||||
|
76: 73(ptr) AccessChain 65(rwsb) 25 69
|
||||||
|
Store 76 75
|
||||||
|
Return
|
||||||
|
FunctionEnd
|
@ -1,12 +1,12 @@
|
|||||||
spv.ssbo.autoassign.frag
|
spv.ssbo.autoassign.frag
|
||||||
// Module Version 10000
|
// Module Version 10000
|
||||||
// Generated by (magic number): 80001
|
// Generated by (magic number): 80001
|
||||||
// Id's are bound by 95
|
// Id's are bound by 99
|
||||||
|
|
||||||
Capability Shader
|
Capability Shader
|
||||||
1: ExtInstImport "GLSL.std.450"
|
1: ExtInstImport "GLSL.std.450"
|
||||||
MemoryModel Logical GLSL450
|
MemoryModel Logical GLSL450
|
||||||
EntryPoint Fragment 4 "main" 88 91
|
EntryPoint Fragment 4 "main" 92 95
|
||||||
ExecutionMode 4 OriginUpperLeft
|
ExecutionMode 4 OriginUpperLeft
|
||||||
Source HLSL 500
|
Source HLSL 500
|
||||||
Name 4 "main"
|
Name 4 "main"
|
||||||
@ -23,13 +23,13 @@ spv.ssbo.autoassign.frag
|
|||||||
MemberName 26(TestCB) 0 "W"
|
MemberName 26(TestCB) 0 "W"
|
||||||
MemberName 26(TestCB) 1 "H"
|
MemberName 26(TestCB) 1 "H"
|
||||||
Name 28 ""
|
Name 28 ""
|
||||||
Name 55 "SB1"
|
|
||||||
MemberName 55(SB1) 0 "@data"
|
|
||||||
Name 57 "SB1"
|
Name 57 "SB1"
|
||||||
Name 86 "pos"
|
MemberName 57(SB1) 0 "@data"
|
||||||
Name 88 "pos"
|
Name 59 "SB1"
|
||||||
Name 91 "@entryPointOutput"
|
Name 90 "pos"
|
||||||
Name 92 "param"
|
Name 92 "pos"
|
||||||
|
Name 95 "@entryPointOutput"
|
||||||
|
Name 96 "param"
|
||||||
MemberDecorate 14(BufType) 0 NonWritable
|
MemberDecorate 14(BufType) 0 NonWritable
|
||||||
MemberDecorate 14(BufType) 0 Offset 0
|
MemberDecorate 14(BufType) 0 Offset 0
|
||||||
MemberDecorate 14(BufType) 1 NonWritable
|
MemberDecorate 14(BufType) 1 NonWritable
|
||||||
@ -45,13 +45,13 @@ spv.ssbo.autoassign.frag
|
|||||||
Decorate 26(TestCB) Block
|
Decorate 26(TestCB) Block
|
||||||
Decorate 28 DescriptorSet 0
|
Decorate 28 DescriptorSet 0
|
||||||
Decorate 28 Binding 15
|
Decorate 28 Binding 15
|
||||||
Decorate 54 ArrayStride 32
|
Decorate 56 ArrayStride 32
|
||||||
MemberDecorate 55(SB1) 0 Offset 0
|
MemberDecorate 57(SB1) 0 Offset 0
|
||||||
Decorate 55(SB1) BufferBlock
|
Decorate 57(SB1) BufferBlock
|
||||||
Decorate 57(SB1) DescriptorSet 0
|
Decorate 59(SB1) DescriptorSet 0
|
||||||
Decorate 57(SB1) Binding 31
|
Decorate 59(SB1) Binding 31
|
||||||
Decorate 88(pos) Location 0
|
Decorate 92(pos) Location 0
|
||||||
Decorate 91(@entryPointOutput) Location 0
|
Decorate 95(@entryPointOutput) Location 0
|
||||||
2: TypeVoid
|
2: TypeVoid
|
||||||
3: TypeFunction 2
|
3: TypeFunction 2
|
||||||
6: TypeFloat 32
|
6: TypeFloat 32
|
||||||
@ -73,26 +73,26 @@ spv.ssbo.autoassign.frag
|
|||||||
28: 27(ptr) Variable Uniform
|
28: 27(ptr) Variable Uniform
|
||||||
29: TypePointer Uniform 21(int)
|
29: TypePointer Uniform 21(int)
|
||||||
34: 21(int) Constant 0
|
34: 21(int) Constant 0
|
||||||
38: TypePointer Uniform 7(fvec4)
|
39: TypePointer Uniform 7(fvec4)
|
||||||
50: 19(int) Constant 1
|
52: 19(int) Constant 1
|
||||||
54: TypeRuntimeArray 14(BufType)
|
56: TypeRuntimeArray 14(BufType)
|
||||||
55(SB1): TypeStruct 54
|
57(SB1): TypeStruct 56
|
||||||
56: TypePointer Uniform 55(SB1)
|
58: TypePointer Uniform 57(SB1)
|
||||||
57(SB1): 56(ptr) Variable Uniform
|
59(SB1): 58(ptr) Variable Uniform
|
||||||
87: TypePointer Input 7(fvec4)
|
91: TypePointer Input 7(fvec4)
|
||||||
88(pos): 87(ptr) Variable Input
|
92(pos): 91(ptr) Variable Input
|
||||||
90: TypePointer Output 7(fvec4)
|
94: TypePointer Output 7(fvec4)
|
||||||
91(@entryPointOutput): 90(ptr) Variable Output
|
95(@entryPointOutput): 94(ptr) Variable Output
|
||||||
4(main): 2 Function None 3
|
4(main): 2 Function None 3
|
||||||
5: Label
|
5: Label
|
||||||
86(pos): 8(ptr) Variable Function
|
90(pos): 8(ptr) Variable Function
|
||||||
92(param): 8(ptr) Variable Function
|
96(param): 8(ptr) Variable Function
|
||||||
89: 7(fvec4) Load 88(pos)
|
93: 7(fvec4) Load 92(pos)
|
||||||
Store 86(pos) 89
|
Store 90(pos) 93
|
||||||
93: 7(fvec4) Load 86(pos)
|
97: 7(fvec4) Load 90(pos)
|
||||||
Store 92(param) 93
|
Store 96(param) 97
|
||||||
94: 7(fvec4) FunctionCall 11(@main(vf4;) 92(param)
|
98: 7(fvec4) FunctionCall 11(@main(vf4;) 96(param)
|
||||||
Store 91(@entryPointOutput) 94
|
Store 95(@entryPointOutput) 98
|
||||||
Return
|
Return
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
11(@main(vf4;): 7(fvec4) Function None 9
|
11(@main(vf4;): 7(fvec4) Function None 9
|
||||||
@ -108,47 +108,51 @@ spv.ssbo.autoassign.frag
|
|||||||
35: 23(ptr) AccessChain 10(pos) 34
|
35: 23(ptr) AccessChain 10(pos) 34
|
||||||
36: 6(float) Load 35
|
36: 6(float) Load 35
|
||||||
37: 6(float) FAdd 33 36
|
37: 6(float) FAdd 33 36
|
||||||
39: 38(ptr) AccessChain 18(SB0) 20 37 20
|
38: 21(int) ConvertFToU 37
|
||||||
40: 7(fvec4) Load 39
|
40: 39(ptr) AccessChain 18(SB0) 20 38 20
|
||||||
41: 23(ptr) AccessChain 10(pos) 22
|
41: 7(fvec4) Load 40
|
||||||
42: 6(float) Load 41
|
42: 23(ptr) AccessChain 10(pos) 22
|
||||||
43: 29(ptr) AccessChain 28 20
|
43: 6(float) Load 42
|
||||||
44: 21(int) Load 43
|
44: 29(ptr) AccessChain 28 20
|
||||||
45: 6(float) ConvertUToF 44
|
45: 21(int) Load 44
|
||||||
46: 6(float) FMul 42 45
|
46: 6(float) ConvertUToF 45
|
||||||
47: 23(ptr) AccessChain 10(pos) 34
|
47: 6(float) FMul 43 46
|
||||||
48: 6(float) Load 47
|
48: 23(ptr) AccessChain 10(pos) 34
|
||||||
49: 6(float) FAdd 46 48
|
49: 6(float) Load 48
|
||||||
51: 38(ptr) AccessChain 18(SB0) 20 49 50
|
50: 6(float) FAdd 47 49
|
||||||
52: 7(fvec4) Load 51
|
51: 21(int) ConvertFToU 50
|
||||||
53: 7(fvec4) FAdd 40 52
|
53: 39(ptr) AccessChain 18(SB0) 20 51 52
|
||||||
Store 13(vTmp) 53
|
54: 7(fvec4) Load 53
|
||||||
58: 23(ptr) AccessChain 10(pos) 22
|
55: 7(fvec4) FAdd 41 54
|
||||||
59: 6(float) Load 58
|
Store 13(vTmp) 55
|
||||||
60: 29(ptr) AccessChain 28 20
|
60: 23(ptr) AccessChain 10(pos) 22
|
||||||
61: 21(int) Load 60
|
61: 6(float) Load 60
|
||||||
62: 6(float) ConvertUToF 61
|
62: 29(ptr) AccessChain 28 20
|
||||||
63: 6(float) FMul 59 62
|
63: 21(int) Load 62
|
||||||
64: 23(ptr) AccessChain 10(pos) 34
|
64: 6(float) ConvertUToF 63
|
||||||
65: 6(float) Load 64
|
65: 6(float) FMul 61 64
|
||||||
66: 6(float) FAdd 63 65
|
66: 23(ptr) AccessChain 10(pos) 34
|
||||||
67: 38(ptr) AccessChain 57(SB1) 20 66 20
|
67: 6(float) Load 66
|
||||||
68: 7(fvec4) Load 67
|
68: 6(float) FAdd 65 67
|
||||||
69: 23(ptr) AccessChain 10(pos) 22
|
69: 21(int) ConvertFToU 68
|
||||||
70: 6(float) Load 69
|
70: 39(ptr) AccessChain 59(SB1) 20 69 20
|
||||||
71: 29(ptr) AccessChain 28 20
|
71: 7(fvec4) Load 70
|
||||||
72: 21(int) Load 71
|
72: 23(ptr) AccessChain 10(pos) 22
|
||||||
73: 6(float) ConvertUToF 72
|
73: 6(float) Load 72
|
||||||
74: 6(float) FMul 70 73
|
74: 29(ptr) AccessChain 28 20
|
||||||
75: 23(ptr) AccessChain 10(pos) 34
|
75: 21(int) Load 74
|
||||||
76: 6(float) Load 75
|
76: 6(float) ConvertUToF 75
|
||||||
77: 6(float) FAdd 74 76
|
77: 6(float) FMul 73 76
|
||||||
78: 38(ptr) AccessChain 57(SB1) 20 77 50
|
78: 23(ptr) AccessChain 10(pos) 34
|
||||||
79: 7(fvec4) Load 78
|
79: 6(float) Load 78
|
||||||
80: 7(fvec4) FAdd 68 79
|
80: 6(float) FAdd 77 79
|
||||||
81: 7(fvec4) Load 13(vTmp)
|
81: 21(int) ConvertFToU 80
|
||||||
82: 7(fvec4) FAdd 81 80
|
82: 39(ptr) AccessChain 59(SB1) 20 81 52
|
||||||
Store 13(vTmp) 82
|
83: 7(fvec4) Load 82
|
||||||
83: 7(fvec4) Load 13(vTmp)
|
84: 7(fvec4) FAdd 71 83
|
||||||
ReturnValue 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
|
FunctionEnd
|
||||||
|
19
Test/hlsl.structbuffer.floatidx.comp
Normal file
19
Test/hlsl.structbuffer.floatidx.comp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
struct sb_t
|
||||||
|
{
|
||||||
|
float4 color;
|
||||||
|
uint2 threadId;
|
||||||
|
};
|
||||||
|
|
||||||
|
RWTexture2D<float4> outtx;
|
||||||
|
ConsumeStructuredBuffer<sb_t> csb : register(u1);
|
||||||
|
RWStructuredBuffer<float4> rwsb;
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void main(uint3 nThreadId : SV_DispatchThreadID)
|
||||||
|
{
|
||||||
|
sb_t data = csb.Consume();
|
||||||
|
float2 coord = float2(data.threadId.xy);
|
||||||
|
outtx[coord] = data.color;
|
||||||
|
|
||||||
|
rwsb[coord.x] = rwsb.Load(coord.y);
|
||||||
|
}
|
@ -249,6 +249,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
{"hlsl.structbuffer.atomics.frag", "main"},
|
{"hlsl.structbuffer.atomics.frag", "main"},
|
||||||
{"hlsl.structbuffer.byte.frag", "main"},
|
{"hlsl.structbuffer.byte.frag", "main"},
|
||||||
{"hlsl.structbuffer.coherent.frag", "main"},
|
{"hlsl.structbuffer.coherent.frag", "main"},
|
||||||
|
{"hlsl.structbuffer.floatidx.comp", "main"},
|
||||||
{"hlsl.structbuffer.incdec.frag", "main"},
|
{"hlsl.structbuffer.incdec.frag", "main"},
|
||||||
{"hlsl.structbuffer.fn.frag", "main"},
|
{"hlsl.structbuffer.fn.frag", "main"},
|
||||||
{"hlsl.structbuffer.rw.frag", "main"},
|
{"hlsl.structbuffer.rw.frag", "main"},
|
||||||
|
@ -712,28 +712,39 @@ TIntermTyped* HlslParseContext::handleBracketOperator(const TSourceLoc& loc, TIn
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cast index value to a uint if it isn't already (for operator[], load indexes, etc)
|
||||||
|
TIntermTyped* HlslParseContext::makeIntegerIndex(TIntermTyped* index)
|
||||||
|
{
|
||||||
|
const TBasicType indexBasicType = index->getType().getBasicType();
|
||||||
|
const int vecSize = index->getType().getVectorSize();
|
||||||
|
|
||||||
|
// We can use int types directly as the index
|
||||||
|
if (indexBasicType == EbtInt || indexBasicType == EbtUint ||
|
||||||
|
indexBasicType == EbtInt64 || indexBasicType == EbtUint64)
|
||||||
|
return index;
|
||||||
|
|
||||||
|
// Cast index to unsigned integer if it isn't one.
|
||||||
|
return intermediate.addConversion(EOpConstructUint, TType(EbtUint, EvqTemporary, vecSize), index);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle seeing a base[index] dereference in the grammar.
|
// Handle seeing a base[index] dereference in the grammar.
|
||||||
//
|
//
|
||||||
TIntermTyped* HlslParseContext::handleBracketDereference(const TSourceLoc& loc, TIntermTyped* base, TIntermTyped* index)
|
TIntermTyped* HlslParseContext::handleBracketDereference(const TSourceLoc& loc, TIntermTyped* base, TIntermTyped* index)
|
||||||
{
|
{
|
||||||
TIntermTyped* result = handleBracketOperator(loc, base, index);
|
index = makeIntegerIndex(index);
|
||||||
|
|
||||||
if (result != nullptr)
|
|
||||||
return result; // it was handled as an operator[]
|
|
||||||
|
|
||||||
const TBasicType indexBasicType = index->getType().getBasicType();
|
|
||||||
|
|
||||||
// Cast index to unsigned integer if it isn't one.
|
|
||||||
if (indexBasicType != EbtInt && indexBasicType != EbtUint &&
|
|
||||||
indexBasicType != EbtInt64 && indexBasicType != EbtUint64)
|
|
||||||
index = intermediate.addConversion(EOpConstructUint, TType(EbtUint), index);
|
|
||||||
|
|
||||||
if (index == nullptr) {
|
if (index == nullptr) {
|
||||||
error(loc, " unknown undex type ", "", "");
|
error(loc, " unknown undex type ", "", "");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TIntermTyped* result = handleBracketOperator(loc, base, index);
|
||||||
|
|
||||||
|
if (result != nullptr)
|
||||||
|
return result; // it was handled as an operator[]
|
||||||
|
|
||||||
bool flattened = false;
|
bool flattened = false;
|
||||||
int indexValue = 0;
|
int indexValue = 0;
|
||||||
if (index->getQualifier().storage == EvqConst) {
|
if (index->getQualifier().storage == EvqConst) {
|
||||||
@ -2570,7 +2581,7 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte
|
|||||||
switch (op) {
|
switch (op) {
|
||||||
case EOpMethodLoad:
|
case EOpMethodLoad:
|
||||||
{
|
{
|
||||||
TIntermTyped* argIndex = argAggregate->getSequence()[1]->getAsTyped(); // index
|
TIntermTyped* argIndex = makeIntegerIndex(argAggregate->getSequence()[1]->getAsTyped()); // index
|
||||||
|
|
||||||
// Byte address buffers index in bytes (only multiples of 4 permitted... not so much a byte address
|
// Byte address buffers index in bytes (only multiples of 4 permitted... not so much a byte address
|
||||||
// buffer then, but that's what it calls itself.
|
// buffer then, but that's what it calls itself.
|
||||||
@ -2596,7 +2607,7 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte
|
|||||||
case EOpMethodLoad3:
|
case EOpMethodLoad3:
|
||||||
case EOpMethodLoad4:
|
case EOpMethodLoad4:
|
||||||
{
|
{
|
||||||
TIntermTyped* argIndex = argAggregate->getSequence()[1]->getAsTyped(); // index
|
TIntermTyped* argIndex = makeIntegerIndex(argAggregate->getSequence()[1]->getAsTyped()); // index
|
||||||
|
|
||||||
TOperator constructOp = EOpNull;
|
TOperator constructOp = EOpNull;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
@ -2654,7 +2665,7 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte
|
|||||||
case EOpMethodStore3:
|
case EOpMethodStore3:
|
||||||
case EOpMethodStore4:
|
case EOpMethodStore4:
|
||||||
{
|
{
|
||||||
TIntermTyped* argIndex = argAggregate->getSequence()[1]->getAsTyped(); // address
|
TIntermTyped* argIndex = makeIntegerIndex(argAggregate->getSequence()[1]->getAsTyped()); // index
|
||||||
TIntermTyped* argValue = argAggregate->getSequence()[2]->getAsTyped(); // value
|
TIntermTyped* argValue = argAggregate->getSequence()[2]->getAsTyped(); // value
|
||||||
|
|
||||||
// Index into the array to find the item being loaded.
|
// Index into the array to find the item being loaded.
|
||||||
@ -2761,7 +2772,7 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte
|
|||||||
|
|
||||||
TIntermSequence& sequence = argAggregate->getSequence();
|
TIntermSequence& sequence = argAggregate->getSequence();
|
||||||
|
|
||||||
TIntermTyped* argIndex = sequence[1]->getAsTyped(); // index
|
TIntermTyped* argIndex = makeIntegerIndex(sequence[1]->getAsTyped()); // index
|
||||||
argIndex = intermediate.addBinaryNode(EOpRightShift, argIndex, intermediate.addConstantUnion(2, loc, true),
|
argIndex = intermediate.addBinaryNode(EOpRightShift, argIndex, intermediate.addConstantUnion(2, loc, true),
|
||||||
loc, TType(EbtInt));
|
loc, TType(EbtInt));
|
||||||
|
|
||||||
|
@ -250,6 +250,7 @@ protected:
|
|||||||
TVariable* getSplitIoVar(int id) const;
|
TVariable* getSplitIoVar(int id) const;
|
||||||
void addInterstageIoToLinkage();
|
void addInterstageIoToLinkage();
|
||||||
void addPatchConstantInvocation();
|
void addPatchConstantInvocation();
|
||||||
|
TIntermTyped* makeIntegerIndex(TIntermTyped*);
|
||||||
|
|
||||||
void fixBuiltInIoType(TType&);
|
void fixBuiltInIoType(TType&);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user