You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
16-bit and 64-bit types. With CompileOptions.Enable16BitTypes (DXC's -enable-16bit-types; MSBuild OneShaderEnable16BitTypes, item metadata Enable16BitTypes, CLI -enable-16bit-types) half, min16float, min10float, min16int, min16uint and float16_t/int16_t/uint16_t (vectors and matrices) are native 16-bit types, in arithmetic and in buffers with DXC's byte layout; without it the 16-bit names other than half/min* are error OSH0360, and the min-precision types are 32-bit values marked RelaxedPrecision on SPIR-V, as DXC does. double, int64_t and uint64_t work on SPIR-V in arithmetic, buffers, asdouble, asuint(double, lo, hi) and 64-bit Interlocked* on structured buffers and group-shared memory. A double argument to a float-only intrinsic (floor, sqrt, ...) is narrowed to float as DXC does, with the new warning OSH0361. Unsuffixed float literals keep double precision until they meet a concrete type. Constant folding is exact at each width.
MSL: native half, short, ushort, long and ulong; double, 64-bit integer vectors in buffers and 64-bit atomics other than unsigned InterlockedMax/InterlockedMin without a used result (the only form Metal 2.4 has) are errors at the first use (OSH5102) that say what to change. WGSL: half is f16 with enable f16; (16-bit values in buffers are read and written as halves of 32-bit words; stores use atomic and/or on the word so neighbours written by other invocations are not disturbed); 16-bit integers, double and 64-bit integers are errors at the first use (OSH5202). A refusal is an error only when that target is selected.
Reflection: EntryPointInfo.RequiredFeatures (DeviceFeatures: Float16, Int16, Float64, Int64, StorageBuffer16, UniformBuffer16, PushConstant16, InputOutput16, Int64Atomics; the serialized entry record gets an optional features child). EntryLayout.RequiredFeatures and PipelineLayout.RequiredFeatures; PipelineLayoutInfo.RequiredFeatures (the Vulkan device features to enable); WebGpuPipelineLayout.RequiredFeatures lists shader-f16. Generated entry classes get a RequiredFeatures constant beside SubgroupOperations, and the generated Layout carries it.
Default vertex formats for 16-bit inputs: Float16x2/Float16x4, Sint16x2/Sint16x4, Uint16x2/Uint16x4.
Pipeline layout helpers (OneShader.Layouts), additions only. PipelineLayout.TryCreateUnion builds one layout for any number of entry points, several per stage; resources at one slot that agree merge with united stages, disagreements are a LayoutError naming both entry points and the slot, and push-constant blocks merge into one covering range when their overlapping members agree (EntryLayout.PushConstantType, WithPushConstantType). Entry points compiled from different files that disagree on a Metal index or WebGPU push slot are reported by TryToMetal/TryToWebGpu. VulkanLayoutOptions and WebGpuLayoutOptions gain stage widening (WidenSets/WidenGroups, WidenBindings, WidenPushConstants) and dynamic offsets by slot (DynamicBindings; WebGPU also DynamicBuffers); ResourceLayout.DynamicOffset, DescriptorSetLayoutBindingInfo.IsDynamic and BindGroupLayoutEntryInfo.HasDynamicOffset expose the flag. EntryLayout.TryWithVertexOverrides / VertexLayout.TryWithOverrides apply the host's stride, and per-location format and offset, checked against the shader's input type (LayoutErrorKind.InvalidVertexInput); Vulkan, Metal and WebGPU vertex descriptions follow. TryToMetal also reports two resources of one stage that take the same Metal index.
Specialization constants. [[vk::constant_id(N)]] const <bool|int|uint|float> Name = <default>; becomes each target's pipeline-time constant, so one compiled shader serves many variants without recompiling. SPIR-V: OpSpecConstant/OpSpecConstantTrue/False with SpecId N, the ids DXC writes for the same source. MSL: constant T Name [[function_constant(N)]], read through is_function_constant_defined with the default as the fallback. WGSL: @id(N) override Name: T = default;. Optimization never folds a specialization constant to its default; code derived from one (including static const initializers) is ordinary code that runs per pipeline. Mistakes are errors at the HLSL line: a duplicate id, a vector or struct type, static, a missing or non-constant default, a negative id (OSH0335); an array size, [numthreads] argument or case label that uses one says why it is refused (OSH0310), as DXC refuses the same uses.
Reflection: ShaderReflection.SpecConstants (SpecConstantInfo: name, id, scalar type, default bits and value, a SpecConstantSlot per target with the SPIR-V SpecId, the Metal function-constant index and variable, the WGSL @id and override name) and EntryPointInfo.UsedSpecConstants. The serialized form gets spec and specuse records, written only for shaders that have constants; the command-line tool's JSON gets specConstants and usedSpecConstants likewise. InterfaceCompatibility reports a removed constant or a changed id or type (InterfaceDifferenceKind.SpecConstant); new constants and changed defaults stay compatible.
OneShader.Layouts: SpecializationValues (from EntryLayout.SpecConstants; typed Set, plain data) converts to Vulkan VkSpecializationInfo contents (Layouts.Vulkan.SpecializationInfo: map entries and the data block), Metal function-constant values (Layouts.Metal.FunctionConstantValue: index, MTLDataType number, bits) and the WebGPU constants record keyed by decimal id. EntryLayout gets SpecConstants.
Generated code: SpecializationConstants.<Name>.Id/Default constants, a blittable Specialization struct (one 4-byte field per constant, Defaults, ToVulkan/ToMetal/ToWebGpu) and SpecConstantIds on every entry-point class that reads constants; the entry's Layout carries them. In a variant file each variant class has its own SpecializationConstants and Specialization (a constant may exist in only some variants), and the aggregate entry class has SpecConstantIds for the variant it was looked up in.
CompileOptions.SpecializationOverrides fixes chosen constants at compile time: they become plain constants, get folded, and leave reflection. A value that does not fit the type is error OSH0335; an unknown name is warning OSH0335.
Metal note: a function that declares function constants cannot build a pipeline state as it is, even when every default is wanted; create it with makeFunction(name:constantValues:) (an empty MTLFunctionConstantValues selects the defaults).
Shader variants in the build package. A OneShader item takes Axes="ALPHA_TEST;LIGHTING=NONE|LAMBERT|PBR" (flags and choices; the cartesian product is compiled), or OneShaderVariant items name hand-picked define sets. One compile per variant per selected target, in parallel; only variants whose define set, shader, includes or options changed are recompiled. More than 64 variants is error OSH0905 (raise it with MaxVariants / OneShaderMaxVariants); malformed declarations are OSH0904 and OSH0906. An error that happens under some variants is reported once on the HLSL line with the define set ((variant ALPHA_TEST=1, LIGHTING=PBR)).
Generated code for a file with variants: Key (one property per axis, enums for choices), Variants.Get(key) returning a Variant with an Entry per entry point (SpirV, Msl, Wgsl, Layout, ...), Bindings and Pipeline per variant, and a static class per variant shaped like a single file's class. Constant-buffer, push-constant and vertex structs are generated once when all variants agree on the layout, per variant when they differ. Files without variants generate exactly the same C# as before. See docs/generated-bindings.md.
A file listed explicitly as a OneShader item (to give it metadata) is no longer added a second time by the default **/*.hlsl glob.
ShaderCompileCache (RecursiveAI.OneShader): thread-safe, bounded compile cache keyed by source, path, options and the content of the includes the compile read; concurrent calls for one key compile once; Clear() empties it.
The build task logs OneShader: N compiled, M up to date. at low importance (-v:d).