Open hadronized opened 5 years ago
Blocks are composed of three main parts:
There are some block transformations that are combinators:
X: A -> B
with Y: B -> C
yields a block Z: A -> C
. Typically, that kind of yielded block will simply get its inputs from X
, its outputs from Y
and internal representation will be injected in the code. It’s important to note that the intermediate C
(both inputs and outputs) must remain used as-is, so that sharing is possible – imagine that several blocks use the same block.B -> C
on a block X: A -> B
yields a block Y: A -> C
.A -> C
on a block X: A -> B
yields a block Y: C -> B
.A -> C
and mapping a function B -> D
on a a block X: A -> B
yields a block Y: C -> D
.X: A -> B
, Y: C -> D
, Z: E -> F
, blend(X, Y, Z) = δ: (A, C, E) -> G
.The GLSL is just a simple AST. That is, a Vec<ExternalDeclaration>
– see my glsl crate for further details. The idea is that it must define:
Input
s.Output
s.Vec<ExternalDeclaration>
that makes its code:
ExternalDeclaration
s are brought into scope.call
function.struct
representation of the block’s inputs and outputs a struct
representation of the block’s outputs.ExternalDeclaration
and brought into scope automatically. For instance, given X: A -> B
, Y: B -> C, the block
X ~ Ywill have as inputs
Aand outputs
Cand its internal code will have the struct definition of
Bas well as the two
callfunctions from
Xand
Y`.In order to authorize a correct naming of structs and functions, they should be named randomly. For instance, the call
functions must carry a prefix or suffix. We can use the name of the box for that, but that’s not enough. I think that we need somekind of a context here in order to be able to get a new render block identifier each time a new one must be created. This will prevent nasty conflicts.
Do we want to be able to reference the call
functions from dependent blocks? If so, how so? Also, how do we reference other input / output types from the current block?
X: A -> B
Y: B -> C
Z: A -> C
Here, the first B
(output) is not the exact same as the second B
(input) if you strictly generate the GLSL code for X
, Y
and Z
. We need to find a way to share B
between X
and Y
for this to work.
Maybe a lead for implementing composition:
A
.C
.Out
type in the code of X
to InOut_{name_of_composition_block}
.In
from Y
.InOut_{name_of_composition_block}
) as ExternalDeclaration
, then both mangled code from X
and Y
. We get two functions call_x
and call_y
that now share the same input / output type.call
, which is now trivial.
P: A -> B
andQ: B -> C
, I want combinators likeP ~ Q: A -> C
.