frameTime.closeFrame(); String path = getPath(step.name()); if (step == AppStep.EndFrame) { if (frameEnded) { return; addStep(path, System.nanoTime()); StatLine end = data.get(path); end.setValueCpu(System.nanoTime() - startFrame); frameEnded = true; } else { addStep(path, System.nanoTime()); closeFrame();
private void addStep(String path, long value) { if (ongoingGpuProfiling && renderer != null) { renderer.stopProfiling(); ongoingGpuProfiling = false; } if (prevPath != null) { StatLine prevLine = data.get(prevPath); if (prevLine != null) { prevLine.setValueCpu(value - prevLine.getValueCpu()); } } StatLine line = pool.get(path); if (line == null) { line = new StatLine(currentFrame); pool.put(path, line); } data.put(path, line); line.setNewFrameValueCpu(value); if (renderer != null) { int id = getUnusedTaskId(); line.taskIds.add(id); renderer.startProfiling(id); } ongoingGpuProfiling = true; prevPath = path; }
public void setRenderer(Renderer renderer) { this.renderer = renderer; poolTaskIds(renderer); }
private void closeFrame() { //close frame if (data != null) { prevPath = null; for (StatLine statLine : data.values()) { statLine.closeFrame(); } currentFrame++; } }
private void layout() { height = 0; selectedValueCpu = 0; selectedValueGpu = 0; rootLine.layout(0); frameTimeValue.setText(df.format(getMsFromNs(prof.getAverageFrameTime())) + "ms"); frameTimeValue.setLocalTranslation(PANEL_WIDTH / 2, -PADDING, 0); setColor(frameTimeValue, prof.getAverageFrameTime(), totalTimeCpu, false, false); frameCpuTimeValue.setText(df.format(getMsFromNs(totalTimeCpu)) + "ms"); frameCpuTimeValue.setLocalTranslation(new Vector3f(PANEL_WIDTH / 4 - bigFont.getLineWidth(frameCpuTimeValue.getText()) / 2, -PADDING - 50, 0)); setColor(frameCpuTimeValue, totalTimeCpu, totalTimeCpu, false, false); frameGpuTimeValue.setText(df.format(getMsFromNs(totalTimeGpu)) + "ms"); frameGpuTimeValue.setLocalTranslation(new Vector3f(3 * PANEL_WIDTH / 4 - bigFont.getLineWidth(frameGpuTimeValue.getText()) / 2, -PADDING - 50, 0)); setColor(frameGpuTimeValue, totalTimeGpu, totalTimeGpu, false, false); selectedField.setText("Selected: " + df.format(getMsFromNs(selectedValueCpu)) + "ms / " + df.format(getMsFromNs(selectedValueGpu)) + "ms"); selectedField.setLocalTranslation(3 * PANEL_WIDTH / 4 - font.getLineWidth(selectedField.getText()) / 2, -PADDING - 75, 0); }
@Override public void vpStep(VpStep step, ViewPort vp, RenderQueue.Bucket bucket) { if (data != null) { vpPath.setLength(0); vpPath.append(vp.getName()).append("/").append((bucket == null ? step.name() : bucket.name() + " Bucket")); path.setLength(0); if ((lastVpStep == VpStep.PostQueue || lastVpStep == VpStep.PostFrame) && bucket != null) { path.append(curAppPath).append("/").append(curVpPath).append(curSpPath).append("/").append(vpPath); curVpPath = vpPath.toString(); } else { if (bucket != null) { path.append(curAppPath).append("/").append(curVpPath).append("/").append(bucket.name() + " Bucket"); } else { path.append(curAppPath).append("/").append(vpPath); curVpPath = vpPath.toString(); } } lastVpStep = step; addStep(path.toString(), System.nanoTime()); } }
font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt"); bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"); prof.setRenderer(app.getRenderer()); rootLine = new StatLineView("Frame"); rootLine.attachTo(ui);
private int getUnusedTaskId() { if (idsPool.isEmpty()) { poolTaskIds(renderer); } return idsPool.pop(); }
private void closeFrame() { //close frame if (data != null) { prevPath = null; for (StatLine statLine : data.values()) { statLine.closeFrame(); } currentFrame++; } }
private void layout() { height = 0; selectedValueCpu = 0; selectedValueGpu = 0; rootLine.layout(0); frameTimeValue.setText(df.format(getMsFromNs(prof.getAverageFrameTime())) + "ms"); frameTimeValue.setLocalTranslation(PANEL_WIDTH / 2, -PADDING, 0); setColor(frameTimeValue, prof.getAverageFrameTime(), totalTimeCpu, false, false); frameCpuTimeValue.setText(df.format(getMsFromNs(totalTimeCpu)) + "ms"); frameCpuTimeValue.setLocalTranslation(new Vector3f(PANEL_WIDTH / 4 - bigFont.getLineWidth(frameCpuTimeValue.getText()) / 2, -PADDING - 50, 0)); setColor(frameCpuTimeValue, totalTimeCpu, totalTimeCpu, false, false); frameGpuTimeValue.setText(df.format(getMsFromNs(totalTimeGpu)) + "ms"); frameGpuTimeValue.setLocalTranslation(new Vector3f(3 * PANEL_WIDTH / 4 - bigFont.getLineWidth(frameGpuTimeValue.getText()) / 2, -PADDING - 50, 0)); setColor(frameGpuTimeValue, totalTimeGpu, totalTimeGpu, false, false); selectedField.setText("Selected: " + df.format(getMsFromNs(selectedValueCpu)) + "ms / " + df.format(getMsFromNs(selectedValueGpu)) + "ms"); selectedField.setLocalTranslation(3 * PANEL_WIDTH / 4 - font.getLineWidth(selectedField.getText()) / 2, -PADDING - 75, 0); }
@Override public void vpStep(VpStep step, ViewPort vp, RenderQueue.Bucket bucket) { if (data != null) { vpPath.setLength(0); vpPath.append(vp.getName()).append("/").append((bucket == null ? step.name() : bucket.name() + " Bucket")); path.setLength(0); if ((lastVpStep == VpStep.PostQueue || lastVpStep == VpStep.PostFrame) && bucket != null) { path.append(curAppPath).append("/").append(curVpPath).append(curSpPath).append("/").append(vpPath); curVpPath = vpPath.toString(); } else { if (bucket != null) { path.append(curAppPath).append("/").append(curVpPath).append("/").append(bucket.name() + " Bucket"); } else { path.append(curAppPath).append("/").append(vpPath); curVpPath = vpPath.toString(); } } lastVpStep = step; addStep(path.toString(), System.nanoTime()); } }
font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt"); bigFont = app.getAssetManager().loadFont("Interface/Fonts/Default.fnt"); prof.setRenderer(app.getRenderer()); rootLine = new StatLineView("Frame"); rootLine.attachTo(ui);
frameTime.closeFrame(); String path = getPath(step.name()); if (step == AppStep.EndFrame) { if (frameEnded) { return; addStep(path, System.nanoTime()); StatLine end = data.get(path); end.setValueCpu(System.nanoTime() - startFrame); frameEnded = true; } else { addStep(path, System.nanoTime()); closeFrame();
public void setRenderer(Renderer renderer) { this.renderer = renderer; poolTaskIds(renderer); }
private void addStep(String path, long value) { if (ongoingGpuProfiling && renderer != null) { renderer.stopProfiling(); ongoingGpuProfiling = false; } if (prevPath != null) { StatLine prevLine = data.get(prevPath); if (prevLine != null) { prevLine.setValueCpu(value - prevLine.getValueCpu()); } } StatLine line = pool.get(path); if (line == null) { line = new StatLine(currentFrame); pool.put(path, line); } data.put(path, line); line.setNewFrameValueCpu(value); if (renderer != null) { int id = getUnusedTaskId(); line.taskIds.add(id); renderer.startProfiling(id); } ongoingGpuProfiling = true; prevPath = path; }
private int getUnusedTaskId() { if (idsPool.isEmpty()) { poolTaskIds(renderer); } return idsPool.pop(); }