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:
parent
292c0c31f2
commit
5e811aeee5
73
dawn.json
73
dawn.json
|
@ -275,6 +275,15 @@
|
|||
"char": {
|
||||
"category": "native"
|
||||
},
|
||||
"color": {
|
||||
"category": "structure",
|
||||
"members": [
|
||||
{"name": "r", "type": "float"},
|
||||
{"name": "g", "type": "float"},
|
||||
{"name": "b", "type": "float"},
|
||||
{"name": "a", "type": "float"}
|
||||
]
|
||||
},
|
||||
"color write mask": {
|
||||
"category": "bitmask",
|
||||
"values": [
|
||||
|
@ -678,6 +687,12 @@
|
|||
{"value": 1, "name": "load"}
|
||||
]
|
||||
},
|
||||
"store op": {
|
||||
"category": "enum",
|
||||
"values": [
|
||||
{"value": 0, "name": "store"}
|
||||
]
|
||||
},
|
||||
"origin 3D": {
|
||||
"category": "structure",
|
||||
"members": [
|
||||
|
@ -744,6 +759,31 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
|
||||
"render pass color attachment descriptor": {
|
||||
"category": "structure",
|
||||
"members": [
|
||||
{"name": "attachment", "type": "texture view"},
|
||||
{"name": "resolve target", "type": "texture view", "optional": true},
|
||||
{"name": "load op", "type": "load op"},
|
||||
{"name": "store op", "type": "store op"},
|
||||
{"name": "clear color", "type": "color"}
|
||||
]
|
||||
},
|
||||
|
||||
"render pass depth stencil attachment descriptor": {
|
||||
"category": "structure",
|
||||
"members": [
|
||||
{"name": "attachment", "type": "texture view"},
|
||||
{"name": "depth load op", "type": "load op"},
|
||||
{"name": "depth store op", "type": "store op"},
|
||||
{"name": "clear depth", "type": "float"},
|
||||
{"name": "stencil load op", "type": "load op"},
|
||||
{"name": "stencil store op", "type": "store op"},
|
||||
{"name": "clear stencil", "type": "uint32_t"}
|
||||
]
|
||||
},
|
||||
|
||||
"render pass descriptor builder": {
|
||||
"category": "object",
|
||||
"methods": [
|
||||
|
@ -752,41 +792,20 @@
|
|||
"returns": "render pass descriptor"
|
||||
},
|
||||
{
|
||||
"name": "set color attachment",
|
||||
"name": "set color attachments",
|
||||
"args": [
|
||||
{"name": "attachment slot", "type": "uint32_t"},
|
||||
{"name": "texture view", "type": "texture view"},
|
||||
{"name": "load op", "type": "load op"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set color attachment clear color",
|
||||
"TODO": "determine where to put these methods (probably BeginRenderPass?)",
|
||||
"args": [
|
||||
{"name": "attachment slot", "type": "uint32_t"},
|
||||
{"name": "clear r", "type": "float"},
|
||||
{"name": "clear g", "type": "float"},
|
||||
{"name": "clear b", "type": "float"},
|
||||
{"name": "clear a", "type": "float"}
|
||||
{"name": "count", "type": "uint32_t"},
|
||||
{"name": "color attachments", "type": "render pass color attachment descriptor", "annotation": "const*", "length": "count"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set depth stencil attachment",
|
||||
"args": [
|
||||
{"name": "texture view", "type": "texture view"},
|
||||
{"name": "depth load op", "type": "load op"},
|
||||
{"name": "stencil load op", "type": "load op"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set depth stencil attachment clear value",
|
||||
"TODO": "determine where to put these methods (probably BeginRenderPass?)",
|
||||
"args": [
|
||||
{"name": "clear depth", "type": "float"},
|
||||
{"name": "clear stencil", "type": "uint32_t"}
|
||||
{"name": "depth stencil attachment", "type": "render pass depth stencil attachment descriptor", "annotation": "const*"}
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"TODO": "Remove this builder and use render pass descriptor directly"
|
||||
},
|
||||
"render pass descriptor": {
|
||||
"category": "object"
|
||||
|
|
|
@ -127,7 +127,13 @@ void frame() {
|
|||
dawnRenderPassDescriptor renderpassInfo;
|
||||
{
|
||||
dawnRenderPassDescriptorBuilder builder = dawnDeviceCreateRenderPassDescriptorBuilder(device);
|
||||
dawnRenderPassDescriptorBuilderSetColorAttachment(builder, 0, backbufferView, DAWN_LOAD_OP_CLEAR);
|
||||
dawnRenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = backbufferView;
|
||||
colorAttachment.resolveTarget = nullptr;
|
||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
colorAttachment.loadOp = DAWN_LOAD_OP_CLEAR;
|
||||
colorAttachment.storeOp = DAWN_STORE_OP_STORE;
|
||||
dawnRenderPassDescriptorBuilderSetColorAttachments(builder, 1, &colorAttachment);
|
||||
renderpassInfo = dawnRenderPassDescriptorBuilderGetResult(builder);
|
||||
dawnRenderPassDescriptorBuilderRelease(builder);
|
||||
}
|
||||
|
|
|
@ -157,9 +157,25 @@ void GetNextRenderPassDescriptor(const dawn::Device& device,
|
|||
dawn::RenderPassDescriptor* info) {
|
||||
*backbuffer = swapchain.GetNextTexture();
|
||||
auto backbufferView = backbuffer->CreateDefaultTextureView();
|
||||
dawn::RenderPassColorAttachmentDescriptor colorAttachment;
|
||||
colorAttachment.attachment = backbufferView;
|
||||
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 = 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;
|
||||
|
||||
*info = device.CreateRenderPassDescriptorBuilder()
|
||||
.SetColorAttachment(0, backbufferView, dawn::LoadOp::Clear)
|
||||
.SetDepthStencilAttachment(depthStencilView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.SetDepthStencilAttachment(&depthStencilAttachment)
|
||||
.GetResult();
|
||||
}
|
||||
|
||||
|
|
|
@ -144,53 +144,52 @@ namespace dawn_native {
|
|||
return GetDevice()->CreateRenderPassDescriptor(this);
|
||||
}
|
||||
|
||||
void RenderPassDescriptorBuilder::SetColorAttachment(uint32_t attachment,
|
||||
TextureViewBase* textureView,
|
||||
dawn::LoadOp loadOp) {
|
||||
if (attachment >= kMaxColorAttachments) {
|
||||
HandleError("Setting color attachment out of bounds");
|
||||
void RenderPassDescriptorBuilder::SetColorAttachments(
|
||||
uint32_t count,
|
||||
const RenderPassColorAttachmentDescriptor* attachments) {
|
||||
if (count > kMaxColorAttachments) {
|
||||
HandleError("Setting color attachments out of bounds");
|
||||
return;
|
||||
}
|
||||
|
||||
if (textureView == nullptr) {
|
||||
HandleError("Texture view cannot be nullptr");
|
||||
return;
|
||||
}
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
// TODO(jiawei.shao@intel.com): support resolve target for multisample color attachment.
|
||||
if (attachments[i].resolveTarget != nullptr) {
|
||||
HandleError("Resolve target is not supported now");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsColorRenderableTextureFormat(textureView->GetFormat())) {
|
||||
HandleError(
|
||||
"The format of the texture view used as color attachment is not color renderable");
|
||||
return;
|
||||
}
|
||||
TextureViewBase* textureView = attachments[i].attachment;
|
||||
if (textureView == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CheckArrayLayersAndLevelCountForAttachment(textureView)) {
|
||||
return;
|
||||
}
|
||||
if (!IsColorRenderableTextureFormat(textureView->GetFormat())) {
|
||||
HandleError(
|
||||
"The format of the texture view used as color attachment is not color "
|
||||
"renderable");
|
||||
return;
|
||||
}
|
||||
|
||||
mColorAttachmentsSet.set(attachment);
|
||||
mColorAttachments[attachment].loadOp = loadOp;
|
||||
mColorAttachments[attachment].view = textureView;
|
||||
if (!CheckArrayLayersAndLevelCountForAttachment(textureView)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): set and make use of storeOp
|
||||
mColorAttachmentsSet.set(i);
|
||||
mColorAttachments[i].loadOp = attachments[i].loadOp;
|
||||
mColorAttachments[i].view = textureView;
|
||||
|
||||
mColorAttachments[i].clearColor[0] = attachments[i].clearColor.r;
|
||||
mColorAttachments[i].clearColor[1] = attachments[i].clearColor.g;
|
||||
mColorAttachments[i].clearColor[2] = attachments[i].clearColor.b;
|
||||
mColorAttachments[i].clearColor[3] = attachments[i].clearColor.a;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPassDescriptorBuilder::SetColorAttachmentClearColor(uint32_t attachment,
|
||||
float clearR,
|
||||
float clearG,
|
||||
float clearB,
|
||||
float clearA) {
|
||||
if (attachment >= kMaxColorAttachments) {
|
||||
HandleError("Setting color attachment out of bounds");
|
||||
return;
|
||||
}
|
||||
|
||||
mColorAttachments[attachment].clearColor[0] = clearR;
|
||||
mColorAttachments[attachment].clearColor[1] = clearG;
|
||||
mColorAttachments[attachment].clearColor[2] = clearB;
|
||||
mColorAttachments[attachment].clearColor[3] = clearA;
|
||||
}
|
||||
|
||||
void RenderPassDescriptorBuilder::SetDepthStencilAttachment(TextureViewBase* textureView,
|
||||
dawn::LoadOp depthLoadOp,
|
||||
dawn::LoadOp stencilLoadOp) {
|
||||
void RenderPassDescriptorBuilder::SetDepthStencilAttachment(
|
||||
const RenderPassDepthStencilAttachmentDescriptor* attachment) {
|
||||
TextureViewBase* textureView = attachment->attachment;
|
||||
if (textureView == nullptr) {
|
||||
HandleError("Texture view cannot be nullptr");
|
||||
return;
|
||||
|
@ -207,16 +206,13 @@ namespace dawn_native {
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): set and make use of depthStoreOp and stencilStoreOp
|
||||
mDepthStencilAttachmentSet = true;
|
||||
mDepthStencilAttachment.depthLoadOp = depthLoadOp;
|
||||
mDepthStencilAttachment.stencilLoadOp = stencilLoadOp;
|
||||
mDepthStencilAttachment.depthLoadOp = attachment->depthLoadOp;
|
||||
mDepthStencilAttachment.stencilLoadOp = attachment->stencilLoadOp;
|
||||
mDepthStencilAttachment.view = textureView;
|
||||
}
|
||||
|
||||
void RenderPassDescriptorBuilder::SetDepthStencilAttachmentClearValue(float clearDepth,
|
||||
uint32_t clearStencil) {
|
||||
mDepthStencilAttachment.clearDepth = clearDepth;
|
||||
mDepthStencilAttachment.clearStencil = clearStencil;
|
||||
mDepthStencilAttachment.clearDepth = attachment->clearDepth;
|
||||
mDepthStencilAttachment.clearStencil = attachment->clearStencil;
|
||||
}
|
||||
|
||||
} // namespace dawn_native
|
||||
|
|
|
@ -72,24 +72,18 @@ namespace dawn_native {
|
|||
uint32_t mHeight;
|
||||
};
|
||||
|
||||
// TODO(jiawei.shao@intel.com): remove RenderPassDescriptorBuilder and set data into
|
||||
// RenderPassDescriptor directly.
|
||||
class RenderPassDescriptorBuilder : public Builder<RenderPassDescriptorBase> {
|
||||
public:
|
||||
RenderPassDescriptorBuilder(DeviceBase* device);
|
||||
|
||||
// Dawn API
|
||||
RenderPassDescriptorBase* GetResultImpl() override;
|
||||
void SetColorAttachment(uint32_t attachment,
|
||||
TextureViewBase* textureView,
|
||||
dawn::LoadOp loadOp);
|
||||
void SetColorAttachmentClearColor(uint32_t attachment,
|
||||
float clearR,
|
||||
float clearG,
|
||||
float clearB,
|
||||
float clearA);
|
||||
void SetDepthStencilAttachment(TextureViewBase* textureView,
|
||||
dawn::LoadOp depthLoadOp,
|
||||
dawn::LoadOp stencilLoadOp);
|
||||
void SetDepthStencilAttachmentClearValue(float clearDepth, uint32_t clearStencil);
|
||||
void SetColorAttachments(uint32_t count,
|
||||
const RenderPassColorAttachmentDescriptor* attachments);
|
||||
void SetDepthStencilAttachment(
|
||||
const RenderPassDepthStencilAttachmentDescriptor* attachment);
|
||||
|
||||
private:
|
||||
friend class RenderPassDescriptorBase;
|
||||
|
|
|
@ -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"(
|
||||
|
|
|
@ -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"(
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -147,8 +147,14 @@ namespace utils {
|
|||
result.color = device.CreateTexture(&descriptor);
|
||||
|
||||
dawn::TextureView colorView = result.color.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;
|
||||
result.renderPassInfo = device.CreateRenderPassDescriptorBuilder()
|
||||
.SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
|
||||
.SetColorAttachments(1, &colorAttachment)
|
||||
.GetResult();
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue