-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
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
WebGPURenderer: Optimize and reuse varyings #28210
WebGPURenderer: Optimize and reuse varyings #28210
Conversation
Seems like some varyings have some specific issue with the |
Hmm... |
Somehow isolated one of the issue, basically using nodes will just always create new varying even when not necessary. For example using This will generate 3 varyings: export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
--> bitangentView is an independent varying of normalView.cross( tangentView ) Doing this will use only 2 varyings: export const TBNViewMatrix = mat3( tangentView, normalView.cross( tangentView ), normalView ); We would need a system to automatically pack the varyings I guess? Seems like my PR is helping when providing names to all varyings. /cc @sunag |
I will check, the current system should resolve this kind of issue, maybe has some bug related with cache. Your PR is good because give name for varyings, the names should help in debugging but should not be essential for optimization until fix this issue. |
@sunag One of the issue with the current node system when using named varying is that the Which is ok and runs well with the To reproduce simply add names to the varyings of the I don't think I will be able to resolve this easily as my knowledge on the node system is still a bit limited but I believe this issue will need to be resolve first in order to convert this draft to a PR a add various names for the attributes and varyings. |
@RenaudRohlinger Could you share your test again? I pushed a commit for us to analyze. Just |
This code doesn't seem to work if you try |
Let's try another time in a fresh PR. |
WebGPU is currently limited to 16 varyings, which can be quickly exceeded with the node system, leading to errors such as:
This PR sets up the naming of varyings where possible in order to reuse them, thereby enhancing performance and enabling debugging.
Before this PR with a fairly advanced setup:
After this PR, on the same program:
The only issue I encountered while working on this was my inability to assign the
v_normalLocal
name tonormalLocal
. /cc @sunag. Otherwise, everything seems to function well, even in complex setups.This contribution is funded by Utsubo