Skip to content

dasSpirv: base value/vector/matrix/swizzle emit machinery - #3522

Merged
borisbat merged 3 commits into
GaijinEntertainment:masterfrom
olegus8:pr/spirv-core
Jul 21, 2026
Merged

dasSpirv: base value/vector/matrix/swizzle emit machinery#3522
borisbat merged 3 commits into
GaijinEntertainment:masterfrom
olegus8:pr/spirv-core

Conversation

@olegus8

@olegus8 olegus8 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

This is the first in a small stacked series that fills out the dasSpirv
daslang → SPIR-V emitter. It adds the general-purpose base machinery —
the scalar / vector / matrix / struct value core that the later layers
(resource & stage bindings; the fp16/int16/fp64 lattice lowering) build on.

What it adds

  • Struct value types — a struct used as a local var (its own
    Function-storage OpVariable), as a function parameter and as a function
    result (OpFunctionParameter / return), undecorated; field reads lower to
    OpCompositeExtract (or through the local's pointer). A declared local
    zero-inits via OpConstantNull.
  • Matrix constructors & productsfloatCxR(col0..colN) builds a matrix
    from its columns in one OpCompositeConstruct; a column read m[i] is an
    OpCompositeExtract; and the three products stay distinct —
    OpMatrixTimesVector (m * v), OpVectorTimesMatrix (v * m),
    OpMatrixTimesMatrix (m * m). A module-scope const-column let matrix
    folds to OpConstantComposite.
  • Write-swizzle lvaluesg.xyz = v lowers to load / OpVectorShuffle /
    store.
  • Whole-vector equalityvec == vec / vec != vec reduced through
    OpAll / OpAny rather than a scalar compare.
  • Bit-cast intrinsicsintBitsToFloat / floatBitsToInt &co →
    OpBitcast; mod / fmodOpFMod; plus const arrays and vector
    index / shift.

Compiler fix (src/ast/ast_inline.cpp)

A bare (non-R2V) variable reference is an lvalue — a reference to
storage, and storage identity is stable for both a local and a global — so
it is inline-pure; only a global's value read (the R2V case) can change
mid-inline and is snapshotted (kept impure). Without this, a global array
being indexed inside an inlined call hoists into a local dynamic-array temp,
which the SPIR-V backend cannot represent.

Tests (tests/spirv)

Value structs & local structs, matrix constructors & products, write-swizzle,
whole-vector compare, bit-cast, fmod, const arrays, vector index / shift,
plus fail-closed fixtures (a non-constant matrix column index; a nested local
struct var). All are spirv-val-clean where spirv-val is available in CI.

Follow-ups in the stack

Resource & stage bindings (samplers, storage images, SSBOs, descriptor
arrays, subgroups, inline ray-query, workgroup size, fragment barycentrics,
mesh output), then the fp16 / int16 / fp64 lattice lowering.

…owering of a[i]) so value-composite indexing compiles under JIT
@borisbat
borisbat merged commit 50493b6 into GaijinEntertainment:master Jul 21, 2026
35 checks passed
borisbat added a commit that referenced this pull request Jul 21, 2026
dasSpirv: resource & stage bindings (stacked on #3522)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants