mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-29 12:34:17 +01:00
fix: incorrect pipeline compilation time report
This commit is contained in:
parent
b8021b642d
commit
665eb23e4a
@ -35,9 +35,7 @@ MetalPipelineCache::MetalPipelineCache(class MetalRenderer* metalRenderer) : m_m
|
||||
MetalPipelineCache::~MetalPipelineCache()
|
||||
{
|
||||
for (auto& [key, value] : m_pipelineCache)
|
||||
{
|
||||
value->release();
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "util/helpers/ConcurrentQueue.h"
|
||||
#include "util/helpers/fspinlock.h"
|
||||
|
||||
// TODO: binary archives
|
||||
class MetalPipelineCache
|
||||
{
|
||||
public:
|
||||
|
@ -386,7 +386,7 @@ MTL::RenderPipelineState* MetalPipelineCompiler::Compile(bool forceCompile, bool
|
||||
}
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto creationDuration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||
auto creationDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count();
|
||||
|
||||
if (error)
|
||||
{
|
||||
@ -479,7 +479,6 @@ void MetalPipelineCompiler::InitFromStateRender(const LatteFetchShader* fetchSha
|
||||
layout->setStride(bufferStride);
|
||||
}
|
||||
|
||||
// TODO: don't always set the vertex descriptor?
|
||||
desc->setVertexDescriptor(vertexDescriptor);
|
||||
vertexDescriptor->release();
|
||||
}
|
||||
@ -487,62 +486,6 @@ void MetalPipelineCompiler::InitFromStateRender(const LatteFetchShader* fetchSha
|
||||
SetFragmentState(desc, lastUsedAttachmentsInfo, activeAttachmentsInfo, m_rasterizationEnabled, lcr, fbosMatch);
|
||||
|
||||
m_pipelineDescriptor = desc;
|
||||
|
||||
//TryLoadBinaryArchive();
|
||||
|
||||
// Load binary
|
||||
/*
|
||||
if (m_binaryArchive)
|
||||
{
|
||||
NS::Object* binArchives[] = {m_binaryArchive};
|
||||
auto binaryArchives = NS::Array::alloc()->init(binArchives, 1);
|
||||
desc->setBinaryArchives(binaryArchives);
|
||||
binaryArchives->release();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
NS::Error* error = nullptr;
|
||||
#ifdef CEMU_DEBUG_ASSERT
|
||||
desc->setLabel(GetLabel("Cached render pipeline state", desc));
|
||||
#endif
|
||||
pipeline = m_mtlr->GetDevice()->newRenderPipelineState(desc, MTL::PipelineOptionFailOnBinaryArchiveMiss, nullptr, &error);
|
||||
|
||||
// Pipeline wasn't found in the binary archive, we need to compile it
|
||||
if (error)
|
||||
{
|
||||
desc->setBinaryArchives(nullptr);
|
||||
|
||||
error->release();
|
||||
error = nullptr;
|
||||
#ifdef CEMU_DEBUG_ASSERT
|
||||
desc->setLabel(GetLabel("New render pipeline state", desc));
|
||||
#endif
|
||||
pipeline = m_mtlr->GetDevice()->newRenderPipelineState(desc, &error);
|
||||
if (error)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "error creating render pipeline state: {}", error->localizedDescription()->utf8String());
|
||||
error->release();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save binary
|
||||
if (m_binaryArchive)
|
||||
{
|
||||
NS::Error* error = nullptr;
|
||||
m_binaryArchive->addRenderPipelineFunctions(desc, &error);
|
||||
if (error)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "error saving render pipeline functions: {}", error->localizedDescription()->utf8String());
|
||||
error->release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
desc->release();
|
||||
|
||||
return pipeline;
|
||||
*/
|
||||
}
|
||||
|
||||
void MetalPipelineCompiler::InitFromStateMesh(const LatteFetchShader* fetchShader, const MetalAttachmentsInfo& lastUsedAttachmentsInfo, const MetalAttachmentsInfo& activeAttachmentsInfo, const LatteContextRegister& lcr, bool& fbosMatch)
|
||||
@ -553,77 +496,4 @@ void MetalPipelineCompiler::InitFromStateMesh(const LatteFetchShader* fetchShade
|
||||
SetFragmentState(desc, lastUsedAttachmentsInfo, activeAttachmentsInfo, m_rasterizationEnabled, lcr, fbosMatch);
|
||||
|
||||
m_pipelineDescriptor = desc;
|
||||
|
||||
//TryLoadBinaryArchive();
|
||||
|
||||
// Load binary
|
||||
// TODO: no binary archives? :(
|
||||
|
||||
/*
|
||||
NS::Error* error = nullptr;
|
||||
#ifdef CEMU_DEBUG_ASSERT
|
||||
desc->setLabel(GetLabel("Mesh pipeline state", desc));
|
||||
#endif
|
||||
pipeline = m_mtlr->GetDevice()->newRenderPipelineState(desc, MTL::PipelineOptionNone, nullptr, &error);
|
||||
desc->release();
|
||||
if (error)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "error creating mesh render pipeline state: {}", error->localizedDescription()->utf8String());
|
||||
error->release();
|
||||
}
|
||||
|
||||
return pipeline;
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
void MetalPipelineCache::TryLoadBinaryArchive()
|
||||
{
|
||||
if (m_binaryArchive || s_cacheTitleId == INVALID_TITLE_ID)
|
||||
return;
|
||||
|
||||
// GPU name
|
||||
const char* deviceName1 = m_mtlr->GetDevice()->name()->utf8String();
|
||||
std::string deviceName;
|
||||
deviceName.assign(deviceName1);
|
||||
|
||||
// Replace spaces with underscores
|
||||
for (auto& c : deviceName)
|
||||
{
|
||||
if (c == ' ')
|
||||
c = '_';
|
||||
}
|
||||
|
||||
// OS version
|
||||
auto osVersion = NS::ProcessInfo::processInfo()->operatingSystemVersion();
|
||||
|
||||
// Precompiled binaries cannot be shared between different devices or OS versions
|
||||
const std::string cacheFilename = fmt::format("{:016x}_mtl_pipelines.bin", s_cacheTitleId);
|
||||
const fs::path cachePath = ActiveSettings::GetCachePath("shaderCache/precompiled/{}/{}-{}-{}/{}", deviceName, osVersion.majorVersion, osVersion.minorVersion, osVersion.patchVersion, cacheFilename);
|
||||
|
||||
// Create the directory if it doesn't exist
|
||||
std::filesystem::create_directories(cachePath.parent_path());
|
||||
|
||||
m_binaryArchiveURL = NS::URL::fileURLWithPath(ToNSString((const char*)cachePath.generic_u8string().c_str()));
|
||||
|
||||
MTL::BinaryArchiveDescriptor* desc = MTL::BinaryArchiveDescriptor::alloc()->init();
|
||||
desc->setUrl(m_binaryArchiveURL);
|
||||
|
||||
NS::Error* error = nullptr;
|
||||
m_binaryArchive = m_mtlr->GetDevice()->newBinaryArchive(desc, &error);
|
||||
if (error)
|
||||
{
|
||||
desc->setUrl(nullptr);
|
||||
|
||||
error->release();
|
||||
error = nullptr;
|
||||
m_binaryArchive = m_mtlr->GetDevice()->newBinaryArchive(desc, &error);
|
||||
if (error)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "failed to create binary archive: {}", error->localizedDescription()->utf8String());
|
||||
error->release();
|
||||
}
|
||||
}
|
||||
desc->release();
|
||||
}
|
||||
*/
|
||||
|
@ -24,17 +24,9 @@ private:
|
||||
bool m_usesGeometryShader;
|
||||
bool m_rasterizationEnabled;
|
||||
|
||||
/*
|
||||
std::map<uint64, MTL::RenderPipelineState*> m_pipelineCache;
|
||||
|
||||
NS::URL* m_binaryArchiveURL;
|
||||
MTL::BinaryArchive* m_binaryArchive;
|
||||
*/
|
||||
NS::Object* m_pipelineDescriptor;
|
||||
|
||||
void InitFromStateRender(const LatteFetchShader* fetchShader, const LatteDecompilerShader* vertexShader, const class MetalAttachmentsInfo& lastUsedAttachmentsInfo, const class MetalAttachmentsInfo& activeAttachmentsInfo, const LatteContextRegister& lcr, bool& fbosMatch);
|
||||
|
||||
void InitFromStateMesh(const LatteFetchShader* fetchShader, const class MetalAttachmentsInfo& lastUsedAttachmentsInfo, const class MetalAttachmentsInfo& activeAttachmentsInfo, const LatteContextRegister& lcr, bool& fbosMatch);
|
||||
|
||||
//void TryLoadBinaryArchive();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user