Allow the DepthClipControl struct, validate the feature is enabled

This change allows the DepthClipControl struct to be chained on the
render pipeline descriptor, but disallows it from being used unless
the feature is enabled. The feature is not enabled on any backend
yet.

Bug: dawn:1178
Change-Id: I37f5c991103dd86c0e61a6ad8cd71cbd86401a9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93948
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Austin Eng 2022-06-17 17:26:59 +00:00 committed by Dawn LUCI CQ
parent baffaef571
commit 0213292dd7
2 changed files with 55 additions and 8 deletions

View File

@ -153,13 +153,16 @@ MaybeError ValidateVertexState(DeviceBase* device,
}
MaybeError ValidatePrimitiveState(const DeviceBase* device, const PrimitiveState* descriptor) {
DAWN_TRY(
ValidateSingleSType(descriptor->nextInChain, wgpu::SType::PrimitiveDepthClampingState));
DAWN_TRY(ValidateSingleSType(descriptor->nextInChain, wgpu::SType::PrimitiveDepthClampingState,
wgpu::SType::PrimitiveDepthClipControl));
const PrimitiveDepthClampingState* clampInfo = nullptr;
FindInChain(descriptor->nextInChain, &clampInfo);
if (clampInfo && !device->IsFeatureEnabled(Feature::DepthClamping)) {
return DAWN_VALIDATION_ERROR("The depth clamping feature is not supported");
}
DAWN_INVALID_IF(clampInfo && !device->IsFeatureEnabled(Feature::DepthClamping),
"%s is not supported", wgpu::FeatureName::DepthClamping);
const PrimitiveDepthClipControl* depthClipControl = nullptr;
FindInChain(descriptor->nextInChain, &depthClipControl);
DAWN_INVALID_IF(depthClipControl && !device->IsFeatureEnabled(Feature::DepthClipControl),
"%s is not supported", wgpu::FeatureName::DepthClipControl);
DAWN_TRY(ValidatePrimitiveTopology(descriptor->topology));
DAWN_TRY(ValidateIndexFormat(descriptor->stripIndexFormat));
DAWN_TRY(ValidateFrontFace(descriptor->frontFace));

View File

@ -975,7 +975,7 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatAllowed) {
}
}
// Test that specifying a clampDepth value results in an error if the feature is not enabled.
// Test that specifying a clampDepth value is an error if the feature is not enabled.
TEST_F(RenderPipelineValidationTest, ClampDepthWithoutFeature) {
{
utils::ComboRenderPipelineDescriptor descriptor;
@ -984,7 +984,8 @@ TEST_F(RenderPipelineValidationTest, ClampDepthWithoutFeature) {
wgpu::PrimitiveDepthClampingState clampingState;
clampingState.clampDepth = true;
descriptor.primitive.nextInChain = &clampingState;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor),
testing::HasSubstr("not supported"));
}
{
utils::ComboRenderPipelineDescriptor descriptor;
@ -993,10 +994,53 @@ TEST_F(RenderPipelineValidationTest, ClampDepthWithoutFeature) {
wgpu::PrimitiveDepthClampingState clampingState;
clampingState.clampDepth = false;
descriptor.primitive.nextInChain = &clampingState;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor),
testing::HasSubstr("not supported"));
}
}
// Test that specifying an unclippedDepth value is an error if the feature is not enabled.
TEST_F(RenderPipelineValidationTest, DepthClipControlWithoutFeature) {
{
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::PrimitiveDepthClipControl depthClipControl;
depthClipControl.unclippedDepth = true;
descriptor.primitive.nextInChain = &depthClipControl;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor),
testing::HasSubstr("not supported"));
}
{
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::PrimitiveDepthClipControl depthClipControl;
depthClipControl.unclippedDepth = false;
descriptor.primitive.nextInChain = &depthClipControl;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor),
testing::HasSubstr("not supported"));
}
}
// Test that using both DepthClipControl and DepthClamp features is invalid.
TEST_F(RenderPipelineValidationTest, DepthClipControlAndDepthClampInvalid) {
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::PrimitiveDepthClipControl depthClipControl;
depthClipControl.unclippedDepth = false;
descriptor.primitive.nextInChain = &depthClipControl;
wgpu::PrimitiveDepthClampingState clampingState;
clampingState.clampDepth = false;
depthClipControl.nextInChain = &clampingState;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor),
testing::HasSubstr("only contain a single chained struct"));
}
// Test that depthStencil.depthCompare must not be undefiend.
TEST_F(RenderPipelineValidationTest, DepthCompareUndefinedIsError) {
utils::ComboRenderPipelineDescriptor descriptor;