From bdcf83ca45ccf594227c0d04bc9dcadc54343406 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 27 Feb 2019 10:53:32 +0100 Subject: [PATCH] gsdx ogl: sparse texture : only commit new area Avoid potential driver overhead --- .../GSdx/Renderers/OpenGL/GSTextureOGL.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp b/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp index 445dc76e58..0fed07d4ea 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp +++ b/plugins/GSdx/Renderers/OpenGL/GSTextureOGL.cpp @@ -520,17 +520,32 @@ 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); + if (m_committed_size.x == 0) { + // Nothing allocated so far + GL_INS("CommitPages initial %dx%d of %u", region.x, region.y, m_texture_id); + glTexturePageCommitmentEXT(m_texture_id, GL_TEX_LEVEL_0, 0, 0, 0, region.x, region.y, 1, commit); + } else { + GL_INS("CommitPages extend %dx%d to %dx%d of %u", m_committed_size.x, m_committed_size.y, region.x, region.y, m_texture_id); + int w = region.x - m_committed_size.x; + int h = region.y - m_committed_size.y; + // Extend width + glTexturePageCommitmentEXT(m_texture_id, GL_TEX_LEVEL_0, m_committed_size.x, 0, 0, w, m_committed_size.y, 1, commit); + // Extend height + glTexturePageCommitmentEXT(m_texture_id, GL_TEX_LEVEL_0, 0, m_committed_size.y, 0, region.x, h, 1, commit); + } m_committed_size = region; + } else { + // Release everything GL_INS("CommitPages release of %u", m_texture_id); + + glTexturePageCommitmentEXT(m_texture_id, GL_TEX_LEVEL_0, 0, 0, 0, m_committed_size.x, m_committed_size.y, 1, commit); + 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)