From 3f1632a1450a5879f337b4bd178e48880cd583f8 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 31 Mar 2021 11:35:17 -0700 Subject: `gfx` explicit transient resource management. (#1774) --- examples/shader-object/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'examples/shader-object') diff --git a/examples/shader-object/main.cpp b/examples/shader-object/main.cpp index aaafc010a..9329a5418 100644 --- a/examples/shader-object/main.cpp +++ b/examples/shader-object/main.cpp @@ -136,8 +136,15 @@ int main() // interacting with the graphics API. Slang::ComPtr device; IDevice::Desc deviceDesc = {}; + deviceDesc.deviceType = DeviceType::Vulkan; SLANG_RETURN_ON_FAIL(gfxCreateDevice(&deviceDesc, device.writeRef())); + Slang::ComPtr transientHeap; + ITransientResourceHeap::Desc transientHeapDesc = {}; + transientHeapDesc.constantBufferSize = 4096; + SLANG_RETURN_ON_FAIL( + device->createTransientResourceHeap(transientHeapDesc, transientHeap.writeRef())); + // Now we can load the shader code. // A `gfx::IShaderProgram` object for use in the `gfx` layer. ComPtr shaderProgram; @@ -212,7 +219,8 @@ int main() { ICommandQueue::Desc queueDesc = {ICommandQueue::QueueType::Graphics}; auto queue = device->createCommandQueue(queueDesc); - auto commandBuffer = queue->createCommandBuffer(); + + auto commandBuffer = transientHeap->createCommandBuffer(); auto encoder = commandBuffer->encodeComputeCommands(); encoder->setPipelineState(pipelineState); encoder->bindRootShaderObject(rootObject); -- cgit v1.2.3