Depth clamp/clip improvements #3900
Labels
api: metal
Issues with Metal
api: vulkan
Issues with Vulkan
type: enhancement
New feature or request
Milestone
Based on gpuweb/gpuweb#2100 (comment) & gpuweb/gpuweb#3638 (comment)
DX12
Clamps depth & has
DepthClipEnable
which corresponds to!unclippedDepth
wgpu/wgpu-hal/src/dx12/device.rs
Line 1345 in 17143c1
TODO:
Metal
Has
setDepthClipMode
available on:iOS 11.0+
&macOS 10.11+
Note: I think if
setDepthClipMode
is not available, Metal will still clip by default.if
setDepthClipMode
is available:DEPTH_CLIP_CONTROL
featureunclippedDepth
{ setMTLDepthClipModeClamp
} else { setMTLDepthClipModeClip
and clampfrag_depth
in shader }else:
frag_depth
in shaderTODO:
Update the following to check for versions instead and rename the capability to
supports_set_depth_clip_mode
.wgpu/wgpu-hal/src/metal/adapter.rs
Lines 737 to 739 in 17143c1
Implement
frag_depth
clamping in the shaderVulkan
Has
depthClamp
&VK_EXT_depth_clip_enable
if both are available:
DEPTH_CLIP_CONTROL
featuredepthClampEnable
depthClipEnable
based onunclippedDepth
else if
depthClamp
is available:DEPTH_CLIP_CONTROL
featureunclippedDepth
{ setdepthClampEnable
} else { clampfrag_depth
in shader }else:
frag_depth
in shaderTODO:
Shader clamping was implemented in [spv-out] option to clamp frag_depth naga#1431 but wgpu is not setting the flag and it should also clamp between
viewport.minDepth
andviewport.maxDepth
(not 0 and 1)Implement the flow above; too many changes to list here (might be useful to undo part of Implement depth-clip-control using depthClamp #3892)
The text was updated successfully, but these errors were encountered: