mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
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>
This commit is contained in:
committed by
Commit Bot service account
parent
31d1e78d57
commit
82fbccbd78
@@ -27,11 +27,16 @@ TEST_F(CommandBufferValidationTest, Empty) {
|
||||
TEST_F(CommandBufferValidationTest, RenderPass) {
|
||||
auto renderpass = CreateSimpleRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpass)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpass)
|
||||
.GetResult();
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
builder.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,36 +17,30 @@
|
||||
class SetScissorRectTest : public ValidationTest {
|
||||
};
|
||||
|
||||
// Test to check that SetScissor can only be used inside render passes
|
||||
TEST_F(SetScissorRectTest, AllowedOnlyInRenderPass) {
|
||||
// Test to check basic use of SetScissor
|
||||
TEST_F(SetScissorRectTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderPass.renderPass)
|
||||
.SetScissorRect(0, 0, 1, 1)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.SetScissorRect(0, 0, 1, 1)
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetScissorRect(0, 0, 1, 1)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetScissorRect(0, 0, 1, 1);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// Test to check that an empty scissor is allowed
|
||||
TEST_F(SetScissorRectTest, EmptyScissor) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderPass.renderPass)
|
||||
.SetScissorRect(0, 0, 0, 0)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetScissorRect(0, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// Test to check that a scissor larger than the framebuffer is allowed
|
||||
@@ -55,79 +49,69 @@ TEST_F(SetScissorRectTest, EmptyScissor) {
|
||||
TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderPass.renderPass)
|
||||
.SetScissorRect(0, 0, renderPass.width + 1, renderPass.height + 1)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetScissorRect(0, 0, renderPass.width + 1, renderPass.height + 1);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
class SetBlendColorTest : public ValidationTest {
|
||||
};
|
||||
|
||||
// Test to check that SetBlendColor can only be used inside render passes
|
||||
TEST_F(SetBlendColorTest, AllowedOnlyInRenderPass) {
|
||||
// Test to check basic use of SetBlendColor
|
||||
TEST_F(SetBlendColorTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderPass.renderPass)
|
||||
.SetBlendColor(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.SetBlendColor(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetBlendColor(0.0f, 0.0f, 0.0f, 0.0f)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetBlendColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// Test that SetBlendColor allows any value, large, small or negative
|
||||
TEST_F(SetBlendColorTest, AnyValueAllowed) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderPass.renderPass)
|
||||
.SetBlendColor(-1.0f, 42.0f, -0.0f, 0.0f)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetBlendColor(-1.0f, 42.0f, -0.0f, 0.0f);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
class SetStencilReferenceTest : public ValidationTest {
|
||||
};
|
||||
|
||||
// Test to check that SetStencilReference can only be used inside render passes
|
||||
TEST_F(SetStencilReferenceTest, AllowedOnlyInRenderPass) {
|
||||
// Test to check basic use of SetBlendColor
|
||||
TEST_F(SetStencilReferenceTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderPass.renderPass)
|
||||
.SetStencilReference(0)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.SetStencilReference(0)
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetStencilReference(0)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetStencilReference(0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// Test that SetStencilReference allows any bit to be set
|
||||
TEST_F(SetStencilReferenceTest, AllBitsAllowed) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderPass.renderPass)
|
||||
.SetStencilReference(0xFFFFFFFF)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetStencilReference(0xFFFFFFFF);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
@@ -46,28 +46,36 @@ class PushConstantTest : public ValidationTest {
|
||||
TEST_F(PushConstantTest, Success) {
|
||||
DummyRenderPass renderpassData = CreateDummyRenderPass();
|
||||
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
// PushConstants in a compute pass
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
// PushConstants in a compute pass
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
// PushConstants in a render pass
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
// PushConstants in a render pass
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
// Setting all constants
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
|
||||
.EndComputePass()
|
||||
// Setting all constants
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
// Setting constants at an offset
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, kMaxPushConstants - 1, 1, constants)
|
||||
.EndComputePass()
|
||||
// Setting constants at an offset
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, kMaxPushConstants - 1, 1, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
.GetResult();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// Test check for constants being set out of bounds
|
||||
@@ -76,45 +84,29 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
|
||||
|
||||
// Control case: setting all constants
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// OOB because count is too big.
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants + 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants + 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// OOB because of the offset.
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 1, kMaxPushConstants, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
// Test which places push constants can be set
|
||||
TEST_F(PushConstantTest, NotInPass) {
|
||||
DummyRenderPass renderpassData = CreateDummyRenderPass();
|
||||
|
||||
// Setting outside of any pass is invalid.
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.GetResult();
|
||||
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants)
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 1, kMaxPushConstants, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,29 +114,29 @@ TEST_F(PushConstantTest, NotInPass) {
|
||||
TEST_F(PushConstantTest, StageForComputePass) {
|
||||
// Control case: setting to the compute stage in compute passes
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// Graphics stages are disallowed
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// A None shader stage mask is valid.
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginComputePass()
|
||||
.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants)
|
||||
.EndComputePass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,29 +146,29 @@ TEST_F(PushConstantTest, StageForRenderPass) {
|
||||
|
||||
// Control case: setting to vertex and fragment in render pass
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// Compute stage is disallowed
|
||||
{
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
// A None shader stage mask is valid.
|
||||
{
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpassData.renderPass)
|
||||
.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,23 +104,27 @@ TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
||||
uint32_t offsets[] = { 0, 0 };
|
||||
|
||||
// Check failure when vertex buffer is not set
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpass)
|
||||
.SetRenderPipeline(pipeline1)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
pass.SetRenderPipeline(pipeline1);
|
||||
pass.DrawArrays(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
|
||||
// Check success when vertex buffer is inherited from previous pipeline
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpass)
|
||||
.SetRenderPipeline(pipeline2)
|
||||
.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.SetRenderPipeline(pipeline1)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
pass.SetRenderPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.DrawArrays(3, 1, 0, 0);
|
||||
pass.SetRenderPipeline(pipeline1);
|
||||
pass.DrawArrays(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
||||
@@ -137,29 +141,37 @@ TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
||||
uint32_t offsets[] = { 0, 0 };
|
||||
|
||||
// Check success when vertex buffer is set for each render pass
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpass)
|
||||
.SetRenderPipeline(pipeline2)
|
||||
.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderPass()
|
||||
.BeginRenderPass(renderpass)
|
||||
.SetRenderPipeline(pipeline1)
|
||||
.SetVertexBuffers(0, 1, vertexBuffers.data(), offsets)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
pass.SetRenderPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.DrawArrays(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
pass.SetRenderPipeline(pipeline1);
|
||||
pass.SetVertexBuffers(0, 1, vertexBuffers.data(), offsets);
|
||||
pass.DrawArrays(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
|
||||
// Check failure because vertex buffer is not inherited in second subpass
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.BeginRenderPass(renderpass)
|
||||
.SetRenderPipeline(pipeline2)
|
||||
.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderPass()
|
||||
.BeginRenderPass(renderpass)
|
||||
.SetRenderPipeline(pipeline1)
|
||||
.DrawArrays(3, 1, 0, 0)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
pass.SetRenderPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.DrawArrays(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
pass.SetRenderPipeline(pipeline1);
|
||||
pass.DrawArrays(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user