Ready branch: biased image samples with a16 (and the a16 layout of extra address words) #861
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#861
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@anasssssssss1 on GitHub · 2026-11-24 12:52 UTC · original
Branch (PRs are collaborator-only):
anasssssssss1:fix-a16-bias, one commit onmainffe310e.What
image_sample_bwitha16stopped the program ("a biased image sample with 16-bit coordinates"). Lowering it needs the address layout the hardware uses witha16, which the sample path did not follow for any extra word:a16, the extra words (texel offset, bias, z-compare) keep a whole VGPR each; only gradients and coordinates are packed two per VGPR, and the coordinates start on a fresh VGPR. Each gradient direction is padded to whole VGPRs. (LLVM's AMDGPU backend packs it this way:packImage16bitOpsToDwords, "bias is of type half but occupies full 32-bit".)addr_valindexed every logical address as if all were packed, so ana16sample with an offset word read its coordinates from the wrong halves; that path was already allowed (image_sample_owitha16). The sample path now maps each logical address throughslot(), and reads extra words whole (extra()). Withouta16every index is unchanged.image_sample_l's level also goes throughslot()(unchanged today, asfirstand the gradients are 0 there).Measured
victory translateover the title'sshaders.rpf(v1.0.2.1), againstmainffe310e:a biased image sample with 16-bit coordinates(64 of the 108 now stop at a later reason.) The emitted programs pass
dxil.dllvalidation apart from the PSV0 container mismatch every program shows with the 10.0.22621 SDK validator, onmaintoo.Checks
cargo clippy --workspace --all-targets --locked -- -D warnings, the same with--all-features, andcargo test --workspace --lockedon Windows 11, RTX 4050 Laptop.@fuzeofficlal on GitHub · 2026-11-24 13:03 UTC · original
I compared
e6cff92withffe310eand #160 at6ad7e15using generated mipmapped textures. Each entry below is the RGBA readback match count on both an RTX 5090 and WARP.ffe310ee6cff926ad7e15image_sample_o a16, constant offset(+1, -1)image_sample_b a16, bias0or+1in the low half and0x7e00in the high halfimage_sample_d a16, four f32 gradient words and one packed UV wordThe gradient mismatch is already present on main. Both main and this branch produced validator-accepted DXIL that sampled mip 3 for lane 0, where the fixture expects mip 0. The two implicit-derivative compute controls exercised actual host readback under the fixture's existing validator allowance for this shader stage.
Test-only commit adds the two passing a16 offset and bias controls to #160's existing sampling tests. The gradient control was already there.
@Sunkiller-qc on GitHub · 2026-11-24 13:09 UTC · original
#569 (SAitken91, open) is the same fix:
image_sample_bwith a16 is refused with "a biased image sample with 16-bit coordinates", and with a16 the extra addresses (offset, bias, compare) still take a whole VGPR each. It reports 108 programs in shaders.rpf. #306 also enables a16 biased samples as part of a larger change. fuzeofficlal's readback table above would be useful on #569 too, so the two can be compared directly.@anasssssssss1 on GitHub · 2026-11-24 13:11 UTC · original
Correction, and closing this as superseded.
r4tedx/VIctory:integration/testers(92bc27b) already lowers biaseda16samples, with the extra words a dword each as here, and with one difference that makes it the better one: on GFX10.3 the derivatives are 16-bit only in theg16opcodes, not becausea16is set (LLVM'slowerImagekeeps the two apart where the target has G16). My branch packs the derivatives whenevera16is set, which is wrong forimage_sample_d*witha16on this GPU. The other cases (offset, bias, coordinates) agree.Please take the testers tree's version rather than
fix-a16-bias.@MichaelSmithAI on GitHub · 2026-11-24 13:02 UTC · original · edited 2026-11-24 13:13 UTC
Daniel checked the A16 bias layout numerically in a Wave64 compute shader on the focused #180 gradient integration. The bias register held +1.0 in the low half and +2.0 in the high half, with the packed coordinates in the next register. The gradient-only baseline (
0831e88) refused this sample at byte 104. With your A16 change, the emitted SampleGrad shader passed Microsoft DXV without a fixed wave size.On an RTX 4090 under Wine/vkd3d-proton 3.2, 32 lanes sampled mip 0 and the other 32 sampled mip 2. All 64 outputs matched the independently compiled DXC reference. This checks bias and address decoding together on the compute path. Your vertex/pixel corpus counts and the shader's effect on a rendered game frame are separate measurements. Integration commit
Daniel also tested a 1D A16 sample with explicit gradients. Microsoft DXV accepted both versions. On the same RTX 4090, baseline
0831e88read padding as a derivative and selected mip 2 for all 64 lanes. With the corrected register layout at9aa5338, 32 lanes selected mip 0 (9.0) and 32 selected mip 2 (81.0), matching the independent DXC reference in every lane. This case demonstrates a sampling error that an emission or validation count would miss. No title run was involved.A separate patterned 2D texture checked the signed texel offset and coordinate placement. The baseline refused the constant (+1, −2) offset at byte 76 as nonconstant. On the port, Microsoft DXV accepted the same shader, and all 64 lanes read value 21 from texel (5, 2), exactly matching DXC. The offset and packed coordinates occupied separate registers with distinct halfwords.