summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-07 18:28:54 +0100
committerSven Gothel <[email protected]>2023-03-07 18:28:54 +0100
commitb266c94103dae5ad7a117ab7e0fb6b401ca3c85b (patch)
treed2e508939ff0fa5248c884779e5925d21a9d02ac /src/jogl/classes/com/jogamp/graph/curve
parent01aac34c2c08d01d728c7906cb1cc132e8e7fab1 (diff)
Graph Perf: Region*: Add setBufferCapacity(..) and cut-off growBuffer() early if not needed (track capacity); Align all VBORegion* buffer init/set/grow impl.
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java14
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java10
2 files changed, 21 insertions, 3 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index d82348b83..5147008a1 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -203,11 +203,25 @@ public abstract class Region {
* Allow the renderer buffers to pre-emptively grow for given vertices- and index counts.
* @param verticesCount number of vertices to hold
* @param indicesCount number of indices to hold
+ * @see #setBufferCapacity(int, int)
* @see #countOutlineShape(OutlineShape, int[])
* @see #countOutlineShapes(List, int[])
*/
public abstract void growBuffer(int verticesCount, int indicesCount);
+ /**
+ * Set the renderer buffers pre-emptively for given vertices- and index counts.
+ * <p>
+ * If the buffers already exceeds given numbers, the buffers are unchanged.
+ * </p>
+ * @param verticesCount number of vertices to hold
+ * @param indicesCount number of indices to hold
+ * @see #growBuffer(int, int)
+ * @see #countOutlineShape(OutlineShape, int[])
+ * @see #countOutlineShapes(List, int[])
+ */
+ public abstract void setBufferCapacity(int verticesCount, int indicesCount);
+
protected abstract void pushVertex(final float[] coords, final float[] texParams, float[] rgba);
protected abstract void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3,
final float[] texParams1, final float[] texParams2, final float[] texParams3, float[] rgba);
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
index 9baa99420..e02752f73 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -30,6 +30,7 @@ package com.jogamp.graph.curve.opengl;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GLArrayData;
+import com.jogamp.opengl.util.GLArrayDataClient;
import com.jogamp.opengl.util.GLArrayDataEditable;
import com.jogamp.opengl.GLProfile;
@@ -77,6 +78,9 @@ public abstract class GLRegion extends Region {
*/
public static final int defaultIndicesCount = 10*33;
+ // private static final float growthFactor = 1.2f; // avg +5% size but 15% more overhead (34% total)
+ protected static final float growthFactor = GLArrayDataClient.DEFAULT_GROWTH_FACTOR; // avg +20% size, but 15% less CPU overhead compared to 1.2 (19% total)
+
/**
* Create a GLRegion using the passed render mode
*
@@ -142,9 +146,9 @@ public abstract class GLRegion extends Region {
protected static void printAndCount(final PrintStream out, final String name, final GLArrayData data, final int[] size, final int[] capacity) {
out.print(name+"[");
if( null != data ) {
- data.printStats(out);
- size[0] += data.getSizeInBytes();
- capacity[0] += data.getCapacityInBytes();
+ out.print(data.fillStatsToString());
+ size[0] += data.getByteCount();
+ capacity[0] += data.getByteCapacity();
out.print("]");
} else {
out.print("null]");