[Shader JIT[ Cache harder

This commit is contained in:
wheremyfoodat 2023-06-07 21:25:46 +03:00
parent 4064abfdeb
commit 6a70edca7e
3 changed files with 19 additions and 1 deletions

View file

@ -9,6 +9,17 @@ void ShaderJIT::reset() {
void ShaderJIT::prepare(PICAShader& shaderUnit) {
// We construct a shader hash from both the code and operand descriptor hashes
// This is so that if only one of them changes, we still properly recompile the shader
// This code is inspired from how Citra solves this problem
Hash hash = shaderUnit.getCodeHash() ^ shaderUnit.getOpdescHash();
auto it = cache.find(hash);
if (it == cache.end()) { // Block has not been compiled yet
auto emitter = std::make_unique<ShaderEmitter>();
cache.emplace_hint(it, hash, std::move(emitter));
} else { // Block has been compiled and found, use it
}
shaderUnit.pc = shaderUnit.entrypoint;
}
#endif // PANDA3DS_SHADER_JIT_SUPPORTED