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

Simplify some GLSL shader loading code #1220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

src/engine/renderer/gl_shader.cpp Outdated Show resolved Hide resolved
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.

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.
@illwieckz illwieckz added T-Improvement Improvement for an existing feature A-Renderer labels Jul 30, 2024
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