From 90a048afc214745db49907f9dd6d1edfc8dada84 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Thu, 7 Aug 2025 21:30:25 +0300 Subject: [PATCH] Fix uninitialized warning and remove header pollution --- include/dynarmic_cp15.hpp | 86 +++++++------------ include/emulator.hpp | 6 -- include/helpers.hpp | 8 +- include/kernel/kernel.hpp | 5 +- include/kernel/kernel_types.hpp | 2 - include/renderer.hpp | 5 -- include/renderer_mtl/mtl_command_encoder.hpp | 2 + .../renderer_mtl/mtl_depth_stencil_cache.hpp | 2 +- .../renderer_mtl/mtl_draw_pipeline_cache.hpp | 1 + include/renderer_mtl/mtl_lut_texture.hpp | 27 +++--- .../renderer_mtl/mtl_vertex_buffer_cache.hpp | 1 - include/renderer_mtl/pica_to_mtl.hpp | 1 + include/scheduler.hpp | 1 - src/emulator.cpp | 4 +- 14 files changed, 60 insertions(+), 91 deletions(-) diff --git a/include/dynarmic_cp15.hpp b/include/dynarmic_cp15.hpp index 1345aad4..ba7fbbf1 100644 --- a/include/dynarmic_cp15.hpp +++ b/include/dynarmic_cp15.hpp @@ -1,71 +1,51 @@ #pragma once -#include "dynarmic/interface/A32/a32.h" #include "dynarmic/interface/A32/config.h" #include "dynarmic/interface/A32/coprocessor.h" #include "helpers.hpp" -#include "memory.hpp" class CP15 final : public Dynarmic::A32::Coprocessor { - using Callback = Dynarmic::A32::Coprocessor::Callback; - using CoprocReg = Dynarmic::A32::CoprocReg; - using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord; - using CallbackOrAccessTwoWords = Dynarmic::A32::Coprocessor::CallbackOrAccessTwoWords; + using Callback = Dynarmic::A32::Coprocessor::Callback; + using CoprocReg = Dynarmic::A32::CoprocReg; + using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord; + using CallbackOrAccessTwoWords = Dynarmic::A32::Coprocessor::CallbackOrAccessTwoWords; - u32 threadStoragePointer; // Pointer to thread-local storage - u32 dummy; // MCR writes here for registers whose values are ignored + u32 threadStoragePointer; // Pointer to thread-local storage + u32 dummy; // MCR writes here for registers whose values are ignored - std::optional CompileInternalOperation(bool two, unsigned opc1, - CoprocReg CRd, CoprocReg CRn, - CoprocReg CRm, unsigned opc2) override { - return std::nullopt; - } + std::optional CompileInternalOperation(bool two, unsigned opc1, CoprocReg CRd, CoprocReg CRn, CoprocReg CRm, unsigned opc2) override { + return std::nullopt; + } - CallbackOrAccessOneWord CompileSendOneWord(bool two, unsigned opc1, CoprocReg CRn, - CoprocReg CRm, unsigned opc2) override { - if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 4) { - return &dummy; // Normally inserts a "Data Synchronization Barrier" - } + CallbackOrAccessOneWord CompileSendOneWord(bool two, unsigned opc1, CoprocReg CRn, CoprocReg CRm, unsigned opc2) override { + if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 4) { + return &dummy; // Normally inserts a "Data Synchronization Barrier" + } - if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 5) { - return &dummy; // Normally inserts a "Data Memory Barrier" - } - Helpers::panic("CP15: CompileSendOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2); - } + if (!two && opc1 == 0 && CRn == CoprocReg::C7 && CRm == CoprocReg::C10 && opc2 == 5) { + return &dummy; // Normally inserts a "Data Memory Barrier" + } + Helpers::panic("CP15: CompileSendOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2); + } - CallbackOrAccessTwoWords CompileSendTwoWords(bool two, unsigned opc, CoprocReg CRm) override { - return std::monostate{}; - } + CallbackOrAccessOneWord CompileGetOneWord(bool two, unsigned opc1, CoprocReg CRn, CoprocReg CRm, unsigned opc2) override { + // Stores a pointer to thread-local storage, accessed via mrc p15, 0, rd, c13, c0, 3 + if (!two && CRn == CoprocReg::C13 && opc1 == 0 && CRm == CoprocReg::C0 && opc2 == 3) { + return &threadStoragePointer; + } - CallbackOrAccessOneWord CompileGetOneWord(bool two, unsigned opc1, CoprocReg CRn, - CoprocReg CRm, unsigned opc2) override { - // Stores a pointer to thread-local storage, accessed via mrc p15, 0, rd, c13, c0, 3 - if (!two && CRn == CoprocReg::C13 && opc1 == 0 && CRm == CoprocReg::C0 && opc2 == 3) { - return &threadStoragePointer; - } + Helpers::panic("CP15: CompileGetOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2); + } - Helpers::panic("CP15: CompileGetOneWord\nopc1: %d CRn: %d CRm: %d opc2: %d\n", opc1, (int)CRn, (int)CRm, opc2); - } + CallbackOrAccessTwoWords CompileSendTwoWords(bool two, unsigned opc, CoprocReg CRm) override { return std::monostate{}; } + CallbackOrAccessTwoWords CompileGetTwoWords(bool two, unsigned opc, CoprocReg CRm) override { return std::monostate{}; } - CallbackOrAccessTwoWords CompileGetTwoWords(bool two, unsigned opc, CoprocReg CRm) override { - return std::monostate{}; - } + std::optional CompileLoadWords(bool two, bool long_transfer, CoprocReg CRd, std::optional option) override { return std::nullopt; } + std::optional CompileStoreWords(bool two, bool long_transfer, CoprocReg CRd, std::optional option) override { return std::nullopt; } - std::optional CompileLoadWords(bool two, bool long_transfer, CoprocReg CRd, - std::optional option) override { - return std::nullopt; - } + public: + void setTLSBase(u32 value) { threadStoragePointer = value; } - std::optional CompileStoreWords(bool two, bool long_transfer, CoprocReg CRd, - std::optional option) override { - return std::nullopt; - } - -public: - void setTLSBase(u32 value) { - threadStoragePointer = value; - } - - // Currently does nothing but may be needed in the future - void reset() {} + // Currently does nothing but may be needed in the future + void reset() {} }; \ No newline at end of file diff --git a/include/emulator.hpp b/include/emulator.hpp index cd39f1c4..b1191f6e 100644 --- a/include/emulator.hpp +++ b/include/emulator.hpp @@ -24,12 +24,6 @@ #include "http_server.hpp" #endif -#ifdef PANDA3DS_FRONTEND_QT -#include "gl/context.h" -#endif - -struct SDL_Window; - enum class ROMType { None, ELF, diff --git a/include/helpers.hpp b/include/helpers.hpp index a95931d4..e13aed7e 100644 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -3,10 +3,8 @@ #include #include #include -#include -#include -#include #include +#include #include "termcolor.hpp" @@ -37,7 +35,7 @@ namespace Helpers { return {}; } const auto buf = std::make_unique(size); - std::snprintf(buf.get(), size, fmt.c_str(), args ...); + std::snprintf(buf.get(), size, fmt.c_str(), args...); return std::string(buf.get(), buf.get() + size - 1); } @@ -50,7 +48,7 @@ namespace Helpers { exit(1); } - + #ifdef PANDA3DS_LIMITED_PANICS template static void panicDev(const char* fmt, Args&&... args) {} diff --git a/include/kernel/kernel.hpp b/include/kernel/kernel.hpp index 7bda8c0a..b8c5f9ba 100644 --- a/include/kernel/kernel.hpp +++ b/include/kernel/kernel.hpp @@ -1,7 +1,5 @@ #pragma once #include -#include -#include #include #include #include @@ -26,8 +24,10 @@ class Kernel { CPU& cpu; Memory& mem; + public: KFcram fcramManager; + private: // The handle number for the next kernel object to be created u32 handleCounter; // A list of our OS threads, the max number of which depends on the resource limit (hardcoded 32 per process on retail it seems). @@ -250,7 +250,6 @@ class Kernel { } ServiceManager& getServiceManager() { return serviceManager; } - KFcram& getFcramManager() { return fcramManager; } Scheduler& getScheduler(); void sendGPUInterrupt(GPUInterrupt type) { serviceManager.sendGPUInterrupt(type); } diff --git a/include/kernel/kernel_types.hpp b/include/kernel/kernel_types.hpp index a55d2742..958768be 100644 --- a/include/kernel/kernel_types.hpp +++ b/include/kernel/kernel_types.hpp @@ -2,10 +2,8 @@ #include #include -#include "fs/archive_base.hpp" #include "handles.hpp" #include "helpers.hpp" -#include "result/result.hpp" enum class KernelObjectType : u8 { AddressArbiter, diff --git a/include/renderer.hpp b/include/renderer.hpp index b3f81faf..27d6a437 100644 --- a/include/renderer.hpp +++ b/include/renderer.hpp @@ -9,10 +9,6 @@ #include "PICA/regs.hpp" #include "helpers.hpp" -#ifdef PANDA3DS_FRONTEND_QT -#include "gl/context.h" -#endif - enum class RendererType : s8 { // Todo: Auto = -1, Null = 0, @@ -23,7 +19,6 @@ enum class RendererType : s8 { }; struct EmulatorConfig; -struct SDL_Window; class GPU; class ShaderUnit; diff --git a/include/renderer_mtl/mtl_command_encoder.hpp b/include/renderer_mtl/mtl_command_encoder.hpp index 562e6b79..ce758e19 100644 --- a/include/renderer_mtl/mtl_command_encoder.hpp +++ b/include/renderer_mtl/mtl_command_encoder.hpp @@ -2,6 +2,8 @@ #include +#include "helpers.hpp" + namespace Metal { struct RenderState { MTL::RenderPipelineState* renderPipelineState = nullptr; diff --git a/include/renderer_mtl/mtl_depth_stencil_cache.hpp b/include/renderer_mtl/mtl_depth_stencil_cache.hpp index 8f7256a9..b902346d 100644 --- a/include/renderer_mtl/mtl_depth_stencil_cache.hpp +++ b/include/renderer_mtl/mtl_depth_stencil_cache.hpp @@ -2,6 +2,7 @@ #include +#include "helpers.hpp" #include "pica_to_mtl.hpp" using namespace PICA; @@ -17,7 +18,6 @@ namespace Metal { class DepthStencilCache { public: DepthStencilCache() = default; - ~DepthStencilCache() { reset(); } void set(MTL::Device* dev) { device = dev; } diff --git a/include/renderer_mtl/mtl_draw_pipeline_cache.hpp b/include/renderer_mtl/mtl_draw_pipeline_cache.hpp index 7178785e..17bead9a 100644 --- a/include/renderer_mtl/mtl_draw_pipeline_cache.hpp +++ b/include/renderer_mtl/mtl_draw_pipeline_cache.hpp @@ -2,6 +2,7 @@ #include +#include "helpers.hpp" #include "objc_helper.hpp" #include "pica_to_mtl.hpp" diff --git a/include/renderer_mtl/mtl_lut_texture.hpp b/include/renderer_mtl/mtl_lut_texture.hpp index 531dc73c..e2f67b6b 100644 --- a/include/renderer_mtl/mtl_lut_texture.hpp +++ b/include/renderer_mtl/mtl_lut_texture.hpp @@ -2,19 +2,22 @@ #include +#include "helpers.hpp" + namespace Metal { -class LutTexture { -public: - LutTexture(MTL::Device* device, MTL::TextureType type, MTL::PixelFormat pixelFormat, u32 width, u32 height, const char* name); - ~LutTexture(); - u32 getNextIndex(); + class LutTexture { + public: + LutTexture(MTL::Device* device, MTL::TextureType type, MTL::PixelFormat pixelFormat, u32 width, u32 height, const char* name); + ~LutTexture(); + u32 getNextIndex(); - MTL::Texture* getTexture() { return texture; } - u32 getCurrentIndex() { return currentIndex; } -private: - MTL::Texture* texture; - u32 currentIndex = 0; -}; + MTL::Texture* getTexture() { return texture; } + u32 getCurrentIndex() { return currentIndex; } -} // namespace Metal + private: + MTL::Texture* texture; + u32 currentIndex = 0; + }; + +} // namespace Metal diff --git a/include/renderer_mtl/mtl_vertex_buffer_cache.hpp b/include/renderer_mtl/mtl_vertex_buffer_cache.hpp index b392389c..d50ea336 100644 --- a/include/renderer_mtl/mtl_vertex_buffer_cache.hpp +++ b/include/renderer_mtl/mtl_vertex_buffer_cache.hpp @@ -5,7 +5,6 @@ #include "helpers.hpp" #include "pica_to_mtl.hpp" - using namespace PICA; namespace Metal { diff --git a/include/renderer_mtl/pica_to_mtl.hpp b/include/renderer_mtl/pica_to_mtl.hpp index 5e9f62c4..94474dad 100644 --- a/include/renderer_mtl/pica_to_mtl.hpp +++ b/include/renderer_mtl/pica_to_mtl.hpp @@ -3,6 +3,7 @@ #include #include "PICA/regs.hpp" +#include "helpers.hpp" // TODO: remove dependency on OpenGL #include "opengl.hpp" diff --git a/include/scheduler.hpp b/include/scheduler.hpp index 8765ae66..b5bdad68 100644 --- a/include/scheduler.hpp +++ b/include/scheduler.hpp @@ -4,7 +4,6 @@ #include #include "helpers.hpp" -#include "logger.hpp" struct Scheduler { enum class EventType { diff --git a/src/emulator.cpp b/src/emulator.cpp index 2af529de..5ea7ce02 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -20,8 +20,8 @@ __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1; Emulator::Emulator() : config(getConfigPath()), kernel(cpu, memory, gpu, config, lua), cpu(memory, kernel, *this), gpu(memory, config), - memory(kernel.getFcramManager(), config), cheats(memory, kernel.getServiceManager().getHID()), audioDevice(config.audioDeviceConfig), - lua(*this), running(false) + memory(kernel.fcramManager, config), cheats(memory, kernel.getServiceManager().getHID()), audioDevice(config.audioDeviceConfig), lua(*this), + running(false) #ifdef PANDA3DS_ENABLE_HTTP_SERVER , httpServer(this)