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", "category": "structure",
"members": [ "members": [
{"name": "color attachment count", "type": "uint32_t"}, {"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} {"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); DawnTextureView backbufferView = dawnTextureCreateView(backbuffer, nullptr);
DawnRenderPassDescriptor renderpassInfo; DawnRenderPassDescriptor renderpassInfo;
DawnRenderPassColorAttachmentDescriptor colorAttachment; DawnRenderPassColorAttachmentDescriptor colorAttachment;
DawnRenderPassColorAttachmentDescriptor* colorAttachments = {&colorAttachment};
{ {
colorAttachment.attachment = backbufferView; colorAttachment.attachment = backbufferView;
colorAttachment.resolveTarget = nullptr; colorAttachment.resolveTarget = nullptr;
@ -136,7 +135,7 @@ void frame() {
colorAttachment.loadOp = DAWN_LOAD_OP_CLEAR; colorAttachment.loadOp = DAWN_LOAD_OP_CLEAR;
colorAttachment.storeOp = DAWN_STORE_OP_STORE; colorAttachment.storeOp = DAWN_STORE_OP_STORE;
renderpassInfo.colorAttachmentCount = 1; renderpassInfo.colorAttachmentCount = 1;
renderpassInfo.colorAttachments = &colorAttachments; renderpassInfo.colorAttachments = &colorAttachment;
renderpassInfo.depthStencilAttachment = nullptr; renderpassInfo.depthStencilAttachment = nullptr;
} }
DawnCommandBuffer commands; DawnCommandBuffer commands;

View File

@ -45,7 +45,7 @@ namespace dawn_native {
AttachmentStateBlueprint::AttachmentStateBlueprint(const RenderPassDescriptor* descriptor) { AttachmentStateBlueprint::AttachmentStateBlueprint(const RenderPassDescriptor* descriptor) {
for (uint32_t i = 0; i < descriptor->colorAttachmentCount; ++i) { for (uint32_t i = 0; i < descriptor->colorAttachmentCount; ++i) {
TextureViewBase* attachment = descriptor->colorAttachments[i]->attachment; TextureViewBase* attachment = descriptor->colorAttachments[i].attachment;
mColorAttachmentsSet.set(i); mColorAttachmentsSet.set(i);
mColorFormats[i] = attachment->GetFormat().format; mColorFormats[i] = attachment->GetFormat().format;
if (mSampleCount == 0) { if (mSampleCount == 0) {

View File

@ -310,39 +310,40 @@ namespace dawn_native {
MaybeError ValidateResolveTarget( MaybeError ValidateResolveTarget(
const DeviceBase* device, const DeviceBase* device,
const RenderPassColorAttachmentDescriptor* colorAttachment) { const RenderPassColorAttachmentDescriptor& colorAttachment) {
if (colorAttachment->resolveTarget == nullptr) { if (colorAttachment.resolveTarget == nullptr) {
return {}; 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( return DAWN_VALIDATION_ERROR(
"Cannot set resolve target when the sample count of the color attachment is 1"); "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"); return DAWN_VALIDATION_ERROR("Cannot use multisampled texture as resolve target");
} }
if (colorAttachment->resolveTarget->GetLayerCount() > 1) { if (resolveTarget->GetLayerCount() > 1) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The array layer count of the resolve target must be 1"); "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"); return DAWN_VALIDATION_ERROR("The mip level count of the resolve target must be 1");
} }
uint32_t colorAttachmentBaseMipLevel = colorAttachment->attachment->GetBaseMipLevel(); uint32_t colorAttachmentBaseMipLevel = attachment->GetBaseMipLevel();
const Extent3D& colorTextureSize = colorAttachment->attachment->GetTexture()->GetSize(); const Extent3D& colorTextureSize = attachment->GetTexture()->GetSize();
uint32_t colorAttachmentWidth = colorTextureSize.width >> colorAttachmentBaseMipLevel; uint32_t colorAttachmentWidth = colorTextureSize.width >> colorAttachmentBaseMipLevel;
uint32_t colorAttachmentHeight = colorTextureSize.height >> colorAttachmentBaseMipLevel; uint32_t colorAttachmentHeight = colorTextureSize.height >> colorAttachmentBaseMipLevel;
uint32_t resolveTargetBaseMipLevel = colorAttachment->resolveTarget->GetBaseMipLevel(); uint32_t resolveTargetBaseMipLevel = resolveTarget->GetBaseMipLevel();
const Extent3D& resolveTextureSize = const Extent3D& resolveTextureSize = resolveTarget->GetTexture()->GetSize();
colorAttachment->resolveTarget->GetTexture()->GetSize();
uint32_t resolveTargetWidth = resolveTextureSize.width >> resolveTargetBaseMipLevel; uint32_t resolveTargetWidth = resolveTextureSize.width >> resolveTargetBaseMipLevel;
uint32_t resolveTargetHeight = resolveTextureSize.height >> resolveTargetBaseMipLevel; uint32_t resolveTargetHeight = resolveTextureSize.height >> resolveTargetBaseMipLevel;
if (colorAttachmentWidth != resolveTargetWidth || if (colorAttachmentWidth != resolveTargetWidth ||
@ -351,9 +352,8 @@ namespace dawn_native {
"The size of the resolve target must be the same as the color attachment"); "The size of the resolve target must be the same as the color attachment");
} }
dawn::TextureFormat resolveTargetFormat = dawn::TextureFormat resolveTargetFormat = resolveTarget->GetFormat().format;
colorAttachment->resolveTarget->GetFormat().format; if (resolveTargetFormat != attachment->GetFormat().format) {
if (resolveTargetFormat != colorAttachment->attachment->GetFormat().format) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The format of the resolve target must be the same as the color attachment"); "The format of the resolve target must be the same as the color attachment");
} }
@ -363,15 +363,13 @@ namespace dawn_native {
MaybeError ValidateRenderPassColorAttachment( MaybeError ValidateRenderPassColorAttachment(
const DeviceBase* device, const DeviceBase* device,
const RenderPassColorAttachmentDescriptor* colorAttachment, const RenderPassColorAttachmentDescriptor& colorAttachment,
uint32_t* width, uint32_t* width,
uint32_t* height, uint32_t* height,
uint32_t* sampleCount) { 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) { if (!attachment->GetFormat().IsColor() || !attachment->GetFormat().isRenderable) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The format of the texture view used as color attachment is not color " "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); cmd->attachmentState = device->GetOrCreateAttachmentState(descriptor);
for (uint32_t i : IterateBitSet(cmd->attachmentState->GetColorAttachmentsMask())) { 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 = cmd->colorAttachments[i].resolveTarget =
descriptor->colorAttachments[i]->resolveTarget; descriptor->colorAttachments[i].resolveTarget;
cmd->colorAttachments[i].loadOp = descriptor->colorAttachments[i]->loadOp; cmd->colorAttachments[i].loadOp = descriptor->colorAttachments[i].loadOp;
cmd->colorAttachments[i].storeOp = descriptor->colorAttachments[i]->storeOp; cmd->colorAttachments[i].storeOp = descriptor->colorAttachments[i].storeOp;
cmd->colorAttachments[i].clearColor = cmd->colorAttachments[i].clearColor =
descriptor->colorAttachments[i]->clearColor; descriptor->colorAttachments[i].clearColor;
} }
if (cmd->attachmentState->HasDepthStencilAttachment()) { if (cmd->attachmentState->HasDepthStencilAttachment()) {

View File

@ -78,8 +78,8 @@ TEST_P(ClipSpaceTest, ClipSpace) {
utils::ComboRenderPassDescriptor renderPassDescriptor({colorTexture.CreateView()}, utils::ComboRenderPassDescriptor renderPassDescriptor({colorTexture.CreateView()},
depthStencilTexture.CreateView()); depthStencilTexture.CreateView());
renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 1.0, 0.0, 1.0}; renderPassDescriptor.cColorAttachments[0].clearColor = {0.0, 1.0, 0.0, 1.0};
renderPassDescriptor.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear; renderPassDescriptor.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
// Clear the depth stencil attachment to 0.5f, so only the bottom-right triangle should be // Clear the depth stencil attachment to 0.5f, so only the bottom-right triangle should be
// drawn. // drawn.

View File

@ -78,8 +78,8 @@ class CullingTest : public DawnTest {
dawn::Texture colorTexture = Create2DTextureForTest(dawn::TextureFormat::RGBA8Unorm); dawn::Texture colorTexture = Create2DTextureForTest(dawn::TextureFormat::RGBA8Unorm);
utils::ComboRenderPassDescriptor renderPassDescriptor({colorTexture.CreateView()}); utils::ComboRenderPassDescriptor renderPassDescriptor({colorTexture.CreateView()});
renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 0.0, 1.0, 1.0}; renderPassDescriptor.cColorAttachments[0].clearColor = {0.0, 0.0, 1.0, 1.0};
renderPassDescriptor.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear; renderPassDescriptor.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder(); dawn::CommandEncoder commandEncoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder renderPass = commandEncoder.BeginRenderPass(&renderPassDescriptor); dawn::RenderPassEncoder renderPass = commandEncoder.BeginRenderPass(&renderPassDescriptor);

View File

@ -347,8 +347,8 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
dawn::TextureView ioSurfaceView = ioSurfaceTexture.CreateView(); dawn::TextureView ioSurfaceView = ioSurfaceTexture.CreateView();
utils::ComboRenderPassDescriptor renderPassDescriptor({ioSurfaceView}, {}); utils::ComboRenderPassDescriptor renderPassDescriptor({ioSurfaceView}, {});
renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = {1 / 255.0f, 2 / 255.0f, renderPassDescriptor.cColorAttachments[0].clearColor = {1 / 255.0f, 2 / 255.0f, 3 / 255.0f,
3 / 255.0f, 4 / 255.0f}; 4 / 255.0f};
// Execute commands to clear the ioSurface // Execute commands to clear the ioSurface
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); dawn::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -131,9 +131,9 @@ class MultisampledRenderingTest : public DawnTest {
utils::ComboRenderPassDescriptor renderPass(colorViews); utils::ComboRenderPassDescriptor renderPass(colorViews);
uint32_t i = 0; uint32_t i = 0;
for (const dawn::TextureView& resolveTargetView : resolveTargetViews) { for (const dawn::TextureView& resolveTargetView : resolveTargetViews) {
renderPass.cColorAttachmentsInfoPtr[i]->loadOp = colorLoadOp; renderPass.cColorAttachments[i].loadOp = colorLoadOp;
renderPass.cColorAttachmentsInfoPtr[i]->clearColor = kClearColor; renderPass.cColorAttachments[i].clearColor = kClearColor;
renderPass.cColorAttachmentsInfoPtr[i]->resolveTarget = resolveTargetView; renderPass.cColorAttachments[i].resolveTarget = resolveTargetView;
++i; ++i;
} }

View File

@ -122,7 +122,7 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
auto commandsClearZero = commandsClearZeroEncoder.Finish(); auto commandsClearZero = commandsClearZeroEncoder.Finish();
utils::ComboRenderPassDescriptor renderPassClearGreen({renderTargetView}); 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 commandsClearGreenEncoder = device.CreateCommandEncoder();
auto clearGreenPass = commandsClearGreenEncoder.BeginRenderPass(&renderPassClearGreen); auto clearGreenPass = commandsClearGreenEncoder.BeginRenderPass(&renderPassClearGreen);
clearGreenPass.EndPass(); 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 // Part 2: draw a blue quad into the right half of the render target, and check result
utils::ComboRenderPassDescriptor renderPassLoad({renderTargetView}); utils::ComboRenderPassDescriptor renderPassLoad({renderTargetView});
renderPassLoad.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Load; renderPassLoad.cColorAttachments[0].loadOp = dawn::LoadOp::Load;
dawn::CommandBuffer commandsLoad; dawn::CommandBuffer commandsLoad;
{ {
auto encoder = device.CreateCommandEncoder(); 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 // In the first render pass we clear renderTarget1 to red and draw a blue triangle in the
// bottom left of renderTarget1. // bottom left of renderTarget1.
utils::ComboRenderPassDescriptor renderPass({renderTarget1.CreateView()}); 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); dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); 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 // In the second render pass we clear renderTarget2 to green and draw a blue triangle in the
// bottom left of renderTarget2. // bottom left of renderTarget2.
utils::ComboRenderPassDescriptor renderPass({renderTarget2.CreateView()}); 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); dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
pass.SetPipeline(pipeline); 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 // Clear textureView with Red(255, 0, 0, 255) and render Green(0, 255, 0, 255) into it
utils::ComboRenderPassDescriptor renderPassInfo({textureView}); 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"( const char* oneColorFragmentShader = R"(
#version 450 #version 450

View File

@ -118,7 +118,7 @@ TEST_P(TextureZeroInitTest, RenderingMipMapClearsToZero) {
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat); 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::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
// Texture's first usage is in BeginRenderPass's call to RecordRenderPass // 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); 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::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
@ -418,7 +418,7 @@ TEST_P(TextureZeroInitTest, ColorAttachmentsClear) {
1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc, kColorFormat); 1, 1, dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc, kColorFormat);
dawn::Texture texture = device.CreateTexture(&descriptor); dawn::Texture texture = device.CreateTexture(&descriptor);
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat); 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::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
@ -484,8 +484,8 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) {
// Encode pass and submit // Encode pass and submit
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); dawn::CommandEncoder encoder = device.CreateCommandEncoder();
utils::ComboRenderPassDescriptor renderPassDesc({renderTexture.CreateView()}); utils::ComboRenderPassDescriptor renderPassDesc({renderTexture.CreateView()});
renderPassDesc.cColorAttachmentsInfoPtr[0]->clearColor = {1.0, 1.0, 1.0, 1.0}; renderPassDesc.cColorAttachments[0].clearColor = {1.0, 1.0, 1.0, 1.0};
renderPassDesc.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear; renderPassDesc.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDesc); dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDesc);
pass.SetPipeline(renderPipeline); pass.SetPipeline(renderPipeline);
pass.SetBindGroup(0, bindGroup, 0, nullptr); pass.SetBindGroup(0, bindGroup, 0, nullptr);

View File

@ -113,8 +113,8 @@ class ViewportTest : public DawnTest {
{ {
utils::ComboRenderPassDescriptor renderPassDescriptor1( utils::ComboRenderPassDescriptor renderPassDescriptor1(
{colorTexture1.CreateView()}, depthStencilTexture1.CreateView()); {colorTexture1.CreateView()}, depthStencilTexture1.CreateView());
renderPassDescriptor1.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 0.0, 1.0, 1.0}; renderPassDescriptor1.cColorAttachments[0].clearColor = {0.0, 0.0, 1.0, 1.0};
renderPassDescriptor1.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear; renderPassDescriptor1.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
renderPassDescriptor1.cDepthStencilAttachmentInfo.clearDepth = info.clearDepth; renderPassDescriptor1.cDepthStencilAttachmentInfo.clearDepth = info.clearDepth;
renderPassDescriptor1.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear; renderPassDescriptor1.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
@ -138,8 +138,8 @@ class ViewportTest : public DawnTest {
{ {
utils::ComboRenderPassDescriptor renderPassDescriptor2( utils::ComboRenderPassDescriptor renderPassDescriptor2(
{colorTexture2.CreateView()}, depthStencilTexture2.CreateView()); {colorTexture2.CreateView()}, depthStencilTexture2.CreateView());
renderPassDescriptor2.cColorAttachmentsInfoPtr[0]->clearColor = {0.0, 0.0, 1.0, 1.0}; renderPassDescriptor2.cColorAttachments[0].clearColor = {0.0, 0.0, 1.0, 1.0};
renderPassDescriptor2.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Clear; renderPassDescriptor2.cColorAttachments[0].loadOp = dawn::LoadOp::Clear;
renderPassDescriptor2.cDepthStencilAttachmentInfo.clearDepth = 0.5; renderPassDescriptor2.cDepthStencilAttachmentInfo.clearDepth = 0.5;
renderPassDescriptor2.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear; renderPassDescriptor2.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;

View File

@ -99,46 +99,42 @@ TEST_F(RenderPassDescriptorValidationTest, OneAttachment) {
// Test OOB color attachment indices are handled // Test OOB color attachment indices are handled
TEST_F(RenderPassDescriptorValidationTest, ColorAttachmentOutOfBounds) { 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 color1 = Create2DAttachment(device, 1, 1, dawn::TextureFormat::RGBA8Unorm);
dawn::TextureView color2 = 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 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 // For setting the color attachment, control case
{ {
utils::ComboRenderPassDescriptor renderPass({color1, color2, color3, color4}); utils::ComboRenderPassDescriptor renderPass({color0, color1, color2, color3});
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
// For setting the color attachment, OOB // For setting the color attachment, OOB
{ {
// We cannot use utils::ComboRenderPassDescriptor here because it only supports at most // We cannot use utils::ComboRenderPassDescriptor here because it only supports at most
// kMaxColorAttachments(4) color attachments. // kMaxColorAttachments(4) color attachments.
dawn::RenderPassColorAttachmentDescriptor colorAttachment1; std::array<dawn::RenderPassColorAttachmentDescriptor, 5> colorAttachments;
colorAttachment1.attachment = color1; colorAttachments[0].attachment = color0;
colorAttachment1.resolveTarget = nullptr; colorAttachments[0].resolveTarget = nullptr;
colorAttachment1.clearColor = {0.0f, 0.0f, 0.0f, 0.0f}; colorAttachments[0].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
colorAttachment1.loadOp = dawn::LoadOp::Clear; colorAttachments[0].loadOp = dawn::LoadOp::Clear;
colorAttachment1.storeOp = dawn::StoreOp::Store; colorAttachments[0].storeOp = dawn::StoreOp::Store;
dawn::RenderPassColorAttachmentDescriptor colorAttachment2 = colorAttachment1; colorAttachments[1] = colorAttachments[0];
dawn::RenderPassColorAttachmentDescriptor colorAttachment3 = colorAttachment1; colorAttachments[1].attachment = color1;
dawn::RenderPassColorAttachmentDescriptor colorAttachment4 = colorAttachment1;
colorAttachment2.attachment = color2;
colorAttachment3.attachment = color3;
colorAttachment4.attachment = color4;
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); 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; dawn::RenderPassDescriptor renderPass;
renderPass.colorAttachmentCount = kMaxColorAttachments + 1; renderPass.colorAttachmentCount = 5;
renderPass.colorAttachments = colorAttachments; renderPass.colorAttachments = colorAttachments.data();
renderPass.depthStencilAttachment = nullptr; renderPass.depthStencilAttachment = nullptr;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -398,7 +394,7 @@ TEST_F(RenderPassDescriptorValidationTest, NonMultisampledColorWithResolveTarget
dawn::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView(); dawn::TextureView resolveTargetTextureView = resolveTargetTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass({colorTextureView}); utils::ComboRenderPassDescriptor renderPass({colorTextureView});
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTargetTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -457,7 +453,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledResolveTarget
dawn::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView(); dawn::TextureView multisampledResolveTargetView = CreateMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = multisampledResolveTargetView; renderPass.cColorAttachments[0].resolveTarget = multisampledResolveTargetView;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -470,7 +466,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetArrayLayerMo
dawn::TextureView resolveTextureView = resolveTexture.CreateView(); dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -483,7 +479,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetMipmapLevelM
dawn::TextureView resolveTextureView = resolveTexture.CreateView(); dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -497,7 +493,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetUsageNoOutpu
dawn::TextureView nonColorUsageResolveTextureView = nonColorUsageResolveTexture.CreateView(); dawn::TextureView nonColorUsageResolveTextureView = nonColorUsageResolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = nonColorUsageResolveTextureView; renderPass.cColorAttachments[0].resolveTarget = nonColorUsageResolveTextureView;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -515,7 +511,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetInErrorState
resolveTexture.CreateView(&errorTextureView)); resolveTexture.CreateView(&errorTextureView));
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = errorResolveTarget; renderPass.cColorAttachments[0].resolveTarget = errorResolveTarget;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -524,7 +520,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, MultisampledColorWithReso
dawn::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView(); dawn::TextureView resolveTargetTextureView = CreateNonMultisampledColorTextureView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTargetTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTargetTextureView;
AssertBeginRenderPassSuccess(&renderPass); AssertBeginRenderPassSuccess(&renderPass);
} }
@ -537,7 +533,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ResolveTargetDifferentFor
dawn::TextureView resolveTextureView = resolveTexture.CreateView(); dawn::TextureView resolveTextureView = resolveTexture.CreateView();
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -564,7 +560,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
resolveTexture.CreateView(&firstMipLevelDescriptor); resolveTexture.CreateView(&firstMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassError(&renderPass); AssertBeginRenderPassError(&renderPass);
} }
@ -576,7 +572,7 @@ TEST_F(MultisampledRenderPassDescriptorValidationTest, ColorAttachmentResolveTar
resolveTexture.CreateView(&secondMipLevelDescriptor); resolveTexture.CreateView(&secondMipLevelDescriptor);
utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass(); utils::ComboRenderPassDescriptor renderPass = CreateMultisampledRenderPass();
renderPass.cColorAttachmentsInfoPtr[0]->resolveTarget = resolveTextureView; renderPass.cColorAttachments[0].resolveTarget = resolveTextureView;
AssertBeginRenderPassSuccess(&renderPass); 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.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
mColorAttachment.loadOp = dawn::LoadOp::Clear; mColorAttachment.loadOp = dawn::LoadOp::Clear;
mColorAttachment.storeOp = dawn::StoreOp::Store; mColorAttachment.storeOp = dawn::StoreOp::Store;
mColorAttachments[0] = &mColorAttachment;
colorAttachmentCount = 1; colorAttachmentCount = 1;
colorAttachments = mColorAttachments; colorAttachments = &mColorAttachment;
depthStencilAttachment = nullptr; depthStencilAttachment = nullptr;
} }

View File

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

View File

@ -408,7 +408,7 @@ class VulkanImageWrappingUsageTests : public VulkanImageWrappingTestBase {
// Submit a clear operation // Submit a clear operation
utils::ComboRenderPassDescriptor renderPassDescriptor({wrappedView}, {}); utils::ComboRenderPassDescriptor renderPassDescriptor({wrappedView}, {});
renderPassDescriptor.cColorAttachmentsInfoPtr[0]->clearColor = clearColor; renderPassDescriptor.cColorAttachments[0].clearColor = clearColor;
dawn::CommandEncoder encoder = device.CreateCommandEncoder(); dawn::CommandEncoder encoder = device.CreateCommandEncoder();
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDescriptor); dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPassDescriptor);

View File

@ -128,13 +128,11 @@ namespace utils {
ComboRenderPassDescriptor::ComboRenderPassDescriptor( ComboRenderPassDescriptor::ComboRenderPassDescriptor(
std::initializer_list<dawn::TextureView> colorAttachmentInfo, std::initializer_list<dawn::TextureView> colorAttachmentInfo,
dawn::TextureView depthStencil) dawn::TextureView depthStencil) {
: cColorAttachmentsInfoPtr() {
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) { for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
mColorAttachmentsInfo[i].loadOp = dawn::LoadOp::Clear; cColorAttachments[i].loadOp = dawn::LoadOp::Clear;
mColorAttachmentsInfo[i].storeOp = dawn::StoreOp::Store; cColorAttachments[i].storeOp = dawn::StoreOp::Store;
mColorAttachmentsInfo[i].clearColor = {0.0f, 0.0f, 0.0f, 0.0f}; cColorAttachments[i].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
cColorAttachmentsInfoPtr[i] = nullptr;
} }
cDepthStencilAttachmentInfo.clearDepth = 1.0f; cDepthStencilAttachmentInfo.clearDepth = 1.0f;
@ -148,13 +146,11 @@ namespace utils {
uint32_t colorAttachmentIndex = 0; uint32_t colorAttachmentIndex = 0;
for (const dawn::TextureView& colorAttachment : colorAttachmentInfo) { for (const dawn::TextureView& colorAttachment : colorAttachmentInfo) {
if (colorAttachment.Get() != nullptr) { if (colorAttachment.Get() != nullptr) {
mColorAttachmentsInfo[colorAttachmentIndex].attachment = colorAttachment; cColorAttachments[colorAttachmentIndex].attachment = colorAttachment;
cColorAttachmentsInfoPtr[colorAttachmentIndex] =
&mColorAttachmentsInfo[colorAttachmentIndex];
} }
++colorAttachmentIndex; ++colorAttachmentIndex;
} }
colorAttachments = cColorAttachmentsInfoPtr; colorAttachments = cColorAttachments.data();
if (depthStencil.Get() != nullptr) { if (depthStencil.Get() != nullptr) {
cDepthStencilAttachmentInfo.attachment = depthStencil; cDepthStencilAttachmentInfo.attachment = depthStencil;
@ -167,19 +163,10 @@ namespace utils {
const ComboRenderPassDescriptor& ComboRenderPassDescriptor::operator=( const ComboRenderPassDescriptor& ComboRenderPassDescriptor::operator=(
const ComboRenderPassDescriptor& otherRenderPass) { const ComboRenderPassDescriptor& otherRenderPass) {
cDepthStencilAttachmentInfo = otherRenderPass.cDepthStencilAttachmentInfo; cDepthStencilAttachmentInfo = otherRenderPass.cDepthStencilAttachmentInfo;
mColorAttachmentsInfo = otherRenderPass.mColorAttachmentsInfo; cColorAttachments = otherRenderPass.cColorAttachments;
colorAttachmentCount = otherRenderPass.colorAttachmentCount; colorAttachmentCount = otherRenderPass.colorAttachmentCount;
// Assign the pointers in colorAttachmentsInfoPtr to items in this->mColorAttachmentsInfo colorAttachments = cColorAttachments.data();
for (uint32_t i = 0; i < colorAttachmentCount; ++i) {
if (otherRenderPass.cColorAttachmentsInfoPtr[i] != nullptr) {
cColorAttachmentsInfoPtr[i] = &mColorAttachmentsInfo[i];
} else {
cColorAttachmentsInfoPtr[i] = nullptr;
}
}
colorAttachments = cColorAttachmentsInfoPtr;
if (otherRenderPass.depthStencilAttachment != nullptr) { if (otherRenderPass.depthStencilAttachment != nullptr) {
// Assign desc.depthStencilAttachment to this->depthStencilAttachmentInfo; // Assign desc.depthStencilAttachment to this->depthStencilAttachmentInfo;

View File

@ -61,12 +61,9 @@ namespace utils {
const ComboRenderPassDescriptor& operator=( const ComboRenderPassDescriptor& operator=(
const ComboRenderPassDescriptor& otherRenderPass); const ComboRenderPassDescriptor& otherRenderPass);
dawn::RenderPassColorAttachmentDescriptor* cColorAttachmentsInfoPtr[kMaxColorAttachments];
dawn::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
private:
std::array<dawn::RenderPassColorAttachmentDescriptor, kMaxColorAttachments> std::array<dawn::RenderPassColorAttachmentDescriptor, kMaxColorAttachments>
mColorAttachmentsInfo; cColorAttachments;
dawn::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
}; };
struct BasicRenderPass { struct BasicRenderPass {