-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Death to baked expressions #4511
Comments
My preference:
|
Thinking aloud: the nice thing about
This parenthesizes as:
So at the point that we need to generate the call to What's nice about today's |
FWIW when working on my |
Naga IR should be changed to eliminate the need to bake expressions.
Baked expressions are a Naga-specific piece of ugly magic: subexpressions that we identify as needing to be evaluated in isolation, not as part of the Statement that actually refers to them. Baking an expression means that it's emitted as an initialized temporary variable. References to the expression are then rendered as uses of that variable.
Examples would be Load expressions, which need to be ordered properly with respect to Call statements that could assign to the variables they read. But it also includes stuff like the operands of MathFunction::Dot applications on Metal, which open-codes the dot product operation, and wants its operands to be cached in locals in advance to avoid repeated evaluation.
We flag expressions for baking pessimistically. For example, most
Load
s do not need to be separated out from the rest of the expression, but we produce (in WGSL output) a separatelet
declaration for every load. For the GLSL input:we generate the WGSL:
That
_e4
temporary is the result of baking.The semantics of Naga IR should be such that backends don't need to filter through the expressions covered by an
Emit
and play strange games with reference count thresholds to decide what to generate.A better approach would not only simplify
Emit
statement processing in backends, but also accommodate backend-specific needs like inlinedDot
calls (or the broad selection of functions in the HLSL backend).The text was updated successfully, but these errors were encountered: