1
- #include " ../../prelude/slang-cpp-prelude.h"
2
-
3
-
4
- #ifdef SLANG_PRELUDE_NAMESPACE
5
- using namespace SLANG_PRELUDE_NAMESPACE ;
6
- #endif
7
-
8
- Vector<uint32_t , 3 > operator +(Vector<uint32_t , 3 > a, Vector<uint32_t , 3 > b)
9
- {
10
- Vector<uint32_t , 3 > r;
11
- r.x = a.x + b.x ;
12
- r.y = a.y + b.y ;
13
- r.z = a.z + b.z ;
14
- return r;
15
- }
16
-
17
- Vector<uint32_t , 3 > operator *(Vector<uint32_t , 3 > a, Vector<uint32_t , 3 > b)
18
- {
19
- Vector<uint32_t , 3 > r;
20
- r.x = a.x * b.x ;
21
- r.y = a.y * b.y ;
22
- r.z = a.z * b.z ;
23
- return r;
24
- }
25
-
26
- Vector<uint32_t , 3 > make_VecU3 (uint32_t a, uint32_t b, uint32_t c)
27
- {
28
- return Vector<uint32_t , 3 >{ a, b, c};
29
- }
30
-
31
- void computeMain_wrapper (gfx_Device_0* device, Vector<uint32_t , 3 > gridDims,
32
- RWStructuredBuffer<float > buffer)
33
- {
34
- gfx_ShaderProgram_0* shaderProgram = loadShaderProgram_0 (device, " computeMain" , " shader" );
35
- gfx_TransientResourceHeap_0* transientHeap = buildTransientHeap_0 (device);
36
- gfx_PipelineState_0* pipelineState = buildPipelineState_0 (device, shaderProgram);
37
- gfx_ResourceView_0* bufferView = createBufferView_0 (device, unconvertBuffer_0 (buffer));
38
- dispatchComputation_0 (device, transientHeap, pipelineState, bufferView, gridDims.x , gridDims.y , gridDims.z );
39
- }
40
-
41
- #line 8 "../../../examples/heterogeneous-hello-world/shader.slang"
42
- struct EntryPointParams_0
43
- {
44
- RWStructuredBuffer<float > ioBuffer_0;
45
- };
46
-
47
-
48
- #line 21
49
- struct gfx_Device_0
50
- {
51
- };
52
-
53
-
54
- #line 22
55
- struct gfx_BufferResource_0
56
- {
57
- };
58
-
59
-
60
- #line 23
61
- struct gfx_ResourceView_0
62
- {
63
- };
64
-
65
-
66
- #line 8
67
- void _computeMain (void * _S1, void * entryPointParams_0, void * _S2)
68
- {
69
-
70
- #line 8
71
- ComputeThreadVaryingInput* _S3 = (slang_bit_cast<ComputeThreadVaryingInput*>(_S1));
72
-
73
- uint32_t tid_0 = (*(&_S3->groupID ) * make_VecU3 (4U , 1U , 1U ) + *(&_S3->groupThreadID )).x ;
74
-
75
- float * _S4 = &(*(&(slang_bit_cast<EntryPointParams_0*>(entryPointParams_0))->ioBuffer_0 ))[tid_0];
76
-
77
- #line 12
78
- float i_0 = *_S4;
79
- bool _S5 = i_0 < 0 .50000000000000000000f ;
80
-
81
- #line 13
82
- float _S6 = i_0 + i_0;
83
-
84
- #line 13
85
- float _S7 = (F32_sqrt ((i_0)));
86
-
87
- #line 13
88
- float o_0 = _S5 ? _S6 : _S7;
89
-
90
- float * _S8 = &(*(&(slang_bit_cast<EntryPointParams_0*>(entryPointParams_0))->ioBuffer_0 ))[tid_0];
91
-
92
- #line 15
93
- *_S8 = o_0;
94
- return ;
95
- }
96
-
97
-
98
- #line 31
99
- gfx_Device_0* createDevice_0 ();
100
-
101
- gfx_BufferResource_0* createStructuredBuffer_0 (gfx_Device_0* _0, FixedArray<float , 4 > _1);
102
-
103
-
104
- gfx_ResourceView_0* createBufferView_0 (gfx_Device_0* _0, gfx_BufferResource_0* _1);
105
-
106
-
107
- #line 4
108
- RWStructuredBuffer<float > convertBuffer_0 (gfx_BufferResource_0* _0);
109
-
110
-
111
- #line 44
112
- void printInitialValues_0 (FixedArray<float , 4 > _0, int32_t _1);
113
-
114
-
115
- #line 50
116
- bool printOutputValues_0 (gfx_Device_0* _0, gfx_BufferResource_0* _1, int32_t _2);
117
-
118
-
119
-
120
-
121
- bool executeComputation_0 ()
122
- {
123
-
124
- FixedArray<float , 4 > initialArray_0 = { 3 .00000000000000000000f , -20 .00000000000000000000f , -6 .00000000000000000000f , 8 .00000000000000000000f };
125
-
126
-
127
- gfx_Device_0* _S9 = createDevice_0 ();
128
- gfx_BufferResource_0* _S10 = createStructuredBuffer_0 (_S9, initialArray_0);
129
- gfx_ResourceView_0* _S11 = createBufferView_0 (_S9, _S10);
130
- Vector<uint32_t , 3 > _S12 = make_VecU3 (uint32_t (int (4 )), uint32_t (int (1 )), uint32_t (int (1 )));
131
- RWStructuredBuffer<float > _S13 = convertBuffer_0 (_S10);
132
-
133
- #line 64
134
- computeMain_wrapper (_S9, _S12, _S13);
135
-
136
- printInitialValues_0 (initialArray_0, int (4 ));
137
- bool _S14 = printOutputValues_0 (_S9, _S10, int (4 ));
138
-
139
-
140
- return true ;
141
- }
142
-
143
- // [numthreads(4, 1, 1)]
144
- SLANG_PRELUDE_EXPORT
145
- void computeMain_Thread (ComputeThreadVaryingInput* varyingInput, void * entryPointParams, void * globalParams)
146
- {
147
- _computeMain (varyingInput, entryPointParams, globalParams);
148
- }
149
- // [numthreads(4, 1, 1)]
150
- SLANG_PRELUDE_EXPORT
151
- void computeMain_Group (ComputeVaryingInput* varyingInput, void * entryPointParams, void * globalParams)
152
- {
153
- ComputeThreadVaryingInput threadInput = {};
154
- threadInput.groupID = varyingInput->startGroupID ;
155
- for (uint32_t x = 0 ; x < 4 ; ++x)
156
- {
157
- threadInput.groupThreadID .x = x;
158
- _computeMain (&threadInput, entryPointParams, globalParams);
159
- }
160
- }
161
- // [numthreads(4, 1, 1)]
162
- SLANG_PRELUDE_EXPORT
163
- void computeMain (ComputeVaryingInput* varyingInput, void * entryPointParams, void * globalParams)
164
- {
165
- ComputeVaryingInput vi = *varyingInput;
166
- ComputeVaryingInput groupVaryingInput = {};
167
- for (uint32_t z = vi.startGroupID .z ; z < vi.endGroupID .z ; ++z)
168
- {
169
- groupVaryingInput.startGroupID .z = z;
170
- for (uint32_t y = vi.startGroupID .y ; y < vi.endGroupID .y ; ++y)
171
- {
172
- groupVaryingInput.startGroupID .y = y;
173
- for (uint32_t x = vi.startGroupID .x ; x < vi.endGroupID .x ; ++x)
174
- {
175
- groupVaryingInput.startGroupID .x = x;
176
- computeMain_Group (&groupVaryingInput, entryPointParams, globalParams);
177
- }
178
- }
179
- }
180
- }
1
+ // This is a placeholder. The contents will be generated during build.
0 commit comments