HLSL: Fix #1163: treat buffers as references when calling functions.

This continues to prevent writing output buffers (out from a function),
but fixes the problem where the copy-in/out was not getting done.

Making everything work will require knowing both in/out-ness and bufferness,
but these are currently mutually exclusive, because both are storage
qualifiers.
This commit is contained in:
John Kessenich
2017-12-04 02:48:10 -07:00
parent 1f89992423
commit 6a14f78061
4 changed files with 182 additions and 196 deletions

View File

@@ -151,12 +151,12 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 76
// Id's are bound by 70
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 64 67
EntryPoint Fragment 4 "main" 58 61
ExecutionMode 4 OriginUpperLeft
Source HLSL 500
Name 4 "main"
@@ -171,55 +171,51 @@ gl_FragCoord origin is upper left
Name 18 "arg_c@count"
Name 25 "@main(u1;"
Name 24 "pos"
Name 50 "sbuf_a"
Name 52 "sbuf_a@count"
Name 53 "sbuf_c"
Name 54 "sbuf_c@count"
Name 55 "param"
Name 56 "param"
Name 57 "param"
Name 58 "param"
Name 62 "pos"
Name 64 "pos"
Name 67 "@entryPointOutput"
Name 68 "param"
Name 71 "sbuf_a@count"
MemberName 71(sbuf_a@count) 0 "@count"
Name 73 "sbuf_a@count"
Name 74 "sbuf_c@count"
Name 75 "sbuf_unused"
Name 49 "sbuf_a"
Name 50 "sbuf_a@count"
Name 51 "sbuf_c"
Name 52 "sbuf_c@count"
Name 56 "pos"
Name 58 "pos"
Name 61 "@entryPointOutput"
Name 62 "param"
Name 65 "sbuf_a@count"
MemberName 65(sbuf_a@count) 0 "@count"
Name 67 "sbuf_a@count"
Name 68 "sbuf_c@count"
Name 69 "sbuf_unused"
Decorate 8 ArrayStride 16
MemberDecorate 9 0 Offset 0
Decorate 9 BufferBlock
Decorate 12 BufferBlock
Decorate 50(sbuf_a) DescriptorSet 0
Decorate 52(sbuf_a@count) DescriptorSet 0
Decorate 53(sbuf_c) DescriptorSet 0
Decorate 54(sbuf_c@count) DescriptorSet 0
Decorate 64(pos) Flat
Decorate 64(pos) Location 0
Decorate 67(@entryPointOutput) Location 0
MemberDecorate 71(sbuf_a@count) 0 Offset 0
Decorate 71(sbuf_a@count) BufferBlock
Decorate 73(sbuf_a@count) DescriptorSet 0
Decorate 74(sbuf_c@count) DescriptorSet 0
Decorate 75(sbuf_unused) DescriptorSet 0
Decorate 49(sbuf_a) DescriptorSet 0
Decorate 50(sbuf_a@count) DescriptorSet 0
Decorate 51(sbuf_c) DescriptorSet 0
Decorate 52(sbuf_c@count) DescriptorSet 0
Decorate 58(pos) Flat
Decorate 58(pos) Location 0
Decorate 61(@entryPointOutput) Location 0
MemberDecorate 65(sbuf_a@count) 0 Offset 0
Decorate 65(sbuf_a@count) BufferBlock
Decorate 67(sbuf_a@count) DescriptorSet 0
Decorate 68(sbuf_c@count) DescriptorSet 0
Decorate 69(sbuf_unused) DescriptorSet 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypeRuntimeArray 7(fvec4)
9: TypeStruct 8
10: TypePointer Function 9(struct)
10: TypePointer Uniform 9(struct)
11: TypeInt 32 1
12: TypeStruct 11(int)
13: TypePointer Function 12(struct)
13: TypePointer Uniform 12(struct)
14: TypeFunction 7(fvec4) 10(ptr) 13(ptr) 10(ptr) 13(ptr)
21: TypeInt 32 0
22: TypePointer Function 21(int)
23: TypeFunction 7(fvec4) 22(ptr)
27: 11(int) Constant 0
28: TypePointer Function 11(int)
28: TypePointer Uniform 11(int)
30: 11(int) Constant 1
31: 21(int) Constant 1
32: 21(int) Constant 0
@@ -228,33 +224,31 @@ gl_FragCoord origin is upper left
36: 6(float) Constant 1077936128
37: 6(float) Constant 1082130432
38: 7(fvec4) ConstantComposite 34 35 36 37
39: TypePointer Function 7(fvec4)
39: TypePointer Uniform 7(fvec4)
42: 11(int) Constant 4294967295
49: TypePointer Uniform 9(struct)
50(sbuf_a): 49(ptr) Variable Uniform
51: TypePointer Uniform 12(struct)
52(sbuf_a@count): 51(ptr) Variable Uniform
53(sbuf_c): 49(ptr) Variable Uniform
54(sbuf_c@count): 51(ptr) Variable Uniform
63: TypePointer Input 21(int)
64(pos): 63(ptr) Variable Input
66: TypePointer Output 7(fvec4)
67(@entryPointOutput): 66(ptr) Variable Output
71(sbuf_a@count): TypeStruct 11(int)
72: TypePointer Uniform 71(sbuf_a@count)
73(sbuf_a@count): 72(ptr) Variable Uniform
74(sbuf_c@count): 72(ptr) Variable Uniform
75(sbuf_unused): 49(ptr) Variable Uniform
49(sbuf_a): 10(ptr) Variable Uniform
50(sbuf_a@count): 13(ptr) Variable Uniform
51(sbuf_c): 10(ptr) Variable Uniform
52(sbuf_c@count): 13(ptr) Variable Uniform
57: TypePointer Input 21(int)
58(pos): 57(ptr) Variable Input
60: TypePointer Output 7(fvec4)
61(@entryPointOutput): 60(ptr) Variable Output
65(sbuf_a@count): TypeStruct 11(int)
66: TypePointer Uniform 65(sbuf_a@count)
67(sbuf_a@count): 66(ptr) Variable Uniform
68(sbuf_c@count): 66(ptr) Variable Uniform
69(sbuf_unused): 10(ptr) Variable Uniform
4(main): 2 Function None 3
5: Label
62(pos): 22(ptr) Variable Function
68(param): 22(ptr) Variable Function
65: 21(int) Load 64(pos)
Store 62(pos) 65
69: 21(int) Load 62(pos)
Store 68(param) 69
70: 7(fvec4) FunctionCall 25(@main(u1;) 68(param)
Store 67(@entryPointOutput) 70
56(pos): 22(ptr) Variable Function
62(param): 22(ptr) Variable Function
59: 21(int) Load 58(pos)
Store 56(pos) 59
63: 21(int) Load 56(pos)
Store 62(param) 63
64: 7(fvec4) FunctionCall 25(@main(u1;) 62(param)
Store 61(@entryPointOutput) 64
Return
FunctionEnd
19(Fn2(block--vf4[0]1;block--vf4[0]1;): 7(fvec4) Function None 14
@@ -277,10 +271,6 @@ gl_FragCoord origin is upper left
25(@main(u1;): 7(fvec4) Function None 23
24(pos): 22(ptr) FunctionParameter
26: Label
55(param): 10(ptr) Variable Function
56(param): 13(ptr) Variable Function
57(param): 10(ptr) Variable Function
58(param): 13(ptr) Variable Function
59: 7(fvec4) FunctionCall 19(Fn2(block--vf4[0]1;block--vf4[0]1;) 55(param) 56(param) 57(param) 58(param)
ReturnValue 59
53: 7(fvec4) FunctionCall 19(Fn2(block--vf4[0]1;block--vf4[0]1;) 49(sbuf_a) 50(sbuf_a@count) 51(sbuf_c) 52(sbuf_c@count)
ReturnValue 53
FunctionEnd