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