From a0c7b5ca791f659d9c98654b47246092aad42665 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 29 Oct 2010 06:30:45 +0200 Subject: JOGL: HashMap ProcAddressTable for all GL profiles incl GLX/WGL/CGL/EGL Reduce (performance/footprint) overhead of ProcAddressTable recreation, instead use a hashmap (major, minor, profile) -> ProcAddressTable. Remove GL2ES12 implementation profile, redundant. --- .../opengl/impl/windows/wgl/WindowsWGLContext.java | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/jogl/classes/com/jogamp/opengl/impl/windows/wgl') diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java index 65a8e8ac3..027fb0065 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java @@ -340,12 +340,30 @@ public class WindowsWGLContext extends GLContextImpl { wglMakeContextCurrentInitialized=false; wglMakeContextCurrentAvailable=false; - if (wglExtProcAddressTable == null) { - // FIXME: cache ProcAddressTables by OpenGL context type bits so we can - // share them among contexts classes (GL4, GL4bc, GL3, GL3bc, ..) - wglExtProcAddressTable = new WGLExtProcAddressTable(new GLProcAddressResolver()); - } - resetProcAddressTable(getWGLExtProcAddressTable()); + int key = compose8bit(major, minor, ctp, 0); + WGLExtProcAddressTable table = null; + synchronized(mappedProcAddressLock) { + table = (WGLExtProcAddressTable) mappedGLXProcAddress.get( key ); + } + if(null != table) { + wglExtProcAddressTable = table; + if(DEBUG) { + System.err.println("GLContext WGL ProcAddressTable reusing key("+major+","+minor+","+ctp+") -> "+table.hashCode()); + } + } else { + if (wglExtProcAddressTable == null) { + // FIXME: cache ProcAddressTables by OpenGL context type bits so we can + // share them among contexts classes (GL4, GL4bc, GL3, GL3bc, ..) + wglExtProcAddressTable = new WGLExtProcAddressTable(new GLProcAddressResolver()); + } + resetProcAddressTable(getWGLExtProcAddressTable()); + synchronized(mappedProcAddressLock) { + mappedGLXProcAddress.put(key, getWGLExtProcAddressTable()); + if(DEBUG) { + System.err.println("GLContext WGL ProcAddressTable mapping key("+major+","+minor+","+ctp+") -> "+getWGLExtProcAddressTable().hashCode()); + } + } + } super.updateGLProcAddressTable(major, minor, ctp); } -- cgit v1.2.3