@@ -54,7 +54,6 @@ uintptr_t gConstantBufferSize, gComputeResultBufferSize;
54
54
Buffer* gConstantBuffer ;
55
55
InputLayout* gInputLayout ;
56
56
Buffer* gVertexBuffer ;
57
- Buffer* gComputeResultBuffer ;
58
57
ShaderProgram* gShaderProgram ;
59
58
BindingState* gBindingState ;
60
59
ShaderInputLayout gShaderInputLayout ;
@@ -125,16 +124,6 @@ Error initializeShaders(
125
124
126
125
return Error::None;
127
126
}
128
-
129
- void outputComputeResult (Renderer* renderer, const char * fileName)
130
- {
131
- float * data = (float *)renderer->map (gComputeResultBuffer , MapFlavor::HostRead);
132
- FILE* f = fopen (fileName, " wt" );
133
- for (auto i = 0u ; i < gComputeResultBufferSize / sizeof (UInt); i++)
134
- fprintf (f, " %.9g\n " , data[i]);
135
- fclose (f);
136
- }
137
-
138
127
//
139
128
// At initialization time, we are going to load and compile our Slang shader
140
129
// code, and then create the D3D11 API objects we need for rendering.
@@ -162,20 +151,7 @@ Error initializeInner(
162
151
gConstantBuffer = renderer->createBuffer (constantBufferDesc);
163
152
if (!gConstantBuffer )
164
153
return Error::Unexpected;
165
-
166
- gComputeResultBufferSize = 512 * sizeof (float );
167
- BufferDesc computeResultBufferDesc;
168
- computeResultBufferDesc.size = gComputeResultBufferSize ;
169
- computeResultBufferDesc.flavor = BufferFlavor::Storage;
170
- gComputeResultBuffer = renderer->createBuffer (computeResultBufferDesc);
171
- if (!gComputeResultBufferSize )
172
- return Error::Unexpected;
173
- // initialize buffer to 0
174
- char * ptr = (char *)renderer->map (gComputeResultBuffer , MapFlavor::HostWrite);
175
- for (auto i = 0u ; i < gComputeResultBufferSize ; i++)
176
- ptr[i] = 0 ;
177
- renderer->unmap (gComputeResultBuffer );
178
-
154
+
179
155
// Input Assembler (IA)
180
156
181
157
InputElementDesc inputElements[] = {
@@ -236,7 +212,6 @@ void renderFrameInner(
236
212
void runCompute (Renderer * renderer)
237
213
{
238
214
renderer->setShaderProgram (gShaderProgram );
239
- renderer->setStorageBuffer (0 , gComputeResultBuffer );
240
215
renderer->setBindingState (gBindingState );
241
216
renderer->dispatchCompute (1 , 1 , 1 );
242
217
}
@@ -434,10 +409,10 @@ int main(
434
409
// If we are in a mode where output is requested, we need to snapshot the back buffer here
435
410
if (gOptions .outputPath )
436
411
{
437
- if (gOptions .shaderType == ShaderProgramType::Compute)
438
- outputComputeResult ( renderer, gOptions .outputPath );
439
- else
440
- renderer->captureScreenShot (gOptions .outputPath );
412
+ if (gOptions .shaderType == ShaderProgramType::Compute)
413
+ renderer-> serializeOutput ( gBindingState , gOptions .outputPath );
414
+ else
415
+ renderer->captureScreenShot (gOptions .outputPath );
441
416
return 0 ;
442
417
}
443
418
0 commit comments