Skip to content
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

ShaderUI : Fix poor scaling in _ShaderPath #5894

Merged

Conversation

johnhaddon
Copy link
Member

The ShaderNetwork.shaders() function builds a Python dictionary containing copies of all the shaders in the network. And in several places, we were calling that at least once per shader, giving us extremely poor scaling for certain large production networks with around 700 individual shaders. This was bad enough that some users reported avoiding the dialogue entirely.

This commit replaces calls to shaders() with individual calls to getShader(). That gives around a 300x speedup when walking the entire _ShaderPath hierarchy for a problematic network and querying the shader:inputs property for each parameter found. This makes the shader dialogues for ShaderTweaks and ShaderQuery usable again.

The `ShaderNetwork.shaders()` function builds a Python dictionary containing copies of all the shaders in the network. And in several places, we were calling that at least once per shader, giving us extremely poor scaling for certain large production networks with around 700 individual shaders. This was bad enough that some users reported avoiding the dialogue entirely.

This commit replaces calls to `shaders()` with individual calls to `getShader()`. That gives around a 300x speedup when walking the entire _ShaderPath hierarchy for a problematic network and querying the `shader:inputs` property for each parameter found. This makes the shader dialogues for ShaderTweaks and ShaderQuery usable again.
@johnhaddon johnhaddon requested a review from ericmehl June 11, 2024 16:17
@johnhaddon johnhaddon self-assigned this Jun 11, 2024
Copy link
Collaborator

@ericmehl ericmehl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and a great speedup for the shader browser. Good to know about the overhead of building the shader dictionary.

@johnhaddon johnhaddon merged commit 5e8b909 into GafferHQ:1.4_maintenance Jun 12, 2024
5 checks passed
@johnhaddon johnhaddon deleted the nonQuadraticShaderPath branch August 7, 2024 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants