Repository navigation
Conversation
…efs R0Y00#2618) In compute stages, s_cselect_b32 sD, a, b where one source holds a number derived from a descriptor (descnum) and the others are constants, such as the C500 form sX, 0, sX, no longer refuses. It emits no HLSL. sD holds ('descnum', 'cselect', offset, arm, arm), so the arm that can zero a buffer's size is kept. No consumer reads that symbol as a value. A numeric read refuses as before. Scalar ALU other than s_mov refuses as "<op> on a select of descriptor data" (Stage.refuse_select_source). A descriptor operand holding it in any word refuses (Stage.select_word, called by Stage.descriptor), because a buffer load ignores edits to words 1-3 (R0Y00#2901). s_cselect_b64, m0/exec/vcc destinations, desc/ptr or run-time register arms and non-compute stages are unchanged. tests/startup_gfx2hlsl_cselect_descnum_check.py splices synthetic words into case A of the compute check. It checks the accepted forms, every later use by its refusal reason, and the unchanged refusals. Three mutated translators (zero arm dropped, load check removed, ALU check removed) must each fail a named check. A dispatch mode compares case A with the dead select on D3D12. Registered in tests/cmake and tests/checks. The note is docs/experiments/startup-gfx2hlsl-cselect-descnum.md. Co-Authored-By: Claude Opus 5.5 <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.
Change
In 250 compute rows of the C500-01 and C500-02 batches, the recorded refusal is
numeric use of sX holding descnumats_cselect_b32 sX, 0, sX(FIX declaration: #2618 (comment)).Stage.scalar_selectintools/startup/gfx2hlsl.pyread both sources as run-time values, and a number derived from a descriptor (descnum) has none.A select between descriptor data and zero can zero a buffer's size, which disables the buffer, so the result can't just be the descriptor arm. In a compute stage,
s_cselect_b32 sD, a, binto an SGPR, with one source holdingdescnumand the others constants, now emits no HLSL. sD holds('descnum', 'cselect', offset, arm a, arm b), and nothing reads that symbol as a value:numeric use of sD holding descnum, throughStage.S, which is unchanged.s_mov_b32ands_mov_b64copy the symbol. Any other scalar ALU with it as a source refuses with<op> on a select of descriptor data(Stage.refuse_select_source, called from the descriptor-data path ofStage.scalar). Otherwise it would turn into a plaindescnumor an in-place descriptor edit, and the arm would be lost.Stage.select_word, called byStage.descriptor). A buffer load ignores edits to words 1–3 of its descriptor (startup: a compute buffer load in gfx2hlsl ignores an edit to word 1–3 of its descriptor #2901, not fixed here), so without this check a copied select would reach the load with the zero arm dropped.scc from descriptor data in s_cselect_b32.Unchanged:
s_cselect_b64, m0/exec/vcc destinations, a raw descriptor word or a pointer as a source, a run-time register next to thedescnumsource, and every non-compute stage.Stage.execz_refusalsandraw_descriptor_aluare not touched. #2603 (draft) has a mesh-subclassop_s_cselect_b32override, but this change is gated tocsand doesn't touchmesh2hlsl.py.A row gets past the select only if sX is dead afterwards or only copied. Where sX is read later, the refusal moves to that read. The packets record only the first refusal, so the row effect needs a coordinator replay of the C500 rows. I own C200-02, not these batches.
Refs #2618, #2022
Verification
Commit faef97d on base b505c32. It merges cleanly onto current main 6ee878d. Windows 11 Pro build 26300, Python 3.14.8.
Result: exit 0,
0 failure(s). All 36 first-pass checks pass. They include two branch cases: a read after a forward join where one path skips the select, and a read at a loop head reached by a back edge after the select. Both refuse withnumeric use of s21 holding joined at a branch target, while the same join with a run-time write translates. Each negative control fails its named check:zero-arm-dropped(the select keeps only itsdescnumsource) fails 12 checks, including "raw conversion with the selected stride", which translates under it.load-check-removed(select_wordfinds nothing) fails the four load checks, including "load through a select copied into s14".alu-check-removed(refuse_select_sourceaccepts everything) fails four checks, including "an ALU copy into word 2 before the load".Before the change, the same check file run on b505c32 exits 1. It fails 17 of its 29 first-pass checks: the four accepted cases are refused at the select, and 13 later-use and branch checks get that refusal instead of their own reason. The mutation phase can't run there, because the helpers don't exist yet.
Existing pure-Python checks, each run directly with
python -B tests/<name>.pyon both b505c32 and faef97d, each exit 0 with no FAIL lines both times:startup_gfx2hlsl_compute_check,startup_gfx2hlsl_cselect_mask_check,startup_gfx2hlsl_scalar_m0_check,startup_gfx2hlsl_join_symbols_check,startup_gfx2hlsl_sopk_accum_check,startup_smem_address_check,startup_gfx2hlsl_refusals_check,startup_gfx2hlsl_handler_arity_check,startup_gfx2hlsl_scalar_null_check. Also on faef97d, each exit 0:docs_links_check,bidi_controls_check,run_checks_parallel_check.Coverage limit: the descriptor-operand refusal is exercised only for buffer load and buffer store operands. Image, sampler and
s_buffer_loadoperands go through the sameStage.descriptorcheck, but nothing here tests them.CTest, on faef97d (
cmake --preset dev -DINTAKE_PYTHON=<pe-env python>, Debug, thencmake --build --preset dev --target offscreen_check):Result: 2/2 passed.
startup_gfx2hlsl_cselect_descnum_controlspassed (0.49 s).startup_gfx2hlsl_cselect_descnum_warppassed (0.62 s):backend=warp debug_layer=enabled, adapter Microsoft Basic Render Driver (1414:008c), driver 10.0.26100.9818, DXC 1.9.2602.17 (Windows SDK 10.0.26100dxc.exe,cs_6_0). It dispatched 3x2x2 groups and compared all 320 words with case A's reference (0 mismatches,debug_errors=0 debug_warnings=0).CI Python list: the
Run Python checksstep of thepython-linuxjob, run on Windows with this interpreter. That istools/run_checks_parallel.py --from-dir tests/checks/python-linuxplus the 205 inline scripts, 211 checks in all, including the new one. Result in 29 s on all cores:tests/startup_run_sh_check.py: "a POSIX launcher; run it on Linux".tests/startup_build_rev_check.py: "the generator controls need both on PATH";cmakewas not on PATH in that shell.Not run:
startup_gfx2hlsl_cselect_descnum_hardware: the machine has one GPU, and no hardware run was requested.Evidence and follow-up
tests/startup_gfx2hlsl_compute_check.py(source-built, in this repository). No capture input.docs/experiments/startup-gfx2hlsl-cselect-descnum.md. Bullet indocs/startup-runtime.md. Registration:tests/cmake/startup_gfx2hlsl_cselect_descnum.cmakeandtests/checks/python-linux/startup_gfx2hlsl_cselect_descnum.txt.Checklist
AI-assisted (Claude Code).