From 1259693f21734b0ebe1b5c95688ad91956c2629c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 6 Oct 2013 15:56:44 +0200 Subject: Bug 789: glDrawArraysIndirect and glDrawElementsIndirect are using GL_DRAW_INDIRECT_BUFFER, add VBO variant and range-check --- make/config/jogl/gl-common.cfg | 6 ++++++ make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 16 ++++++++++++++++ .../com/jogamp/gluegen/opengl/GLConfiguration.java | 6 +++++- .../classes/com/jogamp/gluegen/opengl/GLEmitter.java | 2 +- src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java | 2 ++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index a1b09c5b4..b84115445 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -591,6 +591,9 @@ BufferObjectKind Element glDrawElementsInstancedBaseVertexBaseInstance BufferObjectKind Element glDrawRangeElements BufferObjectKind Element glDrawRangeElementsBaseVertex +BufferObjectKind Indirect glDrawArraysIndirect +BufferObjectKind Indirect glDrawElementsIndirect + # There are no PBOs in the embedded OpenGL variants right now BufferObjectKind UnpackPixel glBitmap BufferObjectKind UnpackPixel glColorTable @@ -651,6 +654,9 @@ RangeCheck glDrawElementsInstancedBaseVertexBaseInstance 3 {1} RangeCheck glDrawRangeElements 5 {3} RangeCheck glDrawRangeElementsBaseVertex 5 {3} +RangeCheck glDrawArraysIndirect 1 1 +RangeCheck glDrawElementsIndirect 2 1 + RangeCheck glEdgeFlagPointer 1 1 RangeCheck glElementPointerATI 1 1 RangeCheck glFogCoordPointer 2 1 diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index d1a4ceda0..c769ddcfa 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -366,6 +366,22 @@ private final boolean checkElementVBOBound(boolean throwException) { "element vertex_buffer_object", throwException); } +private final boolean checkIndirectVBOUnbound(boolean throwException) { + return checkBufferObject(haveGL15 || haveARBVertexBufferObject, + haveARBVertexArrayObject, // allowVAO + false, // bound + GL4.GL_DRAW_INDIRECT_BUFFER, + "indirect vertex_buffer_object", throwException); +} + +private final boolean checkIndirectVBOBound(boolean throwException) { + return checkBufferObject(haveGL15 || haveARBVertexBufferObject, + haveARBVertexArrayObject, // allowVAO + true, // bound + GL4.GL_DRAW_INDIRECT_BUFFER, + "indirect vertex_buffer_object", throwException); +} + private final boolean checkUnpackPBOUnbound(boolean throwException) { return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java index 7fdb93e9b..861957c23 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java @@ -127,10 +127,12 @@ public class GLConfiguration extends ProcAddressConfiguration { kind = GLEmitter.BufferObjectKind.ARRAY; } else if (kindString.equalsIgnoreCase("Element")) { kind = GLEmitter.BufferObjectKind.ELEMENT; + } else if (kindString.equalsIgnoreCase("Indirect")) { + kind = GLEmitter.BufferObjectKind.INDIRECT; } else { throw new RuntimeException("Error parsing \"BufferObjectKind\" command at line " + lineNo + " in file \"" + filename + "\": illegal BufferObjectKind \"" - + kindString + "\", expected one of UnpackPixel, PackPixel, Array, or Element"); + + kindString + "\", expected one of UnpackPixel, PackPixel, Array, Element or Indirect"); } bufferObjectKinds.put(target, kind); @@ -171,6 +173,8 @@ public class GLConfiguration extends ProcAddressConfiguration { prologue = prologue + "ArrayVBO"; } else if (kind == GLEmitter.BufferObjectKind.ELEMENT) { prologue = prologue + "ElementVBO"; + } else if (kind == GLEmitter.BufferObjectKind.INDIRECT) { + prologue = prologue + "IndirectVBO"; } else { throw new RuntimeException("Unknown BufferObjectKind " + kind); } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java index 075c8bfd8..fec90d047 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java @@ -74,7 +74,7 @@ public class GLEmitter extends ProcAddressEmitter { // Buffer Object variants. Used as a Set rather than a Map. private Map bufferObjectMethodBindings = new IdentityHashMap(); - enum BufferObjectKind { UNPACK_PIXEL, PACK_PIXEL, ARRAY, ELEMENT} + enum BufferObjectKind { UNPACK_PIXEL, PACK_PIXEL, ARRAY, ELEMENT, INDIRECT} @Override public void beginEmission(GlueEmitterControls controls) throws IOException { diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java index 890c82c90..f14d16ec4 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java @@ -102,6 +102,7 @@ public class GLBufferStateTracker { setBoundBufferObject(GL.GL_ELEMENT_ARRAY_BUFFER, 0); setBoundBufferObject(GL2.GL_PIXEL_PACK_BUFFER, 0); setBoundBufferObject(GL2.GL_PIXEL_UNPACK_BUFFER, 0); + setBoundBufferObject(GL4.GL_DRAW_INDIRECT_BUFFER, 0); } public final void setBoundBufferObject(int target, int value) { @@ -132,6 +133,7 @@ public class GLBufferStateTracker { case GL.GL_ELEMENT_ARRAY_BUFFER: queryTarget = GL.GL_ELEMENT_ARRAY_BUFFER_BINDING; break; case GL2.GL_PIXEL_PACK_BUFFER: queryTarget = GL2.GL_PIXEL_PACK_BUFFER_BINDING; break; case GL2.GL_PIXEL_UNPACK_BUFFER: queryTarget = GL2.GL_PIXEL_UNPACK_BUFFER_BINDING; break; + case GL4.GL_DRAW_INDIRECT_BUFFER: queryTarget = GL4.GL_DRAW_INDIRECT_BUFFER_BINDING; break; default: gotQueryTarget = false; break; } if (gotQueryTarget) { -- cgit v1.2.3