profiler work
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
ae72912649
commit
b64c5090a6
@ -1956,6 +1956,8 @@ Towns spawn a population of characters when they are max-res'd
|
||||
Hitbox synchronization work
|
||||
LOD emitter service
|
||||
LOD component that destroys far-away physics
|
||||
visually LOD far away models support
|
||||
Profiler work
|
||||
|
||||
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ import electrosphere.client.ui.menu.debug.server.ImGuiTestGen;
|
||||
import electrosphere.client.ui.menu.editor.ImGuiEditorWindows;
|
||||
import electrosphere.controls.ControlHandler.ControlsState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiLinePlot;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiWindow;
|
||||
import electrosphere.renderer.ui.imgui.ImGuiLinePlot.ImGuiLinePlotDataset;
|
||||
@ -205,6 +206,9 @@ public class ImGuiWindowMacros {
|
||||
if(ImGui.button("Client Services")){
|
||||
ImGuiClientServices.clientServicesWindow.setOpen(true);
|
||||
}
|
||||
if(ImGui.button("Enable Profiler")){
|
||||
Main.setEnableProfiler();
|
||||
}
|
||||
//close button
|
||||
if(ImGui.button("Close")){
|
||||
mainDebugWindow.setOpen(false);
|
||||
|
||||
@ -420,7 +420,7 @@ public class CollisionEngine {
|
||||
throw new Error(message);
|
||||
}
|
||||
|
||||
Globals.profiler.beginAggregateCpuSample("CollisionEngine.nearCallback - try collisions");
|
||||
Globals.profiler.beginAggregateCpuSample("CollisionEngine.nearCallback - Full collision phase");
|
||||
try {
|
||||
//creates a buffer to store potential collisions
|
||||
DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); // up to MAX_CONTACTS contacts per box-box
|
||||
@ -452,7 +452,9 @@ public class CollisionEngine {
|
||||
}
|
||||
}
|
||||
//calculate collisions
|
||||
Globals.profiler.beginAggregateCpuSample("CollisionEngine.nearCallback - OdeHelper.collide");
|
||||
int numc = OdeHelper.collide(o1,o2,MAX_CONTACTS,contacts.getGeomBuffer());
|
||||
Globals.profiler.endCpuSample();
|
||||
//create DContacts based on each collision that occurs
|
||||
if (numc != 0) {
|
||||
for (int i=0; i<numc; i++) {
|
||||
|
||||
@ -121,7 +121,7 @@ public class Globals {
|
||||
//
|
||||
//To compress into a single "performance" object
|
||||
//
|
||||
public static Profiler profiler;
|
||||
public static final Profiler profiler = new Profiler();
|
||||
public static NetMonitor netMonitor;
|
||||
|
||||
|
||||
@ -173,8 +173,6 @@ public class Globals {
|
||||
if(Globals.gameConfigCurrent.getSettings().getNetRunNetMonitor()){
|
||||
netMonitor = new NetMonitor();
|
||||
}
|
||||
//profiler
|
||||
profiler = new Profiler();
|
||||
|
||||
|
||||
//add services here
|
||||
|
||||
@ -75,6 +75,11 @@ public class Main {
|
||||
*/
|
||||
static int framestep = 2;
|
||||
|
||||
/**
|
||||
* Sets whether to enable the profiler or not
|
||||
*/
|
||||
private static boolean enableProfiler = false;
|
||||
|
||||
|
||||
/**
|
||||
* The initial method of the application
|
||||
@ -202,6 +207,10 @@ public class Main {
|
||||
|
||||
//main loop
|
||||
while (running) {
|
||||
//enable profiler control
|
||||
if(Main.enableProfiler){
|
||||
Globals.profiler.start();
|
||||
}
|
||||
try {
|
||||
|
||||
Globals.profiler.beginRootCpuSample("frame");
|
||||
@ -441,9 +450,8 @@ public class Main {
|
||||
Globals.netMonitor.close();
|
||||
}
|
||||
//shutdown profiler
|
||||
if(Globals.profiler != null){
|
||||
Globals.profiler.destroy();
|
||||
}
|
||||
Globals.profiler.destroy();
|
||||
|
||||
//shutdown ode
|
||||
if(initOde){
|
||||
OdeHelper.closeODE();
|
||||
@ -484,6 +492,11 @@ public class Main {
|
||||
Main.framestep = framestep;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the engine to enable the profiler
|
||||
*/
|
||||
public static void setEnableProfiler(){
|
||||
Main.enableProfiler = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,11 @@ import org.lwjgl.util.remotery.Remotery;
|
||||
*/
|
||||
public class Profiler {
|
||||
|
||||
/**
|
||||
* Pointer value for uninitialized profiler
|
||||
*/
|
||||
private static final int UNINITIALIZED = -1;
|
||||
|
||||
/**
|
||||
* Controls whether to profile or not
|
||||
* !!WARNING!!: when this is turned on, testing can behave weirdly!! IE GET STUCK!
|
||||
@ -18,18 +23,16 @@ public class Profiler {
|
||||
/**
|
||||
* Pointer to the global instance
|
||||
*/
|
||||
private long pointer = -1;
|
||||
private long pointer = UNINITIALIZED;
|
||||
|
||||
/**
|
||||
* Creates the profiler
|
||||
*/
|
||||
public Profiler(){
|
||||
if(PROFILE){
|
||||
try(MemoryStack stack = MemoryStack.stackPush()){
|
||||
PointerBuffer allocBuffer = stack.mallocPointer(1);
|
||||
Remotery.rmt_CreateGlobalInstance(allocBuffer);
|
||||
pointer = allocBuffer.get();
|
||||
}
|
||||
try(MemoryStack stack = MemoryStack.stackPush()){
|
||||
PointerBuffer allocBuffer = stack.mallocPointer(1);
|
||||
Remotery.rmt_CreateGlobalInstance(allocBuffer);
|
||||
pointer = allocBuffer.get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,11 +86,18 @@ public class Profiler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the remotery instance
|
||||
*/
|
||||
public void start(){
|
||||
Profiler.PROFILE = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the profiler
|
||||
*/
|
||||
public void destroy(){
|
||||
if(PROFILE){
|
||||
if(pointer != UNINITIALIZED){
|
||||
Remotery.rmt_DestroyGlobalInstance(pointer);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user