mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-27 06:55:37 +00:00
gl_buffer_cache: Remove global system getters
This commit is contained in:
parent
02ab844934
commit
2bcae41a73
|
@ -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<CachedBufferEntry>& entry, std::
|
|||
}
|
||||
|
||||
std::shared_ptr<CachedBufferEntry> 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<CachedBufferEntry>(cpu_addr, host_ptr);
|
||||
|
|
|
@ -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<std::shared_ptr<CachedBuffer
|
|||
using BufferInfo = std::pair<GLuint, GLintptr>;
|
||||
|
||||
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<CachedBufferEntry>& 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;
|
||||
|
|
|
@ -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<GLShader::ProgramManager>();
|
||||
|
|
Loading…
Reference in a new issue