|
@@ -37,6 +37,9 @@ import com.jme3.material.RenderState;
|
|
|
import com.jme3.material.Technique;
|
|
|
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.renderer.queue.GeometryList;
|
|
|
import com.jme3.renderer.queue.RenderQueue;
|
|
|
import com.jme3.renderer.queue.RenderQueue.Bucket;
|
|
@@ -80,6 +83,7 @@ public class RenderManager {
|
|
|
private Matrix4f orthoMatrix = new Matrix4f();
|
|
|
private String tmpTech;
|
|
|
private boolean handleTranlucentBucket = true;
|
|
|
+ private AppProfiler prof;
|
|
|
|
|
|
/**
|
|
|
* Create a high-level rendering interface over the
|
|
@@ -377,6 +381,15 @@ public class RenderManager {
|
|
|
uniformBindingManager.setTimer(timer);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Sets an AppProfiler hook that will be called back for
|
|
|
+ * specific steps within a single update frame. Value defaults
|
|
|
+ * to null.
|
|
|
+ */
|
|
|
+ public void setAppProfiler(AppProfiler prof) {
|
|
|
+ this.prof = prof;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns the forced technique name set.
|
|
|
*
|
|
@@ -779,10 +792,12 @@ public class RenderManager {
|
|
|
|
|
|
// render opaque objects with default depth range
|
|
|
// opaque objects are sorted front-to-back, reducing overdraw
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Opaque);
|
|
|
rq.renderQueue(Bucket.Opaque, this, cam, flush);
|
|
|
|
|
|
// render the sky, with depth range set to the farthest
|
|
|
if (!rq.isQueueEmpty(Bucket.Sky)) {
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Sky);
|
|
|
renderer.setDepthRange(1, 1);
|
|
|
rq.renderQueue(Bucket.Sky, this, cam, flush);
|
|
|
depthRangeChanged = true;
|
|
@@ -793,6 +808,7 @@ public class RenderManager {
|
|
|
// rest of the scene's objects. Consequently, they are sorted
|
|
|
// back-to-front.
|
|
|
if (!rq.isQueueEmpty(Bucket.Transparent)) {
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Transparent);
|
|
|
if (depthRangeChanged) {
|
|
|
renderer.setDepthRange(0, 1);
|
|
|
depthRangeChanged = false;
|
|
@@ -802,6 +818,7 @@ public class RenderManager {
|
|
|
}
|
|
|
|
|
|
if (!rq.isQueueEmpty(Bucket.Gui)) {
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Gui);
|
|
|
renderer.setDepthRange(0, 0);
|
|
|
setCamera(cam, true);
|
|
|
rq.renderQueue(Bucket.Gui, this, cam, flush);
|
|
@@ -828,6 +845,8 @@ public class RenderManager {
|
|
|
* @see #setHandleTranslucentBucket(boolean)
|
|
|
*/
|
|
|
public void renderTranslucentQueue(ViewPort vp) {
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.RenderBucket, vp, Bucket.Translucent);
|
|
|
+
|
|
|
RenderQueue rq = vp.getQueue();
|
|
|
if (!rq.isQueueEmpty(Bucket.Translucent) && handleTranlucentBucket) {
|
|
|
rq.renderQueue(Bucket.Translucent, this, vp.getCamera(), true);
|
|
@@ -963,6 +982,8 @@ public class RenderManager {
|
|
|
if (!vp.isEnabled()) {
|
|
|
return;
|
|
|
}
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.BeginRender, vp, null);
|
|
|
+
|
|
|
SafeArrayList<SceneProcessor> processors = vp.getProcessors();
|
|
|
if (processors.isEmpty()) {
|
|
|
processors = null;
|
|
@@ -988,20 +1009,24 @@ public class RenderManager {
|
|
|
vp.isClearStencil());
|
|
|
}
|
|
|
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.RenderScene, vp, null);
|
|
|
List<Spatial> scenes = vp.getScenes();
|
|
|
for (int i = scenes.size() - 1; i >= 0; i--) {
|
|
|
renderScene(scenes.get(i), vp);
|
|
|
}
|
|
|
|
|
|
if (processors != null) {
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.PostQueue, vp, null);
|
|
|
for (SceneProcessor proc : processors.getArray()) {
|
|
|
proc.postQueue(vp.getQueue());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.FlushQueue, vp, null);
|
|
|
flushQueue(vp);
|
|
|
|
|
|
if (processors != null) {
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.PostFrame, vp, null);
|
|
|
for (SceneProcessor proc : processors.getArray()) {
|
|
|
proc.postFrame(vp.getOutputFrameBuffer());
|
|
|
}
|
|
@@ -1010,6 +1035,8 @@ public class RenderManager {
|
|
|
renderTranslucentQueue(vp);
|
|
|
// clear any remaining spatials that were not rendered.
|
|
|
clearQueue(vp);
|
|
|
+
|
|
|
+ if (prof!=null) prof.vpStep(VpStep.EndRender, vp, null);
|
|
|
}
|
|
|
|
|
|
public void setUsingShaders(boolean usingShaders) {
|
|
@@ -1037,18 +1064,23 @@ public class RenderManager {
|
|
|
this.shader = renderer.getCaps().contains(Caps.GLSL100);
|
|
|
uniformBindingManager.newFrame();
|
|
|
|
|
|
+ if (prof!=null) prof.appStep(AppStep.RenderPreviewViewPorts);
|
|
|
for (int i = 0; i < preViewPorts.size(); i++) {
|
|
|
ViewPort vp = preViewPorts.get(i);
|
|
|
if (vp.getOutputFrameBuffer() != null || mainFrameBufferActive) {
|
|
|
renderViewPort(vp, tpf);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (prof!=null) prof.appStep(AppStep.RenderMainViewPorts);
|
|
|
for (int i = 0; i < viewPorts.size(); i++) {
|
|
|
ViewPort vp = viewPorts.get(i);
|
|
|
if (vp.getOutputFrameBuffer() != null || mainFrameBufferActive) {
|
|
|
renderViewPort(vp, tpf);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (prof!=null) prof.appStep(AppStep.RenderPostViewPorts);
|
|
|
for (int i = 0; i < postViewPorts.size(); i++) {
|
|
|
ViewPort vp = postViewPorts.get(i);
|
|
|
if (vp.getOutputFrameBuffer() != null || mainFrameBufferActive) {
|