From d14fbfb9b594f003f11902d53f8993466486dc9d Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Wed, 29 May 2019 21:08:33 -0300 Subject: gl_buffer_cache: Implement flushing --- src/video_core/renderer_opengl/gl_buffer_cache.cpp | 6 +++++- src/video_core/renderer_opengl/gl_buffer_cache.h | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index 2f603e3d7..3ce61c5cd 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp @@ -31,7 +31,7 @@ OGLBuffer CreateBuffer(std::size_t size, GLenum usage) { } // Anonymous namespace CachedBufferEntry::CachedBufferEntry(VAddr cpu_addr, u8* host_ptr) - : RasterizerCacheObject{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) : RasterizerCache{rasterizer}, stream_buffer(size, true) {} @@ -100,6 +100,10 @@ void OGLBufferCache::Unmap() { stream_buffer.Unmap(buffer_offset - buffer_offset_base); } +void OGLBufferCache::FlushObjectInner(const std::shared_ptr& entry) { + glGetNamedBufferSubData(entry->GetBuffer(), 0, entry->GetSize(), entry->GetWritableHostPtr()); +} + OGLBufferCache::BufferInfo OGLBufferCache::StreamBufferUpload(const void* raw_pointer, std::size_t size, std::size_t alignment) { diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index b4fbd201d..4267a5067 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h @@ -33,6 +33,10 @@ public: return size; } + u8* GetWritableHostPtr() const { + return host_ptr; + } + std::size_t GetSize() const { return size; } @@ -63,6 +67,7 @@ public: } private: + u8* host_ptr{}; VAddr cpu_addr{}; std::size_t size{}; std::size_t capacity{}; @@ -93,7 +98,7 @@ public: protected: // We do not have to flush this cache as things in it are never modified by us. - void FlushObjectInner(const std::shared_ptr& object) override {} + void FlushObjectInner(const std::shared_ptr& entry) override; private: BufferInfo StreamBufferUpload(const void* raw_pointer, std::size_t size, std::size_t alignment); -- cgit v1.2.3