Moved the current BufferObjectInstance into ContextCapabilities to make it ThreadLocal
This commit is contained in:
parent
e5a0e67f6d
commit
412dfc7462
|
@ -64,6 +64,8 @@ public class ContextCapabilitiesGenerator {
|
|||
|
||||
public static void generateClassPrologue(PrintWriter writer, boolean context_specific) {
|
||||
writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
|
||||
writer.println("\tfinal BufferObjectTracker tracker;");
|
||||
writer.println();
|
||||
if (!context_specific) {
|
||||
writer.println("\tprivate static boolean " + STUBS_LOADED_NAME + " = false;");
|
||||
}
|
||||
|
@ -72,6 +74,7 @@ public class ContextCapabilitiesGenerator {
|
|||
public static void generateInitializerPrologue(PrintWriter writer) {
|
||||
writer.println("\t" + Utils.CONTEXT_CAPS_CLASS_NAME + "() throws LWJGLException {");
|
||||
writer.println("\t\tSet " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "();");
|
||||
writer.println("\t\ttracker = new BufferObjectTracker();");
|
||||
}
|
||||
|
||||
private static String translateFieldName(String interface_name) {
|
||||
|
|
|
@ -38,11 +38,6 @@ import java.nio.IntBuffer;
|
|||
|
||||
/** Track Vertex Buffer Objects by context. */
|
||||
final class BufferObjectTracker {
|
||||
|
||||
private static BufferObjectTracker current_tracker;
|
||||
|
||||
private static final Map contextToTracker = new WeakHashMap(3, 1.0f);
|
||||
|
||||
private final StateStack vbo_array_stack;
|
||||
private final StateStack vbo_element_stack;
|
||||
|
||||
|
@ -51,7 +46,7 @@ final class BufferObjectTracker {
|
|||
|
||||
private final StateStack attrib_stack;
|
||||
|
||||
private BufferObjectTracker() {
|
||||
BufferObjectTracker() {
|
||||
int stack_size = Math.max(1, Util.glGetInteger(GL11.GL_MAX_CLIENT_ATTRIB_STACK_DEPTH));
|
||||
|
||||
vbo_array_stack = new StateStack(stack_size, 0);
|
||||
|
@ -117,39 +112,22 @@ final class BufferObjectTracker {
|
|||
}
|
||||
|
||||
static StateStack getVBOArrayStack() {
|
||||
return current_tracker.vbo_array_stack;
|
||||
return GLContext.getCapabilities().tracker.vbo_array_stack;
|
||||
}
|
||||
|
||||
static StateStack getVBOElementStack() {
|
||||
return current_tracker.vbo_element_stack;
|
||||
return GLContext.getCapabilities().tracker.vbo_element_stack;
|
||||
}
|
||||
|
||||
static StateStack getPBOPackStack() {
|
||||
return current_tracker.pbo_pack_stack;
|
||||
return GLContext.getCapabilities().tracker.pbo_pack_stack;
|
||||
}
|
||||
|
||||
static StateStack getPBOUnpackStack() {
|
||||
return current_tracker.pbo_unpack_stack;
|
||||
return GLContext.getCapabilities().tracker.pbo_unpack_stack;
|
||||
}
|
||||
|
||||
static StateStack getClientAttribStack() {
|
||||
return current_tracker.attrib_stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after a GLContext has been made current. This will set up the current VBO tracker.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
static void setCurrent(Object context) {
|
||||
if ( context == null ) {
|
||||
current_tracker = null;
|
||||
return;
|
||||
}
|
||||
current_tracker = (BufferObjectTracker)contextToTracker.get(context);
|
||||
if ( current_tracker == null ) {
|
||||
current_tracker = new BufferObjectTracker();
|
||||
contextToTracker.put(context, current_tracker);
|
||||
}
|
||||
return GLContext.getCapabilities().tracker.attrib_stack;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import org.lwjgl.LWJGLException;
|
|||
import java.util.Set;
|
||||
|
||||
public class ContextCapabilities {
|
||||
final BufferObjectTracker tracker;
|
||||
|
||||
public final boolean GL_ARB_color_buffer_float;
|
||||
public final boolean GL_ARB_depth_texture;
|
||||
public final boolean GL_ARB_draw_buffers;
|
||||
|
@ -1997,6 +1999,7 @@ public class ContextCapabilities {
|
|||
|
||||
ContextCapabilities() throws LWJGLException {
|
||||
Set supported_extensions = initAllStubs();
|
||||
tracker = new BufferObjectTracker();
|
||||
this.GL_ARB_color_buffer_float = supported_extensions.contains("GL_ARB_color_buffer_float");
|
||||
this.GL_ARB_depth_texture = supported_extensions.contains("GL_ARB_depth_texture");
|
||||
this.GL_ARB_draw_buffers = supported_extensions.contains("GL_ARB_draw_buffers");
|
||||
|
|
|
@ -191,7 +191,6 @@ public final class GLContext {
|
|||
if (context == null) {
|
||||
ContextCapabilities.unloadAllStubs();
|
||||
setCapabilities(null);
|
||||
BufferObjectTracker.setCurrent(null);
|
||||
if (did_auto_load)
|
||||
unloadOpenGLLibrary();
|
||||
return;
|
||||
|
@ -213,7 +212,6 @@ public final class GLContext {
|
|||
capability_cache.put(context, getCapabilities());
|
||||
} else
|
||||
setCapabilities(capabilities);
|
||||
BufferObjectTracker.setCurrent(context);
|
||||
} catch (LWJGLException e) {
|
||||
if (did_auto_load)
|
||||
unloadOpenGLLibrary();
|
||||
|
|
Loading…
Reference in New Issue