The Unreal work unrolled far more than dxc does: the IR unrolled any
small constant-count loop, and the DXIL unroller any loop of up to 256
trips. On Glide's GlimmerProbeTrace and GlimmerSHUpdate compiles took
10-17x longer and DXIL grew to 470 KB (dxc: 155 KB), so Glide's
replayed compiles took 2.7x as long as with main.
- the IR's automatic unrolling is gone again (it did little for Unreal)
- DXIL unrolls a loop only when unrolled it stays within 300
instructions, as dxc unrolls only small loops without [unroll]
- SCCP visits blocks in reverse postorder, so it settles in a few passes
Glide, against main (bb942b0): 24 threads 1.36 s vs 1.25 s, serial sum
13.2 s vs 11.8 s, DXIL 58.1 MB vs 61.4 MB. Unreal's corpus still
compiles, validates, and reflects no UAV dxc leaves out.
Every shader the editor compiles (11,488 recorded Compile calls) now
compiles, passes DXC 1.8's validator, and reflects bindings the engine
accepts; the editor runs with the D3D debug layer clean.
Front end and semantics:
- -HV 2016..2018 and 2021, with HLSL 2018's component-wise &&, || and ?:
- overload ranking with DXC's conversion costs (worst, then sum), where
intrinsics compete with user functions and templates; ref parameters
of intrinsics (Interlocked* destinations) match exactly
- template class methods checked on use; elaborated struct declarations;
struct fields before globals in methods
- layout of structs over 256 fields
DXIL backend:
- loops with a constant trip count unrolled after promotion (unroll.zig)
- sparse conditional constant propagation (sccp.zig)
- loops with no effects deleted; constant switches folded; float compares
of constants folded; phis read on the edge their branch's condition
decides; empty branches folded through chains of empty blocks
- unreachable blocks, unused groupshared, and resources no code uses any
more dropped; shader flags, PSV and handle properties from what is left
- 64-bit typed resources and atomics
Unreal Engine's D3D12 shader compiler needs DXC_OUT_REFLECTION and reads
every shader's parameters through ID3D12ShaderReflection; it also strips
parts with IDxcContainerBuilder and blobs through IDxcLibrary.
- The DXIL emitter builds the reflection with the object (dxil/reflect.zig):
bound resources, constant buffers with their variables and types, and
per-function data for libraries. A variable is marked used from the
optimized code, by the cbuffer components actually loaded, as DXC marks
them. Input signature usage is likewise taken from the optimized code.
- The drop-in returns it as DXC_OUT_REFLECTION, and IDxcUtils::
CreateReflection serves ID3D12ShaderReflection and
ID3D12LibraryReflection over it.
- New classes: DxcContainerBuilder and DxcContainerReflection; the utils
object also answers IDxcLibrary.
On the 65 test/dxil shaders, reflection printed through the D3D12
interfaces matches DXC 1.8's on 46; the rest differ in details clients do
not read (bitfield members, -Zpr matrix classes, resource order).
Windows (here, with Defender's on-access scanning) serializes opening
files: creating the corpus's 8,772 outputs takes about 1.8 s whatever
the thread count. The compile threads blocked on it, so --job barely
gained past 8 threads.
- A reading thread reads each job's input ahead of the compiles (at
most 256 jobs ahead), and a writing thread writes the outputs, in job
order, after them. An output that cannot be written is reported after
every job's output and fails its job.
- Files the jobs read through the compiler (headers) are cached for the
whole run, with misses remembered, so each is opened once instead of
once per job and include directory searched.
On the Glide corpus: compiles only, 13.6 -> 12.1 s on 1 thread and
2.75 -> 2.6 s on 24; preprocess and compile, 36.2 -> 17.1 s on 1 thread
and 7.3 -> 5.9 s on 24, which is about the time it takes to create its
17,544 output files. Outputs and diagnostics are identical to 0622292
on all 17,544 calls.
Every compile ran in an arena, where a growing list leaves each old
buffer behind, and a few sites dominated: the Glide corpus's 8,772
compiles allocated 38 GB. Now 24 GB:
- intrinsics: build the Db once per process and share it read-only
(it was rebuilt from the static table on every compile, 3.5 GB);
- parser: reserve the token list from the source size (5.2 GB of
regrowth), and collect name parts on the stack (25M allocations);
- dxil emit: reserve the function's instruction list in finish (5.0 GB);
- sema: reserve resolutions from the token count (1.0 GB).
zdxc --job on the corpus: 15.4 -> 14.3 s on 1 thread, 3.0 -> 2.65 s on
24. Output is byte-identical on a 1,462-compile subset.
valueType searched the prologue and every block for the instruction,
so lowering was quadratic in function size. On the Glide corpus it was
half of all samples in zdxc --job; with a type per id the corpus's
8,772 compiles take 15.4 s on 1 thread (was 21.6 s) and 3.0 s on 24
(was 7.4 s). Output is byte-identical on a 1,462-compile subset.
Freeing the arena after every Compile gave its blocks back to the OS
(smp_allocator maps 64 KiB and up directly), so each call faulted about
4 MB of fresh pages in again. On the Glide corpus's 8,770 compiles that
was 9.06M page faults and up to 28 s of kernel time; with the arena kept
(reset to at most 64 MiB) it is 0.4-1.0M, and the replay is 25% faster
on 1 thread, 30% on 8 and 16% on 24. Output is byte-identical.
GlimmerProbeTrace (Glide) still came out at 374 KB of DXIL against
dxc's 155 KB, with 130 allocas against 40. Most of the remainder:
by-value struct parameters copied out of the constant buffer at every
call (GlimmerGroundParams and GlimmerSpanParams, 32 i32s each), then
indexed dynamically, which pinned each copy in memory.
- Arguments loaded from a constant buffer are passed as the constant
buffer place itself, structs as well as arrays (not with matrices,
whose constant buffer access is narrower than a local's). Locals still
alias only within a block with no write since. The alias now comes
first in local_var lowering, so the skipped parameter store always
matches.
- Peepholes on promoted values: bitcast round trips (int/float mixing
locals store i32s), constant integer arithmetic and comparisons,
identities, selects on a constant. A constant out-of-bounds array
index this exposes (on a path that cannot run) becomes 0, since the
validator rejects it.
- Inlined callees' array locals return to a per-type pool on return,
for later callees to reuse.
- -Od and -zdxc-no-opt skip promotion, aliasing and reuse, as they skip
the SPIR-V IR passes.
GlimmerProbeTrace: 374 KB to 191 KB, 21 allocas, 282 bitcasts (from
7198). Its pipeline builds in 3.6 s on an RX 9070 XT (was 5.1 s). All
of Glide's 400 DXIL compiles: 5.91 MB (dxc: 6.11 MB), 7.1x faster than
dxc. All pass dxc 1.8.2505's validator, and Glide renders.
Locals were left as allocas, so every access was a store or a reload.
Glide's GlimmerProbeTrace came out as 2.3 MB of DXIL (DXC: 155 KB) that
AMD's driver took over ten minutes to build into a pipeline, and the game
stalled on a black screen.
- promote.zig: SROA + mem2reg over the finished function. An alloca whose
accesses are loads and stores through constant indices becomes one SSA
variable per element, with phis at the iterated dominance frontiers.
Trivial phis fold away, and dead instructions go. Locals read before
they are written read zero, since the validator rejects reads of undef.
- Dynamically indexed locals pin only what the index can reach. The
emitter records each dynamic getelementptr's range (the indexed array's
extent), and the rest of the local is still promoted.
- A by-value array parameter that the callee only reads aliases the
caller's storage when the argument was loaded from a local in the same
block with no write since. This drops the per-call copies.
- Declarations that lose their last call are pruned before writing, since
the validator rejects unused external functions.
On Glide's 400 DXIL compiles, total output goes from 34.5 MB to 6.8 MB
(DXC: 6.1 MB), and GlimmerProbeTrace from 2.3 MB to 374 KB. Its
pipeline now builds in about 5 s. All 400 objects pass DXC 1.8.2505's
validator (checked with a copy built to claim validator 1.8), and Glide
renders on zdxc.
- A constant buffer vector indexed at run time loads the whole vector and
selects the component.
- Resource arrays in libraries: globals of class arrays, mangled as
pointers to their element (as dxc); each access loads its element for
createHandleForLib. NonUniform indices put !dx.nonuniform on the
getelementptr, so the bitcode writer now writes metadata kinds and
instruction attachments.
- Array types in mangled names count their dimensions as dxc does.
- A resource local assigned different elements of one resource array keeps
the element's index and makes the handle where it is read.
markUses kept the array it marks in a static, which concurrent library
compiles under --job shared: one could mark into another's array, or index
past its own. Make it thread-local.
[branch] and [flatten] on if and switch were dropped: every
OpSelectionMerge had selection control None, leaving the driver to
flatten or keep the branch by its own heuristics. They now become
DontFlatten and Flatten, as in dxc (the Hyperion engine's shaders use
them 21 times). The IR keeps them on the header block; unrolling and
inlining carry them over.
ir/ssa.zig, after inlining:
1. A local struct or array accessed only whole and with constant
indices is split into one local per leaf member / element (scalar
replacement, up to 64 leaves): whole reads construct the value,
whole writes store each part. Promoting whole aggregates instead
made each member write a copy of the aggregate; on the Glide shader
that has many of them RADV then spilled ten times as many scalar
registers.
2. Locals loaded and stored only whole (no resources) become SSA
values: semi-pruned phi placement over dominance frontiers,
renaming over the dominator tree, trivial phis folded, dead phis
(cycles included) dropped. Reads before any write are the new IR
`undef` (OpUndef). Phis take one value per predecessor the emitter
writes, unreachable merge and continue targets included.
Constants that were behind locals fold afterwards. The SPIR-V emitter
emits OpPhi, patching operands emitted after the phi.
The inliner now works top-down from the entry points (each call gets a
copy of the callee's own body, whose calls are inlined as the scan
reaches them), copies only instructions in the callee's blocks (and
locals on first use), and remaps only instructions naming a call
result; scans use a non-allocating operand visitor (opt.eachOperand).
On Glide: loads 115040 -> 20322, stores 63644 -> 5832 (dxc: 11423,
2498), SPIR-V 12.0 -> 13.2 MB (callee bodies copied); compile time
587 -> 771 ms on 327 shaders (dxc: 8.6 s). Two more corpus files
compile (texel offsets that are constants once promoted).
dxc's SPIR-V gets its calls inlined by legalization; zdxc emitted every
function and left inlining to the driver, with 10361 calls across the
Hyperion engine's Glide shaders. ir/inline.zig now inlines bottom-up
before emission:
- The calling block is split at the call: it branches to a copy of the
callee, and the rest of the block (terminator and merge included)
moves to a continuation block. Parameters become the arguments.
- A callee with one return outside every construct branches from it to
the continuation. Returns inside selections or switches become
breaks out of a loop that runs once around the callee, the return
value going through a local.
- Callees that return from inside a loop, [noinline] ones, ones with
RayQuery or by-reference resource parameters, and ones returning a
resource from several places stay functions (resource arguments then
still get specializations).
- Functions nothing reaches any more are marked dead and not emitted.
Only modules with vertex, pixel and compute entry points and no
rasterizer-ordered views for now (the emitter treats the others'
functions specially). -Od and the new -zdxc-no-opt skip it; -zdxc-ir
prints the IR after the SPIR-V passes.
On Glide: 37 calls left; the SPIR-V grows (517k to 838k instructions,
callee bodies copied, one-trip loops) until promotion to SSA values
removes the locals; compile time 597 to 765 ms. The driver's own
statistics barely move, except one compute shader passing float4[28]
arrays by value, whose copies now take more scratch.
Loops the IR keeps (its unrolling gave up, or [loop] asked it not to)
lost their attribute: every OpLoopMerge had loop control None. The
driver now gets Unroll for [unroll] and DontUnroll for [loop], as from
dxc.
On the Hyperion engine's Glide shaders this is what made its half
resolution Glimmer irradiance pass about 5% slower than with dxc: an
[unroll] loop over a run-time count that RADV unrolls for dxc's output
stayed a loop for zdxc's (2381 instructions against dxc's 5765; now
5856).
A resource array element at a dynamic index (textures[i], bindless)
passed to a function failed: specializations re-create constant
elements only. The recipe now keeps dynamic index positions; the call
passes their values as extra arguments, the specialization takes them
as parameters and builds the access chain from them, and passes them
on to its own callees. A NonUniformResourceIndex selection stays
NonUniform in the specialization.
A resource local assigned different elements of one resource array
(tex = textures[a] in one branch, textures[b] in another) failed with
"assigning different resources to one variable". Such a local is now
kept as Function variables holding the indices: each assignment stores
them, each read loads them and re-creates the element. dxc emits an
OpPhi of images there, which spirv-val rejects, unless inlining folds
the branches away.
RAY_FLAG, RAYQUERY_FLAG, COMMITTED_STATUS, CANDIDATE_TYPE,
MEMORY_TYPE_FLAG and BARRIER_SEMANTIC_FLAG were declared as uint
typedefs in Sema but unknown to the parser, so `const RAY_FLAG f = ...`
failed with "unknown type name".
A function-local static whose initializer reads another local static
(static const int n = min((order + 1) * (order + 1), 9)) failed with
"this variable is not supported yet": initializers are lowered in
functions of their own, where the other static is not a local. It is
its private global there, as a file-scope static is.
dxc's option parser skips spaces after an option name, so a separate
option given as "-HV 2021" in a single argument is "-HV" with value
2021 (programs calling IDxcCompiler3::Compile pass it that way).
zdxc rejected it as an unknown argument. "-HV2021" stays an error, as
in dxc.
zig build dropin installs the command line as bin/dxc and builds
dxcompiler (libdxcompiler.so / .dylib, dxcompiler.dll) exporting
DxcCreateInstance and DxcCreateInstance2. It implements IDxcCompiler3,
IDxcVersionInfo and IDxcUtils over compile, with DXC's result shapes,
status codes and include-path spellings, so programs that load DXC's
library (SDL_shadercross, for one) run on zdxc unchanged.
compile.Request gains compat_notes, off for the drop-in: its clients
read any diagnostic text as a warning.
include/zdxc.h: compile a dxc command line in memory and read the
outputs (object, diagnostics, -P, -Frs) from a result; an optional
callback serves the input and #include files. No global state, so any
number of threads can compile at once. zig build installs libzdxc.a
(-Dlinkage=dynamic for a shared library) with the compiler runtime
bundled and only the zdxc_* symbols visible. docs/c-api.md describes it.
The pipeline moves from main.zig into compile.zig, which returns its
outputs instead of writing files; the command line and the C API both
use it, and produce the same bytes. The executable's build step is now
zdxc-cli so that artifact("zdxc") names the library; it still installs
as bin/zdxc. Writing an output file now fails with a message instead of
an error trace.
Compile every shader a JSON job file lists in one process, on all cores.
Each job is a dxc command line; shared args come first. Outputs are
byte-identical to separate runs and each job's diagnostics print together
in job order. 1481 corpus shaders: 0.064 s, against 1.09 s for one zdxc
per shader on 10 cores and 1.68 s for dxc.
Also: an unreadable input exits 1 as in dxc (was 5), and stdout/stderr
write in streaming mode so `2>> log` appends instead of overwriting.
The bitcode writer found an instruction's value ID by counting the
non-void instructions before it, for every operand: quadratic in the
function's size. Large functions (unrolled loops, -O0 hull shaders) took
up to 190 ms; the IDs are now computed once per function. Output is
byte-identical; SubD11_SubDToBezierHS4444 goes from 192 ms to 10 ms
(dxc: 64 ms).
Writing some components of a vector or matrix in an RW structured
buffer or groupshared memory read the whole value and wrote it all
back, racing with other threads writing the other components. Those
stores now write only the named components, as dxc does. Matrix rows
and elements of buffer matrices (W[i][1][2] = x, B[i].m[r] = v, at
constant or dynamic rows) are stored element by element instead of
being rejected.
SPIR-V arrays with the same element, length and stride are now one
type, so buffers of the same element share their runtime array.
-Zpr and #pragma pack_matrix were accepted but ignored, so row-major
matrices silently got the column-major layout. Now, as in dxc:
- #pragma pack_matrix sets the orientation of matrices declared after
it and may come between any two tokens; typedefs keep theirs.
- -Zpr is the default for matrices with neither; -Zpc is accepted and
the two together are an error.
- Entry parameters take an orientation written on them or the
pragma's, not a typedef's (dxc's signatures lose that sugar).
- Structured buffer matrix elements follow -Zpr only in DXIL; in
SPIR-V they take the template argument's orientation too.
Types declared in structs, template ones included, are accepted as the
last part of a qualified type name (TO<float>::In), which the parser
lost with the template's scope. typedef members are reported in struct
templates too (at the definition, as dxc), while alias declarations
(using F = float;) are allowed in any struct, as in dxc. Each HLSL
struct gets a module type of its own: struct types are named, and
same-named structs (two instances' nested In, or a ConstantBuffer<S>
class type and S) shared one layout, which crashed dxv.
Structs and enums remember their enclosing namespaces and structs, and
struct template instances their name and arguments, so mangled names
spell them as dxc does: U/V for struct/class, ?$Name@<args>@ for
instances (type arguments, $0<n> and $0?<n> integral ones, with names
of their own), each enclosing scope after the name, with back-references.
Exported functions whose signature holds a resource or matrix handle get
dxc's error instead of an invalid module.
[noinline] plain functions in libraries become internal functions of
their own (noinline nounwind) instead of being inlined, passed values as
exported functions are: scalars and vectors by value, structs and out /
inout values by pointer (through temporaries at the call). RDAT lists
them, and each function's shader flags, minimum shader model and stage
mask merge in its callees' (dxc's ComputeShaderCompatInfo), as do the
LinAlg extended properties. Functions with resources, matrix handles,
arrays, matrices or groupshared parameters are still inlined (the
validator rejects resources, LinAlg matrices included, in signatures).
Write each library function's RDAT ExtendedProperties the way dxc's
AddLinAlgFunctionProperties does: matrix constructions with their
operation shapes, thread mat-vec multiplies, wave and thread-group
matrix multiplies, outer products and accumulating stores, merged from
callees, in the extended property record tables (part types 13-20)
with record deduplication. Removes the library LinAlg gate.
- Resource locals may be declared without an initializer (an alias of
what is stored into them; reading one first is reported).
- DXIL: inlined calls write out resources into the caller's alias; a
resource written back to the global it is is a no-op.
- SPIR-V: out / inout resource parameters leave the parameter list (an
inout one's value comes in by value); the callee works on a local and
what it holds at the end is traced to a parameter or global, which the
caller stores into the argument after the call.
- An acceleration structure that is only declared gets the ray query
capability its type needs.
- DXIL: a local array of resources (a parameter's copy) aliases the
resource array stored into it; elements index that array.
- SPIR-V: a whole resource array read to pass on stays its variable, so
the callee is specialized on it; arrays read whole are not flattened
(their bindings are still numbered per element), which also lets
global structs holding resource arrays be passed to functions.
- An IR pass for SPIR-V splits structs holding resources: resource
members of locals become resource locals, struct values carry their
resources alongside (construct / extract / insert / load / store),
parameters holding resources (by value or reference, including
`this`) gain a resource parameter per member, and functions returning
resources return the parameter or global they trace to.
- Struct values in SPIR-V leave resource members out.
- Arrays of global structs of resources: an element per resource
variable named by flattened index (globals[5].t), and the whole struct
reserves one consecutive binding range, as dxc numbers them.
- DXIL: structs and arrays holding resources as values (data plus the
resources, statically known) and as locals (data in memory, a
resource slot per member): copies, nested structs, arrays, init lists,
function arguments and returns, and functions returning resources.
- Global structs with resources: each resource is its own global named
by its path (g.tex), bound like other unbound resources; data members
stay in $Globals with resources taking no space in the layout.
- SPIR-V: struct types drop resource members (member indices remapped);
a global struct of textures and samplers gets a binding per resource
and turns on per-element array bindings, as dxc does; dxc's errors
for structs with buffers or mixed members.
- LinAlg vectors of one element stay native vectors.
- vector<T, N> with N up to 1024 from shader model 6.9 (vector lengths
and shapes widen to u16); intrinsic layouts accept long vectors.
- DXIL keeps the scalarized form: buffers, groupshared memory, structs,
intrinsics and LinAlg vector operands work for any length.
- dxc's diagnostics: no swizzles on long vectors, and none in cbuffers,
tbuffers, $Globals, ConstantBuffer/TextureBuffer, patches, streams or
entry point parameters / return types.
- SPIR-V reports long vectors as unsupported (Vulkan has none; dxc's
output is invalid).
- __builtin_LinAlgMatrix [[__LinAlgMatrix_Attributes(c, m, n, use,
scope)]] as a type; matrices live in locals, statics and structs as
matrix-typed allocas (as dxc -Od); !dx.targetTypes.
- All 21 dx::__builtin_LinAlg_* builtins lowered to DXIL ops 322-342
with dxc's overload names (matrix, native vector and scalar operands;
results stored to the out / ref argument).
- The LinearAlgebra shader flag; PSV0 LinAlgRuntimeInfo (constructions,
multiplies, outer products, accumulate stores), byte-identical to dxc
where matrix loads are traceable.
- groupshared parameters alias the caller's variable (they were copied);
constants forwarded through locals within a block (immediates through
parameters); enum static consts folded.
- Linear algebra in libraries (RDAT properties) and long vectors are
reported as not supported yet.
- A spirv type kind: opcode with type, constant and literal operands
(vk::integral_constant, vk::Literal), sized (SpirvType) or opaque.
Integer, float and pointer types map to zdxc's own; others are
declared as spelled and deduplicated. Capabilities and extensions on
aliases, fields and declarations travel with the type.
- vk::WorkgroupSpirvPointer and other inline pointers are values, never
variables; passing one to a function adds VariablePointers (dxc
inlines the call instead).
- __builtin_spv_CooperativeMatrixLengthKHR; template argument deduction
through aliases of inline types and qualified patterns; function
template instances keep their arguments.
- [[vk::ext_literal]] defaults, constants resolved where Sema saw them,
static members through objects, enum-typed values in SPIR-V.
- [[vk::ext_decorate(_string)]] on struct members; capabilities from
inline SPIR-V add the extensions they need; PhysicalStorageBuffer64
addressing with physical storage buffer pointers.
- All vk::khr::CooperativeMatrix tests compile to valid SPIR-V.
- Qualified names through template instances (S<T>::x, S<T>::f(),
typename S<T>::type).
- Partial specialization patterns matched structurally
(matrix<T, N, M>, S<T>); the injected class name inside instances.
- Member function templates (obj.f<T>(), S::f<T>()), including calls
from other members; S::f<1>(x) parsed as a call.
- SFINAE: candidates whose signature fails to substitute are dropped;
a declared-then-defined template uses its definition.
- Out-of-line member definitions, for plain structs (keeping static),
namespaces and class templates (given to every instance), including
nested template<> template<> member templates.
- Deduction from resources (RWStructuredBuffer<T>), through alias
templates and from the injected class name; argument-dependent lookup.
- static const members evaluated in their instance's scope; sizeof(T)
in template arguments; ::template; instantiation depth limit.
- -fspv-use-vulkan-memory-model: a port of spirv-opt's UpgradeMemoryModel
(Coherent / Volatile become access flags, Device scope becomes
QueueFamily); also used when ray tracing reads subgroup built-ins
below Vulkan 1.3, as dxc does.
- Rasterizer-ordered views: SPIR-V fragment shader interlock around the
entry; DXIL ROV metadata, properties, RDAT flag and shader flag.
- globallycoherent: SPIR-V Coherent; DXIL metadata, properties, RDAT.
- -fspv-use-legacy-buffer-matrix-order: row-major byte-address matrices.
- -fspv-preserve-interface accepted (zdxc keeps every interface variable).
SubpassInput / SubpassInputMS with [[vk::input_attachment_index]] (a
SubpassData image read at (0, 0), with the sample for MS). Explicit
[[vk::image_format]] on storage images and texel buffers, followed from
the variable to every load and element access.
Inline SPIR-V: calls of [[vk::ext_instruction(op[, set])]] functions emit
the instruction (OpExtInst for a set) with [[vk::ext_literal]] and
[[vk::ext_reference]] operands; vk::ext_result_id<T>; ext_capability /
ext_extension on functions, variables and entry points;
ext_builtin_input / ext_builtin_output variables; ext_storage_class;
ext_decorate, ext_decorate_id and ext_decorate_string on variables and
entry parameters; vk::ext_execution_mode(_id). The capabilities and
extensions instructions, builtins, decorations and execution modes need
come from a table generated from the SPIR-V grammar.
-fspv-reflect adds SPV_GOOGLE UserSemantic, UserTypeGOOGLE and
CounterBuffer decorations; -fspv-extension= restricts the extensions
used (KHR allows all KHR ones; the NV compute derivatives extension is
used when only it is allowed); -fspv-entrypoint-name= renames the entry
point; -fspv-enable-maximal-reconvergence; -fvk-support-nonzero-base-
instance / -vertex subtract the base instance / vertex as dxc does;
-fspv-use-unknown-image-format. [[vk::builtin(...)]] on parameters and
fields (PointSize, HelperInvocation, BaseVertex, BaseInstance, DrawIndex,
DeviceIndex). Constant buffer block types are named type.<buffer> only.
-fvk-use-gl-layout (strict std140 / std430), -fvk-use-dx-layout (FXC
cbuffer / structured buffer packing) and -fvk-use-scalar-layout pick the
constant buffer, tbuffer and structured buffer rules as dxc picks them;
[[vk::offset]] places members (and is checked against the rules).
-fvk-invert-y flips SV_Position.y in the last pre-raster stage;
-fvk-use-dx-position-w reciprocates SV_Position.w in pixel shaders.
Constant buffer members honor packoffset / register(cN) on both
backends, the rest following the last explicit member (as dxc; DXIL used
to ignore them). Packed structs round their size up to their widest
component, so structured buffers of {double; float3} have dxc's 24-byte
stride on both backends (was 20). 64-bit structured buffer loads and
stores before SM 6.3 go through i32 words (bufferLoad / rawBufferLoad
.i32 with makeDouble / splitDouble), as dxc; they used invalid 64-bit
overloads before.
SPIR-V descriptor bindings are numbered as dxc numbers them: Sema keeps
global and cbuffer declarations in order, lowering records every
descriptor declaration (used or not), and the backend assigns
[[vk::binding]] / [[vk::counter_binding]] first, then register() with the
-fvk-{b,t,s,u}-shift options, then the rest on the next free bindings in
declaration order (Append / Consume counters right after their buffer,
other counters last). Adds -fvk-bind-register, -fvk-bind-globals,
-auto-binding-space, -fvk-auto-shift-bindings, -fvk-stage-io-order and
-fspv-flatten-resource-arrays (one variable per element where indices
are constant), [[vk::push_constant]] buffers (std430, PushConstant),
[[vk::constant_id]] specialization constants, [[vk::location]] and
[[vk::index]], interface variables named after the semantic as written,
and location counts for 1xN / Nx1 matrices. -fcgl is accepted.
Against dxc on the corpus, bindings and locations now match on all 1234
comparable SPIR-V outputs (865 differed before). The SPIR-V checks now
compare bindings and locations with dxc for every test.
[RootSignature(...)] on an entry compiles (global mode, version 1.1 or
-force-rootsig-ver) into an RTS0 part after PSV0; errors are reported as
dxc reports them. Libraries' GlobalRootSignature / LocalRootSignature
subobjects carry their serialized root signature in RDAT's raw bytes.
-T rootsig_1_0 / rootsig_1_1 compile the macro -E names into a root
signature container; -rootsig-define, -Frs and -Qstrip_rootsignature
are supported. All 49 corpus shaders with root signatures match dxc's
RTS0; the DXIL checks now compare RTS0 as well as RDAT.
A port of dxc's root signature parser, verifier and serializer (versions
1.0 and 1.1, local / global modes): text to the RTS0 blob, with dxc's
error messages. Checked byte for byte against dxc on 409 accepted
signatures, and on 307 rejected ones for the same errors. Not wired in
yet.
Vertex, pixel, geometry, hull, domain, mesh and amplification shaders in
libraries: entries carry their signatures (without usage masks, as dxc)
and stage state; hull shaders' patch constant functions are defined under
their mangled HLSL names. Library functions are defined in declaration
order, as dxc defines them, so RDAT records come in the same order.
Prerelease shader model libraries (experimental RDAT) are reported as
unsupported.
Exported functions become definitions of their own: scalars and vectors
by value (vectors split with extractelement / rebuilt with insertelement),
structs and out / inout values by pointer, with dxc's mangled names (type
and name back-references), function annotations (qualifiers, component
types, semantics) and RDAT records as library functions.
-enable-16bit-types now reaches the DXIL backend: the native 16-bit data
layout and the UseNativeLowPrecision flag (feature NativeLowPrecision
instead of MinimumPrecision). 16-bit isinf / isnan / isfinite / isnormal
test the bits before SM 6.9, as dxc does.
State object config, exports associations, shader / pipeline configs and
hit groups declared in a library become RDAT subobject records (root
signature subobjects still need a root signature compiler).
Libraries emit each entry as a function of its own: ray tracing shaders
with Microsoft-mangled names taking payload / attributes / parameters by
pointer, compute shaders by name. Resources become external globals
whose handles come from createHandleForLib (annotated from SM 6.6) in the
functions that use them; unbound ones stay at -1 until linked. Adds the
ray tracing operations (TraceRay, CallShader, ReportHit, IgnoreHit,
AcceptHitAndEndSearch, system values), library metadata (function
annotations, entries by name with payload / attribute sizes), and the
RDAT part, built as dxc builds it: per-function flags, valid stages and
minimum shader model come from the emitted instructions and a table of
dxc's per-operation requirements. Libraries without shaders are empty, as
in dxc. The DXIL checks compare RDAT with dxc's byte for byte.
RayQuery locals allocate their query in the prologue on first use (copies
alias it); methods lower to dx.op.rayQuery_* (TraceRayInline, Proceed,
commits, and the scalar / vector / matrix state reads). Acceleration
structures are SRVs of kind 16 (raw in PSV); using RayQuery sets the
Raytracing tier 1.1 shader flag.
[[vk::shader_record_ext]] / [[vk::shader_record_nv]] ConstantBuffers and
cbuffers become ShaderRecordBufferKHR blocks (std430, no descriptor),
listed only in the interfaces of entries that use them. Builtins that
change during a ray tracing invocation are Volatile from SPIR-V 1.6.