From 7a2427020ec6ead73258aeb326dfb7e0121520f9 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 1 Jul 2018 12:15:17 +0300 Subject: [PATCH 1/1] Use DSA for binding textures if available --- source/texture.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/source/texture.cpp b/source/texture.cpp index fb409e89..f095fe98 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -321,15 +321,20 @@ void Texture::bind_to(unsigned i) const if(manager) manager->resource_used(*this); - unit.bind(); - if(unit.supports_legacy()) + if(ARB_direct_state_access && !unit.supports_legacy()) + glBindTextureUnit(i, id); + else { - if(old && old->target!=target) - glDisable(old->target); - if(!old || old->target!=target) - glEnable(target); + unit.bind(); + if(unit.supports_legacy()) + { + if(old && old->target!=target) + glDisable(old->target); + if((!old || old->target!=target)) + glEnable(target); + } + glBindTexture(target, id); } - glBindTexture(target, id); if(dirty_params) { @@ -350,10 +355,15 @@ void Texture::unbind_from(unsigned i) const Texture *cur = unit.get_texture(); if(unit.set_texture(0)) { - unit.bind(); - glBindTexture(cur->target, 0); - if(unit.supports_legacy()) - glDisable(cur->target); + if(ARB_direct_state_access && !unit.supports_legacy()) + glBindTextureUnit(i, 0); + else + { + unit.bind(); + glBindTexture(cur->target, 0); + if(unit.supports_legacy()) + glDisable(cur->target); + } } } -- 2.43.0