Repository navigation
v0.22.7 — layout bounds, GLSL countLeadingZeros, DXIL view_index, honest CI and diagnostics
LatestA PATCH release: correctness fixes across the WGSL frontend, the shared layouter, the GLSL and DXIL backends, plus CI and diagnostics hygiene. No API changes, no new feature surface beyond one GLSL-input builtin; the GLSL frontend remains a preview.
Added
- The GLSL frontend accepts
textureSamplesand lowers it to the IR's sample-count query (card P2-GLSLIN-014). The builtin takes the multisampled sampler classes of GLSL 4.00 —sampler2DMSandsampler2DMSArray, in all three texel kinds — and becomesImageQueryNumSamples, converted to theintthe GLSL call returns, the query the WGSL frontend, the SPIR-V frontend and every backend already implement. The 2D multisampled array overload is injected when its argument asks for it, like Rust'sD2_MULTI_TEXTURES_ARRAYvariation. The GL 3.30 core and ES 3.00 dialects refuse the call at the version gate (GLSL 4.00 / ES 3.10), with glslang's verdict recorded in the dialect corpus.imageSamplesstays out of the frontend: it takes a multisampled storage image, a class the frontend does not model (image2DMSis not a type it parses, matching Rust naga's own refusal), so no argument could ever match such an overload.
Changed
- CI retries a run once when its jobs were starved at runner acquisition (the macOS arm64 capacity shortage of September–November 2026). The listener reruns the failed jobs only when every failed-or-cancelled job was cancelled at zero steps with no runner assigned, on the first attempt, with no newer run for the same commit; a real failure is never retried.
Fixed
-
GLSL below 4.00 / ES 3.10 gets
countLeadingZerosas Rust naga's log2 polyfill instead offindMSB(card P2-GLSL-005).findMSBexists only from desktop GLSL 4.00 and ES 3.10, so every shader that calledcountLeadingZerosproduced GLSL that no driver compiles at the backend's default target, GLSL 3.30. Below the integer-functions boundary the backend now emits Rust's polyfill operand for operand (31.0 - floor(log2(x + 0.5)), the negative-int short-circuit,mix(…, lessThan(x, 0))for the vector form); at and above it the built-in path is unchanged, andfirstLeadingBit/firstTrailingBitstay unconditional, as in Rust. glslang validates the emitted source at 330/ES 300/ES 310/400. -
@builtin(view_index)compiles and validates at shader model 6.1 on DXIL (card P2-DXIL-109). WithPSVRuntimeInfo1.UsesViewIDset, the PSV0 part must carry one output-dependence mask per non-empty output stream before the input-to-output tables, and the module'sdx.viewIdStatethe same mask — neither was written, so IDxcValidator rejected every such shader with "PSV0 part is not well-formed". The viewid analyzer now marks the outputs that depend on the ViewID input and feeds both tables from one result; the emitted container matches DXC's for the same shaders, masks and tables bit-identical. The ViewID feature bit and the PSV0 flag come from one shared predicate that also recognises the builtin arriving as a struct member of the entry input — that shape emitsdx.op.viewIDtoo, and without the flag the validator rejected the container with "Flags must match usage". -
Type sizes are bounded by Rust naga's
MAX_TYPE_SIZEwherever they are derived (card P2-WGSL-116). An array's size is its element count times the stride; computed in uint32,array<f32, 0x40000000>wrapped to a zero-size struct that compiled without an error, and an array of0x20000001elements exceeded the bound silently outside a struct. The sharedir.Layouternow computes sizes in 64-bit arithmetic and fails aboveir.MaxTypeSize(i32::MAX) following Rust'stry_size, with a struct's span bounded too; the WGSL frontend refuses oversized types where they are created ("type is too large", "struct member is too large" at the member's name), lays every finished module out once as a backstop, and the SPIR-V frontend lays each array out as it parses it. A lowering error now keeps its own source position instead of being re-anchored at the declaration. -
@sizeand@alignon a struct member are evaluated and validated instead of being silently dropped (card P1-WGSL-122). Only a bare decimal literal used to be read; a named constant, a constant expression or a hex literal was ignored, so the module compiled with a default layout, and invalid values (@align(3),@size(2)on anf32) were accepted with a wrong layout. The argument now goes through the same module-const evaluation as@group/@binding/@idand enforces the spec's rules with Rust naga's messages and the argument's span. -
Diagnostics come in a stable order across compiles (card P3-API-008): the WGSL lowerer collected the unused-variable warnings while ranging over a Go map, so their order changed between runs of the same compiler and a consumer's stderr-diff gate could not tell a real difference from noise.
wgsl.Parsenow sorts the warnings by source position, then message. -
A module-scope declaration is usable before its declaration through every syntax the dependency-order walkers read (issue #261): the walkers missed
bitcast's operand and target type,const_assertconditions in both scopes,binding_arrayelement and size, and constant-expression attribute arguments (@workgroup_size(N)with a laterconst N). A function that used a later declaration through any of them failed with "unresolved identifier" or an unknown type. An exhaustiveness test now carries one node of every expression, type, statement and declaration kind, so a future AST node a walker misses fails the test instead of shipping an ordering hole.
Install
go get github.com/gogpu/naga@v0.22.7Full changelog: https://github.com/gogpu/naga/blob/main/CHANGELOG.md · Compare: v0.22.6...v0.22.7