Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement depth-clip-control using depthClamp #3892

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Bottom level categories:
#### Vulkan

- Work around [Vulkan-ValidationLayers#5671](https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/5671) by ignoring reports of violations of [VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912](https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEndDebugUtilsLabelEXT-commandBuffer-01912). By @jimblandy in [#3809](https://github.com/gfx-rs/wgpu/pull/3809).
- Implement depth-clip-control using depthClamp instead of VK_EXT_depth_clip_enable. By @AlbinBernhardssonARM [#3892](https://github.com/gfx-rs/wgpu/pull/3892).

### Added/New Features

Expand Down
31 changes: 2 additions & 29 deletions wgpu-hal/src/vulkan/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub struct PhysicalDeviceFeatures {
timeline_semaphore: Option<vk::PhysicalDeviceTimelineSemaphoreFeaturesKHR>,
image_robustness: Option<vk::PhysicalDeviceImageRobustnessFeaturesEXT>,
robustness2: Option<vk::PhysicalDeviceRobustness2FeaturesEXT>,
depth_clip_enable: Option<vk::PhysicalDeviceDepthClipEnableFeaturesEXT>,
multiview: Option<vk::PhysicalDeviceMultiviewFeaturesKHR>,
astc_hdr: Option<vk::PhysicalDeviceTextureCompressionASTCHDRFeaturesEXT>,
shader_float16: Option<(
Expand Down Expand Up @@ -61,9 +60,6 @@ impl PhysicalDeviceFeatures {
if let Some(ref mut feature) = self.robustness2 {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.depth_clip_enable {
info = info.push_next(feature);
}
if let Some(ref mut feature) = self.astc_hdr {
info = info.push_next(feature);
}
Expand Down Expand Up @@ -179,6 +175,7 @@ impl PhysicalDeviceFeatures {
.shader_int16(requested_features.contains(wgt::Features::SHADER_I16))
//.shader_resource_residency(requested_features.contains(wgt::Features::SHADER_RESOURCE_RESIDENCY))
.geometry_shader(requested_features.contains(wgt::Features::SHADER_PRIMITIVE_INDEX))
.depth_clamp(requested_features.contains(wgt::Features::DEPTH_CLIP_CONTROL))
.build(),
descriptor_indexing: if requested_features.intersects(indexing_features()) {
Some(
Expand Down Expand Up @@ -247,17 +244,6 @@ impl PhysicalDeviceFeatures {
} else {
None
},
depth_clip_enable: if enabled_extensions.contains(&vk::ExtDepthClipEnableFn::name()) {
Some(
vk::PhysicalDeviceDepthClipEnableFeaturesEXT::builder()
.depth_clip_enable(
requested_features.contains(wgt::Features::DEPTH_CLIP_CONTROL),
)
.build(),
)
} else {
None
},
multiview: if effective_api_version >= vk::API_VERSION_1_1
|| enabled_extensions.contains(&vk::KhrMultiviewFn::name())
{
Expand Down Expand Up @@ -472,9 +458,7 @@ impl PhysicalDeviceFeatures {
}
}

if let Some(ref feature) = self.depth_clip_enable {
features.set(F::DEPTH_CLIP_CONTROL, feature.depth_clip_enable != 0);
}
features.set(F::DEPTH_CLIP_CONTROL, self.core.depth_clamp != 0);

if let Some(ref multiview) = self.multiview {
features.set(F::MULTIVIEW, multiview.multiview != 0);
Expand Down Expand Up @@ -699,11 +683,6 @@ impl PhysicalDeviceCapabilities {
extensions.push(vk::ExtConservativeRasterizationFn::name());
}

// Require `VK_EXT_depth_clip_enable` if the associated feature was requested
if requested_features.contains(wgt::Features::DEPTH_CLIP_CONTROL) {
extensions.push(vk::ExtDepthClipEnableFn::name());
}

// Require `VK_KHR_portability_subset` on macOS/iOS
#[cfg(any(target_os = "macos", target_os = "ios"))]
extensions.push(vk::KhrPortabilitySubsetFn::name());
Expand Down Expand Up @@ -898,12 +877,6 @@ impl super::InstanceShared {
.insert(vk::PhysicalDeviceRobustness2FeaturesEXT::default());
builder = builder.push_next(next);
}
if capabilities.supports_extension(vk::ExtDepthClipEnableFn::name()) {
let next = features
.depth_clip_enable
.insert(vk::PhysicalDeviceDepthClipEnableFeaturesEXT::default());
builder = builder.push_next(next);
}
if capabilities.supports_extension(vk::ExtTextureCompressionAstcHdrFn::name()) {
let next = features
.astc_hdr
Expand Down
10 changes: 2 additions & 8 deletions wgpu-hal/src/vulkan/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,8 @@ impl crate::Device<super::Api> for super::Device {
let mut vk_rasterization = vk::PipelineRasterizationStateCreateInfo::builder()
.polygon_mode(conv::map_polygon_mode(desc.primitive.polygon_mode))
.front_face(conv::map_front_face(desc.primitive.front_face))
.line_width(1.0);
.line_width(1.0)
.depth_clamp_enable(desc.primitive.unclipped_depth);
if let Some(face) = desc.primitive.cull_mode {
vk_rasterization = vk_rasterization.cull_mode(conv::map_cull_face(face))
}
Expand All @@ -1622,13 +1623,6 @@ impl crate::Device<super::Api> for super::Device {
if desc.primitive.conservative {
vk_rasterization = vk_rasterization.push_next(&mut vk_rasterization_conservative_state);
}
let mut vk_depth_clip_state =
vk::PipelineRasterizationDepthClipStateCreateInfoEXT::builder()
.depth_clip_enable(false)
.build();
if desc.primitive.unclipped_depth {
vk_rasterization = vk_rasterization.push_next(&mut vk_depth_clip_state);
}

let mut vk_depth_stencil = vk::PipelineDepthStencilStateCreateInfo::builder();
if let Some(ref ds) = desc.depth_stencil {
Expand Down