Repository navigation
borealis: specialize depth-only fragment tests for dynamic draws - #1314
Conversation
Compile one single-sample depth-only discard variant with the test selector folded. Select it from the effective alpha-to-coverage and depth state when the main owns testing. Keep the general variant for draws that can run the read-only depth prolog or enable alpha-to-coverage. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: MERGE at 4adbc945
Blockers: None (wait for hosted CI checks once triggered; local Fedora Clang release and asserts-on builds passed 224/224 asahi tests per profile).
Checked:
- Audited
hk_fragment_main_tests_for_draw(),hk_populate_fs_key(),hk_compile_nir(),hk_static_tests_variant_matches(),hk_bound_fs(),hk_shader_destroy(), shader-binary serialization/deserialization, andhk_cmd_draw.cdraw-time linking and dirty-state tracking. - Verified
hk_fragment_main_tests_for_draw()is the exact complement ofhk_g17p_read_only_early_reject_in()'s draw-time depth conditions (samples == 1 && !alpha_to_coverage && (!depth_test || depth_write || depth_compare_always || depth_bounds)), andhk_static_tests_variant_matches()rules outwrite_z,write_s,loc_written, andhas_input_attachments, so bothepilog_discardsandread_only_early_rejectare guaranteed false wheneverstatic_tests_variantis selected (preserving theno_epilog_discardinvariant inhk_cmd_draw.c). - Verified draw-time switching: all six inputs to
hk_fragment_main_tests_for_draw()are in thefast_link_fsdirty guard inhk_cmd_draw.c, andhk_update_fast_linked()comparesgfx->fast_link_fs.shader == shader, so toggling betweenfsandfs->static_tests_variantrelinks and setslinked_fs_dirty/dirty.fragment_shader. - Verified shader-binary format and lifetime safety:
HK_AGX3_SHADER_BINARY_VERSION(55 -> 56) andHK_CLASSIC_SHADER_BINARY_VERSION(42 -> 43) bumped cleanly (test-hk-execution-allowance.cupdated, AGX2 untouched at40),variants[0]is always eagerly compiled before serialization, serialize/deserialize ordering (variants -> static_tests_variant -> src -> mono) matches on both sides,cache_candidatereturnsVK_NOT_READYsohk_shader_binary_cache_clone()never aliasesstatic_tests_variant, andhk_shader_destroy()frees it cleanly. - Verified exact-head J700 (
4adbc945f84d28743cae2f92d4b8948989d782fe) results: DXVK-3.86%and vkd3d-proton-4.62%GPU on shadow alpha test, 336/336 exact CRCs across 42 row/depth pairs, 128/128 supported dEQP-VK CTS passes (release and-Db_ndebug=false), 224/224asahisuite tests per profile includinghk_fragment_main_tests, and P-core-pinned ABBA/BAAB confirming zero DXVK opaque regression.
Evidence
src/asahi/vulkan/hk_shader.c:hk_compile_nir()clones NIR before main compilation only for single-sample depth-only discarding fragment shaders withkey->fs.dynamic_tests,!force_sample_shading,!zs_self_dep,!early_fragment_tests,!uses_sample_shading,!writes_memory,!outputs_written; compiles the alternate withstatic_key.fs.static_tests = trueandkeep_mono = false, and callshk_shader_destroy(dev, variant, true); free(variant);on compile failure orhk_static_tests_variant_matches()mismatch.src/asahi/vulkan/hk_cmd_buffer.h:hk_bound_fs()checksfs && fs->static_tests_variant && !fs->info.fs.has_input_attachments && hk_fragment_main_tests_for_draw(...);UNUSEDonpresentinhk_pipeline_stat_addr()clears release-Wunused-variable.src/asahi/vulkan/tests/test-hk-fragment-main-tests.c+src/asahi/vulkan/meson.build: covers all eight draw-state combinations ofhk_fragment_main_tests_for_draw().
|
Verdict — FINISH, then merge at Blockers
Checked — Depth/stencil and alpha-to-coverage selection, relinking on state changes, variant ownership and cleanup, and DCO. EvidenceFedora passed 224/224 in each profile. J700 matched all 336 readbacks across 42 workload/depth pairs and passed 128 supported CTS cases per profile. The draw guard passed 160 selector combinations. One missed optimization on M5: fixed 1× pipelines store the count in |
A zero root size in a shader binary requests the full table. Compare effective sizes so an alternate cannot read beyond the prefix allocated for its main, and allow a trimmed alternate when the main gets the full table. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J516s MacBook Pro (18 GB, G15S B1) — exact-head hardware confirmation for
The earlier |
There was a problem hiding this comment.
Verdict: MERGE at cc5feea after integration validation.
Checked: the predicate now compares the same effective root sizes used for allocation. An encoded zero becomes the full table on either side. A full alternate cannot fit a trimmed main, and a trimmed alternate can fit a full main. The delta is limited to that predicate. Keep the binary-size regression coverage, hosted checks and G15S hardware result outstanding.
What: Compile one depth-only discard main with its depth/stencil test selector folded. Select it at draw time when single-sample depth state keeps testing in the main and alpha-to-coverage is disabled.
Tested: MacBook Neo J700 at
4adbc945f84d28743cae2f92d4b8948989d782fe, stock7.3.0-41.fc44.aurora.aarch64. 336 exact CRCs, zero kernel GPU faults or AVCs, and 128 supported Vulkan CTS passes in each build profile. Fedora Mesa CI passed 224 tests per profile with zero failures, timeouts, or warnings in touched files.Risk: Two-way door · native AGX3 fragment compilation and the shader-binary cache.
Not yet: Hardware rows on other affected GPU generations.
The stock DXVK opaque control showed a 7.74% wall-time increase with matching GPU time. A same-boot, performance-core-pinned ABBA/BAAB repeat measured 235.13 → 234.49 µs at depth 1 and 106.45 → 106.48 µs at depth 4, with 104.04 µs GPU time throughout and 16 exact readbacks.
Details
The dynamic pipeline retains its general shader and one optional single-sample depth-only main. Both share the existing shader linker. Alpha-to-coverage, a different sample count, or a depth state that can use read-only early rejection selects the general shader. The optional fragment main is serialized with the shader binary and requires no main compilation at draw time.
Evidence
714529071cb6f063315e85736255ae8469b24a8a, candidate4adbc945f84d28743cae2f92d4b8948989d782fe. Stock kernel and Mesa system files matched before and after. The Apple memory controller reported four-plane SLC and device-tree statusokay. Recorded GPU frequencies came fromagx_stats.abad457, DXVK1011dd9, vkd3d-proton71cae09. The runner used--warmup-ms 140 --run-ms 110 --runs 3 --timed-runs 2 --timestamps on, with--verifyon the DirectX executors. The comparison used ABBA/BAAB with four legs per arm.-Dbuildtype=releaseand-Db_ndebug=if-releaseor-Db_ndebug=false. Meson ran the Asahi suite with--timeout-multiplier 4, including the fragment-main guard tests.Fixed-head validation
cc5feeae3176dfba537d7f205291bca6c76e4159on714529071cb6f063315e85736255ae8469b24a8a, stock Fedora kernel7.3.0-41.fc44.aurora.aarch64. Release and assertions-enabled CTS passed 248 supported cases, with 132 unsupported and zero failures or warnings. Maintenance5 2× and 4× passed cold and after cache replay.7be9463aand depth-only CRC wasc0fb9993. Eight isolated caches replayed in fresh processes with reported workload-level disk-cache hits. The scorer was corrected offline to recognize Mesa’s 64-hex cache identifiers.466f64389304. The descriptor-size regression passed all seven cases.