WebGPU error handling 3: CommandEncoder for validation tests
BUG=dawn:8 Change-Id: I16ad900387adcbaf793177e97a96a5f19dcc47a0 Reviewed-on: https://dawn-review.googlesource.com/c/4760 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
e1f0d4e639
commit
695b68d100
|
@ -21,8 +21,7 @@ class CommandBufferValidationTest : public ValidationTest {
|
|||
|
||||
// Test for an empty command buffer
|
||||
TEST_F(CommandBufferValidationTest, Empty) {
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.GetResult();
|
||||
device.CreateCommandEncoder().Finish();
|
||||
}
|
||||
|
||||
// Test that a command buffer cannot be ended mid render pass
|
||||
|
@ -31,27 +30,27 @@ TEST_F(CommandBufferValidationTest, EndedMidRenderPass) {
|
|||
|
||||
// Control case, command buffer ended after the pass is ended.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Error case, command buffer ended mid-pass.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// Error case, command buffer ended mid-pass. Trying to use encoders after GetResult
|
||||
// Error case, command buffer ended mid-pass. Trying to use encoders after Finish
|
||||
// should fail too.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
// TODO(cwallez@chromium.org) this should probably be a device error, but currently it
|
||||
// produces a builder error.
|
||||
// produces a encoder error.
|
||||
pass.EndPass();
|
||||
}
|
||||
}
|
||||
|
@ -60,27 +59,27 @@ TEST_F(CommandBufferValidationTest, EndedMidRenderPass) {
|
|||
TEST_F(CommandBufferValidationTest, EndedMidComputePass) {
|
||||
// Control case, command buffer ended after the pass is ended.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Error case, command buffer ended mid-pass.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// Error case, command buffer ended mid-pass. Trying to use encoders after GetResult
|
||||
// Error case, command buffer ended mid-pass. Trying to use encoders after Finish
|
||||
// should fail too.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
// TODO(cwallez@chromium.org) this should probably be a device error, but currently it
|
||||
// produces a builder error.
|
||||
// produces a encoder error.
|
||||
pass.EndPass();
|
||||
}
|
||||
}
|
||||
|
@ -91,21 +90,21 @@ TEST_F(CommandBufferValidationTest, RenderPassEndedTwice) {
|
|||
|
||||
// Control case, pass is ended once
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Error case, pass ended twice
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.EndPass();
|
||||
// TODO(cwallez@chromium.org) this should probably be a device error, but currently it
|
||||
// produces a builder error.
|
||||
// produces a encoder error.
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,21 +112,21 @@ TEST_F(CommandBufferValidationTest, RenderPassEndedTwice) {
|
|||
TEST_F(CommandBufferValidationTest, ComputePassEndedTwice) {
|
||||
// Control case, pass is ended once.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Error case, pass ended twice
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.EndPass();
|
||||
// TODO(cwallez@chromium.org) this should probably be a device error, but currently it
|
||||
// produces a builder error.
|
||||
// produces a encoder error.
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,13 +140,13 @@ TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
|
|||
|
||||
// Use the buffer as both index and vertex in the same pass
|
||||
uint32_t zero = 0;
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
auto renderpass = CreateSimpleRenderPass();
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetIndexBuffer(buffer, 0);
|
||||
pass.SetVertexBuffers(0, 1, &buffer, &zero);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Test that using the same buffer as both readable and writable in the same pass is disallowed
|
||||
|
@ -165,13 +164,13 @@ TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
|
|||
dawn::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}});
|
||||
|
||||
// Use the buffer as both index and storage in the same pass
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
auto renderpass = CreateSimpleRenderPass();
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetIndexBuffer(buffer, 0);
|
||||
pass.SetBindGroup(0, bg);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// Test that using the same texture as both readable and writable in the same pass is disallowed
|
||||
|
@ -206,9 +205,9 @@ TEST_F(CommandBufferValidationTest, TextureWithReadAndWriteUsage) {
|
|||
.GetResult();
|
||||
|
||||
// Use the texture as both sampeld and output attachment in the same pass
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
pass.SetBindGroup(0, bg);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
|
|
@ -64,16 +64,13 @@ class CopyCommandTest : public ValidationTest {
|
|||
dawn::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(destTexture, destLevel, destSlice, destOrigin);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &extent3D);
|
||||
|
||||
if (expectation == utils::Expectation::Success) {
|
||||
dawn::CommandBuffer commands =
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &extent3D)
|
||||
.GetResult();
|
||||
encoder.Finish();
|
||||
} else {
|
||||
dawn::CommandBuffer commands =
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToTexture(&bufferCopyView, &textureCopyView, &extent3D)
|
||||
.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,16 +89,13 @@ class CopyCommandTest : public ValidationTest {
|
|||
dawn::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(srcTexture, srcLevel, srcSlice, srcOrigin);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, &extent3D);
|
||||
|
||||
if (expectation == utils::Expectation::Success) {
|
||||
dawn::CommandBuffer commands =
|
||||
AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, &extent3D)
|
||||
.GetResult();
|
||||
encoder.Finish();
|
||||
} else {
|
||||
dawn::CommandBuffer commands =
|
||||
AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, &extent3D)
|
||||
.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -118,20 +112,20 @@ TEST_F(CopyCommandTest_B2B, Success) {
|
|||
|
||||
// Copy different copies, including some that touch the OOB condition
|
||||
{
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 0, destination, 0, 16)
|
||||
.CopyBufferToBuffer(source, 8, destination, 0, 8)
|
||||
.CopyBufferToBuffer(source, 0, destination, 8, 8)
|
||||
.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(source, 0, destination, 0, 16);
|
||||
encoder.CopyBufferToBuffer(source, 8, destination, 0, 8);
|
||||
encoder.CopyBufferToBuffer(source, 0, destination, 8, 8);
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Empty copies are valid
|
||||
{
|
||||
dawn::CommandBuffer commands = AssertWillBeSuccess(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 0, destination, 0, 0)
|
||||
.CopyBufferToBuffer(source, 0, destination, 16, 0)
|
||||
.CopyBufferToBuffer(source, 16, destination, 0, 0)
|
||||
.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(source, 0, destination, 0, 0);
|
||||
encoder.CopyBufferToBuffer(source, 0, destination, 16, 0);
|
||||
encoder.CopyBufferToBuffer(source, 16, destination, 0, 0);
|
||||
encoder.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,16 +136,16 @@ TEST_F(CopyCommandTest_B2B, OutOfBounds) {
|
|||
|
||||
// OOB on the source
|
||||
{
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 8, destination, 0, 12)
|
||||
.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(source, 8, destination, 0, 12);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// OOB on the destination
|
||||
{
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 0, destination, 8, 12)
|
||||
.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(source, 0, destination, 8, 12);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,16 +157,16 @@ TEST_F(CopyCommandTest_B2B, BadUsage) {
|
|||
|
||||
// Source with incorrect usage
|
||||
{
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(vertex, 0, destination, 0, 16)
|
||||
.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(vertex, 0, destination, 0, 16);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// Destination with incorrect usage
|
||||
{
|
||||
dawn::CommandBuffer commands = AssertWillBeError(device.CreateCommandBufferBuilder())
|
||||
.CopyBufferToBuffer(source, 0, vertex, 0, 16)
|
||||
.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(source, 0, vertex, 0, 16);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,26 +21,26 @@ class SetScissorRectTest : public ValidationTest {
|
|||
TEST_F(SetScissorRectTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetScissorRect(0, 0, 1, 1);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Test to check that an empty scissor is allowed
|
||||
TEST_F(SetScissorRectTest, EmptyScissor) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetScissorRect(0, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Test to check that a scissor larger than the framebuffer is allowed
|
||||
|
@ -49,13 +49,13 @@ TEST_F(SetScissorRectTest, EmptyScissor) {
|
|||
TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetScissorRect(0, 0, renderPass.width + 1, renderPass.height + 1);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
class SetBlendColorTest : public ValidationTest {
|
||||
|
@ -65,28 +65,28 @@ class SetBlendColorTest : public ValidationTest {
|
|||
TEST_F(SetBlendColorTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
constexpr dawn::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
pass.SetBlendColor(&kTransparentBlack);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Test that SetBlendColor allows any value, large, small or negative
|
||||
TEST_F(SetBlendColorTest, AnyValueAllowed) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
constexpr dawn::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
|
||||
pass.SetBlendColor(&kAnyColorValue);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
class SetStencilReferenceTest : public ValidationTest {
|
||||
|
@ -96,24 +96,24 @@ class SetStencilReferenceTest : public ValidationTest {
|
|||
TEST_F(SetStencilReferenceTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetStencilReference(0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Test that SetStencilReference allows any bit to be set
|
||||
TEST_F(SetStencilReferenceTest, AllBitsAllowed) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
pass.SetStencilReference(0xFFFFFFFF);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
|
|
@ -46,67 +46,67 @@ class PushConstantTest : public ValidationTest {
|
|||
TEST_F(PushConstantTest, Success) {
|
||||
DummyRenderPass renderpassData = CreateDummyRenderPass();
|
||||
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
// PushConstants in a compute pass
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
// PushConstants in a render pass
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
// Setting all constants
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
// Setting constants at an offset
|
||||
{
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, kMaxPushConstants - 1, 1, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Test check for constants being set out of bounds
|
||||
TEST_F(PushConstantTest, SetPushConstantsOOB) {
|
||||
uint32_t constants[kMaxPushConstants] = {0};
|
||||
|
||||
|
||||
// Control case: setting all constants
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// OOB because count is too big.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, kMaxPushConstants + 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// OOB because of the offset.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 1, kMaxPushConstants, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,29 +114,29 @@ TEST_F(PushConstantTest, SetPushConstantsOOB) {
|
|||
TEST_F(PushConstantTest, StageForComputePass) {
|
||||
// Control case: setting to the compute stage in compute passes
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Graphics stages are disallowed
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// A None shader stage mask is valid.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::ComputePassEncoder pass = builder.BeginComputePass();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,29 +146,29 @@ TEST_F(PushConstantTest, StageForRenderPass) {
|
|||
|
||||
// Control case: setting to vertex and fragment in render pass
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// Compute stage is disallowed
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// A None shader stage mask is valid.
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ TEST_F(QueueSubmitValidationTest, SubmitWithMappedBuffer) {
|
|||
// Create a command buffer that reads from the mappable buffer.
|
||||
dawn::CommandBuffer commands;
|
||||
{
|
||||
dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
|
||||
builder.CopyBufferToBuffer(buffer, 0, targetBuffer, 0, 4);
|
||||
commands = builder.GetResult();
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyBufferToBuffer(buffer, 0, targetBuffer, 0, 4);
|
||||
commands = encoder.Finish();
|
||||
}
|
||||
|
||||
dawn::Queue queue = device.CreateQueue();
|
||||
|
|
|
@ -117,19 +117,19 @@ TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
|||
uint32_t offsets[] = { 0, 0 };
|
||||
|
||||
// Check failure when vertex buffer is not set
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
|
||||
// Check success when vertex buffer is inherited from previous pipeline
|
||||
builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
|
@ -137,7 +137,7 @@ TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
|||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
||||
|
@ -154,37 +154,37 @@ TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
|||
uint32_t offsets[] = { 0, 0 };
|
||||
|
||||
// Check success when vertex buffer is set for each render pass
|
||||
dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.SetVertexBuffers(0, 1, vertexBuffers.data(), offsets);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
encoder.Finish();
|
||||
|
||||
// Check failure because vertex buffer is not inherited in second subpass
|
||||
builder = AssertWillBeError(device.CreateCommandBufferBuilder());
|
||||
encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
{
|
||||
dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
builder.GetResult();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue