shader: split depth-reference views of any sampler table in the SPIR-V bridge #1217
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1224"
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 tedin7 on 2026-11-24T04:22:21Z.
Change
split_sampler_views()only handled one hardcoded profile: a variable named%samplers, type IDs%smpand%_ptr_UC_smp, descriptor set 0 binding 1 andOpAccessChain. It now finds every uniform-constant variable whose type is anOpTypeArrayorOpTypeRuntimeArrayofOpTypeSampler, under any IDs, in any descriptor set except 3, at any binding, reached throughOpAccessChainorOpInBoundsAccessChain. The set 3 view keeps the table's binding. Each table is decided on its own: only a table reached by both a depth-reference and an ordinary sample (sparse forms included) gets a view, with several tables each getting one. The set 3 conflict check and the existing refusals are kept. The old "foreign table is refused" case is now a legal comparison-only table and leaves the module unchanged.Code:
tools/spirv_sampler_views.py. Test:tests/spirv_window/sampler.py. Docs:docs/experiments.md. Standalone SPIR-V bridge, no CPU translator touched. AI-assisted.Verification
Local (Linux, SPIRV-Tools and SPIRV-Cross from apt, no dxc or D3D12):
python3 -B tests/spirv_window/sampler.py spirv-as spirv-val spirv-crossexits 0 with this change and exits 1 on origin/main (01b955a9, same test file; the renamed-table and moved-table cases are refused or left unsplit there).compare_sampler.pyandcheck.pywith the same three tools: pass.tests/spirv_window/*.spvasmfixture plus the pixel variant, so no existing bridge input changes.New cases: renamed IDs with
OpInBoundsAccessChain; runtime-sized table at set 2 binding 7 validated by spirv-val, emitted by SPIRV-Cross with the comparison view atregister(s7, space3); two split tables plus an ordinary-only and a comparison-only table left alone; sparse ordinary use. Negative controls: set 3 on the table or elsewhere, abridge_cmpID, missing or duplicateDescriptorSet/Binding, a decorated table, a non-sampler load type, a non-sampler pointer type, a sampled image that is not anOpSampledImage, two tables sharing one set 3 binding, and an array of images (not a table, module unchanged).Not run: the GPU readback of the renamed variant (
sampler_readback.cpp, unchanged, same four expected words and three descriptor orders as the original; a view wired to the wrong table changes a precise word). Missing prerequisite: a Windows host with dxc and D3D12. The Windows jobsspirv_sampler_views_{hardware,warp}run it.Evidence and follow-up
Fixtures are the existing synthetic
sampler.spvasmedited by the test (renames, type and decoration edits); no game data. Assumption: a table with a sampled image from an unresolvable source counts as possibly used by every table for the ordinary side, so it splits conservatively. Not done: a GPU root signature for a table at a set other than 0 (the readback harness keeps slots 0/1 and 3/1).Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:32:04Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
771498b470ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:33:34Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:33:36Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:40:24Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
a2f907dd9dℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:41:14Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:53:28Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
828a072357ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:54:11Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:33:38Z.
Fixed in
a2f907dd: split tables now refuse overlapping set 3 register ranges (fixed size, runtime size and equal bindings, with tests), and a ; comment after any declaration no longer hides the sampler types (the test adds comments and a semicolon inside a quoted name). tests/spirv_window/sampler.py fails on the previous commit and passes now.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:34:03Z.
AI-assisted update: both P2 findings are fixed in
a2f907dd(overlapping set 3 register ranges are refused; ; comments are stripped before matching). Local checks: tests/spirv_window/sampler.py and check.py pass; sampler.py fails on the previous commit.@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:41:16Z.
Fixed in
828a0723: the reserved set 3 check now reads the parsed DescriptorSet decorations (extra whitespace, tabs and leading zeros included); test added, fails on the previous commit.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:44:20Z.
AI-assisted: the third P2 is fixed in
828a0723, sampler.py and check.py pass locally.@codex review
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:54:13Z.
Fixed in
0806ef57: comment stripping now carries quote and escape state across the whole assembly, so a multiline string with a semicolon on a continuation line is kept intact (test assembles and validates it; it fails on the previous commit).Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:57:22Z.
Windows Server 2025 verification (
0806ef57) — PASS (Debug + Release/O2, WARP)--preset dev) (11.54s build+test):cmake --build --preset dev -j 6 --target offscreen_checkctest --test-dir out\build\dev -R "^spirv_.*_warp$" --output-on-failure-> 11/11 passed (0 skipped, 11.41s;spirv_sampler_views_warp0.88s)/O2(--preset release) (12.29s configure+build+test):cmake --preset release && cmake --build --preset release -j 6 --target offscreen_checkctest --test-dir out\build\release -R "^spirv_.*_warp$" --output-on-failure-> 11/11 passed (0 skipped, 10.55s;spirv_sampler_views_warp0.68s)Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:02:15Z.
@codex review
AI-assisted: all inline findings are fixed through
0806ef57; please re-read the current head.Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T05:12:05Z.
Codex Review: Didn't find any major issues. Delightful!
Reviewed commit:
0806ef5769ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:24:49Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
0806ef5ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:32:04Z.
Code review location:
tools/spirv_sampler_views.py; line 127For two mixed two-element tables at
(set 0, binding 1)and(set 2, binding 2), this check accepts both and moves their comparison arrays to bindings 1 and 2 in set 3. The corresponding HLSL arrays occupys1..s2ands2..s3inspace3, so the comparison views overlap ats2even though the original tables were in separate spaces. The two views therefore cannot bind their descriptors independently; multiple runtime-sized tables have the same problem. Check the full register ranges, or refuse overlapping layouts, before emitting the views.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:32:04Z.
Code review location:
tools/spirv_sampler_views.py; line 61Adding a valid inline comment such as
%smp = OpTypeSampler ; sampler typeto the existing fixture makesread_module()include the comment tokens in the stored definition, so this equality no longer recognizes the sampler table.split_sampler_views()then silently returns the original mixed module, leaving ordinary and depth-reference operations on the same sampler and recreating the HLSL type conflict. The parent commit still splits this same input. Strip or tokenize SPIR-V comments before matching type declarations.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:33:34Z.
Code review location:
tools/spirv_sampler_views.py; line 127Fixed in
a2f907ddImported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:33:36Z.
Code review location:
tools/spirv_sampler_views.py; line 61Fixed in
a2f907ddImported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:40:24Z.
Code review location:
tools/spirv_sampler_views.py; line 132If the existing fixture's table decoration is changed to
OpDecorate %samplers DescriptorSet 3(with valid extra whitespace), this accepts set 3 while the reserved-set regex insplit_sampler_views()misses it because it requires single spaces. The generalized path then emits both%samplersand%bridge_cmpat set 3/binding 1, so the ordinary and comparison views occupy the same sampler registers and cannot be bound independently. The parent rejected this input through its hard-coded set-0 check. Validate the parsed descriptor-set value before allocating the comparison view rather than relying on the formatting-sensitive scan.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:41:14Z.
Code review location:
tools/spirv_sampler_views.py; line 132Fixed in
828a0723Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T04:53:28Z.
Code review location:
tools/spirv_sampler_views.py; line 160For a mixed-sampler module containing a valid multiline
OpSourcestring, each call tostrip_comment()forgets whether the previous line opened a quote. A continuation line such asint tmp = 0; }"is consequently truncated at the semicolon, removing the string's closing quote and producing an unassemblable rewritten module. Adding that source string to the existing sampler fixture reproduces the corruption, while the parent preserves the string. Preserve quote and escape state across the full assembly rather than resetting it for every line.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:54:11Z.
Code review location:
tools/spirv_sampler_views.py; line 160Fixed in
0806ef57