Remove indirection for colorAttachments
This is to match the work in progress webgpu.h header.
BUG=dawn:22
Change-Id: I1371cda1b7666de8eb8283fa7e5da935d17e1d52
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9381
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/dawn.json b/dawn.json
index c20a4c8..7fe8cfe 100644
--- a/dawn.json
+++ b/dawn.json
@@ -929,7 +929,7 @@
"category": "structure",
"members": [
{"name": "color attachment count", "type": "uint32_t"},
- {"name": "color attachments", "type": "render pass color attachment descriptor", "annotation": "const*const*", "length": "color attachment count"},
+ {"name": "color attachments", "type": "render pass color attachment descriptor", "annotation": "const*", "length": "color attachment count"},
{"name": "depth stencil attachment", "type": "render pass depth stencil attachment descriptor", "annotation": "const*", "optional": true}
]
},
diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp
index c5642ee..e04bd8e 100644
--- a/examples/CHelloTriangle.cpp
+++ b/examples/CHelloTriangle.cpp
@@ -128,7 +128,6 @@
DawnTextureView backbufferView = dawnTextureCreateView(backbuffer, nullptr);
DawnRenderPassDescriptor renderpassInfo;
DawnRenderPassColorAttachmentDescriptor colorAttachment;
- DawnRenderPassColorAttachmentDescriptor* colorAttachments = {&colorAttachment};
{
colorAttachment.attachment = backbufferView;
colorAttachment.resolveTarget = nullptr;
@@ -136,7 +135,7 @@
colorAttachment.loadOp = DAWN_LOAD_OP_CLEAR;
colorAttachment.storeOp = DAWN_STORE_OP_STORE;
renderpassInfo.colorAttachmentCount = 1;
- renderpassInfo.colorAttachments = &colorAttachments;
+ renderpassInfo.colorAttachments = &colorAttachment;
renderpassInfo.depthStencilAttachment = nullptr;
}
DawnCommandBuffer commands;
diff --git a/src/dawn_native/AttachmentState.cpp b/src/dawn_native/AttachmentState.cpp
index d21b018..febf6d6 100644
--- a/src/dawn_native/AttachmentState.cpp
+++ b/src/dawn_native/AttachmentState.cpp
@@ -45,7 +45,7 @@
AttachmentStateBlueprint::AttachmentStateBlueprint(const RenderPassDescriptor* descriptor) {
for (uint32_t i = 0; i < descriptor->colorAttachmentCount; ++i) {
- TextureViewBase* attachment = descriptor->colorAttachments[i]->attachment;
+ TextureViewBase* attachment = descriptor->colorAttachments[i].attachment;
mColorAttachmentsSet.set(i);
mColorFormats[i] = attachment->GetFormat().format;
if (mSampleCount == 0) {
diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp
index e3bf712..0c5208e 100644
--- a/src/dawn_native/CommandEncoder.cpp
+++ b/src/dawn_native/CommandEncoder.cpp
@@ -310,39 +310,40 @@
MaybeError ValidateResolveTarget(
const DeviceBase* device,
- const RenderPassColorAttachmentDescriptor* colorAttachment) {
- if (colorAttachment->resolveTarget == nullptr) {
+ const RenderPassColorAttachmentDescriptor& colorAttachment) {
+ if (colorAttachment.resolveTarget == nullptr) {
return {};
}
- DAWN_TRY(device->ValidateObject(colorAttachment->resolveTarget));
+ const TextureViewBase* resolveTarget = colorAttachment.resolveTarget;
+ const TextureViewBase* attachment = colorAttachment.attachment;
+ DAWN_TRY(device->ValidateObject(colorAttachment.resolveTarget));
- if (!colorAttachment->attachment->GetTexture()->IsMultisampledTexture()) {
+ if (!attachment->GetTexture()->IsMultisampledTexture()) {
return DAWN_VALIDATION_ERROR(
"Cannot set resolve target when the sample count of the color attachment is 1");
}
- if (colorAttachment->resolveTarget->GetTexture()->IsMultisampledTexture()) {
+ if (resolveTarget->GetTexture()->IsMultisampledTexture()) {
return DAWN_VALIDATION_ERROR("Cannot use multisampled texture as resolve target");
}
- if (colorAttachment->resolveTarget->GetLayerCount() > 1) {
+ if (resolveTarget->GetLayerCount() > 1) {
return DAWN_VALIDATION_ERROR(
"The array layer count of the resolve target must be 1");
}
- if (colorAttachment->resolveTarget->GetLevelCount() > 1) {
+ if (resolveTarget->GetLevelCount() > 1) {
return DAWN_VALIDATION_ERROR("The mip level count of the resolve target must be 1");
}
- uint32_t colorAttachmentBaseMipLevel = colorAttachment->attachment->GetBaseMipLevel();
- const Extent3D& colorTextureSize = colorAttachment->attachment->GetTexture()->GetSize();
+ uint32_t colorAttachmentBaseMipLevel = attachment->GetBaseMipLevel();
+ const Extent3D& colorTextureSize = attachment->GetTexture()->GetSize();
uint32_t colorAttachmentWidth = colorTextureSize.width >> colorAttachmentBaseMipLevel;
uint32_t colorAttachmentHeight = colorTextureSize.height >> colorAttachmentBaseMipLevel;
- uint32_t resolveTargetBaseMipLevel = colorAttachment->resolveTarget->GetBaseMipLevel();
- const Extent3D& resolveTextureSize =
- colorAttachment->resolveTarget->GetTexture()->GetSize();
+ uint32_t resolveTargetBaseMipLevel = resolveTarget->GetBaseMipLevel();
+ const Extent3D& resolveTextureSize = resolveTarget->GetTexture()->GetSize();
uint32_t resolveTargetWidth = resolveTextureSize.width >> resolveTargetBaseMipLevel;
uint32_t resolveTargetHeight = resolveTextureSize.height >> resolveTargetBaseMipLevel;
if (colorAttachmentWidth != resolveTargetWidth ||
@@ -351,9 +352,8 @@
"The size of the resolve target must be the same as the color attachment");
}
- dawn::TextureFormat resolveTargetFormat =
- colorAttachment->resolveTarget->GetFormat().format;
- if (resolveTargetFormat != colorAttachment->attachment->GetFormat().format) {
+ dawn::TextureFormat resolveTargetFormat = resolveTarget->GetFormat().format;
+ if (resolveTargetFormat != attachment->GetFormat().format) {
return DAWN_VALIDATION_ERROR(
"The format of the resolve target must be the same as the color attachment");
}
@@ -363,15 +363,13 @@
MaybeError ValidateRenderPassColorAttachment(
const DeviceBase* device,
- const RenderPassColorAttachmentDescriptor* colorAttachment,
+ const RenderPassColorAttachmentDescriptor& colorAttachment,
uint32_t* width,
uint32_t* height,
uint32_t* sampleCount) {
- DAWN_ASSERT(colorAttachment != nullptr);
+ DAWN_TRY(device->ValidateObject(colorAttachment.attachment));
- DAWN_TRY(device->ValidateObject(colorAttachment->attachment));
-
- const TextureViewBase* attachment = colorAttachment->attachment;
+ const TextureViewBase* attachment = colorAttachment.attachment;
if (!attachment->GetFormat().IsColor() || !attachment->GetFormat().isRenderable) {
return DAWN_VALIDATION_ERROR(
"The format of the texture view used as color attachment is not color "
@@ -517,13 +515,13 @@
cmd->attachmentState = device->GetOrCreateAttachmentState(descriptor);
for (uint32_t i : IterateBitSet(cmd->attachmentState->GetColorAttachmentsMask())) {
- cmd->colorAttachments[i].view = descriptor->colorAttachments[i]->attachment;
+ cmd->colorAttachments[i].view = descriptor->colorAttachments[i].attachment;
cmd->colorAttachments[i].resolveTarget =
- descriptor->colorAttachments[i]->resolveTarget;
- cmd->colorAttachments[i].loadOp = descriptor->colorAttachments[i]->loadOp;
- cmd->colorAttachments[i].storeOp = descriptor->colorAttachments[i]->storeOp;
+ descriptor->colorAttachments[i].resolveTarget;
+ cmd->colorAttachments[i].loadOp = descriptor->colorAttachments[i].loadOp;
+ cmd->colorAttachments[i].storeOp = descriptor->colorAttachments[i].storeOp;
cmd->colorAttachments[i].clearColor =
- descriptor->colorAttachments[i]->clearColor;
+ descriptor->colorAttachments[i].clearColor;
}
if (cmd->attachmentState->HasDepthStencilAttachment()) {
diff --git a/src/tests/end2end/ClipSpaceTests.cpp b/src/tests/end2end/ClipSpaceTests.cpp
index 58bd477..439f0d3 100644
--- a/src/tests/end2end/ClipSpaceTests.cpp
+++ b/src/tests/end2end/ClipSpaceTests.cpp
@@ -78,8 +78,8 @@
utils::ComboRenderPassDescriptor renderPassDescriptor({colorTexture.CreateView()},
depthStencilTexture.CreateView());
- renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 1.0, 0.0, 1.0};
- renderPassDescriptor.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear;
+ renderPassDescriptor.cColorAttachments[0].clearColor = {0.0, 1.0, 0.0, 1.0};
+ renderPassDescriptor.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
// Clear the depth stencil attachment to 0.5f, so only the bottom-right triangle should be
// drawn.
diff --git a/src/tests/end2end/CullingTests.cpp b/src/tests/end2end/CullingTests.cpp
index eaa8a02..7745348 100644
--- a/src/tests/end2end/CullingTests.cpp
+++ b/src/tests/end2end/CullingTests.cpp
@@ -78,8 +78,8 @@
dawn::Texture colorTexture = Create2DTextureForTest(dawn::TextureFormat::RGBA8Unorm);
utils::ComboRenderPassDescriptor renderPassDescriptor({colorTexture.CreateView()});
- renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 0.0, 1.0, 1.0};
- renderPassDescriptor.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear;
+ renderPassDescriptor.cColorAttachments[0].clearColor = {0.0, 0.0, 1.0, 1.0};
+ renderPassDescriptor.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = commandEncoder.BeginRenderPass(&renderPassDescriptor);
diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp
index 001b3f7..e4823ff 100644
--- a/src/tests/end2end/IOSurfaceWrappingTests.cpp
+++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp
@@ -347,8 +347,8 @@
dawn::TextureView ioSurfaceView = ioSurfaceTexture.CreateView();
utils::ComboRenderPassDescriptor renderPassDescriptor({ioSurfaceView}, {});
- renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = {1 / 255.0f, 2 / 255.0f,
- 3 / 255.0f, 4 / 255.0f};
+ renderPassDescriptor.cColorAttachments[0].clearColor = {1 / 255.0f, 2 / 255.0f, 3 / 255.0f,
+ 4 / 255.0f};
// Execute commands to clear the ioSurface
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp
index b291487..c9fb5d9 100644
--- a/src/tests/end2end/MultisampledRenderingTests.cpp
+++ b/src/tests/end2end/MultisampledRenderingTests.cpp
@@ -131,9 +131,9 @@
utils::ComboRenderPassDescriptor renderPass(colorViews);
uint32_t i = 0;
for (const dawn::TextureView& resolveTargetView : resolveTargetViews) {
- renderPass.cColorAttachmentsInfoPtr[i]->loadOp = colorLoadOp;
- renderPass.cColorAttachmentsInfoPtr[i]->clearColor = kClearColor;
- renderPass.cColorAttachmentsInfoPtr[i]->resolveTarget = resolveTargetView;
+ renderPass.cColorAttachments[i].loadOp = colorLoadOp;
+ renderPass.cColorAttachments[i].clearColor = kClearColor;
+ renderPass.cColorAttachments[i].resolveTarget = resolveTargetView;
++i;
}
diff --git a/src/tests/end2end/RenderPassLoadOpTests.cpp b/src/tests/end2end/RenderPassLoadOpTests.cpp
index 8cf66c3..9c0d9ea 100644
--- a/src/tests/end2end/RenderPassLoadOpTests.cpp
+++ b/src/tests/end2end/RenderPassLoadOpTests.cpp
@@ -122,7 +122,7 @@
auto commandsClearZero = commandsClearZeroEncoder.Finish();
utils::ComboRenderPassDescriptor renderPassClearGreen({renderTargetView});
- renderPassClearGreen.cColorAttachmentsInfoPtr[0]->clearColor = {0.0f, 1.0f, 0.0f, 1.0f};
+ renderPassClearGreen.cColorAttachments[0].clearColor = {0.0f, 1.0f, 0.0f, 1.0f};
auto commandsClearGreenEncoder = device.CreateCommandEncoder();
auto clearGreenPass = commandsClearGreenEncoder.BeginRenderPass(&renderPassClearGreen);
clearGreenPass.EndPass();
@@ -136,7 +136,7 @@
// Part 2: draw a blue quad into the right half of the render target, and check result
utils::ComboRenderPassDescriptor renderPassLoad({renderTargetView});
- renderPassLoad.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Load;
+ renderPassLoad.cColorAttachments[0].loadOp = dawn::LoadOp::Load;
dawn::CommandBuffer commandsLoad;
{
auto encoder = device.CreateCommandEncoder();
diff --git a/src/tests/end2end/RenderPassTests.cpp b/src/tests/end2end/RenderPassTests.cpp
index 578e2fa..506bc11 100644
--- a/src/tests/end2end/RenderPassTests.cpp
+++ b/src/tests/end2end/RenderPassTests.cpp
@@ -89,7 +89,7 @@
// In the first render pass we clear renderTarget1 to red and draw a blue triangle in the
// bottom left of renderTarget1.
utils::ComboRenderPassDescriptor renderPass({renderTarget1.CreateView()});
- renderPass.cColorAttachmentsInfoPtr[0]->clearColor = {1.0f, 0.0f, 0.0f, 1.0f};
+ renderPass.cColorAttachments[0].clearColor = {1.0f, 0.0f, 0.0f, 1.0f};
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline);
@@ -101,7 +101,7 @@
// In the second render pass we clear renderTarget2 to green and draw a blue triangle in the
// bottom left of renderTarget2.
utils::ComboRenderPassDescriptor renderPass({renderTarget2.CreateView()});
- renderPass.cColorAttachmentsInfoPtr[0]->clearColor = {0.0f, 1.0f, 0.0f, 1.0f};
+ renderPass.cColorAttachments[0].clearColor = {0.0f, 1.0f, 0.0f, 1.0f};
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline);
diff --git a/src/tests/end2end/TextureViewTests.cpp b/src/tests/end2end/TextureViewTests.cpp
index 76554ca..27c0ff9 100644
--- a/src/tests/end2end/TextureViewTests.cpp
+++ b/src/tests/end2end/TextureViewTests.cpp
@@ -491,7 +491,7 @@
// Clear textureView with Red(255, 0, 0, 255) and render Green(0, 255, 0, 255) into it
utils::ComboRenderPassDescriptor renderPassInfo({textureView});
- renderPassInfo.cColorAttachmentsInfoPtr[0]->clearColor = {1.0f, 0.0f, 0.0f, 1.0f};
+ renderPassInfo.cColorAttachments[0].clearColor = {1.0f, 0.0f, 0.0f, 1.0f};
const char* oneColorFragmentShader = R"(
#version 450
diff --git a/src/tests/end2end/TextureZeroInitTests.cpp b/src/tests/end2end/TextureZeroInitTests.cpp
index 18d98e3..7129c3c 100644
--- a/src/tests/end2end/TextureZeroInitTests.cpp
+++ b/src/tests/end2end/TextureZeroInitTests.cpp
@@ -118,7 +118,7 @@
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
- renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->attachment = view;
+ renderPass.renderPassInfo.cColorAttachments[0].attachment = view;
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
{
// Texture's first usage is in BeginRenderPass's call to RecordRenderPass
@@ -146,7 +146,7 @@
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
- renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->attachment = view;
+ renderPass.renderPassInfo.cColorAttachments[0].attachment = view;
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
{
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
@@ -418,7 +418,7 @@
1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc, kColorFormat);
dawn::Texture texture = device.CreateTexture(&descriptor);
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
- renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Load;
+ renderPass.renderPassInfo.cColorAttachments[0].loadOp = dawn::LoadOp::Load;
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
@@ -484,8 +484,8 @@
// Encode pass and submit
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
utils::ComboRenderPassDescriptor renderPassDesc({renderTexture.CreateView()});
- renderPassDesc.cColorAttachmentsInfoPtr[0]->clearColor = {1.0, 1.0, 1.0, 1.0};
- renderPassDesc.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear;
+ renderPassDesc.cColorAttachments[0].clearColor = {1.0, 1.0, 1.0, 1.0};
+ renderPassDesc.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDesc);
pass.SetPipeline(renderPipeline);
pass.SetBindGroup(0, bindGroup, 0, nullptr);
diff --git a/src/tests/end2end/ViewportTests.cpp b/src/tests/end2end/ViewportTests.cpp
index 570b377..fe672d86 100644
--- a/src/tests/end2end/ViewportTests.cpp
+++ b/src/tests/end2end/ViewportTests.cpp
@@ -113,8 +113,8 @@
{
utils::ComboRenderPassDescriptor renderPassDescriptor1(
{colorTexture1.CreateView()}, depthStencilTexture1.CreateView());
- renderPassDescriptor1.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 0.0, 1.0, 1.0};
- renderPassDescriptor1.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear;
+ renderPassDescriptor1.cColorAttachments[0].clearColor = {0.0, 0.0, 1.0, 1.0};
+ renderPassDescriptor1.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
renderPassDescriptor1.cDepthStencilAttachmentInfo.clearDepth = info.clearDepth;
renderPassDescriptor1.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
@@ -138,8 +138,8 @@
{
utils::ComboRenderPassDescriptor renderPassDescriptor2(
{colorTexture2.CreateView()}, depthStencilTexture2.CreateView());
- renderPassDescriptor2.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 0.0, 1.0, 1.0};
- renderPassDescriptor2.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear;
+ renderPassDescriptor2.cColorAttachments[0].clearColor = {0.0, 0.0, 1.0, 1.0};
+ renderPassDescriptor2.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
renderPassDescriptor2.cDepthStencilAttachmentInfo.clearDepth = 0.5;
renderPassDescriptor2.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
diff --git a/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp b/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp
index 31ddb0d..d3bae71 100644
--- a/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp
+++ b/src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp
@@ -99,46 +99,42 @@
// Test OOB color attachment indices are handled
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) {
+ dawn::TextureView color0 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm);
dawn::TextureView color1 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm);
dawn::TextureView color2 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm);
dawn::TextureView color3 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm);
- dawn::TextureView color4 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm);
// For setting the color attachment, control case
{
- utils::ComboRenderPassDescriptor renderPass({color1, color2, color3, color4});
+ utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3});
AssertBeginRenderPassSuccess(&renderPass);
}
// For setting the color attachment, OOB
{
// 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;
+ std::array<dawn::RenderPassColorAttachmentDescriptor, 5> colorAttachments;
+ colorAttachments[0].attachment = color0;
+ colorAttachments[0].resolveTarget = nullptr;
+ colorAttachments[0].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
+ colorAttachments[0].loadOp = dawn::LoadOp::Clear;
+ colorAttachments[0].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;
+ colorAttachments[1] = colorAttachments[0];
+ colorAttachments[1].attachment = color1;
- dawn::TextureView color5 =
+ colorAttachments[2] = colorAttachments[0];
+ colorAttachments[2].attachment = color2;
+
+ colorAttachments[3] = colorAttachments[0];
+ colorAttachments[3].attachment = color3;
+
+ colorAttachments[4] = colorAttachments[0];
+ colorAttachments[4].attachment =
Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm);
- 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.colorAttachmentCount = 5;
+ renderPass.colorAttachments = colorAttachments.data();
renderPass.depthStencilAttachment = nullptr;
AssertBeginRenderPassError(&renderPass);
}
@@ -398,7 +394,7 @@
dawn::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass({colorTextureView});
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTargetTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
AssertBeginRenderPassError(&renderPass);
}
@@ -457,7 +453,7 @@
dawn::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = multisampledResolveTargetView;
+ renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView;
AssertBeginRenderPassError(&renderPass);
}
@@ -470,7 +466,7 @@
dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass);
}
@@ -483,7 +479,7 @@
dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass);
}
@@ -497,7 +493,7 @@
dawn::TextureView nonColorUsageResolveTextureView = nonColorUsageResolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = nonColorUsageResolveTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = nonColorUsageResolveTextureView;
AssertBeginRenderPassError(&renderPass);
}
@@ -515,7 +511,7 @@
resolveTexture.CreateView(&errorTextureView));
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = errorResolveTarget;
+ renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget;
AssertBeginRenderPassError(&renderPass);
}
@@ -524,7 +520,7 @@
dawn::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTargetTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
AssertBeginRenderPassSuccess(&renderPass);
}
@@ -537,7 +533,7 @@
dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass);
}
@@ -564,7 +560,7 @@
resolveTexture.CreateView(&firstMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass);
}
@@ -576,7 +572,7 @@
resolveTexture.CreateView(&secondMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
- renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView;
+ renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassSuccess(&renderPass);
}
}
diff --git a/src/tests/unittests/validation/ValidationTest.cpp b/src/tests/unittests/validation/ValidationTest.cpp
index 5b9a594..461d9d7 100644
--- a/src/tests/unittests/validation/ValidationTest.cpp
+++ b/src/tests/unittests/validation/ValidationTest.cpp
@@ -114,9 +114,8 @@
mColorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
mColorAttachment.loadOp = dawn::LoadOp::Clear;
mColorAttachment.storeOp = dawn::StoreOp::Store;
- mColorAttachments[0] = &mColorAttachment;
colorAttachmentCount = 1;
- colorAttachments = mColorAttachments;
+ colorAttachments = &mColorAttachment;
depthStencilAttachment = nullptr;
}
diff --git a/src/tests/unittests/validation/ValidationTest.h b/src/tests/unittests/validation/ValidationTest.h
index 3d0b59c..e4a266d 100644
--- a/src/tests/unittests/validation/ValidationTest.h
+++ b/src/tests/unittests/validation/ValidationTest.h
@@ -50,7 +50,6 @@
private:
dawn::RenderPassColorAttachmentDescriptor mColorAttachment;
- dawn::RenderPassColorAttachmentDescriptor* mColorAttachments[1];
};
protected:
diff --git a/src/tests/white_box/VulkanImageWrappingTests.cpp b/src/tests/white_box/VulkanImageWrappingTests.cpp
index 295f3ac..53e7166 100644
--- a/src/tests/white_box/VulkanImageWrappingTests.cpp
+++ b/src/tests/white_box/VulkanImageWrappingTests.cpp
@@ -408,7 +408,7 @@
// Submit a clear operation
utils::ComboRenderPassDescriptor renderPassDescriptor({wrappedView}, {});
- renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = clearColor;
+ renderPassDescriptor.cColorAttachments[0].clearColor = clearColor;
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDescriptor);
diff --git a/src/utils/DawnHelpers.cpp b/src/utils/DawnHelpers.cpp
index 25a8d73..1ad9adf 100644
--- a/src/utils/DawnHelpers.cpp
+++ b/src/utils/DawnHelpers.cpp
@@ -128,13 +128,11 @@
ComboRenderPassDescriptor::ComboRenderPassDescriptor(
std::initializer_list<dawn::TextureView> colorAttachmentInfo,
- dawn::TextureView depthStencil)
- : cColorAttachmentsInfoPtr() {
+ dawn::TextureView depthStencil) {
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
- mColorAttachmentsInfo[i].loadOp = dawn::LoadOp::Clear;
- mColorAttachmentsInfo[i].storeOp = dawn::StoreOp::Store;
- mColorAttachmentsInfo[i].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
- cColorAttachmentsInfoPtr[i] = nullptr;
+ cColorAttachments[i].loadOp = dawn::LoadOp::Clear;
+ cColorAttachments[i].storeOp = dawn::StoreOp::Store;
+ cColorAttachments[i].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
}
cDepthStencilAttachmentInfo.clearDepth = 1.0f;
@@ -148,13 +146,11 @@
uint32_t colorAttachmentIndex = 0;
for (const dawn::TextureView& colorAttachment : colorAttachmentInfo) {
if (colorAttachment.Get() != nullptr) {
- mColorAttachmentsInfo[colorAttachmentIndex].attachment = colorAttachment;
- cColorAttachmentsInfoPtr[colorAttachmentIndex] =
- &mColorAttachmentsInfo[colorAttachmentIndex];
+ cColorAttachments[colorAttachmentIndex].attachment = colorAttachment;
}
++colorAttachmentIndex;
}
- colorAttachments = cColorAttachmentsInfoPtr;
+ colorAttachments = cColorAttachments.data();
if (depthStencil.Get() != nullptr) {
cDepthStencilAttachmentInfo.attachment = depthStencil;
@@ -167,19 +163,10 @@
const ComboRenderPassDescriptor& ComboRenderPassDescriptor::operator=(
const ComboRenderPassDescriptor& otherRenderPass) {
cDepthStencilAttachmentInfo = otherRenderPass.cDepthStencilAttachmentInfo;
- mColorAttachmentsInfo = otherRenderPass.mColorAttachmentsInfo;
-
+ cColorAttachments = otherRenderPass.cColorAttachments;
colorAttachmentCount = otherRenderPass.colorAttachmentCount;
- // Assign the pointers in colorAttachmentsInfoPtr to items in this->mColorAttachmentsInfo
- for (uint32_t i = 0; i < colorAttachmentCount; ++i) {
- if (otherRenderPass.cColorAttachmentsInfoPtr[i] != nullptr) {
- cColorAttachmentsInfoPtr[i] = &mColorAttachmentsInfo[i];
- } else {
- cColorAttachmentsInfoPtr[i] = nullptr;
- }
- }
- colorAttachments = cColorAttachmentsInfoPtr;
+ colorAttachments = cColorAttachments.data();
if (otherRenderPass.depthStencilAttachment != nullptr) {
// Assign desc.depthStencilAttachment to this->depthStencilAttachmentInfo;
diff --git a/src/utils/DawnHelpers.h b/src/utils/DawnHelpers.h
index 4011bc4..337ae85 100644
--- a/src/utils/DawnHelpers.h
+++ b/src/utils/DawnHelpers.h
@@ -61,12 +61,9 @@
const ComboRenderPassDescriptor& operator=(
const ComboRenderPassDescriptor& otherRenderPass);
- dawn::RenderPassColorAttachmentDescriptor* cColorAttachmentsInfoPtr[kMaxColorAttachments];
- dawn::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
-
- private:
std::array<dawn::RenderPassColorAttachmentDescriptor, kMaxColorAttachments>
- mColorAttachmentsInfo;
+ cColorAttachments;
+ dawn::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
};
struct BasicRenderPass {