gl_buffer_cache: Remove global system getters
This commit is contained in:
parent
02ab844934
commit
2bcae41a73
3 changed files with 14 additions and 9 deletions
|
@ -33,8 +33,8 @@ OGLBuffer CreateBuffer(std::size_t size, GLenum usage) {
|
||||||
CachedBufferEntry::CachedBufferEntry(VAddr cpu_addr, u8* host_ptr)
|
CachedBufferEntry::CachedBufferEntry(VAddr cpu_addr, u8* host_ptr)
|
||||||
: RasterizerCacheObject{host_ptr}, host_ptr{host_ptr}, cpu_addr{cpu_addr} {}
|
: RasterizerCacheObject{host_ptr}, host_ptr{host_ptr}, cpu_addr{cpu_addr} {}
|
||||||
|
|
||||||
OGLBufferCache::OGLBufferCache(RasterizerOpenGL& rasterizer, std::size_t size)
|
OGLBufferCache::OGLBufferCache(RasterizerOpenGL& rasterizer, Core::System& system, std::size_t size)
|
||||||
: RasterizerCache{rasterizer}, stream_buffer(size, true) {}
|
: RasterizerCache{rasterizer}, system{system}, stream_buffer(size, true) {}
|
||||||
|
|
||||||
OGLBufferCache::~OGLBufferCache() = default;
|
OGLBufferCache::~OGLBufferCache() = default;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ OGLBufferCache::BufferInfo OGLBufferCache::UploadMemory(GPUVAddr gpu_addr, std::
|
||||||
bool is_written) {
|
bool is_written) {
|
||||||
std::lock_guard lock{mutex};
|
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 host_ptr{memory_manager.GetPointer(gpu_addr)};
|
||||||
const auto cache_addr{ToCacheAddr(host_ptr)};
|
const auto cache_addr{ToCacheAddr(host_ptr)};
|
||||||
if (!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,
|
OGLBufferCache::BufferInfo OGLBufferCache::FixedBufferUpload(GPUVAddr gpu_addr, u8* host_ptr,
|
||||||
std::size_t size, bool internalize,
|
std::size_t size, bool internalize,
|
||||||
bool is_written) {
|
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);
|
const auto cpu_addr = *memory_manager.GpuToCpuAddress(gpu_addr);
|
||||||
auto entry = GetUncachedBuffer(cpu_addr, host_ptr);
|
auto entry = GetUncachedBuffer(cpu_addr, host_ptr);
|
||||||
entry->SetSize(size);
|
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) {
|
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 entry;
|
||||||
}
|
}
|
||||||
return std::make_shared<CachedBufferEntry>(cpu_addr, host_ptr);
|
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_resource_manager.h"
|
||||||
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
class RasterizerOpenGL;
|
class RasterizerOpenGL;
|
||||||
|
@ -79,7 +83,7 @@ class OGLBufferCache final : public RasterizerCache<std::shared_ptr<CachedBuffer
|
||||||
using BufferInfo = std::pair<GLuint, GLintptr>;
|
using BufferInfo = std::pair<GLuint, GLintptr>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OGLBufferCache(RasterizerOpenGL& rasterizer, std::size_t size);
|
explicit OGLBufferCache(RasterizerOpenGL& rasterizer, Core::System& system, std::size_t size);
|
||||||
~OGLBufferCache();
|
~OGLBufferCache();
|
||||||
|
|
||||||
void Unregister(const std::shared_ptr<CachedBufferEntry>& entry) override;
|
void Unregister(const std::shared_ptr<CachedBufferEntry>& entry) override;
|
||||||
|
@ -116,6 +120,8 @@ private:
|
||||||
|
|
||||||
void AlignBuffer(std::size_t alignment);
|
void AlignBuffer(std::size_t alignment);
|
||||||
|
|
||||||
|
Core::System& system;
|
||||||
|
|
||||||
u8* buffer_ptr = nullptr;
|
u8* buffer_ptr = nullptr;
|
||||||
GLintptr buffer_offset = 0;
|
GLintptr buffer_offset = 0;
|
||||||
GLintptr buffer_offset_base = 0;
|
GLintptr buffer_offset_base = 0;
|
||||||
|
|
|
@ -83,9 +83,8 @@ struct DrawParameters {
|
||||||
|
|
||||||
RasterizerOpenGL::RasterizerOpenGL(Core::System& system, Core::Frontend::EmuWindow& emu_window,
|
RasterizerOpenGL::RasterizerOpenGL(Core::System& system, Core::Frontend::EmuWindow& emu_window,
|
||||||
ScreenInfo& info)
|
ScreenInfo& info)
|
||||||
: texture_cache{system, *this, device},
|
: texture_cache{system, *this, device}, shader_cache{*this, system, emu_window, device},
|
||||||
shader_cache{*this, system, emu_window, device}, system{system}, screen_info{info},
|
system{system}, screen_info{info}, buffer_cache{*this, system, STREAM_BUFFER_SIZE} {
|
||||||
buffer_cache(*this, STREAM_BUFFER_SIZE) {
|
|
||||||
OpenGLState::ApplyDefaultState();
|
OpenGLState::ApplyDefaultState();
|
||||||
|
|
||||||
shader_program_manager = std::make_unique<GLShader::ProgramManager>();
|
shader_program_manager = std::make_unique<GLShader::ProgramManager>();
|
||||||
|
|
Loading…
Reference in a new issue