Skip to content

CrossTL 3.6.0

Choose a tag to compare

@NripeshN NripeshN released this 09 Nov 12:31
· 228 commits to main since this release
230283a

This page lists every breaking change, addition and improvement in 3.6.0 and 142 of its 184 fixes; GitHub limits release notes to 125,000 characters. The complete list of all 238 entries is in CHANGELOG.md.

Breaking Changes

  • WGSL output refuses a function-local array whose size is a constant computed from a specialization constant that CrossGL declares as a module-scope variable, such as float tmp[doubled]; with constant int count @constant_id(3) = 4; and constant int doubled = count * 2;, which is how the Metal importer writes an MSL [[function_constant]], with SpecializationConstantError (project.translate.specialization-constant-unsupported), because WGSL takes an override expression as an element count only for a var<workgroup> array. It used to size the array by the constant's default, ignoring the value the host specializes.
  • The CrossGL parser refuses a token it cannot place with a SyntaxError that names the token and the construct, at program, shader, stage, structure, member, enumeration, trait and switch scope and where an expression is expected: struct S { float a junk; float b; };, float v = ; and a structure cut off at the end of the input are refused. It used to skip such tokens one at a time, so S lost b, v took the value ; and the cut-off structure vanished from every target's output, and it truncated a program of more than 10,000 top-level declarations with a printed warning. Empty declarations (;) and struct S; forward declarations are still accepted. The Rust importer now writes type Name = T; as typedef T Name;, which the parser used to skip, and the Slang importer refuses extern static const and StructuredBuffer<T*> with SlangImportRefused (project.translate.slang-import-unsupported).
  • The CrossGL parser refuses a malformed generic<...> structure, enumeration, function or trait declaration, one without its <, cut off at the end of the input or with no declaration after its parameters, with SyntaxError. It used to skip the whole declaration, so it vanished from the program and from every target's output.
  • The Metal, HLSL and Vulkan GLSL importers refuse a statement or expression they have no CrossGL form for, with MetalImportRefused (project.translate.metal-import-unsupported), DirectXImportRefused (project.translate.directx-import-unsupported) and SpirvStatementUnsupportedError (project.translate.spirv-statement-unsupported or project.translate.spirv-expression-unsupported). They used to write // Unhandled statement type: ... or /* Unhandled expression */ in its place, which dropped the statement from every target's output, and the Vulkan GLSL importer's expression fallback printed the Python form of the node.
  • CrossGL reads static_assert(condition) and static_assert(condition, "message") at shader, stage and structure scope and as a statement, and checks it for every target after sizeof is folded: a true condition is removed, a false one is refused with StaticAssertionFailedError (project.translate.static-assertion-failed), and one the translator cannot evaluate is refused with StaticAssertionUnresolvedError (project.translate.static-assertion-unresolved). A condition may use integer literals, integer const declarations, enumerators, folded sizeof, arithmetic, bitwise, shift, comparison and logical operators, !, ?: and integer and bool conversions, on values from 0 to 2^31 - 1. A shader-scope assertion used to be skipped unchecked, so a program its source compiler rejects translated, and one in a function body became a call to an undeclared static_assert function.
  • HLSL and Slang input import SV_VertexID as the CrossGL built-in gl_RelativeVertexID, which, like Direct3D's value, leaves out the draw's base vertex. HLSL and Slang output write it back as SV_VertexID; GLSL, SPIR-V and Metal output, whose vertex index includes the base vertex, read it as gl_VertexIndex - gl_BaseVertex, and the entry point takes the base vertex as a parameter, reusing one that already carries it. OpenGL's gl_BaseVertex is zero for glDrawArrays, so GLSL output still reads first more in a non-indexed draw that starts at vertex first. WGSL and WebGL output, which cannot read the base vertex, refuse it with RelativeVertexIdUnsupportedError (project.translate.relative-vertex-id-unsupported), and so does every target for a member of a nested structure that carries it. source_options={"zero_base_vertex": True} keeps the old import for a shader whose draws all have a zero base vertex. SV_VertexID used to import as gl_VertexID, so GLSL, SPIR-V and Metal output read the vertex BaseVertex positions further on in a draw with a non-zero base vertex, and WGSL and WebGL output translated it the same way (#3894).
  • HLSL output refuses a volatile resource, such as a GLSL volatile buffer, a SPIR-V Volatile block or a Metal volatile device T* buffer, and a resource coherent at system scope, such as Metal's coherent(system), with DirectXLoweringRefused (project.translate.directx-lowering-unsupported); SPIR-V output refuses coherent(system) and coherent(host) with SpirvLoweringRefused (project.translate.vulkan-lowering-unsupported). HLSL has no volatile resource (DXC rejects volatile on a global) and globallycoherent neither reaches past the device nor stops DXC from merging repeated accesses, and Vulkan's Coherent reaches the device at most. Both used to drop the qualifier and declare an ordinary resource, so a spin-wait on a flag could compile to an infinite loop (#3902).
  • HLSL output refuses a call that passes two private pointer views of one local array, at least one of them writable, such as two(x, x + 1) for a Metal void two(thread float* a, thread float* b), with DirectXPrivatePointerParameterError (project.translate.directx-private-pointer-unsupported, reason aliased-view-backing), as GLSL output already does. Views rooted at one caller parameter are refused the same way, and a call whose views of one array are all read-only still translates. HLSL output passes each view as an inout copy of the array, so it used to emit two independent copies, which DXC accepts: the copy written back last overwrote the other view's writes, and a read-only view did not see writes made through the other (#3827).
  • Output refuses a specialization constant it cannot keep specializable, where it used to freeze the constant at its default value. WGSL output refuses, with SpecializationConstantError (project.translate.specialization-constant-unsupported), a specialization constant that is not a bool, i32, u32, f32 or f16 scalar, an id above 65535, an array sized by one other than a var<workgroup> array, and a switch case selector that reads one; Slang output refuses, with the same error, an array sized by a dependent constant it declares as a static global and a case label that reads one; both refuse two constants with one id and a malformed id. Metal output refuses a specialization constant whose type has no function constant form, such as a double, with MetalLoweringRefused; it used to lower a double one to float. HLSL output refuses a compute workgroup size set through local_size_x_id, local_size_y_id or local_size_z_id with SpecializedWorkgroupSizeError (project.translate.workgroup-size-specialization-unsupported), since numthreads takes literals and Direct3D has no specialization constants; it used to write the default size (#3776, #3778, #3795, #3835).

Added

  • HLSL output of a compute, mesh or amplification entry whose result depends on a threadgroup size that the source's host chooses at dispatch time, such as a Metal kernel with threadgroup memory and no threadgroup_size source option, reads the size from the CROSSGL_WORKGROUP_SIZE_X, _Y and _Z macros, which the host defines when it compiles the shader (dxc -D CROSSGL_WORKGROUP_SIZE_X=64 ...), as GLSL output does without SPIR-V specialization: [numthreads(CROSSGL_WORKGROUP_SIZE_X, CROSSGL_WORKGROUP_SIZE_Y, CROSSGL_WORKGROUP_SIZE_Z)], behind an #error that names the macros when they are missing. gl_WorkGroupSize and [[threads_per_threadgroup]] read the same macros, and host reflection reports the entry's host_workgroup_size with the macros and no size. Such an entry used to be refused with HostDefinedWorkgroupSizeError, which Slang output still raises.
  • A CrossGL function marked @explicit_specialization(primary, types), such as uint8 bump_u8(uint8 x) @explicit_specialization(bump, uint8) { return x + 2; }, replaces the body of the generic bump for T = uint8, as a C++ template <> uint8_t bump<uint8_t>(uint8_t) does. HLSL, GLSL, Metal, SPIR-V, CUDA, HIP, Slang, Mojo and WGSL output call it for every matching instantiation, including one reached only through another generic function and a call on a narrow storage load such as bump(buffer_load(p, id)) for a RWStructuredBuffer<uint8> p. Rust output, which keeps native generics, refuses such a program with RustLoweringRefused, and a malformed attribute is a SyntaxError. The Metal importer marks each explicit specialization it imports for the CrossGL and Metal targets this way, so apply<T> calling twice(x) runs the twice<float> specialization. Metal output, and every target given the imported CrossGL, used to call a copy of the primary template's body, such as twice_float, instead.
  • HLSL output reads a specialization constant that has no default, such as an MSL [[function_constant]] declared without a value, from a CROSSGL_SPECIALIZE_<name> macro that the host defines when it compiles the shader (dxc -D CROSSGL_SPECIALIZE_forward=1), the macro GLSL output already uses: static const bool forward = (bool)(CROSSGL_SPECIALIZE_forward);, after an #error that stops compilation when the macro is missing. Host reflection lists such a constant in specializationConstants with kind: preprocessor-macro, required: true and its macro. HLSL output used to refuse it with DirectXSpecializationConstantError (missing-required-value).
  • Slang output of a compute, mesh or amplification entry whose threadgroup size the source's host chooses at dispatch time, such as a Metal kernel with threadgroup memory and no threadgroup_size source option, writes [numthreads(CROSSGL_WORKGROUP_SIZE_X, CROSSGL_WORKGROUP_SIZE_Y, CROSSGL_WORKGROUP_SIZE_Z)] when the host defines those macros (slangc -D CROSSGL_WORKGROUP_SIZE_X=64 ...), as HLSL output does, and otherwise names three [vk::constant_id(N)] constants with the ids GLSL and SPIR-V output use, so a SPIR-V pipeline sets the size through LocalSizeId. A gl_WorkGroupSize entry parameter reads WorkgroupSize(). Slang output used to refuse such an entry with HostDefinedWorkgroupSizeError (project.translate.workgroup-size-host-defined). Specialized workgroup sizes are declared once per module; a module with two such entries used to declare the constants twice, which slangc rejects as an ambiguous reference.
  • SPIR-V, GLSL and WGSL output translate a compute, mesh or task entry whose threadgroup size the host chooses at dispatch time, such as a Metal kernel that reads threads_per_threadgroup or sizes a threadgroup tile by it. SPIR-V output declares the size as three specialization constants whose ids no other specialization constant of the program uses; GLSL output declares layout(local_size_x_id = N, ...) under GL_SPIRV or VULKAN and otherwise reads the CROSSGL_WORKGROUP_SIZE_X, _Y and _Z macros, as HLSL output does; WGSL output declares @id(N) override crossgl_workgroup_size_x: u32; and its _y and _z companions. They used to refuse such entries with project.translate.workgroup-size-host-defined. SPIR-V output also gives each entry point of a module its own workgroup size, with LocalSize, or LocalSizeId when the size is specialized, and refuses a helper that reads gl_WorkGroupSize and is shared by entries of different sizes.
  • SPIR-V output translates ++, -- and += on a buffer element, a structure member, a vector component or a shared array element, and in a loop condition, through the wrapping step helpers the other targets use, so the result wraps at INT_MAX and INT_MIN. SPIR-V output used to refuse these programs.
  • GLSL and Metal output lower RWByteAddressBuffer.InterlockedMin and InterlockedMax with an int value, which compare as signed integers, to a compare-exchange loop on the buffer's uint word: a word that already holds the value is left unchanged, and the original value converts into an int, uint or float receiver as the signed overload's out int does. The call must be a statement, an assignment statement or a declaration directly in a block; one inside a larger expression, including a for initializer, and a value that is neither int nor uint are refused.
  • The HLSL, Metal, CUDA, HIP, OpenCL and Slang preprocessors define Clang's __COUNTER__, __INCLUDE_LEVEL__, __BASE_FILE__ and, except for HLSL, __FILE_NAME__, count built-in macros as defined for #ifdef and defined, evaluate __has_include and __has_include_next in #if and #elif, turn _Pragma("...") into a #pragma line, accept the null directive and %: for #, and read a function-like macro invocation whose arguments continue on later lines or whose ( starts the next line, and a block comment spanning lines. __LINE__ is the line where the outermost invocation ends, counting backslash-spliced lines, as in Clang. __DATE__, __TIME__ and __TIMESTAMP__ are refused with PreprocessorError (project.translate.preprocessor-unsupported-builtin), because they would make the output depend on the time of the build.
  • A static_assert in a generic structure whose condition depends on the structure's type parameters, such as static_assert(sizeof(in_T) <= 16) in a Metal template structure, is not evaluated against the template itself: it is dropped when no live code names the template, checked with the arguments substituted in each specialization the Metal importer writes, and refused with StaticAssertionUnresolvedError (project.translate.static-assertion-unresolved) when live code names the CrossGL generic structure. A condition that names none of the parameters is still evaluated.
  • GLSL and Metal output lower HLSL ByteAddressBuffer and RWByteAddressBuffer to uint storage buffers: every load, store, size query and Interlocked* member indexes 32-bit words at address >> 2, and the HLSL importer reads Load<T> and Store<T> as bit-cast word accesses. Rasterizer-ordered byte-address buffers, a byte-address buffer inside a structure and a multi-word operand with side effects are refused with a typed diagnostic. Both outputs used to copy RWByteAddressBuffer and the importer's buffer_load* and buffer_store calls, which neither compiler accepts; the importer also dropped the template argument of Load<T> and Store<T>, and byte-address atomics were rewritten as if their value were the original-value argument.
  • SPIR-V output lowers CrossGL atomicLoad and atomicStore to relaxed OpAtomicLoad and OpAtomicStore, at Device scope on storage buffers and Workgroup scope on workgroup memory, and HLSL output lowers atomicLoad of a byte-address buffer member. SPIR-V output used to refuse both calls as neither a declared function nor a built-in with a SPIR-V lowering, and HLSL output refused the byte-address load.
  • The GLSL importer reads GL_KHR_memory_scope_semantics atomics, such as atomicAdd(mem, data, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed), atomicCompSwap with its two semantics pairs, atomicLoad, atomicStore and imageAtomic*, as CrossGL's relaxed atomics when every semantics operand is gl_SemanticsRelaxed and the scope is no wider than gl_ScopeDevice. Acquire, release and acquire-release semantics, MakeAvailable, MakeVisible, Volatile, gl_ScopeCrossDevice, non-constant operands, imageAtomicLoad and imageAtomicStore are refused with ScopedAtomicUnsupportedError (project.translate.opengl-import-scoped-atomic-unsupported), and Metal output refuses a buffer-block atomic with extra operands. The operands used to be passed through: OpenGL and HLSL output refused the call's argument count, SPIR-V output reported gl_ScopeDevice as an unknown variable and Metal output dropped them.
  • Metal output accepts an array sized by a specialization constant, directly or through other constants. A uniform or storage block member is laid out from the constant's default size, as GL_KHR_vulkan_glsl lays out such a block, and any other array, such as a shared array, takes its size from a CROSSGL_SPECIALIZATION_CONSTANT_ID_<id> macro that defaults to the declared value and that the host sets through MTLCompileOptions.preprocessorMacros or -D. Metal host reflection lists such a constant with kind preprocessor-macro, its id, macro name and default. On every target, the length() of an array sized by constants is its size expression, int(N), so it follows a specialized value; where a local, parameter or member hides a name of that expression at the call, it is refused with ArrayLengthUnresolvedError. Metal output used to refuse these arrays; 3.5.0 froze the constant at its default.
  • A geometry stage that writes several vertex streams translates between GLSL, HLSL and SPIR-V. HLSL input numbers its PointStream parameters in order, as DXC does, and GLSL output declares stream k's outputs layout(stream = k) and writes Append() and RestartStrip() on it as EmitStreamVertex(k) and EndStreamPrimitive(k), with the built-in outputs and the locations the next stage reads on stream 0. HLSL output gives each GLSL stream N, from @stream(N) outputs or EmitStreamVertex(N), its own GeometryOutputN structure and inout PointStream<GeometryOutputN> streamN parameter, with EmitVertex() and EndPrimitive() on stream 0. SPIR-V output writes OpEmitStreamVertex and OpEndStreamPrimitive with the GeometryStreams capability and a Stream decoration on every output, and SPIR-V input imports them with @stream(N). Several streams whose output primitive is not points, a built-in output on a stream other than 0, more than four streams and a stream number that is not a constant are refused, with GeometryStreamUnsupportedError in GLSL output and HlslGeometryStreamUnsupportedError (project.translate.hlsl-geometry-stream-unsupported) in HLSL output. HLSL output used to refuse a second stream with HlslGeometryStreamUnsupportedError, GLSL output refused several PointStream parameters, and SPIR-V output and input refused EmitStreamVertex. GLSL input also puts an output declared after layout(stream = N) out; on stream N; it used to put it on stream 0 (#3853).
  • A compute stage's local_size_x_id, local_size_y_id and local_size_z_id, as in layout(local_size_x_id = 0, local_size_x = 64) in;, make that workgroup dimension a specialization constant in SPIR-V, GLSL, Slang and WGSL output: SPIR-V output builds BuiltIn WorkgroupSize as an OpSpecConstantComposite of SpecId-decorated dimensions, GLSL output keeps the ids under its SPIR-V guard, Slang output sizes numthreads with vk::constant_id constants and reads gl_WorkGroupSize as WorkgroupSize(), and WGSL output sizes the entry point with override declarations. A duplicate, non-literal or out-of-range id is refused with SpecializedWorkgroupSizeError (project.translate.workgroup-size-specialization-unsupported). The ids used to be dropped, so every target fixed the size at its default and the pipeline's specialization never reached the dispatch (#3835, #3793, #3788, #3791).
  • CrossGL has cooperative_matrix_diagonal(value), a cooperative matrix with value on its diagonal and zero elsewhere, whose shape comes from the declaration, assignment or return it initializes, as for a fill; a one-argument CooperativeMatrix<...>(value) constructor means the same, as mat3(s) does, and another number of arguments is a SyntaxError. Metal input reads simdgroup_matrix<T, Cols, Rows>(value) and the simdgroup_float8x8(value) style spellings as it and Metal output writes it back; GLSL and HLSL output lower it for a registered lane mapping, evaluating value once, and SPIR-V and the other targets refuse it with their cooperative-matrix errors. Metal input used to turn the constructor into a call to an undefined function, and a one-argument CooperativeMatrix<...>(value) was copied unchanged into the output.
  • A cooperative matrix multiply-accumulate takes independent component types for A, B and the accumulator, as Metal's simdgroup_multiply_accumulate(d, a, b, c) and SPIR-V's OpCooperativeMatrixMulAddKHR do, so a kernel with half inputs and a float accumulator translates; the result takes the accumulator's component type, or the destination's when there is one. A plain multiply still needs one component type. The type checker used to refuse such a kernel on every target, Metal to Metal included.
  • Metal input gives a simdgroup_matrix that a kernel only loads, fills, multiplies and stores, with no thread_elements() view, the lane mapping the caller configures for the 32-lane SIMD-group, so GLSL and HLSL output lower the kernel. Such a matrix used to keep an unspecified lane contract, and GLSL and HLSL output refused the kernel even with a mapping configured. A matrix whose contract comes from a view keeps it, and symbolic or unregistered shapes are still refused.

Improved

  • WGSL output passes an array element, a structure member, a vector component or swizzle, a storage buffer element or a module-scope variable to an inout or out parameter by copying it into a function-scope temporary before the call and storing it back after the call in parameter order, as GLSL does. An earlier argument that calls a function is bound to a let first, an index the call could change is evaluated once, and a while or for condition with such a call becomes a loop guard. A call in the right operand of && or ||, a ternary branch, a for update or a do-while condition, where that order cannot be kept, is refused, and so is a uniform, constant or constant-buffer member passed this way, which WGSL cannot store to. These arguments used to be refused, because a WGSL ptr<function, T> parameter can only point at a whole variable.
  • The Metal importer evaluates is_scalar, is_vector and is_arithmetic and their _v forms in a constraint, directly or through a variable template such as PyTorch's is_scalar_integral_v<T> = is_integral_v<T> && is_scalar_v<T>, as metal_type_traits defines them, and expands a namespace-scope alias template in a type-trait operand, so metal::is_same_v<StrY, Int<1>> with template <int val> using Int = integral_constant<int, val>; is decided. The first used to be refused as an unrecognized SFINAE constraint and the second with MetalTypeTraitError.
  • The Metal importer ranks an enabled constrained template whose substituted parameters are exactly the argument types above a competing non-template overload that needs a conversion, as C++ does: PyTorch's simd_sum(T) beside float2 simd_sum(float2), called with a float, calls the template. Such a call used to be refused because the competing overload had unproven precedence.
  • The Metal importer decides more static_assert conditions: ones over qualified namespace constants such as ::c10::metal::simdgroup_size, integral static_cast<T>(v) and T(v) casts, constexpr auto locals and structure members declared in one list such as uint32_t m, n, k;, and, for the Metal and CrossGL targets as for the others, ones over constexpr aggregates such as static_assert((complex_t<half>{1.0h, 2.0h} * complex_t<half>{3.0h, 4.0h}).real == -5.0h) in MLX's complex.h. A condition that holds is removed and one that fails is refused with MetalStaticAssertionError (assertion-failed). They used to be refused as unresolved, so every Metal or CrossGL translation of a kernel that includes complex.h failed with StaticAssertionUnresolvedError. A structure head with alignas(...), [[...]] or __attribute__((...)) is read as the structure it declares; it used to be scanned as a structure named alignas.
  • The Metal importer types each subscript of a multidimensional array local or parameter, so shmem[0][tid.x] of T shmem[N][M] is a T, and types the metal:: and ::metal:: spellings of the SIMD-group built-ins as it types the unqualified ones. A constrained call with such an argument, such as OP::finalize(shmem[0][tid.x], param), used to be refused, because shmem[0] was typed as a T and shmem[0][tid.x] was left untyped.
  • The Metal importer binds a constrained call in an inline helper that no kernel calls to the template C++ selects, and binds a constrained call whose argument types are known only once another call is bound, as in auto a = larger(x, 1.0f); halve(a);. The first used to be left to code generation, whose only remaining candidate could be an explicit specialization for another type, and the second was refused.
  • The Metal importer inlines more structure members that return a reference into the structure's storage: an accessor beside an overload that takes an extra tag argument, such as T& frag_at(short i, short j) beside template <bool B> T& frag_at(short i, short j, metal::bool_constant<B>), a member template called with integer constants, such as frag_at<0, 1>(), and an accessor that forwards to another, such as thread T& at_t(short i, short j) thread { return at(j, i); }, through chains up to eight deep. They used to be refused with MetalStructMethodError (reference-return-identity-unsupported).
  • The Metal importer declares each concrete metal::bool_constant<B>, metal::integral_constant<T, v>, metal::true_type and metal::false_type that a source uses as a type as a structure with the same static constexpr value, such as metal_integral_constant_bool_true, so pick(src, metal::bool_constant<true>{}) for template <bool B> float pick(..., metal::bool_constant<B>) translates, and gives a const auto or constexpr auto local its initializer's type. Such a tag used to become the undeclared type bool_constant<true_>, which every target refused.
  • The Metal importer resolves a member type named through an alias of its owner structure, such as kern::acc_type or typename kern::acc_type with using kern = KH;, in a declaration, in a type-trait operand of a lowered structure method such as metal::is_same_v<scalar_T, float>, and in a materialized helper, where typename IOTraits_float2_float2::scalar_T(0) names the alias's target. It used to write the bare, undeclared acc_type, refuse the trait with MetalTypeTraitError (operand-unresolved), and keep a functional cast that the Metal parser rejects.
  • Metal output writes a conditional array extent, such as threadgroup float scratch[size == 0 ? 1 : size];, as HLSL and GLSL output do. It used to print the expression's AST node and refuse the program with GeneratedAstTextError.
  • The Metal importer deduces the template arguments that an explicit argument list leaves out from the call's arguments before applying defaults, as C++ does, for the Metal and CrossGL targets as for the others: offset<false>(ptr, n) for template <bool scaled, typename T> void offset(const device T*& p, int n) binds T from ptr. Two arguments that deduce different types are refused with MetalTemplateArgumentResolutionError. Such a call used to be refused because T was not supplied.
  • Project translation of a Metal source for HLSL, GLSL and the other targets without templates deduces the template arguments of a call in a materialized template through a unary sign, a predefined Metal constant or a one-argument math function, as in erf(-x), exp(-x) and x * M_SQRT1_2_F, and no longer splits x * -y at the sign. Such programs, such as candle's unary.metal, used to be refused for a missing template argument.
  • The Metal importer reads a function template whose result type is a decltype of its parameters, written directly, as a trailing return type such as auto f(T a) -> decltype(a + a), or through an alias template such as template <class T> using sum_t = decltype(T{} + T{});, and types each call, and an auto local initialized from one, from the concrete operand types with the usual promotions. Such a definition used to be dropped, leaving calls to an undefined function, and auto b = f(x) was declared as decltype(x + x). A CrossGL generic function whose result type is still a decltype when it is specialized is refused with GenericResultTypeError (project.translate.generic-result-type-unresolved).
  • The Metal importer binds a call to a user function template named like a Metal SIMD-group or quad function, such as a simd_shuffle_down(IndexValPair<U>, ...) overload in MLX's arg_reduce.metal, to the instantiation C++ selects, and refuses a call whose scalar or vector arguments the built-in also accepts, which the Metal compiler reports as ambiguous. Such a template used to shadow the built-in, so its own call to the built-in recursed into itself and was refused with RecursionUnsupportedError.
  • The Metal importer drops a family of enable_if-constrained function templates that no call, address-of or explicit specialization names, such as pow(T, U) overloads selected by is_complex_v<T>. It used to import them as duplicate generic CrossGL functions with one signature, which no target accepts and which stopped the typing of the functions after them, so MLX's gated_delta_update_vjp.metal was refused with MetalAddressProvenanceError.
  • The Metal importer keeps a subscript of a value whose type is a template parameter, such as reg[i] for thread T& reg, m[i / 4][i % 4] or x4[i][k] for device const T04* x4, in the generic CrossGL function, and each target types it once T is substituted. It used to refuse it as an aggregate subscript, as it still does when the structure declares its own operator[].
  • Metal output proves the address space of a storage pointer view taken of another view, such as (device const T*)((device const char*)src + off), follows a view's constness through pointer arithmetic, and writes a view that removes const from read-only storage as a const view when every use only reads through it. Such views used to be refused with PointerReinterpretationError, as in seven ggml kernels.
  • Slang output lowers WaveShuffleDown, WaveShuffleUp, WaveShuffleXor and WaveShuffleAndFillUp, which Metal simd_shuffle_down, simd_shuffle_up, simd_shuffle_xor and simd_shuffle_and_fill_up import as, to one helper per operation and type that reads WaveReadLaneAt once with every lane active; a source lane outside the SIMD-group reads the calling lane, as MSL documents. @gl_SubgroupInvocationID and @gl_SubgroupSize entry parameters, from MSL thread_index_in_simdgroup and threads_per_simdgroup, are read from WaveGetLaneIndex() and WaveGetLaneCount(). Both used to be refused, which stopped every Metal kernel whose headers define shuffle overloads, such as MLX's utils.h.
  • The Metal importer types more arguments of a call to a constrained function template or overload set, so it selects the overload instead of refusing the call because one or more call argument types could not be inferred: a swizzle of a subscript, call, member access or parenthesized expression, as in max(m, partials[i].x), load(p).yz or (a * b).w; a call of a source function whose declarations all state one concrete return type, as in cast_to<float>(linspace_value(i, v, p[0])); a conditional, as in cast_to<float>(u < p ? 1u : 0u); a unary - or +, as in max(0, -padL); and arithmetic on two different scalar or vector types, typed as the Metal compiler types it, so half4 * float is half4 and int + 1.0 is float. It used to type half * 1.5 as half where Metal gives float, which could select the wrong overload.
  • The Metal importer selects a function template by an enable_if_t<B, T> or typename enable_if<B, T>::type return type, with or without metal::, as it does by an enable_if_t template parameter, takes a namespace-scope template<> specialization as the body of its template instead of a competing overload, and writes an enabler left in concrete code as the type it names, so enable_if_t<true, float> is float. An enabler whose condition is false or not constant is refused with MetalTypeTraitError (project.translate.metal-type-trait-unresolved). A source that declares its own enable_if keeps its meaning. Calls that chose between such overloads used to stop the import.
  • Metal import of sources with many template instantiations or many reopened namespace blocks is faster: the importer finds the declaration a receiver.method(...) call sees with one sweep over the call sites instead of a scan per call, and computes a refused call's source location only when it refuses it. A large reduction kernel from the Metal corpus imports in 386 s instead of 461 s, and PyTorch MPS BinaryKernel.metal, which reopens c10::metal about 500 times, in 62 s instead of 71.5 s.
  • The Metal importer reads more of the template-heavy MSL in MLX, PyTorch and ggml kernels: adjacent string literals join into one, as in static_assert(c, "a" "b"); function-pointer template parameters, such as void (*load)(device const T *, short, thread U &), bind by name, so explicit template arguments no longer shift by one; matrix types and structures declared through typedef struct { ... } name; are operands of is_same and the other folded traits; a free operator used in a static_assert outside a template is instantiated; a math built-in applied to a member of a value whose type is a template parameter, as in metal::abs(y.x), takes a dependent result type; auto, auto* and const auto* locals initialized from reinterpret_cast<P>(e) or (P)e give template argument deduction the pointer type P; a union declared in a function body is hoisted with the layout metadata of a program-scope union; an unnamed structure or union with declarators, such as union { uint i; half t[2]; } val;, is named __crossgl_unnamed_<kind>_<n>; integral constexpr auto locals can size arrays; sizeof of a concrete structure, alias or class template specialization folds; and S a, b, c; declares three variables. Such sources used to stop with MetalParserError (Expected RPAREN, got STRING, Expected union name), MetalTemplateSpecializationError, MetalSourceOverloadResolutionError, MetalBuiltinResultTypeResolutionError or MetalSourceMaterializationError (missing T).
  • Translating large Metal sources is faster: AST walks classify values from a per-type table and use an explicit stack, the Metal preprocessor finds a name's declaration by bisection and a local integral constant's binding with one sweep, free-operator candidates come from a cached list, and template materialization looks up structure specializations by their normalized template-id. MLX's unary.metal to GLSL takes 81 s of CPU instead of 102 s, and steel_conv.metal to HLSL 199 s instead of 234 s.
  • Refusals that depend only on a program's entry stages or workgroup sizes come earlier. For a program with more than one entry and no selected entry_point, HLSL, Slang, GLSL, SPIR-V and WGSL output refuse a kernel whose workgroup size only the host chooses with HostDefinedWorkgroupSizeError (project.translate.workgroup-size-host-defined) right after the CrossGL parse, before the semantics passes and the other kernels' code, and WebGL output refuses a source with no vertex or fragment entry with StageUnsupportedError before importing it, so before the Metal importer materializes templates. candle's gemv.metal to HLSL is refused after 19.9 s of CPU instead of 71.1 s, and MLX's steel_conv.metal to WebGL after 0.69 s instead of more than 90 s.
  • OpenGL output proves more storage subscripts in range: a guarded subscript through a rebased storage pointer whose base may lie before the buffer, as in a helper passed in + size - offset - N, is bounded from the helper's guards, and a subscript such as in[y * stride + i] is bounded through affine relations between locals, as after uint c = y; y = uint(n - 1 - y); with a guard on c. Such subscripts, as in MLX's reverse scans, used to be refused with project.translate.opengl-index-type-unsupported (composed pointer index range unproven).
  • HLSL and GLSL output lower dynamically indexed bfloat and bool lane arrays that share a 32-bit union word, such as MLX's uint_or_packed<T> atomic helpers for bfloat16 and bool scatter, as they lower 8- and 16-bit integer and half lanes. HLSL output keeps a bfloat lane's 16-bit pattern; GLSL output holds it as a float, so a store rounds to nearest even and quiets a NaN, keeping its sign. A bool lane stores one byte, 0 or 1, and reads back as != 0. They used to be refused.
  • Importing large template-heavy Metal modules is faster: struct-scoped alias rules reuse cached regular expressions and are built only for the aliases the source spells, the built-in input and mesh payload passes index each function body once instead of once per entry point, a comparison such as i < n no longer sends the template-argument search to the end of the module, and fragment and whole-module source analyses are cached apart. A sort module that took 452 s to import takes 94 s, and materializing a constrained partial structure for 8 specializations in a 17 KB module takes 0.40 s instead of 1.21 s. Output is unchanged.

Fixed

  • WGSL output types buffer_load(b, i) and b.Load(i) as b[i], so a generic call such as bump(buffer_load(b, i)) is specialized, converts the value that buffer_store and .Store write to the buffer's element type, as an assignment does, and declares an 8- or 16-bit integer storage element, as in RWStructuredBuffer<uint8> or Metal device uchar*, as one 32-bit word, array<u32>, as SPIR-V output does. A generic function instantiated for an 8- or 16-bit type argument without an explicit specialization is refused with NarrowIntegerUnsupportedError (project.translate.wgsl-narrow-integer-unsupported). The generic call used to be refused because its type argument could not be inferred, and WGSL output stored an i32 into an array<u32>, declared the buffer as array<uint8> and wrote fn bump_uint8(x: uint8), which naga rejects.
  • HLSL, GLSL and SPIR-V output of a Metal source select an explicit specialization by type, whichever spelling of an integer scalar the specialization and the call use: bump(x) for a uchar x runs template <> uint8_t bump<uint8_t>(uint8_t), and ushort and uint16_t, and uint and uint32_t, match the same way. They used to give the call a helper with a copy of the primary template's body, which computed a different result.
  • GLSL output writes a 64-bit integer literal that initializes a 32-bit integer, such as 2654435761 in uint[3](1, 2654435761, 805459861) or uint x = 3674653429; from a C or Metal source, with the type it initializes when the value fits: 2654435761u. It used to write 2654435761l, which glslang rejects because GLSL has no implicit int64_t to uint conversion. A literal inside a larger expression, or one that initializes a 64-bit integer, keeps its type.
  • Metal output passes an argument to a device, threadgroup or constant reference parameter, such as a Metal device float& v or CrossGL inout device float v, in place. It used to copy the argument into a thread temporary and store it back after the call, which the Metal compiler rejects with cannot bind reference in default address space to object in address space 'device'.
  • The Metal importer declares const auto p = data + i; for a device float* data as device float* p, because the const qualifies the local pointer, not the storage it points to, so a store through p translates. It used to declare const device float* p, so Metal output refused the store as one through a const-qualified local alias and other compilers rejected it. A const auto* local and a pointer into const or constant storage keep their const.
  • The Metal importer calls a Metal library function where C++ overload resolution selects it over a source function of the same name: after using metal::max; beside a source bfloat max(bfloat, bfloat), max(h0, h1) on half values calls the library max, and after using namespace metal; an exact library overload is preferred to an enabled user template, so max(x, 1.0f) on a float x calls metal::max beside a float-only max template. It used to bind the source function in both cases, which on every target converted the half operands to bfloat in the first and ran the template's body in the second. A constrained call in the body of an unconstrained template is bound when that template is instantiated, a call whose constrained candidates are all disabled and whose library function lookup cannot see is refused instead of calling the library function, and return ::max(...) is no longer written as return::max(...).
  • Metal output places the [[id(n)]] of an argument buffer's array member after the member's name, as in device float* params [[id(0)]][4];. It used to write device float* params[4] [[id(0)]];, which the Metal compiler rejects with 'id' attribute cannot be applied to types.
  • HLSL output types a predefined Metal constant that no local shadows, such as M_SQRT1_2_F, as its own scalar type, so x * M_SQRT1_2_F for a float16 x is a float product. It used to give the product the type of x and pass it through the binary16 widening helper, which DXC rejects.
  • HLSL, GLSL and the other targets without templates drop an explicit specialization of a Metal function template, such as template <> void f<float>(...), that nothing names once project translation has made a concrete copy of every call and removed the primary template. It used to stay in the output as a separate function, such as f_u3cfloat_u3e, whose body called the removed generic helpers by their template names, which DXC rejects, as in MLX's gated_delta_update_vjp.metal.
  • The Metal importer applies a structure's converting constructor wherever C++ copy-initializes an object of that structure from a value of another type, not only in a declaration or a return: in an assignment such as c = v or *p = v, a stored buffer element such as out[i] = v or out[i] = inv ? float2(x, -y) : v, and a value or const reference argument of a user function, structure method or overloaded operator, and a call whose only candidate needs such a conversion binds to it. The value used to reach every target unconverted, so, for example, DXC rejected MLX's fft.metal. An assignment that would run the structure's own operator= instead is refused with MetalAssignmentOperatorError (project.translate.metal-assignment-operator-unrepresentable).
  • The Metal importer resolves a member alias of a structure template through the most specialized matching partial specialization, so typename tr<device half*>::type uses template <typename T> struct tr<device T*>. It used to read the primary template's alias, such as float for a primary using type = float;, on every target. A choice it cannot decide where the type is named, such as a partial specialization constrained with enable_if_t or two matches neither of which is more specialized, is refused with MetalStructAliasResolutionError.
  • The Metal importer binds a device const T* buffer that a function stores through after casting const away as a writable buffer, a RWStructuredBuffer in HLSL output, converts the result of an atomic such as atomic_fetch_add_explicit on an atomic_int when it initializes or is stored into another integer type, as in uint x = atomic_fetch_add_explicit(...), and imports a C compound literal such as (float4x4){c0, c1, c2, c3} or (Pair){1.5f, 2} as a braced initialization. It used to bind such a buffer as a read-only StructuredBuffer, to refuse the atomic result with an untyped ValueError, and to write the compound literal as a constructor call with an initializer-list argument that no generator can lower. HLSL output keeps a buffer's view through a pointer cast that only removes const, and refuses a storage pointer alias it cannot lower with DirectXResourcePointerAliasError (project.translate.directx-resource-pointer-alias-unsupported) instead of an untyped ValueError.
  • HLSL output samples at level 0 in a compute stage: an implicit-LOD sample that a compute entry reaches, directly or through a helper, is written as t.SampleLevel(s, uv, 0.0), as SPIR-V output already samples the base level there. It used to write t.Sample(s, uv), which DXC accepts in a compute shader only for Shader Model 6.6 with a derivative-capable thread-group shape.
  • The Metal importer reads a static constexpr data member through a plain object, such as t.value, h.inner.count, h.many[1].count or p->count, as the member's constant, as it reads T::value. It used to read it as a field, which HLSL output then read from a structure that keeps no storage for static members. An object expression with side effects, such as tags[count++].bias, keeps its lowering.
  • Slang output writes CrossGL as_type<T>(x) as bit_cast<T>(x) and a Metal constant T& x [[buffer(n)]] entry argument as ConstantBuffer<T> x, and refuses any other reference entry parameter with SlangLoweringRefused. It used to copy as_type<T>(x) unchanged and write the argument as T &x, which slangc rejects. A wave result whose type has the shape its use expects is converted, as in bool(WaveReadLaneAt(uint(b), lane)).
  • Slang output refuses bfloat16, its vectors and the MSL bfloat and bfloatN spellings with SlangLoweringRefused, naming each type, because Slang has no bfloat16 type and half or float would change its range, precision and size. It used to copy the type names, as in RWStructuredBuffer<bfloat16>, which slangc rejects as undefined identifiers.
  • Slang output declares a function-local threadgroup array of a Metal kernel or helper as static groupshared, writes buffer_store to a RWStructuredBuffer as buf[i] = v, and accepts scalar and uint2 SV_GroupThreadID and SV_GroupID entry parameters, as it accepts SV_DispatchThreadID. It used to write the local as groupshared, which slangc rejects (E31201), and the store as buf.Store(i, v), which slangc rejects because structured buffers have no Store method (E30027). A groupshared local with an initializer and a threadgroup pointer local, which used to be written as groupshared float* p, are refused with SlangLoweringRefused.
  • Slang and WGSL output keep a specialization constant that CrossGL declares as a module-scope variable, such as constant bool x @function_constant(N);, which is how the Metal importer writes an MSL [[function_constant(N)]], specializable: [vk::constant_id(N)] const bool x; in Slang output and @id(N) override x: bool; in WGSL output, with the default when there is one. A module-scope constant computed from one, such as constant int span = tile * stride + 1;, is declared as one computed from a const T name @constant_id(N) constant already is. Slang output used to write static const bool x;, which slangc rejects (E31225), WGSL output var<private> x: bool;, which is always false, and both dropped the id of a constant with a default, as in const b: f32 = 0.25;, and froze a constant computed from one at its default or wrote a WGSL const that reads an override, which naga rejects.
  • The Metal importer types a call to a built-in SIMD-group function whose arguments match no user overload of that name as the built-in's result: beside MLX's bfloat simd_prefix_inclusive_sum(bfloat), before + simd_prefix_inclusive_sum(n) for int values stays integer arithmetic. It used to take the user overload's bfloat type and convert before to bfloat, which on every target rounded values above 256 and left row tiles unwritten in MLX's sorted gather_mm_rhs and gather_qmm_rhs kernels.
  • The HLSL importer keeps an expression statement whose root is a conditional, an element or member access or a cast, such as c ? bump() : bump(); or data[i++];, as expr;, and drops a literal statement such as 1;. It used to write // Unhandled statement type: TernaryOpNode in place of such a statement, so its calls and side effects were lost.
  • The Metal importer writes the half and bfloat predefined constants, HALF_MAX, HALF_MIN, HALF_EPSILON, MAXHALF, the M_*_H constants, BFLT_MAX, BFLT_MIN, BFLT_EPSILON and the M_*_BF constants, as conversions of their exact values, such as float16(3.140625f) for M_PI_H, and the integer limits such as HALF_DIG and BFLT_MAX_EXP as int literals. It used to keep the names, which HLSL and GLSL output left undeclared. Predefined constants, FLT_MIN and M_PI_F included, also type the arguments of constrained calls, so max(result, FLT_MIN) is no longer refused.
  • Metal output stores back a buffer element, threadgroup value or vector component passed to an inout or out parameter before a return and before the rest of the statement reads it: return f(tile[i]); becomes a local, the store back and a return of the local, and in tile[l] = bump(tile[l]);, v.y = bump(v.y) + 1; or ivec2(bump(v.y), v.y) the call is evaluated into a local whose store back runs before the statement reads it. It used to refuse such a return, write return bump(tmp); tile[i] = tmp; for a tail expression, losing the write, and run the assignment before the store back or read the stale value. A wrapping compound assignment lowered to t = asint(asuint(t) + asuint(v)) evaluates v first when v may write t, as in v.y += bump(v.y), as glslang, Mesa and DXC do; it used to read t first, so Metal, HLSL and SPIR-V output gave different results.
  • WGSL output declares a storage buffer element, structure member or workgroup variable that the program uses atomically, and a CrossGL atomic<T> or atomic_uint, as atomic<i32> or atomic<u32>, passes it to the atomic built-ins by pointer, as in atomicAdd(&data[i], v), and writes plain reads and stores of it, ++ and -- included, as atomicLoad and atomicStore. It used to write atomicAdd(data[i], v) on a plain array<i32>, which naga rejects. atomicCompSwap and atomicCompareExchange become a retry loop around atomicCompareExchangeWeak, which may fail spuriously. A float atomic, an atomic on read-only or uniform storage, a copy of a structure that holds atomics, an atomic local, an atomic inout argument and a compare-exchange inside a conditional, &&, ||, a do-while condition or a for update are refused with WGSLAtomicLoweringError.
  • WGSL output declares an entry point's function-scope threadgroup, workgroup, shared or groupshared variable, such as a Metal threadgroup float tile[256];, as a module-scope var<workgroup> and renames the entry's uses if the name is taken. It used to declare it as a function var, so every invocation worked on its own copy of the tile. Such a variable in a helper, with an initializer, or whose type names a value the entry declares is refused with WGSLWorkgroupLocalError (project.translate.wgsl-workgroup-local-...).
  • WGSL output writes a conditional whose arms have side effects, such as int x = c ? bump() : 7;, as an if/else when it is a whole initializer, assigned value, return value or expression statement, nested conditionals included. It used to write select(7, bump(), c), which evaluates both arms, so bump() ran even when c was false. Such a conditional anywhere else, as in 1 + (c ? bump() : 0), is refused with a ValueError. An expression statement that is not a call or an update, such as data[0];, is written as the phony assignment _ = data[0];; it used to be written bare, which naga rejects.
  • The Vulkan GLSL importer keeps an expression statement whose root is a conditional, a member access, an index or a literal, such as (a > 0) ? bump() : reset(); or values[0];. It used to write // Unhandled statement type: TernaryOpNode in its place, so both calls were lost.
  • WGSL output lowers isnan, isinf, isfinite and signbit of an f32 scalar or vector to bit tests, component by component: isnan(x) becomes ((bitcast<u32>(x) & 0x7fffffffu) > 0x7f800000u). An operand that is not f32, or whose type is unknown, is refused with WGSLFloatClassificationError (project.translate.wgsl-float-classification-unsupported). It used to copy the calls, which naga rejects because WGSL has none of these built-ins.
  • Output for every target other than Metal lowers Metal's isordered, isunordered and isnormal: isunordered(x, y) becomes isnan(x) || isnan(y), isordered(x, y) its negation, and isnormal(x) becomes isfinite(x) && abs(x) >= the smallest normal value, 2^-126 for float and 2^-14 for half, component by component for a vector, with operands that have side effects evaluated once and in order. A vector operand with side effects, an operand of unknown type and a 64-bit operand are refused with FloatRelationUnsupportedError (project.translate.<target>-metal-relational-function-unsupported). GLSL and HLSL output used to copy the calls, which glslang and DXC reject, and SPIR-V output refused them.
  • A call of a program function that returns void, used as a value, as in float y = f() + 1.0; for void f(), is refused on every target with VoidValueError (project.translate.<target>-void-value); SPIR-V output used to emit an instruction on a void operand, which spirv-val rejects. A cast to void, CrossGL void(e) or HLSL (void)e;, is written as the statement e;, or dropped when e has no side effects, a void conditional statement as an if/else, and a cast in a for header or a non-last comma operand loses the cast; one left anywhere else is refused with VoidCastError (project.translate.<target>-void-cast) except on Metal. GLSL output used to write void(x);, which glslang rejects, HLSL and WGSL output were invalid, SPIR-V output refused the call, and the HLSL importer dropped (void)bump(); together with its side effect. SPIR-V output also refuses an operator operand, a switch selector or a for-in bound it cannot generate; it used to write 0, 0.0 or false in its place.
  • SPIR-V output passes a swizzle of several components, such as v.xz, as an out or inout argument by copying the components into a temporary before the inlined call and storing each one back after it. It used to refuse the call or bind the wrong storage. A storage buffer argument with a side-effecting subscript, such as inc(outBuf.vecs[j++].z), evaluates the subscript once; SPIR-V output used to run j++ once per overload candidate it checked and write the wrong element.
  • Metal output declares a CrossGL stage-block shared variable or an HLSL program-scope groupshared variable that a helper reaches, directly or through other calls, in the entry point and passes it to the helper as a threadgroup reference parameter. The helper used to name an undeclared variable, or the variable was declared at program scope, which the Metal compiler rejects. A call that copies an inout or out argument in and out through a temporary, as Metal output does for threadgroup, device and vector-component arguments, evaluates the side effects of earlier arguments before the copy and an index the call can change once, and an if, else if, while, for or switch header that holds such a call gets a statement of its own so the copy runs at every evaluation; such a call in a do-while condition or a for update is refused with a ValueError. Headers with such calls used to produce MSL that the compiler rejected with no matching function.
  • Metal output writes an inout or out argument that is an element of a GLSL buffer block held as bytes back through the block's store form, and a component write to an element of an array of vectors, such as block.v[i].y = x, as a store of that component. It used to write both through the block's const device load, which the Metal compiler rejects as not assignable. Such a write to a read-only block is refused.
  • A for header that declares or assigns several variables, or updates several, such as for (int i = 0, n = 4; i < n; i++, n--) or for (k = 0, m = 3; k < m; k++), translates from CrossGL and GLSL input with every element of each list, evaluated in order. The CrossGL and GLSL parsers used to fail on these lists or keep only their first element, and SPIR-V output dropped every update but the first. WGSL output writes a list update or one with side effects, and a do-while loop, as a loop with a continuing block, so continue still runs the update or the condition, and ends a value-returning function after such a loop with a return of a zero value, which WGSL's behaviour analysis requires.
  • The CrossGL parser reads a braced constructor of a generic type: vec<T, 2>{x, y} is the constructor call vec<T, 2>(x, y), and Pair<float>{1.0, 2.0} an aggregate of type Pair<float>. The Metal importer writes the first form for a defaulted template such as template <typename IdxT = int> vec<IdxT, 2> f(...), which used to be refused with Expected binding name, got NUMBER, and Pair<float>{1.0, 2.0} used to be read as Pair < float, which Metal output wrote as int(Pair < float)>{1.0, 2.0}.
  • CUDA and HIP output keep a module-scope static variable or a stage-private variable per thread: each kernel that reaches it declares it as a local, zero-initialized when it has no initializer, and passes it by reference to the helpers on the way. A private variable that is a resource or a pointer is refused with DevicePrivateGlobalUnsupportedError (project.translate.device-private-global-unsupported). They used to declare it as a host global, which nvcc rejects as undefined in device code.
  • The Metal importer gives free functions of one name declared in several namespaces, such as a::f and b::f, distinct program-scope names and binds each call by C++ name lookup, using-directives included. Identical parameter lists used to become duplicate definitions, which every target compiler rejects, and different ones a single overload set, so a call could bind to a better-matching global overload instead of the namespace member C++ selects. User overloads of a Metal library function, such as metal::simd_shuffle_down(bfloat, ushort) or the ldexp(bfloat, int) that MLX's bf16_math.h declares in metal, metal::fast and metal::precise, still extend the library function, so ldexp(float, int) keeps calling it.
  • The Metal importer writes a comma-operator statement, such as a = x, b = y;, as one parenthesized CrossGL comma expression, and resolves array designators, [i] = v and the GNU range form [a ... b] = v, to positional initializer lists, zero-filling the elements left out and sizing an unsized array by its largest index. It used to write a = x , b = y; and copy the designators, neither of which the CrossGL parser reads. A duplicate or out-of-range index, a non-constant index, a range with side effects and a designator chain are refused with MetalImportRefused (project.translate.metal-import-unsupported).
  • A shader-scope helper that names a stage's declaration, directly or through the functions it calls, is copied into each stage that calls it, and each copy reads its own stage's input structure. The SPIR-V importer writes helpers at shader scope beside the stages' interface variables, so HLSL and Metal output used to print input.inUV in a helper without an input parameter, which DXC rejects as an undeclared identifier, SPIR-V output refused the program with Unknown variable inUV, and two stages with same-named helpers both read FragmentInput.
  • CUDA, HIP, HLSL, Metal, GLSL, GLSL ES, Rust, Slang and WGSL output refuse generated code that contains the printed form of a CrossTL AST node, such as ConstructorNode(constructor_type=NamedType(...), arguments=2), or a default Python object representation, with GeneratedAstTextError (project.translate.<target>-ast-node-unlowered), which names the node. An emitter with no rule for a node used to print it into the code it returned.
  • The SPIR-V importer names a geometry stage's Input variable decorated BuiltIn PrimitiveId gl_PrimitiveIDIn and keeps gl_PrimitiveID for the Output one. Both used to import as gl_PrimitiveID, so gl_PrimitiveID = gl_PrimitiveIDIn; came back as gl_PrimitiveID = gl_PrimitiveID;, which GLSL and SPIR-V output compiled to copy the stage's own output. HLSL output lowers geometry built-ins declared as stage variables, as the SPIR-V importer writes them, to SV_GSInstanceID, SV_PrimitiveID and output structure members, as it lowers undeclared ones, instead of refusing them as non-array per-vertex inputs, and refuses a geometry or tessellation entry without the HLSL attributes its stage needs with DirectXStageAttributesMissingError (project.translate.directx-stage-attributes-missing) instead of an untyped ValueError.
  • A program-scope constant or a static_assert whose initializer calls a function of the program, as MSL and HLSL allow, is evaluated at translation time with the source's rules, the usual arithmetic conversions, modular unsigned and narrowing conversions and binary32 rounding, and the call is replaced by a literal of its return type. GLSL, WGSL and SPIR-V output used to refuse such a constant, and Metal, Slang and CUDA output wrote the call ahead of the function it names, which their compilers reject. A call the evaluator does not run, such as one that overflows a signed integer, divides by zero or calls sin, is left for the generators to refuse.
  • GLSL and WebGL output declare a stage-level vertex @output variable whose type is or holds an integer flat, as they already did for members of stage output structures. The SPIR-V importer writes vertex outputs this way, and they used to be written out int cgl_location_0;, which glslang rejects for GLSL ES because an integer vertex output must be flat.
  • The SPIR-V importer writes a lookup through OpSampledImage of a separate image and sampler as CrossGL's separate-sampler call, such as texture(image, sampler, uv), also for textureLod, textureGrad, textureOffset, textureGather and the comparison lookups, as the HLSL importer writes them, and takes the image back out of the combination for texelFetch and textureSize. It used to write texture(sampler2D(image, sampler), uv), which only Vulkan GLSL reads, so GLSL, HLSL and Metal output failed and SPIR-V output refused the shadow lookups. Every module DXC writes uses separate samplers.
  • The SPIR-V importer declares a Private storage-class variable as a static module-scope variable, one copy per invocation. It used to declare a plain module-scope variable, which HLSL output treated as read-only (DXC: read-only variable is not assignable), GLSL output as a uniform and Metal output as a constant, so a shader that wrote it did not compile.
  • The SPIR-V importer imports storage images and texel buffers with CrossGL's image types, such as uimage2D x @r32ui, imageBuffer and samplerBuffer, and an OpAtomic* through OpImageTexelPointer as imageAtomicAdd, imageAtomicMin, imageAtomicMax, imageAtomicAnd, imageAtomicOr, imageAtomicXor, imageAtomicExchange or imageAtomicCompSwap, a subtraction, increment or decrement being imageAtomicAdd of the negated value. It used to write HLSL's RWTexture2D<uint>, RWBuffer and Buffer, which Metal and WGSL output do not read, so every SPIR-V storage image failed on those targets.
  • A call of a reserved SPIR-V operation name that the program does not declare, such as spirvImageSparseSample or spirvSparseTexel, which the SPIR-V importer writes for an operation CrossGL cannot express, is refused on every target other than CrossGL with SpirvOperationUnsupportedError (project.translate.<target>-spirv-operation-unsupported), and WGSL output, since WGSL has no texture atomics, refuses imageAtomic* calls with WGSLImageAtomicUnsupportedError (project.translate.wgsl-image-atomic-unsupported). The generators used to copy these calls into their output.
  • A stage-scope constant, const, static const or MSL constant with an initializer, is declared as a constant on every target. GLSL and HLSL output used to drop the declaration, so DXC rejected its uses as undeclared identifiers, and Slang output declared it as a uniform. One whose initializer reads run-time values becomes a private variable that the entry point assigns first. Slang output writes const and constant globals as static const, CUDA and HIP output an initialized constant as const and a constant array as __device__ const, and WGSL output a const global as const; WGSL output used to write a var<private> whose initializer naga rejected when it read another module variable.
  • The GLSL importer applies a default block layout, layout(...) uniform; or layout(...) buffer;, to the blocks declared after it, with later defaults and a block's own qualifiers taking precedence, and passes a block-level row_major or column_major to the block's matrix members and to structure members that name no order of their own. It used to ignore the defaults, so the blocks after layout(std140) buffer; were laid out as std430 and a block-level row_major was lost. A qualifier that cannot be a block default is refused with SyntaxError.
  • The binding-index, array-extent, sizeof and static_assert evaluators convert to a narrow integer type modulo its width, as MSL and HLSL do, so uint8_t(300) is 44, and evaluate constants, conversions and sizeof operands that name a program-scope type alias through the alias. They used to evaluate uint8_t(300) as 300, so a static_assert that overlooked the wrap passed and a binding index written as a narrow conversion bound the wrong slot, and they refused operands that named an alias. A negative result of a signed narrow conversion used as a binding index stays unresolved.
  • The Metal importer finds a constant declared in one block of a namespace from every later block of the same namespace, as C++ lookup does, and reads multi-word integer types such as unsigned int, unsigned short int and long int in namespace-scope constants and static data members. A static_assert in a reopened block used to be refused with MetalStaticAssertionError because it found no value for the constant.
  • The Metal importer binds namespace-scope variables by C++ name lookup: a qualified reference such as outer::inner::COUNT, ::outer::inner::COUNT or one through a namespace alias names the variable, a variable declared in several namespaces gets a distinct program-scope name built from its namespace path while a global one keeps its name, and an unqualified use is looked up through blocks, enclosing namespaces and using-directives. A qualified reference used to be written as an identifier nothing declared, such as outer_u3a_u3ainner_u3a_u3aCOUNT, and same-named variables of different namespaces were all written as N. An unqualified use that lookup cannot bind to one declaration is refused with MetalNamespaceLookupError (project.translate.metal-namespace-lookup).
  • The Metal importer gives a program-scope constant auto or constant constexpr auto its initializer's type, as it does for a block-scope auto. It used to write constant auto name, which GLSL output refused with OpenGLCompileTimeGlobalError and the other generators could not declare.
  • Metal output parenthesizes a conditional that is the condition of another conditional, so (a ? b : 0) ? 5 : 6 stays as written. It used to be written a ? b : 0 ? 5 : 6, which groups as a ? b : (0 ? 5 : 6) and gives a different result. Metal output also keeps the parentheses that clang's -Wparentheses warnings ask for, around && inside ||, & and ^ inside |, & inside ^ and a comparison inside &, | or ^, so the output compiles under -Werror -Wall (#4048).
  • The Metal importer keeps a structure's alignas specifier, an integral constant or alignas(T), as @metal_alignas(N); sizeof honours it and a buffer of such structures takes @buffer_layout(metal), so struct alignas(16) Rec { float a; float b; } has a 16-byte stride in Metal, GLSL, HLSL and SPIR-V output, as in MSL. The importer used to drop the specifier, which gave an 8-byte stride. A specialization of a generic structure that carries an attribute is refused with GenericStructAttributeError (project.translate.generic-struct-attribute) instead of losing the attribute.
  • HLSL output writes CrossGL's byte-address buffer atomics, atomicAdd, atomicMin, atomicMax, atomicAnd, atomicOr, atomicXor and atomicExchange(buffer, offset, value) and atomicCompareExchange(buffer, offset, compare, value), as the RWByteAddressBuffer.Interlocked* method when the call is a statement, as InterlockedCompareStore for a compare-exchange whose result is unused, and through a __crossgl_bab_atomic_<op>_<uint|int> helper that returns the original value when the result is used; an int value selects the signed InterlockedMin and InterlockedMax. It used to copy the calls, as in prev = InterlockedAdd(dst, 0, 1), which DXC rejects. SPIR-V output writes them as OpAtomic* on the word at offset / 4, with OpAtomicSMin and OpAtomicSMax for an int value, also for the InterlockedMin and InterlockedMax methods; it used to refuse the CrossGL forms and compare the methods' values as unsigned. A form that cannot be lowered is refused with ByteAddressAtomicUnsupportedError (project.translate.byte-address-atomic-unsupported).
  • The CrossGL parser keeps every qualifier of a declaration whose layout(...) follows another qualifier, as GLSL 4.20 allows, at program, shader and stage scope: uniform layout(rgba16f) imageCube img; stays a uniform with the rgba16f layout. The qualifier list used to end at layout, so the declaration lost uniform.
  • A generic function's specialization takes a name the program does not already declare: with float pick_float(float a, float b) beside generic<T> T pick(T a, T b), the float specialization is pick_float_2. HLSL, GLSL, Metal, CUDA, HIP, Slang, Mojo and SPIR-V output used to emit two pick_float definitions, which their compilers reject. An implicit template call of a Metal source that project translation materializes takes a free name the same way.
  • HLSL output applies the offset of a buffer pointer alias, such as device float* first = data + 4;, only to accesses through that alias. It used to look the offset up by the name of the root buffer, so data[tid] beside the alias read data.Load(first_offset + tid) and wrote data[first_offset + tid], and an access through one of two aliases of the same buffer could take the other's offset; DXC compiled the wrong indices without complaint.
  • Project translation of a Metal source types the arguments of an implicit template call as the Metal compiler does before choosing the template arguments: g(u + l) for uint u and long l specializes g for long and g(v4 * f) for float4. It used to type a + b as a, so g(u + l) became g_uint(uint(int64_t(u) + l)), which truncates, typed a call of an overloaded function by its last definition, so g(f(x)) with float f(float) and half f(half) became g_half(...), and could take an undeduced auto as a template argument, as in min<uint, auto>. A call whose argument has no sound type, such as g(f(x)) with that overloaded f, is refused with MetalSourceMaterializationError.
  • GLSL, Slang and HLSL output declare a block marked @push_constant, such as an HLSL [[vk::push_constant]] cbuffer or ConstantBuffer<T>, as Vulkan push constants. GLSL output writes layout(push_constant) uniform with each member's layout(offset = N) under #ifdef VULKAN and keeps its OpenGL uniform block in the #else branch; Slang output writes [[vk::push_constant]] cbuffer or ConstantBuffer<T> with [[vk::offset(N)]] members and no binding; HLSL output writes [[vk::push_constant]] ConstantBuffer<T> with std430 [[vk::offset]] members under #ifdef __spirv__, reading blocks whose arrays or matrices DXC cannot place as 32-bit words, and keeps a constant buffer at the same offsets for Direct3D. A second push-constant block in a stage, an array of blocks, an offset on a structure member and a layout the target cannot express are refused with PushConstantBlockError. All three used to declare an ordinary uniform buffer at binding 0 or a register, which the host never binds, so the program read its constants from an unbound descriptor. The Slang importer reads [[vk::offset(N)]] on a cbuffer member as @offset(N).
  • HLSL output refuses a uniform or push-constant block whose layout its declarations cannot reproduce, such as one with a 16-bit member, with DirectXBufferLayoutError (project.translate.directx-buffer-layout-unsupported). It used to raise an untyped ValueError.
  • HLSL output moves half values held in groupshared arrays, function-local arrays and the pointer and array parameters into them as bits: such arrays are declared with uint16_t elements, a read is asfloat16(element), a write is element = asuint16(value) and a selection between stored elements selects the bits, so a copy keeps a NaN's bit pattern. Arithmetic and comparisons stay in float16_t, and a program whose binary16 workgroup and private memory cannot all be rewritten keeps all of it typed. The arrays used to be float16_t, and the D3D11.3 specification lets every typed 16-bit load, store and selection change a NaN's bits, which WARP does.
  • HLSL output runs an atomic in the condition of an if, else if, while, for, do-while or switch on a groupshared value or a typed buffer element, such as if (atomicAdd(g, 1u) == 0u) or a spin lock on atomicCompSwap, as an Interlocked* statement before the test, once per evaluation: an else if atomic runs only after the earlier conditions fail, and a loop condition's atomic runs on every iteration, including one a continue starts. It used to write the atomic inside the condition, which DXC rejects because Interlocked* returns the original value through an out argument.
  • HLSL output writes atomicLoad, atomicStore, an atomicExchange whose result is unused and an atomicAdd nested in an expression on a groupshared value as Interlocked* calls, and stores an atomic's result into a GLSL buffer block member through a temporary and a Store. It used to print the groupshared calls under their CrossGL names, and to write b.Load(...) as the assignment target or the out argument, which DXC rejects as not assignable.
  • Metal, HLSL, CUDA and HIP output compute an 8- or 16-bit integer operation of a GLSL or HLSL source at its own width, as GLSL with GL_EXT_shader_explicit_arithmetic_types and HLSL with -enable-16bit-types do: for uint16_t a, b, a * b is computed as uint16_t(uint(a) * uint(b)), so uint((a * b) >> 8) drops the bits above 16 and (a + b) < a is true on overflow. They used to compute in 32 bits, as CrossGL's promotion to int does, and HLSL output wrote int(a) * int(b). SPIR-V and WGSL output keep a shift's left operand type, so v << 12 for a uint16_t v wraps at 16 bits, and SPIR-V output no longer fails on a for header that declares several 8- or 16-bit variables, such as for (short i = 0, step = 3; ...). Metal sources keep C promotion.
  • DirectX, Slang and Metal output read and write the 8- and 16-bit integer and float16_t members of a GLSL buffer or uniform block at their own size and alignment, as GL_EXT_shader_8bit_storage and GL_EXT_shader_16bit_storage lay them out: after uint16_t words[2];, words[1] is at byte 2 and the next 4-byte member at byte 4. They used to give each such member 4 bytes, so words[1] was at byte 4 and the next member at byte 8. DirectX and Slang output load and store 16- and 64-bit components with Load<T> and Store<T>; a 64-bit integer used to go through the 32-bit Load and Store, which dropped its high word. Metal output spells float16_t(x) as half(x), and a block Slang output cannot lay out is refused with BufferBlockUnsupportedError instead of being written as a comment with a placeholder.
  • CUDA and HIP output map the named 8- and 16-bit integer vectors that GLSL input imports, i8vec2 to u16vec4, to char2 to ushort4, with make_char2-style constructors and arithmetic helpers, as they map vec2<i8>, and type a swizzle of a narrow vector by its element, so vec4<i16> t = s.wzyx is a short4. They used to copy i8vec2 unchanged and type the swizzle as an int vector, as in short4 t = make_int4(...), which nvcc and hipcc reject.
  • The HLSL and Slang importers keep a storage image's format and texel type: HLSL [[vk::image_format(F)]] and Slang [format(F)] import as @format(F), and a typed UAV without a format whose texel is not the four-component default, such as RWTexture2D<uint>, imports with the new @texel attribute, as uimage2D @format(unknown) @texel(uint), from which HLSL and Slang output declare the texel type again. An unknown format, and @texel beside an explicit format, are refused. GLSL output used to declare rgba32f for a [[vk::image_format("rgba8")]] image, an HLSL round trip returned RWTexture2D<unorm float4> and RWTexture2D<uint> as RWTexture2D<float4> and RWTexture2D<uint4>, and the Slang importer read RWTexture2D<uint> as a float image2D. A helper's storage-image parameter takes the type of the images passed to it, so DXC finds its overload; passing images of different texel types to one parameter is refused.
  • The Slang importer reads a storage texture subscript as an image operation: a read is imageLoad narrowed to the element type, a write, compound write, increment or component write is imageStore of the widened texel, and Interlocked* on a texel is imageAtomic*. Writes CrossGL cannot express are refused. The subscripts used to stay in CrossGL, so GLSL and SPIR-V output refused them and Metal output wrote invalid subscripts. Slang output writes CrossGL atomics on groupshared values as Interlocked* calls; it used to copy them.
  • The HLSL, Metal, GLSL, CUDA, HIP, OpenCL and Slang importers expand macros as the C preprocessor does: arguments are replaced before substitution, so F(F(1)) is fully expanded and CAT(v, N) through #define CAT_I(a, b) a##b pastes the replaced N; a function-like name at the end of a replacement is rescanned with the ( that follows the invocation; a self-referential macro in an argument is replaced once; and #if groups nested in a skipped group are not evaluated. A malformed invocation, such as one with the wrong argument count, an unterminated argument list or an invalid paste, is refused with the shared preprocessor's MacroError or PreprocessorError. They used to substitute text, which left F(F(1)) partly unexpanded and pasted the unreplaced N.
  • A call to a generic function deduces its type parameters from a buffer or array element, a structure member, a typed constant, a shader-scope or stage-scope variable and the result of another generic call on GLSL, HLSL, Metal and SPIR-V output, and a T* parameter deduces T from a buffer argument such as RWStructuredBuffer<X>, keeping the pointer and its address space. Metal and HLSL output used to specialize the caller of a nested generic call with the unsubstituted parameter, as in T twice_T, Metal output called undeclared specializations such as twice_float for a global argument, and GLSL and SPIR-V output refused these calls. Metal, HLSL and GLSL output refuse a call to a specialization they did not emit with GenericSpecializationOrderError (project.translate.generic-specialization-uncollected), and the Metal importer accepts atomic load and compare-exchange targets typed by an open generic parameter.
  • A call that only a built-in accepts goes to the built-in when the source also declares a function of that name and argument count: beside a user float dot(float x, float y), dot(v, float4(1.0f)) stays the library dot, because a vector argument whose width differs from every user overload's parameter cannot convert. Metal output used to send every two-argument dot to the renamed user function, as in dot_fn(v.x, ...), which the Metal compiler rejects or, with matching widths, truncates to the x component.
  • A Metal source's vector-scalar arithmetic keeps MSL's types on every target: a scalar that ranks above the vector's component type converts to it, so h * f for a half3 h and a float f is a half3 computed in half, and v / u for an int3 v and a uint u is a signed division. The Metal importer writes the conversion into its CrossGL output, as in h * half(f). CrossGL used to apply GLSL's common type, computing float3(h) * f and an unsigned division, so half3 h = saturate(fmod(f3, x)) did not compile in Metal output. fmod and % on half values use an exact cgl_half_fmod on SPIR-V and WGSL output instead of being refused, and WGSL output writes fmod as %, the truncated remainder; it used to write an undeclared fmod call.
  • The Metal importer spells MSL's names for one scalar type, such as uint, uint32_t and unsigned int, or ulong, uint64_t and size_t, the same inside template names, so max_value<uint>() reaches the explicit specialization max_value<uint32_t>; it used to call an undeclared max_value_u3cuint_u3e. Metal output passes 8- and 16-bit scalar arguments of min, max and clamp in their 32-bit register type, which used to match no overload beside a uchar buffer element.
  • The Metal importer refuses a type trait, such as is_same_v<T, U>, that it cannot evaluate in code outside a template with MetalTypeTraitError (project.translate.metal-type-trait-unresolved) for every target. Unless the project pipeline checked static assertions for a target without templates, it used to reach the output as a mangled name, such as is_same_u3csampler_u2c..., that nothing declares.
  • The Metal importer reads i < MAX(a, b), whose expansion holds a > inside parentheses, as a comparison: the scan that decides whether name < opens a template argument list skips < and > inside parentheses and brackets. It used to read a template argument list that swallowed the rest of the function. Explicit specializations whose names would collide, such as pick<(N > 2)> and pick<(N < 2)>, or twice<int> beside a function twice_int, take a numbered suffix; they used to share one name.
  • Metal output tracks read-only locals by block, so a writable local that reuses the name of a const local from an earlier block or loop body can be written. Every store to it used to be refused.
  • The Metal importer prefers a non-template member function over a member template when the conversions of the parameters they share tie, as C++ does: with both declaring a uint parameter, scaler.apply(values, lane) for a ushort lane calls the non-template apply. It used to call the template unless every argument matched the non-template exactly.
  • The Metal importer resolves an owner's static constant members in a template-id inside a member function unless a parameter, local or member template parameter hides them, keeps the method calls of a member function whose only receivers are its own structure-typed locals, and drops pointee const from a cast to const threadgroup T* when the destination is not const. It used to write unresolved names such as Tile_float_TM, drop those method calls, and write threadgroup float* p = (const threadgroup float*)..., which the Metal compiler rejects.
  • The Metal importer writes a kernel template only through its instantiations; the uninstantiated template used to become an entry point with unbound template parameters. In a project source, a comment before a nested block no longer hides the block's first declaration from template argument deduction, and a generic function's specialization keeps a parameter type that names no type parameter as declared, so a pointer parameter is no longer redeclared as a reference to a pointer.
  • The Metal importer declares the specialization of a namespaced function template in that namespace and calls it by its qualified name, such as ::lib::detail::combine_float, so a type alias, alias template or constant declared beside the template is visible in it. It used to declare the specialization at global scope, where Metal output kept real_t or common_t<float, float> undeclared.
  • The Metal importer translates a member of a class template specialization only when the program uses it, as C++ instantiates member definitions. An unused member whose body is ill-formed for the specialization's arguments, such as scan_impl calling simd_prefix_inclusive_sum on a structure, used to be translated, so HLSL output refused a valid source with WavePrefixInclusiveSum ... got cplx.
  • The Metal importer calls a non-template free operator that the source defines at namespace scope, such as cplx operator+(cplx a, cplx b), wherever a + b, a unary or compound form or a direct call such as operator>(a, b) selects it. Every target used to apply the built-in operator, silently dropping the definition.
  • Metal output keeps the index of a threadgroup or threadgroup_imageblock entry parameter as [[threadgroup(n)]], which the host passes to setThreadgroupMemoryLength:atIndex:. It used to drop it, so the compiler numbered the slots in declaration order and slots 0 and 2 became 0 and 1. An index that is not one non-negative integer literal is refused with MetalLoweringRefused.
  • Metal output converts the value of a texel write to the texture's element type, so a GLSL imageStore of an f16vec4 to a float image passes a float4 to texture2d<float>::write. It used to pass the half4, which the Metal compiler rejects with no matching member function for call to 'write'.
  • Metal output names the entry parameter of a uniform block whose name is an MSL keyword once lowercased, such as a block Kernel, kernel_. It used to name it kernel, which the Metal compiler reads as a keyword.
  • OpenGL output finishes a helper that declares one storage-pointer name in two scopes from different offsets of a parameter; translation used to never finish, as for Apple's hash_encoder_kernel.metal. A pointer that still refers to itself after a fixed number of passes is given read_write access.
  • HLSL and Slang output keep a storage image's texel format. HLSL output declares an 8- or 16-bit normalized format with a unorm or snorm texel type, so an rgba8 image is RWTexture2D<unorm float4> and an rg8_snorm one RWTexture2D<snorm float2>, on globals and on parameters, and adds [[vk::image_format("rgba8")]] under #ifdef __spirv__ for every format DXC cannot derive from the texel type; Slang output writes [format("rgba8")] for every explicit format. Both used to declare every float storage image as RWTexture2D<float4>, so an rgba8 image lost its normalization and DXC and slangc gave it the SPIR-V format Rgba32f (#3929).
  • GLSL output keeps the Vulkan descriptor set of a resource whose set is not 0: its layout binding is CROSSGL_BINDING(set, Vulkan binding, OpenGL binding), a macro defined after the #version and #extension lines that expands to set = S, binding = B when glslang compiles for Vulkan and defines VULKAN, and to the planned OpenGL binding = N otherwise. A set-0 resource keeps binding = B. GLSL output used to write only the OpenGL binding, so glslang -V put every resource in set 0 (#3898).
  • CrossGL input reads a pointer buffer followed by an attribute, such as buffer float* data @binding(2);, at program or stage scope as a declaration. It used to skip it, so every target read an undeclared buffer.
  • Metal output declares struct BuiltInTriangleIntersectionAttributes { float2 barycentrics; } when an HLSL or Slang closest-hit or any-hit stage, a helper or a structure member uses DXR's triangle attributes and the program does not declare them, and the stage's [[visible]] function takes it as an ordinary argument. It used to write the HLSL type name undeclared, which the Metal compiler rejects as an unknown type name (#3917).
  • Metal input reads a mesh function's output parameter spelled mesh<V, P, NV, NP, topology::triangle> without metal::, under using namespace metal, as it reads the qualified spelling. It used to refuse the function with MetalParserError (Expected type, got MESH) (#3885).
  • Metal output of a vertex stage that reads gl_InstanceID computes it as [[instance_id]] less [[base_instance]], so it counts from zero as in OpenGL and Direct3D, while gl_InstanceIndex keeps [[instance_id]], and Metal input reads [[instance_id]] as gl_InstanceIndex. Slang output reads gl_InstanceIndex as int(gl_InstanceID + gl_BaseInstance), written with SV_InstanceID and SV_StartInstanceLocation, and gl_VertexIndex as gl_VertexID, in reads and in entry parameters. Metal output used to read gl_InstanceID from [[instance_id]], which includes the draw's base instance, and Slang output copied gl_InstanceIndex and gl_VertexIndex unchanged, which slangc rejects as undeclared identifiers, and refused an entry parameter carrying either (#3893).
  • HLSL and Metal output read GLSL's gl_VertexID, gl_InstanceID, gl_BaseVertex and gl_BaseInstance wherever a vertex stage reads them by name, in the entry point or a helper: the entry point takes the system value as a parameter, reusing an input that already carries it, passes it to the helpers that read it and converts the uint value to GLSL's int once at its start. HLSL output also reuses an input that already carries SV_VertexID, SV_InstanceID or SV_ViewID instead of declaring a second one. Both used to copy the reads unchanged, which DXC and the Metal compiler reject as undeclared identifiers (#3891).
  • HLSL and Slang input read SV_StartVertexLocation, SV_StartInstanceLocation and SV_DrawIndex as the draw parameters gl_BaseVertex, gl_BaseInstance and gl_DrawID. HLSL output writes gl_BaseVertex and gl_BaseInstance as those Shader Model 6.8 system values and refuses them for the dx10 and dx11 profiles, Slang output writes gl_DrawID as SV_DrawIndex, and Metal output, which has no draw-index attribute, refuses a vertex input carrying a built-in it cannot spell, such as uint draw @ gl_DrawID, with MetalLoweringRefused. The three semantics used to import as user vertex attributes, so GLSL output declared layout(location = n) in inputs, SPIR-V output gave them a Location and Metal output an [[attribute(n)]], which no vertex fetch fills (#3840, #3545).
  • SPIR-V output decorates a vertex input carrying @gl_BaseVertex, @gl_BaseInstance or @gl_DrawID, their ARB spellings, or HLSL's SV_StartVertexLocation or SV_StartInstanceLocation as BuiltIn BaseVertex, BaseInstance and DrawIndex, with the DrawParameters capability and the SPV_KHR_shader_draw_parameters extension. It used to give the input a user Location, which no vertex fetch fills (#3794, #3800, #3807).
  • Metal output accepts an int entry parameter or stage structure member carrying one of GLSL's int built-ins, gl_VertexID, gl_InstanceID, gl_BaseVertex, gl_BaseInstance, gl_PrimitiveID, gl_Layer, gl_ViewportIndex, gl_SampleID, gl_ViewIndex or gl_FragStencilRefARB, and reads it through the uint attribute Metal declares: a parameter takes the attribute under a fresh name and initializes an int local, and a member is declared uint, converted to int where it is read and to uint where it is written, with /=, %= and >>= keeping their signed meaning. gl_BaseVertex and gl_BaseInstance map to [[base_vertex]] and [[base_instance]], and HLSL output declares an int SV_StencilRef member as uint, which DXIL requires. Metal output used to refuse every such int declaration with an untyped ValueError and to declare gl_BaseVertex and gl_BaseInstance members as vertex attributes (#3777, #3780, #3781).
  • Slang input keeps the stage roles of mesh, task and ray tracing entry points, as HLSL input does: a miss, hit or callable entry's payload, hit attributes and callable data become @ payload, @ hit_attribute and @ callable_data, a mesh entry's out vertices, out indices, out primitives and in payload parameters become @ vertices out, @ indices out, @ primitives out and @ mesh_payload in, mesh and task entries keep [numthreads] and [outputtopology], and struct [raypayload] Payload parses. Slang input used to drop the roles and read payload as the parameter's type, and refused struct [raypayload] with SyntaxError: Expected IDENTIFIER, got LBRACKET (#3880, #3887, #2597).
  • SPIR-V input declares a task or mesh stage's TaskPayloadWorkgroupEXT variable as Payload payload @taskPayloadSharedEXT, as GLSL input does, and SPIR-V output passes the stage's payload variable to OpEmitMeshTasksEXT, refusing a stage where the choice is ambiguous. SPIR-V input used to drop the declaration and keep its uses, so no target took the import, and SPIR-V output wrote OpEmitMeshTasksEXT without its payload operand, which spirv-val accepts, so the mesh stage read no payload (#3879, #3909).
  • SPIR-V output passes the rayPayloadEXT or callableDataEXT variable at the location that TraceRay(..., 0) or CallShader(index, 0) names to OpTraceRayKHR and OpExecuteCallableKHR; GLSL and SPIR-V input write traceRayEXT and executeCallableEXT in this form. A location that no variable, or more than one, occupies is still refused. SPIR-V output used to refuse the location as not an addressable value, so no GLSL or SPIR-V shader that traced a ray or called a callable shader reached SPIR-V (#3888).
  • Every target carries a mesh primitive's cull flag, CrossGL gl_CullPrimitiveEXT, which HLSL and Slang input read SV_CullPrimitive as: GLSL output writes gl_MeshPrimitivesEXT[i].gl_CullPrimitiveEXT, SPIR-V output BuiltIn CullPrimitiveEXT with PerPrimitiveEXT, HLSL and Slang output SV_CullPrimitive, and Metal output a [[primitive_culled]] member of the primitive structure, and every generator accepts either spelling. GLSL output used to write an SV_CullPrimitive member as a user perprimitiveEXT out bool, which glslang rejects ('out' : cannot be bool), SPIR-V and Metal output refused it, and HLSL and Slang output refused gl_CullPrimitiveEXT. Slang output also writes GLSL-style mesh and task stages, which it used to copy with gl_MeshVerticesEXT and the index arrays unchanged, and translates a task stage without a mesh stage, which it refused with DispatchMesh payload argument requires a mesh stage (#3878, #3906).
  • GLSL output of a mesh or task stage that enables GL_NV_mesh_shader keeps only that extension. It used to add #extension GL_EXT_mesh_shader : require above it, which glslang rejects (GL_EXT_mesh_shader is already turned on, and not allowed with GL_NV_mesh_shader) (#3842).
  • Slang input keeps globallycoherent on a UAV as @globallycoherent, as HLSL input does, and Metal output writes a globallycoherent buffer as coherent(device). Slang input used to drop the qualifier, and Metal output declared the buffer as an ordinary device T*, so its writes were not made visible across the device (#3861).
  • Metal output keeps restrict, volatile and coherent on a buffer T* storage pointer, and restrict on a structured buffer, as device T* __restrict, volatile device T* and coherent device T*, on entry points and on the helpers the buffers pass through, and Metal input reads __restrict and __restrict__ on a buffer argument as restrict. SPIR-V and HLSL output read Metal's device- and threadgroup-scoped coherent as coherent, writing Coherent and globallycoherent, and GLSL output accepts volatile and coherent on a buffer T* pointer. Metal input and output used to drop these qualifiers, SPIR-V and HLSL output dropped coherent(device), and GLSL output refused the pointer qualifiers as representable only on shader-storage buffers (#3838, #3851, #3852, #3858).
  • SPIR-V input imports a storage block's Coherent and Volatile decorations, on the variable, the structure or any member, and its Restrict, NonWritable and NonReadable decorations, when the variable, the structure or every member carries them, as @coherent, @volatile, @restrict, a read-only StructuredBuffer and @writeonly. It used to drop all but a NonWritable on the variable, so a block whose members alone were non-writable, as CrossTL's own SPIR-V output decorates them, imported writable and HLSL output gave it a u register. GLSL output accepts a plain store into a writeonly storage buffer; it used to refuse it as requiring read-write storage (#3833, #3839, #3844, #3845).
  • HLSL, GLSL and Slang output declare a stage-scope variable whose type is a plain type alias, such as real scratch; for typedef float real;, as a private variable of the aliased type, also for an alias used as a vector element type or reached through a structure member. HLSL and GLSL output used to drop the declaration, so the body read an undeclared name, and Slang output declared it as a uniform (#3818).
  • A stage that names a gl_ built-in variable GLSL does not declare for that stage, such as gl_VertexID or gl_DrawID in a fragment stage, in its entry point or in a function it calls, and that the program does not declare itself, is refused with BuiltinValueUnsupportedError (project.translate.builtin-value-unsupported), as the same name as a member semantic already is. It used to be copied into GLSL, HLSL, Metal and Slang output, whose compilers reject it as an undeclared identifier (#3841).
  • SPIR-V input keeps the primitive, spacing, vertex-order and PointMode execution modes of a TessellationControl entry point, where DXC writes a hull shader's modes, as the @domain, @partitioning and @outputtopology attributes of the CrossGL tessellation_control stage, and SPIR-V output of a control stage without @domain writes the spacing, winding and point mode the stage declares. SPIR-V input used to keep only OutputVertices, so a round trip lost the modes (#3871).
  • GLSL and SPIR-V output of a tessellation stage, and the tessellation factors in HLSL output, read a bare identifier attribute argument such as @domain(tri) or @patchconstantfunc(Constants) by its name, as they read @domain("tri"). They used to compare it as a value, so the stage was refused or a triangle domain kept four outer factors (#3868).
  • SPIR-V output resolves a call to an overloaded function whose overloads are declared after the caller. It used to emit the caller first and refuse the call as neither a declared function nor a built-in (#3870).
  • Metal, WGSL and Slang output keep a specialization constant such as const int scale @constant_id(0) = 3; specializable with its id: Metal output declares a [[function_constant(0)]] and defines scale through is_function_constant_defined, falling back to the default, WGSL output writes @id(0) override scale: i32 = 3;, and Slang output [vk::constant_id(0)] const int scale = 3;. Constants computed from one follow the specialized value: WGSL output makes a dependent scalar an override and a dependent aggregate a var<private>, and Slang output keeps a foldable dependent int or bool constant static const. All three used to write an ordinary constant, which froze the default value and dropped the id (#3776, #3778, #3795).
  • Slang input imports [vk::constant_id(N)] and [SpecializationConstant] as @constant_id(N), giving each automatic constant the lowest id the explicit ones leave free, in declaration order, as slangc does. A misstated id, a static or non-const specialization constant, and a numthreads dimension that depends on one are refused with SlangImportRefused. Slang input used to drop both attributes, so every target fixed the constant at its default and lost its SpecId (#3792).
  • GLSL output raises #version to 430 core, or 310 es for GLSL ES, for a program with an array of arrays, such as float a[2][3], in a declaration, parameter, structure member, block instance or constructor, and keeps the version of a 4.20 program that enables GL_ARB_arrays_of_arrays; WebGL output, fixed at GLSL ES 3.00, refuses it with WebGLLoweringRefused (project.translate.webgl-lowering-unsupported). GLSL output used to keep a lower version such as #version 300 es, which glslang rejects (#3810).
  • Metal input lowers a scalar conversion of a structure, T(v), T{v}, static_cast<T>(v) or (T)v, through the structure's conversion operator also in a function template first instantiated from a member of a structure template, choosing the operator whose result type is T or else the only one, whose result it converts; an ambiguous or missing conversion is refused with MetalSourceOverloadResolutionError. It folds an argument-less call to a constexpr function template whose template parameters are all defaulted, such as get_bytes_per_pack(), in a static data member or constructor member initializer, and defines a helper reached from both a kernel and a template member once. It used to write a scalar constructor of the structure value, as in float(fp8{...}), to leave the call to the removed template in place and to define the helper twice, so the MLX block-scaled (mxfp4, mxfp8, nvfp4) matrix loaders compiled on no target (#2690).
  • Metal input folds __builtin_ctz, __builtin_clz and __builtin_popcount, and their l and ll forms, on a constant operand, as in constexpr short logN = __builtin_ctz(N); after template materialization, and leaves a zero operand to ctz or clz unfolded, as Clang does; such a specialization used to be refused with MetalTemplateSpecializationError. HLSL and GLSL output pass a row x[r] of a local float x[R][C] to a thread float* parameter as that row with offset 0 and extent C, and a view into the row, such as &x[1][0], with its offset; they used to refuse both with DirectXPrivatePointerParameterError and OpenGLPrivatePointerParameterError (reason missing-view-backing), because only a whole local array could back a view.
  • SPIR-V input types a bare OpTypeImage as Vulkan GLSL's separate texture type, such as texture2D, itexture2D or texture2DMS, read through a constructor such as sampler2D(tex, samp) at an OpSampledImage, and an OpTypeSampledImage as the combined sampler type, such as sampler2D, samplerCube or sampler2DShadow. It used to name both Texture2D, which is neither CrossGL type, so Metal output refused every texture operation as requiring a declared texture or image resource argument.
  • HLSL output records binary16 storage for any number of buffers that fits the 64 KiB limit of its resource-storage header, so a module with many entry points, such as 300 kernels with one half buffer each, translates, and a header over the limit is refused with DirectXHalfStorageError (project.translate.directx-half-storage-unsupported, reason resource-storage-contract-limit). It used to refuse a module with more than 256 such buffers with an untyped ValueError after generating the whole program.
  • CUDA, HIP, Slang, Rust, Mojo and WGSL output refuse a program that uses a cooperative matrix with CooperativeMatrixLoweringUnsupportedError (project.translate.cooperative-matrix-unsupported), which names every cooperative-matrix type and operation it uses. They have no lowering for one and used to write the CrossGL type, or the Python representation of the type or operation, into the program.
  • GLSL output pads a short array constructor whose size is a compile-time integer constant, as it pads a literal size: float[N](x) with const int N = 3; becomes float[N](x, 0.0, 0.0), and float[N][2](float[2](x, 1.0)) with N = 2 becomes float[N][2](float[2](x, 1.0), float[2](0.0, 0.0)). It used to copy the constructor with one argument, which glslang rejects with array constructor needs one argument per array element (#3811). A size set by a specialization constant is left as written.
  • GLSL output refuses an array constructor with more arguments than elements, such as a = float[1](x, 1.0);, in an assignment, a return, a call argument or a structure constructor, with OpenGLAggregateInitializerError (project.translate.opengl-aggregate-initializer-invalid), as it already did in a declaration. It used to copy it, which glslang rejects (#3710).
  • Metal output refuses the length() of a StructuredBuffer<T> or RWStructuredBuffer<T>, such as values.length() for StructuredBuffer<float> values, in an entry point or a helper, with BufferLengthUnsupportedError (project.translate.metal-buffer-length-unsupported), as it already does for a buffer float* view: a Metal buffer argument is a pointer and carries no size. It used to copy values.length() unchanged onto the device pointer, which the Metal compiler rejects as not a structure or union.
  • GLSL and HLSL output write the length() of an element of a structured buffer array, such as bufs[1].length() for StructuredBuffer<float> bufs[2], as bufs[1].data.length() and int(cgl_buffer_count(bufs[1])), as they do for a single StructuredBuffer<T>. They used to copy bufs[1].length() unchanged, which glslang rejects because length does not operate on a block and DXC rejects because StructuredBuffer<float> has no member named length (#3641).
  • Metal output refuses the length() of an AppendStructuredBuffer<T> or ConsumeStructuredBuffer<T>, and of an element of a structured buffer array such as bufs[1].length() for StructuredBuffer<float> bufs[2], with BufferLengthUnsupportedError (project.translate.metal-buffer-length-unsupported), as it does for a StructuredBuffer<T>. It used to copy the call unchanged onto the device pointer, which the Metal compiler rejects as not a structure or union.
  • GLSL output writes GetDimensions(count, stride) on a StructuredBuffer<T> or RWStructuredBuffer<T>, such as values.GetDimensions(n, s), as n = uint(values.length()), s = 4u: the element count, read as the buffer's length() is, less the element offset in a helper that takes the buffer, and the element's std430 array stride, 16 for a vec3. An element type whose std430 stride GLSL output does not know, such as a structure, is refused with OpenGLLoweringRefused. It used to copy the call unchanged, which glslang rejects with '.' : cannot apply to an array: GetDimensions, and wrote values[v_offset].GetDimensions(n, s) in a helper ('GetDimensions' : vector swizzle too long) (#3755).
  • GLSL output writes the length() of a StructuredBuffer<T> or RWStructuredBuffer<T> helper parameter, such as v.length() in int count(StructuredBuffer<float> v), as the length of the buffer the specialized helper reads less the element offset it is called with, (values.length() - int(v_offset)), and does the same for a buffer float* parameter or local view, so count(data + 2) counts the elements from data[2] on. It used to write values[v_offset].length(), the length() of one element, which glslang rejects (#3640).
  • HLSL output writes the length() of a buffer T* helper parameter, such as v.length() in int count(buffer float* v), as the element count of the buffer the helper receives less the element offset it is called with, (int(cgl_buffer_count(v)) - int(v_offset)), as GLSL output does, and does the same for a local view such as buffer float* p = data + 2;. It used to copy v.length() unchanged, which DXC rejects with no member named 'length' in 'RWStructuredBuffer<float>', and wrote p.length() for the local view, whose p HLSL output does not declare (#3759).
  • WGSL output writes the length() of an HLSL-style StructuredBuffer<T> or RWStructuredBuffer<T>, such as values.length() for StructuredBuffer<float> values, as i32(arrayLength(&values)). It used to copy values.length() unchanged, which naga rejects (#3582).
  • WGSL output writes the four-argument texture() with an explicit sampler and a bias, texture(t, s, uv, 0.5), which HLSL t.SampleBias(s, uv, 0.5) and Metal t.sample(s, uv, bias(0.5)) import as, as textureSampleBias(t, s, uv, 0.5), passing the layer of a 2D array or cube array texture as its own argument and converting an integer bias with f32(), as it does for texture(t, uv, bias). It refuses a bias in a vertex or compute stage with ImplicitLodStageUnsupportedError (project.translate.wgsl-implicit-lod-stage-unsupported), and a bias on a 1D or depth texture, through a comparison sampler, on an element of a sampled texture array selected at run time or that is not a scalar, and a four-argument call whose second argument is not a sampler, with WGSLTextureBiasUnsupportedError (project.translate.wgsl-texture-bias-unsupported). It used to refuse every such call with ValueError: WGSL target supports texture() calls with texture/coords or texture/sampler/coords arguments (#3584).
  • WGSL output converts the length() of a buffer T* storage buffer or a StructuredBuffer<T> to u32 where a uint is expected, as a variable's value, an argument or a return value, so uint n = values.length(); becomes var n: u32 = u32(i32(arrayLength(&values)));. It used to write var n: u32 = i32(arrayLength(&values));, which naga rejects (#3617).
  • WGSL output converts a negative integer literal to u32 as an i32: uint u = -1;, uint(-1), uvec2(-1, 2) and a uint member's value in U(-1, x) or U s = {-1, x}; are written u32(-1i), 4294967295 as in GLSL output. They used to be written u32(-1), which naga rejects because the abstract integer -1 has no u32 value (#3686).
  • WGSL output writes a scalar element of a matrix array constructor or initializer as the matrix with that scalar on its diagonal, as it writes mat3(s): mat4 n[3] = mat4[3](1.0); becomes array<mat4x4<f32>, 3>(mat4x4<f32>(vec4<f32>(1.0, 0.0, 0.0, 0.0), ...), mat4x4<f32>(), mat4x4<f32>()), the identity followed by zero matrices. It used to keep the scalar, as in array<mat4x4<f32>, 3>(1.0, mat4x4<f32>(), mat4x4<f32>()) or array(x, 1.0) for mat2 m[2] = mat2[2](x, 1.0);, which naga rejects (#3635).
  • WGSL output lowers a plain enumeration, whose variants carry no data, to one i32 constant per variant, as GLSL and Metal output write int constants: enum Mode { First, Second = 5, Third } becomes const Mode_First: i32 = 0;, const Mode_Second: i32 = 5; and const Mode_Third: i32 = 6;, a Mode value is an i32, and Mode::Second is Mode_Second. An enumeration whose variants carry data is refused with WGSLEnumUnsupportedError (project.translate.wgsl-enum-unsupported). Every program with a shader-scope enumeration used to fail with AttributeError: 'EnumNode' object has no attribute 'members' (#3687).
  • WGSL output writes a structure's brace initializer, such as Pair p = {x, 2.0};, as the structure's value constructor, var p: Pair = Pair(x, 2.0);, in a declaration, an assignment, a return value, a call argument, a shader-scope constant or variable, a nested member and an array of structures. Each value is converted to its member's type, as in Q(u32(1), i32(x)), and the members left out are set to zero as GLSL output does. An initializer with more values than members, or one for a structure that holds an atomic or a resource, is refused with WGSLStructInitializerError (project.translate.wgsl-struct-initializer-unsupported). It used to write array(x, 2.0), which naga rejects because the declared type is Pair (#3653).
  • WGSL output writes a vector's or a matrix's brace initializer as the type's value constructor: vec3 v = {x, 1.0, 2.0}; becomes var v: vec3<f32> = vec3<f32>(x, 1.0, 2.0);, and mat2 m = {vec2(1.0, 0.0), vec2(0.0, x)}; or {{1.0, 0.0}, {0.0, x}} becomes mat2x2<f32>(vec2<f32>(1.0, 0.0), vec2<f32>(0.0, x)), in the same places as a structure's, including a structure member, as in V(vec3<f32>(x, 1.0, 2.0), 3.0), and an array of vectors. A matrix takes one vector per column or one scalar per component. Each value is converted to the component or column type, as in vec3<f32>(f32(k), 1.0, 2.0), and the components a vector list leaves out are set to zero as GLSL output does. A list with more values than the vector has components, a non-scalar vector component, and a matrix list that is neither one vector per column nor one scalar per component are refused with WGSLVectorInitializerError (project.translate.wgsl-vector-initializer-unsupported). It used to write array(x, 1.0, 2.0), which naga rejects because the declared type is vec3<f32> (#3684).
  • An empty brace initializer of a scalar variable or constant, such as float one = {};, int n = {};, short s = {}; or real_t one = {}; for typedef float real_t;, which CUDA and HIP input import as var one: f32 = {};, is the scalar's zero on every target, as if the zero were written: float one = 0.0; in HLSL, GLSL and Metal output and var one: f32 = 0.0; in WGSL output. HLSL output used to copy {}, which DXC rejects, WGSL output to write array(), which naga rejects, and GLSL output to refuse the program with OpenGLAggregateInitializerError; SPIR-V output refused a half or 16-bit one, and Metal output wrote an 8- or 16-bit one as int(short({})), which the Metal compiler rejects (#3735).
  • A one-value brace initializer of a scalar variable or constant, such as float g = {1.0};, int n = {x}; or real_t g = {1.0}; for typedef float real_t;, at shader scope or in a function, is its value converted to the declared type on every target, as if float g = 1.0; or int n = int(x); were written, and so is a nested list such as {{1.0}}. A scalar's brace list with more than one value, such as float g = {1.0, 2.0};, is refused with ScalarBraceInitializerError (project.translate.scalar-brace-initializer-invalid). WGSL output used to write var<private> g: f32 = array(1.0);, which naga rejects, SPIR-V output an OpConstantComposite of float, which spirv-val rejects, Rust output [1.0], which rustc rejects, and GLSL output refused the program with OpenGLAggregateInitializerError; Metal, CUDA and HIP output copied the braces, which their compilers reject when the value narrows, as in uint u = {x}; for int x, and HLSL output dropped a longer list's values, writing float g; (#3760).
  • An empty brace initializer of a variable or constant of a plain enumeration, one whose variants carry no data, such as Mode m = {};, which CUDA and HIP input import as var m: Mode = {};, is zero: int m = 0; in HLSL, GLSL, Metal, Slang and HIP output and var m: i32 = 0; in WGSL output, also for an enumeration that names its type, such as enum Mode : uint, whose variables these generators write as int. HLSL output used to copy int m = {};, which DXC rejects, WGSL output to write var m: i32 = array();, which naga rejects, and GLSL output to refuse the program with OpenGLAggregateInitializerError. CUDA output keeps Mode m = {};, which C++ value-initializes to zero (#3752).
  • Rust output writes an empty brace initializer of a plain enumeration, such as Mode m = {}; for enum Mode { First, Second }, as the variant whose discriminant is 0: let m: Mode = Mode::First;. An enumeration with no zero-valued variant, such as enum Mode { First = 3, Second = 5 }, is refused with RustEnumEmptyBraceError (project.translate.rust-enum-empty-brace-unsupported), as is one whose variants carry data, such as enum MaybeInt { Value(int), Missing }. It used to write let m: Mode = [];, which rustc rejects (#3820).
  • WGSL output writes a declared array whose initializer gives fewer elements than the array has, such as float a[3] = float[3](0.0); or {x, 1.0}, as array<f32, 3>(0.0, f32(), f32()), with the elements left out set to zero as GLSL output does. It used to write array(0.0), a one-element array that naga rejects.
  • WGSL output zero-fills a short array constructor outside a declaration as well, in an assignment, a call argument, an index or a return value: a = float[3](1.0); becomes a = array<f32, 3>(1.0, f32(), f32());, and vec3[2](vec3(x)) becomes array<vec3<f32>, 2>(vec3<f32>(x), vec3<f32>()), as in a declaration. A constructor with more arguments than its size, and an empty one, are refused with WGSLAggregateInitializerError (project.translate.wgsl-aggregate-initializer-invalid). All three used to raise an untyped ValueError (#3638).
  • WGSL output refuses an array initializer with more elements than its declared array, such as float a[1] = {x, 1.0}; or float a[1] = float[1](x, 1.0);, with WGSLAggregateInitializerError (project.translate.wgsl-aggregate-initializer-invalid), which names the array type and both counts, as GLSL and HLSL output refuse it. This covers a declaration, an assignment, a return value, a call argument, a shader-scope constant, a structure member and an array of structures, and an array whose size is a constant, as in float a[COUNT]. It used to write var a: array<f32, 1> = array(x, 1.0);, which naga rejects (#3685).
  • WGSL output gives a shader-scope array variable's brace list its declared type, as it does for a local or a shader-scope constant: float g[3] = float[3](1.0); or float g[3] = {1.0}; becomes var<private> g: array<f32, 3> = array<f32, 3>(1.0, f32(), f32());, and a list longer than its array, such as float g[3] = {1.0, 2.0, 3.0, 4.0};, is refused with WGSLAggregateInitializerError (project.translate.wgsl-aggregate-initializer-invalid), as in a local declaration. It used to write array(1.0), a one-element array, and copy a long list as array(1.0, 2.0, 3.0, 4.0); naga rejects both because the declared type is array<f32, 3> (#3676).

The other 42 fixes are listed in CHANGELOG.md.