Fix rendering bugs when using ubershaders
This commit is contained in:
parent
de2cc0119c
commit
b82ba53b6b
2 changed files with 10 additions and 2 deletions
|
|
@ -93,7 +93,7 @@ void VkShaderManager::Deinit()
|
|||
|
||||
VkShaderProgram* VkShaderManager::Get(const VkShaderKey& key, bool isUberShader)
|
||||
{
|
||||
VkShaderProgram& program = isUberShader ? generic[key.Layout.AsDWORD] : specialized[key];
|
||||
VkShaderProgram& program = isUberShader ? generic[key.GeneralizedShaderKey()] : specialized[key];
|
||||
if (program.frag)
|
||||
return &program;
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,14 @@ public:
|
|||
uint32_t AsDWORD = 0;
|
||||
} Layout;
|
||||
|
||||
inline uint64_t GeneralizedShaderKey() const
|
||||
{
|
||||
return uint64_t(Layout.AsDWORD) |
|
||||
(uint64_t(EffectState) << 32) |
|
||||
((uint64_t(SpecialEffect) & 0xFF) << (32 + 16)) |
|
||||
((uint64_t(VertexFormat) & 0xFF) << (32 + 16 + 8));
|
||||
}
|
||||
|
||||
bool operator<(const VkShaderKey& other) const { return memcmp(this, &other, sizeof(VkShaderKey)) < 0; }
|
||||
bool operator==(const VkShaderKey& other) const { return memcmp(this, &other, sizeof(VkShaderKey)) == 0; }
|
||||
bool operator!=(const VkShaderKey& other) const { return memcmp(this, &other, sizeof(VkShaderKey)) != 0; }
|
||||
|
|
@ -186,7 +194,7 @@ private:
|
|||
|
||||
VulkanRenderDevice* fb = nullptr;
|
||||
|
||||
std::map<uint32_t, VkShaderProgram> generic;
|
||||
std::map<uint64_t, VkShaderProgram> generic;
|
||||
std::map<VkShaderKey, VkShaderProgram> specialized;
|
||||
|
||||
std::list<VkPPShader*> PPShaders;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue