From 9c2fb609d69308ce85d905d4d963a03bd4d911d7 Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Fri, 23 Aug 2024 19:50:20 +0000 Subject: [PATCH] Revert "[webgpu-headers] Define depthWriteEnabled as WGPUOptionalBool" This reverts commit 8c230a7cbab3512441955df12fed83bc00c21c13. Reason for revert: Probably causing roll failures on Windows build, example: https://ci.chromium.org/ui/p/chromium/builders/try/win-rel/727795/overview Original change's description: > [webgpu-headers] Define depthWriteEnabled as WGPUOptionalBool > > The following CLs must be merged before: > - https://chromium-review.googlesource.com/c/chromium/src/+/5683307 > - https://skia-review.googlesource.com/c/skia/+/874238 > > https://github.com/webgpu-native/webgpu-headers/pull/308 > > Bug: 42241167 > Change-Id: Ib6266b6981fb8caf38b734977ceaeeeed2cf55f9 > Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/197214 > Reviewed-by: Austin Eng > Commit-Queue: Fr # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 42241167 Change-Id: I4fd367f0fb2b23ded925822ba238c64c43a9c3d3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/203463 Reviewed-by: Austin Eng Reviewed-by: Brandon Jones Commit-Queue: Brandon Jones Commit-Queue: Loko Kung --- generator/dawn_json_generator.py | 3 +- generator/templates/api.h | 1 - generator/templates/api_cpp.h | 72 +------------------ generator/templates/api_cpp_print.h | 2 +- .../templates/dawn/native/ValidationUtils.cpp | 4 +- .../templates/dawn/native/api_absl_format.cpp | 6 +- src/dawn/common/xlib_with_undefs.h | 2 - src/dawn/dawn.json | 10 +-- src/dawn/native/BlitBufferToDepthStencil.cpp | 4 +- src/dawn/native/BlitColorToColorWithDraw.cpp | 2 +- src/dawn/native/BlitDepthToDepth.cpp | 2 +- src/dawn/native/RenderPipeline.cpp | 27 +++---- src/dawn/native/d3d11/RenderPipelineD3D11.cpp | 12 ++-- src/dawn/native/d3d12/RenderPipelineD3D12.cpp | 5 +- src/dawn/native/metal/RenderPipelineMTL.mm | 3 +- src/dawn/native/opengl/RenderPipelineGL.cpp | 4 +- src/dawn/native/vulkan/RenderPipelineVk.cpp | 5 +- .../vulkan/ResolveTextureLoadingUtilsVk.cpp | 1 - src/dawn/node/binding/Converter.cpp | 9 ++- src/dawn/node/binding/Converter.h | 1 - src/dawn/tests/end2end/DepthBiasTests.cpp | 2 +- .../tests/end2end/DepthStencilCopyTests.cpp | 4 +- .../end2end/DepthStencilSamplingTests.cpp | 2 +- .../tests/end2end/DepthStencilStateTests.cpp | 50 ++++++------- src/dawn/tests/end2end/FragDepthTests.cpp | 8 +-- .../end2end/MultisampledRenderingTests.cpp | 2 +- .../end2end/MultisampledSamplingTests.cpp | 2 +- .../tests/end2end/PrimitiveStateTests.cpp | 4 +- .../ReadOnlyDepthStencilAttachmentTests.cpp | 4 +- src/dawn/tests/end2end/ShaderTests.cpp | 2 +- .../end2end/VertexOnlyRenderPipelineTests.cpp | 16 ++--- src/dawn/tests/end2end/ViewportTests.cpp | 2 +- .../validation/CompatValidationTests.cpp | 2 +- .../PipelineAndPassCompatibilityTests.cpp | 2 +- .../RenderPipelineValidationTests.cpp | 49 ++++++------- .../unittests/wire/WireOptionalTests.cpp | 4 +- .../utils/ComboRenderPipelineDescriptor.cpp | 2 +- tools/android/BUILD.gn | 1 - .../android/dawn/MappedNamedConstantsTest.kt | 1 - 39 files changed, 121 insertions(+), 213 deletions(-) diff --git a/generator/dawn_json_generator.py b/generator/dawn_json_generator.py index 4932e423dd7..dff8f81dae1 100644 --- a/generator/dawn_json_generator.py +++ b/generator/dawn_json_generator.py @@ -145,8 +145,7 @@ def __init__(self, is_enabled, name, json_data): value += prefix if value_name == "undefined": - if name != "optional bool": - assert value == 0 + assert value == 0 self.hasUndefined = True if value != lastValue + 1: self.contiguousFromZero = False diff --git a/generator/templates/api.h b/generator/templates/api.h index 6106216eff9..3322b6b35a1 100644 --- a/generator/templates/api.h +++ b/generator/templates/api.h @@ -73,7 +73,6 @@ #endif #define WGPU_BREAKING_CHANGE_DEPTH_CLIP_CONTROL -#define WGPU_BREAKING_CHANGE_DEPTH_WRITE_ENABLED #include #include diff --git a/generator/templates/api_cpp.h b/generator/templates/api_cpp.h index 49315cb0cb5..e88d34a5be4 100644 --- a/generator/templates/api_cpp.h +++ b/generator/templates/api_cpp.h @@ -100,9 +100,7 @@ static T& AsNonConstReference(const T& value) { ) {%- endmacro -%} -//* Although 'optional bool' is defined as an enum value, in C++, we manually implement it to -//* provide conversion utilities. -{% for type in by_category["enum"] if type.name.get() != "optional bool" %} +{% for type in by_category["enum"] %} {% set CppType = as_cppType(type.name) %} {% set CType = as_cType(type.name) %} enum class {{CppType}} : uint32_t { @@ -155,67 +153,6 @@ class {{BoolCppType}} { {{BoolCType}} mValue = static_cast<{{BoolCType}}>(false); }; -// Special class for optional booleans in order to allow conversions. -{% set OptionalBool = types["optional bool"] %} -{% set OptionalBoolCppType = as_cppType(OptionalBool.name) %} -{% set OptionalBoolCType = as_cType(OptionalBool.name) %} -{% set OptionalBoolUndefined = as_cEnum(OptionalBool.name, find_by_name(OptionalBool.values, "undefined").name) %} -class {{OptionalBoolCppType}} { - public: - constexpr {{OptionalBoolCppType}}() = default; - // NOLINTNEXTLINE(runtime/explicit) allow implicit construction - constexpr {{OptionalBoolCppType}}(bool value) : mValue(static_cast<{{OptionalBoolCType}}>(value)) {} - // NOLINTNEXTLINE(runtime/explicit) allow implicit construction - constexpr {{OptionalBoolCppType}}(std::optional value) : - mValue(value ? static_cast<{{OptionalBoolCType}}>(*value) : {{OptionalBoolUndefined}}) {} - // NOLINTNEXTLINE(runtime/explicit) allow implicit construction - constexpr {{OptionalBoolCppType}}({{OptionalBoolCType}} value): mValue(value) {} - - // Define the values that are equivalent to the enums. - {% for value in OptionalBool.values %} - static const {{OptionalBoolCppType}} {{as_cppEnum(value.name)}}; - {% endfor %} - - // Assignment operators. - {{OptionalBoolCppType}}& operator=(const bool& value) { - mValue = static_cast<{{OptionalBoolCType}}>(value); - return *this; - } - {{OptionalBoolCppType}}& operator=(const std::optional& value) { - mValue = value ? static_cast<{{OptionalBoolCType}}>(*value) : {{OptionalBoolUndefined}}; - return *this; - } - {{OptionalBoolCppType}}& operator=(const {{OptionalBoolCType}}& value) { - mValue = value; - return *this; - } - - // Conversion functions. - operator {{OptionalBoolCType}}() const { return mValue; } - operator std::optional() const { - if (mValue == {{OptionalBoolUndefined}}) { - return std::nullopt; - } - return static_cast(mValue); - } - - // Comparison functions. - bool operator==({{OptionalBoolCType}} rhs) const { - return mValue == rhs; - } - bool operator!=({{OptionalBoolCType}} rhs) const { - return mValue != rhs; - } - - private: - friend struct std::hash<{{OptionalBoolCppType}}>; - // Default to undefined. - {{OptionalBoolCType}} mValue = {{OptionalBoolUndefined}}; -}; -{% for value in OptionalBool.values %} - inline const {{OptionalBoolCppType}} {{OptionalBoolCppType}}::{{as_cppEnum(value.name)}} = {{OptionalBoolCppType}}({{as_cEnum(OptionalBool.name, value.name)}}); -{% endfor %} - // Helper class to wrap Status which allows implicit conversion to bool. // Used while callers switch to checking the Status enum instead of booleans. // TODO(crbug.com/42241199): Remove when all callers check the enum. @@ -1015,13 +952,6 @@ struct hash<{{metadata.namespace}}::{{BoolCppType}}> { return hash()(v); } }; -template <> -struct hash<{{metadata.namespace}}::{{OptionalBoolCppType}}> { - public: - size_t operator()(const {{metadata.namespace}}::{{OptionalBoolCppType}} &v) const { - return hash<{{OptionalBoolCType}}>()(v.mValue); - } -}; } // namespace std #endif // {{PREFIX}}{{API}}_CPP_H_ diff --git a/generator/templates/api_cpp_print.h b/generator/templates/api_cpp_print.h index 4c7c84a2ea0..42d03a387c4 100644 --- a/generator/templates/api_cpp_print.h +++ b/generator/templates/api_cpp_print.h @@ -39,7 +39,7 @@ namespace {{metadata.namespace}} { - {% for type in by_category["enum"] if type.name.get() != "optional bool" %} + {% for type in by_category["enum"] %} template std::basic_ostream& operator<<(std::basic_ostream& o, {{as_cppType(type.name)}} value) { switch (value) { diff --git a/generator/templates/dawn/native/ValidationUtils.cpp b/generator/templates/dawn/native/ValidationUtils.cpp index a7cd252ce75..95dcddd19fb 100644 --- a/generator/templates/dawn/native/ValidationUtils.cpp +++ b/generator/templates/dawn/native/ValidationUtils.cpp @@ -36,9 +36,9 @@ namespace {{native_namespace}} { {% set namespace = metadata.namespace %} {% for type in by_category["enum"] %} MaybeError Validate{{type.name.CamelCase()}}({{namespace}}::{{as_cppType(type.name)}} value) { - switch ({{as_cType(type.name)}}(value)) { + switch (value) { {% for value in type.values if value.valid %} - case {{as_cEnum(type.name, value.name)}}: + case {{namespace}}::{{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}: return {}; {% endfor %} default: diff --git a/generator/templates/dawn/native/api_absl_format.cpp b/generator/templates/dawn/native/api_absl_format.cpp index bdac4ade997..f0fc7893095 100644 --- a/generator/templates/dawn/native/api_absl_format.cpp +++ b/generator/templates/dawn/native/api_absl_format.cpp @@ -85,9 +85,9 @@ namespace {{namespace}} { absl::FormatSink* s) { if (spec.conversion_char() == absl::FormatConversionChar::s) { s->Append("{{as_cppType(type.name)}}::"); - switch ({{as_cType(type.name)}}(value)) { + switch (value) { {% for value in type.values %} - case {{as_cEnum(type.name, value.name)}}: + case {{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}: s->Append("{{as_cppEnum(value.name)}}"); return {true}; {% endfor %} @@ -95,7 +95,7 @@ namespace {{namespace}} { break; } } - s->Append(absl::StrFormat("%u", static_cast<{{as_cType(type.name)}}>(value))); + s->Append(absl::StrFormat("%u", static_cast::type>(value))); return {true}; } {% endfor %} diff --git a/src/dawn/common/xlib_with_undefs.h b/src/dawn/common/xlib_with_undefs.h index 9fc22420674..6f419e8bbf0 100644 --- a/src/dawn/common/xlib_with_undefs.h +++ b/src/dawn/common/xlib_with_undefs.h @@ -48,8 +48,6 @@ #undef Always #undef Bool #undef Status -#undef False -#undef True using XErrorHandler = int (*)(Display*, XErrorEvent*); diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json index 9ab4fbbbfe0..ad1b051aaf8 100644 --- a/src/dawn/dawn.json +++ b/src/dawn/dawn.json @@ -625,14 +625,6 @@ "category": "native", "wasm type": "i" }, - "optional bool": { - "category": "enum", - "values": [ - {"value": 0, "name": "false"}, - {"value": 1, "name": "true"}, - {"value": 2, "name": "undefined", "jsrepr": "undefined"} - ] - }, "string view": { "category": "structure", "members": [ @@ -3818,7 +3810,7 @@ "extensible": "in", "members": [ {"name": "format", "type": "texture format"}, - {"name": "depth write enabled", "type": "optional bool", "default": "undefined"}, + {"name": "depth write enabled", "type": "bool", "default": "false"}, {"name": "depth compare", "type": "compare function", "default": "undefined"}, {"name": "stencil front", "type": "stencil face state"}, {"name": "stencil back", "type": "stencil face state"}, diff --git a/src/dawn/native/BlitBufferToDepthStencil.cpp b/src/dawn/native/BlitBufferToDepthStencil.cpp index 0ecdc89c59e..c6bf28a7933 100644 --- a/src/dawn/native/BlitBufferToDepthStencil.cpp +++ b/src/dawn/native/BlitBufferToDepthStencil.cpp @@ -162,7 +162,7 @@ ResultOrError> GetOrCreateRG8ToDepth16UnormPipeline(Devi DepthStencilState dsState = {}; dsState.format = wgpu::TextureFormat::Depth16Unorm; - dsState.depthWriteEnabled = wgpu::OptionalBool::True; + dsState.depthWriteEnabled = true; dsState.depthCompare = wgpu::CompareFunction::Always; RenderPipelineDescriptor renderPipelineDesc = {}; @@ -226,7 +226,7 @@ ResultOrError GetOrCreateR8ToSt DepthStencilState dsState = {}; dsState.format = format; - dsState.depthWriteEnabled = wgpu::OptionalBool::False; + dsState.depthWriteEnabled = false; dsState.depthCompare = wgpu::CompareFunction::Always; dsState.stencilFront.passOp = wgpu::StencilOperation::Replace; diff --git a/src/dawn/native/BlitColorToColorWithDraw.cpp b/src/dawn/native/BlitColorToColorWithDraw.cpp index 14566ce6513..124607b72fc 100644 --- a/src/dawn/native/BlitColorToColorWithDraw.cpp +++ b/src/dawn/native/BlitColorToColorWithDraw.cpp @@ -171,7 +171,7 @@ ResultOrError> GetOrCreateExpandMultisamplePipeline( DepthStencilState depthStencilState = {}; if (pipelineKey.depthStencilFormat != wgpu::TextureFormat::Undefined) { depthStencilState.format = pipelineKey.depthStencilFormat; - depthStencilState.depthWriteEnabled = wgpu::OptionalBool::False; + depthStencilState.depthWriteEnabled = false; depthStencilState.depthCompare = wgpu::CompareFunction::Always; renderPipelineDesc.depthStencil = &depthStencilState; diff --git a/src/dawn/native/BlitDepthToDepth.cpp b/src/dawn/native/BlitDepthToDepth.cpp index c2115767300..79d3da83ae6 100644 --- a/src/dawn/native/BlitDepthToDepth.cpp +++ b/src/dawn/native/BlitDepthToDepth.cpp @@ -87,7 +87,7 @@ ResultOrError> GetOrCreateDepthBlitPipeline(DeviceBase* DepthStencilState dsState = {}; dsState.format = format; - dsState.depthWriteEnabled = wgpu::OptionalBool::True; + dsState.depthWriteEnabled = true; dsState.depthCompare = wgpu::CompareFunction::Always; RenderPipelineDescriptor renderPipelineDesc = {}; diff --git a/src/dawn/native/RenderPipeline.cpp b/src/dawn/native/RenderPipeline.cpp index 64d8f4123e2..813de672799 100644 --- a/src/dawn/native/RenderPipeline.cpp +++ b/src/dawn/native/RenderPipeline.cpp @@ -337,19 +337,23 @@ MaybeError ValidateDepthStencilState(const DeviceBase* device, DAWN_INVALID_IF( format->HasDepth() && descriptor->depthCompare == wgpu::CompareFunction::Undefined && - (descriptor->depthWriteEnabled == wgpu::OptionalBool::True || + (descriptor->depthWriteEnabled || descriptor->stencilFront.depthFailOp != wgpu::StencilOperation::Keep || descriptor->stencilBack.depthFailOp != wgpu::StencilOperation::Keep), "Depth stencil format (%s) has a depth aspect and depthCompare is %s while it's actually " - "used by depthWriteEnabled (%s), or stencil front depth fail operation (%s), or " + "used by depthWriteEnabled (%u), or stencil front depth fail operation (%s), or " "stencil back depth fail operation (%s).", descriptor->format, wgpu::CompareFunction::Undefined, descriptor->depthWriteEnabled, descriptor->stencilFront.depthFailOp, descriptor->stencilBack.depthFailOp); - DAWN_INVALID_IF( - format->HasDepth() && descriptor->depthWriteEnabled == wgpu::OptionalBool::Undefined, - "Depth stencil format (%s) has a depth aspect and depthWriteEnabled is undefined.", - descriptor->format); + UnpackedPtr unpacked; + DAWN_TRY_ASSIGN(unpacked, ValidateAndUnpack(descriptor)); + if (const auto* depthWriteDefined = unpacked.Get()) { + DAWN_INVALID_IF( + format->HasDepth() && !depthWriteDefined->depthWriteDefined, + "Depth stencil format (%s) has a depth aspect and depthWriteEnabled is undefined.", + descriptor->format); + } DAWN_INVALID_IF( !format->HasDepth() && descriptor->depthCompare != wgpu::CompareFunction::Always && @@ -360,9 +364,8 @@ MaybeError ValidateDepthStencilState(const DeviceBase* device, wgpu::CompareFunction::Undefined); DAWN_INVALID_IF( - !format->HasDepth() && descriptor->depthWriteEnabled == wgpu::OptionalBool::True, - "Depth stencil format (%s) doesn't have depth aspect while depthWriteEnabled (%s) " - "is true.", + !format->HasDepth() && descriptor->depthWriteEnabled, + "Depth stencil format (%s) doesn't have depth aspect while depthWriteEnabled (%u) is true.", descriptor->format, descriptor->depthWriteEnabled); if (!format->HasStencil()) { @@ -975,16 +978,16 @@ RenderPipelineBase::RenderPipelineBase(DeviceBase* device, // Reify depth option for stencil-only formats const Format& format = device->GetValidInternalFormat(mDepthStencil.format); if (!format.HasDepth()) { - mDepthStencil.depthWriteEnabled = wgpu::OptionalBool::False; + mDepthStencil.depthWriteEnabled = false; mDepthStencil.depthCompare = wgpu::CompareFunction::Always; } if (format.HasDepth() && mDepthStencil.depthCompare == wgpu::CompareFunction::Undefined && - mDepthStencil.depthWriteEnabled != wgpu::OptionalBool::True && + !mDepthStencil.depthWriteEnabled && mDepthStencil.stencilFront.depthFailOp == wgpu::StencilOperation::Keep && mDepthStencil.stencilBack.depthFailOp == wgpu::StencilOperation::Keep) { mDepthStencil.depthCompare = wgpu::CompareFunction::Always; } - mWritesDepth = mDepthStencil.depthWriteEnabled == wgpu::OptionalBool::True; + mWritesDepth = mDepthStencil.depthWriteEnabled; if (mDepthStencil.stencilWriteMask) { if ((mPrimitive.cullMode != wgpu::CullMode::Front && (mDepthStencil.stencilFront.failOp != wgpu::StencilOperation::Keep || diff --git a/src/dawn/native/d3d11/RenderPipelineD3D11.cpp b/src/dawn/native/d3d11/RenderPipelineD3D11.cpp index 2c86c56edd1..91fc8412355 100644 --- a/src/dawn/native/d3d11/RenderPipelineD3D11.cpp +++ b/src/dawn/native/d3d11/RenderPipelineD3D11.cpp @@ -405,13 +405,11 @@ MaybeError RenderPipeline::InitializeDepthStencilState() { const DepthStencilState* state = GetDepthStencilState(); D3D11_DEPTH_STENCIL_DESC depthStencilDesc = {}; - depthStencilDesc.DepthEnable = (state->depthCompare == wgpu::CompareFunction::Always && - state->depthWriteEnabled != wgpu::OptionalBool::True) - ? FALSE - : TRUE; - depthStencilDesc.DepthWriteMask = state->depthWriteEnabled == wgpu::OptionalBool::True - ? D3D11_DEPTH_WRITE_MASK_ALL - : D3D11_DEPTH_WRITE_MASK_ZERO; + depthStencilDesc.DepthEnable = + (state->depthCompare == wgpu::CompareFunction::Always && !state->depthWriteEnabled) ? FALSE + : TRUE; + depthStencilDesc.DepthWriteMask = + state->depthWriteEnabled ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO; depthStencilDesc.DepthFunc = ToD3D11ComparisonFunc(state->depthCompare); depthStencilDesc.StencilEnable = UsesStencil() ? TRUE : FALSE; diff --git a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp index 7d727d5cde4..0784d272375 100644 --- a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp +++ b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp @@ -555,12 +555,11 @@ D3D12_DEPTH_STENCIL_DESC RenderPipeline::ComputeDepthStencilDesc() { D3D12_DEPTH_STENCIL_DESC depthStencilDescriptor = {}; depthStencilDescriptor.DepthEnable = (descriptor->depthCompare == wgpu::CompareFunction::Always && - descriptor->depthWriteEnabled != wgpu::OptionalBool::True) + !descriptor->depthWriteEnabled) ? FALSE : TRUE; depthStencilDescriptor.DepthWriteMask = - descriptor->depthWriteEnabled == wgpu::OptionalBool::True ? D3D12_DEPTH_WRITE_MASK_ALL - : D3D12_DEPTH_WRITE_MASK_ZERO; + descriptor->depthWriteEnabled ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; depthStencilDescriptor.DepthFunc = ToD3D12ComparisonFunc(descriptor->depthCompare); depthStencilDescriptor.StencilEnable = UsesStencil() ? TRUE : FALSE; diff --git a/src/dawn/native/metal/RenderPipelineMTL.mm b/src/dawn/native/metal/RenderPipelineMTL.mm index 51356d1f866..f0ddef54a16 100644 --- a/src/dawn/native/metal/RenderPipelineMTL.mm +++ b/src/dawn/native/metal/RenderPipelineMTL.mm @@ -546,8 +546,7 @@ MTLCullMode ToMTLCullMode(wgpu::CullMode mode) { mtlDepthStencilDescriptor.depthCompareFunction = ToMetalCompareFunction(descriptor->depthCompare); - mtlDepthStencilDescriptor.depthWriteEnabled = - descriptor->depthWriteEnabled == wgpu::OptionalBool::True; + mtlDepthStencilDescriptor.depthWriteEnabled = descriptor->depthWriteEnabled; if (UsesStencil()) { NSRef backFaceStencilRef = AcquireNSRef([MTLStencilDescriptor new]); diff --git a/src/dawn/native/opengl/RenderPipelineGL.cpp b/src/dawn/native/opengl/RenderPipelineGL.cpp index cd0387c752a..57991a0bc62 100644 --- a/src/dawn/native/opengl/RenderPipelineGL.cpp +++ b/src/dawn/native/opengl/RenderPipelineGL.cpp @@ -345,13 +345,13 @@ void RenderPipeline::ApplyDepthStencilState(const OpenGLFunctions& gl, // Depth writes only occur if depth is enabled if (descriptor->depthCompare == wgpu::CompareFunction::Always && - descriptor->depthWriteEnabled != wgpu::OptionalBool::True) { + !descriptor->depthWriteEnabled) { gl.Disable(GL_DEPTH_TEST); } else { gl.Enable(GL_DEPTH_TEST); } - if (descriptor->depthWriteEnabled == wgpu::OptionalBool::True) { + if (descriptor->depthWriteEnabled) { gl.DepthMask(GL_TRUE); } else { gl.DepthMask(GL_FALSE); diff --git a/src/dawn/native/vulkan/RenderPipelineVk.cpp b/src/dawn/native/vulkan/RenderPipelineVk.cpp index 55860c518dc..b88fbd8c19f 100644 --- a/src/dawn/native/vulkan/RenderPipelineVk.cpp +++ b/src/dawn/native/vulkan/RenderPipelineVk.cpp @@ -656,11 +656,10 @@ VkPipelineDepthStencilStateCreateInfo RenderPipeline::ComputeDepthStencilDesc() // Depth writes only occur if depth is enabled depthStencilState.depthTestEnable = (descriptor->depthCompare == wgpu::CompareFunction::Always && - descriptor->depthWriteEnabled != wgpu::OptionalBool::True) + !descriptor->depthWriteEnabled) ? VK_FALSE : VK_TRUE; - depthStencilState.depthWriteEnable = - descriptor->depthWriteEnabled == wgpu::OptionalBool::True ? VK_TRUE : VK_FALSE; + depthStencilState.depthWriteEnable = descriptor->depthWriteEnabled ? VK_TRUE : VK_FALSE; depthStencilState.depthCompareOp = ToVulkanCompareOp(descriptor->depthCompare); depthStencilState.depthBoundsTestEnable = false; depthStencilState.minDepthBounds = 0.0f; diff --git a/src/dawn/native/vulkan/ResolveTextureLoadingUtilsVk.cpp b/src/dawn/native/vulkan/ResolveTextureLoadingUtilsVk.cpp index 1bc34c7836c..6f4cf7c3e72 100644 --- a/src/dawn/native/vulkan/ResolveTextureLoadingUtilsVk.cpp +++ b/src/dawn/native/vulkan/ResolveTextureLoadingUtilsVk.cpp @@ -155,7 +155,6 @@ ResultOrError> GetOrCreateColorBlitPipeline( DepthStencilState depthStencilState = {}; if (pipelineKey.depthStencilFormat != wgpu::TextureFormat::Undefined) { depthStencilState.format = pipelineKey.depthStencilFormat; - depthStencilState.depthWriteEnabled = wgpu::OptionalBool::False; renderPipelineDesc.depthStencil = &depthStencilState; } diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp index 181c42ac560..c3c383d2453 100644 --- a/src/dawn/node/binding/Converter.cpp +++ b/src/dawn/node/binding/Converter.cpp @@ -922,6 +922,10 @@ bool Converter::Convert(wgpu::ColorTargetState& out, const interop::GPUColorTarg bool Converter::Convert(wgpu::DepthStencilState& out, const interop::GPUDepthStencilState& in) { out = {}; + auto depthWriteDefined = Allocate(); + depthWriteDefined->depthWriteDefined = in.depthWriteEnabled.has_value(); + out.nextInChain = depthWriteDefined; + return Convert(out.format, in.format) && Convert(out.depthWriteEnabled, in.depthWriteEnabled) && Convert(out.depthCompare, in.depthCompare) && Convert(out.stencilFront, in.stencilFront) && Convert(out.stencilBack, in.stencilBack) && @@ -1730,11 +1734,6 @@ bool Converter::Convert(wgpu::Bool& out, const bool& in) { return true; } -bool Converter::Convert(wgpu::OptionalBool& out, const std::optional& in) { - out = in; - return true; -} - char* Converter::ConvertStringReplacingNull(std::string_view in) { char* out = Allocate(in.size() + 1); out[in.size()] = '\0'; diff --git a/src/dawn/node/binding/Converter.h b/src/dawn/node/binding/Converter.h index 7eeb76be02a..363d07605a2 100644 --- a/src/dawn/node/binding/Converter.h +++ b/src/dawn/node/binding/Converter.h @@ -268,7 +268,6 @@ class Converter { [[nodiscard]] bool Convert(wgpu::PipelineLayout& out, const interop::GPUAutoLayoutMode& in); [[nodiscard]] bool Convert(wgpu::Bool& out, const bool& in); - [[nodiscard]] bool Convert(wgpu::OptionalBool& out, const std::optional& in); // Below are the various overloads of Convert() used to convert the Dawn types -> interop. [[nodiscard]] bool Convert(interop::GPUTextureDimension& out, wgpu::TextureDimension in); diff --git a/src/dawn/tests/end2end/DepthBiasTests.cpp b/src/dawn/tests/end2end/DepthBiasTests.cpp index 43f817bd31f..59667311f3d 100644 --- a/src/dawn/tests/end2end/DepthBiasTests.cpp +++ b/src/dawn/tests/end2end/DepthBiasTests.cpp @@ -125,7 +125,7 @@ class DepthBiasTests : public DawnTest { renderPipelineDesc.vertex.module = vertexModule; renderPipelineDesc.cFragment.module = fragmentModule; wgpu::DepthStencilState* depthStencil = renderPipelineDesc.EnableDepthStencil(depthFormat); - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; depthStencil->depthBias = bias; depthStencil->depthBiasSlopeScale = biasSlopeScale; depthStencil->depthBiasClamp = biasClamp; diff --git a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp index 1eb060eb544..0cae10b5395 100644 --- a/src/dawn/tests/end2end/DepthStencilCopyTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilCopyTests.cpp @@ -216,7 +216,7 @@ class DepthStencilCopyTests : public DawnTestWithParamsdepthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, std::string(R"( @fragment fn main() -> @builtin(frag_depth) f32 { return )" + std::to_string(regionDepth) + R"(; @@ -1109,7 +1109,7 @@ class StencilCopyTests : public DepthStencilCopyTests { renderPipelineDesc.EnableDepthStencil(GetParam().mTextureFormat); depthStencil->stencilFront.passOp = wgpu::StencilOperation::DecrementClamp; if (!hasDepth) { - depthStencil->depthWriteEnabled = wgpu::OptionalBool::False; + depthStencil->depthWriteEnabled = false; depthStencil->depthCompare = wgpu::CompareFunction::Always; } diff --git a/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp b/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp index edbe12f4353..0f7835ded6d 100644 --- a/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilSamplingTests.cpp @@ -690,7 +690,7 @@ TEST_P(DepthStencilSamplingTest, CheckDepthTextureRange) { pDesc1.cTargets[0].format = wgpu::TextureFormat::R32Float; pDesc1.primitive.topology = wgpu::PrimitiveTopology::PointList; pDesc1.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8); - pDesc1.cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::True; + pDesc1.cDepthStencil.depthWriteEnabled = true; wgpu::RenderPipeline pipeline1 = device.CreateRenderPipeline(&pDesc1); // The second pipeline checks the depth texture and outputs 1 to a texel on success. diff --git a/src/dawn/tests/end2end/DepthStencilStateTests.cpp b/src/dawn/tests/end2end/DepthStencilStateTests.cpp index bca6738810e..2071920651e 100644 --- a/src/dawn/tests/end2end/DepthStencilStateTests.cpp +++ b/src/dawn/tests/end2end/DepthStencilStateTests.cpp @@ -126,7 +126,7 @@ class DepthStencilStateTest : public DawnTest { stencilFace.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::True; + baseState.depthWriteEnabled = true; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = stencilFace; baseState.stencilFront = stencilFace; @@ -134,7 +134,7 @@ class DepthStencilStateTest : public DawnTest { baseState.stencilWriteMask = 0xff; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::True; + state.depthWriteEnabled = true; state.depthCompare = compareFunction; state.stencilBack = stencilFace; state.stencilFront = stencilFace; @@ -175,7 +175,7 @@ class DepthStencilStateTest : public DawnTest { baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::False; + baseState.depthWriteEnabled = false; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilFront = baseStencilFaceDescriptor; @@ -188,7 +188,7 @@ class DepthStencilStateTest : public DawnTest { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -228,7 +228,7 @@ class DepthStencilStateTest : public DawnTest { baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::False; + baseState.depthWriteEnabled = false; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilFront = baseStencilFaceDescriptor; @@ -241,7 +241,7 @@ class DepthStencilStateTest : public DawnTest { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = stencilOperation; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -267,7 +267,7 @@ class DepthStencilStateTest : public DawnTest { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -394,7 +394,7 @@ TEST_P(DepthStencilStateTest, Basic) { stencilFace.passOp = wgpu::StencilOperation::Undefined; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFace; state.stencilFront = stencilFace; @@ -417,7 +417,7 @@ TEST_P(DepthStencilStateTest, DepthStencilDisabled) { stencilFace.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFace; state.stencilFront = stencilFace; @@ -482,7 +482,7 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) { stencilFace.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::True; + baseState.depthWriteEnabled = true; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = stencilFace; baseState.stencilFront = stencilFace; @@ -490,7 +490,7 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) { baseState.stencilWriteMask = 0xff; wgpu::DepthStencilState noDepthWrite; - noDepthWrite.depthWriteEnabled = wgpu::OptionalBool::False; + noDepthWrite.depthWriteEnabled = false; noDepthWrite.depthCompare = wgpu::CompareFunction::Always; noDepthWrite.stencilBack = stencilFace; noDepthWrite.stencilFront = stencilFace; @@ -498,7 +498,7 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) { noDepthWrite.stencilWriteMask = 0xff; wgpu::DepthStencilState checkState; - checkState.depthWriteEnabled = wgpu::OptionalBool::False; + checkState.depthWriteEnabled = false; checkState.depthCompare = wgpu::CompareFunction::Equal; checkState.stencilBack = stencilFace; checkState.stencilFront = stencilFace; @@ -596,7 +596,7 @@ TEST_P(DepthStencilStateTest, StencilReadMask) { baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::False; + baseState.depthWriteEnabled = false; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilFront = baseStencilFaceDescriptor; @@ -609,7 +609,7 @@ TEST_P(DepthStencilStateTest, StencilReadMask) { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -635,7 +635,7 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) { baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::False; + baseState.depthWriteEnabled = false; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilFront = baseStencilFaceDescriptor; @@ -648,7 +648,7 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -674,7 +674,7 @@ TEST_P(DepthStencilStateTest, StencilFail) { baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::False; + baseState.depthWriteEnabled = false; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilFront = baseStencilFaceDescriptor; @@ -687,7 +687,7 @@ TEST_P(DepthStencilStateTest, StencilFail) { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -712,7 +712,7 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) { baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::True; + baseState.depthWriteEnabled = true; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilFront = baseStencilFaceDescriptor; @@ -725,7 +725,7 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Replace; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::True; + state.depthWriteEnabled = true; state.depthCompare = wgpu::CompareFunction::Less; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -748,7 +748,7 @@ TEST_P(DepthStencilStateTest, StencilDepthPass) { baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState baseState; - baseState.depthWriteEnabled = wgpu::OptionalBool::True; + baseState.depthWriteEnabled = true; baseState.depthCompare = wgpu::CompareFunction::Always; baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilFront = baseStencilFaceDescriptor; @@ -761,7 +761,7 @@ TEST_P(DepthStencilStateTest, StencilDepthPass) { stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::True; + state.depthWriteEnabled = true; state.depthCompare = wgpu::CompareFunction::Less; state.stencilBack = stencilFaceDescriptor; state.stencilFront = stencilFaceDescriptor; @@ -798,7 +798,7 @@ TEST_P(DepthStencilStateTest, CreatePipelineWithAllFormats) { // Test that the front and back stencil states are set correctly (and take frontFace into account) TEST_P(DepthStencilStateTest, StencilFrontAndBackFace) { wgpu::DepthStencilState state; - state.depthWriteEnabled = wgpu::OptionalBool::False; + state.depthWriteEnabled = false; state.depthCompare = wgpu::CompareFunction::Always; state.stencilFront.compare = wgpu::CompareFunction::Always; state.stencilBack.compare = wgpu::CompareFunction::Never; @@ -813,7 +813,7 @@ TEST_P(DepthStencilStateTest, StencilFrontAndBackFace) { // Test that the depth reference of a new render pass is initialized to default value 0 TEST_P(DepthStencilStateTest, StencilReferenceInitialized) { wgpu::DepthStencilState stencilAlwaysReplaceState; - stencilAlwaysReplaceState.depthWriteEnabled = wgpu::OptionalBool::False; + stencilAlwaysReplaceState.depthWriteEnabled = false; stencilAlwaysReplaceState.depthCompare = wgpu::CompareFunction::Always; stencilAlwaysReplaceState.stencilFront.compare = wgpu::CompareFunction::Always; stencilAlwaysReplaceState.stencilFront.passOp = wgpu::StencilOperation::Replace; @@ -821,7 +821,7 @@ TEST_P(DepthStencilStateTest, StencilReferenceInitialized) { stencilAlwaysReplaceState.stencilBack.passOp = wgpu::StencilOperation::Replace; wgpu::DepthStencilState stencilEqualKeepState; - stencilEqualKeepState.depthWriteEnabled = wgpu::OptionalBool::False; + stencilEqualKeepState.depthWriteEnabled = false; stencilEqualKeepState.depthCompare = wgpu::CompareFunction::Always; stencilEqualKeepState.stencilFront.compare = wgpu::CompareFunction::Equal; stencilEqualKeepState.stencilFront.passOp = wgpu::StencilOperation::Keep; diff --git a/src/dawn/tests/end2end/FragDepthTests.cpp b/src/dawn/tests/end2end/FragDepthTests.cpp index fb490b9a4a1..9af05335cf5 100644 --- a/src/dawn/tests/end2end/FragDepthTests.cpp +++ b/src/dawn/tests/end2end/FragDepthTests.cpp @@ -56,7 +56,7 @@ TEST_P(FragDepthTests, FragDepthIsClampedToViewport) { pDesc.cFragment.targetCount = 0; wgpu::DepthStencilState* pDescDS = pDesc.EnableDepthStencil(kDepthFormat); - pDescDS->depthWriteEnabled = wgpu::OptionalBool::True; + pDescDS->depthWriteEnabled = true; pDescDS->depthCompare = wgpu::CompareFunction::Always; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pDesc); @@ -119,7 +119,7 @@ TEST_P(FragDepthTests, ChangingPipelineLayoutDoesntInvalidateViewport) { upDesc.cFragment.targetCount = 0; wgpu::DepthStencilState* upDescDS = upDesc.EnableDepthStencil(kDepthFormat); - upDescDS->depthWriteEnabled = wgpu::OptionalBool::True; + upDescDS->depthWriteEnabled = true; upDescDS->depthCompare = wgpu::CompareFunction::Always; wgpu::RenderPipeline uniformPipeline = device.CreateRenderPipeline(&upDesc); @@ -137,7 +137,7 @@ TEST_P(FragDepthTests, ChangingPipelineLayoutDoesntInvalidateViewport) { spDesc.cFragment.targetCount = 0; wgpu::DepthStencilState* spDescDS = spDesc.EnableDepthStencil(kDepthFormat); - spDescDS->depthWriteEnabled = wgpu::OptionalBool::True; + spDescDS->depthWriteEnabled = true; spDescDS->depthCompare = wgpu::CompareFunction::Always; wgpu::RenderPipeline storagePipeline = device.CreateRenderPipeline(&spDesc); @@ -203,7 +203,7 @@ TEST_P(FragDepthTests, RasterizationClipBeforeFS) { pDesc.cFragment.targetCount = 0; wgpu::DepthStencilState* pDescDS = pDesc.EnableDepthStencil(kDepthFormat); - pDescDS->depthWriteEnabled = wgpu::OptionalBool::True; + pDescDS->depthWriteEnabled = true; pDescDS->depthCompare = wgpu::CompareFunction::Always; wgpu::RenderPipeline uniformPipeline = device.CreateRenderPipeline(&pDesc); diff --git a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp index 9cdd67e5b94..97ba10878d5 100644 --- a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp @@ -334,7 +334,7 @@ class MultisampledRenderingTest : public DawnTest { if (hasDepthStencilAttachment) { wgpu::DepthStencilState* depthStencil = pipelineDescriptor.EnableDepthStencil(kDepthStencilFormat); - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; depthStencil->depthCompare = wgpu::CompareFunction::Less; } diff --git a/src/dawn/tests/end2end/MultisampledSamplingTests.cpp b/src/dawn/tests/end2end/MultisampledSamplingTests.cpp index 3c8ca16c547..39b60b3d527 100644 --- a/src/dawn/tests/end2end/MultisampledSamplingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledSamplingTests.cpp @@ -93,7 +93,7 @@ class MultisampledSamplingTest : public DawnTest { desc.cAttributes[0].format = wgpu::VertexFormat::Float32x2; wgpu::DepthStencilState* depthStencil = desc.EnableDepthStencil(kDepthFormat); - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; desc.multisample.count = kSampleCount; desc.cFragment.targetCount = 1; diff --git a/src/dawn/tests/end2end/PrimitiveStateTests.cpp b/src/dawn/tests/end2end/PrimitiveStateTests.cpp index 284c9c17d61..154bcf23197 100644 --- a/src/dawn/tests/end2end/PrimitiveStateTests.cpp +++ b/src/dawn/tests/end2end/PrimitiveStateTests.cpp @@ -132,7 +132,7 @@ class DepthClippingTest : public DawnTest { descriptor.vertex.module = vsModule; descriptor.cFragment.module = fsModule; wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil(); - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; depthStencil->format = wgpu::TextureFormat::Depth24PlusStencil8; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); @@ -312,7 +312,7 @@ TEST_P(DepthClippingTest, UnclippedNotClamped) { return vec4f(frag_pos.z / 4.0, 0.0, 0.0, 1.0); })"); wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil(); - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; depthStencil->format = wgpu::TextureFormat::Depth24PlusStencil8; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp b/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp index 1237c5bf334..6b7b5356677 100644 --- a/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp +++ b/src/dawn/tests/end2end/ReadOnlyDepthStencilAttachmentTests.cpp @@ -70,7 +70,7 @@ class ReadOnlyDepthStencilAttachmentTests wgpu::CompareFunction depthCompare = wgpu::CompareFunction::Always; wgpu::CompareFunction stencilCompare = wgpu::CompareFunction::Always; - wgpu::OptionalBool depthWriteEnabled = wgpu::OptionalBool::False; + bool depthWriteEnabled = false; bool stencilWriteEnabled = false; float depthClearValue = 0.0; @@ -395,7 +395,7 @@ TEST_P(ReadOnlyDepthAndStencilAttachmentTests, ModifyDepthSampleStencil) { spec1.stencilClearValue = 42; spec1.depthClearValue = 0.2; spec1.depthCompare = wgpu::CompareFunction::LessEqual; - spec1.depthWriteEnabled = wgpu::OptionalBool::True; + spec1.depthWriteEnabled = true; auto render1 = DoRender(spec1); // Stencil was read successfully, but only in the bottom part. diff --git a/src/dawn/tests/end2end/ShaderTests.cpp b/src/dawn/tests/end2end/ShaderTests.cpp index a5309c0c84e..05974b5ca00 100644 --- a/src/dawn/tests/end2end/ShaderTests.cpp +++ b/src/dawn/tests/end2end/ShaderTests.cpp @@ -2198,7 +2198,7 @@ TEST_P(ShaderTests, FragDepthAndInstanceIndex) { desc.cFragment.module = module; desc.cFragment.targetCount = 0; wgpu::DepthStencilState* dsState = desc.EnableDepthStencil(); - dsState->depthWriteEnabled = wgpu::OptionalBool::True; + dsState->depthWriteEnabled = true; dsState->depthCompare = wgpu::CompareFunction::Always; device.CreateRenderPipeline(&desc); diff --git a/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp b/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp index 3118c4dcb9c..22ebed90656 100644 --- a/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp +++ b/src/dawn/tests/end2end/VertexOnlyRenderPipelineTests.cpp @@ -90,32 +90,32 @@ class VertexOnlyRenderPipelineTest : public DawnTest { // ignore the stencil component depthPipelineNoFragment = CreateRenderPipeline(wgpu::CompareFunction::Always, wgpu::StencilOperation::Keep, - wgpu::CompareFunction::Always, wgpu::OptionalBool::True, false); + wgpu::CompareFunction::Always, true, false); depthPipelineWithFragment = CreateRenderPipeline(wgpu::CompareFunction::Always, wgpu::StencilOperation::Keep, - wgpu::CompareFunction::Always, wgpu::OptionalBool::True, true); + wgpu::CompareFunction::Always, true, true); // Create a vertex-only render pipeline that only modify the stencil in DepthStencilView, // and ignore the depth component stencilPipelineNoFragment = CreateRenderPipeline(wgpu::CompareFunction::Always, wgpu::StencilOperation::Replace, - wgpu::CompareFunction::Always, wgpu::OptionalBool::False, false); + wgpu::CompareFunction::Always, false, false); stencilPipelineWithFragment = CreateRenderPipeline(wgpu::CompareFunction::Always, wgpu::StencilOperation::Replace, - wgpu::CompareFunction::Always, wgpu::OptionalBool::False, true); + wgpu::CompareFunction::Always, false, true); // Create a complete render pipeline that do both depth and stencil tests, and draw to color // attachment - fullPipeline = CreateRenderPipeline( - wgpu::CompareFunction::Equal, wgpu::StencilOperation::Keep, - wgpu::CompareFunction::GreaterEqual, wgpu::OptionalBool::False, true); + fullPipeline = + CreateRenderPipeline(wgpu::CompareFunction::Equal, wgpu::StencilOperation::Keep, + wgpu::CompareFunction::GreaterEqual, false, true); } wgpu::RenderPipeline CreateRenderPipeline( wgpu::CompareFunction stencilCompare = wgpu::CompareFunction::Always, wgpu::StencilOperation stencilPassOp = wgpu::StencilOperation::Keep, wgpu::CompareFunction depthCompare = wgpu::CompareFunction::Always, - wgpu::OptionalBool writeDepth = wgpu::OptionalBool::False, + bool writeDepth = false, bool useFragment = true) { wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( @vertex diff --git a/src/dawn/tests/end2end/ViewportTests.cpp b/src/dawn/tests/end2end/ViewportTests.cpp index 11df0696ca6..2d6049b3746 100644 --- a/src/dawn/tests/end2end/ViewportTests.cpp +++ b/src/dawn/tests/end2end/ViewportTests.cpp @@ -122,7 +122,7 @@ class ViewportTest : public DawnTest { pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::PointList; wgpu::DepthStencilState* depthStencil = pipelineDesc.EnableDepthStencil(wgpu::TextureFormat::Depth32Float); - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc); // Create the texture that will store the post-viewport-transform depth. diff --git a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp index 9280c2b1fac..48a1cb2cbc9 100644 --- a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp @@ -202,7 +202,7 @@ TEST_F(CompatValidationTest, CanNotCreatePipelineWithNonZeroDepthBiasClamp) { wgpu::DepthStencilState* depthStencil = testDescriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24Plus); - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; depthStencil->depthBias = 0; depthStencil->depthBiasSlopeScale = 0; diff --git a/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp b/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp index 0e361424b61..32ba3f7ce02 100644 --- a/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp +++ b/src/dawn/tests/unittests/validation/PipelineAndPassCompatibilityTests.cpp @@ -59,7 +59,7 @@ class RenderPipelineAndPassCompatibilityTests : public ValidationTest { // Enable depth/stencil write if needed wgpu::DepthStencilState* depthStencil = pipelineDescriptor.EnableDepthStencil(format); if (enableDepthWrite) { - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; } if (enableStencilWrite) { depthStencil->stencilFront.failOp = wgpu::StencilOperation::Replace; diff --git a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp index 439c6a9664f..d14f8aca77e 100644 --- a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -292,7 +292,7 @@ TEST_F(RenderPipelineValidationTest, DepthStencilAspectRequirement) { wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8); depthStencil->depthCompare = wgpu::CompareFunction::LessEqual; - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; device.CreateRenderPipeline(&descriptor); } @@ -305,7 +305,7 @@ TEST_F(RenderPipelineValidationTest, DepthStencilAspectRequirement) { wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil(wgpu::TextureFormat::Stencil8); depthStencil->depthCompare = wgpu::CompareFunction::LessEqual; - depthStencil->depthWriteEnabled = wgpu::OptionalBool::False; + depthStencil->depthWriteEnabled = false; ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); } @@ -318,7 +318,7 @@ TEST_F(RenderPipelineValidationTest, DepthStencilAspectRequirement) { wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil(wgpu::TextureFormat::Stencil8); depthStencil->depthCompare = wgpu::CompareFunction::Undefined; - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + depthStencil->depthWriteEnabled = true; ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); } } @@ -1363,7 +1363,7 @@ TEST_F(RenderPipelineValidationTest, DepthCompareRequiredForFormatsWithDepth) { descriptor.vertex.module = vsModule; descriptor.cFragment.module = fsModule; - descriptor.cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::True; + descriptor.cDepthStencil.depthWriteEnabled = true; descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth32Float); // Control case: Always is valid for format with depth. @@ -1375,30 +1375,30 @@ TEST_F(RenderPipelineValidationTest, DepthCompareRequiredForFormatsWithDepth) { ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); // Undefined is valid though if depthCompare is not used by anything. - descriptor.cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::False; + descriptor.cDepthStencil.depthWriteEnabled = false; descriptor.cDepthStencil.stencilFront.depthFailOp = wgpu::StencilOperation::Keep; descriptor.cDepthStencil.stencilBack.depthFailOp = wgpu::StencilOperation::Keep; device.CreateRenderPipeline(&descriptor); // Undefined is invalid if depthCompare is used by depthWriteEnabled. - descriptor.cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::True; + descriptor.cDepthStencil.depthWriteEnabled = true; descriptor.cDepthStencil.stencilFront.depthFailOp = wgpu::StencilOperation::Keep; descriptor.cDepthStencil.stencilBack.depthFailOp = wgpu::StencilOperation::Keep; ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); // Undefined is invalid if depthCompare is used by stencilFront.depthFailOp. - descriptor.cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::False; + descriptor.cDepthStencil.depthWriteEnabled = false; descriptor.cDepthStencil.stencilFront.depthFailOp = wgpu::StencilOperation::Zero; descriptor.cDepthStencil.stencilBack.depthFailOp = wgpu::StencilOperation::Keep; ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); // Undefined is invalid if depthCompare is used by stencilBack.depthFailOp. - descriptor.cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::False; + descriptor.cDepthStencil.depthWriteEnabled = false; descriptor.cDepthStencil.stencilFront.depthFailOp = wgpu::StencilOperation::Keep; descriptor.cDepthStencil.stencilBack.depthFailOp = wgpu::StencilOperation::Zero; ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); - descriptor.cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::False; + descriptor.cDepthStencil.depthWriteEnabled = false; descriptor.cDepthStencil.stencilFront.depthFailOp = wgpu::StencilOperation::Keep; descriptor.cDepthStencil.stencilBack.depthFailOp = wgpu::StencilOperation::Keep; descriptor.EnableDepthStencil(wgpu::TextureFormat::Stencil8); @@ -1423,35 +1423,32 @@ TEST_F(RenderPipelineValidationTest, DepthWriteEnabledRequiredForFormatsWithDept descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth32Float); // Control case: Set depthWriteEnabled to false for format with depth. - depthStencil->depthWriteEnabled = wgpu::OptionalBool::False; + depthStencil->depthWriteEnabled = false; device.CreateRenderPipeline(&descriptor); + // When DepthStencilStateDepthWriteDefinedDawn struct is chained, depthWriteEnabled is now + // considered optional and depthWriteDefined needs to be true for formats with depth only. + wgpu::DepthStencilStateDepthWriteDefinedDawn depthWriteDefined; depthStencil = descriptor.EnableDepthStencil(wgpu::TextureFormat::Stencil8); + depthStencil->nextInChain = &depthWriteDefined; - // depthWriteEnabled set to undefined is valid for format with no depth. - depthStencil->depthWriteEnabled = wgpu::OptionalBool::Undefined; + // depthWriteDefined set to true is valid for format with no depth. + depthWriteDefined.depthWriteDefined = true; device.CreateRenderPipeline(&descriptor); - // depthWriteEnabled set to false is valid for format with no depth. - depthStencil->depthWriteEnabled = wgpu::OptionalBool::False; + // depthWriteDefined set to false is valid for format with no depth. + depthWriteDefined.depthWriteDefined = false; device.CreateRenderPipeline(&descriptor); - // Error case: depthWriteEnabled set to true is invalid for format with no depth. - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; - ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); - depthStencil = descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth32Float); + depthStencil->nextInChain = &depthWriteDefined; - // depthWriteEnabled set to false is valid for format with depth. - depthStencil->depthWriteEnabled = wgpu::OptionalBool::False; - device.CreateRenderPipeline(&descriptor); - - // depthWriteEnabled set to true is valid for format with depth. - depthStencil->depthWriteEnabled = wgpu::OptionalBool::True; + // depthWriteDefined set to true is valid for format with depth. + depthWriteDefined.depthWriteDefined = true; device.CreateRenderPipeline(&descriptor); - // Error case: depthWriteEnabled set to undefined is invalid for format with depth. - depthStencil->depthWriteEnabled = wgpu::OptionalBool::Undefined; + // Error case: depthWriteDefined set to false is invalid for format with depth. + depthWriteDefined.depthWriteDefined = false; ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); } diff --git a/src/dawn/tests/unittests/wire/WireOptionalTests.cpp b/src/dawn/tests/unittests/wire/WireOptionalTests.cpp index 159d0c21431..078e42d1c8d 100644 --- a/src/dawn/tests/unittests/wire/WireOptionalTests.cpp +++ b/src/dawn/tests/unittests/wire/WireOptionalTests.cpp @@ -108,7 +108,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) { wgpu::DepthStencilState depthStencilState = {}; depthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8; - depthStencilState.depthWriteEnabled = wgpu::OptionalBool::False; + depthStencilState.depthWriteEnabled = false; depthStencilState.depthCompare = wgpu::CompareFunction::Always; depthStencilState.stencilBack = stencilFace; depthStencilState.stencilFront = stencilFace; @@ -158,7 +158,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) { apiDevice, MatchesLambda([](const WGPURenderPipelineDescriptor* desc) -> bool { return desc->depthStencil != nullptr && desc->depthStencil->nextInChain == nullptr && - desc->depthStencil->depthWriteEnabled == WGPUOptionalBool_False && + desc->depthStencil->depthWriteEnabled == false && desc->depthStencil->depthCompare == WGPUCompareFunction_Always && desc->depthStencil->stencilBack.compare == WGPUCompareFunction_Always && desc->depthStencil->stencilBack.failOp == WGPUStencilOperation_Keep && diff --git a/src/dawn/utils/ComboRenderPipelineDescriptor.cpp b/src/dawn/utils/ComboRenderPipelineDescriptor.cpp index e181766c402..3f653d736c4 100644 --- a/src/dawn/utils/ComboRenderPipelineDescriptor.cpp +++ b/src/dawn/utils/ComboRenderPipelineDescriptor.cpp @@ -104,7 +104,7 @@ ComboRenderPipelineDescriptor::ComboRenderPipelineDescriptor() { stencilFace.passOp = wgpu::StencilOperation::Keep; cDepthStencil.format = wgpu::TextureFormat::Depth24PlusStencil8; - cDepthStencil.depthWriteEnabled = wgpu::OptionalBool::False; + cDepthStencil.depthWriteEnabled = false; cDepthStencil.depthCompare = wgpu::CompareFunction::Always; cDepthStencil.stencilBack = stencilFace; cDepthStencil.stencilFront = stencilFace; diff --git a/tools/android/BUILD.gn b/tools/android/BUILD.gn index f614befa7c2..f98c605200d 100644 --- a/tools/android/BUILD.gn +++ b/tools/android/BUILD.gn @@ -126,7 +126,6 @@ dawn_json_generator("kotlin_gen") { "java/android/dawn/MapMode.kt", "java/android/dawn/MipmapFilterMode.kt", "java/android/dawn/MultisampleState.kt", - "java/android/dawn/OptionalBool.kt", "java/android/dawn/Origin3D.kt", "java/android/dawn/PipelineLayout.kt", "java/android/dawn/PipelineLayoutDescriptor.kt", diff --git a/tools/android/webgpu/src/test/java/android/dawn/MappedNamedConstantsTest.kt b/tools/android/webgpu/src/test/java/android/dawn/MappedNamedConstantsTest.kt index dd7c38833b7..95d6a940472 100644 --- a/tools/android/webgpu/src/test/java/android/dawn/MappedNamedConstantsTest.kt +++ b/tools/android/webgpu/src/test/java/android/dawn/MappedNamedConstantsTest.kt @@ -43,7 +43,6 @@ class MappedNamedConstantsTest { MapAsyncStatus::class, MapMode::class, MipmapFilterMode::class, - OptionalBool::class, PopErrorScopeStatus::class, PowerPreference::class, PresentMode::class,