Created
October 31, 2015 16:45
-
-
Save Themaister/e4b6219406ca1f1b8bff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original source | |
#version 310 es | |
layout(local_size_x = 1) in; | |
layout(std430, binding = 0) writeonly buffer SSBO | |
{ | |
vec4 data[]; | |
} outdata; | |
layout(std430, binding = 1) readonly buffer SSBO2 | |
{ | |
vec4 data[]; | |
} indata; | |
struct Foo | |
{ | |
vec4 a; | |
vec4 b; | |
vec4 c; | |
vec4 d; | |
}; | |
layout(std430, binding = 2) readonly buffer SSBO3 | |
{ | |
Foo foos[]; | |
} foobar; | |
vec4 bar(Foo foo) | |
{ | |
return foo.a + foo.b + foo.c + foo.d; | |
} | |
void baz(out Foo foo) | |
{ | |
uint ident = gl_GlobalInvocationID.x; | |
foo.a = indata.data[4u * ident + 0u]; | |
foo.b = indata.data[4u * ident + 1u]; | |
foo.c = indata.data[4u * ident + 2u]; | |
foo.d = indata.data[4u * ident + 3u]; | |
} | |
void meow(inout Foo foo) | |
{ | |
foo.a += 10.0; | |
foo.b += 20.0; | |
foo.c += 30.0; | |
foo.d += 40.0; | |
} | |
void main() | |
{ | |
Foo foo; | |
baz(foo); | |
meow(foo); | |
outdata.data[gl_GlobalInvocationID.x] = bar(foo) + bar(foobar.foos[gl_GlobalInvocationID.x]); | |
} | |
// GLSL -> glslangValidator -> SPIRV -> GLSL disassembler | |
#version 310 es | |
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; | |
struct Foo | |
{ | |
vec4 a; | |
vec4 b; | |
vec4 c; | |
vec4 d; | |
}; | |
layout(binding = 1, std430) buffer SSBO2 | |
{ | |
vec4 data[]; | |
} indata; | |
layout(binding = 0, std430) buffer SSBO | |
{ | |
vec4 data[]; | |
} outdata; | |
layout(binding = 2, std430) buffer SSBO3 | |
{ | |
Foo foos[]; | |
} foobar; | |
vec4 bar(Foo foo); | |
void baz(out Foo foo); | |
void meow(inout Foo foo); | |
void main() | |
{ | |
Foo param; | |
baz(param); | |
Foo foo = param; | |
Foo param_1 = foo; | |
meow(param_1); | |
foo = param_1; | |
Foo param_2 = foo; | |
Foo param_3 = foobar.foos[gl_GlobalInvocationID.x]; | |
outdata.data[gl_GlobalInvocationID.x] = (bar(param_2) + bar(param_3)); | |
return; | |
} | |
vec4 bar(Foo foo) | |
{ | |
return (((foo.a + foo.b) + foo.c) + foo.d); | |
} | |
void baz(out Foo foo) | |
{ | |
uint ident = gl_GlobalInvocationID.x; | |
foo.a = indata.data[((4u * ident) + 0u)]; | |
foo.b = indata.data[((4u * ident) + 1u)]; | |
foo.c = indata.data[((4u * ident) + 2u)]; | |
foo.d = indata.data[((4u * ident) + 3u)]; | |
return; | |
} | |
void meow(inout Foo foo) | |
{ | |
foo.a = (foo.a + vec4(10.000000)); | |
foo.b = (foo.b + vec4(20.000000)); | |
foo.c = (foo.c + vec4(30.000000)); | |
foo.d = (foo.d + vec4(40.000000)); | |
return; | |
} | |
// SPIRV | |
// Module Version 99 | |
// Generated by (magic number): 51a00bb | |
// Id's are bound by 135 | |
Source ESSL 310 | |
Capability Shader | |
1: ExtInstImport "GLSL.std.450" | |
MemoryModel Logical GLSL450 | |
EntryPoint GLCompute 4 "main" | |
ExecutionMode 4 LocalSize 1 1 1 | |
Name 4 "main" | |
Name 8 "Foo" | |
MemberName 8(Foo) 0 "a" | |
MemberName 8(Foo) 1 "b" | |
MemberName 8(Foo) 2 "c" | |
MemberName 8(Foo) 3 "d" | |
Name 12 "bar(struct-Foo-vf4-vf4-vf4-vf41;" | |
Name 11 "foo" | |
Name 16 "baz(struct-Foo-vf4-vf4-vf4-vf41;" | |
Name 15 "foo" | |
Name 19 "meow(struct-Foo-vf4-vf4-vf4-vf41;" | |
Name 18 "foo" | |
Name 41 "ident" | |
Name 44 "gl_GlobalInvocationID" | |
Name 48 "SSBO2" | |
MemberName 48(SSBO2) 0 "data" | |
Name 50 "indata" | |
Name 105 "foo" | |
Name 106 "param" | |
Name 109 "param" | |
Name 114 "SSBO" | |
MemberName 114(SSBO) 0 "data" | |
Name 116 "outdata" | |
Name 119 "param" | |
Name 123 "SSBO3" | |
MemberName 123(SSBO3) 0 "foos" | |
Name 125 "foobar" | |
Name 128 "param" | |
Decorate 44(gl_GlobalInvocationID) BuiltIn GlobalInvocationId | |
Decorate 47 ArrayStride 16 | |
MemberDecorate 48(SSBO2) 0 Offset 0 | |
Decorate 48(SSBO2) BufferBlock | |
Decorate 50(indata) Binding 1 | |
Decorate 113 ArrayStride 16 | |
MemberDecorate 114(SSBO) 0 Offset 0 | |
Decorate 114(SSBO) BufferBlock | |
Decorate 116(outdata) Binding 0 | |
Decorate 122 ArrayStride 64 | |
MemberDecorate 123(SSBO3) 0 Offset 0 | |
Decorate 123(SSBO3) BufferBlock | |
Decorate 125(foobar) Binding 2 | |
2: TypeVoid | |
3: TypeFunction 2 | |
6: TypeFloat 32 | |
7: TypeVector 6(float) 4 | |
8(Foo): TypeStruct 7(fvec4) 7(fvec4) 7(fvec4) 7(fvec4) | |
9: TypePointer Function 8(Foo) | |
10: TypeFunction 7(fvec4) 9(ptr) | |
14: TypeFunction 2 9(ptr) | |
21: TypeInt 32 1 | |
22: 21(int) Constant 0 | |
23: TypePointer Function 7(fvec4) | |
26: 21(int) Constant 1 | |
30: 21(int) Constant 2 | |
34: 21(int) Constant 3 | |
39: TypeInt 32 0 | |
40: TypePointer Function 39(int) | |
42: TypeVector 39(int) 3 | |
43: TypePointer Input 42(ivec3) | |
44(gl_GlobalInvocationID): 43(ptr) Variable Input | |
47: TypeRuntimeArray 7(fvec4) | |
48(SSBO2): TypeStruct 47 | |
49: TypePointer Uniform 48(SSBO2) | |
50(indata): 49(ptr) Variable Uniform | |
51: 39(int) Constant 4 | |
54: 39(int) Constant 0 | |
56: TypePointer Uniform 7(fvec4) | |
62: 39(int) Constant 1 | |
69: 39(int) Constant 2 | |
76: 39(int) Constant 3 | |
81: 6(float) Constant 1092616192 | |
87: 6(float) Constant 1101004800 | |
93: 6(float) Constant 1106247680 | |
99: 6(float) Constant 1109393408 | |
113: TypeRuntimeArray 7(fvec4) | |
114(SSBO): TypeStruct 113 | |
115: TypePointer Uniform 114(SSBO) | |
116(outdata): 115(ptr) Variable Uniform | |
122: TypeRuntimeArray 8(Foo) | |
123(SSBO3): TypeStruct 122 | |
124: TypePointer Uniform 123(SSBO3) | |
125(foobar): 124(ptr) Variable Uniform | |
129: TypePointer Uniform 8(Foo) | |
4(main): 2 Function None 3 | |
5: Label | |
105(foo): 9(ptr) Variable Function | |
106(param): 9(ptr) Variable Function | |
109(param): 9(ptr) Variable Function | |
119(param): 9(ptr) Variable Function | |
128(param): 9(ptr) Variable Function | |
107: 2 FunctionCall 16(baz(struct-Foo-vf4-vf4-vf4-vf41;) 106(param) | |
108: 8(Foo) Load 106(param) | |
Store 105(foo) 108 | |
110: 8(Foo) Load 105(foo) | |
Store 109(param) 110 | |
111: 2 FunctionCall 19(meow(struct-Foo-vf4-vf4-vf4-vf41;) 109(param) | |
112: 8(Foo) Load 109(param) | |
Store 105(foo) 112 | |
117: 42(ivec3) Load 44(gl_GlobalInvocationID) | |
118: 39(int) CompositeExtract 117 0 | |
120: 8(Foo) Load 105(foo) | |
Store 119(param) 120 | |
121: 7(fvec4) FunctionCall 12(bar(struct-Foo-vf4-vf4-vf4-vf41;) 119(param) | |
126: 42(ivec3) Load 44(gl_GlobalInvocationID) | |
127: 39(int) CompositeExtract 126 0 | |
130: 129(ptr) AccessChain 125(foobar) 22 127 | |
131: 8(Foo) Load 130 | |
Store 128(param) 131 | |
132: 7(fvec4) FunctionCall 12(bar(struct-Foo-vf4-vf4-vf4-vf41;) 128(param) | |
133: 7(fvec4) FAdd 121 132 | |
134: 56(ptr) AccessChain 116(outdata) 22 118 | |
Store 134 133 | |
Return | |
FunctionEnd | |
12(bar(struct-Foo-vf4-vf4-vf4-vf41;): 7(fvec4) Function None 10 | |
11(foo): 9(ptr) FunctionParameter | |
13: Label | |
24: 23(ptr) AccessChain 11(foo) 22 | |
25: 7(fvec4) Load 24 | |
27: 23(ptr) AccessChain 11(foo) 26 | |
28: 7(fvec4) Load 27 | |
29: 7(fvec4) FAdd 25 28 | |
31: 23(ptr) AccessChain 11(foo) 30 | |
32: 7(fvec4) Load 31 | |
33: 7(fvec4) FAdd 29 32 | |
35: 23(ptr) AccessChain 11(foo) 34 | |
36: 7(fvec4) Load 35 | |
37: 7(fvec4) FAdd 33 36 | |
ReturnValue 37 | |
FunctionEnd | |
16(baz(struct-Foo-vf4-vf4-vf4-vf41;): 2 Function None 14 | |
15(foo): 9(ptr) FunctionParameter | |
17: Label | |
41(ident): 40(ptr) Variable Function | |
45: 42(ivec3) Load 44(gl_GlobalInvocationID) | |
46: 39(int) CompositeExtract 45 0 | |
Store 41(ident) 46 | |
52: 39(int) Load 41(ident) | |
53: 39(int) IMul 51 52 | |
55: 39(int) IAdd 53 54 | |
57: 56(ptr) AccessChain 50(indata) 22 55 | |
58: 7(fvec4) Load 57 | |
59: 23(ptr) AccessChain 15(foo) 22 | |
Store 59 58 | |
60: 39(int) Load 41(ident) | |
61: 39(int) IMul 51 60 | |
63: 39(int) IAdd 61 62 | |
64: 56(ptr) AccessChain 50(indata) 22 63 | |
65: 7(fvec4) Load 64 | |
66: 23(ptr) AccessChain 15(foo) 26 | |
Store 66 65 | |
67: 39(int) Load 41(ident) | |
68: 39(int) IMul 51 67 | |
70: 39(int) IAdd 68 69 | |
71: 56(ptr) AccessChain 50(indata) 22 70 | |
72: 7(fvec4) Load 71 | |
73: 23(ptr) AccessChain 15(foo) 30 | |
Store 73 72 | |
74: 39(int) Load 41(ident) | |
75: 39(int) IMul 51 74 | |
77: 39(int) IAdd 75 76 | |
78: 56(ptr) AccessChain 50(indata) 22 77 | |
79: 7(fvec4) Load 78 | |
80: 23(ptr) AccessChain 15(foo) 34 | |
Store 80 79 | |
Return | |
FunctionEnd | |
19(meow(struct-Foo-vf4-vf4-vf4-vf41;): 2 Function None 14 | |
18(foo): 9(ptr) FunctionParameter | |
20: Label | |
82: 23(ptr) AccessChain 18(foo) 22 | |
83: 7(fvec4) Load 82 | |
84: 7(fvec4) CompositeConstruct 81 81 81 81 | |
85: 7(fvec4) FAdd 83 84 | |
86: 23(ptr) AccessChain 18(foo) 22 | |
Store 86 85 | |
88: 23(ptr) AccessChain 18(foo) 26 | |
89: 7(fvec4) Load 88 | |
90: 7(fvec4) CompositeConstruct 87 87 87 87 | |
91: 7(fvec4) FAdd 89 90 | |
92: 23(ptr) AccessChain 18(foo) 26 | |
Store 92 91 | |
94: 23(ptr) AccessChain 18(foo) 30 | |
95: 7(fvec4) Load 94 | |
96: 7(fvec4) CompositeConstruct 93 93 93 93 | |
97: 7(fvec4) FAdd 95 96 | |
98: 23(ptr) AccessChain 18(foo) 30 | |
Store 98 97 | |
100: 23(ptr) AccessChain 18(foo) 34 | |
101: 7(fvec4) Load 100 | |
102: 7(fvec4) CompositeConstruct 99 99 99 99 | |
103: 7(fvec4) FAdd 101 102 | |
104: 23(ptr) AccessChain 18(foo) 34 | |
Store 104 103 | |
Return | |
FunctionEnd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment