Repository navigation
Recompiler: image_sample_o under an implicit LOD moves each blended mip by its own texels - #229
Merged
Merged
Conversation
…ip by its own texels A pixel shader's image_sample_o with an implicit LOD and a linear mip filter blends two mips; the console moves each one's texel coordinate by the offset in that mip's texels. XCL moved both by the offset / the size of the rounded LOD's mip, so the second mip read a texel off when the offset was half its texel or less. Now both mips are sampled with SampleLevel (each offset by its own size) and blended by the LOD's fraction. The per-mip form is taken when it is exact: MIP_FILTER linear, not anisotropic (as desc::sampler_d3d12 decides), and LOD >= 1 or min = mag filter (a level-0 SampleLevel filters with the mag filter). Otherwise the single Sample is kept as before. A clamp past the last mip samples the last mip. texel_offset / sample_coord / moved_coords are shared with the existing offset path. Test harness: draw textures with several mips (runner::draw_views, ViewTexture data = the levels one after the other). Test: gpu_ps_image_sample_offset_implicit_lod_between_mips (LOD 0.25 between 8x8 and 4x4, offset +1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
artor410
force-pushed
the
recomp/sample-offset-per-mip
branch
from
November 23, 2026 21:26
20271d4 to
8a98da6
Compare
ivall
added a commit
that referenced
this pull request
Nov 23, 2026
Owner
|
Merged (main 60565c4), your rebased head; main had merged the earlier head with |
Kalmarv
added a commit
to Kalmarv/xcl
that referenced
this pull request
Nov 23, 2026
ivall#229 picks the offset's mip for the plain form only; the bias, gradient and (in a PS) comparison forms still divided by mip 0's size. The level is now the given LOD, else that of the given gradients or the pixel's own (screen derivatives for comparison samplers, which CalculateLevelOfDetail does not take), plus the bias. That LOD is the unclamped one, so a bias on a magnified pixel starts below 0 (found by ryotdev); the sampler's MIN_LOD / MAX_LOD and the view's last mip are applied after the bias. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HANDOFF "Next steps" 5:
image_sample_owith an offset from a VGPR. A pixel shader's implicit LOD with a linear mip filter blends two mips; the console moves each one by the offset in its own texels. XCL moved both by offset / size of the rounded LOD's mip, so the second mip read one texel off whenever the offset was half its texel or less.Summary
emit.rs:texel_offset/sample_coord/moved_coords, shared with the existing offset path (no second copy of the GetDimensions / sign-extension code).runner.rs:ViewTextureuploads every mip level (data= the levels one after the other);draw_views=drawwith textures and samplers.drawnow goes throughdraw_on_multi.tests.rs:draw_console_views(SGPRs + textures) and the new test.Evidence
gpu_ps_image_sample_offset_implicit_lod_between_mips: a PS draw, 8² / 4² / 2² / 1² texture (level k texel x = 100·k + x), point min/mag, linear mip, clamp, uv = pixel centre · 2^0.25 / 8 (LOD 0.25), offset (+1, 0). Expected per pixel, from the console rule:0.75 · texel₈(⌊8u⌋+1) + 0.25 · (100 + texel₄(⌊4u⌋+1)).pixel (0,0) = 25.75, expected 26(mip 1 read texel 0 instead of 1)After: passes;
gpu_image_sample_offset(lz) still passes.Rebased on
d4f17ca(draw_gsfrom #199 anddraw_viewsshare onedraw_gs_views).cargo test --workspace --no-fail-fast: lib 606 passed, every other target green excepte2e::test_title_draws_with_a_root_signature_under_the_debug_layer, which fails the same way onmainhere: my checkout's path is over 260 characters and the test title's overlay file writes hitos error 3. Tested on an NVIDIA RTX 3070 Ti (driver 610.88, 32-lane waves); not run on AMD.Merge Danger
Door: two-way
Blast Radius: PS
image_sample*_owith an implicit LODOnly that form changes; every other sample keeps its HLSL. Its HLSL now has three samples instead of one (the fallback
Sampleis always emitted; DXC folds the select only for static samplers) – I could not count how many pack programs use it without the pack. Not covered / not verified:CalculateLevelOfDetailand the sampler'sMipLODBias: not checked that it adds the bias as the hardware does (the test uses bias 0)._l_owith a fractional LOD and_b_ooutside a PS still use the one-mip form.Overlap: none of the open PRs that touch
emit.rs(#128, #134, #138, #152, #174, #187, #199, #202, #214) change the MIMG sample code.AI-assisted (Claude Code), synthetic inputs only, no game data.
🤖 Generated with Claude Code