mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +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
@@ -250,13 +250,18 @@ TEST_F(WireTests, ReleaseCalledOnRefCount0) {
|
||||
// Test that the wire is able to send numerical values
|
||||
TEST_F(WireTests, ValueArgument) {
|
||||
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device);
|
||||
dawnCommandBufferBuilderDispatch(builder, 1, 2, 3);
|
||||
dawnComputePassEncoder pass = dawnCommandBufferBuilderBeginComputePass(builder);
|
||||
dawnComputePassEncoderDispatch(pass, 1, 2, 3);
|
||||
|
||||
dawnCommandBufferBuilder apiBuilder = api.GetNewCommandBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice))
|
||||
.WillOnce(Return(apiBuilder));
|
||||
|
||||
EXPECT_CALL(api, CommandBufferBuilderDispatch(apiBuilder, 1, 2, 3))
|
||||
dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
|
||||
EXPECT_CALL(api, CommandBufferBuilderBeginComputePass(apiBuilder))
|
||||
.WillOnce(Return(apiPass));
|
||||
|
||||
EXPECT_CALL(api, ComputePassEncoderDispatch(apiPass, 1, 2, 3))
|
||||
.Times(1);
|
||||
|
||||
FlushClient();
|
||||
@@ -281,13 +286,18 @@ bool CheckPushConstantValues(const uint32_t* values) {
|
||||
|
||||
TEST_F(WireTests, ValueArrayArgument) {
|
||||
dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device);
|
||||
dawnCommandBufferBuilderSetPushConstants(builder, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4, testPushConstantValues);
|
||||
dawnComputePassEncoder pass = dawnCommandBufferBuilderBeginComputePass(builder);
|
||||
dawnComputePassEncoderSetPushConstants(pass, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4, testPushConstantValues);
|
||||
|
||||
dawnCommandBufferBuilder apiBuilder = api.GetNewCommandBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice))
|
||||
.WillOnce(Return(apiBuilder));
|
||||
|
||||
EXPECT_CALL(api, CommandBufferBuilderSetPushConstants(apiBuilder, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4, ResultOf(CheckPushConstantValues, Eq(true))));
|
||||
dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
|
||||
EXPECT_CALL(api, CommandBufferBuilderBeginComputePass(apiBuilder))
|
||||
.WillOnce(Return(apiPass));
|
||||
|
||||
EXPECT_CALL(api, ComputePassEncoderSetPushConstants(apiPass, DAWN_SHADER_STAGE_BIT_VERTEX, 0, 4, ResultOf(CheckPushConstantValues, Eq(true))));
|
||||
|
||||
FlushClient();
|
||||
}
|
||||
@@ -318,28 +328,33 @@ TEST_F(WireTests, CStringArgument) {
|
||||
}
|
||||
|
||||
// Test that the wire is able to send objects as value arguments
|
||||
TEST_F(WireTests, ObjectAsValueArgument) {
|
||||
TEST_F(WireTests, DISABLED_ObjectAsValueArgument) {
|
||||
// Create pipeline
|
||||
dawnRenderPipelineBuilder pipelineBuilder = dawnDeviceCreateRenderPipelineBuilder(device);
|
||||
dawnRenderPipeline pipeline = dawnRenderPipelineBuilderGetResult(pipelineBuilder);
|
||||
dawnComputePipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.nextInChain = nullptr;
|
||||
pipelineDesc.layout = nullptr;
|
||||
pipelineDesc.entryPoint = "main";
|
||||
pipelineDesc.module = nullptr;
|
||||
dawnComputePipeline pipeline = dawnDeviceCreateComputePipeline(device, &pipelineDesc);
|
||||
|
||||
dawnRenderPipelineBuilder apiPipelineBuilder = api.GetNewRenderPipelineBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateRenderPipelineBuilder(apiDevice))
|
||||
.WillOnce(Return(apiPipelineBuilder));
|
||||
|
||||
dawnRenderPipeline apiPipeline = api.GetNewRenderPipeline();
|
||||
EXPECT_CALL(api, RenderPipelineBuilderGetResult(apiPipelineBuilder))
|
||||
dawnComputePipeline apiPipeline = api.GetNewComputePipeline();
|
||||
EXPECT_CALL(api, DeviceCreateComputePipeline(apiDevice, _))
|
||||
.WillOnce(Return(apiPipeline));
|
||||
|
||||
// Create command buffer builder, setting pipeline
|
||||
dawnCommandBufferBuilder cmdBufBuilder = dawnDeviceCreateCommandBufferBuilder(device);
|
||||
dawnCommandBufferBuilderSetRenderPipeline(cmdBufBuilder, pipeline);
|
||||
dawnComputePassEncoder pass = dawnCommandBufferBuilderBeginComputePass(cmdBufBuilder);
|
||||
dawnComputePassEncoderSetComputePipeline(pass, pipeline);
|
||||
|
||||
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice))
|
||||
.WillOnce(Return(apiCmdBufBuilder));
|
||||
|
||||
EXPECT_CALL(api, CommandBufferBuilderSetRenderPipeline(apiCmdBufBuilder, apiPipeline));
|
||||
dawnComputePassEncoder apiPass = api.GetNewComputePassEncoder();
|
||||
EXPECT_CALL(api, CommandBufferBuilderBeginComputePass(apiCmdBufBuilder))
|
||||
.WillOnce(Return(apiPass));
|
||||
|
||||
EXPECT_CALL(api, ComputePassEncoderSetComputePipeline(apiPass, apiPipeline));
|
||||
|
||||
FlushClient();
|
||||
}
|
||||
@@ -472,23 +487,33 @@ TEST_F(WireTests, StructureOfStructureArrayArgument) {
|
||||
|
||||
// Test that the server doesn't forward calls to error objects or with error objects
|
||||
// Also test that when GetResult is called on an error builder, the error callback is fired
|
||||
TEST_F(WireTests, CallsSkippedAfterBuilderError) {
|
||||
// TODO(cwallez@chromium.org): This test is disabled because the introduction of encoders breaks
|
||||
// the assumptions of the "builder error" handling that a builder is self-contained. We need to
|
||||
// revisit this once the new error handling is in place.
|
||||
TEST_F(WireTests, DISABLED_CallsSkippedAfterBuilderError) {
|
||||
dawnCommandBufferBuilder cmdBufBuilder = dawnDeviceCreateCommandBufferBuilder(device);
|
||||
dawnCommandBufferBuilderSetErrorCallback(cmdBufBuilder, ToMockBuilderErrorCallback, 1, 2);
|
||||
|
||||
dawnRenderPassEncoder pass = dawnCommandBufferBuilderBeginRenderPass(cmdBufBuilder, nullptr);
|
||||
|
||||
dawnBufferBuilder bufferBuilder = dawnDeviceCreateBufferBuilderForTesting(device);
|
||||
dawnBufferBuilderSetErrorCallback(bufferBuilder, ToMockBuilderErrorCallback, 3, 4);
|
||||
dawnBuffer buffer = dawnBufferBuilderGetResult(bufferBuilder); // Hey look an error!
|
||||
|
||||
// These calls will be skipped because of the error
|
||||
dawnBufferSetSubData(buffer, 0, 0, nullptr);
|
||||
dawnCommandBufferBuilderSetIndexBuffer(cmdBufBuilder, buffer, 0);
|
||||
dawnRenderPassEncoderSetIndexBuffer(pass, buffer, 0);
|
||||
dawnRenderPassEncoderEndPass(pass);
|
||||
dawnCommandBufferBuilderGetResult(cmdBufBuilder);
|
||||
|
||||
dawnCommandBufferBuilder apiCmdBufBuilder = api.GetNewCommandBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandBufferBuilder(apiDevice))
|
||||
.WillOnce(Return(apiCmdBufBuilder));
|
||||
|
||||
dawnRenderPassEncoder apiPass = api.GetNewRenderPassEncoder();
|
||||
EXPECT_CALL(api, CommandBufferBuilderBeginRenderPass(apiCmdBufBuilder, _))
|
||||
.WillOnce(Return(apiPass));
|
||||
|
||||
dawnBufferBuilder apiBufferBuilder = api.GetNewBufferBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateBufferBuilderForTesting(apiDevice))
|
||||
.WillOnce(Return(apiBufferBuilder));
|
||||
@@ -501,7 +526,7 @@ TEST_F(WireTests, CallsSkippedAfterBuilderError) {
|
||||
}));
|
||||
|
||||
EXPECT_CALL(api, BufferSetSubData(_, _, _, _)).Times(0);
|
||||
EXPECT_CALL(api, CommandBufferBuilderSetIndexBuffer(_, _, _)).Times(0);
|
||||
EXPECT_CALL(api, RenderPassEncoderSetIndexBuffer(_, _, _)).Times(0);
|
||||
EXPECT_CALL(api, CommandBufferBuilderGetResult(_)).Times(0);
|
||||
|
||||
FlushClient();
|
||||
|
||||
@@ -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