diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index 3ce61c5cd5..fb3aedd07d 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp @@ -33,8 +33,8 @@ OGLBuffer CreateBuffer(std::size_t size, GLenum usage) { CachedBufferEntry::CachedBufferEntry(VAddr cpu_addr, u8* host_ptr) : RasterizerCacheObject{host_ptr}, host_ptr{host_ptr}, cpu_addr{cpu_addr} {} -OGLBufferCache::OGLBufferCache(RasterizerOpenGL& rasterizer, std::size_t size) - : RasterizerCache{rasterizer}, stream_buffer(size, true) {} +OGLBufferCache::OGLBufferCache(RasterizerOpenGL& rasterizer, Core::System& system, std::size_t size) + : RasterizerCache{rasterizer}, system{system}, stream_buffer(size, true) {} OGLBufferCache::~OGLBufferCache() = default; @@ -53,7 +53,7 @@ OGLBufferCache::BufferInfo OGLBufferCache::UploadMemory(GPUVAddr gpu_addr, std:: bool is_written) { std::lock_guard lock{mutex}; - auto& memory_manager = Core::System::GetInstance().GPU().MemoryManager(); + auto& memory_manager = system.GPU().MemoryManager(); const auto host_ptr{memory_manager.GetPointer(gpu_addr)}; const auto cache_addr{ToCacheAddr(host_ptr)}; if (!host_ptr) { @@ -119,7 +119,7 @@ OGLBufferCache::BufferInfo OGLBufferCache::StreamBufferUpload(const void* raw_po OGLBufferCache::BufferInfo OGLBufferCache::FixedBufferUpload(GPUVAddr gpu_addr, u8* host_ptr, std::size_t size, bool internalize, bool is_written) { - auto& memory_manager = Core::System::GetInstance().GPU().MemoryManager(); + auto& memory_manager = system.GPU().MemoryManager(); const auto cpu_addr = *memory_manager.GpuToCpuAddress(gpu_addr); auto entry = GetUncachedBuffer(cpu_addr, host_ptr); entry->SetSize(size); @@ -161,7 +161,7 @@ void OGLBufferCache::GrowBuffer(std::shared_ptr& entry, std:: } std::shared_ptr OGLBufferCache::GetUncachedBuffer(VAddr cpu_addr, u8* host_ptr) { - if (auto entry = TryGetReservedBuffer(host_ptr); entry) { + if (auto entry = TryGetReservedBuffer(host_ptr)) { return entry; } return std::make_shared(cpu_addr, host_ptr); diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index 4267a5067b..19d643e419 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h @@ -17,6 +17,10 @@ #include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/gl_stream_buffer.h" +namespace Core { +class System; +} + namespace OpenGL { class RasterizerOpenGL; @@ -79,7 +83,7 @@ class OGLBufferCache final : public RasterizerCache; public: - explicit OGLBufferCache(RasterizerOpenGL& rasterizer, std::size_t size); + explicit OGLBufferCache(RasterizerOpenGL& rasterizer, Core::System& system, std::size_t size); ~OGLBufferCache(); void Unregister(const std::shared_ptr& entry) override; @@ -116,6 +120,8 @@ private: void AlignBuffer(std::size_t alignment); + Core::System& system; + u8* buffer_ptr = nullptr; GLintptr buffer_offset = 0; GLintptr buffer_offset_base = 0; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index d1790f24fd..35ba842355 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -83,9 +83,8 @@ struct DrawParameters { RasterizerOpenGL::RasterizerOpenGL(Core::System& system, Core::Frontend::EmuWindow& emu_window, ScreenInfo& info) - : texture_cache{system, *this, device}, - shader_cache{*this, system, emu_window, device}, system{system}, screen_info{info}, - buffer_cache(*this, STREAM_BUFFER_SIZE) { + : texture_cache{system, *this, device}, shader_cache{*this, system, emu_window, device}, + system{system}, screen_info{info}, buffer_cache{*this, system, STREAM_BUFFER_SIZE} { OpenGLState::ApplyDefaultState(); shader_program_manager = std::make_unique();