native: accept a literal sampler whose word 3 is a GPU value when no axis is BORDER #3519
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!3519
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3517"
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?
@JB2WIN on GitHub · 2026-11-29 21:13 UTC · original
JB2WIN:native/sampler-dynamic-word3→main· +20 −0 · 2 files · 1 commits · closed without mergingRefs #3226, #3023.
A literal (static) sampler whose words 0-2 are constants but whose word 3 comes from a GPU value was refused as
nonconstant sampler. The static sampler reads word 3 only for the border colour (bits 31:30,decode_samplerinsrc/startup_stubs/translated_sampler_bindings.h), and only a BORDER address mode uses it (CLAMP_X/Y/Z 6 or 7). So with words 0-2 constant and no BORDER axis, word 3 cannot change the sampler. The translator now sets it to 0. With a BORDER axis it refuses, namedsampler border colour from a GPU value.This is a step on the #3023 heap-texture route. In my local prototype of that route (texture loads and image fields stubbed in), 299 requests stop at
nonconstant samplerwith words 0-2 constant and word 3 numeric. Onmaintoday those programs stop earlier, at the heap refusal, so this PR alone moves no request in the local cohort. It is groundwork, measured on the prototype only.Tests:
native_sampler_heap_check.py:dynamic_word3(literal words 0-2,v_readfirstlane_b32 s15, v0as word 3) compiles.border_word3(the same with CLAMP_X 6) refuses with the new reason.native_sampler_heap_hardware,native_exec_symbol_b64_controls,startup_inline_sampler_{controls,warp,hardware},startup_compute_dispatch_native_hardware: pass (WARP skips as on main).src/reverted,native_sampler_heap_hardwarefails.AI-assisted.
🤖 Generated with Claude Code
@Leyukaka on GitHub · 2026-11-29 21:32 UTC · original · reviewed
Diff-only review at
ace59889, nothing built or run.The logic is correct for non-comparison samplers:
decode_samplerreads word 3 only in bits 31:30, and modes 6 and 7 are the only BORDER address modes, so a GPU word 3 cannot change the sampler when no axis is BORDER.SHOULD: for a comparison sampler, word 3 is zeroed before the
border & 0x3ffff000check (mainsrc/gfx1013_compute_native.cpp:1170-1175, "unsupported comparison sampler fields"), so that check is vacuous for a GPU word 3. The decoded sampler is the same, but a constraint enforced on literal words is dropped without a note. Either refuse a GPU word 3 whencomparison, or say in the comment why bits 29:12 do not matter. No test covers comparison + GPU word 3.SHOULD:
border_word3only has CLAMP_X = 6, so a mutant that checks only X (axis < 1) or== 6instead of>= 6would pass. One refusal case with CLAMP_Z = 7 pins both.@JB2WIN on GitHub · 2026-11-29 22:00 UTC · original
Closing this one. A remeasure of my local prototype with this change showed that it moves none of the 299: all of them have CLAMP_BORDER on X and Y, so they stop at the new
sampler border colour from a GPU value.The cause is elsewhere. In all 299, word 3 is written by
s_brev_b32(163),s_bfe_u32(67), or by a value that has already been through one of them (43). The symbol analysis does not fold either instruction even when the operands are constant. With the fold, word 3 is the constant 0x80000000 (OPAQUE_WHITE), and the sampler is literal. So the fold is the fix (claim on #3226, issuecomment-7263320436). A real GPU word 3 has not shown up in my captures. I'll reopen this if one does.AI-assisted.
@JB2WIN on GitHub · 2026-11-29 22:26 UTC · original
@Leyukaka thanks. Our messages crossed: I closed this after the remeasure (comment above), because the 299 get a constant word 3 from the
s_brev_b32/s_bfe_u32fold instead. Both of your points still apply to that follow-up. Those 299 are comparison samplers with CLAMP_BORDER on X and Y, so the comparison path'sborder & 0x3ffff000check will be checked on a real constant word 3 there. Its test will also include a CLAMP_Z = 7 case.AI-assisted.
Pull request closed