Table of Contents
Threads
What may be shared
| Object | May be shared between threads? |
|---|---|
| Definitions | Yes. Definitions may be made, removed and read in any thread: each is made under a lock, and a compilation reads them as they were when it started, so programs may be compiled in several threads at once. The programs kept are kept for every thread, under the same lock. |
program |
Yes. A compiled program never changes. The vector program-spirv returns is the program's own, the same at each call: read it, and copy it to change it. |
vertex-input, uniform, resource, program-binding, slot-layout |
Yes. They never change. |
The buffer pack-uniforms or pack-value writes |
No: it is the caller's, and belongs to one thread at a time. |
Targets, such as :vulkan's |
Yes. A target never changes. |
| The SPIR-V grammar's tables, the IR's operation table | Yes. They never change once loaded. |
| An IR module and everything in it: its types, values, functions and blocks | No: one thread at a time. |
An IR builder |
No: one thread at a time. |
A SPIR-V module of clsl/spirv |
No: one thread at a time. |
| The generator's grammar model | Yes. It never changes once read. |
Modules may be translated into SPIR-V in several threads at once, each its own.
Global state
The definitions are the one global state clsl keeps: a registry of what
define-function and its kin define, which exists once per image by nature,
as the image's functions do, with the programs compile-program compiled from
them, a cache keyed by the definitions each was compiled from. Nothing in
clsl needs setting up again when a saved image starts.
A uniform of define-uniform is a special variable. pack-uniforms writes it
as the thread that packs sees it, so a thread may let-bind it to pack its
own value, as for a camera of its own.
Every frame
What a frame loop calls allocates nothing:
definitions-generationandprogram-stale-p, which say whether a program needs compiling again;pack-uniformsgiven a:buffer, andpack-value, given doubles and float pairs as double-floats, vectors and matrices of them as vectors of double-floats, and complex numbers of doubles as(complex double-float)values;dfloat-partsof a single-float, or of a double-float of a magnitude from 2^-70 to the floats' largest.
Compiling allocates, as it makes a program: compile a program once, and again
when program-stale-p says a definition it uses has changed, and read what a
pipeline needs of it when the pipeline is made.