Browse Source

ubo 바인딩.

Hongtae Kim 6 years ago
parent
commit
e6b378aa01
1 changed files with 33 additions and 0 deletions
  1. 33
    0
      TestApp1/TestApp1.cpp

+ 33
- 0
TestApp1/TestApp1.cpp View File

@@ -319,6 +319,39 @@ public:
319 319
             PrintPipelineReflection(&reflection, DKLogCategory::Verbose);
320 320
 		}
321 321
 
322
+        DKShaderBindingSetLayout layout;
323
+        DKObject<DKShaderBindingSet> bindSet = device->CreateShaderBindingSet(layout);
324
+        if (bindSet)
325
+        {
326
+            struct
327
+            {
328
+                DKMatrix4 projectionMatrix;
329
+                DKMatrix4 modelMatrix;
330
+                DKMatrix4 viewMatrix;
331
+            } ubo;
332
+
333
+            DKObject<DKGpuBuffer> uboBuffer = device->CreateBuffer(sizeof(ubo), DKGpuBuffer::StorageModePrivate, DKCpuCacheModeDefault);
334
+            if (uboBuffer)
335
+            {
336
+                ubo.projectionMatrix = DKMatrix4::identity;
337
+                ubo.modelMatrix = DKMatrix4::identity;
338
+                ubo.viewMatrix = DKMatrix4::identity;
339
+
340
+                void* p = uboBuffer->Lock(0);
341
+                if (p)
342
+                {
343
+                    memcpy(uboBuffer->Lock(0), &ubo, sizeof(ubo));
344
+                    uboBuffer->Unlock();
345
+
346
+                    bindSet->SetBuffer(0, uboBuffer);
347
+                }
348
+                else
349
+                {
350
+                    DKLogE("GpuBuffer Lock failed!");
351
+                }
352
+            }
353
+        }
354
+
322 355
 		DKTimer timer;
323 356
 		timer.Reset();
324 357