mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 08:57:26 +00:00
Remove RenderPassDescriptorBuilder
This patch removes RenderPassDescriptorBuilder completely from Dawn. With this patch, RenderPassDescriptor is a structure instead of a Dawn object, and all the checks in RenderPassDescriptorBuilder are moved into CommandEncoder.cpp. This patch also updates the helper functions and structures related to RenderPassDescriptor because RenderPassDescriptor is no longer an object but a structure with members in pointers. BUG=dawn:6 Change-Id: Ic6d015582031891f35ffef912f0e460a9c010f81 Reviewed-on: https://dawn-review.googlesource.com/c/4902 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
738567f148
commit
b2c5023c9c
@@ -26,12 +26,12 @@ TEST_F(CommandBufferValidationTest, Empty) {
|
||||
|
||||
// Test that a command buffer cannot be ended mid render pass
|
||||
TEST_F(CommandBufferValidationTest, EndedMidRenderPass) {
|
||||
dawn::RenderPassDescriptor renderpass = CreateSimpleRenderPass();
|
||||
DummyRenderPass dummyRenderPass(device);
|
||||
|
||||
// Control case, command buffer ended after the pass is ended.
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
encoder.Finish();
|
||||
}
|
||||
@@ -39,7 +39,7 @@ TEST_F(CommandBufferValidationTest, EndedMidRenderPass) {
|
||||
// Error case, command buffer ended mid-pass.
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ TEST_F(CommandBufferValidationTest, EndedMidRenderPass) {
|
||||
// should fail too.
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
// TODO(cwallez@chromium.org) this should probably be a device error, but currently it
|
||||
// produces a encoder error.
|
||||
@@ -86,12 +86,12 @@ TEST_F(CommandBufferValidationTest, EndedMidComputePass) {
|
||||
|
||||
// Test that a render pass cannot be ended twice
|
||||
TEST_F(CommandBufferValidationTest, RenderPassEndedTwice) {
|
||||
dawn::RenderPassDescriptor renderpass = CreateSimpleRenderPass();
|
||||
DummyRenderPass dummyRenderPass(device);
|
||||
|
||||
// Control case, pass is ended once
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
encoder.Finish();
|
||||
}
|
||||
@@ -99,7 +99,7 @@ TEST_F(CommandBufferValidationTest, RenderPassEndedTwice) {
|
||||
// Error case, pass ended twice
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.EndPass();
|
||||
// TODO(cwallez@chromium.org) this should probably be a device error, but currently it
|
||||
// produces a encoder error.
|
||||
@@ -141,8 +141,8 @@ TEST_F(CommandBufferValidationTest, BufferWithMultipleReadUsage) {
|
||||
// Use the buffer as both index and vertex in the same pass
|
||||
uint32_t zero = 0;
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
auto renderpass = CreateSimpleRenderPass();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
DummyRenderPass dummyRenderPass(device);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.SetIndexBuffer(buffer, 0);
|
||||
pass.SetVertexBuffers(0, 1, &buffer, &zero);
|
||||
pass.EndPass();
|
||||
@@ -165,8 +165,8 @@ TEST_F(CommandBufferValidationTest, BufferWithReadAndWriteUsage) {
|
||||
|
||||
// Use the buffer as both index and storage in the same pass
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
auto renderpass = CreateSimpleRenderPass();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
DummyRenderPass dummyRenderPass(device);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&dummyRenderPass);
|
||||
pass.SetIndexBuffer(buffer, 0);
|
||||
pass.SetBindGroup(0, bg);
|
||||
pass.EndPass();
|
||||
@@ -194,19 +194,11 @@ TEST_F(CommandBufferValidationTest, TextureWithReadAndWriteUsage) {
|
||||
dawn::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}});
|
||||
|
||||
// Create the render pass that will use the texture as an output attachment
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = view;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Load;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
dawn::RenderPassDescriptor renderPass = device.CreateRenderPassDescriptorBuilder()
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({view});
|
||||
|
||||
// Use the texture as both sampeld and output attachment in the same pass
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetBindGroup(0, bg);
|
||||
pass.EndPass();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
|
||||
@@ -20,11 +20,11 @@ class DebugMarkerValidationTest : public ValidationTest {};
|
||||
|
||||
// Correct usage of debug markers should succeed in render pass.
|
||||
TEST_F(DebugMarkerValidationTest, RenderSuccess) {
|
||||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 4, 4);
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.PushDebugGroup("Event Start");
|
||||
pass.PushDebugGroup("Event Start");
|
||||
pass.InsertDebugMarker("Marker");
|
||||
@@ -38,11 +38,11 @@ TEST_F(DebugMarkerValidationTest, RenderSuccess) {
|
||||
|
||||
// A PushDebugGroup call without a following PopDebugGroup produces an error in render pass.
|
||||
TEST_F(DebugMarkerValidationTest, RenderUnbalancedPush) {
|
||||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 4, 4);
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.PushDebugGroup("Event Start");
|
||||
pass.PushDebugGroup("Event Start");
|
||||
pass.InsertDebugMarker("Marker");
|
||||
@@ -55,11 +55,11 @@ TEST_F(DebugMarkerValidationTest, RenderUnbalancedPush) {
|
||||
|
||||
// A PopDebugGroup call without a preceding PushDebugGroup produces an error in render pass.
|
||||
TEST_F(DebugMarkerValidationTest, RenderUnbalancedPop) {
|
||||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 4, 4);
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPassInfo);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.PushDebugGroup("Event Start");
|
||||
pass.InsertDebugMarker("Marker");
|
||||
pass.PopDebugGroup();
|
||||
|
||||
@@ -19,11 +19,11 @@ class SetScissorRectTest : public ValidationTest {
|
||||
|
||||
// Test to check basic use of SetScissor
|
||||
TEST_F(SetScissorRectTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetScissorRect(0, 0, 1, 1);
|
||||
pass.EndPass();
|
||||
}
|
||||
@@ -32,11 +32,11 @@ TEST_F(SetScissorRectTest, Success) {
|
||||
|
||||
// Test to check that an empty scissor is allowed
|
||||
TEST_F(SetScissorRectTest, EmptyScissor) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetScissorRect(0, 0, 0, 0);
|
||||
pass.EndPass();
|
||||
}
|
||||
@@ -47,11 +47,11 @@ TEST_F(SetScissorRectTest, EmptyScissor) {
|
||||
// TODO(cwallez@chromium.org): scissor values seem to be integers in all APIs do the same
|
||||
// and test negative values?
|
||||
TEST_F(SetScissorRectTest, ScissorLargerThanFramebuffer) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetScissorRect(0, 0, renderPass.width + 1, renderPass.height + 1);
|
||||
pass.EndPass();
|
||||
}
|
||||
@@ -63,11 +63,11 @@ class SetBlendColorTest : public ValidationTest {
|
||||
|
||||
// Test to check basic use of SetBlendColor
|
||||
TEST_F(SetBlendColorTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
constexpr dawn::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
pass.SetBlendColor(&kTransparentBlack);
|
||||
pass.EndPass();
|
||||
@@ -77,11 +77,11 @@ TEST_F(SetBlendColorTest, Success) {
|
||||
|
||||
// Test that SetBlendColor allows any value, large, small or negative
|
||||
TEST_F(SetBlendColorTest, AnyValueAllowed) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
constexpr dawn::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
|
||||
pass.SetBlendColor(&kAnyColorValue);
|
||||
pass.EndPass();
|
||||
@@ -94,11 +94,11 @@ class SetStencilReferenceTest : public ValidationTest {
|
||||
|
||||
// Test to check basic use of SetStencilReferenceTest
|
||||
TEST_F(SetStencilReferenceTest, Success) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetStencilReference(0);
|
||||
pass.EndPass();
|
||||
}
|
||||
@@ -107,11 +107,11 @@ TEST_F(SetStencilReferenceTest, Success) {
|
||||
|
||||
// Test that SetStencilReference allows any bit to be set
|
||||
TEST_F(SetStencilReferenceTest, AllBitsAllowed) {
|
||||
DummyRenderPass renderPass = CreateDummyRenderPass();
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPass.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetStencilReference(0xFFFFFFFF);
|
||||
pass.EndPass();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class PushConstantTest : public ValidationTest {
|
||||
|
||||
// Test valid usage of the parameters to SetPushConstants
|
||||
TEST_F(PushConstantTest, Success) {
|
||||
DummyRenderPass renderpassData = CreateDummyRenderPass();
|
||||
DummyRenderPass renderpassData(device);
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
// PushConstants in a compute pass
|
||||
@@ -56,7 +56,7 @@ TEST_F(PushConstantTest, Success) {
|
||||
|
||||
// PushConstants in a render pass
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderpassData);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
}
|
||||
@@ -142,12 +142,12 @@ TEST_F(PushConstantTest, StageForComputePass) {
|
||||
|
||||
// Test valid stages for render passes
|
||||
TEST_F(PushConstantTest, StageForRenderPass) {
|
||||
DummyRenderPass renderpassData = CreateDummyRenderPass();
|
||||
DummyRenderPass renderpassData(device);
|
||||
|
||||
// Control case: setting to vertex and fragment in render pass
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderpassData);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
encoder.Finish();
|
||||
@@ -156,7 +156,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
|
||||
// Compute stage is disallowed
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderpassData);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::Compute, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
@@ -165,7 +165,7 @@ TEST_F(PushConstantTest, StageForRenderPass) {
|
||||
// A None shader stage mask is valid.
|
||||
{
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpassData.renderPass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderpassData);
|
||||
pass.SetPushConstants(dawn::ShaderStageBit::None, 0, 1, constants);
|
||||
pass.EndPass();
|
||||
encoder.Finish();
|
||||
|
||||
@@ -16,9 +16,28 @@
|
||||
|
||||
#include "common/Constants.h"
|
||||
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class RenderPassDescriptorValidationTest : public ValidationTest {
|
||||
public:
|
||||
void AssertBeginRenderPassSuccess(const dawn::RenderPassDescriptor* descriptor) {
|
||||
dawn::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor);
|
||||
commandEncoder.Finish();
|
||||
}
|
||||
void AssertBeginRenderPassError(const dawn::RenderPassDescriptor* descriptor) {
|
||||
dawn::CommandEncoder commandEncoder = TestBeginRenderPass(descriptor);
|
||||
ASSERT_DEVICE_ERROR(commandEncoder.Finish());
|
||||
}
|
||||
|
||||
private:
|
||||
dawn::CommandEncoder TestBeginRenderPass(const dawn::RenderPassDescriptor* descriptor) {
|
||||
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||
dawn::RenderPassEncoder renderPassEncoder = commandEncoder.BeginRenderPass(descriptor);
|
||||
renderPassEncoder.EndPass();
|
||||
return commandEncoder;
|
||||
}
|
||||
};
|
||||
|
||||
dawn::Texture CreateTexture(dawn::Device& device,
|
||||
@@ -51,10 +70,10 @@ dawn::TextureView Create2DAttachment(dawn::Device& device,
|
||||
return texture.CreateDefaultTextureView();
|
||||
}
|
||||
|
||||
// A render pass with no attachments isn't valid
|
||||
TEST_F(RenderPassDescriptorValidationTest, Empty) {
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.GetResult();
|
||||
// Using BeginRenderPass with no attachments isn't valid
|
||||
TEST_F(RenderPassDescriptorValidationTest, Empty) {
|
||||
utils::ComboRenderPassDescriptor renderPass({}, nullptr);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// A render pass with only one color or one depth attachment is ok
|
||||
@@ -62,60 +81,67 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
|
||||
// One color attachment
|
||||
{
|
||||
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = color;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({color});
|
||||
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
// One depth-stencil attachment
|
||||
{
|
||||
dawn::TextureView depthStencil = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = depthStencil;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencil);
|
||||
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
// Test OOB color attachment indices are handled
|
||||
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
|
||||
dawn::TextureView color1 = Create2DAttachment(device, 1, 1,
|
||||
dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView color2 = Create2DAttachment(device, 1, 1,
|
||||
dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView color3 = Create2DAttachment(device, 1, 1,
|
||||
dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView color4 = Create2DAttachment(device, 1, 1,
|
||||
dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
// For setting the color attachment, control case
|
||||
{
|
||||
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachments[kMaxColorAttachments];
|
||||
colorAttachments[kMaxColorAttachments - 1].attachment = color;
|
||||
colorAttachments[kMaxColorAttachments - 1].resolveTarget = nullptr;
|
||||
colorAttachments[kMaxColorAttachments - 1].clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachments[kMaxColorAttachments - 1].loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachments[kMaxColorAttachments - 1].storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(kMaxColorAttachments, colorAttachments)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({color1, color2, color3, color4});
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
// For setting the color attachment, OOB
|
||||
{
|
||||
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachments[kMaxColorAttachments + 1];
|
||||
colorAttachments[kMaxColorAttachments].attachment = color;
|
||||
colorAttachments[kMaxColorAttachments].resolveTarget = nullptr;
|
||||
colorAttachments[kMaxColorAttachments].clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachments[kMaxColorAttachments].loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachments[kMaxColorAttachments].storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(kMaxColorAttachments + 1, colorAttachments)
|
||||
.GetResult();
|
||||
// We cannot use utils::ComboRenderPassDescriptor here because it only supports at most
|
||||
// kMaxColorAttachments(4) color attachments.
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment1;
|
||||
colorAttachment1.attachment = color1;
|
||||
colorAttachment1.resolveTarget = nullptr;
|
||||
colorAttachment1.clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
colorAttachment1.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment1.storeOp = dawn::StoreOp::Store;
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment2 = colorAttachment1;
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment3 = colorAttachment1;
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment4 = colorAttachment1;
|
||||
colorAttachment2.attachment = color2;
|
||||
colorAttachment3.attachment = color3;
|
||||
colorAttachment4.attachment = color4;
|
||||
|
||||
dawn::TextureView color5 = Create2DAttachment(device, 1, 1,
|
||||
dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment5 = colorAttachment1;
|
||||
colorAttachment5.attachment = color5;
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor* colorAttachments[] = {&colorAttachment1,
|
||||
&colorAttachment2,
|
||||
&colorAttachment3,
|
||||
&colorAttachment4,
|
||||
&colorAttachment5};
|
||||
dawn::RenderPassDescriptor renderPass;
|
||||
renderPass.colorAttachmentCount = kMaxColorAttachments + 1;
|
||||
renderPass.colorAttachments = colorAttachments;
|
||||
renderPass.depthStencilAttachment = nullptr;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,82 +151,25 @@ TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
|
||||
dawn::TextureView color1x1B = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
dawn::TextureView color2x2 = Create2DAttachment(device, 2, 2, dawn::TextureFormat::R8G8B8A8Unorm);
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment1x1A;
|
||||
colorAttachment1x1A.attachment = color1x1A;
|
||||
colorAttachment1x1A.resolveTarget = nullptr;
|
||||
colorAttachment1x1A.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment1x1A.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment1x1A.storeOp = dawn::StoreOp::Store;
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment1x1B;
|
||||
colorAttachment1x1B.attachment = color1x1B;
|
||||
colorAttachment1x1B.resolveTarget = nullptr;
|
||||
colorAttachment1x1B.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment1x1B.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment1x1B.storeOp = dawn::StoreOp::Store;
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment2x2;
|
||||
colorAttachment2x2.attachment = color2x2;
|
||||
colorAttachment2x2.resolveTarget = nullptr;
|
||||
colorAttachment2x2.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment2x2.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment2x2.storeOp = dawn::StoreOp::Store;
|
||||
|
||||
dawn::TextureView depthStencil1x1 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
|
||||
dawn::TextureView depthStencil2x2 = Create2DAttachment(device, 2, 2, dawn::TextureFormat::D32FloatS8Uint);
|
||||
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment1x1;
|
||||
depthStencilAttachment1x1.attachment = depthStencil1x1;
|
||||
depthStencilAttachment1x1.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment1x1.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment1x1.clearDepth = 1.0f;
|
||||
depthStencilAttachment1x1.clearStencil = 0;
|
||||
depthStencilAttachment1x1.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment1x1.stencilStoreOp = dawn::StoreOp::Store;
|
||||
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment2x2;
|
||||
depthStencilAttachment2x2.attachment = depthStencil2x2;
|
||||
depthStencilAttachment2x2.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment2x2.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment2x2.clearDepth = 1.0f;
|
||||
depthStencilAttachment2x2.clearStencil = 0;
|
||||
depthStencilAttachment2x2.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment2x2.stencilStoreOp = dawn::StoreOp::Store;
|
||||
|
||||
// Control case: all the same size (1x1)
|
||||
{
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachments[2];
|
||||
colorAttachments[0] = colorAttachment1x1A;
|
||||
colorAttachments[1] = colorAttachment1x1B;
|
||||
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(2, colorAttachments)
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment1x1)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({color1x1A, color1x1B}, depthStencil1x1);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// One of the color attachments has a different size
|
||||
{
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachments[2];
|
||||
colorAttachments[0] = colorAttachment1x1A;
|
||||
colorAttachments[1] = colorAttachment2x2;
|
||||
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(2, colorAttachments)
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment1x1)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({color1x1A, color2x2});
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// The depth stencil attachment has a different size
|
||||
{
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachments[2];
|
||||
colorAttachments[0] = colorAttachment1x1A;
|
||||
colorAttachments[1] = colorAttachment1x1B;
|
||||
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(2, colorAttachments)
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment2x2)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({color1x1A, color1x1B}, depthStencil2x2);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,31 +180,14 @@ TEST_F(RenderPassDescriptorValidationTest, FormatMismatch) {
|
||||
|
||||
// Using depth-stencil for color
|
||||
{
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = depthStencil;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({depthStencil});
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Using color for depth-stencil
|
||||
{
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = color;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({}, color);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,16 +221,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
||||
descriptor.arrayLayerCount = 5;
|
||||
|
||||
dawn::TextureView colorTextureView = colorTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorTextureView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D array texture view with arrayLayerCount > 1 is not allowed for depth stencil
|
||||
@@ -288,17 +232,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
||||
descriptor.arrayLayerCount = 5;
|
||||
|
||||
dawn::TextureView depthStencilView = depthStencilTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = depthStencilView;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D array texture view that covers the first layer of the texture is OK for color
|
||||
@@ -309,15 +244,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
||||
descriptor.arrayLayerCount = 1;
|
||||
|
||||
dawn::TextureView colorTextureView = colorTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorTextureView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D array texture view that covers the first layer is OK for depth stencil
|
||||
@@ -327,19 +255,9 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
||||
descriptor.baseArrayLayer = 0;
|
||||
descriptor.arrayLayerCount = 1;
|
||||
|
||||
dawn::TextureView depthStencilTextureView =
|
||||
depthStencilTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = depthStencilTextureView;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
dawn::TextureView depthStencilView = depthStencilTexture.CreateTextureView(&descriptor);
|
||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D array texture view that covers the last layer is OK for color
|
||||
@@ -350,15 +268,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
||||
descriptor.arrayLayerCount = 1;
|
||||
|
||||
dawn::TextureView colorTextureView = colorTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorTextureView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D array texture view that covers the last layer is OK for depth stencil
|
||||
@@ -368,19 +279,9 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
|
||||
descriptor.baseArrayLayer = kArrayLayers - 1;
|
||||
descriptor.arrayLayerCount = 1;
|
||||
|
||||
dawn::TextureView depthStencilTextureView =
|
||||
depthStencilTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = depthStencilTextureView;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
dawn::TextureView depthStencilView = depthStencilTexture.CreateTextureView(&descriptor);
|
||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,15 +314,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
||||
descriptor.mipLevelCount = 2;
|
||||
|
||||
dawn::TextureView colorTextureView = colorTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorTextureView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D texture view with mipLevelCount > 1 is not allowed for depth stencil
|
||||
@@ -431,17 +325,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
||||
descriptor.mipLevelCount = 2;
|
||||
|
||||
dawn::TextureView depthStencilView = depthStencilTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = depthStencilView;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D texture view that covers the first level of the texture is OK for color
|
||||
@@ -452,15 +337,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
||||
descriptor.mipLevelCount = 1;
|
||||
|
||||
dawn::TextureView colorTextureView = colorTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorTextureView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D texture view that covers the first level is OK for depth stencil
|
||||
@@ -470,19 +348,9 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
||||
descriptor.baseMipLevel = 0;
|
||||
descriptor.mipLevelCount = 1;
|
||||
|
||||
dawn::TextureView depthStencilTextureView =
|
||||
depthStencilTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = depthStencilTextureView;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
dawn::TextureView depthStencilView = depthStencilTexture.CreateTextureView(&descriptor);
|
||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D texture view that covers the last level is OK for color
|
||||
@@ -493,15 +361,8 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
||||
descriptor.mipLevelCount = 1;
|
||||
|
||||
dawn::TextureView colorTextureView = colorTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorTextureView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
|
||||
// Using 2D texture view that covers the last level is OK for depth stencil
|
||||
@@ -511,19 +372,9 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
|
||||
descriptor.baseMipLevel = kLevelCount - 1;
|
||||
descriptor.mipLevelCount = 1;
|
||||
|
||||
dawn::TextureView depthStencilTextureView =
|
||||
depthStencilTexture.CreateTextureView(&descriptor);
|
||||
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
|
||||
depthStencilAttachment.attachment = depthStencilTextureView;
|
||||
depthStencilAttachment.depthLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
depthStencilAttachment.clearDepth = 1.0f;
|
||||
depthStencilAttachment.clearStencil = 0;
|
||||
depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
|
||||
depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
|
||||
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
dawn::TextureView depthStencilView = depthStencilTexture.CreateTextureView(&descriptor);
|
||||
utils::ComboRenderPassDescriptor renderPass({}, depthStencilView);
|
||||
AssertBeginRenderPassSuccess(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,15 +398,9 @@ TEST_F(RenderPassDescriptorValidationTest, ResolveTarget) {
|
||||
dawn::TextureView colorTextureView = colorTexture.CreateDefaultTextureView();
|
||||
dawn::TextureView resolveTargetTextureView = resolveTexture.CreateDefaultTextureView();
|
||||
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorTextureView;
|
||||
colorAttachment.resolveTarget = resolveTargetTextureView;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
|
||||
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTargetTextureView;
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,31 +84,6 @@ std::string ValidationTest::GetLastDeviceErrorMessage() const {
|
||||
return mDeviceErrorMessage;
|
||||
}
|
||||
|
||||
dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.size.width = 640;
|
||||
descriptor.size.height = 480;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.arrayLayerCount = 1;
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
descriptor.mipLevelCount = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
||||
|
||||
auto colorBuffer = device.CreateTexture(&descriptor);
|
||||
auto colorView = colorBuffer.CreateDefaultTextureView();
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = colorView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
return device.CreateRenderPassDescriptorBuilder()
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
void ValidationTest::OnDeviceError(const char* message, dawnCallbackUserdata userdata) {
|
||||
auto self = reinterpret_cast<ValidationTest*>(static_cast<uintptr_t>(userdata));
|
||||
self->mDeviceErrorMessage = message;
|
||||
@@ -138,34 +113,30 @@ void ValidationTest::OnBuilderErrorStatus(dawnBuilderErrorStatus status, const c
|
||||
expectation.statusMessage = message;
|
||||
}
|
||||
|
||||
ValidationTest::DummyRenderPass ValidationTest::CreateDummyRenderPass() {
|
||||
DummyRenderPass dummy;
|
||||
dummy.width = 400;
|
||||
dummy.height = 400;
|
||||
dummy.attachmentFormat = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
ValidationTest::DummyRenderPass::DummyRenderPass(const dawn::Device& device)
|
||||
: attachmentFormat(dawn::TextureFormat::R8G8B8A8Unorm), width(400), height(400) {
|
||||
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.size.width = dummy.width;
|
||||
descriptor.size.height = dummy.height;
|
||||
descriptor.size.width = width;
|
||||
descriptor.size.height = height;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.arrayLayerCount = 1;
|
||||
descriptor.sampleCount = 1;
|
||||
descriptor.format = dummy.attachmentFormat;
|
||||
descriptor.format = attachmentFormat;
|
||||
descriptor.mipLevelCount = 1;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
|
||||
dummy.attachment = device.CreateTexture(&descriptor);
|
||||
attachment = device.CreateTexture(&descriptor);
|
||||
|
||||
dawn::TextureView view = dummy.attachment.CreateDefaultTextureView();
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = view;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
colorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
dummy.renderPass = AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
dawn::TextureView view = attachment.CreateDefaultTextureView();
|
||||
mColorAttachment.attachment = view;
|
||||
mColorAttachment.resolveTarget = nullptr;
|
||||
mColorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
mColorAttachment.loadOp = dawn::LoadOp::Clear;
|
||||
mColorAttachment.storeOp = dawn::StoreOp::Store;
|
||||
mColorAttachments[0] = &mColorAttachment;
|
||||
|
||||
return dummy;
|
||||
colorAttachmentCount = 1;
|
||||
colorAttachments = mColorAttachments;
|
||||
depthStencilAttachment = nullptr;
|
||||
}
|
||||
|
||||
@@ -53,18 +53,20 @@ class ValidationTest : public testing::Test {
|
||||
bool EndExpectDeviceError();
|
||||
std::string GetLastDeviceErrorMessage() const;
|
||||
|
||||
dawn::RenderPassDescriptor CreateSimpleRenderPass();
|
||||
|
||||
// Helper functions to create objects to test validation.
|
||||
|
||||
struct DummyRenderPass {
|
||||
dawn::RenderPassDescriptor renderPass;
|
||||
struct DummyRenderPass : public dawn::RenderPassDescriptor{
|
||||
public:
|
||||
DummyRenderPass(const dawn::Device& device);
|
||||
dawn::Texture attachment;
|
||||
dawn::TextureFormat attachmentFormat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
private:
|
||||
dawn::RenderPassColorAttachmentDescriptor mColorAttachment;
|
||||
dawn::RenderPassColorAttachmentDescriptor* mColorAttachments[1];
|
||||
};
|
||||
DummyRenderPass CreateDummyRenderPass();
|
||||
|
||||
protected:
|
||||
dawn::Device device;
|
||||
|
||||
@@ -24,8 +24,6 @@ class VertexBufferValidationTest : public ValidationTest {
|
||||
void SetUp() override {
|
||||
ValidationTest::SetUp();
|
||||
|
||||
renderpass = CreateSimpleRenderPass();
|
||||
|
||||
fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
|
||||
#version 450
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
@@ -99,11 +97,11 @@ class VertexBufferValidationTest : public ValidationTest {
|
||||
return device.CreateRenderPipeline(&descriptor);
|
||||
}
|
||||
|
||||
dawn::RenderPassDescriptor renderpass;
|
||||
dawn::ShaderModule fsModule;
|
||||
};
|
||||
|
||||
TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
||||
DummyRenderPass renderPass(device);
|
||||
auto vsModule2 = MakeVertexShader(2);
|
||||
auto vsModule1 = MakeVertexShader(1);
|
||||
|
||||
@@ -119,7 +117,7 @@ TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
||||
// Check failure when vertex buffer is not set
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
@@ -129,7 +127,7 @@ TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
||||
// Check success when vertex buffer is inherited from previous pipeline
|
||||
encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline2);
|
||||
pass.SetVertexBuffers(0, 2, vertexBuffers.data(), offsets);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
@@ -141,6 +139,7 @@ TEST_F(VertexBufferValidationTest, VertexInputsInheritedBetweenPipelines) {
|
||||
}
|
||||
|
||||
TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
||||
DummyRenderPass renderPass(device);
|
||||
auto vsModule2 = MakeVertexShader(2);
|
||||
auto vsModule1 = MakeVertexShader(1);
|
||||
|
||||
@@ -156,14 +155,14 @@ TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
||||
// Check success when vertex buffer is set for each render pass
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.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 = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.SetVertexBuffers(0, 1, vertexBuffers.data(), offsets);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
@@ -174,14 +173,14 @@ TEST_F(VertexBufferValidationTest, VertexInputsNotInheritedBetweenRendePasses) {
|
||||
// Check failure because vertex buffer is not inherited in second subpass
|
||||
encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.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 = encoder.BeginRenderPass(renderpass);
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||
pass.SetPipeline(pipeline1);
|
||||
pass.Draw(3, 1, 0, 0);
|
||||
pass.EndPass();
|
||||
|
||||
@@ -179,34 +179,31 @@ TEST_F(WireArgumentTests, CStringArgument) {
|
||||
FlushClient();
|
||||
}
|
||||
|
||||
|
||||
// Test that the wire is able to send objects as value arguments
|
||||
TEST_F(WireArgumentTests, ObjectAsValueArgument) {
|
||||
// Create a RenderPassDescriptor
|
||||
dawnRenderPassDescriptorBuilder renderPassBuilder =
|
||||
dawnDeviceCreateRenderPassDescriptorBuilder(device);
|
||||
dawnRenderPassDescriptor renderPass =
|
||||
dawnRenderPassDescriptorBuilderGetResult(renderPassBuilder);
|
||||
|
||||
dawnRenderPassDescriptorBuilder apiRenderPassBuilder = api.GetNewRenderPassDescriptorBuilder();
|
||||
EXPECT_CALL(api, DeviceCreateRenderPassDescriptorBuilder(apiDevice))
|
||||
.WillOnce(Return(apiRenderPassBuilder));
|
||||
dawnRenderPassDescriptor apiRenderPass = api.GetNewRenderPassDescriptor();
|
||||
EXPECT_CALL(api, RenderPassDescriptorBuilderGetResult(apiRenderPassBuilder))
|
||||
.WillOnce(Return(apiRenderPass));
|
||||
|
||||
// Create command buffer encoder, setting render pass descriptor
|
||||
dawnCommandEncoder cmdBufEncoder = dawnDeviceCreateCommandEncoder(device);
|
||||
dawnCommandEncoderBeginRenderPass(cmdBufEncoder, renderPass);
|
||||
dawnCommandEncoder apiEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice)).WillOnce(Return(apiEncoder));
|
||||
|
||||
dawnCommandEncoder apiCmdBufEncoder = api.GetNewCommandEncoder();
|
||||
EXPECT_CALL(api, DeviceCreateCommandEncoder(apiDevice))
|
||||
.WillOnce(Return(apiCmdBufEncoder));
|
||||
dawnBufferDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.size = 8;
|
||||
descriptor.usage = static_cast<dawnBufferUsageBit>(DAWN_BUFFER_USAGE_BIT_TRANSFER_SRC |
|
||||
DAWN_BUFFER_USAGE_BIT_TRANSFER_DST);
|
||||
|
||||
EXPECT_CALL(api, CommandEncoderBeginRenderPass(apiCmdBufEncoder, apiRenderPass)).Times(1);
|
||||
dawnBuffer buffer = dawnDeviceCreateBuffer(device, &descriptor);
|
||||
dawnBuffer apiBuffer = api.GetNewBuffer();
|
||||
EXPECT_CALL(api, DeviceCreateBuffer(apiDevice, _))
|
||||
.WillOnce(Return(apiBuffer))
|
||||
.RetiresOnSaturation();
|
||||
|
||||
dawnCommandEncoderCopyBufferToBuffer(cmdBufEncoder, buffer, 0, buffer, 4, 4);
|
||||
EXPECT_CALL(api, CommandEncoderCopyBufferToBuffer(apiEncoder, apiBuffer, 0, apiBuffer, 4, 4));
|
||||
|
||||
EXPECT_CALL(api, CommandEncoderRelease(apiEncoder));
|
||||
EXPECT_CALL(api, BufferRelease(apiBuffer));
|
||||
|
||||
EXPECT_CALL(api, CommandEncoderRelease(apiCmdBufEncoder));
|
||||
EXPECT_CALL(api, RenderPassDescriptorBuilderRelease(apiRenderPassBuilder));
|
||||
EXPECT_CALL(api, RenderPassDescriptorRelease(apiRenderPass));
|
||||
FlushClient();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user