textures: accept fixed-point texel snapping in magnified BC7 tail draws #308
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/313"
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 R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-21T21:47:17Z.
Change
bc7_draw_warpfails on the Windows 10 in-box WARP (10.0.19041.5794) on unmodifiedmain(b53bfb0):The actual value is the second texel of the 2x1 mip (29, 18, 32, 72 of 255), read four pixels before the texel boundary at x=2048. This adapter converts the scaled texture coordinate to fixed point with 8 fractional bits, rounding to nearest, before it picks the point-sampled texel. A pixel center within 1/512 texel below a boundary therefore selects the next texel. The reference in
draw_verifiedexpectedfloor()of the exact coordinate for those pixels. Only the tail draws that magnify by 256x or more have such pixels, which is why only4096x4and4x4096at first resident mip 11 fail.This PR accepts the next texel for exactly those pixels (center at or above 511/512 of a texel), as a whole RGBA texel, next to the existing exact-boundary case in
tests/pixel_aot_render.cpp. No expected value changes and no fixture is removed. The translator is not involved: the copy shader samples with the interpolated coordinate as is.It solves an independent problem (a test assumption stricter than the adapter's addressing precision) and makes the texture check usable on Windows 10 without the Agility SDK. It touches the compare loop of
draw_verifiedonly. #283 changes other hunks of the same file and does not overlap textually.Verification
Commit e7ac54e on
b53bfb0. Windows 10 22H2 (19045), debug layer enabled,debug_errors=0 debug_warnings=0. Adapters: in-box WARP 10.0.19041.5794; app-local WARP 1.0.22 with Agility SDK 1.620.2; NVIDIA GeForce RTX 3060, driver 596.36.b53bfb0)bc7_draw_warpfailed,bc7_draw_hardwarepassedFull suite,
ctest --preset dev --no-tests=error, 143 tests registered:gpu_alias_lookup_writes_warpbvh_wave64_warp,wave_shuffle_warpThe three remaining failures do not go through the changed code.
bvh_wave64_warpandwave_shuffle_warpon WARP 1.0.22 are the lane misrouting tracked in #145.gpu_alias_lookup_writes_warpfails only on the in-box WARP (record=1 field=64 expected=0001f5a0 actual=0007d680) and passes on WARP 1.0.22; I have not investigated it yet.New negative control in
tests/bc7_draw_check.py: the copy shader with its coordinate shifted by 1/64 texel must still fail on the 4096x4 draw of the 2x1 mip. Measured first mismatch: x=2016 on the RTX 3060 and on WARP 1.0.22, x=2012 on the in-box WARP (2016 minus the same 4-pixel band). The control accepts x in 2012..2016 at y=0 and nothing else.Evidence and follow-up
Measured with a local diagnostic build that counts mismatching pixels instead of stopping at the first (not part of this PR). Sub-case sweep of the 15 positive draws of
bc7_draw_check.py:Mismatching pixels per draw of the 2x1 mip on the in-box WARP, all of them equal to the next texel as a whole RGBA value:
The 4x4096 case is the same along y. Uploading the same texels as
R8G8B8A8_UNORMinstead of BC7 gives identical counts, so BC7 decoding, the sub-block upload and mip selection are not involved.Assumptions and limits:
d3d12.hhasD3D12_SUBTEXEL_FRACTIONAL_BIT_COUNT= 8, and the Direct3D 11.3 functional specification (3.2.4) says texture coordinates are snapped to fixed point after scaling by the texture size. That the in-box WARP rounds to nearest at that precision is inferred from the measured counts, not from WARP's code.docs/experiments.mdgains one sentence in the tail-check paragraph. The reproduction command is unchanged.AI-assisted (Claude Code). The Windows results were measured locally.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:57:00Z.
The cross-adapter reference adjustment is approved specifically for point-sampled magnified tail mips. Keep the exact texel as the first choice. On each axis admit its immediate neighbor only where quantization can cross an actual boundary (up to 1/512 texel below, including the tie). Use a whole RGBA tuple from the same mip, with the existing edge addressing. Please show controls just inside and outside the interval and a mixed-channel negative control, alongside the existing wrong-mip and offset controls. In the notes distinguish the observed Win10 WARP values from the precision model inferred from them.
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-21T22:24:40Z.
Thanks, implemented in the follow-up commit. Point by point:
Scope: point-sampled magnified tail mips only. The neighbor branch runs only when
req.isTailDraw && req.scale > 1. Onlycheck_bc7_tailsetsisTailDraw, andscale > 1holds only for a requested mip above the first resident one. The renderer has a single static sampler (FILTER_MIN_MAG_MIP_POINT, clamp), so no other filter can reach it. A comment at the branch now says so.Exact texel first. Unchanged:
matches(expected)runs before anything else, and the neighbor branch is entered only if it fails.One immediate neighbor per axis, only where quantization can cross a boundary. I replaced the 3x3 candidate loop with an explicit per-axis neighbor. Per axis it is the previous texel for a center exactly on a boundary (the case that already existed), the next texel for a center at or above 511/512 of a texel (tie included), and otherwise none. The candidates are then (near x, exact y), (exact x, near y) and (near x, near y). The diagonal is reachable only when both axes are inside their own interval. The old loop admitted the same set, so this is a readability change, not a behavior change.
Same mip, whole RGBA tuple, existing edge addressing. Candidates come from
sampled.expectedof the sampled level and are compared with onememcmpover the four channels. On the last texel of an axis no neighbor is admitted, since clamp addressing has no boundary above it.Controls. Each control shader replaces chosen pixels with a texel fetched at its center, so the readback is identical on every adapter and the test exercises the acceptance logic itself, not the adapter's rounding. All use the 2x1 (or 1x2) mip at first resident mip 11.
pixel_mismatch x=2043 y=0pixel_mismatch x=254 y=0pixel_mismatch x=2044 y=0pixel_mismatch x=2048 y=0pixel_mismatch x=4095 y=0pixel_mismatch x=0 y=2043The existing wrong-mip controls and the 1/64-texel offset control are unchanged.
Each control fails when the logic is broken locally (not committed), on WARP 1.0.22, the RTX 3060 and the in-box WARP alike:
>for>=)Observed versus inferred.
docs/experiments.mdnow states them separately.R8G8B8A8_UNORM. WARP 1.0.9 through 1.0.22 and the RTX 3060 returned the first texel at all of them.D3D12_SUBTEXEL_FRACTIONAL_BIT_COUNTis 8 ind3d12.h, which fits the model but does not show how that WARP is implemented.Results. Windows 10 22H2 (19045), debug layer enabled, RTX 3060 on driver 32.0.15.9636, branch rebased on
6ee2406(head4d65fc3).ctest --preset dev --no-tests=error --timeout 120 -R '^bc7_draw_(warp|hardware)$': 2 of 2 passed on the in-box build (WARP 10.0.19041.5794) and 2 of 2 on the Agility 1.620.2 build with WARP 1.0.22.Both were rerun after the final rebase, together with
pixel_aot_warpandpixel_aot_hardware: 4 of 4 passed on each build.Full suite, 143 tests, measured on the same two commits before that rebase (on
1292d15):gpu_alias_lookup_writes_warpbvh_wave64_warp,wave_shuffle_warpThe three failures are the same as before this PR and do not go through the changed code. The two on WARP 1.0.22 are the lane misrouting from #145.
gpu_alias_lookup_writes_warpfails only on the in-box WARP and I have not investigated it.AI-assisted (Claude Code).