diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/core/core.cpp | 9 | ||||
-rw-r--r-- | src/core/core.h | 22 | ||||
-rw-r--r-- | src/core/crypto/aes_util.cpp | 35 | ||||
-rw-r--r-- | src/core/crypto/aes_util.h | 12 | ||||
-rw-r--r-- | src/core/crypto/encryption_layer.h | 1 | ||||
-rw-r--r-- | src/core/crypto/key_manager.cpp | 15 | ||||
-rw-r--r-- | src/core/crypto/key_manager.h | 7 | ||||
-rw-r--r-- | src/core/hle/service/arp/arp.cpp | 75 | ||||
-rw-r--r-- | src/core/hle/service/arp/arp.h | 16 | ||||
-rw-r--r-- | src/core/hle/service/audio/audin_a.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/audio/audrec_a.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/audio/audren_a.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/filesystem/fsp_ldr.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/filesystem/fsp_pr.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 11 | ||||
-rw-r--r-- | src/core/hle/service/nvflinger/nvflinger.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/service/service.cpp | 2 | ||||
-rw-r--r-- | src/core/memory.cpp | 24 | ||||
-rw-r--r-- | src/core/settings.cpp | 6 |
21 files changed, 187 insertions, 72 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 28de22398..c11f017da 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -134,6 +134,8 @@ add_library(core STATIC hle/service/apm/apm.h hle/service/apm/interface.cpp hle/service/apm/interface.h + hle/service/arp/arp.cpp + hle/service/arp/arp.h hle/service/audio/audctl.cpp hle/service/audio/audctl.h hle/service/audio/auddbg.cpp diff --git a/src/core/core.cpp b/src/core/core.cpp index e51e66550..e01c45cdd 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -18,6 +18,7 @@ #include "core/loader/loader.h" #include "core/settings.h" #include "file_sys/vfs_real.h" +#include "video_core/renderer_base.h" #include "video_core/video_core.h" namespace Core { @@ -178,7 +179,6 @@ System::ResultStatus System::Init(EmuWindow& emu_window) { cpu_cores[index] = std::make_shared<Cpu>(cpu_exclusive_monitor, cpu_barrier, index); } - gpu_core = std::make_unique<Tegra::GPU>(); telemetry_session = std::make_unique<Core::TelemetrySession>(); service_manager = std::make_shared<Service::SM::ServiceManager>(); @@ -186,10 +186,13 @@ System::ResultStatus System::Init(EmuWindow& emu_window) { Service::Init(service_manager); GDBStub::Init(); - if (!VideoCore::Init(emu_window)) { + renderer = VideoCore::CreateRenderer(emu_window); + if (!renderer->Init()) { return ResultStatus::ErrorVideoCore; } + gpu_core = std::make_unique<Tegra::GPU>(renderer->Rasterizer()); + // Create threads for CPU cores 1-3, and build thread_to_cpu map // CPU core 0 is run on the main thread thread_to_cpu[std::this_thread::get_id()] = cpu_cores[0]; @@ -221,7 +224,7 @@ void System::Shutdown() { perf_results.frametime * 1000.0); // Shutdown emulation session - VideoCore::Shutdown(); + renderer.reset(); GDBStub::Shutdown(); Service::Shutdown(); Kernel::Shutdown(); diff --git a/src/core/core.h b/src/core/core.h index 4c9967559..a3be88aa8 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -27,6 +27,10 @@ namespace Service::SM { class ServiceManager; } +namespace VideoCore { +class RendererBase; +} + namespace Core { class System { @@ -129,11 +133,26 @@ public: /// Gets a CPU interface to the CPU core with the specified index Cpu& CpuCore(size_t core_index); - /// Gets the GPU interface + /// Gets a mutable reference to the GPU interface Tegra::GPU& GPU() { return *gpu_core; } + /// Gets an immutable reference to the GPU interface. + const Tegra::GPU& GPU() const { + return *gpu_core; + } + + /// Gets a mutable reference to the renderer. + VideoCore::RendererBase& Renderer() { + return *renderer; + } + + /// Gets an immutable reference to the renderer. + const VideoCore::RendererBase& Renderer() const { + return *renderer; + } + /// Gets the scheduler for the CPU core that is currently running Kernel::Scheduler& CurrentScheduler() { return *CurrentCpuCore().Scheduler(); @@ -197,6 +216,7 @@ private: /// AppLoader used to load the current executing application std::unique_ptr<Loader::AppLoader> app_loader; + std::unique_ptr<VideoCore::RendererBase> renderer; std::unique_ptr<Tegra::GPU> gpu_core; std::shared_ptr<Tegra::DebugContext> debug_context; Kernel::SharedPtr<Kernel::Process> current_process; diff --git a/src/core/crypto/aes_util.cpp b/src/core/crypto/aes_util.cpp index 4690af5f8..a9876c83e 100644 --- a/src/core/crypto/aes_util.cpp +++ b/src/core/crypto/aes_util.cpp @@ -3,10 +3,22 @@ // Refer to the license.txt file included. #include <mbedtls/cipher.h> +#include "common/assert.h" +#include "common/logging/log.h" #include "core/crypto/aes_util.h" #include "core/crypto/key_manager.h" namespace Core::Crypto { +namespace { +std::vector<u8> CalculateNintendoTweak(size_t sector_id) { + std::vector<u8> out(0x10); + for (size_t i = 0xF; i <= 0xF; --i) { + out[i] = sector_id & 0xFF; + sector_id >>= 8; + } + return out; +} +} // Anonymous namespace static_assert(static_cast<size_t>(Mode::CTR) == static_cast<size_t>(MBEDTLS_CIPHER_AES_128_CTR), "CTR has incorrect value."); @@ -56,27 +68,28 @@ void AESCipher<Key, KeySize>::SetIV(std::vector<u8> iv) { } template <typename Key, size_t KeySize> -void AESCipher<Key, KeySize>::Transcode(const u8* src, size_t size, u8* dest, Op op) { - size_t written = 0; - - const auto context = op == Op::Encrypt ? &ctx->encryption_context : &ctx->decryption_context; +void AESCipher<Key, KeySize>::Transcode(const u8* src, size_t size, u8* dest, Op op) const { + auto* const context = op == Op::Encrypt ? &ctx->encryption_context : &ctx->decryption_context; mbedtls_cipher_reset(context); + size_t written = 0; if (mbedtls_cipher_get_cipher_mode(context) == MBEDTLS_MODE_XTS) { mbedtls_cipher_update(context, src, size, dest, &written); - if (written != size) + if (written != size) { LOG_WARNING(Crypto, "Not all data was decrypted requested={:016X}, actual={:016X}.", size, written); + } } else { const auto block_size = mbedtls_cipher_get_block_size(context); for (size_t offset = 0; offset < size; offset += block_size) { auto length = std::min<size_t>(block_size, size - offset); mbedtls_cipher_update(context, src + offset, length, dest + offset, &written); - if (written != length) + if (written != length) { LOG_WARNING(Crypto, "Not all data was decrypted requested={:016X}, actual={:016X}.", length, written); + } } } @@ -97,16 +110,6 @@ void AESCipher<Key, KeySize>::XTSTranscode(const u8* src, size_t size, u8* dest, } } -template <typename Key, size_t KeySize> -std::vector<u8> AESCipher<Key, KeySize>::CalculateNintendoTweak(size_t sector_id) { - std::vector<u8> out(0x10); - for (size_t i = 0xF; i <= 0xF; --i) { - out[i] = sector_id & 0xFF; - sector_id >>= 8; - } - return out; -} - template class AESCipher<Key128>; template class AESCipher<Key256>; } // namespace Core::Crypto
\ No newline at end of file diff --git a/src/core/crypto/aes_util.h b/src/core/crypto/aes_util.h index 5b0b02738..8ce9d6612 100644 --- a/src/core/crypto/aes_util.h +++ b/src/core/crypto/aes_util.h @@ -7,7 +7,7 @@ #include <memory> #include <type_traits> #include <vector> -#include "common/assert.h" +#include "common/common_types.h" #include "core/file_sys/vfs.h" namespace Core::Crypto { @@ -38,15 +38,19 @@ public: void SetIV(std::vector<u8> iv); template <typename Source, typename Dest> - void Transcode(const Source* src, size_t size, Dest* dest, Op op) { + void Transcode(const Source* src, size_t size, Dest* dest, Op op) const { + static_assert(std::is_trivially_copyable_v<Source> && std::is_trivially_copyable_v<Dest>, + "Transcode source and destination types must be trivially copyable."); Transcode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), op); } - void Transcode(const u8* src, size_t size, u8* dest, Op op); + void Transcode(const u8* src, size_t size, u8* dest, Op op) const; template <typename Source, typename Dest> void XTSTranscode(const Source* src, size_t size, Dest* dest, size_t sector_id, size_t sector_size, Op op) { + static_assert(std::is_trivially_copyable_v<Source> && std::is_trivially_copyable_v<Dest>, + "XTSTranscode source and destination types must be trivially copyable."); XTSTranscode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), sector_id, sector_size, op); } @@ -56,7 +60,5 @@ public: private: std::unique_ptr<CipherContext> ctx; - - static std::vector<u8> CalculateNintendoTweak(size_t sector_id); }; } // namespace Core::Crypto diff --git a/src/core/crypto/encryption_layer.h b/src/core/crypto/encryption_layer.h index 71bca1f23..7f05af9b4 100644 --- a/src/core/crypto/encryption_layer.h +++ b/src/core/crypto/encryption_layer.h @@ -4,6 +4,7 @@ #pragma once +#include "common/common_types.h" #include "core/file_sys/vfs.h" namespace Core::Crypto { diff --git a/src/core/crypto/key_manager.cpp b/src/core/crypto/key_manager.cpp index 678ac5752..fc45e7ab5 100644 --- a/src/core/crypto/key_manager.cpp +++ b/src/core/crypto/key_manager.cpp @@ -2,19 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> #include <array> #include <fstream> #include <locale> #include <sstream> #include <string_view> -#include <mbedtls/sha256.h> -#include "common/assert.h" #include "common/common_paths.h" #include "common/file_util.h" -#include "common/logging/log.h" #include "core/crypto/key_manager.h" #include "core/settings.h" -#include "key_manager.h" namespace Core::Crypto { @@ -66,8 +63,7 @@ KeyManager::KeyManager() { AttemptLoadKeyFile(yuzu_keys_dir, hactool_keys_dir, "title.keys", true); } -void KeyManager::LoadFromFile(std::string_view filename_, bool is_title_keys) { - const auto filename = std::string(filename_); +void KeyManager::LoadFromFile(const std::string& filename, bool is_title_keys) { std::ifstream file(filename); if (!file.is_open()) return; @@ -107,11 +103,8 @@ void KeyManager::LoadFromFile(std::string_view filename_, bool is_title_keys) { } } -void KeyManager::AttemptLoadKeyFile(std::string_view dir1_, std::string_view dir2_, - std::string_view filename_, bool title) { - const std::string dir1(dir1_); - const std::string dir2(dir2_); - const std::string filename(filename_); +void KeyManager::AttemptLoadKeyFile(const std::string& dir1, const std::string& dir2, + const std::string& filename, bool title) { if (FileUtil::Exists(dir1 + DIR_SEP + filename)) LoadFromFile(dir1 + DIR_SEP + filename, title); else if (FileUtil::Exists(dir2 + DIR_SEP + filename)) diff --git a/src/core/crypto/key_manager.h b/src/core/crypto/key_manager.h index 03152a12c..c4c53cefc 100644 --- a/src/core/crypto/key_manager.h +++ b/src/core/crypto/key_manager.h @@ -5,6 +5,7 @@ #pragma once #include <array> +#include <string> #include <type_traits> #include <unordered_map> #include <vector> @@ -109,9 +110,9 @@ private: std::unordered_map<KeyIndex<S256KeyType>, Key256> s256_keys; bool dev_mode; - void LoadFromFile(std::string_view filename, bool is_title_keys); - void AttemptLoadKeyFile(std::string_view dir1, std::string_view dir2, std::string_view filename, - bool title); + void LoadFromFile(const std::string& filename, bool is_title_keys); + void AttemptLoadKeyFile(const std::string& dir1, const std::string& dir2, + const std::string& filename, bool title); static const std::unordered_map<std::string, KeyIndex<S128KeyType>> s128_file_id; static const std::unordered_map<std::string, KeyIndex<S256KeyType>> s256_file_id; diff --git a/src/core/hle/service/arp/arp.cpp b/src/core/hle/service/arp/arp.cpp new file mode 100644 index 000000000..358ef2576 --- /dev/null +++ b/src/core/hle/service/arp/arp.cpp @@ -0,0 +1,75 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <memory> + +#include "common/logging/log.h" +#include "core/hle/ipc_helpers.h" +#include "core/hle/kernel/hle_ipc.h" +#include "core/hle/service/arp/arp.h" +#include "core/hle/service/service.h" +#include "core/hle/service/sm/sm.h" + +namespace Service::ARP { + +class ARP_R final : public ServiceFramework<ARP_R> { +public: + explicit ARP_R() : ServiceFramework{"arp:r"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetApplicationLaunchProperty"}, + {1, nullptr, "GetApplicationLaunchPropertyWithApplicationId"}, + {2, nullptr, "GetApplicationControlProperty"}, + {3, nullptr, "GetApplicationControlPropertyWithApplicationId"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class IRegistrar final : public ServiceFramework<IRegistrar> { +public: + explicit IRegistrar() : ServiceFramework{"IRegistrar"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "Issue"}, + {1, nullptr, "SetApplicationLaunchProperty"}, + {2, nullptr, "SetApplicationControlProperty"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class ARP_W final : public ServiceFramework<ARP_W> { +public: + explicit ARP_W() : ServiceFramework{"arp:w"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, &ARP_W::AcquireRegistrar, "AcquireRegistrar"}, + {1, nullptr, "DeleteProperties"}, + }; + // clang-format on + + RegisterHandlers(functions); + } + +private: + void AcquireRegistrar(Kernel::HLERequestContext& ctx) { + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(RESULT_SUCCESS); + rb.PushIpcInterface<IRegistrar>(); + + LOG_DEBUG(Service_ARP, "called"); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm) { + std::make_shared<ARP_R>()->InstallAsService(sm); + std::make_shared<ARP_W>()->InstallAsService(sm); +} + +} // namespace Service::ARP diff --git a/src/core/hle/service/arp/arp.h b/src/core/hle/service/arp/arp.h new file mode 100644 index 000000000..9d100187c --- /dev/null +++ b/src/core/hle/service/arp/arp.h @@ -0,0 +1,16 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Service::SM { +class ServiceManager; +} + +namespace Service::ARP { + +/// Registers all ARP services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& sm); + +} // namespace Service::ARP diff --git a/src/core/hle/service/audio/audin_a.cpp b/src/core/hle/service/audio/audin_a.cpp index e62a27945..a70d5bca4 100644 --- a/src/core/hle/service/audio/audin_a.cpp +++ b/src/core/hle/service/audio/audin_a.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once - #include "core/hle/service/audio/audin_a.h" namespace Service::Audio { diff --git a/src/core/hle/service/audio/audrec_a.cpp b/src/core/hle/service/audio/audrec_a.cpp index 9c32f9b98..016eabf53 100644 --- a/src/core/hle/service/audio/audrec_a.cpp +++ b/src/core/hle/service/audio/audrec_a.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once - #include "core/hle/service/audio/audrec_a.h" namespace Service::Audio { diff --git a/src/core/hle/service/audio/audren_a.cpp b/src/core/hle/service/audio/audren_a.cpp index bc9930d79..616ff3dc4 100644 --- a/src/core/hle/service/audio/audren_a.cpp +++ b/src/core/hle/service/audio/audren_a.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once - #include "core/hle/service/audio/audren_a.h" namespace Service::Audio { diff --git a/src/core/hle/service/filesystem/fsp_ldr.cpp b/src/core/hle/service/filesystem/fsp_ldr.cpp index ee6d4d055..0ab9c2606 100644 --- a/src/core/hle/service/filesystem/fsp_ldr.cpp +++ b/src/core/hle/service/filesystem/fsp_ldr.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once - #include "core/hle/service/filesystem/fsp_ldr.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/filesystem/fsp_pr.cpp b/src/core/hle/service/filesystem/fsp_pr.cpp index 0b51385ee..32b0ae454 100644 --- a/src/core/hle/service/filesystem/fsp_pr.cpp +++ b/src/core/hle/service/filesystem/fsp_pr.cpp @@ -2,8 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#pragma once - #include "core/hle/service/filesystem/fsp_pr.h" #include "core/hle/service/service.h" diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index ed69a4325..2b74e6a33 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp @@ -30,9 +30,9 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 addr, offset, width, height, stride, static_cast<PixelFormat>(format), transform, crop_rect}; - Core::System::GetInstance().perf_stats.EndGameFrame(); - - VideoCore::g_renderer->SwapBuffers(framebuffer); + auto& instance = Core::System::GetInstance(); + instance.perf_stats.EndGameFrame(); + instance.Renderer().SwapBuffers(framebuffer); } } // namespace Service::Nvidia::Devices diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 57b128b40..4b601781f 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -150,15 +150,16 @@ u32 nvhost_as_gpu::UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& ou LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", params.offset); - auto& gpu = Core::System::GetInstance().GPU(); - - auto itr = buffer_mappings.find(params.offset); - + const auto itr = buffer_mappings.find(params.offset); ASSERT_MSG(itr != buffer_mappings.end(), "Tried to unmap invalid mapping"); + auto& system_instance = Core::System::GetInstance(); + // Remove this memory region from the rasterizer cache. - VideoCore::g_renderer->Rasterizer()->FlushAndInvalidateRegion(params.offset, itr->second.size); + system_instance.Renderer().Rasterizer().FlushAndInvalidateRegion(params.offset, + itr->second.size); + auto& gpu = system_instance.GPU(); params.offset = gpu.memory_manager->UnmapBuffer(params.offset, itr->second.size); buffer_mappings.erase(itr->second.offset); diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp index 5344441e1..0bf51062c 100644 --- a/src/core/hle/service/nvflinger/nvflinger.cpp +++ b/src/core/hle/service/nvflinger/nvflinger.cpp @@ -127,9 +127,11 @@ void NVFlinger::Compose() { MicroProfileFlip(); if (buffer == boost::none) { + auto& system_instance = Core::System::GetInstance(); + // There was no queued buffer to draw, render previous frame - Core::System::GetInstance().perf_stats.EndGameFrame(); - VideoCore::g_renderer->SwapBuffers({}); + system_instance.perf_stats.EndGameFrame(); + system_instance.Renderer().SwapBuffers({}); continue; } diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 61e0c34a0..31ea79773 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -19,6 +19,7 @@ #include "core/hle/service/am/am.h" #include "core/hle/service/aoc/aoc_u.h" #include "core/hle/service/apm/apm.h" +#include "core/hle/service/arp/arp.h" #include "core/hle/service/audio/audio.h" #include "core/hle/service/bcat/bcat.h" #include "core/hle/service/bpc/bpc.h" @@ -207,6 +208,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { AM::InstallInterfaces(*sm, nv_flinger); AOC::InstallInterfaces(*sm); APM::InstallInterfaces(*sm); + ARP::InstallInterfaces(*sm); Audio::InstallInterfaces(*sm); BCAT::InstallInterfaces(*sm); BPC::InstallInterfaces(*sm); diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 4b3bb7b31..1133bcbaf 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -326,43 +326,45 @@ void RasterizerMarkRegionCached(Tegra::GPUVAddr gpu_addr, u64 size, bool cached) } void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) { + auto& system_instance = Core::System::GetInstance(); + // Since pages are unmapped on shutdown after video core is shutdown, the renderer may be // null here - if (VideoCore::g_renderer == nullptr) { + if (!system_instance.IsPoweredOn()) { return; } VAddr end = start + size; - auto CheckRegion = [&](VAddr region_start, VAddr region_end) { + const auto CheckRegion = [&](VAddr region_start, VAddr region_end) { if (start >= region_end || end <= region_start) { // No overlap with region return; } - VAddr overlap_start = std::max(start, region_start); - VAddr overlap_end = std::min(end, region_end); + const VAddr overlap_start = std::max(start, region_start); + const VAddr overlap_end = std::min(end, region_end); - std::vector<Tegra::GPUVAddr> gpu_addresses = - Core::System::GetInstance().GPU().memory_manager->CpuToGpuAddress(overlap_start); + const std::vector<Tegra::GPUVAddr> gpu_addresses = + system_instance.GPU().memory_manager->CpuToGpuAddress(overlap_start); if (gpu_addresses.empty()) { return; } - u64 overlap_size = overlap_end - overlap_start; + const u64 overlap_size = overlap_end - overlap_start; for (const auto& gpu_address : gpu_addresses) { - auto* rasterizer = VideoCore::g_renderer->Rasterizer(); + auto& rasterizer = system_instance.Renderer().Rasterizer(); switch (mode) { case FlushMode::Flush: - rasterizer->FlushRegion(gpu_address, overlap_size); + rasterizer.FlushRegion(gpu_address, overlap_size); break; case FlushMode::Invalidate: - rasterizer->InvalidateRegion(gpu_address, overlap_size); + rasterizer.InvalidateRegion(gpu_address, overlap_size); break; case FlushMode::FlushAndInvalidate: - rasterizer->FlushAndInvalidateRegion(gpu_address, overlap_size); + rasterizer.FlushAndInvalidateRegion(gpu_address, overlap_size); break; } } diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 79e0b347b..a4623223d 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/gdbstub/gdbstub.h" #include "core/hle/service/hid/hid.h" #include "core/settings.h" @@ -19,8 +20,9 @@ void Apply() { VideoCore::g_toggle_framelimit_enabled = values.toggle_framelimit; - if (VideoCore::g_renderer) { - VideoCore::g_renderer->UpdateCurrentFramebufferLayout(); + auto& system_instance = Core::System::GetInstance(); + if (system_instance.IsPoweredOn()) { + system_instance.Renderer().UpdateCurrentFramebufferLayout(); } Service::HID::ReloadInputDevices(); |