diff options
author | phil <[email protected]> | 2016-12-05 11:31:37 +1300 |
---|---|---|
committer | phil <[email protected]> | 2016-12-05 11:31:37 +1300 |
commit | 0c9283835e3ba4ca2363334aa11f35aa613f0087 (patch) | |
tree | 702cb48736681c97f9a6838fd4df850d8959277e | |
parent | 26cbb62dede2a7bdf12b9762a9238e4fe7319399 (diff) |
setFFP more minimize calls added for matrixes
Also a frame stat of skipped no shader
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java | 461 | ||||
-rw-r--r-- | src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java | 181 |
2 files changed, 331 insertions, 311 deletions
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java b/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java index 36fe389..210b7a3 100644 --- a/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java +++ b/src/main/java/org/jogamp/java3d/Jogl2es2PerFrameStats.java @@ -1,230 +1,233 @@ -/*
- * Copyright (c) 2016 JogAmp Community. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-package org.jogamp.java3d;
-
-import java.util.HashSet;
-
-public class Jogl2es2PerFrameStats
-{
- public long endOfPrevFrameTime;
-
- public HashSet<ShaderProgramId> usedPrograms = new HashSet<ShaderProgramId>();
- //public ArrayList<ShaderProgramId> usedPrograms = new ArrayList<ShaderProgramId>();
- //public HashSet<String> usedProgramNames = new HashSet<String>();
- //TODO: how do I get these?
- //public HashMap<ShaderProgramId, String> usedProgramNames = new HashMap<ShaderProgramId, String>();
-
- public int geoToClearBuffers;
- public int glDrawStripArrays;
- public int glDrawStripArraysStrips;
- public int glDrawArrays;
- public int glDrawStripElements;
- public int glDrawStripElementsStrips;
- public int glDrawElements;
- public int setFFPAttributes;
- public int programToLocationData;
- public int enableTexCoordPointer;
- public int createGLSLShader;
- public int createGLSLShaderProgram;
- public int compileGLSLShader;
- public int destroyGLSLShader;
- public int destroyGLSLShaderProgram;
- public int linkGLSLShaderProgram;
- public int useGLSLShaderProgram;
- public int bindGLSLVertexAttrName;
- public int lookupGLSLShaderAttrNames;
- public int updateDirectionalLight;
- public int updatePointLight;
- public int updateSpotLight;
- public int updateExponentialFog;
- public int updateLinearFog;
- public int disableFog;
- public int setFogEnableFlag;
- public int updateLineAttributes;
- public int resetLineAttributes;
- public int updateMaterial;
- public int updateMaterialColor;
- public int updateColoringAttributes;
- public int resetColoringAttributes;
- public int updatePointAttributes;
- public int resetPointAttributes;
- public int updatePolygonAttributes;
- public int resetPolygonAttributes;
- public int updateRenderingAttributes;
- public int resetRenderingAttributes;
- public int updateTransparencyAttributes;
- public int resetTransparency;
- public int updateTextureAttributes;
- public int resetTextureAttributes;
- public int resetTexCoordGeneration;
- public int updateTextureUnitState;
- public int bindTexture2D;
- public int bindTextureCubeMap;
- public int setBlendColor;
- public int setBlendFunc;
- public int setFullSceneAntialiasing;
- public int setLightEnables;
- public int setSceneAmbient;
- public int activeTextureUnit;
- public int resetTextureNative;
- public int useCtx;
- public int releaseCtx;
- public int clear;
- public int setModelViewMatrix;
- public int setProjectionMatrix;
- public int setViewport;
- public int freeTexture;
- public int generateTexID;
- public int setDepthBufferWriteEnable;
- public int redundantUseProgram;
-
- public int coordCount;
- public int indexCount;
- public int glVertexAttribPointerNormals;
- public int glVertexAttribPointerUserAttribs;
- public int glVertexAttribPointerColor;
- public int glVertexAttribPointerCoord;
- public int glBufferData;
- public int glBufferSubData;
- public int glDisableVertexAttribArray;
-
- public int modelMatrixUpdated;
- public int glModelViewMatrixUpdated;
- public int glModelViewProjectionMatrixUpdated;
- public int glNormalMatrixUpdated;
- public int glModelViewMatrixInverseUpdated;
-
- public int modelMatrixSkipped;
- public int glModelViewMatrixSkipped;
- public int glModelViewProjectionMatrixSkipped;
- public int glNormalMatrixSkipped;
- public int glModelViewMatrixInverseSkipped;
-
- public int interleavedBufferCreated;
-
- public int glVertexAttribPointerInterleaved;
-
- public long setViewportTime;
-
- public long syncRenderTime;
-
- public void outputPerFrameData()
- {
- boolean highInterestOnly = true;
-
- System.out.println("coordCount " + coordCount + " indexCount " + indexCount);
- System.out.println("glDrawStripArrays " + glDrawStripArrays + "\t made up of glDrawStripArraysStrips " + glDrawStripArraysStrips);
- System.out.println("glDrawArrays " + glDrawArrays);
- System.out.println(
- "glDrawStripElements " + glDrawStripElements + "\t made up of glDrawStripElementsStrips " + glDrawStripElementsStrips);
- System.out.println("glDrawElements " + glDrawElements);
- System.out.println("glVertexAttribPointerCoord " + glVertexAttribPointerCoord);
- System.out.println("glVertexAttribPointerNormals " + glVertexAttribPointerNormals);
- System.out.println("glVertexAttribPointerColor " + glVertexAttribPointerColor);
- System.out.println("glVertexAttribPointerUserAttribs " + glVertexAttribPointerUserAttribs);
- System.out.println("enableTexCoordPointer " + enableTexCoordPointer);
- System.out.println("glBufferData " + glBufferData + " glBufferSubData " + glBufferSubData);
- System.out.println("glVertexAttribPointerInterleaved " + glVertexAttribPointerInterleaved);
- System.out.println("interleavedBufferCreated " + interleavedBufferCreated);
- System.out.println("---");
- System.out.println("setModelViewMatrix " + setModelViewMatrix);
- System.out.println("setFFPAttributes " + setFFPAttributes);
- System.out.println("modelMatrixUpdated " + modelMatrixUpdated + " modelMatrixSkipped " + modelMatrixSkipped);
- System.out
- .println("glModelViewMatrixUpdated " + glModelViewMatrixUpdated + " glModelViewMatrixSkipped " + glModelViewMatrixSkipped);
- System.out.println("glModelViewProjectionMatrixUpdated " + glModelViewProjectionMatrixUpdated
- + " glModelViewProjectionMatrixSkipped " + glModelViewProjectionMatrixSkipped);
- System.out.println("glNormalMatrixUpdated " + glNormalMatrixUpdated + " glNormalMatrixSkipped " + glNormalMatrixSkipped);
- System.out.println("---");
- if (!highInterestOnly)
- {
- System.out.println("glDisableVertexAttribArray " + glDisableVertexAttribArray + " note native called commented out, trouble?");
- System.out.println("geoToClearBuffers " + geoToClearBuffers);
- System.out.println("programToLocationData " + programToLocationData);
- System.out.print("createGLSLShader " + createGLSLShader);
- System.out.print("\tcreateGLSLShaderProgram " + createGLSLShaderProgram);
- System.out.print("\tcompileGLSLShader " + compileGLSLShader);
- System.out.print("\tdestroyGLSLShader " + destroyGLSLShader);
- System.out.print("\tdestroyGLSLShaderProgram " + destroyGLSLShaderProgram);
- System.out.print("\tlinkGLSLShaderProgram " + linkGLSLShaderProgram);
- System.out.print("\tbindGLSLVertexAttrName " + bindGLSLVertexAttrName);
- System.out.println("\tlookupGLSLShaderAttrNames " + lookupGLSLShaderAttrNames);
- System.out.print("updateDirectionalLight " + updateDirectionalLight);
- System.out.print("\tupdatePointLight " + updatePointLight);
- System.out.println("\tupdateSpotLight " + updateSpotLight);
- System.out.print("updateExponentialFog " + updateExponentialFog);
- System.out.print("\tupdateLinearFog " + updateLinearFog);
- System.out.print("\tdisableFog " + disableFog);
- System.out.println("\tsetFogEnableFlag " + setFogEnableFlag);
- System.out.print("updateLineAttributes " + updateLineAttributes);
- System.out.println("\tresetLineAttributes " + resetLineAttributes);
- System.out.print("updateMaterial " + updateMaterial);
- System.out.println("\tupdateMaterialColor " + updateMaterialColor);
- System.out.print("updateColoringAttributes " + updateColoringAttributes);
- System.out.println("\tresetColoringAttributes " + resetColoringAttributes);
- System.out.print("updatePointAttributes " + updatePointAttributes);
- System.out.println("\tresetPointAttributes " + resetPointAttributes);
- System.out.print("updatePolygonAttributes " + updatePolygonAttributes);
- System.out.println("\tresetPolygonAttributes " + resetPolygonAttributes);
- System.out.print("updateRenderingAttributes " + updateRenderingAttributes);
- System.out.println("\tresetRenderingAttributes " + resetRenderingAttributes);
- System.out.println("setBlendColor " + setBlendColor);
- System.out.println("setFullSceneAntialiasing " + setFullSceneAntialiasing);
- System.out.println("setLightEnables " + setLightEnables);
- System.out.println("setSceneAmbient " + setSceneAmbient);
- System.out.println("resetTexCoordGeneration " + resetTexCoordGeneration);
- System.out.println("freeTexture " + freeTexture);
- System.out.println("generateTexID " + generateTexID);
- System.out.println("useCtx " + useCtx);
- System.out.println("releaseCtx " + releaseCtx);
- System.out.println("clear " + clear);
- System.out.println("setViewport " + setViewport);
- System.out.println("setProjectionMatrix " + setProjectionMatrix);
- }
-
- System.out.print("updateTransparencyAttributes " + updateTransparencyAttributes);
- System.out.println("\tresetTransparency " + resetTransparency);
- System.out.print("updateTextureAttributes " + updateTextureAttributes);
- System.out.println("\tresetTextureAttributes " + resetTextureAttributes);
- System.out.println("updateTextureUnitState " + updateTextureUnitState);
- System.out.println("bindTexture2D " + bindTexture2D + "\tbindTextureCubeMap " + bindTextureCubeMap);
- System.out.println("setBlendFunc " + setBlendFunc);
- System.out.println("activeTextureUnit " + activeTextureUnit + "\tresetTextureNative " + resetTextureNative);
- System.out.println("setDepthBufferWriteEnable " + setDepthBufferWriteEnable);
- System.out.println("useGLSLShaderProgram " + useGLSLShaderProgram + " redundantUseProgram " + redundantUseProgram);
-
- //for (ShaderProgramId id : usedPrograms)
- // System.out.println("ShaderProgramId " + ((JoglShaderObject) id).getValue());
- if ((syncRenderTime - setViewportTime) != 0)
- {
- System.out.println("time in frame (not in glFinish) " + (syncRenderTime - setViewportTime) + //
- " = (ms) " + ((syncRenderTime - setViewportTime) / 1000000L));// + //
- // " = fps: " + (1000 / ((syncRenderTime - setViewportTime) / 1000000L)));
- }
-
- long now = System.nanoTime();
- System.out.println("time since end of previous frame (ns) " + (now - endOfPrevFrameTime) + //
- " = (ms) " + ((now - endOfPrevFrameTime) / 1000000L) + //
- " = fps: " + (1000 / ((now - endOfPrevFrameTime) / 1000000L)));
- }
+/* + * Copyright (c) 2016 JogAmp Community. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +package org.jogamp.java3d; + +import java.util.HashSet; + +public class Jogl2es2PerFrameStats +{ + public long endOfPrevFrameTime; + + public HashSet<ShaderProgramId> usedPrograms = new HashSet<ShaderProgramId>(); + //public ArrayList<ShaderProgramId> usedPrograms = new ArrayList<ShaderProgramId>(); + //public HashSet<String> usedProgramNames = new HashSet<String>(); + //TODO: how do I get these? + //public HashMap<ShaderProgramId, String> usedProgramNames = new HashMap<ShaderProgramId, String>(); + + public int geoToClearBuffers; + public int glDrawStripArrays; + public int glDrawStripArraysStrips; + public int glDrawArrays; + public int glDrawStripElements; + public int glDrawStripElementsStrips; + public int glDrawElements; + public int executeSkippedNoShaderProgram; + public int setFFPAttributes; + public int programToLocationData; + public int enableTexCoordPointer; + public int createGLSLShader; + public int createGLSLShaderProgram; + public int compileGLSLShader; + public int destroyGLSLShader; + public int destroyGLSLShaderProgram; + public int linkGLSLShaderProgram; + public int useGLSLShaderProgram; + public int bindGLSLVertexAttrName; + public int lookupGLSLShaderAttrNames; + public int updateDirectionalLight; + public int updatePointLight; + public int updateSpotLight; + public int updateExponentialFog; + public int updateLinearFog; + public int disableFog; + public int setFogEnableFlag; + public int updateLineAttributes; + public int resetLineAttributes; + public int updateMaterial; + public int updateMaterialColor; + public int updateColoringAttributes; + public int resetColoringAttributes; + public int updatePointAttributes; + public int resetPointAttributes; + public int updatePolygonAttributes; + public int resetPolygonAttributes; + public int updateRenderingAttributes; + public int resetRenderingAttributes; + public int updateTransparencyAttributes; + public int resetTransparency; + public int updateTextureAttributes; + public int resetTextureAttributes; + public int resetTexCoordGeneration; + public int updateTextureUnitState; + public int bindTexture2D; + public int bindTextureCubeMap; + public int setBlendColor; + public int setBlendFunc; + public int setFullSceneAntialiasing; + public int setLightEnables; + public int setSceneAmbient; + public int activeTextureUnit; + public int resetTextureNative; + public int useCtx; + public int releaseCtx; + public int clear; + public int setModelViewMatrix; + public int setProjectionMatrix; + public int setViewport; + public int freeTexture; + public int generateTexID; + public int setDepthBufferWriteEnable; + public int redundantUseProgram; + + public int coordCount; + public int indexCount; + public int glVertexAttribPointerNormals; + public int glVertexAttribPointerUserAttribs; + public int glVertexAttribPointerColor; + public int glVertexAttribPointerCoord; + public int glBufferData; + public int glBufferSubData; + public int glDisableVertexAttribArray; + + public int modelMatrixUpdated; + public int glModelViewMatrixUpdated; + public int glModelViewProjectionMatrixUpdated; + public int glNormalMatrixUpdated; + public int glModelViewMatrixInverseUpdated; + + public int modelMatrixSkipped; + public int glModelViewMatrixSkipped; + public int glModelViewProjectionMatrixSkipped; + public int glNormalMatrixSkipped; + public int glModelViewMatrixInverseSkipped; + + public int interleavedBufferCreated; + + public int glVertexAttribPointerInterleaved; + + public long setViewportTime; + + public long syncRenderTime; + + public void outputPerFrameData() + { + boolean highInterestOnly = true; + + System.out.println("coordCount " + coordCount + " indexCount " + indexCount); + System.out.println("glDrawStripArrays " + glDrawStripArrays + "\t made up of glDrawStripArraysStrips " + glDrawStripArraysStrips); + System.out.println("glDrawArrays " + glDrawArrays); + System.out.println( + "glDrawStripElements " + glDrawStripElements + "\t made up of glDrawStripElementsStrips " + glDrawStripElementsStrips); + System.out.println("glDrawElements " + glDrawElements); + System.out.println("glVertexAttribPointerCoord " + glVertexAttribPointerCoord); + System.out.println("glVertexAttribPointerNormals " + glVertexAttribPointerNormals); + System.out.println("glVertexAttribPointerColor " + glVertexAttribPointerColor); + System.out.println("glVertexAttribPointerUserAttribs " + glVertexAttribPointerUserAttribs); + System.out.println("enableTexCoordPointer " + enableTexCoordPointer); + System.out.println("glBufferData " + glBufferData + " glBufferSubData " + glBufferSubData); + System.out.println("glVertexAttribPointerInterleaved " + glVertexAttribPointerInterleaved); + System.out.println("interleavedBufferCreated " + interleavedBufferCreated); + System.out.println("---"); + System.out.println("setModelViewMatrix " + setModelViewMatrix); + System.out.println("setFFPAttributes " + setFFPAttributes); + System.out.println("executeSkippedNoShaderProgram " + executeSkippedNoShaderProgram); + + System.out.println("modelMatrixUpdated " + modelMatrixUpdated + " modelMatrixSkipped " + modelMatrixSkipped); + System.out + .println("glModelViewMatrixUpdated " + glModelViewMatrixUpdated + " glModelViewMatrixSkipped " + glModelViewMatrixSkipped); + System.out.println("glModelViewProjectionMatrixUpdated " + glModelViewProjectionMatrixUpdated + + " glModelViewProjectionMatrixSkipped " + glModelViewProjectionMatrixSkipped); + System.out.println("glNormalMatrixUpdated " + glNormalMatrixUpdated + " glNormalMatrixSkipped " + glNormalMatrixSkipped); + System.out.println("---"); + if (!highInterestOnly) + { + System.out.println("glDisableVertexAttribArray " + glDisableVertexAttribArray + " note native called commented out, trouble?"); + System.out.println("geoToClearBuffers " + geoToClearBuffers); + System.out.println("programToLocationData " + programToLocationData); + System.out.print("createGLSLShader " + createGLSLShader); + System.out.print("\tcreateGLSLShaderProgram " + createGLSLShaderProgram); + System.out.print("\tcompileGLSLShader " + compileGLSLShader); + System.out.print("\tdestroyGLSLShader " + destroyGLSLShader); + System.out.print("\tdestroyGLSLShaderProgram " + destroyGLSLShaderProgram); + System.out.print("\tlinkGLSLShaderProgram " + linkGLSLShaderProgram); + System.out.print("\tbindGLSLVertexAttrName " + bindGLSLVertexAttrName); + System.out.println("\tlookupGLSLShaderAttrNames " + lookupGLSLShaderAttrNames); + System.out.print("updateDirectionalLight " + updateDirectionalLight); + System.out.print("\tupdatePointLight " + updatePointLight); + System.out.println("\tupdateSpotLight " + updateSpotLight); + System.out.print("updateExponentialFog " + updateExponentialFog); + System.out.print("\tupdateLinearFog " + updateLinearFog); + System.out.print("\tdisableFog " + disableFog); + System.out.println("\tsetFogEnableFlag " + setFogEnableFlag); + System.out.print("updateLineAttributes " + updateLineAttributes); + System.out.println("\tresetLineAttributes " + resetLineAttributes); + System.out.print("updateMaterial " + updateMaterial); + System.out.println("\tupdateMaterialColor " + updateMaterialColor); + System.out.print("updateColoringAttributes " + updateColoringAttributes); + System.out.println("\tresetColoringAttributes " + resetColoringAttributes); + System.out.print("updatePointAttributes " + updatePointAttributes); + System.out.println("\tresetPointAttributes " + resetPointAttributes); + System.out.print("updatePolygonAttributes " + updatePolygonAttributes); + System.out.println("\tresetPolygonAttributes " + resetPolygonAttributes); + System.out.print("updateRenderingAttributes " + updateRenderingAttributes); + System.out.println("\tresetRenderingAttributes " + resetRenderingAttributes); + System.out.println("setBlendColor " + setBlendColor); + System.out.println("setFullSceneAntialiasing " + setFullSceneAntialiasing); + System.out.println("setLightEnables " + setLightEnables); + System.out.println("setSceneAmbient " + setSceneAmbient); + System.out.println("resetTexCoordGeneration " + resetTexCoordGeneration); + System.out.println("freeTexture " + freeTexture); + System.out.println("generateTexID " + generateTexID); + System.out.println("useCtx " + useCtx); + System.out.println("releaseCtx " + releaseCtx); + System.out.println("clear " + clear); + System.out.println("setViewport " + setViewport); + System.out.println("setProjectionMatrix " + setProjectionMatrix); + } + + System.out.print("updateTransparencyAttributes " + updateTransparencyAttributes); + System.out.println("\tresetTransparency " + resetTransparency); + System.out.print("updateTextureAttributes " + updateTextureAttributes); + System.out.println("\tresetTextureAttributes " + resetTextureAttributes); + System.out.println("updateTextureUnitState " + updateTextureUnitState); + System.out.println("bindTexture2D " + bindTexture2D + "\tbindTextureCubeMap " + bindTextureCubeMap); + System.out.println("setBlendFunc " + setBlendFunc); + System.out.println("activeTextureUnit " + activeTextureUnit + "\tresetTextureNative " + resetTextureNative); + System.out.println("setDepthBufferWriteEnable " + setDepthBufferWriteEnable); + System.out.println("useGLSLShaderProgram " + useGLSLShaderProgram + " redundantUseProgram " + redundantUseProgram); + + //for (ShaderProgramId id : usedPrograms) + // System.out.println("ShaderProgramId " + ((JoglShaderObject) id).getValue()); + if ((syncRenderTime - setViewportTime) != 0) + { + System.out.println("time in frame (not in glFinish) " + (syncRenderTime - setViewportTime) + // + " = (ms) " + ((syncRenderTime - setViewportTime) / 1000000L));// + // + // " = fps: " + (1000 / ((syncRenderTime - setViewportTime) / 1000000L))); + } + + long now = System.nanoTime(); + System.out.println("time since end of previous frame (ns) " + (now - endOfPrevFrameTime) + // + " = (ms) " + ((now - endOfPrevFrameTime) / 1000000L) + // + " = fps: " + (1000 / ((now - endOfPrevFrameTime) / 1000000L))); + } }
\ No newline at end of file diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java index e3ed085..bede426 100644 --- a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java +++ b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java @@ -772,6 +772,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline if (!NO_PROGRAM_WARNING_GIVEN) System.err.println("Execute called with no shader Program in use!"); NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; } if (DO_OUTPUT_ERRORS) @@ -1486,6 +1489,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline if (!NO_PROGRAM_WARNING_GIVEN) System.err.println("Execute called with no shader Program in use!"); NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; } if (DO_OUTPUT_ERRORS) @@ -2109,6 +2115,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline if (!NO_PROGRAM_WARNING_GIVEN) System.err.println("Execute called with no shader Program in use!"); NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; } if (DO_OUTPUT_ERRORS) @@ -2884,6 +2893,9 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline if (!NO_PROGRAM_WARNING_GIVEN) System.err.println("Execute called with no shader Program in use!"); NO_PROGRAM_WARNING_GIVEN = true; + + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.executeSkippedNoShaderProgram++; } if (DO_OUTPUT_ERRORS) outputErrors(ctx); @@ -2975,99 +2987,98 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline if (locs.glModelViewMatrix != -1) { - // minimise not working due to late calc of matrix - //if (!MINIMISE_NATIVE_CALLS_FFP - // || (shaderProgramId != ctx.prevShaderProgram || !ctx.gl_state.glModelViewMatrix.equals(ctx.currentModelViewMat))) - // { - ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); - - gl.glUniformMatrix4fv(locs.glModelViewMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMat), 0); - if (DO_OUTPUT_ERRORS) - outputErrors(ctx); - - if (MINIMISE_NATIVE_CALLS_FFP) - ctx.gl_state.glModelViewMatrix.set(ctx.currentModelViewMat); - if (OUTPUT_PER_FRAME_STATS) - ctx.perFrameStats.glModelViewMatrixUpdated++; - // } - // else if (OUTPUT_PER_FRAME_STATS) - // { - // ctx.perFrameStats.glModelViewMatrixSkipped++; - // } + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || !ctx.gl_state.glModelViewMatrix.equals(ctx.currentModelViewMat))) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); + + gl.glUniformMatrix4fv(locs.glModelViewMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMat), 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glModelViewMatrix.set(ctx.currentModelViewMat); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glModelViewMatrixUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glModelViewMatrixSkipped++; + } } if (locs.glModelViewMatrixInverse != -1) { - // minimise not working due to late calc of matrix - //if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram - // || !ctx.gl_state.glModelViewMatrixInverse.equals(ctx.currentModelViewMatInverse))) - //{ - // Expensive, only calc if required - ctx.currentModelViewMatInverse.mul(ctx.currentViewMat, ctx.currentModelMat); - ctx.matrixUtil.invert(ctx.currentModelViewMatInverse); - - //gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, false, ctx.toFB(ctx.currentModelViewMatInverse)); - gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse), 0); - if (DO_OUTPUT_ERRORS) - outputErrors(ctx); - - if (MINIMISE_NATIVE_CALLS_FFP) - ctx.gl_state.glModelViewMatrixInverse.set(ctx.currentModelViewMatInverse); - if (OUTPUT_PER_FRAME_STATS) - ctx.perFrameStats.glModelViewMatrixInverseUpdated++; - // } - // else if (OUTPUT_PER_FRAME_STATS) - // { - // ctx.perFrameStats.glModelViewMatrixInverseSkipped++; - // } + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram + || !ctx.gl_state.glModelViewMatrixInverse.equals(ctx.currentModelViewMatInverse))) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + ctx.currentModelViewMatInverse.mul(ctx.currentViewMat, ctx.currentModelMat); + ctx.matrixUtil.invert(ctx.currentModelViewMatInverse); + + //gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, false, ctx.toFB(ctx.currentModelViewMatInverse)); + gl.glUniformMatrix4fv(locs.glModelViewMatrixInverse, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewMatInverse), 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glModelViewMatrixInverse.set(ctx.currentModelViewMatInverse); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glModelViewMatrixInverseUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glModelViewMatrixInverseSkipped++; + } } if (locs.glModelViewProjectionMatrix != -1) { - // minimise not working due to late calc of matrix - // if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram - // || !ctx.gl_state.glModelViewProjectionMatrix.equals(ctx.currentModelViewProjMat))) - // { - ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); - ctx.currentModelViewProjMat.mul(ctx.currentProjMat, ctx.currentModelViewMat); - - //gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, false, ctx.toFB(ctx.currentModelViewProjMat)); - gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewProjMat), 0); - if (DO_OUTPUT_ERRORS) - outputErrors(ctx); - - if (MINIMISE_NATIVE_CALLS_FFP) - ctx.gl_state.glModelViewProjectionMatrix.set(ctx.currentModelViewProjMat); - if (OUTPUT_PER_FRAME_STATS) - ctx.perFrameStats.glModelViewProjectionMatrixUpdated++; - // } - // else if (OUTPUT_PER_FRAME_STATS) - // { - // ctx.perFrameStats.glModelViewProjectionMatrixSkipped++; - // } + if (!MINIMISE_NATIVE_CALLS_FFP || (shaderProgramId != ctx.prevShaderProgram + || !ctx.gl_state.glModelViewProjectionMatrix.equals(ctx.currentModelViewProjMat))) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); + ctx.currentModelViewProjMat.mul(ctx.currentProjMat, ctx.currentModelViewMat); + + //gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, false, ctx.toFB(ctx.currentModelViewProjMat)); + gl.glUniformMatrix4fv(locs.glModelViewProjectionMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentModelViewProjMat), 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glModelViewProjectionMatrix.set(ctx.currentModelViewProjMat); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glModelViewProjectionMatrixUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glModelViewProjectionMatrixSkipped++; + } } if (locs.glNormalMatrix != -1) { - // minimise not working due to late calc of matrix - //if (!MINIMISE_NATIVE_CALLS_FFP - // || (shaderProgramId != ctx.prevShaderProgram || !ctx.gl_state.glNormalMatrix.equals(ctx.currentNormalMat))) - //{ - ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); - Jogl2es2MatrixUtil.transposeInvert(ctx.currentModelViewMat, ctx.currentNormalMat); - - //gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, false, ctx.toFB(ctx.currentNormalMat)); - gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentNormalMat), 0); - if (DO_OUTPUT_ERRORS) - outputErrors(ctx); - if (MINIMISE_NATIVE_CALLS_FFP) - ctx.gl_state.glNormalMatrix.set(ctx.currentNormalMat); - if (OUTPUT_PER_FRAME_STATS) - ctx.perFrameStats.glNormalMatrixUpdated++; - //} - //else if (OUTPUT_PER_FRAME_STATS) - //{ - // ctx.perFrameStats.glNormalMatrixSkipped++; - //} + if (!MINIMISE_NATIVE_CALLS_FFP + || (shaderProgramId != ctx.prevShaderProgram || !ctx.gl_state.glNormalMatrix.equals(ctx.currentNormalMat))) + { + // Expensive, only calc if required, not in the setmodelview call, in case unneeded + ctx.currentModelViewMat.mul(ctx.currentViewMat, ctx.currentModelMat); + Jogl2es2MatrixUtil.transposeInvert(ctx.currentModelViewMat, ctx.currentNormalMat); + + //gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, false, ctx.toFB(ctx.currentNormalMat)); + gl.glUniformMatrix3fv(locs.glNormalMatrix, 1, true, ctx.matrixUtil.toArray(ctx.currentNormalMat), 0); + if (DO_OUTPUT_ERRORS) + outputErrors(ctx); + if (MINIMISE_NATIVE_CALLS_FFP) + ctx.gl_state.glNormalMatrix.set(ctx.currentNormalMat); + if (OUTPUT_PER_FRAME_STATS) + ctx.perFrameStats.glNormalMatrixUpdated++; + } + else if (OUTPUT_PER_FRAME_STATS) + { + ctx.perFrameStats.glNormalMatrixSkipped++; + } } // if set one of the 2 colors below should be used by the shader (material for lighting) @@ -6485,6 +6496,12 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline joglesctx.currentModelMat.set(modelMatrix); //Moved up into setffp and only calc'ed if requested + + joglesctx.currentModelViewMat.setZero(); // indicate no longer valid + joglesctx.currentModelViewMatInverse.setZero(); + joglesctx.currentModelViewProjMat.setZero(); + joglesctx.currentNormalMat.setZero(); + /* joglesctx.currentModelViewMat.mul(joglesctx.matrixUtil.deburnV, joglesctx.matrixUtil.deburnM); |