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>
This commit is contained in:
Corentin Wallez 2019-09-20 22:59:47 +00:00 committed by Commit Bot service account
parent 0c4d75931a
commit a838c7d497
19 changed files with 91 additions and 116 deletions

View File

@ -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}
]
},

View File

@ -128,7 +128,6 @@ void frame() {
DawnTextureView backbufferView = dawnTextureCreateView(backbuffer, nullptr);
DawnRenderPassDescriptor renderpassInfo;
DawnRenderPassColorAttachmentDescriptor colorAttachment;
DawnRenderPassColorAttachmentDescriptor* colorAttachments = {&colorAttachment};
{
colorAttachment.attachment = backbufferView;
colorAttachment.resolveTarget = nullptr;
@ -136,7 +135,7 @@ void frame() {
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;

View File

@ -45,7 +45,7 @@ namespace dawn_native {
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) {

View File

@ -310,39 +310,40 @@ namespace dawn_native {
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 @@ namespace dawn_native {
"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 @@ namespace dawn_native {
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 @@ namespace dawn_native {
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()) {

View File

@ -78,8 +78,8 @@ TEST_P(ClipSpaceTest, ClipSpace) {
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.

View File

@ -78,8 +78,8 @@ class CullingTest : public DawnTest {
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);

View File

@ -347,8 +347,8 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
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();

View File

@ -131,9 +131,9 @@ class MultisampledRenderingTest : public DawnTest {
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;
}

View File

@ -122,7 +122,7 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
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 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
// 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();

View File

@ -89,7 +89,7 @@ TEST_P(RenderPassTest, TwoRenderPassesInOneCommandBuffer) {
// 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 @@ TEST_P(RenderPassTest, TwoRenderPassesInOneCommandBuffer) {
// 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);

View File

@ -491,7 +491,7 @@ class TextureViewRenderingTest : public DawnTest {
// 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

View File

@ -118,7 +118,7 @@ TEST_P(TextureZeroInitTest, RenderingMipMapClearsToZero) {
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 @@ TEST_P(TextureZeroInitTest, RenderingArrayLayerClearsToZero) {
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 @@ TEST_P(TextureZeroInitTest, ColorAttachmentsClear) {
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 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) {
// 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);

View File

@ -113,8 +113,8 @@ class ViewportTest : public DawnTest {
{
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 @@ class ViewportTest : public DawnTest {
{
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;

View File

@ -99,46 +99,42 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
// 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 @@ TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget
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 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget
dawn::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = multisampledResolveTargetView;
renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView;
AssertBeginRenderPassError(&renderPass);
}
@ -470,7 +466,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMo
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 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelM
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 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutpu
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 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState
resolveTexture.CreateView(&errorTextureView));
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = errorResolveTarget;
renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget;
AssertBeginRenderPassError(&renderPass);
}
@ -524,7 +520,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithReso
dawn::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTargetTextureView;
renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
AssertBeginRenderPassSuccess(&renderPass);
}
@ -537,7 +533,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFor
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 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
resolveTexture.CreateView(&firstMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView;
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass);
}
@ -576,7 +572,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
resolveTexture.CreateView(&secondMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView;
renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassSuccess(&renderPass);
}
}

View File

@ -114,9 +114,8 @@ ValidationTest::DummyRenderPass::DummyRenderPass(const dawn::Device& device)
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;
}

View File

@ -50,7 +50,6 @@ class ValidationTest : public testing::Test {
private:
dawn::RenderPassColorAttachmentDescriptor mColorAttachment;
dawn::RenderPassColorAttachmentDescriptor* mColorAttachments[1];
};
protected:

View File

@ -408,7 +408,7 @@ class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
// 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);

View File

@ -128,13 +128,11 @@ namespace utils {
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 @@ namespace utils {
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 @@ namespace utils {
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;

View File

@ -61,12 +61,9 @@ namespace utils {
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 {