-
Notifications
You must be signed in to change notification settings - Fork 2.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
Generate "Ubershaders" that can handle all lighting configurations #16104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is probably one of the better areas to "uber" combine. It's a shame about Mali and older GPUs since this'll complicate things a bit... but seems worth it to me as well.
Wish we had lighting right before this, though...
-[Unknown]
GPU/Common/ShaderId.cpp
Outdated
if (chanEnabled) { | ||
id.SetBits(VS_BIT_LIGHT0_COMP + 4 * i, 2, gstate.getLightComputation(i)); | ||
id.SetBits(VS_BIT_LIGHT0_TYPE + 4 * i, 2, gstate.getLightType(i)); | ||
if (g_Config.bLightUberShader) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also check bitwiseOps?
-[Unknown]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it so that the ubershader is now a GPU_FEATURE flag, and it's set depending on whether bitwise ops work.
Indeed would be nice to have lighting correct, but the duplicated changes will at least be very nearby and easy to port, once we find what's wrong. And yeah, this will get a round of fixes before it's time to review, thanks for looking though :) |
GLES being a pedant about signed vs unsigned again, of course. Fixing. |
Wait, forgot the shade mapping part.. it might be working but I need to check, heh. |
Oh, the shade mapping (env mapping) is working, but there's some old cruft to clean out... actually never mind, I'll leave it as-is. |
…gurations This drastically reduces the shader compile stutter that happens when a lot of new light setups are created, like on the first punch in Tekken 6. There's more stuff that might benefit from being made dynamic like this. These branches are very cheap on modern GPUs since they're branching on a uniform variable, so no divergence. Only tested on Vulkan. I think we'll need to keep the old path too for gpus like Mali-450...
5ce45cf
to
f30252f
Compare
Fixed the test, should be mostly finished now, I think. |
In #16104, we drastically reduced the number of shader variants for games that use flexible lighting setups. I looked at a few games and it seems that a lot of games have the same shaders with fog on/off, while fog is super cheap to compute. So let's just always do it, reducing vertex shader variants further (though the amount of pipelines will probably remain the same, since we still specialize the fragment shader). Might also be worth adding a dynamic bool for the fragment shader, but if so, doing it separately.
Instead of a ton of specific shaders for every little difference.
Applies to Vulkan, DX11 and GLES3.
This drastically reduces or removes the shader compile stutter that happens when a lot of new light setups are created, like on the first punch in Tekken 6.
There's more stuff that might benefit from being made dynamic like this. These branches are very cheap on modern GPUs since they're branching on a uniform variable, so no divergence.
I think we'll need to keep the old path too for gpus like Mali-450...
Tested in VK, D3D11, and OpenGL/ES.
Also! TODO: this need to somehow take doLight from shade mapping into account.