eval::Program

An immutable compiled expression program, produced by an eval::Graph.

Declared in src/libs/libeval/eval/Program.hpp
Group eval

Detailed description

A Program holds the compiled state of one eval::Graph: the slot bindings, and the lane that runs them. After compile() it does not change. Callers look up slot handles once with input() and output(), set inputs, call evaluate() and read the outputs.

Several threads can share one Program. Each worker holds its own ThreadCopy for input and output scratch, so no synchronization is needed. lowering() reports which lane actually ran, which can differ from the backend() that was asked for.

See also eval::Graph, eval::evaluate().

Member function documentation

lowering

eval::Program::Lowering Program::lowering() const

Returns the lowering that actually runs this program, as opposed to the backend that was asked for.

Every lowering goes through glslang to SPIR-V. The value says what runs the SPIR-V: the interpreter, the in-memory LLVM JIT, or a GPU dispatch. A default-constructed Program has no lane and returns Lowering::None.

See also spirvDisassembly().

setMat4

void Program::setMat4(eval::Handle h, const QMatrix4x4 &m)

Binds m to the input slot that h names, as a mat4 in column-major order. Does nothing when h names no slot.

`setMat4`/`getMat4` were STUBS, and a stub setter is worse than a missing one: `setMat4` accepted a matrix and dropped it, so a caller binding a `mat4` input got the zero matrix and no diagnostic, and `getMat4` answered the default-constructed identity for every output.

Matrices have read and written correctly through `Program::get()`/`set()` as a column-major `QVariantList` since Phase 5d — these two typed convenience overloads were left behind and nothing noticed, because the only caller in the tree is `testEvalUnit`'s link-only smoke row, which calls each of them and discards the result.

**The order is the whole content of the fix.** `Value::mat` is column-major, and so is `QMatrix4x4`'s raw storage: `constData()` and `data()` both hand out columns. What is NOT column-major is `QMatrix4x4(const float*)`, whose documentation says the array "is assumed to be in row-major order" — so constructing from `v.mat` would transpose every matrix and still compile, which is exactly the failure §SUR-66c names for the GLSL side.

spirvDisassembly

QString Program::spirvDisassembly() const

Returns the SPIR-V this program lowered through, as disassembled text.

The value is empty when the program kept no SPIR-V, and that is a normal answer. Only the interpreter lane keeps the binary. The native and GPU lanes consume the module into LLVM IR or a QShader, and a program with no lane never produced one. Read lowering() beside this value to tell the cases apart.

In this section