Преглед изворни кода

fix : update sample with recent api

Heedong Lee пре 4 година
родитељ
комит
d811fe8ccd
2 измењених фајлова са 18 додато и 18 уклоњено
  1. 14
    14
      Samples/ComputeShader/ComputeShader.cpp
  2. 4
    4
      Samples/Texture/Texture.cpp

+ 14
- 14
Samples/ComputeShader/ComputeShader.cpp Прегледај датотеку

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

+ 4
- 4
Samples/Texture/Texture.cpp Прегледај датотеку

35
 
35
 
36
                 size_t bufferLength = bytesPerPixel * width * height;
36
                 size_t bufferLength = bytesPerPixel * width * height;
37
                 DKObject<DKGpuBuffer> stagingBuffer = device->CreateBuffer(bufferLength, DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
37
                 DKObject<DKGpuBuffer> stagingBuffer = device->CreateBuffer(bufferLength, DKGpuBuffer::StorageModeShared, DKCpuCacheModeReadWrite);
38
-                
38
+
39
                 memcpy(stagingBuffer->Contents(), image->Contents(), bufferLength);
39
                 memcpy(stagingBuffer->Contents(), image->Contents(), bufferLength);
40
                 stagingBuffer->Flush();
40
                 stagingBuffer->Flush();
41
 
41
 
111
 		pipelineDescriptor.fragmentFunction = fragShaderFunction;
111
 		pipelineDescriptor.fragmentFunction = fragShaderFunction;
112
 		pipelineDescriptor.colorAttachments.Resize(1);
112
 		pipelineDescriptor.colorAttachments.Resize(1);
113
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
113
 		pipelineDescriptor.colorAttachments.Value(0).pixelFormat = swapChain->ColorPixelFormat();
114
-        pipelineDescriptor.colorAttachments.Value(0).blendingEnabled = true;
115
-        pipelineDescriptor.colorAttachments.Value(0).sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
116
-        pipelineDescriptor.colorAttachments.Value(0).destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
114
+        pipelineDescriptor.colorAttachments.Value(0).blendState.enabled = true;
115
+        pipelineDescriptor.colorAttachments.Value(0).blendState.sourceRGBBlendFactor = DKBlendFactor::SourceAlpha;
116
+        pipelineDescriptor.colorAttachments.Value(0).blendState.destinationRGBBlendFactor = DKBlendFactor::OneMinusSourceAlpha;
117
 		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
117
 		pipelineDescriptor.depthStencilAttachmentPixelFormat = DKPixelFormat::Invalid; // no depth buffer
118
 		pipelineDescriptor.vertexDescriptor.attributes = {
118
 		pipelineDescriptor.vertexDescriptor.attributes = {
119
 			{ DKVertexFormat::Float3, 0, 0, 0 },
119
 			{ DKVertexFormat::Float3, 0, 0, 0 },