tools: record what CLAMP and OMOD do on an RDNA 2 card under every MODE value (T5) #437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/437"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by JeffreyBytes on 2026-11-29T03:14:05Z.
Summary
Second piece of T5 (#412): what VOP3
clampand the output modifiers do on an RDNA 2 card under every MODE value. #333 left two of these open because nobody knows the console's MODE bits 8 and 9, and I offered on #334 to measure them. This doesn't tell you what the console sets, but it reduces each open case to "which of four settings".Same route as #420: hand-written kernels through ROCm,
MODE[9:0]set withs_setreg_b32. 64 forms, each under all 1,024 MODE values, on an RX 6700 XT. The model inrdna2_float.pymatches every recorded word.Forms:
clamp,mul:2,mul:4,div:2and clamp with each OMOD onv_add_f32,v_sub_f32,v_mul_f32,v_mul_legacy_f32,v_fma_f32andv_fmac_f32(gfx1030's VOP3 encoding); clamp onv_min_f32/v_max_f32;v_fract_f32plain and with OMOD;v_cvt_f32_ubyte0/2/3with modifiers; neg and abs sources on the legacy multiply and on fmac; and the VOP3P clamp bit onv_fma_mix_f32,v_fma_mixlo_f16,v_fma_mixhi_f16. The assembler takesclamp mul:2but notmul:2 clamp, and no OMOD on VOP3P.What the card does
0x1000x220v_fract_f320x2330x3f7fffffThat OMOD rule is the one
tb_half_outputalready encodes for f16 (mode & 0x280); this is the same thing measured for f32.Against
check_float_forms_gpu.pyWhere its models accept more than one candidate, this is what the card gives for MODE
0xc0with bits 8/9 as 00, DX10 only, IEEE only, both:clamped)scaled)0x3f7fffff, rounded onceThe IEEE columns are the surprise: with IEEE set nothing is scaled, not just zeros, and no candidate in the check allows for that. I haven't changed the check here.
Against the translator
I haven't changed the translator either, but three things stand out:
float_result(hlsl/emitter/values.rs) always emitstb_omodand thensaturate(). That's the card with DX10_CLAMP set and IEEE clear, MODE0x1c0, so it's an assumption about bits 8 and 9.tb_omod(hlsl/text/helper_code.rs) returns a zero or denormal input with its sign kept. The card gives +0.tb_half_outputinoutput.rs) reads DX10_CLAMP from the mode value, where it's clear under0xc0, while the f32 path assumes it's set. They can't both be right.What's still open
Which of the four the console uses. Nothing in the repo settles it.
s_setreg_imm32_b32is in 28,190 recorded shaders but which fields it writes isn't recorded. One thing worth a look by someone who knows the stage descriptor: the word at +0x44 that gave0xc0is0x000000c0, upper bits zero. If that word is the whole MODE register, both bits are clear, a NaN passes through a clamp and the f32 path'ssaturate()is wrong for NaN. I haven't verified that reading.Limits: one card, one ROCm build. f16 OMOD isn't measured. Same GFX10.3-only caveat as #420.
Layout
tools/native_rdna2/float_forms.hip,check_float_forms.py;check_float.py's run loop is split out so both share it (a rerun still reproducesnative-rdna2-float.jsonbyte for byte);rdna2_float.form()models the modifiersevidence/native-rdna2-float-forms.json(99 KB)tests/test_native_rdna2_float_forms.py, no GPU, about 13 sdocs/CONSOLE_REFERENCE.mddocs/REFERENCES.mdfor ROCm and Mesa RADV, which the native checks run through and which weren't listedTested
No Lanes scenario and no NVIDIA run, for the same reasons as #420: this runs native instructions outside TuxBox's providers, only on an RDNA 2 card, and changes no provider, translator or shared check code.
GPU, driver and backend: AMD Radeon RX 6700 XT (
1002:73df, gfx1031), Linux 7.3.6, ROCm under/opt/rocmwithHSA_OVERRIDE_GFX_VERSION=10.3.0(set by the script). No Proton involved.Commands run and their results:
Checks
docs/RESULTS.mdanddocs/progress.svgdon't change; the new receipt isn't a type those views count.