Deprecate renderpass color/depth .attachment

As of https://github.com/gpuweb/gpuweb/pull/1352 the spec indicates that
GPURenderPassColorAttachmentDescriptor and
GPURenderPassDepthStencilAttachmentDescriptor should use .view rather
than .attachment to indicate the TextureView associated with the
render pass attachment.

Bug: dawn:762
Change-Id: I70d615e19d8e7aae5b26aa5965c7109289ab868b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/47902
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Brandon Jones
2021-04-17 01:51:53 +00:00
committed by Commit Bot service account
parent 12953caa42
commit 5e6a092703
10 changed files with 133 additions and 36 deletions

View File

@@ -65,7 +65,10 @@ namespace dawn_native {
i < ColorAttachmentIndex(static_cast<uint8_t>(descriptor->colorAttachmentCount));
++i) {
TextureViewBase* attachment =
descriptor->colorAttachments[static_cast<uint8_t>(i)].attachment;
descriptor->colorAttachments[static_cast<uint8_t>(i)].view;
if (attachment == nullptr) {
attachment = descriptor->colorAttachments[static_cast<uint8_t>(i)].attachment;
}
mColorAttachmentsSet.set(i);
mColorFormats[i] = attachment->GetFormat().format;
if (mSampleCount == 0) {
@@ -75,7 +78,10 @@ namespace dawn_native {
}
}
if (descriptor->depthStencilAttachment != nullptr) {
TextureViewBase* attachment = descriptor->depthStencilAttachment->attachment;
TextureViewBase* attachment = descriptor->depthStencilAttachment->view;
if (attachment == nullptr) {
attachment = descriptor->depthStencilAttachment->attachment;
}
mDepthStencilFormat = attachment->GetFormat().format;
if (mSampleCount == 0) {
mSampleCount = attachment->GetTexture()->GetSampleCount();

View File

@@ -155,7 +155,8 @@ namespace dawn_native {
}
const TextureViewBase* resolveTarget = colorAttachment.resolveTarget;
const TextureViewBase* attachment = colorAttachment.attachment;
const TextureViewBase* attachment =
colorAttachment.view != nullptr ? colorAttachment.view : colorAttachment.attachment;
DAWN_TRY(device->ValidateObject(colorAttachment.resolveTarget));
DAWN_TRY(ValidateCanUseAs(colorAttachment.resolveTarget->GetTexture(),
wgpu::TextureUsage::RenderAttachment));
@@ -203,16 +204,33 @@ namespace dawn_native {
}
MaybeError ValidateRenderPassColorAttachment(
const DeviceBase* device,
DeviceBase* device,
const RenderPassColorAttachmentDescriptor& colorAttachment,
uint32_t* width,
uint32_t* height,
uint32_t* sampleCount) {
DAWN_TRY(device->ValidateObject(colorAttachment.attachment));
DAWN_TRY(ValidateCanUseAs(colorAttachment.attachment->GetTexture(),
wgpu::TextureUsage::RenderAttachment));
TextureViewBase* attachment;
if (colorAttachment.view != nullptr) {
if (colorAttachment.attachment != nullptr) {
return DAWN_VALIDATION_ERROR(
"Cannot specify both a attachment and view. attachment is deprecated, "
"favor view instead.");
}
attachment = colorAttachment.view;
} else if (colorAttachment.attachment != nullptr) {
device->EmitDeprecationWarning(
"RenderPassColorAttachmentDescriptor.attachment has been deprecated. Use "
"RenderPassColorAttachmentDescriptor.view instead.");
attachment = colorAttachment.attachment;
} else {
return DAWN_VALIDATION_ERROR(
"Must specify a view for RenderPassColorAttachmentDescriptor");
}
DAWN_TRY(device->ValidateObject(attachment));
DAWN_TRY(
ValidateCanUseAs(attachment->GetTexture(), wgpu::TextureUsage::RenderAttachment));
const TextureViewBase* attachment = colorAttachment.attachment;
if (!(attachment->GetAspects() & Aspect::Color) ||
!attachment->GetFormat().isRenderable) {
return DAWN_VALIDATION_ERROR(
@@ -243,18 +261,35 @@ namespace dawn_native {
}
MaybeError ValidateRenderPassDepthStencilAttachment(
const DeviceBase* device,
DeviceBase* device,
const RenderPassDepthStencilAttachmentDescriptor* depthStencilAttachment,
uint32_t* width,
uint32_t* height,
uint32_t* sampleCount) {
DAWN_ASSERT(depthStencilAttachment != nullptr);
DAWN_TRY(device->ValidateObject(depthStencilAttachment->attachment));
DAWN_TRY(ValidateCanUseAs(depthStencilAttachment->attachment->GetTexture(),
wgpu::TextureUsage::RenderAttachment));
TextureViewBase* attachment;
if (depthStencilAttachment->view != nullptr) {
if (depthStencilAttachment->attachment != nullptr) {
return DAWN_VALIDATION_ERROR(
"Cannot specify both a attachment and view. attachment is deprecated, "
"favor view instead.");
}
attachment = depthStencilAttachment->view;
} else if (depthStencilAttachment->attachment != nullptr) {
device->EmitDeprecationWarning(
"RenderPassDepthStencilAttachmentDescriptor.attachment has been deprecated. "
"Use RenderPassDepthStencilAttachmentDescriptor.view instead.");
attachment = depthStencilAttachment->attachment;
} else {
return DAWN_VALIDATION_ERROR(
"Must specify a view for RenderPassDepthStencilAttachmentDescriptor");
}
DAWN_TRY(device->ValidateObject(attachment));
DAWN_TRY(
ValidateCanUseAs(attachment->GetTexture(), wgpu::TextureUsage::RenderAttachment));
const TextureViewBase* attachment = depthStencilAttachment->attachment;
if ((attachment->GetAspects() & (Aspect::Depth | Aspect::Stencil)) == Aspect::None ||
!attachment->GetFormat().isRenderable) {
return DAWN_VALIDATION_ERROR(
@@ -313,7 +348,7 @@ namespace dawn_native {
return {};
}
MaybeError ValidateRenderPassDescriptor(const DeviceBase* device,
MaybeError ValidateRenderPassDescriptor(DeviceBase* device,
const RenderPassDescriptor* descriptor,
uint32_t* width,
uint32_t* height,
@@ -521,7 +556,10 @@ namespace dawn_native {
for (ColorAttachmentIndex index :
IterateBitSet(cmd->attachmentState->GetColorAttachmentsMask())) {
uint8_t i = static_cast<uint8_t>(index);
TextureViewBase* view = descriptor->colorAttachments[i].attachment;
TextureViewBase* view = descriptor->colorAttachments[i].view;
if (view == nullptr) {
view = descriptor->colorAttachments[i].attachment;
}
TextureViewBase* resolveTarget = descriptor->colorAttachments[i].resolveTarget;
cmd->colorAttachments[index].view = view;
@@ -540,7 +578,10 @@ namespace dawn_native {
}
if (cmd->attachmentState->HasDepthStencilAttachment()) {
TextureViewBase* view = descriptor->depthStencilAttachment->attachment;
TextureViewBase* view = descriptor->depthStencilAttachment->view;
if (view == nullptr) {
view = descriptor->depthStencilAttachment->attachment;
}
cmd->depthStencilAttachment.view = view;
cmd->depthStencilAttachment.clearDepth =

View File

@@ -329,7 +329,7 @@ namespace dawn_native {
// Prepare render pass color attachment descriptor.
RenderPassColorAttachmentDescriptor colorAttachmentDesc;
colorAttachmentDesc.attachment = dstView.Get();
colorAttachmentDesc.view = dstView.Get();
colorAttachmentDesc.loadOp = wgpu::LoadOp::Load;
colorAttachmentDesc.storeOp = wgpu::StoreOp::Store;
colorAttachmentDesc.clearColor = {0.0, 0.0, 0.0, 1.0};