|
@@ -261,11 +261,113 @@ void PrintShaderResource(const DKShaderResource& res)
|
261
|
261
|
}
|
262
|
262
|
}
|
263
|
263
|
|
|
264
|
+
|
264
|
265
|
class TestApp1 : public DKApplication
|
265
|
266
|
{
|
266
|
267
|
DKResourcePool resourcePool;
|
267
|
268
|
DKString userConfigPath;
|
268
|
269
|
|
|
270
|
+ DKObject<DKGraphicsDevice> device;
|
|
271
|
+
|
|
272
|
+ void TestRenderPipelineReflection(const DKString& path)
|
|
273
|
+ {
|
|
274
|
+ DKObject<DKData> vertData = resourcePool.LoadResourceData(path + ".vert.spv");
|
|
275
|
+ DKObject<DKData> fragData = resourcePool.LoadResourceData(path + ".frag.spv");
|
|
276
|
+
|
|
277
|
+ DKASSERT(vertData);
|
|
278
|
+ DKASSERT(fragData);
|
|
279
|
+
|
|
280
|
+ DKShader vertShader(vertData, DKShader::Vertex);
|
|
281
|
+ DKShader fragShader(fragData, DKShader::Fragment);
|
|
282
|
+
|
|
283
|
+ DKObject<DKShaderModule> vertShaderModule = device->CreateShaderModule(&vertShader);
|
|
284
|
+ DKObject<DKShaderModule> fragShaderModule = device->CreateShaderModule(&fragShader);
|
|
285
|
+
|
|
286
|
+ DKObject<DKShaderFunction> vertShaderFunction = vertShaderModule->CreateFunction(vertShaderModule->FunctionNames().Value(0));
|
|
287
|
+ DKObject<DKShaderFunction> fragShaderFunction = fragShaderModule->CreateFunction(fragShaderModule->FunctionNames().Value(0));
|
|
288
|
+
|
|
289
|
+ DKLog("VertexFunction.VertexAttributes: %d", vertShaderFunction->VertexAttributes().Count());
|
|
290
|
+ for (int i = 0; i < vertShaderFunction->VertexAttributes().Count(); ++i)
|
|
291
|
+ {
|
|
292
|
+ const DKVertexAttribute& attr = vertShaderFunction->VertexAttributes().Value(i);
|
|
293
|
+ DKLog(" --> VertexAttribute[%d]: \"%ls\" (location:%u)", i, (const wchar_t*)attr.name, attr.location);
|
|
294
|
+ }
|
|
295
|
+
|
|
296
|
+ // setup dummy vertex-descriptor
|
|
297
|
+ DKVertexDescriptor vertexDescriptor = VertexDescriptorForVertexAttributes(vertShaderFunction->VertexAttributes());
|
|
298
|
+
|
|
299
|
+ // setup rendering pipeline state object (PSO)
|
|
300
|
+ DKRenderPipelineDescriptor pipelineDescriptor;
|
|
301
|
+ pipelineDescriptor.vertexFunction = vertShaderFunction;
|
|
302
|
+ pipelineDescriptor.fragmentFunction = fragShaderFunction;
|
|
303
|
+ pipelineDescriptor.colorAttachments.Resize(1);
|
|
304
|
+ pipelineDescriptor.colorAttachments.Value(0).pixelFormat = DKPixelFormat::RGBA8Unorm;
|
|
305
|
+ pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
|
|
306
|
+ pipelineDescriptor.vertexDescriptor = vertexDescriptor;
|
|
307
|
+ pipelineDescriptor.primitiveTopology = DKPrimitiveType::Triangle;
|
|
308
|
+ pipelineDescriptor.frontFace = DKFrontFace::CCW;
|
|
309
|
+ pipelineDescriptor.triangleFillMode = DKTriangleFillMode::Fill;
|
|
310
|
+ pipelineDescriptor.depthClipMode = DKDepthClipMode::Clip;
|
|
311
|
+ pipelineDescriptor.cullMode = DKCullMode::None;
|
|
312
|
+ pipelineDescriptor.rasterizationEnabled = true;
|
|
313
|
+
|
|
314
|
+ DKRenderPipelineReflection reflection;
|
|
315
|
+ DKObject<DKRenderPipelineState> pipelineState = device->CreateRenderPipeline(pipelineDescriptor, &reflection);
|
|
316
|
+ if (pipelineState)
|
|
317
|
+ {
|
|
318
|
+ DKLog("=========================================================");
|
|
319
|
+ DKLog("PipelineReflection.VertexResources: %d", reflection.vertexResources.Count());
|
|
320
|
+ for (auto& arg : reflection.vertexResources)
|
|
321
|
+ PrintShaderResource(arg);
|
|
322
|
+ DKLog("---------------------------------------------------------");
|
|
323
|
+ DKLog("PipelineReflection.FragmentResources: %d", reflection.fragmentResources.Count());
|
|
324
|
+ for (auto& arg : reflection.fragmentResources)
|
|
325
|
+ PrintShaderResource(arg);
|
|
326
|
+ DKLog("=========================================================");
|
|
327
|
+ }
|
|
328
|
+ else
|
|
329
|
+ {
|
|
330
|
+ DKLogE("CreateRenderPipeline failed.");
|
|
331
|
+ }
|
|
332
|
+ }
|
|
333
|
+
|
|
334
|
+ void TestComputePipelineReflection(const DKString& path)
|
|
335
|
+ {
|
|
336
|
+ DKObject<DKData> shaderData = resourcePool.LoadResourceData(path + ".comp.spv");
|
|
337
|
+
|
|
338
|
+ DKASSERT(shaderData);
|
|
339
|
+
|
|
340
|
+ DKShader shader(shaderData, DKShader::Compute);
|
|
341
|
+
|
|
342
|
+ DKObject<DKShaderModule> shaderModule = device->CreateShaderModule(&shader);
|
|
343
|
+ DKObject<DKShaderFunction> shaderFunction = shaderModule->CreateFunction(shaderModule->FunctionNames().Value(0));
|
|
344
|
+
|
|
345
|
+ DKLog("ComputeFunction.StageInputAttributes: %d", shaderFunction->StageInputAttributes().Count());
|
|
346
|
+ for (int i = 0; i < shaderFunction->StageInputAttributes().Count(); ++i)
|
|
347
|
+ {
|
|
348
|
+ const DKShaderAttribute& attr = shaderFunction->StageInputAttributes().Value(i);
|
|
349
|
+ DKLog(" --> ShaderAttribute[%d]: \"%ls\" (location:%u)", i, (const wchar_t*)attr.name, attr.location);
|
|
350
|
+ }
|
|
351
|
+
|
|
352
|
+ // setup pipeline state object (PSO)
|
|
353
|
+ DKComputePipelineDescriptor pipelineDescriptor;
|
|
354
|
+
|
|
355
|
+ DKComputePipelineReflection reflection;
|
|
356
|
+ DKObject<DKComputePipelineState> pipelineState = device->CreateComputePipeline(pipelineDescriptor, &reflection);
|
|
357
|
+ if (pipelineState)
|
|
358
|
+ {
|
|
359
|
+ DKLog("=========================================================");
|
|
360
|
+ DKLog("PipelineReflection.Resources: %d", reflection.resources.Count());
|
|
361
|
+ for (auto& arg : reflection.resources)
|
|
362
|
+ PrintShaderResource(arg);
|
|
363
|
+ DKLog("=========================================================");
|
|
364
|
+ }
|
|
365
|
+ else
|
|
366
|
+ {
|
|
367
|
+ DKLogE("CreateComputePipeline failed.");
|
|
368
|
+ }
|
|
369
|
+ }
|
|
370
|
+
|
269
|
371
|
public:
|
270
|
372
|
void OnInitialize(void) override
|
271
|
373
|
{
|
|
@@ -283,60 +385,10 @@ public:
|
283
|
385
|
if (numItemsImported >= 0)
|
284
|
386
|
DKLogI("UserSettings: %ls (%d items imported)", (const wchar_t*)userConfigPath, numItemsImported);
|
285
|
387
|
|
286
|
|
- DKObject<DKData> vertData = resourcePool.LoadResourceData("shaders/texturearray/instancing.vert.spv");
|
287
|
|
- DKObject<DKData> fragData = resourcePool.LoadResourceData("shaders/texturearray/instancing.frag.spv");
|
288
|
|
-
|
289
|
|
- DKShader vertShader(vertData, DKShader::Vertex);
|
290
|
|
- DKShader fragShader(fragData, DKShader::Fragment);
|
291
|
|
-
|
292
|
|
- DKObject<DKGraphicsDevice> device = DKGraphicsDevice::SharedInstance();
|
293
|
|
- DKObject<DKShaderModule> vertShaderModule = device->CreateShaderModule(&vertShader);
|
294
|
|
- DKObject<DKShaderModule> fragShaderModule = device->CreateShaderModule(&fragShader);
|
295
|
|
-
|
296
|
|
- DKObject<DKShaderFunction> vertShaderFunction = vertShaderModule->CreateFunction(vertShaderModule->FunctionNames().Value(0));
|
297
|
|
- DKObject<DKShaderFunction> fragShaderFunction = fragShaderModule->CreateFunction(fragShaderModule->FunctionNames().Value(0));
|
|
388
|
+ device = DKGraphicsDevice::SharedInstance();
|
298
|
389
|
|
299
|
|
- DKObject<DKCommandQueue> queue = device->CreateCommandQueue(DKCommandQueue::Graphics);
|
300
|
|
-
|
301
|
|
- DKLog("VertexFunction.VertexAttributes: %d", vertShaderFunction->VertexAttributes().Count());
|
302
|
|
- for (int i = 0; i < vertShaderFunction->VertexAttributes().Count(); ++i)
|
303
|
|
- {
|
304
|
|
- const DKVertexAttribute& attr = vertShaderFunction->VertexAttributes().Value(i);
|
305
|
|
- DKLog(" --> VertexAttribute[%d]: \"%ls\" (location:%u)", i, (const wchar_t*)attr.name, attr.location);
|
306
|
|
- }
|
307
|
|
-
|
308
|
|
- // setup dummy vertex-descriptor
|
309
|
|
- DKVertexDescriptor vertexDescriptor = VertexDescriptorForVertexAttributes(vertShaderFunction->VertexAttributes());
|
310
|
|
-
|
311
|
|
- // setup rendering pipeline state object (PSO)
|
312
|
|
- DKRenderPipelineDescriptor pipelineDescriptor;
|
313
|
|
- pipelineDescriptor.vertexFunction = vertShaderFunction;
|
314
|
|
- pipelineDescriptor.fragmentFunction = fragShaderFunction;
|
315
|
|
- pipelineDescriptor.colorAttachments.Resize(1);
|
316
|
|
- pipelineDescriptor.colorAttachments.Value(0).pixelFormat = DKPixelFormat::RGBA8Unorm;
|
317
|
|
- pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
|
318
|
|
- pipelineDescriptor.vertexDescriptor = vertexDescriptor;
|
319
|
|
- pipelineDescriptor.primitiveTopology = DKPrimitiveType::Triangle;
|
320
|
|
- pipelineDescriptor.frontFace = DKFrontFace::CCW;
|
321
|
|
- pipelineDescriptor.triangleFillMode = DKTriangleFillMode::Fill;
|
322
|
|
- pipelineDescriptor.depthClipMode = DKDepthClipMode::Clip;
|
323
|
|
- pipelineDescriptor.cullMode = DKCullMode::None;
|
324
|
|
- pipelineDescriptor.rasterizationEnabled = true;
|
325
|
|
-
|
326
|
|
- DKRenderPipelineReflection reflection;
|
327
|
|
- DKObject<DKRenderPipelineState> pipelineState = device->CreateRenderPipeline(pipelineDescriptor, &reflection);
|
328
|
|
- if (pipelineState)
|
329
|
|
- {
|
330
|
|
- DKLog("=========================================================");
|
331
|
|
- DKLog("PipelineReflection.VertexResources: %d", reflection.vertexResources.Count());
|
332
|
|
- for (auto& arg : reflection.vertexResources)
|
333
|
|
- PrintShaderResource(arg);
|
334
|
|
- DKLog("---------------------------------------------------------");
|
335
|
|
- DKLog("PipelineReflection.FragmentResources: %d", reflection.fragmentResources.Count());
|
336
|
|
- for (auto& arg : reflection.fragmentResources)
|
337
|
|
- PrintShaderResource(arg);
|
338
|
|
- DKLog("=========================================================");
|
339
|
|
- }
|
|
390
|
+ TestRenderPipelineReflection("shaders/deferredshadows/deferred");
|
|
391
|
+ TestComputePipelineReflection("shaders/computeshader/emboss");
|
340
|
392
|
|
341
|
393
|
Terminate(0);
|
342
|
394
|
}
|
|
@@ -344,6 +396,8 @@ public:
|
344
|
396
|
{
|
345
|
397
|
DKLogD("%s", DKGL_FUNCTION_NAME);
|
346
|
398
|
|
|
399
|
+ device = NULL;
|
|
400
|
+
|
347
|
401
|
int numItemsExported = DKPropertySet::DefaultSet().Export(userConfigPath, true);
|
348
|
402
|
DKLogI("Setting saved: %ls (%d items exported)", (const wchar_t*)userConfigPath, numItemsExported);
|
349
|
403
|
|