mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Make properties required
This commit makes depthWriteEnabled and depthCompare required and makes depthClearValue conditionally required for the spec change in WebGPU V1. https://github.com/gpuweb/gpuweb/pull/3849 depthClearValue is required if depthLoadOp is clear and the attachment has a depth aspect. To simulate it, this commit lets NAN represent unspecified depthClearValue and lets the default value of depthClearValue be NAN. Bug: dawn:1669 Change-Id: I469338e909b1d3c345bc2642ee47daee858909ca Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120620 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
@@ -137,6 +137,7 @@ ResultOrError<Ref<RenderPipelineBase>> GetOrCreateRG8ToDepth16UnormPipeline(Devi
|
||||
DepthStencilState dsState = {};
|
||||
dsState.format = wgpu::TextureFormat::Depth16Unorm;
|
||||
dsState.depthWriteEnabled = true;
|
||||
dsState.depthCompare = wgpu::CompareFunction::Always;
|
||||
|
||||
RenderPipelineDescriptor renderPipelineDesc = {};
|
||||
renderPipelineDesc.vertex.module = shaderModule.Get();
|
||||
@@ -186,6 +187,7 @@ ResultOrError<InternalPipelineStore::BlitR8ToStencilPipelines> GetOrCreateR8ToSt
|
||||
DepthStencilState dsState = {};
|
||||
dsState.format = format;
|
||||
dsState.depthWriteEnabled = false;
|
||||
dsState.depthCompare = wgpu::CompareFunction::Always;
|
||||
dsState.stencilFront.passOp = wgpu::StencilOperation::Replace;
|
||||
|
||||
RenderPipelineDescriptor renderPipelineDesc = {};
|
||||
@@ -288,6 +290,7 @@ MaybeError BlitRG8ToDepth16Unorm(DeviceBase* device,
|
||||
|
||||
RenderPassDepthStencilAttachment dsAttachment;
|
||||
dsAttachment.view = dstView.Get();
|
||||
dsAttachment.depthClearValue = 0.0;
|
||||
dsAttachment.depthLoadOp = wgpu::LoadOp::Load;
|
||||
dsAttachment.depthStoreOp = wgpu::StoreOp::Store;
|
||||
|
||||
@@ -400,6 +403,7 @@ MaybeError BlitR8ToStencil(DeviceBase* device,
|
||||
}
|
||||
|
||||
RenderPassDepthStencilAttachment dsAttachment;
|
||||
dsAttachment.depthClearValue = 0.0;
|
||||
dsAttachment.view = dstView.Get();
|
||||
if (format.HasDepth()) {
|
||||
dsAttachment.depthLoadOp = wgpu::LoadOp::Load;
|
||||
|
||||
@@ -75,6 +75,7 @@ ResultOrError<Ref<RenderPipelineBase>> GetOrCreateDepthBlitPipeline(DeviceBase*
|
||||
DepthStencilState dsState = {};
|
||||
dsState.format = format;
|
||||
dsState.depthWriteEnabled = true;
|
||||
dsState.depthCompare = wgpu::CompareFunction::Always;
|
||||
|
||||
RenderPipelineDescriptor renderPipelineDesc = {};
|
||||
renderPipelineDesc.vertex.module = shaderModule.Get();
|
||||
@@ -203,6 +204,7 @@ MaybeError BlitDepthToDepth(DeviceBase* device,
|
||||
|
||||
RenderPassDepthStencilAttachment dsAttachment = {};
|
||||
dsAttachment.view = dstView.Get();
|
||||
dsAttachment.depthClearValue = 0.0;
|
||||
dsAttachment.depthLoadOp = wgpu::LoadOp::Load;
|
||||
dsAttachment.depthStoreOp = wgpu::StoreOp::Store;
|
||||
if (dst.texture->GetFormat().HasStencil()) {
|
||||
|
||||
@@ -371,12 +371,18 @@ MaybeError ValidateRenderPassDepthStencilAttachment(
|
||||
depthStencilAttachment->stencilReadOnly);
|
||||
}
|
||||
|
||||
if (depthStencilAttachment->depthLoadOp == wgpu::LoadOp::Clear) {
|
||||
DAWN_INVALID_IF(std::isnan(depthStencilAttachment->depthClearValue),
|
||||
"depthClearValue is NaN.");
|
||||
if (depthStencilAttachment->depthLoadOp == wgpu::LoadOp::Clear &&
|
||||
IsSubset(Aspect::Depth, attachment->GetAspects())) {
|
||||
DAWN_INVALID_IF(
|
||||
std::isnan(depthStencilAttachment->depthClearValue),
|
||||
"depthClearValue (%f) must be set and must not be a NaN value if the attachment "
|
||||
"(%s) has a depth aspect and depthLoadOp is clear.",
|
||||
depthStencilAttachment->depthClearValue, attachment);
|
||||
DAWN_INVALID_IF(depthStencilAttachment->depthClearValue < 0.0f ||
|
||||
depthStencilAttachment->depthClearValue > 1.0f,
|
||||
"depthClearValue is not between 0.0 and 1.0");
|
||||
"depthClearValue (%f) must be between 0.0 and 1.0 if the attachment (%s) "
|
||||
"has a depth aspect and depthLoadOp is clear.",
|
||||
depthStencilAttachment->depthClearValue, attachment);
|
||||
}
|
||||
|
||||
// *sampleCount == 0 must only happen when there is no color attachment. In that case we
|
||||
|
||||
Reference in New Issue
Block a user