A buffer_load_format_* with a run-time FORMAT called the four per-component
decode functions %fmt_dec_c0..3 at every load, whatever it wrote. One
function %fmt_dec(format, element, component) replaces them, and a load
calls it once per register it writes, with the component that register's
DST_SEL picks: _x makes one call, not four. The function computes the four
components' channel width and offset as before and the parameter selects
one, so the values are the same.
fconst (and tof of a uint constant) emitted a new OpBitcast of the uint
constant at every use; they now give one cached OpConstant %float per bit
pattern, written so spirv-as reads back the same 32 bits (float_literal:
shortest decimal for a finite value, the SPIRV-Tools hex-float spelling for
an infinity or a NaN). The test interpreters read that spelling.
Tests: test_buffer_format_decode_one.py with hand-written fixtures
(calls per load, values for 16 codes, swizzles, out of bounds, _x/_xy
against _xyzw for all 128 codes) and test_fconst_constant.py (exact bits of
+-0, denormals, infinities and NaN payloads).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- tools/rdna2spirv.py, mesh_export: #1197's misc-vector return for pos1
(Layer/ViewportIndex) comes first, then this pull request's compressed
components; both kept.
- docs/design.md, "Mesh shaders" row: main's row (with #1197's sentence)
plus this pull request's compressed-export sentence.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "Mesh shaders" row of docs/design.md changed on main (#802); the
compressed-export sentence is added to main's version of the row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cfg_structure.structure() wraps post-dominating join blocks after a diamond or loop in a ('guard', g, ...) node even when %pc == g is tautologically true on every incoming path. wave64_emulate_opt._unwrap_known_pc_guards already unwraps these guards for --wave64-emulate, which is why ms_wave_info_s3 passed on 32-wide NVIDIA GPUs while crashing with 0xC0000005 on native wave64 AMD RDNA2 Windows (driver 24.10.24, LLPC) where blk2's OpControlBarrier stayed trapped inside a conditional OpBranchConditional.
Move unwrap_known_pc_guards into tools/cfg_structure.py (reused by wave64_emulate_opt with zero duplication) and apply it in rdna2spirv.capped_tree() so both assemble() and needs_barrier_rounds() see post-dominating join blocks at top level.
SHADER-STRUCTURED-PC-UNWRAP
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
AMD's proprietary Windows Vulkan driver (24.10.24, LLPC) segfaults (0xC0000005) during vkCreateGraphicsPipelines whenever a MeshEXT shader lists a Block-decorated per-vertex output struct with ClipDistance/CullDistance (%ms_out_vtx) before the Block-decorated PerPrimitiveEXT CullPrimitiveEXT output (%ms_cull) in OpEntryPoint's interface list (even glslangValidator's own GLSL output with gl_ClipDistance + gl_CullPrimitiveEXT hits the same crash).
Listing %ms_cull before %ms_out_vtx/%ms_out_pos in OpEntryPoint fixes ms_clip on AMD Windows RDNA2 (0xC0000005 -> 2048/4096 covered pixels exact, 0 validation errors) while keeping %ms_cull_blk in its Block+bool form required by SPIRV-Tools <=2025.1 (SHADER-30).
SHADER-MS-CLIP-IFACE
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
translator-tests fails on main since 6261ca916 (the merge of #957), which added runtime/test/shaders/cs_dpp_cmp.asm:
tests/test_translate.py::test_gpu_samples_translate_and_validate[cs_dpp_cmp.asm] and
::test_wave64_emulate_uses_no_subgroup_ops[cs_dpp_cmp.asm] stop at the llvm-mc assertion of conftest.Shader with
"dpp variant of this instruction is not supported" (2 failed, 1879 passed on a runner with llvm-mc 21; the same two
with 23.1.4).
llvm-mc has no gfx1013 encoding for a VOPC compare in DPP form, so the fixture carries the line
"; run_gpu_tests: text only, ..." and assemble_to_s in scripts/run_gpu_tests.py writes its listing from the text.
conftest.Shader assembled every sample with llvm-mc and did not know the line. It now does the same as the GPU
runner for a sample that carries it, so both tests translate and validate the fixture instead of failing before
they reach the translator.
Two new tests: the line is spelled in conftest as in run_gpu_tests.py, and only a sample that carries it skips
llvm-mc (the same lines without it still go to llvm-mc and fail there). Controls: with the line spelled
differently in conftest the spelling test and both cs_dpp_cmp tests fail; with every sample taking the text path
the second new test fails.
The translator-tests step with the workflow's file list (37 files, pytest 9.2.0, llvm-mc 23.1.4, without numpy
and Pillow, so 134 skipped): 2 failed, 1618 passed on main 89d7dfcf5; 1622 passed here.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
lower_addr64 rewrites the assembled module's 64-bit address arithmetic (the zero-extend, shift-by-32, OR/AND, add and
subtract with carry, narrowing, sign-extension, 64-bit bitcasts and pair compares the address idiom uses) into uint
pairs and an OpBitcast of a 2x32 vector to the PhysicalStorageBuffer pointer, and drops OpCapability Int64 when
nothing else needs it, so translated shaders run on devices without shaderInt64. --int64-addresses keeps the 64-bit
form. Semantic tests for the lowering, the interpreters learn the pair pointer form, design.md row.
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
The VOP1/VOP3 op saturates each signed i16 half of SRC0 to unsigned
8-bit and packs the pair into the low 16 bits of VDST, preserving the
high half (GFX9+ partial write; LLVM VOP1Inst_t16, Mesa ACO
instr_is_16bit). Neg/abs/clamp/omod are refused; _sdwa restricts to the
documented source/destination selects; _e32 rejects all modifiers.
Adds a hand-written fixture and a semantic test driving the SPIR-V
through spirv_mini_interp against a plain-Python reference (lane edge
values, SGPR/literal sources, sdwa selects, refused modifiers), the
docs/design.md contract row, and drops the op from the
fssm_crosscheck unhandled list. The two tests that used the mnemonic
as the still-unsupported canary now use v_mullit_f32.
Generated with [Devin](https://devin.ai)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
RSRC2 bit 10 adds an SGPR after the workgroup ids. The translator refused every compute
shader that sets it. None of the 2,689 carved CS does, but 91 compute programs of the
pipeline library in shaders.rpf do (docs/shader_library.md), and they read it as
s_and_b32 sN, sTG, 0xfc0, mostly followed by v_mbcnt_lo_u32_b32.
The prologue now writes it: waves in the group in [5:0], this wave's index in [11:6], 0
above. That is the GFX6-10 layout Mesa reads (ac_nir_lower_intrinsics_to_args.c:
load_num_subgroups = tg_size[5:0], load_subgroup_id = tg_size[11:6], wave64 local
invocation index = mbcnt(~0, tg_size & 0xfc0)). Thread i is in wave i / W, as for
s_get_waveid_in_workgroup. Not measured on hardware.
tests/semantic/test_cs_tg_size.py runs it on the CPU (local index through the 0xfc0 field
in wave32 and wave64, 1-D and 3-D groups, the wave count with a partial wave, the whole
value, the register after three workgroup ids). The two tests that pinned the refusal now
check that it translates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts were both-sides additions: docs/design.md (main's DPP, EXEC and
saveexec row updates kept; this branch's Control flow row kept) and
tools/rdna2spirv.py (main's _out_inside_input and --opt kept next to
_depth_arg and --max-structured-depth).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_volume_address_operands (a16), test_explicit_mip_depth_compare (a16) and test_rcp_iflag_mods' source-modifier
chain walked an f32 through `OpBitcast %uint` and back to `OpBitcast %float`. That round trip is now the original id,
so the a16 coordinates and LOD are the UnpackHalf2x16 component itself, and a modified source feeds OpFDiv directly.
The checks now skip bitcasts (or, for the modifiers, require none) on the way to the same source. tests/ outside
tests/semantic now fails exactly as main does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The image_gather4_l emulation picked its mip as Floor(lod + 0.5). The sum
is rounded in binary32: 0x3effffff + 0.5 lies halfway between 1 - 2^-24
and 1.0 and rounds to even, 1.0, so the gather fetched mip 1 where native
nearest-mip sampling at the same LOD reads mip 0 (RTX 5070, 621.24).
Compute floor(lod) + (lod - floor(lod) >= 0.5) instead: both operations
are exact in binary32, and a tie still rounds up (SHADER-152).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict in tools/rdna2spirv.py assemble(): main added the x_round_fns
helper loop next to the old inline depth check. Kept main's helper loop
and this branch's capped_tree() call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- shader_disasm: prune stale listings against every input, not the --skip-existing remainder (a resumed run
deleted every listing it had just reused).
- progress_dashboard: a drive-letter path is never inside the repository off Windows (it printed user names);
its own read_text helper is read_utf8, so the encoding check does not take it for pathlib's.
- Translator tests follow this round's rules: desc_lookup's BroadcastFirst in the typed-load condition walker;
resinfo sizes are 0 past the last level and a 2D depth word is 0 (SHADER-388); SHADER-315 constant folding in
the perm and i16 tests; #2089's structured wave64 emulation.
- test_semantic_translator_use: 57 oracle-only files merged before it are DEBT; test_spirv_tools_required is
allowed (CI meta-test).
- Test fixes: image_fuzz fake writes the programs, preflight follows c506d00c's loader hint rule, feature_scan
reads the first line of a pytest-decorated message, w64_graphics wording.
- docs: rows merged again in design.md, README.md, d3d12_vulkan.md; GameInput table rebuilt from #3172's rows;
orphan rows in models.md and embedded_shaders.md; repeated bullets; anchors; a flag not on main.
- Repo rules: stdout guard on 14 programs; LF writes; csv lineterminator in bink_play.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: tools/rdna2spirv.py (--pc-tail-ubo and --max-structured-depth
both added next to --max-shared-memory: kept both) and docs/design.md
(upstream reworded the neighbouring rows: kept theirs and re-applied the
SHADER-427 sentence of the "Control flow" row).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
needs_barrier_rounds() looked at the unbounded structured tree, while
assemble() emits the dispatch loop once the tree nests deeper than
MAX_STRUCTURED_DEPTH. A wave32 compute shader with a top-level s_barrier
over the bound then got the dispatch loop without barrier rounds. Both
now use capped_tree(). With the default bound (64) no corpus module is
affected (the deepest is 29); it matters when --max-structured-depth is
set below a shader's depth.
The CLI test now pins the default to the literal 64.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The semantic CI job discovers tests with unittest. Run the numerical fixture there and retain compiled shader validation in the tool-backed pytest job.
- tests/semantic: BaseVertex/BaseInstance read 0 in the wave interpreter; the LDS MockGens follow
SHADER-309 (lds_bound, lds_access, lds_atomic); abs emission tests load their operand, since
SHADER-315 folds scalar ALU on constants.
- test_translate: the dynamic gather sampler is a loaded word, not s16 + 0 (SHADER-315 folds it).
- test_world_build: DDS downscale weights colours by alpha (62804d0d).
- test_fspx_shaders_stage: the fake disassembler writes the listing make_game now checks.
- xgameruntime_test: re-read the package id after clearing the LEONIDA_PACKAGE_ID override.
- docs: one row per topic again in design.md (72 topics) and README.md; one Other languages line;
embedded_shaders.md keeps one copy of each bullet; animation.md links the heading anchor.
- tools/scripts: character_textures uses report_paths.same_report_path; stdout guard on six programs;
LF write in vs_input_survey; the cl.exe fallback compiles winhttp_offline.cpp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #1904 the corpus's deepest structured tree is 29, not 118. With the
SHADER-299 bound at 16, 1,031 modules (747 CS, 284 PS) still took the
dispatch-loop form, which saves only 12% of their spirv-val time but
compiles 1.67x (PS) to 2.0x (CS) slower on an RTX 5070 Ti / 621.24.
The bound now sits above the corpus as a guard, and
--max-structured-depth N (0 = never) sets it per run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ps_sdwa_f16_const read mrt0 lane y as 0x0000 instead of 0x1c00 on NVIDIA: the
_sdwa src0_sel:BYTE_1 selects the f16 denormal 0x0040 (2^-18), and the driver
flushed it on the way into f32 because the module declared no 16-bit denormal
mode. The translator models f16 arithmetic in f32 with integer narrowing, so no
f32 denormal is involved and that conversion is what the 16-bit mode governs.
Every module now also emits OpExecutionMode %main DenormPreserve 16 with the
matching capability (core since SPIR-V 1.4, so no extension), and the index
lists shaderDenormPreserveFloat16, which vk_pipeline_check requires and
--no-float-controls still drops along with the 32-bit mode.
Tested on an RTX 4070 SUPER (driver 610.88, validation layers on): the GPU test
goes from 4096/4096 mismatches to 4096/4096 pixels exact, and the full GPU suite
from 142/189 to 143/189 passed with 0 failures and the same 46 skips.
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
GS_OP_EMIT_CUT closes the strip after adding its last vertex. Treating it as a plain emit connects disjoint strips and rasterizes triangles across the gap.
- docs: one row per topic again in design.md (59 topics merged sentence by sentence, keeping every
number) and README.md (the current models/character rows); one Other languages line.
- docs/i18n: the two Spanish quickstarts had been concatenated; keep #1912's, drop #2277's row.
- make_game: the shader fingerprint covers spirv_asm.py and its tables; LF settings write.
- tools: pe_shader_containers, gamedata_maps and anim_rigs use report_paths.same_report_path (BUILD-589);
stdout guard on five tools; LF text writes in three; user_sgpr_census tolerates an unreachable --json.
- tests: fspx stage fakes write real carve/unpack indexes (c7408a1f); typed f16 stores round toward zero
(SHADER-358); test_ci_registration's helper is no longer collected as a test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>