Repository navigation
fix(shader): v_mullit_f32 legacy rules, v_cvt_pk_u8_f32 rounding and VOP3 neg/abs - #501
Conversation
|
Thanks, checked against the RDNA2 ISA guide (V_MULLIT_F32 only says "specific INF, NaN, overflow rules", and the older GCN description has the same -MAX_FLOAT conditions you measured) and the code follows your rules exactly: the -MAX test catches -MAX, -inf and negative NaNs, the FMul never sees a NaN or zero operand, and the u8 rounding is exact (truncate, exact fraction, ties to even, 255 guard). The new modifier block for |
|
Added the TechnicalDebt line under "Functional": |
caf75e0 to
3707e39
Compare
|
Thanks, the TechnicalDebt line says exactly what the code assumes (IEEE=1 with denormals kept, sNaN src0 quieted, positive denormal src2 positive) and the rebase left the fix commit unchanged.
I'll run it through my PPSA21564 check next and merge it after that if it's clean. |
|
#498 landed today, and it now conflicts with this one in if (opcode == RdnaOpcode::VLdexpF16 || opcode == RdnaOpcode::VCvtPkU8F32) {I tried the combined form here on current main and the full ctest passes, |
…VOP3 neg/abs Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
3707e39 to
9e6362d
Compare
|
Rebased on current
|
Takes upstream's merged versions of our boykopovar#586 boykopovar#611 boykopovar#612 boykopovar#505 boykopovar#490 boykopovar#619 boykopovar#503 boykopovar#627 boykopovar#628 boykopovar#618 and drops astrobot's local copies, plus gate-batch-3 (boykopovar#469 boykopovar#500 boykopovar#504 boykopovar#509 boykopovar#510 boykopovar#514 boykopovar#525 boykopovar#526 boykopovar#528), round o/p (boykopovar#617 boykopovar#620 boykopovar#621 boykopovar#622 boykopovar#623 boykopovar#624 boykopovar#501 boykopovar#508 boykopovar#629 boykopovar#630 boykopovar#631). Conflicts: - SpirvAnalysis.hpp/.cpp, SpirvBufferAccess.cpp: upstream's boykopovar#586/boykopovar#612. The 64-bit LDS atomics keep the full array (f27d6e5 no longer needed). - SpirvMemoryInstructions.cpp: upstream's constant slot plus offset; astrobot's split-wave append/consume kept. - GuestTextureResource.cpp, TextureTiling.cpp and their tests: upstream's boykopovar#490/boykopovar#503 (astrobot had no other change there). - MaskedSelect.cpp test, ShaderMemory.cpp LDS test: upstream's. - State.cpp: upstream's boykopovar#505 export count and boykopovar#469 null pixel program; astrobot's depth export rejection and depth target model kept. - Pipeline.cpp: upstream's pipeline key; astrobot's depth attachment and blend check (a trailing unused attachment stays valid, as colorGapPipelineTests expects). - Draw.cpp, Recorder.cpp, ShaderResources.cpp: astrobot's (renderPassKey with depth, moved sample functions, residency maintenance), which already hold the merged boykopovar#505/boykopovar#628/boykopovar#490 changes. - ShaderInputState.cpp: both register sets. - State.hpp: the duplicate exportIndex member from the auto-merge removed. - CMakeLists.txt: astrobot's test list (a superset of upstream's). - tests/Graphics.cpp: upstream's CompactedExportTests replaces astrobot's inline copy; tests/Recorder.cpp: upstream's viewPastLastMipTests added.
What
VOP3
neg/absonv_mullit_f32(all three sources) andv_cvt_pk_u8_f32(src0) used to throw. Enabling them showed that both ops differed from hardware even without modifiers, so this PR fixes that as well:v_mullit_f32was a plainv_mul_f32that ignored src2. It now follows the measured rules.v_cvt_pk_u8_f32truncated. It now rounds to nearest even, like the hardware (1.5 → 2, 2.5 → 2, 3.5 → 4).Anything still unmodelled keeps throwing: clamp/omod on both ops, and neg/abs on src1/src2 of
v_cvt_pk_u8_f32(llvm-mc rejects those too).Behaviour measured on HW
The ISA guide doesn't spell these out, so I measured them on an RDNA2 GPU (gfx1035; llvm-mc gives the same VOP3 opcode 0x150/0x15e on gfx1013). Modifiers apply before every check below.
v_mullit_f32 d, s0, s1, s2:0xff7fffff(−MAX_FLOAT). The −MAX test is exact:0xff7ffffemultiplies normally.| 0x400000), sign kept.v_cvt_pk_u8_f32: NaN and values ≤ 0 → 0, values ≥ 255 → 255, otherwise round to nearest even.These results don't depend on the IEEE or DENORM mode, with two exceptions: IEEE=0 keeps sNaN s0 unquieted, and flushed f32 denormals make a positive-denormal s2 count as 0. The implementation follows the default compute mode (IEEE=1, denormals kept), and the test has no sNaN or denormal rows.
To stay exact on any driver, everything is done on the bits:
RoundEvenisn't in Vulkan's precision table.v_mad_legacy_f32is not included: on gfx1030+ its opcode 0x140 isv_fma_legacy_f32, so I can't measure it on my GPU, and its translation stays as it is on main.Tested
Linux, RADV + lavapipe (local Mesa and CI's Ubuntu Mesa 25.2.8):
agc_driver_vop3_legacy_source_modifiers_tests: 32 lanes × 10 forms, expected values taken from the hardware. The rows cover the specials (±0, ±inf, qNaN with payloads, ±MAX, −MAX−1ulp), rounding ties, and both clamp edges.agc_driver_pixel_helper_lanes, which already fails on main with local RADV (not touched here).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)