Repository navigation
borealis: implement VK_EXT_depth_clamp_control - #1346
Conversation
With depth clamp enabled, the hardware clamps depth to the min/max Z of each scissor record, which hk filled from the viewport depth range. Take them from the user range instead when the clamp mode is VK_DEPTH_CLAMP_MODE_USER_DEFINED_RANGE_EXT, in both the generic and the native bind-tail viewport paths (shared hk_depth_clamp_bounds()). The range is dynamic state (VP_DEPTH_CLAMP_RANGE): it re-emits the viewport records like the clamp enable does, and the bind-tail snapshot keeps the mode and range so a cached viewport payload is not reused across a range change. Without depthRangeUnrestricted the user range lies within [0, 1], so the clamp-disabled bounds are unchanged. Signed-off-by: Nick <nekreshen@yandex.ru>
There was a problem hiding this comment.
Verdict: MERGE at 2fe6cb33
Blockers: none.
Checked:
- Audited all 3 changed files (
src/asahi/vulkan/hk_cmd_buffer.h,src/asahi/vulkan/hk_cmd_draw.c,src/asahi/vulkan/hk_physical_device.c,+48/-11) and everydepth_clamp/DEPTH_CLAMPreference acrosshk_cmd_draw.c. - Shared
hk_depth_clamp_bounds()cleanly handles all three states (clamp disabled ->[0, 1],VK_DEPTH_CLAMP_MODE_USER_DEFINED_RANGE_EXT-> user[minDepthClamp, maxDepthClamp], viewport range ->[MIN2, MAX2]) for bothhk_flush_vp_state()andhk_g17p_draw_state_viewports(). - Dynamic state tracking is complete:
IS_DIRTY(VP_DEPTH_CLAMP_RANGE)triggers both viewport flush sites,hk_g17p_flush_dynamic_state_fast()falls back to slow wheneverVP_DEPTH_CLAMP_RANGEis dirty, andhk_g17p_bind_tail_dyn_capture()/hk_g17p_bind_tail_viewport_dyn_matches()capture and comparedepth_clamp_modeanddepth_clamp_range(two floats, no padding) whendepth_clamp_enableis active. - Exact-head J815 M5 (G17G) Borealis A/B verification: 6,065 depth-clamp/fragdepth/depth-range cases
273 -> 383 Pass(110 fixes / 0 regressions), all 188depth_clamp_controlcases112 Pass / 76 NotSupported(negative control failed 80/112), 15,958-case dEQP gate0 diffs,meson test --suite asahi223/223, Godot TPS neutral,0GPU faults. - DCO
Signed-off-by:present; no Apple material or policy issues.
Evidence
- Diff:
hk_cmd_buffer.h,hk_cmd_draw.c,hk_physical_device.c(+48/-11). - Audited
hk_g17p_flush_dynamic_state_fast()L15738 anddirty.cullL13274 to confirm no fast-path or PPP-state bypass onVP_DEPTH_CLAMP_RANGE. - Note (non-blocking): G13–G16 and M5 Pro/Max hardware not yet run; viewport scissor Z clamp path is shared.
|
@DjDeveloperr, code-owner heads-up: App approval at |
|
Merge-train finding, holding this one out of batch 11. The rest of the batch lands without it. The new
J713's fleet85 kernel already rejects a family of d32/s8 stencil and tess/geom submits with EINVAL on plain |
|
Ran it on an AGX3 Mac at this head (2fe6cb3):
So on G17G the depth-clamp path builds a submission the kernel accepts. That points at the fleet85 d32/s8 EINVAL family rather than this PR. I don't have a G16G to check that kernel directly. |
|
@DjDeveloperr, code-owner heads-up: App approval at |
|
Merge-train landing at
Revert: |
What: Implement VK_EXT_depth_clamp_control. With depth clamp on, the min/max Z of each scissor record (what the hardware clamps to) now comes from the user range when the mode is USER_DEFINED_RANGE, in the generic viewport path and in the HAL200 draw-state viewports of the native bind tail. The range is dynamic state: it re-emits the viewport records, and the bind-tail snapshot keeps the mode and range so a cached viewport payload is not reused across a range change.
Tested: J815 MacBook Air 15" M5 (T8142, G17G), Borealis, kernel
7.3.0-aurora-j815-dev, at 2fe6cb3 vs base 8bad0a5: depth clamp/fragdepth/depth range list (6,065): 273 -> 383 Pass, 110 fixes, 0 regressions; all 188depth_clamp_controlcases: 112 Pass, 76 NotSupported (D24 formats, depthRangeUnrestricted); earlier negative control (range ignored): 80 of the 112 fail; dEQP gate 0 diffs;meson test --suite asahi223/223; Godot TPS demo 1080p FSR2 voxel GI (FAST=1): 49.4 / 49.7 static, 57.3 route vs 49.5 / 49.7, 57.5 base (neutral). 0 GPU faults. Regression line: 0 SELinux denials (N/A on this image), 0 failed units, 0 new kernel errors.Risk: two-way door · all Borealis Macs; draws that do not set a user range take the same values as before.
Not yet: G13-G16 and M5 Pro/Max hardware; VK_KHR_depth_clamp_zero_one is not included (the CTS has no functional test for it).
Details
hk_depth_clamp_bounds(): clamp off -> [0, 1] as before; USER_DEFINED_RANGE -> the range; otherwise the viewport min/max. Used byhk_flush_vp_state()andhk_g17p_draw_state_viewports().hk_g17p_bind_tail_viewport_dyn_matches()compares the mode and range when clamp is on.Evidence
Commands (gpu-perf):
dcc-20261129.txt:
depth_clamp|clamp_zero_one|clamp_range|zero_one|fragdepth|depth_rangeminusdepth_range_unrestrictedandtexture_gatherGate (15,958, broad regression list):
Godot TPS demo, 1080p FSR2 voxel GI,
FAST=1(BENCH lines, a = base, f = this PR):