Skip to content

Simplify some GLSL shader loading code #1220

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

Closed

Conversation

VReaperV
Copy link
Contributor

@VReaperV VReaperV commented Jul 15, 2024

Make somewhat messy code I noticed while working on #1105 and subsequent prs into something more readable.

Merge the two branches in GLShaderManager::buildPermutation() into one since they were doing essentially the same thing. Change some variable names to avoid confusion between shader and shader programs, fixed some formatting like whitespaces in [] and missing {} in if statements. Removed a redundant namespace in function call.

There is technically a slight difference in that compute shaders may be loaded even if deformIndex is > 0, but I don't think that really matters.

Str::StringRef compileMacros, int deformIndex )
{
GLShaderManager::CompileGPUShaders( shader, program, compileMacros );
if ( ( !baseProgram->VS && shader->_hasVertexShader ) || ( !baseProgram->FS && shader->_hasFragmentShader )
Copy link
Member

Choose a reason for hiding this comment

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

It's kinda confusing that program and baseProgram can be the same. I'm not convinced that this refactoring is really simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, code from CompileAndLinkGPUShaderProgram() can be moved to buildPermutation() and baseProgram set to program explicitly for deformIndex == 0.

@VReaperV VReaperV force-pushed the simplify-build-permutation branch from b2a1bc1 to 6b06dd7 Compare July 17, 2024 20:30
Merge the two branches in `GLShaderManager::buildPermutation()` into one since they were doing essentially the same thing.
Change some variable names to avoid confusion between shader and shader programs, fixed some formatting like whitespaces in [] and missing {} in if statements. Removed a redundant namespace in function call.
@VReaperV VReaperV force-pushed the simplify-build-permutation branch from 6b06dd7 to 8725226 Compare July 17, 2024 20:32
@illwieckz illwieckz added T-Improvement Improvement for an existing feature A-Renderer labels Jul 30, 2024
@VReaperV VReaperV closed this Mar 12, 2025
@VReaperV VReaperV deleted the simplify-build-permutation branch March 12, 2025 21:32
@VReaperV
Copy link
Contributor Author

This code was removed by #1586.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Renderer T-Improvement Improvement for an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants