Add depth-clamping support for Metal

This CL adds depth clamping support to Metal by invoking
MTLRenderCommandEncoder::setDepthClipMode. I only implemented the
feature for the new-style of RenderPipelineDescriptor since the
old one seems to be deprecated.

Bug: dawn:716
Change-Id: Icd63c72294546042ae452360863a7f9c16b40f95
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45640
Commit-Queue: Brian Ho <hob@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Brian Ho
2021-04-05 17:16:47 +00:00
committed by Commit Bot service account
parent cb0bdb3401
commit 2cccd5a70c
10 changed files with 407 additions and 10 deletions

View File

@@ -550,6 +550,28 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
}
}
// Test that specifying a clampDepth value results in an error if the feature is not enabled.
TEST_F(RenderPipelineValidationTest, ClampDepthWithoutExtension) {
{
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::PrimitiveDepthClampingState clampingState;
clampingState.clampDepth = true;
descriptor.primitive.nextInChain = &clampingState;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
{
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::PrimitiveDepthClampingState clampingState;
clampingState.clampDepth = false;
descriptor.primitive.nextInChain = &clampingState;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
}
// Test that the entryPoint names must be present for the correct stage in the shader module.
TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@@ -739,3 +761,34 @@ TEST_F(RenderPipelineValidationTest, DISABLED_BindingsFromCorrectEntryPoint) {
descriptor.layout = layout1;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
class DepthClampingValidationTest : public RenderPipelineValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"depth_clamping"};
return adapter.CreateDevice(&descriptor);
}
};
// Tests that specifying a clampDepth value succeeds if the extension is enabled.
TEST_F(DepthClampingValidationTest, Success) {
{
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::PrimitiveDepthClampingState clampingState;
clampingState.clampDepth = true;
descriptor.primitive.nextInChain = &clampingState;
device.CreateRenderPipeline2(&descriptor);
}
{
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::PrimitiveDepthClampingState clampingState;
clampingState.clampDepth = false;
descriptor.primitive.nextInChain = &clampingState;
device.CreateRenderPipeline2(&descriptor);
}
}