fix: pipeline cache with mesh shaders

This commit is contained in:
Samuliak 2024-10-19 09:29:14 +02:00
parent 8f2385a690
commit 15eb6bb37f
No known key found for this signature in database
3 changed files with 35 additions and 27 deletions

View file

@ -43,19 +43,21 @@ MetalPipelineCache::~MetalPipelineCache()
MTL::RenderPipelineState* MetalPipelineCache::GetRenderPipelineState(const LatteFetchShader* fetchShader, const LatteDecompilerShader* vertexShader, const LatteDecompilerShader* geometryShader, const LatteDecompilerShader* pixelShader, const MetalAttachmentsInfo& lastUsedAttachmentsInfo, const MetalAttachmentsInfo& activeAttachmentsInfo, const LatteContextRegister& lcr)
{
uint64 hash = CalculatePipelineHash(fetchShader, vertexShader, geometryShader, pixelShader, lastUsedAttachmentsInfo, activeAttachmentsInfo, lcr);
auto& pipeline = m_pipelineCache[hash];
if (pipeline)
return pipeline;
auto it = m_pipelineCache.find(hash);
if (it != m_pipelineCache.end())
return it->second;
MetalPipelineCompiler compiler(m_mtlr);
bool fbosMatch;
compiler.InitFromState(fetchShader, vertexShader, geometryShader, pixelShader, lastUsedAttachmentsInfo, activeAttachmentsInfo, lcr, fbosMatch);
pipeline = compiler.Compile(false, true, true);
MTL::RenderPipelineState* pipeline = compiler.Compile(false, true, true);
// If FBOs don't match, it wouldn't be possible to reconstruct the pipeline from the cache
if (fbosMatch)
AddCurrentStateToCache(hash);
m_pipelineCache.insert({hash, pipeline});
return pipeline;
}
@ -355,6 +357,9 @@ void MetalPipelineCache::LoadPipelineFromCache(std::span<uint8> fileData)
MetalAttachmentsInfo attachmentsInfo(*lcr, pixelShader);
// TODO: this shouldn't probably be called directly
LatteShader_UpdatePSInputs(lcr->GetRawView());
MTL::RenderPipelineState* pipeline = nullptr;
// compile
{