summaryrefslogtreecommitdiffstats
path: root/examples/gpu-printing/main.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-03-04 16:25:58 -0800
committerGitHub <noreply@github.com>2021-03-04 16:25:58 -0800
commita5ac4999b4dea546a7ef824669ab1809224b6448 (patch)
tree15bb22eb98a94f7f81489deef55396461501d3dc /examples/gpu-printing/main.cpp
parent13ff0bd345990c0fdfb7b52ebd5339cddb04889e (diff)
Refactor `gfx` to surface `CommandBuffer` interface. (#1735)
* Refactor `gfx` to surface `CommandBuffer` interface. * Fixes. * Fix code review issues, and make vulkan runnable on devices without VK_EXT_extended_dynamic_states. * Update solution files * Move out-of-date examples to examples/experimental Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'examples/gpu-printing/main.cpp')
-rw-r--r--examples/gpu-printing/main.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/examples/gpu-printing/main.cpp b/examples/gpu-printing/main.cpp
index 4f79147f6..63eb31a82 100644
--- a/examples/gpu-printing/main.cpp
+++ b/examples/gpu-printing/main.cpp
@@ -175,19 +175,26 @@ Result execute()
printBufferViewDesc.type = IResourceView::Type::UnorderedAccess;
auto printBufferView = gRenderer->createBufferView(printBuffer, printBufferViewDesc);
+ ICommandQueue::Desc queueDesc = {ICommandQueue::QueueType::Graphics};
+ auto queue = gRenderer->createCommandQueue(queueDesc);
+ auto commandBuffer = queue->createCommandBuffer();
+ auto encoder = commandBuffer->encodeComputeCommands();
// TODO: need to copy a zero into the start of the print buffer!
gDescriptorSet->setResource(0, 0, printBufferView);
- gRenderer->setDescriptorSet(PipelineType::Compute, gPipelineLayout, 0, gDescriptorSet);
-
- gRenderer->setPipelineState(gPipelineState);
- gRenderer->dispatchCompute(1, 1, 1);
+ encoder->setDescriptorSet(gPipelineLayout, 0, gDescriptorSet);
+ encoder->setPipelineState(gPipelineState);
+ encoder->dispatchCompute(1, 1, 1);
+ encoder->endEncoding();
+ commandBuffer->close();
+ queue->executeCommandBuffer(commandBuffer);
// TODO: need to copy from the print buffer to a staging buffer...
- auto printBufferData = (uint32_t*) gRenderer->map(printBuffer, MapFlavor::HostRead);
+ ComPtr<ISlangBlob> blob;
+ gRenderer->readBufferResource(printBuffer, 0, printBufferSize, blob.writeRef());
- gGPUPrinting.processGPUPrintCommands(printBufferData, printBufferSize);
+ gGPUPrinting.processGPUPrintCommands(blob->getBufferPointer(), printBufferSize);
return SLANG_OK;
}