From 6b33ae470a02e6b37727ed7001651c773a3cce86 Mon Sep 17 00:00:00 2001 From: Nehon Date: Sun, 5 Feb 2017 17:54:44 +0100 Subject: [PATCH] Added a new step in AppProfiler for viewport processors and added method to pass the profiler to all processors. --- .../com/jme3/app/DefaultAndroidProfiler.java | 11 +++++--- .../jme3/app/state/VideoRecorderAppState.java | 7 +++++ .../main/java/com/jme3/app/BasicProfiler.java | 12 ++++++--- .../jme3/app/state/ScreenshotAppState.java | 9 ++++++- .../light/LightProbeBlendingProcessor.java | 10 +++++-- .../src/main/java/com/jme3/post/Filter.java | 13 +++++++++ .../com/jme3/post/FilterPostProcessor.java | 20 ++++++++++---- .../main/java/com/jme3/post/HDRRenderer.java | 7 +++++ .../java/com/jme3/post/PreDepthProcessor.java | 7 +++++ .../java/com/jme3/post/SceneProcessor.java | 8 ++++++ .../java/com/jme3/profile/AppProfiler.java | 7 ++++- .../main/java/com/jme3/profile/SpStep.java | 13 +++++++++ .../main/java/com/jme3/profile/VpStep.java | 2 ++ .../java/com/jme3/renderer/RenderManager.java | 12 ++++++--- .../jme3/shadow/AbstractShadowRenderer.java | 6 +++++ .../com/jme3/shadow/BasicShadowRenderer.java | 9 ++++++- .../com/jme3/shadow/PssmShadowRenderer.java | 8 ++++++ .../jme3/app/state/VideoRecorderAppState.java | 7 +++++ .../java/com/jme3/system/awt/AwtPanel.java | 7 +++++ .../java/com/jme3/post/ssao/SSAOFilter.java | 2 +- .../com/jme3/water/ReflectionProcessor.java | 7 +++++ .../com/jme3/water/SimpleWaterProcessor.java | 27 ++++++++++++------- .../com/jme3/niftygui/NiftyJmeDisplay.java | 7 +++++ 23 files changed, 186 insertions(+), 32 deletions(-) create mode 100644 jme3-core/src/main/java/com/jme3/profile/SpStep.java diff --git a/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java b/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java index 71a5dbd51..306887910 100644 --- a/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java +++ b/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java @@ -33,8 +33,8 @@ package com.jme3.app; import android.os.Build; -import com.jme3.profile.AppProfiler; -import com.jme3.profile.AppStep; +import com.jme3.profile.*; + import static com.jme3.profile.AppStep.BeginFrame; import static com.jme3.profile.AppStep.EndFrame; import static com.jme3.profile.AppStep.ProcessAudio; @@ -47,7 +47,6 @@ import static com.jme3.profile.AppStep.RenderPreviewViewPorts; import static com.jme3.profile.AppStep.SpatialUpdate; import static com.jme3.profile.AppStep.StateManagerRender; import static com.jme3.profile.AppStep.StateManagerUpdate; -import com.jme3.profile.VpStep; import static com.jme3.profile.VpStep.BeginRender; import static com.jme3.profile.VpStep.EndRender; import static com.jme3.profile.VpStep.FlushQueue; @@ -164,4 +163,10 @@ public class DefaultAndroidProfiler implements AppProfiler { } } } + + @Override + public void spStep(SpStep step, String... additionalInfo) { + + } + } diff --git a/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java b/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java index a388ad612..47d0e36ca 100644 --- a/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java +++ b/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java @@ -34,6 +34,7 @@ package com.jme3.app.state; import android.graphics.Bitmap; import com.jme3.app.Application; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; @@ -226,6 +227,7 @@ public class VideoRecorderAppState extends AbstractAppState { private LinkedBlockingQueue usedItems = new LinkedBlockingQueue(); private MjpegFileWriter writer; private boolean fastMode = true; + private AppProfiler prof; public void addImage(Renderer renderer, FrameBuffer out) { if (freeItems == null) { @@ -313,6 +315,11 @@ public class VideoRecorderAppState extends AbstractAppState { } writer = null; } + + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } } public static final class IsoTimer extends com.jme3.system.Timer { diff --git a/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java b/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java index e36356040..d652e4488 100644 --- a/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java +++ b/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java @@ -32,9 +32,7 @@ package com.jme3.app; -import com.jme3.profile.AppProfiler; -import com.jme3.profile.AppStep; -import com.jme3.profile.VpStep; +import com.jme3.profile.*; import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue.Bucket; import com.jme3.scene.Mesh; @@ -191,7 +189,13 @@ public class BasicProfiler implements AppProfiler { @Override public void vpStep( VpStep step, ViewPort vp, Bucket bucket ) { - } + } + + @Override + public void spStep(SpStep step, String... additionalInfo) { + + } + } diff --git a/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java b/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java index c6ba5b124..ea4d5cd73 100644 --- a/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java +++ b/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java @@ -37,6 +37,7 @@ import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; @@ -67,6 +68,7 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen private String shotName; private long shotIndex = 0; private int width, height; + private AppProfiler prof; /** * Using this constructor, the screenshot files will be written sequentially to the system @@ -256,7 +258,12 @@ public class ScreenshotAppState extends AbstractAppState implements ActionListen } } } - + + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + /** * Called by postFrame() once the screen has been captured to outBuf. */ diff --git a/jme3-core/src/main/java/com/jme3/light/LightProbeBlendingProcessor.java b/jme3-core/src/main/java/com/jme3/light/LightProbeBlendingProcessor.java index 9e1ec344b..572fd5c18 100644 --- a/jme3-core/src/main/java/com/jme3/light/LightProbeBlendingProcessor.java +++ b/jme3-core/src/main/java/com/jme3/light/LightProbeBlendingProcessor.java @@ -33,6 +33,7 @@ package com.jme3.light; import com.jme3.bounding.BoundingSphere; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue; @@ -56,6 +57,7 @@ public class LightProbeBlendingProcessor implements SceneProcessor { private RenderManager renderManager; private LightProbe probe = new LightProbe(); private Spatial poi; + private AppProfiler prof; public LightProbeBlendingProcessor(Spatial poi) { this.poi = poi; @@ -177,8 +179,12 @@ public class LightProbeBlendingProcessor implements SceneProcessor { public void setPoi(Spatial poi) { this.poi = poi; } - - + + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + private class BlendFactor implements Comparable{ LightProbe lightProbe; diff --git a/jme3-core/src/main/java/com/jme3/post/Filter.java b/jme3-core/src/main/java/com/jme3/post/Filter.java index feaacbe5d..b162ed511 100644 --- a/jme3-core/src/main/java/com/jme3/post/Filter.java +++ b/jme3-core/src/main/java/com/jme3/post/Filter.java @@ -85,6 +85,14 @@ public abstract class Filter implements Savable { protected Texture2D renderedTexture; protected Texture2D depthTexture; protected Material passMaterial; + protected String name; + + public Pass(String name) { + this.name = name; + } + + public Pass() { + } /** * init the pass called internally @@ -197,6 +205,11 @@ public abstract class Filter implements Savable { depthTexture.getImage().dispose(); } } + + @Override + public String toString() { + return name == null ? super.toString() : name; + } } /** diff --git a/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java b/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java index fc7fdd6bf..7ccbbe5ae 100644 --- a/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java +++ b/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java @@ -34,6 +34,7 @@ package com.jme3.post; import com.jme3.asset.AssetManager; import com.jme3.export.*; import com.jme3.material.Material; +import com.jme3.profile.*; import com.jme3.renderer.*; import com.jme3.renderer.queue.RenderQueue; import com.jme3.texture.FrameBuffer; @@ -56,6 +57,7 @@ import java.util.List; */ public class FilterPostProcessor implements SceneProcessor, Savable { + public static final String FPP = FilterPostProcessor.class.getSimpleName(); private RenderManager renderManager; private Renderer renderer; private ViewPort viewPort; @@ -80,6 +82,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable { private int lastFilterIndex = -1; private boolean cameraInit = false; private boolean multiView = false; + private AppProfiler prof; private Format fbFormat = Format.RGB111110F; @@ -216,7 +219,6 @@ public class FilterPostProcessor implements SceneProcessor, Savable { r.setFrameBuffer(buff); r.clearBuffers(true, true, true); renderManager.renderGeometry(fsQuad); - } public boolean isInitialized() { @@ -224,13 +226,12 @@ public class FilterPostProcessor implements SceneProcessor, Savable { } public void postQueue(RenderQueue rq) { - for (Filter filter : filters.getArray()) { if (filter.isEnabled()) { + if (prof != null) prof.spStep(SpStep.ProcPostQueue, FPP, filter.getName()); filter.postQueue(rq); } } - } /** @@ -244,10 +245,12 @@ public class FilterPostProcessor implements SceneProcessor, Savable { boolean msDepth = depthTexture != null && depthTexture.getImage().getMultiSamples() > 1; for (int i = 0; i < filters.size(); i++) { Filter filter = filters.get(i); + if (prof != null) prof.spStep(SpStep.ProcPostFrame, FPP, filter.getName()); if (filter.isEnabled()) { if (filter.getPostRenderPasses() != null) { for (Iterator it1 = filter.getPostRenderPasses().iterator(); it1.hasNext();) { Filter.Pass pass = it1.next(); + if (prof != null) prof.spStep(SpStep.ProcPostFrame, FPP, filter.getName(), pass.toString()); pass.beforeRender(); if (pass.requiresSceneAsTexture()) { pass.getPassMaterial().setTexture("Texture", tex); @@ -269,7 +272,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable { renderProcessing(r, pass.getRenderFrameBuffer(), pass.getPassMaterial()); } } - + if (prof != null) prof.spStep(SpStep.ProcPostFrame, FPP, filter.getName(), "postFrame"); filter.postFrame(renderManager, viewPort, buff, sceneFb); Material mat = filter.getMaterial(); @@ -298,7 +301,9 @@ public class FilterPostProcessor implements SceneProcessor, Savable { tex = filter.getRenderedTexture(); } + if (prof != null) prof.spStep(SpStep.ProcPostFrame, FPP, filter.getName(), "render"); renderProcessing(r, buff, mat); + if (prof != null) prof.spStep(SpStep.ProcPostFrame, FPP, filter.getName(), "postFilter"); filter.postFilter(r, buff); if (wantsBilinear) { @@ -324,7 +329,6 @@ public class FilterPostProcessor implements SceneProcessor, Savable { if (viewPort != null) { renderManager.setCamera(viewPort.getCamera(), false); } - } public void preFrame(float tpf) { @@ -351,6 +355,7 @@ public class FilterPostProcessor implements SceneProcessor, Savable { for (Filter filter : filters.getArray()) { if (filter.isEnabled()) { + if (prof != null) prof.spStep(SpStep.ProcPreFrame, FPP, filter.getName()); filter.preFrame(tpf); } } @@ -419,6 +424,11 @@ public class FilterPostProcessor implements SceneProcessor, Savable { } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + public void reshape(ViewPort vp, int w, int h) { Camera cam = vp.getCamera(); //this has no effect at first init but is useful when resizing the canvas with multi views diff --git a/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java b/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java index 06482f21f..424f3b689 100644 --- a/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java +++ b/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java @@ -34,6 +34,7 @@ package com.jme3.post; import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.math.Vector2f; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.*; import com.jme3.renderer.queue.RenderQueue; import com.jme3.texture.FrameBuffer; @@ -61,6 +62,7 @@ public class HDRRenderer implements SceneProcessor { private RenderManager renderManager; private ViewPort viewPort; private static final Logger logger = Logger.getLogger(HDRRenderer.class.getName()); + private AppProfiler prof; private Camera fbCam = new Camera(1, 1); @@ -418,4 +420,9 @@ public class HDRRenderer implements SceneProcessor { } } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + } diff --git a/jme3-core/src/main/java/com/jme3/post/PreDepthProcessor.java b/jme3-core/src/main/java/com/jme3/post/PreDepthProcessor.java index 3b318b514..a3125dd1e 100644 --- a/jme3-core/src/main/java/com/jme3/post/PreDepthProcessor.java +++ b/jme3-core/src/main/java/com/jme3/post/PreDepthProcessor.java @@ -35,6 +35,7 @@ import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.material.RenderState; import com.jme3.material.RenderState.FaceCullMode; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue; @@ -51,6 +52,7 @@ public class PreDepthProcessor implements SceneProcessor { private AssetManager assetManager; private Material preDepth; private RenderState forcedRS; + private AppProfiler prof; public PreDepthProcessor(AssetManager assetManager){ this.assetManager = assetManager; @@ -96,4 +98,9 @@ public class PreDepthProcessor implements SceneProcessor { vp = null; } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + } diff --git a/jme3-core/src/main/java/com/jme3/post/SceneProcessor.java b/jme3-core/src/main/java/com/jme3/post/SceneProcessor.java index 4f90e52ff..3a8ff1689 100644 --- a/jme3-core/src/main/java/com/jme3/post/SceneProcessor.java +++ b/jme3-core/src/main/java/com/jme3/post/SceneProcessor.java @@ -31,6 +31,7 @@ */ package com.jme3.post; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue; @@ -90,4 +91,11 @@ public interface SceneProcessor { */ public void cleanup(); + /** + * Sets a profiler Instance for this processor. + * + * @param profiler the profiler instance. + */ + public void setProfiler(AppProfiler profiler); + } diff --git a/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java b/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java index 85ab1e74c..4cfe0b92f 100644 --- a/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java +++ b/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java @@ -57,7 +57,12 @@ public interface AppProfiler { * steps the Bucket parameter will be non-null. */ public void vpStep(VpStep step, ViewPort vp, Bucket bucket); - + + /** + * Called at the beginning of the specified SpStep (SceneProcessor step). + * For more detailed steps it is possible to provide additional information as strings, like the name of the processor. + */ + public void spStep(SpStep step, String... additionalInfo); } diff --git a/jme3-core/src/main/java/com/jme3/profile/SpStep.java b/jme3-core/src/main/java/com/jme3/profile/SpStep.java new file mode 100644 index 000000000..13d25d976 --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/profile/SpStep.java @@ -0,0 +1,13 @@ +package com.jme3.profile; + +/** + * Indicates a scene processor-level step within the profiled + * frame. + *

+ * Created by Nehon on 25/01/2017. + */ +public enum SpStep { + ProcPreFrame, + ProcPostQueue, + ProcPostFrame, +} diff --git a/jme3-core/src/main/java/com/jme3/profile/VpStep.java b/jme3-core/src/main/java/com/jme3/profile/VpStep.java index c295be3af..9dff85368 100644 --- a/jme3-core/src/main/java/com/jme3/profile/VpStep.java +++ b/jme3-core/src/main/java/com/jme3/profile/VpStep.java @@ -42,9 +42,11 @@ package com.jme3.profile; public enum VpStep { BeginRender, RenderScene, + PreFrame, PostQueue, FlushQueue, PostFrame, + ProcEndRender, RenderBucket, EndRender } diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java index 5d8265fcb..950f1a4a6 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java +++ b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java @@ -42,9 +42,7 @@ import com.jme3.material.Technique; import com.jme3.material.TechniqueDef; import com.jme3.math.*; import com.jme3.post.SceneProcessor; -import com.jme3.profile.AppProfiler; -import com.jme3.profile.AppStep; -import com.jme3.profile.VpStep; +import com.jme3.profile.*; import com.jme3.renderer.queue.GeometryList; import com.jme3.renderer.queue.RenderQueue; import com.jme3.renderer.queue.RenderQueue.Bucket; @@ -1070,10 +1068,13 @@ public class RenderManager { } if (processors != null) { + if (prof != null) prof.vpStep(VpStep.PreFrame, vp, null); for (SceneProcessor proc : processors.getArray()) { if (!proc.isInitialized()) { proc.initialize(this, vp); } + proc.setProfiler(this.prof); + if (prof != null) prof.spStep(SpStep.ProcPreFrame, proc.getClass().getSimpleName()); proc.preFrame(tpf); } } @@ -1098,6 +1099,7 @@ public class RenderManager { if (processors != null) { if (prof!=null) prof.vpStep(VpStep.PostQueue, vp, null); for (SceneProcessor proc : processors.getArray()) { + if (prof != null) prof.spStep(SpStep.ProcPostQueue, proc.getClass().getSimpleName()); proc.postQueue(vp.getQueue()); } } @@ -1108,14 +1110,16 @@ public class RenderManager { if (processors != null) { if (prof!=null) prof.vpStep(VpStep.PostFrame, vp, null); for (SceneProcessor proc : processors.getArray()) { + if (prof != null) prof.spStep(SpStep.ProcPostFrame, proc.getClass().getSimpleName()); proc.postFrame(vp.getOutputFrameBuffer()); } + if (prof != null) prof.vpStep(VpStep.ProcEndRender, vp, null); } //renders the translucent objects queue after processors have been rendered renderTranslucentQueue(vp); // clear any remaining spatials that were not rendered. clearQueue(vp); - + if (prof!=null) prof.vpStep(VpStep.EndRender, vp, null); } diff --git a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java index dff4da90d..b390c1340 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java @@ -44,6 +44,7 @@ import com.jme3.math.Matrix4f; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; @@ -99,6 +100,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, protected Picture[] dispPic; protected RenderState forcedRenderState = new RenderState(); protected Boolean renderBackFacesShadows = true; + protected AppProfiler prof; /** * true if the fallback material should be used, otherwise false @@ -807,6 +809,10 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, init(assetManager, nbShadowMaps, (int) shadowMapSize); } + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + /** * De-serialize this instance, for example when loading from a J3O file. * diff --git a/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java index 1410574ea..4beb4000c 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java @@ -35,6 +35,7 @@ import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.math.Vector3f; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; @@ -75,7 +76,8 @@ public class BasicShadowRenderer implements SceneProcessor { protected GeometryList lightReceivers = new GeometryList(new OpaqueComparator()); protected GeometryList shadowOccluders = new GeometryList(new OpaqueComparator()); - + private AppProfiler prof; + /** * Creates a BasicShadowRenderer * @param manager the asset manager @@ -221,6 +223,11 @@ public class BasicShadowRenderer implements SceneProcessor { public void cleanup() { } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + public void reshape(ViewPort vp, int w, int h) { dispPic.setPosition(w / 20f, h / 20f); dispPic.setWidth(w / 5f); diff --git a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java index bf6362d62..4b854ec37 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java @@ -38,6 +38,7 @@ import com.jme3.math.Matrix4f; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; import com.jme3.renderer.Caps; import com.jme3.renderer.RenderManager; @@ -76,6 +77,8 @@ import java.util.List; @Deprecated public class PssmShadowRenderer implements SceneProcessor { + private AppProfiler prof; + /** * FilterMode specifies how shadows are filtered * @deprecated use {@link EdgeFilteringMode} @@ -725,6 +728,11 @@ public class PssmShadowRenderer implements SceneProcessor { } } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + /** * get the length over which the shadow will fade out when using a * shadowZextend diff --git a/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java b/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java index ccaecc580..90b9e98cf 100644 --- a/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java +++ b/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java @@ -33,6 +33,7 @@ package com.jme3.app.state; import com.jme3.app.Application; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; @@ -220,6 +221,7 @@ public class VideoRecorderAppState extends AbstractAppState { private LinkedBlockingQueue freeItems; private LinkedBlockingQueue usedItems = new LinkedBlockingQueue(); private MjpegFileWriter writer; + private AppProfiler prof; public void addImage(Renderer renderer, FrameBuffer out) { if (freeItems == null) { @@ -298,6 +300,11 @@ public class VideoRecorderAppState extends AbstractAppState { } writer = null; } + + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } } public static final class IsoTimer extends com.jme3.system.Timer { diff --git a/jme3-desktop/src/main/java/com/jme3/system/awt/AwtPanel.java b/jme3-desktop/src/main/java/com/jme3/system/awt/AwtPanel.java index 8c472bda1..f77eb7336 100644 --- a/jme3-desktop/src/main/java/com/jme3/system/awt/AwtPanel.java +++ b/jme3-desktop/src/main/java/com/jme3/system/awt/AwtPanel.java @@ -32,6 +32,7 @@ package com.jme3.system.awt; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue; @@ -79,6 +80,7 @@ public class AwtPanel extends Canvas implements SceneProcessor { private int newHeight = 1; private AtomicBoolean reshapeNeeded = new AtomicBoolean(false); private final Object lock = new Object(); + private AppProfiler prof; public AwtPanel(PaintMode paintMode) { this(paintMode, false); @@ -333,4 +335,9 @@ public class AwtPanel extends Canvas implements SceneProcessor { @Override public void cleanup() { } + + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } } diff --git a/jme3-effects/src/main/java/com/jme3/post/ssao/SSAOFilter.java b/jme3-effects/src/main/java/com/jme3/post/ssao/SSAOFilter.java index 860b834df..3645bfd36 100644 --- a/jme3-effects/src/main/java/com/jme3/post/ssao/SSAOFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/ssao/SSAOFilter.java @@ -156,7 +156,7 @@ public class SSAOFilter extends Filter { random.setWrap(Texture.WrapMode.Repeat); ssaoMat.setTexture("RandomMap", random); - ssaoPass = new Pass() { + ssaoPass = new Pass("SSAO pass") { @Override public boolean requiresDepthAsTexture() { diff --git a/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java b/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java index 6307c474e..a3c12e4e8 100644 --- a/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java +++ b/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java @@ -33,6 +33,7 @@ package com.jme3.water; import com.jme3.math.Plane; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; @@ -50,6 +51,7 @@ public class ReflectionProcessor implements SceneProcessor { private Camera reflectionCam; private FrameBuffer reflectionBuffer; private Plane reflectionClipPlane; + private AppProfiler prof; /** * Creates a ReflectionProcessor @@ -100,6 +102,11 @@ public class ReflectionProcessor implements SceneProcessor { public void cleanup() { } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + /** * Internal use only
* returns the frame buffer diff --git a/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java b/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java index 996720904..7f07cd550 100644 --- a/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java +++ b/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java @@ -35,21 +35,16 @@ import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.math.*; import com.jme3.post.SceneProcessor; -import com.jme3.renderer.Camera; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.Renderer; -import com.jme3.renderer.ViewPort; +import com.jme3.profile.AppProfiler; +import com.jme3.renderer.*; import com.jme3.renderer.queue.RenderQueue; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; import com.jme3.scene.shape.Quad; -import com.jme3.texture.FrameBuffer; +import com.jme3.texture.*; import com.jme3.texture.Image.Format; -import com.jme3.texture.Texture; import com.jme3.texture.Texture.WrapMode; -import com.jme3.texture.Texture2D; import com.jme3.ui.Picture; -import com.jme3.util.TempVars; /** * @@ -125,8 +120,9 @@ public class SimpleWaterProcessor implements SceneProcessor { private float distortionScale = 0.2f; private float distortionMix = 0.5f; private float texScale = 1f; - - + private AppProfiler prof; + + /** * Creates a SimpleWaterProcessor * @param manager the asset manager @@ -222,6 +218,11 @@ public class SimpleWaterProcessor implements SceneProcessor { public void cleanup() { } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + //debug only : displays maps protected void displayMap(Renderer r, Picture pic, int left) { Camera cam = vp.getCamera(); @@ -585,6 +586,7 @@ public class SimpleWaterProcessor implements SceneProcessor { RenderManager rm; ViewPort vp; + private AppProfiler prof; public void initialize(RenderManager rm, ViewPort vp) { this.rm = rm; @@ -611,5 +613,10 @@ public class SimpleWaterProcessor implements SceneProcessor { public void cleanup() { } + + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } } } diff --git a/jme3-niftygui/src/main/java/com/jme3/niftygui/NiftyJmeDisplay.java b/jme3-niftygui/src/main/java/com/jme3/niftygui/NiftyJmeDisplay.java index 53967f4af..4f6d6de7b 100644 --- a/jme3-niftygui/src/main/java/com/jme3/niftygui/NiftyJmeDisplay.java +++ b/jme3-niftygui/src/main/java/com/jme3/niftygui/NiftyJmeDisplay.java @@ -42,6 +42,7 @@ import com.jme3.audio.AudioRenderer; import com.jme3.input.InputManager; import com.jme3.input.event.KeyInputEvent; import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; import com.jme3.renderer.ViewPort; @@ -71,6 +72,7 @@ public class NiftyJmeDisplay implements SceneProcessor { protected ResourceLocationJme resourceLocation; protected int w, h; + private AppProfiler prof; protected class ResourceLocationJme implements ResourceLocation { @@ -359,4 +361,9 @@ public class NiftyJmeDisplay implements SceneProcessor { } } + @Override + public void setProfiler(AppProfiler profiler) { + this.prof = profiler; + } + }