mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 06:25:46 +00:00
Made all GL functions only query ContextCapabilities.getCapabilities() once. Now all GLCheck checks will take the ContextCapabilities instance as an argument instead of querying for it. Inspired by MatthiasM, who just don't seem to be content with LWJGL performance, ever ;)
This commit is contained in:
parent
905aec0877
commit
2502496b2d
113 changed files with 5698 additions and 4347 deletions
|
|
@ -55,70 +55,69 @@ class GLChecks {
|
|||
private GLChecks() {
|
||||
}
|
||||
|
||||
static References getReferences() {
|
||||
return StateTracker.getReferencesStack().getReferences();
|
||||
static References getReferences(ContextCapabilities caps) {
|
||||
return StateTracker.getReferencesStack(caps).getReferences();
|
||||
}
|
||||
|
||||
private static boolean checkBufferObject(int buffer_enum, boolean state) {
|
||||
IntBuffer scratch_buffer = GLContext.getCapabilities().scratch_int_buffer;
|
||||
private static boolean checkBufferObject(ContextCapabilities caps, int buffer_enum, boolean state) {
|
||||
IntBuffer scratch_buffer = caps.scratch_int_buffer;
|
||||
GL11.glGetInteger(buffer_enum, scratch_buffer);
|
||||
boolean is_enabled = scratch_buffer.get(0) != 0;
|
||||
return state == is_enabled;
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureArrayVBOdisabled() {
|
||||
if ((GLContext.getCapabilities().OpenGL15 && !checkBufferObject(GL15.GL_ARRAY_BUFFER_BINDING, false) ||
|
||||
(GLContext.getCapabilities().GL_ARB_vertex_buffer_object && !checkBufferObject(ARBVertexBufferObject.GL_ARRAY_BUFFER_BINDING_ARB, false))))
|
||||
static void ensureArrayVBOdisabled(ContextCapabilities caps) {
|
||||
if ((caps.OpenGL15 && !checkBufferObject(caps, GL15.GL_ARRAY_BUFFER_BINDING, false) ||
|
||||
(caps.GL_ARB_vertex_buffer_object && !checkBufferObject(caps, ARBVertexBufferObject.GL_ARRAY_BUFFER_BINDING_ARB, false))))
|
||||
throw new OpenGLException("Cannot use Buffers when Array Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureArrayVBOenabled() {
|
||||
if ((GLContext.getCapabilities().OpenGL15 && !checkBufferObject(GL15.GL_ARRAY_BUFFER_BINDING, true) ||
|
||||
(GLContext.getCapabilities().GL_ARB_vertex_buffer_object && !checkBufferObject(ARBVertexBufferObject.GL_ARRAY_BUFFER_BINDING_ARB, true))))
|
||||
static void ensureArrayVBOenabled(ContextCapabilities caps) {
|
||||
if ((caps.OpenGL15 && !checkBufferObject(caps, GL15.GL_ARRAY_BUFFER_BINDING, true) ||
|
||||
(caps.GL_ARB_vertex_buffer_object && !checkBufferObject(caps, ARBVertexBufferObject.GL_ARRAY_BUFFER_BINDING_ARB, true))))
|
||||
throw new OpenGLException("Cannot use offsets when Array Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that element array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureElementVBOdisabled() {
|
||||
if ((GLContext.getCapabilities().OpenGL15 && !checkBufferObject(GL15.GL_ELEMENT_ARRAY_BUFFER_BINDING, false) ||
|
||||
(GLContext.getCapabilities().GL_ARB_vertex_buffer_object && !checkBufferObject(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, false))))
|
||||
static void ensureElementVBOdisabled(ContextCapabilities caps) {
|
||||
if ((caps.OpenGL15 && !checkBufferObject(caps, GL15.GL_ELEMENT_ARRAY_BUFFER_BINDING, false) ||
|
||||
(caps.GL_ARB_vertex_buffer_object && !checkBufferObject(caps, ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, false))))
|
||||
throw new OpenGLException("Cannot use Buffers when Element Array Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that element array buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureElementVBOenabled() {
|
||||
if ((GLContext.getCapabilities().OpenGL15 && !checkBufferObject(GL15.GL_ELEMENT_ARRAY_BUFFER_BINDING, true) ||
|
||||
(GLContext.getCapabilities().GL_ARB_vertex_buffer_object && !checkBufferObject(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, true))))
|
||||
static void ensureElementVBOenabled(ContextCapabilities caps) {
|
||||
if ((caps.OpenGL15 && !checkBufferObject(caps, GL15.GL_ELEMENT_ARRAY_BUFFER_BINDING, true) ||
|
||||
(caps.GL_ARB_vertex_buffer_object && !checkBufferObject(caps, ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB, true))))
|
||||
throw new OpenGLException("Cannot use offsets when Element Array Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel pack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensurePackPBOdisabled() {
|
||||
if ((GLContext.getCapabilities().GL_ARB_pixel_buffer_object && !checkBufferObject(ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_ARB, false) ||
|
||||
(GLContext.getCapabilities().GL_EXT_pixel_buffer_object && !checkBufferObject(EXTPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_EXT, false))))
|
||||
static void ensurePackPBOdisabled(ContextCapabilities caps) {
|
||||
if ((caps.GL_ARB_pixel_buffer_object && !checkBufferObject(caps, ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_ARB, false) || (caps.GL_EXT_pixel_buffer_object && !checkBufferObject(caps, EXTPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_EXT, false))))
|
||||
throw new OpenGLException("Cannot use Buffers when Pixel Pack Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel pack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensurePackPBOenabled() {
|
||||
if ((GLContext.getCapabilities().GL_ARB_pixel_buffer_object && !checkBufferObject(ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_ARB, true) ||
|
||||
(GLContext.getCapabilities().GL_EXT_pixel_buffer_object && !checkBufferObject(EXTPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_EXT, true))))
|
||||
static void ensurePackPBOenabled(ContextCapabilities caps) {
|
||||
if ((caps.GL_ARB_pixel_buffer_object && !checkBufferObject(caps, ARBPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_ARB, true) ||
|
||||
(caps.GL_EXT_pixel_buffer_object && !checkBufferObject(caps, EXTPixelBufferObject.GL_PIXEL_PACK_BUFFER_BINDING_EXT, true))))
|
||||
throw new OpenGLException("Cannot use offsets when Pixel Pack Buffer Object is disabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel unpack buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
|
||||
static void ensureUnpackPBOdisabled() {
|
||||
if ((GLContext.getCapabilities().GL_ARB_pixel_buffer_object && !checkBufferObject(ARBPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_ARB, false) ||
|
||||
(GLContext.getCapabilities().GL_EXT_pixel_buffer_object && !checkBufferObject(EXTPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, false))))
|
||||
static void ensureUnpackPBOdisabled(ContextCapabilities caps) {
|
||||
if ((caps.GL_ARB_pixel_buffer_object && !checkBufferObject(caps, ARBPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_ARB, false) ||
|
||||
(caps.GL_EXT_pixel_buffer_object && !checkBufferObject(caps, EXTPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, false))))
|
||||
throw new OpenGLException("Cannot use Buffers when Pixel Unpack Buffer Object is enabled");
|
||||
}
|
||||
|
||||
/** Helper method to ensure that pixel unpack buffer objects are enabled. If they are disabled, we'll throw an OpenGLException */
|
||||
static void ensureUnpackPBOenabled() {
|
||||
if ((GLContext.getCapabilities().GL_ARB_pixel_buffer_object && !checkBufferObject(ARBPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_ARB, true) ||
|
||||
(GLContext.getCapabilities().GL_EXT_pixel_buffer_object && !checkBufferObject(EXTPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, true))))
|
||||
static void ensureUnpackPBOenabled(ContextCapabilities caps) {
|
||||
if ((caps.GL_ARB_pixel_buffer_object && !checkBufferObject(caps, ARBPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_ARB, true) ||
|
||||
(caps.GL_EXT_pixel_buffer_object && !checkBufferObject(caps, EXTPixelBufferObject.GL_PIXEL_UNPACK_BUFFER_BINDING_EXT, true))))
|
||||
throw new OpenGLException("Cannot use offsets when Pixel Unpack Buffer Object is disabled");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ final class StateTracker {
|
|||
attrib_stack = new StateStack(0);
|
||||
}
|
||||
|
||||
static void popAttrib() {
|
||||
getTracker().doPopAttrib();
|
||||
static void popAttrib(ContextCapabilities caps) {
|
||||
caps.tracker.doPopAttrib();
|
||||
}
|
||||
|
||||
private void doPopAttrib() {
|
||||
|
|
@ -50,8 +50,8 @@ final class StateTracker {
|
|||
}
|
||||
}
|
||||
|
||||
static void pushAttrib(int mask) {
|
||||
getTracker().doPushAttrib(mask);
|
||||
static void pushAttrib(ContextCapabilities caps, int mask) {
|
||||
caps.tracker.doPushAttrib(mask);
|
||||
}
|
||||
|
||||
private void doPushAttrib(int mask) {
|
||||
|
|
@ -62,11 +62,7 @@ final class StateTracker {
|
|||
}
|
||||
}
|
||||
|
||||
private static StateTracker getTracker() {
|
||||
return GLContext.getCapabilities().tracker;
|
||||
}
|
||||
|
||||
static ReferencesStack getReferencesStack() {
|
||||
return GLContext.getCapabilities().tracker.references_stack;
|
||||
static ReferencesStack getReferencesStack(ContextCapabilities caps) {
|
||||
return caps.tracker.references_stack;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ public class JavaMethodsGenerator {
|
|||
writer.print("enabled");
|
||||
else
|
||||
writer.print("disabled");
|
||||
writer.println("();");
|
||||
writer.println("(caps);");
|
||||
}
|
||||
|
||||
private static void printBufferObjectChecks(PrintWriter writer, MethodDeclaration method, Mode mode) {
|
||||
|
|
@ -184,15 +184,16 @@ public class JavaMethodsGenerator {
|
|||
generateParametersJava(writer, method, typeinfos_instance, false, mode);
|
||||
TypeMirror result_type = Utils.getMethodReturnType(method);
|
||||
writer.println(") {");
|
||||
Code code_annotation = method.getAnnotation(Code.class);
|
||||
if (code_annotation != null)
|
||||
writer.println(code_annotation.value());
|
||||
if (context_specific) {
|
||||
writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = GLContext.getCapabilities().");
|
||||
writer.println("\t\tContextCapabilities caps = GLContext.getCapabilities();");
|
||||
writer.print("\t\tlong " + Utils.FUNCTION_POINTER_VAR_NAME + " = caps.");
|
||||
writer.println(Utils.getFunctionAddressName(interface_decl, method) + ";");
|
||||
writer.print("\t\tBufferChecks.checkFunctionAddress(");
|
||||
writer.println(Utils.FUNCTION_POINTER_VAR_NAME + ");");
|
||||
}
|
||||
Code code_annotation = method.getAnnotation(Code.class);
|
||||
if (code_annotation != null)
|
||||
writer.println(code_annotation.value());
|
||||
printBufferObjectChecks(writer, method, mode);
|
||||
printParameterChecks(writer, method, mode);
|
||||
printParameterCaching(writer, interface_decl, method, mode);
|
||||
|
|
@ -399,7 +400,7 @@ public class JavaMethodsGenerator {
|
|||
param.getAnnotation(CachedReference.class) != null &&
|
||||
(mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) &&
|
||||
param.getAnnotation(Result.class) == null) {
|
||||
writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".getReferences().");
|
||||
writer.print("\t\t" + Utils.CHECKS_CLASS_NAME + ".getReferences(caps).");
|
||||
writer.print(Utils.getReferenceName(interface_decl, method, param) + " = ");
|
||||
writer.println(param.getSimpleName() + ";");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue