|
@@ -109,6 +109,9 @@ public final class GLRenderer implements Renderer {
|
|
|
private final GLExt glext;
|
|
|
private final GLFbo glfbo;
|
|
|
private final TextureUtil texUtil;
|
|
|
+ private boolean debug = false;
|
|
|
+ private int debugGroupId = 0;
|
|
|
+
|
|
|
|
|
|
public GLRenderer(GL gl, GLExt glext, GLFbo glfbo) {
|
|
|
this.gl = gl;
|
|
@@ -128,6 +131,29 @@ public final class GLRenderer implements Renderer {
|
|
|
generateMipmapsForFramebuffers = v;
|
|
|
}
|
|
|
|
|
|
+ public void setDebugEnabled(boolean v) {
|
|
|
+ debug = v;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void popDebugGroup() {
|
|
|
+ if (debug && caps.contains(Caps.GLDebug)) {
|
|
|
+ glext.glPopDebugGroup();
|
|
|
+ debugGroupId--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void pushDebugGroup(String name) {
|
|
|
+ if (debug && caps.contains(Caps.GLDebug)) {
|
|
|
+ if (name == null) name = "Group " + debugGroupId;
|
|
|
+ glext.glPushDebugGroup(GLExt.GL_DEBUG_SOURCE_APPLICATION, debugGroupId, name);
|
|
|
+ debugGroupId++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Statistics getStatistics() {
|
|
|
return statistics;
|
|
@@ -574,6 +600,10 @@ public final class GLRenderer implements Renderer {
|
|
|
caps.add(Caps.UnpackRowLength);
|
|
|
}
|
|
|
|
|
|
+ if (caps.contains(Caps.OpenGL43) || hasExtension("GL_KHR_debug")) {
|
|
|
+ caps.add(Caps.GLDebug);
|
|
|
+ }
|
|
|
+
|
|
|
// Print context information
|
|
|
logger.log(Level.INFO, "OpenGL Renderer Information\n" +
|
|
|
" * Vendor: {0}\n" +
|
|
@@ -1431,6 +1461,9 @@ public final class GLRenderer implements Renderer {
|
|
|
}
|
|
|
|
|
|
source.setId(id);
|
|
|
+ if (debug && caps.contains(Caps.GLDebug)) {
|
|
|
+ if(source.getName() != null) glext.glObjectLabel(GLExt.GL_SHADER, id, source.getName());
|
|
|
+ }
|
|
|
} else {
|
|
|
throw new RendererException("Cannot recompile shader source");
|
|
|
}
|
|
@@ -2103,6 +2136,9 @@ public final class GLRenderer implements Renderer {
|
|
|
assert context.boundFBO == fb.getId();
|
|
|
|
|
|
context.boundFB = fb;
|
|
|
+ if (debug && caps.contains(Caps.GLDebug)) {
|
|
|
+ if (fb.getName() != null) glext.glObjectLabel(GL3.GL_FRAMEBUFFER, fb.getId(), fb.getName());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2626,6 +2662,9 @@ public final class GLRenderer implements Renderer {
|
|
|
assert texId != -1;
|
|
|
|
|
|
setupTextureParams(unit, tex);
|
|
|
+ if (debug && caps.contains(Caps.GLDebug)) {
|
|
|
+ if (tex.getName() != null) glext.glObjectLabel(GL.GL_TEXTURE, tex.getImage().getId(), tex.getName());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2995,6 +3034,9 @@ public final class GLRenderer implements Renderer {
|
|
|
attribs[slot] = vb.getWeakRef();
|
|
|
}
|
|
|
}
|
|
|
+ if (debug && caps.contains(Caps.GLDebug)) {
|
|
|
+ if (vb.getName() != null) glext.glObjectLabel(GLExt.GL_BUFFER, vb.getId(), vb.getName());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void setVertexAttrib(VertexBuffer vb) {
|