Interface Expr
- All Known Implementing Classes:
Expr.Binary,Expr.Call,Expr.Construct,Expr.Lit,Expr.Loop,Expr.Raw,Expr.Ref,Expr.Sample,Expr.Swizzle
SurfaceOutputs built from these; a backend code generator walks the DAG
to emit target GLSL (or, later, SPIR-V/MSL). Every node exposes its
ShaderType so the generator can type-check and construct correctly.
The set is deliberately small (enough for the standard metallic-roughness
surface and custom surfaces, iterative ones included through Expr.Loop), with
Expr.Raw as a per-target escape.
A node used twice is computed once. The IR is a value: two nodes are the same
computation when their kinds, fields and children are, whether they are one Java object or two
built apart, and equals and hashCode say so. The generator writes such a node
once and reads it wherever it is used, so a Java method that builds a sub-expression is as
cheap to call twice as once, and a variable reused in a long chain does not multiply the
shader's size. Comparing, hashing and toString visit a node shared by many parents
once; toString writes such a node the first time as #1=… and then as #1.
A 1.x minor release may add node types: a switch over an Expr needs a
default branch.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordBinary arithmetic; result type follows GLSL scalar/vector promotion.static final recordA built-in or engine helper call with a declared result type.static final recordA constructor likevec4(rgb, a)orvec3(x).static final recordA numeric literal, scalar or vector by value count.static final recordA value computed by a bounded loop: a state of one value or several, their initial values, and the state after one turn, taken at mostmaxIterationstimes.static enumArithmetic operators.static final recordNon-portable inline GLSL, valid only fortarget.static final recordA named value: an input the framework or the surface declares (a UBO member, a varying, a sampler, aMaterial.Surfaceinput), or the state of theExpr.Loopit is read in, whichExpr.Loop.of(limn.render3d.shader.Expr, int, java.util.function.Function<? super limn.render3d.shader.Expr, ? extends limn.render3d.shader.Expr>)hands the loop's turn.static final recordSamplessampleratuv→ vec4.static final recordComponent selection, e.g. -
Method Summary
-
Method Details
-
type
ShaderType type()
-