Add render pass color and depth stencil attachment descriptor

This patch is the first one of the descriptorization of render pass. In
this patch we add support of RenderPassColorAttachmentDescriptor
and RenderPassDepthStencilAttachmentDescriptor to
RenderPassDescriptorBuilder.

This patch also adds StoreOp to render pass color and depth stencil
attachment descriptor.

RenderPassDescriptorBuilder will be completely removed in the next
patch.

BUG=dawn:6, dawn:49
TEST=dawn_end2end_tests, dawn_unittests

Change-Id: If623b41d04016425efa53932ae1648daf2263675
Reviewed-on: https://dawn-review.googlesource.com/c/3300
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Jiawei Shao
2018-12-19 08:21:13 +00:00
committed by Commit Bot service account
parent 292c0c31f2
commit 5e811aeee5
13 changed files with 429 additions and 184 deletions

View File

@@ -728,11 +728,17 @@ TEST_P(BlendStateTest, IndependentBlendState) {
renderTargetViews[i] = renderTargets[i].CreateDefaultTextureView();
}
dawn::RenderPassColorAttachmentDescriptor colorAttachments[4];
for (uint32_t i = 0; i < 4; ++i) {
colorAttachments[i].attachment = renderTargetViews[i];
colorAttachments[i].resolveTarget = nullptr;
colorAttachments[i].clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
colorAttachments[i].loadOp = dawn::LoadOp::Clear;
colorAttachments[i].storeOp = dawn::StoreOp::Store;
}
dawn::RenderPassDescriptor renderpass = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetViews[0], dawn::LoadOp::Clear)
.SetColorAttachment(1, renderTargetViews[1], dawn::LoadOp::Clear)
.SetColorAttachment(2, renderTargetViews[2], dawn::LoadOp::Clear)
.SetColorAttachment(3, renderTargetViews[3], dawn::LoadOp::Clear)
.SetColorAttachments(4, colorAttachments)
.GetResult();
dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(

View File

@@ -53,9 +53,24 @@ class DepthStencilStateTest : public DawnTest {
depthTextureView = depthTexture.CreateDefaultTextureView();
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
colorAttachment.attachment = renderTargetView;
colorAttachment.resolveTarget = nullptr;
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
colorAttachment.loadOp = dawn::LoadOp::Clear;
colorAttachment.storeOp = dawn::StoreOp::Store;
dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
depthStencilAttachment.attachment = depthTextureView;
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;
renderpass = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthTextureView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(

View File

@@ -112,12 +112,16 @@ class RenderPassLoadOpTests : public DawnTest {
// Tests clearing, loading, and drawing into color attachments
TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
colorAttachment.attachment = renderTargetView;
colorAttachment.resolveTarget = nullptr;
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
colorAttachment.loadOp = dawn::LoadOp::Clear;
colorAttachment.storeOp = dawn::StoreOp::Store;
// Part 1: clear once, check to make sure it's cleared
auto renderPassClearZero = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(0, 0.0f, 0.0f, 0.0f, 0.0f)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
auto commandsClearZeroBuilder = device.CreateCommandBufferBuilder();
@@ -125,9 +129,10 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
clearZeroPass.EndPass();
auto commandsClearZero = commandsClearZeroBuilder.GetResult();
dawn::RenderPassColorAttachmentDescriptor colorAttachmentGreen = colorAttachment;
colorAttachmentGreen.clearColor = { 0.0f, 1.0f, 0.0f, 1.0f };
auto renderPassClearGreen = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(0, 0.0f, 1.0f, 0.0f, 1.0f)
.SetColorAttachments(1, &colorAttachmentGreen)
.GetResult();
auto commandsClearGreenBuilder = device.CreateCommandBufferBuilder();
@@ -142,9 +147,10 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
EXPECT_TEXTURE_RGBA8_EQ(expectGreen.data(), renderTarget, 0, 0, kRTSize, kRTSize, 0, 0);
// Part 2: draw a blue quad into the right half of the render target, and check result
dawn::RenderPassColorAttachmentDescriptor colorAttachmentLoad = colorAttachment;
colorAttachmentLoad.loadOp = dawn::LoadOp::Load;
auto renderPassLoad = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, renderTargetView, dawn::LoadOp::Load)
.SetColorAttachments(1, &colorAttachmentLoad)
.GetResult();
dawn::CommandBuffer commandsLoad;

View File

@@ -490,9 +490,14 @@ class TextureViewRenderingTest : public DawnTest {
dawn::ShaderModule vsModule = CreateDefaultVertexShaderModule(device);
// Clear textureView with Red(255, 0, 0, 255) and render Green(0, 255, 0, 255) into it
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
colorAttachment.attachment = textureView;
colorAttachment.resolveTarget = nullptr;
colorAttachment.clearColor = { 1.0, 0.0, 0.0, 1.0 };
colorAttachment.loadOp = dawn::LoadOp::Clear;
colorAttachment.storeOp = dawn::StoreOp::Store;
dawn::RenderPassDescriptor renderPassInfo = device.CreateRenderPassDescriptorBuilder()
.SetColorAttachment(0, textureView, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(0, 1.0, 0.0, 0.0, 1.0)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
const char* oneColorFragmentShader = R"(

View File

@@ -149,8 +149,14 @@ 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()
.SetColorAttachment(0, view, dawn::LoadOp::Load)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
// Use the texture as both sampeld and output attachment in the same pass

View File

@@ -62,15 +62,29 @@ 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())
.SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
// 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(depthStencil, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
}
@@ -80,58 +94,27 @@ TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
// 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())
.SetColorAttachment(kMaxColorAttachments - 1, color, dawn::LoadOp::Clear)
.SetColorAttachments(kMaxColorAttachments, colorAttachments)
.GetResult();
}
// 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())
.SetColorAttachment(kMaxColorAttachments, color, dawn::LoadOp::Clear)
.GetResult();
}
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
// For setting the clear color, control case
{
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(kMaxColorAttachments - 1, 0.0f, 0.0f, 0.0f, 0.0f)
.GetResult();
}
// For setting the clear color, OOB
{
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(kMaxColorAttachments, 0.0f, 0.0f, 0.0f, 0.0f)
.GetResult();
}
}
// Test setting a clear value without an attachment and vice-versa is ok.
TEST_F(RenderPassDescriptorValidationTest, ClearAndAttachmentMismatchIsOk) {
dawn::TextureView color = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
// For cleared attachment 0 doesn't get a color, clear color for 1 is unused
{
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetColorAttachmentClearColor(1, 0.0f, 0.0f, 0.0f, 0.0f)
.GetResult();
}
// Clear depth stencil doesn't get values
{
dawn::TextureView depthStencil = Create2DAttachment(device, 1, 1, dawn::TextureFormat::D32FloatS8Uint);
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetDepthStencilAttachment(depthStencil, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.GetResult();
}
// Clear values for depth-stencil when it isn't used
{
AssertWillBeSuccess(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color, dawn::LoadOp::Clear)
.SetDepthStencilAttachmentClearValue(0.0f, 0)
.SetColorAttachments(kMaxColorAttachments + 1, colorAttachments)
.GetResult();
}
}
@@ -141,33 +124,82 @@ TEST_F(RenderPassDescriptorValidationTest, SizeMustMatch) {
dawn::TextureView color1x1A = Create2DAttachment(device, 1, 1, dawn::TextureFormat::R8G8B8A8Unorm);
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())
.SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
.SetColorAttachment(1, color1x1B, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthStencil1x1, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetColorAttachments(2, colorAttachments)
.SetDepthStencilAttachment(&depthStencilAttachment1x1)
.GetResult();
}
// One of the color attachments has a different size
{
dawn::RenderPassColorAttachmentDescriptor colorAttachments[2];
colorAttachments[0] = colorAttachment1x1A;
colorAttachments[1] = colorAttachment2x2;
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
.SetColorAttachment(1, color2x2, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthStencil1x1, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetColorAttachments(2, colorAttachments)
.SetDepthStencilAttachment(&depthStencilAttachment1x1)
.GetResult();
}
// The depth stencil attachment has a different size
{
dawn::RenderPassColorAttachmentDescriptor colorAttachments[2];
colorAttachments[0] = colorAttachment1x1A;
colorAttachments[1] = colorAttachment1x1B;
AssertWillBeError(device.CreateRenderPassDescriptorBuilder())
.SetColorAttachment(0, color1x1A, dawn::LoadOp::Clear)
.SetColorAttachment(1, color1x1B, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(depthStencil2x2, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetColorAttachments(2, colorAttachments)
.SetDepthStencilAttachment(&depthStencilAttachment2x2)
.GetResult();
}
}
@@ -179,15 +211,30 @@ 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())
.SetColorAttachment(0, depthStencil, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
// 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(color, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
}
@@ -222,8 +269,15 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
descriptor.layerCount = 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())
.SetColorAttachment(0, colorTextureView, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
@@ -234,8 +288,16 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
descriptor.layerCount = 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(depthStencilView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
@@ -247,8 +309,14 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
descriptor.layerCount = 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())
.SetColorAttachment(0, colorTextureView, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
@@ -261,9 +329,16 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
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(
depthStencilTextureView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
@@ -275,8 +350,14 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
descriptor.layerCount = 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())
.SetColorAttachment(0, colorTextureView, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
@@ -289,9 +370,16 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLayerCountForColorAndDepth
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(
depthStencilTextureView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
}
@@ -325,8 +413,14 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
descriptor.levelCount = 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())
.SetColorAttachment(0, colorTextureView, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
@@ -337,8 +431,16 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
descriptor.levelCount = 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(depthStencilView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
@@ -350,8 +452,14 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
descriptor.levelCount = 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())
.SetColorAttachment(0, colorTextureView, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
@@ -364,9 +472,16 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
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(
depthStencilTextureView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
@@ -378,8 +493,14 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
descriptor.levelCount = 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())
.SetColorAttachment(0, colorTextureView, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
@@ -392,9 +513,48 @@ TEST_F(RenderPassDescriptorValidationTest, TextureViewLevelCountForColorAndDepth
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(
depthStencilTextureView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
.SetDepthStencilAttachment(&depthStencilAttachment)
.GetResult();
}
}
// Tests on the resolve target of RenderPassColorAttachmentDescriptor.
// TODO(jiawei.shao@intel.com): add more tests when we support multisample color attachments.
TEST_F(RenderPassDescriptorValidationTest, ResolveTarget) {
constexpr uint32_t kArrayLayers = 1;
constexpr uint32_t kSize = 32;
constexpr dawn::TextureFormat kColorFormat = dawn::TextureFormat::R8G8B8A8Unorm;
constexpr uint32_t kLevelCount = 1;
dawn::Texture colorTexture = CreateTexture(
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, kLevelCount);
dawn::Texture resolveTexture = CreateTexture(
device, dawn::TextureDimension::e2D, kColorFormat, kSize, kSize, kArrayLayers, kLevelCount);
// It is not allowed to set resolve target when the sample count of the color attachment is 1.
{
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();
}
}

View File

@@ -87,9 +87,14 @@ dawn::RenderPassDescriptor ValidationTest::CreateSimpleRenderPass() {
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()
.SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
}
@@ -141,9 +146,14 @@ ValidationTest::DummyRenderPass ValidationTest::CreateDummyRenderPass() {
dummy.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())
.SetColorAttachment(0, view, dawn::LoadOp::Clear)
.SetColorAttachments(1, &colorAttachment)
.GetResult();
return dummy;