Repository navigation
shader: keep structured-to-raw descriptor words at compute joins - #3687
Merged
Merged
Conversation
At a branch target gfx2hlsl keeps a descriptor word only when every path brings the same symbol and names_one_value() accepts it. The tags that raw_descriptor_alu() puts on the converted words (stride cleared, byte count, OOB_SELECT 3) were not accepted, so a compute buffer access after a join refused with "descriptor operand ...: sN holds a word joined at a branch target" even when every path brought the same converted words. raw_conversion_word() accepts those words at compute joins only. A spill of a modified word stays refused, and vertex stages are unchanged. Joins that mix a converted word with another word, and a loop whose back edge converts the words the header entered with, still refuse. A numeric read of the joined byte count refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaslw-lab
approved these changes
Dec 1, 2026
lukaslw-lab
left a comment
Contributor
There was a problem hiding this comment.
Reviewed be5efdf7 by reading the diff; not built or run.
Verdict: approve. A compute join now keeps the converted words only when every path brings the identical symbol, and the only readers check the whole converted descriptor, never the count. No MUST, no SHOULD.
- Checked, no finding:
stride0andoob3name one value on every path.oob3isword | 0x30000000, whether or not theoob0mask ran first, so the two spellings that share the tag give the same bits.byte_countis the one tag that can stand for two values:NUM_RECORDS * strideandNUM_RECORDS * max(stride, 1)differ when the stride is 0. Its only readers,load_descriptorandstore_descriptor(gfx2hlsl.py:7504-7552), compare the four-word tuple and emit an unbounded raw access without reading the count. A single path with either product was already accepted, so the clamped/plain join adds no new run-time case. The two numeric-read controls pin the other way the count could be used.- A partly converted set (
oob0only, or the stride cleared on one arm) still fails at the use, because the consumers need the full(w0, stride0, byte_count, oob3)tuple. The "one arm clears the stride only" control covers the join side of that. - The gate is
kind == 'cs', andnames_one_valueis unchanged, so spill proofs and other stages behave as before.
- Loop control: the back edge brings converted words into a header entered with plain ones, and the join refuses. This is the case a first-visit
keptentry could otherwise get wrong.
Tests: the four kept diamonds prove the join path (gfx2hlsl.py:4257-4259) translates the same load as one path does. The refused diamonds, the loop and the mutant (raw_conversion_word = lambda sym: False) prove the new condition is what keeps them. CI did not run startup_gfx2hlsl_load_desc_check.py: it is not in the Windows pr filter or in the Linux job's script list, so the author's local run is the only one.
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.
Refs #2274
Change
At a branch target,
tools/startup/gfx2hlsl.pykeeps a descriptor word only when every path brings the samesymbol and
names_one_value()accepts it. The tags thatraw_descriptor_alu()adds to the words of thestructured-to-raw conversion (
stride0,byte_count,oob3) were not accepted. A compute buffer access after ajoin therefore refused with
descriptor operand s[a:b]: sN holds a word joined at a branch target, even when everypath brought the same converted words.
raw_conversion_word()accepts those words at compute joins only (names_one_value()is unchanged). Vertex stagesare unchanged. The spill path still refuses a modified word, as
startup_gfx2hlsl_compute_spill_check.pyrequires.The
joined_wordnote indocs/experiments/startup-gfx2hlsl-cselect-descnum.mdgains one sentence.The byte-count tag covers both products (
NUM_RECORDS * strideandNUM_RECORDS * max(stride, 1)). No computeconsumer reads the count: raw loads and stores are unbounded, and a numeric read of a descriptor word is
refused. #3100 gives the clamped product its own tag (
('byte_count', 'min1')). The new helper checks only thefirst tag, so either merge order keeps both forms at a join.
Fixture
tests/startup_gfx2hlsl_load_desc_check.py(compute case A, source-built words) gains joins after the conversion:runs the clamped conversion and the other the plain one; both arms clear the stride.
joined at a branch target: one arm converts and the other does not; one arm clears the strideonly; a loop enters the load with the loaded words and converts them before its back edge.
numeric use of ...: a vector read of the joined byte-count word, and of a scalar computed from it,after the clamped/plain diamond.
raw_conversion_wordreplaced bylambda sym: False, the kept diamond refuses again.Evidence
Commit under test:
be5efdf7onmain1a9ccbc4(fixture and join checks rerun after the rebase; the retranslation numbers are fromfbb76499ona3bfd019).Single checks, all exit 0:
Offline retranslation of a local set of compute requests that refused with this message (37 programs): none
refuse with it now. 3 translate, and their HLSL compiles with DXC (
cs_6_0). The rest stop at later, separaterefusals: a readfirstlane waterfall body,
s_cbranch_execzjoins, and a descriptor used for both a load and a store.The other 119 requests of the same local batch refuse with the same text as before. A further 223 local compute
requests that already translated give byte-identical HLSL and manifests before and after the change. These are
local results and say nothing about run-time behavior.
🤖 Generated with Claude Code