diff options
author | Sven Gothel <[email protected]> | 2023-03-07 18:05:15 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-03-07 18:05:15 +0100 |
commit | 657df3d32a291a74e7eb31c8ccef0fde151afcc1 (patch) | |
tree | 006344b5f080fba866b990cf93f2555385d43813 | |
parent | 90a95e6f689b479f3c3ae3caf4e30447030c7682 (diff) |
Graph Perf: Region*: Rely on growBuffer(..) per addOutlineShape() and known buffer data-type to directly put[34][sif](..) skipping GLArrayDataClient/Buffers buffer-growth and validations
4 files changed, 75 insertions, 50 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index 70f30a193..252e57e2b 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -330,6 +330,19 @@ public abstract class Region { pushNewVerticesImpl(vertIn1, vertIn2, vertIn3, transform, rgba); } + protected static void put3i(final IntBuffer b, final int v1, final int v2, final int v3) { + b.put(v1); b.put(v2); b.put(v3); + } + protected static void put3s(final ShortBuffer b, final short v1, final short v2, final short v3) { + b.put(v1); b.put(v2); b.put(v3); + } + protected static void put3f(final FloatBuffer b, final float v1, final float v2, final float v3) { + b.put(v1); b.put(v2); b.put(v3); + } + protected static void put4f(final FloatBuffer b, final float v1, final float v2, final float v3, final float v4) { + b.put(v1); b.put(v2); b.put(v3); b.put(v4); + } + private final AABBox tmpBox = new AABBox(); protected static final int GL_UINT16_MAX = 0xffff; // 65,535 diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index b7a244f81..cf4fc65fc 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -29,6 +29,8 @@ package jogamp.graph.curve.opengl; import java.io.PrintStream; import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; @@ -240,15 +242,11 @@ public class VBORegion2PMSAAES2 extends GLRegion { @Override protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { - // NIO array[3] is much slows than group/single - // gca_VerticesAttr.putf(coords, 0, 3); - // gca_CurveParamsAttr.putf(texParams, 0, 3); - gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]); - gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]); if( null != gca_ColorsAttr ) { if( null != rgba ) { - // gca_ColorsAttr.putf(rgba, 0, 4); - gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -258,18 +256,18 @@ public class VBORegion2PMSAAES2 extends GLRegion { @Override protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3, final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) { - gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]); - gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]); - gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]); - gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]); - gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]); - gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]); if( null != gca_ColorsAttr ) { if( null != rgba ) { final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3]; - gca_ColorsAttr.put4f(r, g, b, a); - gca_ColorsAttr.put4f(r, g, b, a); - gca_ColorsAttr.put4f(r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -288,9 +286,9 @@ public class VBORegion2PMSAAES2 extends GLRegion { @Override protected final void pushIndices(final int idx1, final int idx2, final int idx3) { if( usesI32Idx() ) { - indicesBuffer.put3i(idx1, idx2, idx3); + put3i((IntBuffer)indicesBuffer.getBuffer(), idx1, idx2, idx3); } else { - indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3); + put3s((ShortBuffer)indicesBuffer.getBuffer(), (short)idx1, (short)idx2, (short)idx3); } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index 2998f3fe1..e5dcfeb84 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -29,6 +29,8 @@ package jogamp.graph.curve.opengl; import java.io.PrintStream; import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; @@ -299,12 +301,15 @@ public class VBORegion2PVBAAES2 extends GLRegion { // NIO array[3] is much slows than group/single // gca_VerticesAttr.putf(coords, 0, 3); // gca_CurveParamsAttr.putf(texParams, 0, 3); - gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]); - gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]); + // gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]); + // gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]); if( null != gca_ColorsAttr ) { if( null != rgba ) { // gca_ColorsAttr.putf(rgba, 0, 4); - gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]); + // gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -314,18 +319,27 @@ public class VBORegion2PVBAAES2 extends GLRegion { @Override protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3, final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) { - gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]); - gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]); - gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]); - gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]); - gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]); - gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]); + // gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]); + // gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]); + // gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]); + // gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]); + // gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]); + // gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]); if( null != gca_ColorsAttr ) { if( null != rgba ) { final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3]; - gca_ColorsAttr.put4f(r, g, b, a); - gca_ColorsAttr.put4f(r, g, b, a); - gca_ColorsAttr.put4f(r, g, b, a); + // gca_ColorsAttr.put4f(r, g, b, a); + // gca_ColorsAttr.put4f(r, g, b, a); + // gca_ColorsAttr.put4f(r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -344,9 +358,11 @@ public class VBORegion2PVBAAES2 extends GLRegion { @Override protected final void pushIndices(final int idx1, final int idx2, final int idx3) { if( usesI32Idx() ) { - indicesBuffer.put3i(idx1, idx2, idx3); + // indicesBuffer.put3i(idx1, idx2, idx3); + put3i((IntBuffer)indicesBuffer.getBuffer(), idx1, idx2, idx3); } else { - indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3); + // indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3); + put3s((ShortBuffer)indicesBuffer.getBuffer(), (short)idx1, (short)idx2, (short)idx3); } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 5a4c0c731..dcd5831d4 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -29,6 +29,8 @@ package jogamp.graph.curve.opengl; import java.io.PrintStream; import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; @@ -142,15 +144,11 @@ public class VBORegionSPES2 extends GLRegion { @Override protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { - // NIO array[3] is much slows than group/single - // gca_VerticesAttr.putf(coords, 0, 3); - // gca_CurveParamsAttr.putf(texParams, 0, 3); - gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]); - gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]); if( null != gca_ColorsAttr ) { if( null != rgba ) { - // gca_ColorsAttr.putf(rgba, 0, 4); - gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -160,18 +158,18 @@ public class VBORegionSPES2 extends GLRegion { @Override protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3, final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) { - gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]); - gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]); - gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]); - gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]); - gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]); - gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]); if( null != gca_ColorsAttr ) { if( null != rgba ) { final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3]; - gca_ColorsAttr.put4f(r, g, b, a); - gca_ColorsAttr.put4f(r, g, b, a); - gca_ColorsAttr.put4f(r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -190,9 +188,9 @@ public class VBORegionSPES2 extends GLRegion { @Override protected final void pushIndices(final int idx1, final int idx2, final int idx3) { if( usesI32Idx() ) { - indicesBuffer.put3i(idx1, idx2, idx3); + put3i((IntBuffer)indicesBuffer.getBuffer(), idx1, idx2, idx3); } else { - indicesBuffer.put3s((short)idx1, (short)idx2, (short)idx3); + put3s((ShortBuffer)indicesBuffer.getBuffer(), (short)idx1, (short)idx2, (short)idx3); } } |