gl_buffer_cache: Implement flushing
This commit is contained in:
parent
345f852bdb
commit
d14fbfb9b5
2 changed files with 11 additions and 2 deletions
|
@ -31,7 +31,7 @@ OGLBuffer CreateBuffer(std::size_t size, GLenum usage) {
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
CachedBufferEntry::CachedBufferEntry(VAddr cpu_addr, u8* host_ptr)
|
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)
|
OGLBufferCache::OGLBufferCache(RasterizerOpenGL& rasterizer, std::size_t size)
|
||||||
: RasterizerCache{rasterizer}, stream_buffer(size, true) {}
|
: RasterizerCache{rasterizer}, stream_buffer(size, true) {}
|
||||||
|
@ -100,6 +100,10 @@ void OGLBufferCache::Unmap() {
|
||||||
stream_buffer.Unmap(buffer_offset - buffer_offset_base);
|
stream_buffer.Unmap(buffer_offset - buffer_offset_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OGLBufferCache::FlushObjectInner(const std::shared_ptr<CachedBufferEntry>& entry) {
|
||||||
|
glGetNamedBufferSubData(entry->GetBuffer(), 0, entry->GetSize(), entry->GetWritableHostPtr());
|
||||||
|
}
|
||||||
|
|
||||||
OGLBufferCache::BufferInfo OGLBufferCache::StreamBufferUpload(const void* raw_pointer,
|
OGLBufferCache::BufferInfo OGLBufferCache::StreamBufferUpload(const void* raw_pointer,
|
||||||
std::size_t size,
|
std::size_t size,
|
||||||
std::size_t alignment) {
|
std::size_t alignment) {
|
||||||
|
|
|
@ -33,6 +33,10 @@ public:
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8* GetWritableHostPtr() const {
|
||||||
|
return host_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t GetSize() const {
|
std::size_t GetSize() const {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -63,6 +67,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
u8* host_ptr{};
|
||||||
VAddr cpu_addr{};
|
VAddr cpu_addr{};
|
||||||
std::size_t size{};
|
std::size_t size{};
|
||||||
std::size_t capacity{};
|
std::size_t capacity{};
|
||||||
|
@ -93,7 +98,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// We do not have to flush this cache as things in it are never modified by us.
|
// We do not have to flush this cache as things in it are never modified by us.
|
||||||
void FlushObjectInner(const std::shared_ptr<CachedBufferEntry>& object) override {}
|
void FlushObjectInner(const std::shared_ptr<CachedBufferEntry>& entry) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BufferInfo StreamBufferUpload(const void* raw_pointer, std::size_t size, std::size_t alignment);
|
BufferInfo StreamBufferUpload(const void* raw_pointer, std::size_t size, std::size_t alignment);
|
||||||
|
|
Loading…
Reference in a new issue