|
@@ -23,7 +23,7 @@ private:
|
23
|
23
|
|
24
|
24
|
public:
|
25
|
25
|
UVQuad() = default;
|
26
|
|
-
|
|
26
|
+
|
27
|
27
|
size_t VerticesCount() const { return vertices.Count(); }
|
28
|
28
|
size_t IndicesCount() const { return indices.Count(); }
|
29
|
29
|
UVQuad::Vertex* VerticesData() { return vertices; }
|
|
@@ -134,7 +134,7 @@ public:
|
134
|
134
|
descriptorSetPostCompute = device->CreateShaderBindingSet(descriptorSetLayout);
|
135
|
135
|
|
136
|
136
|
uniformBuffer = device->CreateBuffer(sizeof(GraphicShaderBindingSet::UBO), DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
|
137
|
|
-
|
|
137
|
+
|
138
|
138
|
if (descriptorSetPreCompute)
|
139
|
139
|
{
|
140
|
140
|
if (uniformBuffer)
|
|
@@ -203,7 +203,7 @@ public:
|
203
|
203
|
|
204
|
204
|
size_t bufferLength = bytesPerPixel * width * height;
|
205
|
205
|
DKObject<DKGpuBuffer> stagingBuffer = device->CreateBuffer(bufferLength, DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
|
206
|
|
-
|
|
206
|
+
|
207
|
207
|
memcpy(stagingBuffer->Contents(), image->Contents(), bufferLength);
|
208
|
208
|
stagingBuffer->Flush();
|
209
|
209
|
|
|
@@ -295,7 +295,7 @@ public:
|
295
|
295
|
DKTexture::UsageSampled; // For FragmentShader
|
296
|
296
|
return device->CreateTexture(texDesc);
|
297
|
297
|
}(graphicsQueue->Device(), sourceTexture->Width(), sourceTexture->Height());
|
298
|
|
-
|
|
298
|
+
|
299
|
299
|
// create sampler for fragment-shader
|
300
|
300
|
DKSamplerDescriptor samplerDesc = {};
|
301
|
301
|
samplerDesc.magFilter = DKSamplerDescriptor::MinMagFilterLinear;
|
|
@@ -306,7 +306,7 @@ public:
|
306
|
306
|
samplerDesc.maxAnisotropy = 1;
|
307
|
307
|
DKObject<DKSamplerState> sampler = device->CreateSamplerState(samplerDesc);
|
308
|
308
|
|
309
|
|
-
|
|
309
|
+
|
310
|
310
|
DKObject<DKSwapChain> swapChain = graphicsQueue->CreateSwapChain(window);
|
311
|
311
|
|
312
|
312
|
DKLog("VertexFunction.VertexAttributes: %d", vsf->StageInputAttributes().Count());
|
|
@@ -316,23 +316,23 @@ public:
|
316
|
316
|
DKLog(" --> VertexAttribute[%d]: \"%ls\" (location:%u)", i, (const wchar_t*)attr.name, attr.location);
|
317
|
317
|
}
|
318
|
318
|
|
319
|
|
-
|
|
319
|
+
|
320
|
320
|
DKRenderPipelineDescriptor pipelineDescriptor = {};
|
321
|
321
|
// setup shader
|
322
|
322
|
pipelineDescriptor.vertexFunction = vsf;
|
323
|
323
|
pipelineDescriptor.fragmentFunction = fsf;
|
324
|
|
-
|
|
324
|
+
|
325
|
325
|
// setup color-attachment render-targets
|
326
|
326
|
pipelineDescriptor.colorAttachments.Resize(1);
|
327
|
327
|
pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
|
328
|
|
- pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = false;
|
329
|
|
- pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
|
330
|
|
- pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
|
|
328
|
+ pipelineDescriptor.colorAttachments.Value(0).blendState.enabled = false;
|
|
329
|
+ pipelineDescriptor.colorAttachments.Value(0).blendState.sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
|
|
330
|
+ pipelineDescriptor.colorAttachments.Value(0).blendState.destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
|
331
|
331
|
// setup depth-stencil
|
332
|
332
|
pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::D32Float;
|
333
|
333
|
pipelineDescriptor.depthStencilDescriptor.depthWriteEnabled = true;
|
334
|
334
|
pipelineDescriptor.depthStencilDescriptor.depthCompareFunction = DKCompareFunctionLessEqual;
|
335
|
|
-
|
|
335
|
+
|
336
|
336
|
// setup vertex buffer and attributes
|
337
|
337
|
pipelineDescriptor.vertexDescriptor = quad->VertexDescriptor();
|
338
|
338
|
|
|
@@ -385,9 +385,9 @@ public:
|
385
|
385
|
DKComputePipelineDescriptor embossComputePipelineDescriptor = {};
|
386
|
386
|
embossComputePipelineDescriptor.computeFunction = cs_ef;
|
387
|
387
|
DKObject<DKComputePipelineState> emboss = device->CreateComputePipeline(embossComputePipelineDescriptor);
|
388
|
|
-
|
|
388
|
+
|
389
|
389
|
DKObject<DKTexture> depthBuffer = nullptr;
|
390
|
|
-
|
|
390
|
+
|
391
|
391
|
DKTimer timer;
|
392
|
392
|
timer.Reset();
|
393
|
393
|
|
|
@@ -426,7 +426,7 @@ public:
|
426
|
426
|
rpd.depthStencilAttachment.loadAction = DKRenderPassAttachmentDescriptor::LoadActionClear;
|
427
|
427
|
rpd.depthStencilAttachment.storeAction = DKRenderPassAttachmentDescriptor::StoreActionDontCare;
|
428
|
428
|
|
429
|
|
-
|
|
429
|
+
|
430
|
430
|
DKObject<DKComputeCommandEncoder> computeEncoder = nullptr;
|
431
|
431
|
DKObject<DKRenderCommandEncoder> renderEncoder = nullptr;
|
432
|
432
|
|