mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 14:31:17 +12:00
fix: AIR shaders not getting loaded properly
This commit is contained in:
parent
a8da524dd4
commit
371c089923
2 changed files with 23 additions and 11 deletions
|
@ -123,14 +123,27 @@ public:
|
|||
}
|
||||
|
||||
// Get the file size
|
||||
// Use a loop to handle the case where the file size is 0 (more of a safety net)
|
||||
struct stat fileStat;
|
||||
if (fstat(m_fd, &fileStat) == -1)
|
||||
while (true)
|
||||
{
|
||||
close(m_fd);
|
||||
cemuLog_log(LogType::Force, "failed to get file size: {}", filePath);
|
||||
return;
|
||||
if (fstat(m_fd, &fileStat) == -1)
|
||||
{
|
||||
close(m_fd);
|
||||
cemuLog_log(LogType::Force, "failed to get file size: {}", filePath);
|
||||
return;
|
||||
}
|
||||
m_fileSize = fileStat.st_size;
|
||||
|
||||
if (m_fileSize == 0)
|
||||
{
|
||||
cemuLog_logOnce(LogType::Force, "file size is 0: {}", filePath);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
m_fileSize = fileStat.st_size;
|
||||
|
||||
// Memory map the file
|
||||
m_data = mmap(nullptr, m_fileSize, PROT_READ, MAP_PRIVATE, m_fd, 0);
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
if (m_threadsActive.exchange(true))
|
||||
return;
|
||||
// create thread pool
|
||||
const uint32 threadCount = 2;
|
||||
const uint32 threadCount = 8;
|
||||
for (uint32 i = 0; i < threadCount; ++i)
|
||||
s_threads.emplace_back(&ShaderMtlThreadPool::CompilerThreadFunc, this);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ void RendererShaderMtl::ShaderCacheLoading_end()
|
|||
// Close RAM filesystem
|
||||
if (s_hasRAMFilesystem)
|
||||
{
|
||||
//executeCommand("diskutil eject {}", METAL_AIR_CACHE_PATH);
|
||||
executeCommand("diskutil eject {}", METAL_AIR_CACHE_PATH);
|
||||
s_hasRAMFilesystem = false;
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,6 @@ MTL::Library* RendererShaderMtl::LibraryFromAIR(std::span<uint8> data)
|
|||
NS::Error* error = nullptr;
|
||||
MTL::Library* library = m_mtlr->GetDevice()->newLibrary(dispatchData, &error);
|
||||
FinishCompilation();
|
||||
printf("AIR size: %zu\n", data.size());
|
||||
if (error)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "failed to create library from AIR: {}", error->localizedDescription()->utf8String());
|
||||
|
@ -296,17 +295,17 @@ void RendererShaderMtl::CompileInternal()
|
|||
mslFile.close();
|
||||
|
||||
// Compile
|
||||
executeCommand("xcrun -sdk macosx metal -o {}.ir -c {}.metal -Wno-unused-variable -Wno-sign-compare", baseFilename, baseFilename);
|
||||
executeCommand("xcrun -sdk macosx metal -o {}.ir -c {}.metal -w", baseFilename, baseFilename);
|
||||
executeCommand("xcrun -sdk macosx metallib -o {}.metallib {}.ir", baseFilename, baseFilename);
|
||||
|
||||
// Clean up
|
||||
executeCommand("rm {}.metal", baseFilename);
|
||||
executeCommand("rm {}.ir", baseFilename);
|
||||
|
||||
// Load from the newly Generated AIR
|
||||
// Load from the newly generated AIR
|
||||
MemoryMappedFile airFile(fmt::format("{}.metallib", baseFilename));
|
||||
std::span<uint8> airData = std::span<uint8>(airFile.data(), airFile.size());
|
||||
library = LibraryFromAIR(std::span<uint8>(cacheFileData.data(), cacheFileData.size()));
|
||||
library = LibraryFromAIR(std::span<uint8>(airData.data(), airData.size()));
|
||||
|
||||
// Store in the cache
|
||||
uint64 h1, h2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue