From 16d5f477ff58d3f3fe2c659684735620c2725302 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 7 Feb 2019 12:17:15 +0100 Subject: [PATCH] gsdx ogl: implement CommitPages --- plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp | 18 ++++++++++++++++++ plugins/GSdx/Renderers/OpenGL/GSTextureOGL.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp b/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp index a0835c8791..d61765724c 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp +++ b/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp @@ -515,6 +515,24 @@ void GSTextureOGL::GenerateMipmap() } } +void GSTextureOGL::CommitPages(const GSVector2i& region, bool commit) +{ + GLState::available_vram += m_mem_usage; + + if (commit) { + GL_INS("CommitPages %dx%d of %u", region.x, region.y, m_texture_id); + m_committed_size = region; + } else { + GL_INS("CommitPages release of %u", m_texture_id); + m_committed_size = GSVector2i(0, 0); + } + + m_mem_usage = (m_committed_size.x * m_committed_size.y) << m_int_shift; + GLState::available_vram -= m_mem_usage; + + glTexturePageCommitmentEXT(m_texture_id, GL_TEX_LEVEL_0, 0, 0, 0, m_committed_size.x, m_committed_size.y, 1, commit); +} + bool GSTextureOGL::Save(const std::string& fn) { // Collect the texture data diff --git a/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.h b/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.h index 1f712899e2..69a38a5b21 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.h +++ b/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.h @@ -84,5 +84,7 @@ class GSTextureOGL final : public GSTexture void Clear(const void* data); void Clear(const void* data, const GSVector4i& area); + void CommitPages(const GSVector2i& region, bool commit) final; + uint32 GetMemUsage(); };