mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-08 16:04:39 +00:00
Added @NoErrorCheck on vertex data methods.
The debug build will now track Begin/End pairs and never call GetError inside them.
This commit is contained in:
parent
72c3da7aeb
commit
4eb94622ca
17 changed files with 271 additions and 12 deletions
|
|
@ -32,14 +32,28 @@
|
|||
package org.lwjgl.opengl;
|
||||
|
||||
final class StateTracker {
|
||||
private final ReferencesStack references_stack;
|
||||
private ReferencesStack references_stack;
|
||||
private final StateStack attrib_stack;
|
||||
|
||||
private boolean insideBeginEnd;
|
||||
|
||||
StateTracker() {
|
||||
references_stack = new ReferencesStack();
|
||||
attrib_stack = new StateStack(0);
|
||||
}
|
||||
|
||||
/** This is called after getting function addresses. */
|
||||
void init() {
|
||||
references_stack = new ReferencesStack();
|
||||
}
|
||||
|
||||
static void setBeginEnd(ContextCapabilities caps, boolean inside) {
|
||||
caps.tracker.insideBeginEnd = inside;
|
||||
}
|
||||
|
||||
boolean isBeginEnd() {
|
||||
return insideBeginEnd;
|
||||
}
|
||||
|
||||
static void popAttrib(ContextCapabilities caps) {
|
||||
caps.tracker.doPopAttrib();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public final class Util {
|
|||
*
|
||||
*/
|
||||
public static void checkGLError() throws OpenGLException {
|
||||
if ( ContextCapabilities.DEBUG && GLContext.getCapabilities().tracker.isBeginEnd() ) // Do not call GetError inside a Begin/End pair.
|
||||
return;
|
||||
int err = GL11.glGetError();
|
||||
if ( err != GL11.GL_NO_ERROR ) {
|
||||
throw new OpenGLException(err);
|
||||
|
|
|
|||
|
|
@ -59,9 +59,10 @@ public class ContextCapabilitiesGenerator {
|
|||
private final static String EXTENSION_PREFIX = "GL_";
|
||||
private final static String CORE_PREFIX = "Open";
|
||||
|
||||
public static void generateClassPrologue(PrintWriter writer, boolean context_specific) {
|
||||
public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
|
||||
writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
|
||||
writer.println("\tfinal StateTracker tracker;");
|
||||
writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
|
||||
writer.println("\tfinal StateTracker tracker = new StateTracker();");
|
||||
writer.println("\tfinal IntBuffer scratch_int_buffer = BufferUtils.createIntBuffer(16);");
|
||||
writer.println();
|
||||
if ( !context_specific ) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact
|
|||
}
|
||||
|
||||
public Collection<String> supportedOptions() {
|
||||
return unmodifiableCollection(Arrays.asList("-Acontextspecific"));
|
||||
return unmodifiableCollection(Arrays.asList("-Acontextspecific", "-Ageneratechecks"));
|
||||
}
|
||||
|
||||
public void roundComplete(RoundCompleteEvent event) {
|
||||
|
|
@ -99,15 +99,16 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact
|
|||
|
||||
public void process() {
|
||||
Map<String, String> options = env.getOptions();
|
||||
boolean generate_error_checks = options.containsKey("-Ageneratechecks");
|
||||
boolean context_specific = options.containsKey("-Acontextspecific");
|
||||
try {
|
||||
generateContextCapabilitiesSource(context_specific);
|
||||
generateContextCapabilitiesSource(context_specific, generate_error_checks);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateContextCapabilitiesSource(boolean context_specific) throws IOException {
|
||||
private void generateContextCapabilitiesSource(boolean context_specific, boolean generate_error_checks) throws IOException {
|
||||
PrintWriter writer = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "org.lwjgl.opengl", new File(Utils.CONTEXT_CAPS_CLASS_NAME + ".java"), null);
|
||||
writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
|
||||
writer.println();
|
||||
|
|
@ -120,7 +121,7 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact
|
|||
writer.println("import java.util.HashSet;");
|
||||
writer.println("import java.nio.IntBuffer;");
|
||||
writer.println();
|
||||
ContextCapabilitiesGenerator.generateClassPrologue(writer, context_specific);
|
||||
ContextCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks);
|
||||
DeclarationFilter filter = DeclarationFilter.getFilter(InterfaceDeclaration.class);
|
||||
Collection<TypeDeclaration> interface_decls = filter.filter(env.getSpecifiedTypeDeclarations());
|
||||
for (TypeDeclaration typedecl : interface_decls) {
|
||||
|
|
@ -179,7 +180,7 @@ public class ContextGeneratorProcessorFactory implements AnnotationProcessorFact
|
|||
if (Utils.isFinal(interface_decl))
|
||||
ContextCapabilitiesGenerator.generateInitializer(writer, interface_decl);
|
||||
}
|
||||
writer.println("\t\ttracker = new StateTracker();");
|
||||
writer.println("\t\ttracker.init();");
|
||||
writer.println("\t}");
|
||||
writer.println("}");
|
||||
writer.close();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue