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

If two shaders / permutations produce the same code, do we compile them twice? #1435

Open
illwieckz opened this issue Nov 12, 2024 · 12 comments

Comments

@illwieckz
Copy link
Member

If two shaders / permutations produce the same code, do we compile them twice?

@illwieckz
Copy link
Member Author

illwieckz commented Nov 12, 2024

If not, we may do an index of cached shader text checksum, not just an index of shader+permutation id so we can automatically deduplicate both compile time and storage.

@VReaperV
Copy link
Contributor

The glsl caching code is a mess. It should be changed to be a straightforward "do all of the shader code processing, including adding macros, then check if we can load it based on that".

@VReaperV
Copy link
Contributor

If two shaders / permutations produce the same code, do we compile them twice?

Is there an example of such permutations or shaders? If two permutations exist for the same shader that are created by setting different macros, yet produce the same results, then some macros should just be nuked.

@illwieckz
Copy link
Member Author

I wonder if that happens with generic2D.

@VReaperV
Copy link
Contributor

I wonder if that happens with generic2D.

You mean permutations of it?

@illwieckz
Copy link
Member Author

Yes.

@illwieckz
Copy link
Member Author

illwieckz commented Nov 12, 2024

I mean I wonder if some permutations of generic2D and some permutations of generic may produce the same binary.

@VReaperV
Copy link
Contributor

Yes.

There's only one: deph fade.

@VReaperV
Copy link
Contributor

I mean I wonder if some permutations of generic2D and some permutations of generic may do the same.

Well, technically generic2D shader always has:

#if defined(GENERIC_2D)
	gl_FragDepth = 0;
#endif

@VReaperV
Copy link
Contributor

(the other one doesn't)

@VReaperV
Copy link
Contributor

The above is no longer true, now that the generic2D shader no longer uses that and is basically the same as generic one now.

@VReaperV
Copy link
Contributor

If not, we may do an index of cached shader text checksum, not just an index of shader+permutation id so we can automatically deduplicate both compile time and storage.

This is probably the best option, especially considering some of the post-processing our shader sources go through, which is not cached properly I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants