Introduce [Render|Compute]PassEncoder.
This splits off part of CommandBufferBuilder in separate
RenderPassEncoder and ComputePassEncoder objects. To match the WebGPU
IDL and factor some code, both these encoders inherit from
ProgrammablePassEncoder.
These encoders are pure frontend objects and record into the
CommandBufferBuilder command allocator objects, so no changes to the
backends were needed.
Error handling is still ew, because the "builder" mechanism we had
doesn't allow for "split builders". Nicer error handling will have to
wait on Dawn matching WebGPU.
All the tests and samples were updated to the new structure.
BUG=dawn:5
Change-Id: I5f5d4ad866e2c07fedd1ba7a122258c6610941f1
Reviewed-on: https://dawn-review.googlesource.com/1543
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp
index 4a69710..77b2ad8 100644
--- a/examples/ComputeBoids.cpp
+++ b/examples/ComputeBoids.cpp
@@ -261,21 +261,26 @@
dawn::CommandBuffer createCommandBuffer(const dawn::RenderPassDescriptor& renderPass, size_t i) {
static const uint32_t zeroOffsets[1] = {0};
auto& bufferDst = particleBuffers[(i + 1) % 2];
- return device.CreateCommandBufferBuilder()
- .BeginComputePass()
- .SetComputePipeline(updatePipeline)
- .SetBindGroup(0, updateBGs[i])
- .Dispatch(kNumParticles, 1, 1)
- .EndComputePass()
+ dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
- .BeginRenderPass(renderPass)
- .SetRenderPipeline(renderPipeline)
- .SetVertexBuffers(0, 1, &bufferDst, zeroOffsets)
- .SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets)
- .DrawArrays(3, kNumParticles, 0, 0)
- .EndRenderPass()
+ {
+ dawn::ComputePassEncoder pass = builder.BeginComputePass();
+ pass.SetComputePipeline(updatePipeline);
+ pass.SetBindGroup(0, updateBGs[i]);
+ pass.Dispatch(kNumParticles, 1, 1);
+ pass.EndPass();
+ }
- .GetResult();
+ {
+ dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+ pass.SetRenderPipeline(renderPipeline);
+ pass.SetVertexBuffers(0, 1, &bufferDst, zeroOffsets);
+ pass.SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets);
+ pass.DrawArrays(3, kNumParticles, 0, 0);
+ pass.EndPass();
+ }
+
+ return builder.GetResult();
}
void init() {