diff options
author | Sven Gothel <[email protected]> | 2023-03-07 18:28:54 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-03-07 18:28:54 +0100 |
commit | b266c94103dae5ad7a117ab7e0fb6b401ca3c85b (patch) | |
tree | d2e508939ff0fa5248c884779e5925d21a9d02ac /src/jogl/classes/jogamp/graph | |
parent | 01aac34c2c08d01d728c7906cb1cc132e8e7fab1 (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/jogamp/graph')
3 files changed, 203 insertions, 123 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index d088c0a29..89693bb66 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -53,13 +53,15 @@ import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureCoords; import com.jogamp.opengl.util.texture.TextureSequence; -public class VBORegion2PMSAAES2 extends GLRegion { +public final class VBORegion2PMSAAES2 extends GLRegion { private static final boolean DEBUG_FBO_1 = false; private static final boolean DEBUG_FBO_2 = false; private final RenderState.ProgramLocal rsLocal; // Pass-1: + private int curVerticesCap = 0; + private int curIndicesCap = 0; private GLArrayDataServer gca_VerticesAttr; private GLArrayDataServer gca_CurveParamsAttr; private GLArrayDataServer gca_ColorsAttr; @@ -86,58 +88,6 @@ public class VBORegion2PMSAAES2 extends GLRegion { final int[] maxTexSize = new int[] { -1 } ; - /** - * <p> - * Since multiple {@link Region}s may share one - * {@link ShaderProgram}, the uniform data must always be updated. - * </p> - * - * @param gl - * @param renderer - * @param renderModes - * @param pass1 - * @param quality - * @param sampleCount - */ - public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) { - final RenderState rs = renderer.getRenderState(); - final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount, colorTexSeq); - final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); - final boolean updateLocLocal; - if( pass1 ) { - updateLocLocal = !sp.equals(spPass1); - spPass1 = sp; - if( DEBUG ) { - System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal); - } - if( updateLocLocal ) { - rs.updateAttributeLoc(gl, true, gca_VerticesAttr, true); - rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, true); - if( null != gca_ColorsAttr ) { - rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true); - } - } - rsLocal.update(gl, rs, updateLocLocal, renderModes, true, true); - rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true); - if( null != gcu_ColorTexUnit ) { - rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true); - rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true); - } - } else { - updateLocLocal = !sp.equals(spPass2); - spPass2 = sp; - if( DEBUG ) { - System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal); - } - if( updateLocLocal ) { - rs.updateAttributeLoc(gl, true, gca_FboVerticesAttr, true); - rs.updateAttributeLoc(gl, true, gca_FboTexCoordsAttr, true); - } - rsLocal.update(gl, rs, updateLocLocal, renderModes, false, true); - rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit - } - } - public VBORegion2PMSAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit, final int initialVerticesCount, final int initialIndicesCount) { @@ -148,20 +98,8 @@ public class VBORegion2PMSAAES2 extends GLRegion { // We leave GLArrayDataClient.DEFAULT_GROWTH_FACTOR intact for avg +19% size, but 15% less CPU overhead compared to 1.2 (19% total) // Pass 1: - indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), initialIndicesCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); - - gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, - false, initialVerticesCount, GL.GL_STATIC_DRAW); - - gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT, - false, initialVerticesCount, GL.GL_STATIC_DRAW); + initBuffer(initialVerticesCount, initialIndicesCount); - if( hasColorChannel() ) { - gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT, - false, initialVerticesCount, GL.GL_STATIC_DRAW); - } else { - gca_ColorsAttr = null; - } if( hasColorTexture() ) { gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit()); colorTexBBox = new float[4]; @@ -196,13 +134,54 @@ public class VBORegion2PMSAAES2 extends GLRegion { false, 4, GL.GL_STATIC_DRAW); } + private void initBuffer(final int verticeCount, final int indexCount) { + indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesBuffer.setGrowthFactor(growthFactor); + curIndicesCap = indicesBuffer.getElemCapacity(); + + gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_VerticesAttr.setGrowthFactor(growthFactor); + gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_CurveParamsAttr.setGrowthFactor(growthFactor); + if( hasColorChannel() ) { + gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_ColorsAttr.setGrowthFactor(growthFactor); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); + } + @Override - indicesBuffer.growIfNeeded(indexCount * indicesBuffer.getCompsPerElem()); - gca_VerticesAttr.growIfNeeded(verticeCount * gca_VerticesAttr.getCompsPerElem()); - gca_CurveParamsAttr.growIfNeeded(verticeCount * gca_CurveParamsAttr.getCompsPerElem()); - if( null != gca_ColorsAttr ) { - gca_ColorsAttr.growIfNeeded(verticeCount * gca_ColorsAttr.getCompsPerElem()); public void growBuffer(final int verticesCount, final int indicesCount) { + if( curIndicesCap < indicesBuffer.elemPosition() + indicesCount ) { + indicesBuffer.growIfNeeded(indicesCount * indicesBuffer.getCompsPerElem()); + curIndicesCap = indicesBuffer.getElemCapacity(); + } + if( curVerticesCap < gca_VerticesAttr.elemPosition() + verticesCount ) { + gca_VerticesAttr.growIfNeeded(verticesCount * gca_VerticesAttr.getCompsPerElem()); + gca_CurveParamsAttr.growIfNeeded(verticesCount * gca_CurveParamsAttr.getCompsPerElem()); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.growIfNeeded(verticesCount * gca_ColorsAttr.getCompsPerElem()); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); + } + } + + @Override + public void setBufferCapacity(final int verticesCount, final int indicesCount) { + if( curIndicesCap < indicesCount ) { + indicesBuffer.reserve(indicesCount); + curIndicesCap = indicesBuffer.getElemCapacity(); + } + if( curVerticesCap < verticesCount ) { + gca_VerticesAttr.reserve(verticesCount); + gca_CurveParamsAttr.reserve(verticesCount); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.reserve(verticesCount); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); } } @@ -340,6 +319,58 @@ public class VBORegion2PMSAAES2 extends GLRegion { // the buffers were disabled, since due to real/fbo switching and other vbo usage } + /** + * <p> + * Since multiple {@link Region}s may share one + * {@link ShaderProgram}, the uniform data must always be updated. + * </p> + * + * @param gl + * @param renderer + * @param renderModes + * @param pass1 + * @param quality + * @param sampleCount + */ + public void useShaderProgram(final GL2ES2 gl, final RegionRenderer renderer, final int renderModes, final boolean pass1, final int quality, final int sampleCount) { + final RenderState rs = renderer.getRenderState(); + final boolean updateLocGlobal = renderer.useShaderProgram(gl, renderModes, pass1, quality, sampleCount, colorTexSeq); + final ShaderProgram sp = renderer.getRenderState().getShaderProgram(); + final boolean updateLocLocal; + if( pass1 ) { + updateLocLocal = !sp.equals(spPass1); + spPass1 = sp; + if( DEBUG ) { + System.err.println("XXX changedSP.p1 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal); + } + if( updateLocLocal ) { + rs.updateAttributeLoc(gl, true, gca_VerticesAttr, true); + rs.updateAttributeLoc(gl, true, gca_CurveParamsAttr, true); + if( null != gca_ColorsAttr ) { + rs.updateAttributeLoc(gl, true, gca_ColorsAttr, true); + } + } + rsLocal.update(gl, rs, updateLocLocal, renderModes, true, true); + rs.updateUniformLoc(gl, updateLocLocal, gcu_PMVMatrix02, true); + if( null != gcu_ColorTexUnit ) { + rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexUnit, true); + rs.updateUniformLoc(gl, updateLocLocal, gcu_ColorTexBBox, true); + } + } else { + updateLocLocal = !sp.equals(spPass2); + spPass2 = sp; + if( DEBUG ) { + System.err.println("XXX changedSP.p2 updateLocation loc "+updateLocLocal+" / glob "+updateLocGlobal); + } + if( updateLocLocal ) { + rs.updateAttributeLoc(gl, true, gca_FboVerticesAttr, true); + rs.updateAttributeLoc(gl, true, gca_FboTexCoordsAttr, true); + } + rsLocal.update(gl, rs, updateLocLocal, renderModes, false, true); + rs.updateUniformDataLoc(gl, updateLocLocal, false /* updateData */, gcu_FboTexUnit, true); // FIXME always update if changing tex-unit + } + } + private final AABBox drawWinBox = new AABBox(); private final int[] drawView = new int[] { 0, 0, 0, 0 }; private final float[] drawVec4Tmp0 = new float[4]; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index 436c7cdb8..9567bab10 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -58,7 +58,7 @@ import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureCoords; import com.jogamp.opengl.util.texture.TextureSequence; -public class VBORegion2PVBAAES2 extends GLRegion { +public final class VBORegion2PVBAAES2 extends GLRegion { private static final boolean DEBUG_FBO_1 = false; private static final boolean DEBUG_FBO_2 = false; @@ -95,6 +95,8 @@ public class VBORegion2PVBAAES2 extends GLRegion { private final RenderState.ProgramLocal rsLocal; // Pass-1: + private int curVerticesCap = 0; + private int curIndicesCap = 0; private GLArrayDataServer gca_VerticesAttr; private GLArrayDataServer gca_CurveParamsAttr; private GLArrayDataServer gca_ColorsAttr; @@ -176,9 +178,6 @@ public class VBORegion2PVBAAES2 extends GLRegion { } } - // private static final float growthFactor = 1.2f; // avg +5% size but 15% more overhead (34% total) - private static final float growthFactor = GLArrayDataClient.DEFAULT_GROWTH_FACTOR; // avg +20% size, but 15% less CPU overhead compared to 1.2 (19% total) - public VBORegion2PVBAAES2(final GLProfile glp, final int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit, final int initialVerticesCount, final int initialIndicesCount) { @@ -187,7 +186,7 @@ public class VBORegion2PVBAAES2 extends GLRegion { rsLocal = new RenderState.ProgramLocal(); // Pass 1: - growBufferSize(initialVerticesCount, initialIndicesCount); + initBuffer(initialVerticesCount, initialIndicesCount); if( hasColorTexture() ) { gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit()); @@ -224,37 +223,58 @@ public class VBORegion2PVBAAES2 extends GLRegion { false, 4, GL.GL_STATIC_DRAW); } + private void initBuffer(final int verticeCount, final int indexCount) { + indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesBuffer.setGrowthFactor(growthFactor); + curIndicesCap = indicesBuffer.getElemCapacity(); + + gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_VerticesAttr.setGrowthFactor(growthFactor); + gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_CurveParamsAttr.setGrowthFactor(growthFactor); + if( hasColorChannel() ) { + gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_ColorsAttr.setGrowthFactor(growthFactor); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); + } + @Override - if(null == indicesBuffer ) { - indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); - indicesBuffer.setGrowthFactor(growthFactor); - } else { - indicesBuffer.growIfNeeded(indexCount * indicesBuffer.getCompsPerElem()); - } - if( null == gca_VerticesAttr ) { - gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, - false, verticeCount, GL.GL_STATIC_DRAW); - gca_VerticesAttr.setGrowthFactor(growthFactor); - } else { - gca_VerticesAttr.growIfNeeded(verticeCount * gca_VerticesAttr.getCompsPerElem()); public void growBuffer(final int verticesCount, final int indicesCount) { + if( curIndicesCap < indicesBuffer.elemPosition() + indicesCount ) { + // System.err.printf("XXX Buffer grow - Indices: %d < ( %d = %d + %d ); Status: %s%n", + // curIndicesCap, indicesBuffer.elemPosition() + indicesCount, indicesBuffer.elemPosition(), indicesCount, indicesBuffer.elemStatsToString()); + indicesBuffer.growIfNeeded(indicesCount * indicesBuffer.getCompsPerElem()); + curIndicesCap = indicesBuffer.getElemCapacity(); + } + if( curVerticesCap < gca_VerticesAttr.elemPosition() + verticesCount ) { + // System.err.printf("XXX Buffer grow - Verices: %d < ( %d = %d + %d ); Status: %s%n", + // curVerticesCap, gca_VerticesAttr.elemPosition() + verticesCount, gca_VerticesAttr.elemPosition(), verticesCount, gca_VerticesAttr.elemStatsToString()); + gca_VerticesAttr.growIfNeeded(verticesCount * gca_VerticesAttr.getCompsPerElem()); + gca_CurveParamsAttr.growIfNeeded(verticesCount * gca_CurveParamsAttr.getCompsPerElem()); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.growIfNeeded(verticesCount * gca_ColorsAttr.getCompsPerElem()); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); } - if( null == gca_CurveParamsAttr ) { - gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT, - false, verticeCount, GL.GL_STATIC_DRAW); - gca_CurveParamsAttr.setGrowthFactor(growthFactor); - } else { - gca_CurveParamsAttr.growIfNeeded(verticeCount * gca_CurveParamsAttr.getCompsPerElem()); - } + } - if( null == gca_ColorsAttr ) { - if( hasColorChannel() ) { - gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT, - false, verticeCount, GL.GL_STATIC_DRAW); - gca_ColorsAttr.setGrowthFactor(growthFactor); + @Override + public void setBufferCapacity(final int verticesCount, final int indicesCount) { + if( curIndicesCap < indicesCount ) { + indicesBuffer.reserve(indicesCount); + curIndicesCap = indicesBuffer.getElemCapacity(); + } + if( curVerticesCap < verticesCount ) { + gca_VerticesAttr.reserve(verticesCount); + gca_CurveParamsAttr.reserve(verticesCount); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.reserve(verticesCount); } - } else { - gca_ColorsAttr.growIfNeeded(verticeCount * gca_ColorsAttr.getCompsPerElem()); + curVerticesCap = gca_VerticesAttr.getElemCapacity(); } } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 20170b4ed..adf3e4bc2 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -50,9 +50,11 @@ import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureCoords; import com.jogamp.opengl.util.texture.TextureSequence; -public class VBORegionSPES2 extends GLRegion { +public final class VBORegionSPES2 extends GLRegion { private final RenderState.ProgramLocal rsLocal; + private int curVerticesCap = 0; + private int curIndicesCap = 0; private GLArrayDataServer gca_VerticesAttr = null; private GLArrayDataServer gca_CurveParamsAttr = null; private GLArrayDataServer gca_ColorsAttr; @@ -69,22 +71,8 @@ public class VBORegionSPES2 extends GLRegion { rsLocal = new RenderState.ProgramLocal(); - // We leave GLArrayDataClient.DEFAULT_GROWTH_FACTOR intact for avg +19% size, but 15% less CPU overhead compared to 1.2 (19% total) + initBuffer(initialVerticesCount, initialIndicesCount); - indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), initialIndicesCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); - - gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, - false, initialVerticesCount, GL.GL_STATIC_DRAW); - - gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT, - false, initialVerticesCount, GL.GL_STATIC_DRAW); - - if( hasColorChannel() ) { - gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT, - false, initialVerticesCount, GL.GL_STATIC_DRAW); - } else { - gca_ColorsAttr = null; - } if( hasColorTexture() ) { gcu_ColorTexUnit = new GLUniformData(UniformNames.gcu_ColorTexUnit, colorTexSeq.getTextureUnit()); colorTexBBox = new float[4]; @@ -96,13 +84,54 @@ public class VBORegionSPES2 extends GLRegion { } } + private void initBuffer(final int verticeCount, final int indexCount) { + indicesBuffer = GLArrayDataServer.createData(3, glIdxType(), indexCount, GL.GL_STATIC_DRAW, GL.GL_ELEMENT_ARRAY_BUFFER); + indicesBuffer.setGrowthFactor(growthFactor); + curIndicesCap = indicesBuffer.getElemCapacity(); + + gca_VerticesAttr = GLArrayDataServer.createGLSL(AttributeNames.VERTEX_ATTR_NAME, 3, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_VerticesAttr.setGrowthFactor(growthFactor); + gca_CurveParamsAttr = GLArrayDataServer.createGLSL(AttributeNames.CURVEPARAMS_ATTR_NAME, 3, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_CurveParamsAttr.setGrowthFactor(growthFactor); + if( hasColorChannel() ) { + gca_ColorsAttr = GLArrayDataServer.createGLSL(AttributeNames.COLOR_ATTR_NAME, 4, GL.GL_FLOAT, + false, verticeCount, GL.GL_STATIC_DRAW); + gca_ColorsAttr.setGrowthFactor(growthFactor); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); + } + @Override - indicesBuffer.growIfNeeded(indexCount * indicesBuffer.getCompsPerElem()); - gca_VerticesAttr.growIfNeeded(verticeCount * gca_VerticesAttr.getCompsPerElem()); - gca_CurveParamsAttr.growIfNeeded(verticeCount * gca_CurveParamsAttr.getCompsPerElem()); - if( null != gca_ColorsAttr ) { - gca_ColorsAttr.growIfNeeded(verticeCount * gca_ColorsAttr.getCompsPerElem()); public void growBuffer(final int verticesCount, final int indicesCount) { + if( curIndicesCap < indicesBuffer.elemPosition() + indicesCount ) { + indicesBuffer.growIfNeeded(indicesCount * indicesBuffer.getCompsPerElem()); + curIndicesCap = indicesBuffer.getElemCapacity(); + } + if( curVerticesCap < gca_VerticesAttr.elemPosition() + verticesCount ) { + gca_VerticesAttr.growIfNeeded(verticesCount * gca_VerticesAttr.getCompsPerElem()); + gca_CurveParamsAttr.growIfNeeded(verticesCount * gca_CurveParamsAttr.getCompsPerElem()); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.growIfNeeded(verticesCount * gca_ColorsAttr.getCompsPerElem()); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); + } + } + + @Override + public void setBufferCapacity(final int verticesCount, final int indicesCount) { + if( curIndicesCap < indicesCount ) { + indicesBuffer.reserve(indicesCount); + curIndicesCap = indicesBuffer.getElemCapacity(); + } + if( curVerticesCap < verticesCount ) { + gca_VerticesAttr.reserve(verticesCount); + gca_CurveParamsAttr.reserve(verticesCount); + if( null != gca_ColorsAttr ) { + gca_ColorsAttr.reserve(verticesCount); + } + curVerticesCap = gca_VerticesAttr.getElemCapacity(); } } |