startup: lower v_lerp_u8 in gfx2hlsl #2873
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2873
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2873"
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?
@R0D4X on GitHub · 2026-11-26 15:30 UTC · original
R0D4X:feat/gfx2hlsl-lerp-u8→main· +216 −1 · 4 files · 1 commits · merged 2026-11-27 05:26 UTCRoot Cause / Motivation
tools/disasm_rdna2.pyalready decodes VOP3Av_lerp_u8(0x14d), buttools/startup/gfx2hlsl.pyhad no lowering for it inVEC_U, refusing shaders that perform unsigned per-byte averaging with rounding.Summary
tools/startup/gfx2hlsl.py):'v_lerp_u8': (3, 'lerp_u8({0}, {1}, {2})')toVEC_U.uint lerp_u8(uint a, uint b, uint c)on demand inPipeline.common()(uses_lerp_u8, absent when unused), implementing AMD RDNA 2 ISAV_LERP_U8:D_i = (S0_i + S1_i + (S2_i & 1)) >> 1for each byte lanei in 0..3(preserving only bit8*iofS2).'v_lerp_u8'to the VOP3A integerneg/absencoding guard incheck_encoding()soneg/absbits (including inline integers) are rejected withv_lerp_u8 with neg/abs.tests/startup_gfx2hlsl_lerp_u8_check.py,tests/cmake/startup_gfx2hlsl_lerp_u8.cmake,tests/checks/python-linux/startup_gfx2hlsl_lerp_u8.txt):exec-masked emission, and pinned refusals (abs/negon VGPR and inline constants,clamp,omod,op_sel, wrong operand counts).vs_5_1/ps_5_1) and DXC (vs_6_0/ps_6_0) offscreen draws on WARP and hardware across 2 sets x 4 lanes, plus two GPU mutation controls (dropping& 1uonS2bytes and dropping rounding bits).Before / After
v_lerp_u8was rejected as unsupported bygfx2hlsl.py.v_lerp_u8translates via an on-demandlerp_u8helper, passes 600 reference triples and pinned refusal controls, and matches FXC/DXC readback on WARP and hardware with 0 D3D12 debug-layer errors/warnings.Verification
f283b7c8(based onb505c32b)10.0.26300.9974), MSVC19.44.35230, Windows SDK10.0.26100.0, FXC + DXC1.9.2602.17, D3D12 debug layer enabledMicrosoft Basic Render Driver(1414:008c), driver10.0.26100.9818NVIDIA GeForce RTX 5080(10de:2c02), driver32.0.16.2124Commands and measured results (0 failures, 0 skips):
git diff --check,startup_gfx2hlsl_lerp_u8_check.py,startup_gfx2hlsl_sad_check.py,startup_gfx2hlsl_sad_hi_msad_check.py,startup_gfx2hlsl_operand_count_check.py,startup_gfx2hlsl_handler_arity_check.py,startup_translator_check.py,run_checks_parallel_check.py,docs_links_check.py,bidi_controls_check.py): PASSctest --preset dev --no-tests=error -j 1 -R '^(startup_tools_lint|startup_gfx2hlsl_lerp_u8_)' -V: 4/4 passed (4.44 sec,debug_errors=0 debug_warnings=0on WARP and RTX 5080)ctest --preset release --no-tests=error -j 1 -R '^startup_gfx2hlsl_lerp_u8_' -V: 3/3 passed (3.93 sec,debug_errors=0 debug_warnings=0on WARP and RTX 5080)drop_s2_mask,drop_top_byte,drop_negabs_guard): 3/3 caught (rc=1) and reverted cleanly.Evidence Scope
devandreleaseFXC & DXC offscreen draws + 2 GPU mutation controls on WARP and RTX 5080 with D3D12 debug layer enabled, andtools/disasm_rdna2.pydecode of all fixture VOP3A words.AI-assisted; source-built fixtures only.
@KelboLive on GitHub · 2026-11-26 21:01 UTC · original · reviewed
V_LERP_U8 lowering follows the same clean pattern as recent VOP3A additions (perm_b32, sad variants). The HLSL helper — lerp_u8(a, b, c) = ((a+ b+ c&1)>>1 per byte) — matches the AMD RDNA 2 ISA reference exactly: D.u[i] = (S0.u[i] + S1.u[i] + S2.u[i&1]) >> 1 for each byte lane.
The test harness is solid:
check_encoding correctly adds v_lerp_u8 to the neg/abs refusal list shared with other VOP3A integer forms. uses_lerp_u8 follows the same boolean pattern as uses_perm_b32.
No concerns. Clean and correct.
@R0Y00 on GitHub · 2026-11-27 05:26 UTC · original · approved these changes
Reviewed
f283b7c82e31e4f059505f215874ee88c12c1a86in a clean integration build against maine62e3a5e. The translated helper applies each independent rounding bit without cross-byte carry, and the encoding guard rejects the invalid integer modifiers. The controls and both GPU readbacks passed. Windows 11 26200.9974, Release /O2, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. Relevant release tests: startup_gfx2hlsl_lerp_u8_(controls|warp|hardware). Required Windows CI passed.