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
Nodes: Introduce NodeBuilder.formatOperation #27954
base: dev
Are you sure you want to change the base?
Conversation
Signed-off-by: Levi Pesin <35454228+LeviPesin@users.noreply.github.com>
Signed-off-by: Levi Pesin <35454228+LeviPesin@users.noreply.github.com>
No idea why the CI-3 job fails... Examples work fine locally. |
Signed-off-by: Levi Pesin <35454228+LeviPesin@users.noreply.github.com>
Seems like I just was accidentally testing on the WebGPU backend, not WebGL2 one... Should be fixed now. |
Signed-off-by: Levi Pesin <35454228+LeviPesin@users.noreply.github.com>
Not sure what could've broken... |
@sunag Can you please look into this? |
@@ -258,7 +258,7 @@ export const blur = tslFn( ( { n, latitudinal, poleAxis, outputDirection, weight | |||
|
|||
const axis = vec3( cond( latitudinal, poleAxis, cross( poleAxis, outputDirection ) ) ).toVar(); | |||
|
|||
If( all( axis.equals( vec3( 0.0 ) ) ), () => { | |||
If( all( axis.equal( vec3( 0.0 ) ) ), () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... currently equals
should return a bvec
while equal
should return a bool
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why equal
should return bool
? I think it makes sense to return bool
in case of primitive types and bvec
in case of vectors (exactly how ==
works in WGSL and equal
in GLSL), as now.
The formatting of the generated code has improved a lot 🚀 |
The
I did't compare the generated codes, maybe the new formatting can lose operator precedence? |
If so, this is a bug -- I tried to account for every case (difference between left and right arguments, operators of same precedence that could or could not associate with themselves, operators that don't associate with certain other precedence at all in WGSL), but it's still possible that something fails. I will try to look into it... |
It will also improve much, much more after a PR with various fixes for |
Signed-off-by: Levi Pesin <35454228+LeviPesin@users.noreply.github.com>
Related issue: #27512
Description
This is (finally) the first PR of #27512 -- I started with this one because I think this is the most useful and simple feature of all included (I hope I will file other PRs soon).
This PR introduces a new NodeBuilder method for formatting operations and functions. This allows to not worry about enclosing operations in brackets anymore (as it was done in OperatorNode previously and caused many unneeded ones), allows to simplify polyfilling of missing in GLSL/WGSL operators and functions (now it can be done in basically one line; .getMethod() and .getFunctionOperator() are also not needed now), and as a bonus also allows auto-building something like
node.addAssign( node2 )
tonode += node2
(on the shader code generation step instead of node graph building, but I think in this case this is enough). I also removedequals
element because it seems to be just a duplicate of already existingequal
.