From 198e9e8e48517e1196ff5691fd6d7688e4f1e6b7 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 29 Jan 2023 22:16:08 +0000 Subject: [PATCH] Avoid page faults when using the fallback shader size These occured in some homebrew otherwise. --- .../skyline/gpu/interconnect/common/shader_cache.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/common/shader_cache.cpp b/app/src/main/cpp/skyline/gpu/interconnect/common/shader_cache.cpp index 55bb336d..b1a0607d 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/common/shader_cache.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/common/shader_cache.cpp @@ -100,7 +100,16 @@ namespace skyline::gpu::interconnect { size_t storageOffset{splitBinaryStorage.size()}; splitBinaryStorage.resize(storageOffset + FallbackSize); auto shaderStorage{span{splitBinaryStorage}.subspan(storageOffset, FallbackSize)}; - ctx.channelCtx.asCtx->gmmu.Read(shaderStorage, programBase + programOffset); + auto mappings{ctx.channelCtx.asCtx->gmmu.TranslateRange(programBase + programOffset, storageOffset + FallbackSize)}; + u8 *shaderStoragePtr{shaderStorage.data()}; + for (auto mapping : mappings) { + if (!mapping.valid()) + break; + + std::memcpy(shaderStoragePtr, mapping.data(), mapping.size()); + shaderStoragePtr += mapping.size(); + } + binary.binary = shaderStorage; } }