소스 검색

코딩 컨벤션 정리

Heedong Arkiny Lee 5 년 전
부모
커밋
d3559dff34
1개의 변경된 파일31개의 추가작업 그리고 36개의 파일을 삭제
  1. 31
    36
      Samples/ComputeShader/ComputeShader.cpp

+ 31
- 36
Samples/ComputeShader/ComputeShader.cpp 파일 보기

@@ -75,7 +75,6 @@ public:
75 75
 
76 76
         if (textureTarget == nullptr)
77 77
         {
78
-            // create depth buffer
79 78
             DKTextureDescriptor texDesc = {};
80 79
             texDesc.textureType = DKTexture::Type2D;
81 80
             texDesc.pixelFormat = DKPixelFormat::BGRA8Unorm;
@@ -85,7 +84,8 @@ public:
85 84
             texDesc.mipmapLevels = 1;
86 85
             texDesc.sampleCount = 1;
87 86
             texDesc.arrayLength = 1;
88
-            texDesc.usage = DKTexture::UsageShaderRead | DKTexture::UsageStorage | DKTexture::UsageSampled;
87
+            texDesc.usage = DKTexture::UsageStorage  // For Compute Shader
88
+                | DKTexture::UsageSampled | DKTexture::UsageShaderRead;// For FragmentShader
89 89
             textureTarget = device->CreateTexture(texDesc);
90 90
         }
91 91
 
@@ -198,7 +198,7 @@ class MeshDemo : public SampleApp
198 198
 	DKAtomicNumber32 runningRenderThread;
199 199
 
200 200
     //Resource
201
-	DKObject<UVQuad> Quad;
201
+	DKObject<UVQuad> quad;
202 202
     DKObject<DKTexture> textureColorMap;
203 203
 
204 204
     DKObject<TextureComputeTarget> ComputeTarget;
@@ -265,7 +265,7 @@ public:
265 265
         DKObject<DKCommandQueue> computeQueue = device->CreateCommandQueue(DKCommandQueue::Compute);
266 266
 
267 267
         // Geometry Initialzie
268
-        Quad->InitializeGpuResource(graphicsQueue);
268
+        quad->InitializeGpuResource(graphicsQueue);
269 269
 
270 270
         // create shaders
271 271
 		DKObject<DKData> vertData = resourcePool.LoadResourceData("shaders/ComputeShader/texture.vert.spv");
@@ -275,27 +275,25 @@ public:
275 275
         DKObject<DKData> sharpenData = resourcePool.LoadResourceData("shaders/ComputeShader/sharpen.comp.spv");
276 276
 
277 277
 
278
-        DKObject<GPUShader> VS = DKOBJECT_NEW GPUShader(vertData);
279
-        DKObject<GPUShader> FS = DKOBJECT_NEW GPUShader(fragData);
278
+        DKObject<GPUShader> vs = DKOBJECT_NEW GPUShader(vertData);
279
+        DKObject<GPUShader> fs = DKOBJECT_NEW GPUShader(fragData);
280 280
 
281
-        DKObject<GPUShader> CS_E = DKOBJECT_NEW GPUShader(embossData);
282
-        DKObject<GPUShader> CS_ED = DKOBJECT_NEW GPUShader(edgedetectData);
283
-        DKObject<GPUShader> CS_SH = DKOBJECT_NEW GPUShader(sharpenData);
281
+        DKObject<GPUShader> cs_e = DKOBJECT_NEW GPUShader(embossData);
282
+        DKObject<GPUShader> cs_ed = DKOBJECT_NEW GPUShader(edgedetectData);
283
+        DKObject<GPUShader> cs_sh = DKOBJECT_NEW GPUShader(sharpenData);
284 284
 
285
-        VS->InitializeGpuResource(graphicsQueue);
286
-        FS->InitializeGpuResource(graphicsQueue);
287
-
288
-        CS_E->InitializeGpuResource(computeQueue);
289
-        CS_ED->InitializeGpuResource(computeQueue);
290
-        CS_SH->InitializeGpuResource(computeQueue);
291
-
292
-        auto VSF = VS->Function();
293
-        auto FSF = FS->Function();
294
-        auto CS_EF = CS_E->Function();
295
-        auto CS_EDF = CS_ED->Function();
296
-        auto CS_SHF = CS_SH->Function();
285
+        vs->InitializeGpuResource(graphicsQueue);
286
+        fs->InitializeGpuResource(graphicsQueue);
297 287
 
288
+        cs_e->InitializeGpuResource(computeQueue);
289
+        cs_ed->InitializeGpuResource(computeQueue);
290
+        cs_sh->InitializeGpuResource(computeQueue);
298 291
 
292
+        auto vsf = vs->Function();
293
+        auto fsf = fs->Function();
294
+        auto cs_ef = cs_e->Function();
295
+        auto cs_edf = cs_ed->Function();
296
+        auto cs_shf = cs_sh->Function();
299 297
 
300 298
         // Texture Resource Initialize
301 299
         
@@ -312,8 +310,7 @@ public:
312 310
         computeSamplerDesc.compareFunction = DKCompareFunctionNever;
313 311
         DKObject<DKSamplerState> computeSampler = device->CreateSamplerState(computeSamplerDesc);
314 312
 
315
-
316
-		// create texture
313
+        // create texture
317 314
 		DKObject<DKTexture> texture = LoadTexture2D(graphicsQueue, resourcePool.LoadResourceData("textures/deathstar3.png"));
318 315
 		
319 316
         // create sampler
@@ -329,18 +326,18 @@ public:
329 326
 		
330 327
 		DKObject<DKSwapChain> swapChain = graphicsQueue->CreateSwapChain(window);
331 328
 
332
-		DKLog("VertexFunction.VertexAttributes: %d", VSF->StageInputAttributes().Count());
333
-		for (int i = 0; i < VSF->StageInputAttributes().Count(); ++i)
329
+		DKLog("VertexFunction.VertexAttributes: %d", vsf->StageInputAttributes().Count());
330
+		for (int i = 0; i < vsf->StageInputAttributes().Count(); ++i)
334 331
 		{
335
-			const DKShaderAttribute& attr = VSF->StageInputAttributes().Value(i);
332
+			const DKShaderAttribute& attr = vsf->StageInputAttributes().Value(i);
336 333
 			DKLog("  --> VertexAttribute[%d]: \"%ls\" (location:%u)", i, (const wchar_t*)attr.name, attr.location);
337 334
 		}
338 335
 
339 336
 		
340 337
 		DKRenderPipelineDescriptor pipelineDescriptor;
341 338
         // setup shader
342
-        pipelineDescriptor.vertexFunction = VSF;
343
-		pipelineDescriptor.fragmentFunction = FSF;
339
+        pipelineDescriptor.vertexFunction = vsf;
340
+		pipelineDescriptor.fragmentFunction = fsf;
344 341
         
345 342
         // setup color-attachment render-targets
346 343
 		pipelineDescriptor.colorAttachments.Resize(1);
@@ -354,7 +351,7 @@ public:
354 351
         pipelineDescriptor.depthStencilDescriptor.depthCompareFunction = DKCompareFunctionLessEqual;
355 352
    
356 353
         // setup vertex buffer and attributes
357
-        pipelineDescriptor.vertexDescriptor = Quad->VertexDescriptor();
354
+        pipelineDescriptor.vertexDescriptor = quad->VertexDescriptor();
358 355
 
359 356
         // setup topology and rasterization
360 357
 		pipelineDescriptor.primitiveTopology = DKPrimitiveType::Triangle;
@@ -403,7 +400,7 @@ public:
403 400
         //auto CS_SHF = CS_SH->Function();
404 401
 
405 402
         DKComputePipelineDescriptor embossComputePipelineDescriptor;
406
-        embossComputePipelineDescriptor.computeFunction = CS_EF;
403
+        embossComputePipelineDescriptor.computeFunction = cs_ef;
407 404
         auto Emboss = device->CreateComputePipeline(embossComputePipelineDescriptor);
408 405
         
409 406
         DKObject<DKTexture> depthBuffer = nullptr;
@@ -456,9 +453,7 @@ public:
456 453
                 if (computebindSet)
457 454
                 {
458 455
                     computebindSet->SetTexture(0, texture);
459
-                    //computebindSet->SetSamplerState(0, sampler);
460 456
                     computebindSet->SetTexture(1, targettex);
461
-                    //computebindSet->SetSamplerState(1, sampler);
462 457
                 }
463 458
                 computeEncoder->SetComputePipelineState(Emboss);
464 459
                 computeEncoder->SetResources(0, computebindSet);
@@ -479,11 +474,11 @@ public:
479 474
                 }
480 475
 
481 476
 				encoder->SetRenderPipelineState(pipelineState);
482
-				encoder->SetVertexBuffer(Quad->VertexBuffer(), 0, 0);
483
-				encoder->SetIndexBuffer(Quad->IndexBuffer(), 0, DKIndexType::UInt32);
477
+				encoder->SetVertexBuffer(quad->VertexBuffer(), 0, 0);
478
+				encoder->SetIndexBuffer(quad->IndexBuffer(), 0, DKIndexType::UInt32);
484 479
                 encoder->SetResources(0, graphicShaderBindingSet->PostcomputeDescSet());
485 480
 				// draw scene!
486
-				encoder->DrawIndexed(Quad->IndicesCount(), 1, 0, 0, 0);
481
+				encoder->DrawIndexed(quad->IndicesCount(), 1, 0, 0, 0);
487 482
                 encoder->EndEncoding();
488 483
 
489 484
                 if (computeCmdbuffer)
@@ -518,7 +513,7 @@ public:
518 513
                 DKApplication::Instance()->Terminate(0);
519 514
         }), NULL, NULL);
520 515
 
521
-        Quad = DKOBJECT_NEW UVQuad();
516
+        quad = DKOBJECT_NEW UVQuad();
522 517
 
523 518
 		runningRenderThread = 1;
524 519
 		renderThread = DKThread::Create(DKFunction(this, &MeshDemo::RenderThread)->Invocation());