Repository navigation
shader: lower gfx1013 binary16 v_cmp and v_cmp_class_f16 in pixel_aot - #612
Conversation
|
Independent Windows GPU run on cmake --build out/partial --target offscreen_check
ctest --test-dir out/partial --no-tests=error -R '^pixel_aot_predicate_rounding_(hardware|warp)$' --output-on-failureWARP passed (7.49 s), including the four wrong-reference cases and three shader mutations. RTX 4060 failed (4.36 s) at the ninth positive FP16 input ( At pixel (0, 0), channel 1 expected I reran that case alone twice per backend: the original shader failed both times on RTX 4060 and passed both times on WARP. In a local HLSL-only diagnostic I guarded just that comparison with AI-assisted. |
MarlomMedeiros
left a comment
There was a problem hiding this comment.
Community review + independent run on a second adapter, since the PR notes MSVC/D3D12/DXC/WARP were not exercised on the authoring macOS host.
Environment
- Commit under test:
857b893on basee3946dd - Windows 11 build 26300.10075, VS 2026 MSVC 19.52, Ninja, DXC from SDK 10.0.26100
ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(warp|hardware)$' -V: both passed- Hardware: NVIDIA GeForce RTX 5070 (vendor=10de device=2f04), driver 32.0.16.2135, D3D12 debug layer enabled,
debug_errors=0 debug_warnings=0on every draw - WARP: Microsoft Basic Render Driver, driver 10.0.26100.10068
tests/pixel_aot_check.pycontrols,tests/form_coverage_check.py, and the LLVM 15.0.7 binary round-trip (binarymode) all pass on this commit
The f16 compare draw runs inside pixel_aot_predicate_rounding_* through check_f16_compare_draws: all 14 F16_COMPARE_SETS cases passed pixel-exact on the integer readback on both adapters, the 4 corrupted-reference controls reported pixel_mismatch, and all 3 shader mutants (e32 predicate flip, e64 dropped neg, class dropped neg) were detected on both backends.
Review notes
- The lowering mirrors the existing
v_cmp_*_f32/v_cmp_class_f32arms faithfully: sameLANE_MASKdestination handling, same("condition", ...)tuple shape, samemask != "entry"and pending-load guards, modifiers gated to_e64throughf16_cmp_operand,widen16/vop3p_f16_word/INLINE_F16reused rather than duplicated. class16decomposes the f16 15:0 bits correctly: sNaN/qNaN split on the quiet bit, inf at 0x7c00, normal from 0x0400, denormal and zero below, sign folding the negative classes. The reference test asserts the raw 0x7f800000-emptiness invariant per set.- Reject controls look non-vacuous: e32 modifiers, >16-bit literals,
clamp/op_selsuffixes,v_cmpxvariants, mid-program and pending-load placements, plus a modifier-on-the-class-mask case that correctly routes throughint_operandinstead. - One consistency note: a class mask wider than 10 bits (
> 0x3ff) is accepted and emits dead bits, same as thev_cmp_class_f32arm. Not a defect, just parity. - Interaction note for #651 (exec-masked regions, not yet merged): these f16 arms write the same
("condition", ...)tupless_and_saveexec_b64consumes, so they would be able to open masked regions automatically once both land. Inside a region thev_cmpdeny prefix still rejects them, which is the intended behavior. No conflict, just a free capability. - Heads-up on base age: the branch sits on
e3946dd, 15+ commits behind currentmain(8f57366). The cmp arm chain has moved since, so a rebase may hit minor textual conflicts inlower().
No blockers found.
|
AI-assisted: yes. All reported checks ran locally on the adapter and driver listed. |
|
@Neoplayer Independent AMD (RDNA4) result on Environment
CommandsObserved21 tests, 21 passed, 0 failed, 0 skipped (113.36 s): Main draw suite:
Why this is worth measuring on this adapterTwo things here are vendor-sensitive by nature:
LimitThe negative controls are in AI-assisted; runs executed locally. |
|
Independent RTX 3060 Ti result on Windows 10 22H2 build cmake --preset dev "-DINTAKE_PYTHON=$((Get-Command python).Source)" "-DDXC_EXECUTABLE=$dxc" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
cmake --build --preset dev --parallel 4 --target offscreen_check
$env:XBOX2WINDOWS_ADAPTER = 'RTX 3060 Ti'
ctest --preset dev --no-tests=error -V -R '^pixel_aot_predicate_rounding_(hardware|warp)$'
The same shader program was rejected during translation at the branch point AI-assisted. All reported runs were executed locally. |
857b893 to
32dd77b
Compare
|
Thanks for the independent runs. The RTX 4060 and RTX 3060 Ti failure on Fix in Run on macOS arm64 (LLVM 15.0.7) after the rebase: AI-assisted. |
|
RTX 3060 Ti retest on Windows 10 22H2 build cmake --preset dev "-DINTAKE_PYTHON=$((Get-Command python).Source)" "-DDXC_EXECUTABLE=$dxc" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
cmake --build --preset dev --parallel 4 --target offscreen_check
$env:XBOX2WINDOWS_ADAPTER = 'RTX 3060 Ti'
ctest --preset dev --no-tests=error -V -R '^pixel_aot_predicate_rounding_(hardware|warp)$'
AI-assisted. All reported runs were executed locally. |
Change
Lower all 34 gfx1013 binary16 comparison and classification instruction forms (
17 VOPC_e32+17 VOP3_e64) intools/pixel_aot.py, synchronizetools/scan_unsupported_shaders.py, and add binary + DXC/WARP draw tests and negative controls intests/pixel_aot_check.pyandtests/form_coverage_check.py:tools/pixel_aot.py:class16(uint bits)inPREAMBLE(modeling all 10 IEEE binary16SIInstrFlags::ClassFlagsbits on bits[15:0]: signaling NaN, quiet NaN,-inf,-normal,-denormal,-0,+0,+denormal,+normal,+inf), and fix the missing opening parenthesis inclass32(if (magnitude != 0u)).f16_cmp_operand()supporting binary16 inline constants (INLINE_F16), integer inline patterns, 16-bit literals (rejecting> 0xffff), SGPR/VGPR sources, and VOP3_e64-onlyabs/negmodifiers (for_e32, modifiers raiseValueError("Input modifiers require VOP3 encoding")).lower()branches forv_cmp_class_f16(_e32|_e64)?and all 16v_cmp_<COMPARE>_f16(_e32|_e64)?predicates.tools/scan_unsupported_shaders.py:v_cmp_class_f16/v_cmp_<op>_f16(with optional_e32) and modifiedv_cmp_class_f16_e64/v_cmp_<op>_f16_e64(-,|...|,abs(...)) inSUPPORTED_INSTRUCTIONS_REGEX.tests/pixel_aot_check.py&tests/form_coverage_check.py:F16_COMPARE_SETS,f16_compares(),f16_compares_reference(), andcheck_f16_compare_draws()covering dirty high halfwords,±0.0,±denorm(0x0001/0x8001),±inf, quiet/signaling NaNs, inline constants (-4.0..4.0,0.15915494/0x3118, integer1/-1),_e64input modifiers, andR32G32B32A32_UINT(integer_rt=True) expectations plus wrong-bit and shader-mutation controls (lt -> leswap, dropped-on_e64, dropped-onv_cmp_class_f16_e64).(uncompressed_export(f16_compares()), translate_int)incheck_binary(), update rejected neighbor controls tov_cmp_class_f64_e32/v_cmp_lt_f64_e64, and updatetests/form_coverage_check.py(len(compare_forms) == 90).Verification
Commit under test:
857b893on macOS arm64 with Homebrew LLVM 15.0.7 (-mcpu=gfx1013) and Python 3.12.13:FORM_COVERAGE_RECORD=/tmp/x2w_f16_cov.txt python3 -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy libLLVM-15.dylib: exit0; recorded all 34 binary16 compare/class forms (17_e32+17_e64).python3 -Bsimulation executing emitted HLSL (widen16,class16,main) againstf16_compares_reference()across all 14F16_COMPARE_SETS:All 14 sets match emitted HLSL bit-for-bit!and all 3 shader mutations caught.LLVM_LIB=libLLVM-15.dylib LLVM_MC=llvm-mc LLVM_OBJCOPY=llvm-objcopy python3 -B tests/rdna2_tools_check.py:Ran 50 tests in 0.492s—OK(0 skips).python3 -B tests/form_coverage_check.py:form coverage checks passed.compute_store_check.py binary,depth_mask_check.py binary,mesh_*_check.py binary,sampled_coverage_check.py binary,ffx_dispatch_aot_check.py,awc_metadata_check.py,bc7_*,bcpack_check.py,bidi_controls_check.py,dependency_paths_check.py,docs_links_check.py,dxcontainer_part_offsets_check.py,dxil_retarget_check.py,gpu_report_format_check.py,layout_chunks_check.py,pso_readiness_check.py,resource_ranges_check.py,resource_root_check.py,script_state_check.py,sgd5_effects_check.py,shader_probe_check.py,xmem_attribute_scan_check.py,intake/paths_check.py): exit0.git diff --check: exit0.MSVC, D3D12, DXC, and WARP runtime execution (
pixel_aot_warp/check_f16_compare_draws) were not run on this macOS host and will be exercised by Windows CI.Evidence and follow-up
All fixtures are source-built synthetic sequences verified with LLVM 15.0.7
-mcpu=gfx1013.Checklist
AI-assisted.