mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-06 15:01:18 +12:00
correct the object shader hash
This commit is contained in:
parent
2ee92e53e9
commit
b13ba58aad
4 changed files with 27 additions and 12 deletions
|
@ -8,7 +8,6 @@
|
|||
#include "Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerInstructions.h"
|
||||
#include "Cafe/HW/Latte/Core/FetchShader.h"
|
||||
#include "Cafe/HW/Latte/ISA/LatteInstructions.h"
|
||||
#include "HW/Latte/Renderer/Renderer.h"
|
||||
#include "util/containers/LookupTableL3.h"
|
||||
#include "util/helpers/fspinlock.h"
|
||||
#include <openssl/sha.h> /* SHA1_DIGEST_LENGTH */
|
||||
|
@ -108,14 +107,6 @@ void LatteShader_calculateFSKey(LatteFetchShader* fetchShader)
|
|||
key += (uint64)(attrib->offset & 3);
|
||||
key = std::rotl<uint64>(key, 2);
|
||||
}
|
||||
|
||||
// TODO: also check if geometry shader is used
|
||||
if (g_renderer->GetType() == RendererAPI::Metal)
|
||||
{
|
||||
key += (uint64)group.attributeBufferIndex;
|
||||
key = std::rotl<uint64>(key, 5);
|
||||
// TODO: hash the stride as well
|
||||
}
|
||||
}
|
||||
// todo - also hash invalid buffer groups?
|
||||
fetchShader->key = key;
|
||||
|
@ -155,6 +146,23 @@ void LatteFetchShader::CalculateFetchShaderVkHash()
|
|||
this->vkPipelineHashFragment = h;
|
||||
}
|
||||
|
||||
void LatteFetchShader::CalculateFetchShaderMtlObjectShaderHash(uint32* contextRegister)
|
||||
{uint64 key = 0;
|
||||
for (sint32 g = 0; g < bufferGroups.size(); g++)
|
||||
{
|
||||
LatteParsedFetchShaderBufferGroup_t& group = bufferGroups[g];
|
||||
uint32 bufferIndex = group.attributeBufferIndex;
|
||||
uint32 bufferBaseRegisterIndex = mmSQ_VTX_ATTRIBUTE_BLOCK_START + bufferIndex * 7;
|
||||
uint32 bufferStride = (contextRegister[bufferBaseRegisterIndex + 2] >> 11) & 0xFFFF;
|
||||
|
||||
key += (uint64)bufferIndex;
|
||||
key = std::rotl<uint64>(key, 5);
|
||||
key += (uint64)bufferStride;
|
||||
key = std::rotl<uint64>(key, 5);
|
||||
}
|
||||
mtlShaderHashObject = key;
|
||||
}
|
||||
|
||||
void _fetchShaderDecompiler_parseInstruction_VTX_SEMANTIC(LatteFetchShader* parsedFetchShader, uint32* contextRegister, const LatteClauseInstruction_VTX* instr)
|
||||
{
|
||||
uint32 semanticId = instr->getFieldSEM_SEMANTIC_ID(); // location (attribute index inside shader)
|
||||
|
@ -337,6 +345,7 @@ LatteFetchShader* LatteShaderRecompiler_createFetchShader(LatteFetchShader::Cach
|
|||
// these only make sense when vertex shader does not call FS?
|
||||
LatteShader_calculateFSKey(newFetchShader);
|
||||
newFetchShader->CalculateFetchShaderVkHash();
|
||||
newFetchShader->CalculateFetchShaderMtlObjectShaderHash(contextRegister);
|
||||
return newFetchShader;
|
||||
}
|
||||
|
||||
|
@ -396,6 +405,7 @@ LatteFetchShader* LatteShaderRecompiler_createFetchShader(LatteFetchShader::Cach
|
|||
}
|
||||
LatteShader_calculateFSKey(newFetchShader);
|
||||
newFetchShader->CalculateFetchShaderVkHash();
|
||||
newFetchShader->CalculateFetchShaderMtlObjectShaderHash(contextRegister);
|
||||
|
||||
// register in cache
|
||||
// its possible that during multi-threaded shader cache loading, two identical (same hash) fetch shaders get created simultaneously
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue