shader: compose ballot lowering with the SPIR-V address window #768

Merged
Jess-Doit merged 1 commit from upstream-pr/774 into main 2026-11-23 02:24:19 +00:00
Jess-Doit commented 2026-11-23 02:10:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-23T02:10:30Z.


Change

Check the reserved %x2w_ prefix against the input assembly. Give address temporaries a separate %x2w_address_ prefix so a source pointer name cannot collide with a ballot temporary. The adapter rejects reserved IDs in the input and conflicts with descriptor sets 1 and 2.

Verification

Tested 9958958 on Windows 10 22H2 build 19045.6456 with the Vulkan SDK 1.4.363.0 tools. The combined fixture reproduced the original reserved-prefix error. The renamed-pointer case then reproduced a duplicate-ID error before the separate prefix was added. The public CLI now validates both inputs and both lowered outputs. Existing rejection cases and both reserved-ID controls passed.

$env:PATH = "C:\VulkanSDK\1.4.363.0\Bin;$env:PATH"
python -B tests/spirv_window/check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

App-local Agility 1.620.2 and WARP 1.0.22 matched all 16 words in each of the eight address-window cases for the plain shader and both combined variants. Renaming the pointer produced byte-identical logical SPIR-V. Clearing the ballot bit caused the expected mismatch at word 11 (eca86420 expected, 00000000 observed). The debug layer reported zero warnings and errors. The GTX 1060 and Windows 10 in-box WARP both returned the existing capability skip 77.

To repeat the combined readback with DXC and an app-local WARP build:

New-Item -ItemType Directory -Force -Path out/window-ballot | Out-Null
@'
from pathlib import Path
from runpy import run_path

out = Path('out/window-ballot')
assembly = run_path('tests/spirv_window/check.py')['combined']
(out / 'ballot.spvasm').write_text(assembly, encoding='utf-8')
renamed = assembly.replace('%p2 ', '%ballot_ballot_bit ')
(out / 'ballot-renamed.spvasm').write_text(renamed, encoding='utf-8')
mask = 'OpConstantComposite %ballot_type %c1 %c2 %c3 %c4'
clear = 'OpConstantComposite %ballot_type %c2 %c2 %c3 %c4'
(out / 'ballot-clear.spvasm').write_text(assembly.replace(mask, clear), encoding='utf-8')
'@ | python -B -
foreach ($case in 'ballot', 'ballot-renamed', 'ballot-clear') {
    $shader = "out/window-ballot/$case"
    python -B tools/spirv_address_window.py "$shader.spvasm" "$shader.spv"
    spirv-cross "$shader.spv" --hlsl --shader-model 66 --output "$shader.hlsl"
    dxc -T cs_6_6 -E main -Fo "$shader.dxil" "$shader.hlsl"
    out/build/app-local/offscreen_check.exe warp --spirv-address-window "$shader.dxil"
}

Evidence and follow-up

The regression extends the existing MIT-licensed subtract.spvasm fixture with a ballot read that controls the stored value. It runs in the existing offline SPIR-V validation job. The experiment notes describe the combined case.

Checklist

  • Covers one reviewable behavior.
  • Includes commands and observed results.
  • Covers reserved input IDs and a cleared-bit negative control.
  • Updates the experiment documentation.
  • Uses source-built fixtures.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6550829750 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/774). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-23T02:10:30Z. --- ## Change Check the reserved `%x2w_` prefix against the input assembly. Give address temporaries a separate `%x2w_address_` prefix so a source pointer name cannot collide with a ballot temporary. The adapter rejects reserved IDs in the input and conflicts with descriptor sets 1 and 2. ## Verification Tested `9958958` on Windows 10 22H2 build 19045.6456 with the Vulkan SDK 1.4.363.0 tools. The combined fixture reproduced the original reserved-prefix error. The renamed-pointer case then reproduced a duplicate-ID error before the separate prefix was added. The public CLI now validates both inputs and both lowered outputs. Existing rejection cases and both reserved-ID controls passed. ```powershell $env:PATH = "C:\VulkanSDK\1.4.363.0\Bin;$env:PATH" python -B tests/spirv_window/check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` App-local Agility 1.620.2 and WARP 1.0.22 matched all 16 words in each of the eight address-window cases for the plain shader and both combined variants. Renaming the pointer produced byte-identical logical SPIR-V. Clearing the ballot bit caused the expected mismatch at word 11 (`eca86420` expected, `00000000` observed). The debug layer reported zero warnings and errors. The GTX 1060 and Windows 10 in-box WARP both returned the existing capability skip `77`. To repeat the combined readback with DXC and an app-local WARP build: ```powershell New-Item -ItemType Directory -Force -Path out/window-ballot | Out-Null @' from pathlib import Path from runpy import run_path out = Path('out/window-ballot') assembly = run_path('tests/spirv_window/check.py')['combined'] (out / 'ballot.spvasm').write_text(assembly, encoding='utf-8') renamed = assembly.replace('%p2 ', '%ballot_ballot_bit ') (out / 'ballot-renamed.spvasm').write_text(renamed, encoding='utf-8') mask = 'OpConstantComposite %ballot_type %c1 %c2 %c3 %c4' clear = 'OpConstantComposite %ballot_type %c2 %c2 %c3 %c4' (out / 'ballot-clear.spvasm').write_text(assembly.replace(mask, clear), encoding='utf-8') '@ | python -B - foreach ($case in 'ballot', 'ballot-renamed', 'ballot-clear') { $shader = "out/window-ballot/$case" python -B tools/spirv_address_window.py "$shader.spvasm" "$shader.spv" spirv-cross "$shader.spv" --hlsl --shader-model 66 --output "$shader.hlsl" dxc -T cs_6_6 -E main -Fo "$shader.dxil" "$shader.hlsl" out/build/app-local/offscreen_check.exe warp --spirv-address-window "$shader.dxil" } ``` ## Evidence and follow-up The regression extends the existing MIT-licensed `subtract.spvasm` fixture with a ballot read that controls the stored value. It runs in the existing offline SPIR-V validation job. The experiment notes describe the combined case. ## Checklist - [x] Covers one reviewable behavior. - [x] Includes commands and observed results. - [x] Covers reserved input IDs and a cleared-bit negative control. - [x] Updates the experiment documentation. - [x] Uses source-built fixtures. AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:44:43 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!768
No description provided.