1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00

Add additional profiler scopes for increased resolution

This commit is contained in:
Daniel Evans 2018-08-31 20:01:50 +01:00
parent 14885c24dc
commit be55b616f7
5 changed files with 53 additions and 20 deletions

View File

@ -6,6 +6,7 @@
#define RW_PROFILE_THREAD(name) MicroProfileOnThreadCreate(name) #define RW_PROFILE_THREAD(name) MicroProfileOnThreadCreate(name)
#define RW_PROFILE_FRAME_BOUNDARY() MicroProfileFlip(nullptr) #define RW_PROFILE_FRAME_BOUNDARY() MicroProfileFlip(nullptr)
#define RW_PROFILE_SCOPE(label) MICROPROFILE_SCOPEI("Default", label, MP_YELLOW) #define RW_PROFILE_SCOPE(label) MICROPROFILE_SCOPEI("Default", label, MP_YELLOW)
#define RW_PROFILE_SCOPEC(label, colour) MICROPROFILE_SCOPEI("Default", label, colour)
#define RW_PROFILE_COUNTER_ADD(name, qty) MICROPROFILE_COUNTER_ADD(name, qty) #define RW_PROFILE_COUNTER_ADD(name, qty) MICROPROFILE_COUNTER_ADD(name, qty)
#define RW_PROFILE_COUNTER_SET(name, qty) MICROPROFILE_COUNTER_SET(name, qty) #define RW_PROFILE_COUNTER_SET(name, qty) MICROPROFILE_COUNTER_SET(name, qty)
#define RW_TIMELINE_ENTER(name, color) MICROPROFILE_TIMELINE_ENTER_STATIC(color, name) #define RW_TIMELINE_ENTER(name, color) MICROPROFILE_TIMELINE_ENTER_STATIC(color, name)
@ -14,6 +15,7 @@
#define RW_PROFILE_THREAD(name) do {} while (0) #define RW_PROFILE_THREAD(name) do {} while (0)
#define RW_PROFILE_FRAME_BOUNDARY() do {} while (0) #define RW_PROFILE_FRAME_BOUNDARY() do {} while (0)
#define RW_PROFILE_SCOPE(label) do {} while (0) #define RW_PROFILE_SCOPE(label) do {} while (0)
#define RW_PROFILE_SCOPEC(label, colour) do {} while (0)
#define RW_PROFILE_COUNTER_ADD(name, qty) do {} while (0) #define RW_PROFILE_COUNTER_ADD(name, qty) do {} while (0)
#define RW_PROFILE_COUNTER_SET(name, qty) do {} while (0) #define RW_PROFILE_COUNTER_SET(name, qty) do {} while (0)
#define RW_TIMELINE_ENTER(name, color) do {} while (0) #define RW_TIMELINE_ENTER(name, color) do {} while (0)

View File

@ -7,6 +7,7 @@
#include <data/Clump.hpp> #include <data/Clump.hpp>
#include "core/Profiler.hpp"
#include "core/Logger.hpp" #include "core/Logger.hpp"
#include "engine/GameData.hpp" #include "engine/GameData.hpp"
@ -653,6 +654,7 @@ void handleInstanceResponse(InstanceObject* instance, const btManifoldPoint& mp,
bool GameWorld::ContactProcessedCallback(btManifoldPoint& mp, void* body0, bool GameWorld::ContactProcessedCallback(btManifoldPoint& mp, void* body0,
void* body1) { void* body1) {
RW_PROFILE_SCOPEC(__func__, MP_GOLDENROD1);
auto obA = static_cast<btCollisionObject*>(body0); auto obA = static_cast<btCollisionObject*>(body0);
auto obB = static_cast<btCollisionObject*>(body1); auto obB = static_cast<btCollisionObject*>(body1);
@ -689,18 +691,24 @@ bool GameWorld::ContactProcessedCallback(btManifoldPoint& mp, void* body0,
void GameWorld::PhysicsTickCallback(btDynamicsWorld* physWorld, void GameWorld::PhysicsTickCallback(btDynamicsWorld* physWorld,
btScalar timeStep) { btScalar timeStep) {
RW_PROFILE_SCOPEC(__func__, MP_CYAN);
GameWorld* world = static_cast<GameWorld*>(physWorld->getWorldUserInfo()); GameWorld* world = static_cast<GameWorld*>(physWorld->getWorldUserInfo());
RW_PROFILE_COUNTER_SET("physicsTick/vehiclePool", world->vehiclePool.objects.size());
for (auto& p : world->vehiclePool.objects) { for (auto& p : world->vehiclePool.objects) {
RW_PROFILE_SCOPEC("VehicleObject", MP_THISTLE1);
VehicleObject* object = static_cast<VehicleObject*>(p.second); VehicleObject* object = static_cast<VehicleObject*>(p.second);
object->tickPhysics(timeStep); object->tickPhysics(timeStep);
} }
RW_PROFILE_COUNTER_SET("physicsTick/pedestrianPool", world->pedestrianPool.objects.size());
for (auto& p : world->pedestrianPool.objects) { for (auto& p : world->pedestrianPool.objects) {
RW_PROFILE_SCOPEC("CharacterObject", MP_THISTLE1);
CharacterObject* object = static_cast<CharacterObject*>(p.second); CharacterObject* object = static_cast<CharacterObject*>(p.second);
object->tickPhysics(timeStep); object->tickPhysics(timeStep);
} }
RW_PROFILE_COUNTER_SET("physicsTick/instancePool", world->instancePool.objects.size());
for (auto& p : world->instancePool.objects) { for (auto& p : world->instancePool.objects) {
InstanceObject* object = static_cast<InstanceObject*>(p.second); InstanceObject* object = static_cast<InstanceObject*>(p.second);
object->tickPhysics(timeStep); object->tickPhysics(timeStep);

View File

@ -6,6 +6,7 @@
#include "ai/PlayerController.hpp" #include "ai/PlayerController.hpp"
#include "core/Logger.hpp" #include "core/Logger.hpp"
#include "core/Profiler.hpp"
#include "engine/GameState.hpp" #include "engine/GameState.hpp"
#include "engine/GameWorld.hpp" #include "engine/GameWorld.hpp"
#include "script/SCMFile.hpp" #include "script/SCMFile.hpp"
@ -226,6 +227,7 @@ SCMByte* ScriptMachine::getGlobals() {
} }
void ScriptMachine::execute(float dt) { void ScriptMachine::execute(float dt) {
RW_PROFILE_SCOPEC(__func__, MP_ORANGERED);
int ms = dt * 1000.f; int ms = dt * 1000.f;
for (auto t = _activeThreads.begin(); t != _activeThreads.end(); ++t) { for (auto t = _activeThreads.begin(); t != _activeThreads.end(); ++t) {
auto& thread = *t; auto& thread = *t;

View File

@ -370,6 +370,7 @@ int RWGame::run() {
bool running = true; bool running = true;
while (StateManager::currentState() && running) { while (StateManager::currentState() && running) {
RW_PROFILE_FRAME_BOUNDARY(); RW_PROFILE_FRAME_BOUNDARY();
RW_PROFILE_SCOPE("Main Loop");
running = updateInput(); running = updateInput();
@ -405,7 +406,7 @@ int RWGame::run() {
} }
float RWGame::tickWorld(const float deltaTime, float accumulatedTime) { float RWGame::tickWorld(const float deltaTime, float accumulatedTime) {
RW_PROFILE_SCOPE(__func__); RW_PROFILE_SCOPEC(__func__, MP_GREEN);
auto deltaTimeWithTimeScale = auto deltaTimeWithTimeScale =
deltaTime * world->state->basic.timeScale; deltaTime * world->state->basic.timeScale;
@ -414,8 +415,11 @@ float RWGame::tickWorld(const float deltaTime, float accumulatedTime) {
break; break;
} }
{
RW_PROFILE_SCOPEC("stepSimulation", MP_DARKORANGE1);
world->dynamicsWorld->stepSimulation( world->dynamicsWorld->stepSimulation(
deltaTimeWithTimeScale, kMaxPhysicsSubSteps, deltaTime); deltaTimeWithTimeScale, kMaxPhysicsSubSteps, deltaTime);
}
StateManager::get().tick(deltaTimeWithTimeScale); StateManager::get().tick(deltaTimeWithTimeScale);
@ -521,22 +525,7 @@ void RWGame::tick(float dt) {
} }
} }
world->updateEffects(); tickObjects(dt);
for (auto& object : world->allObjects) {
object->_updateLastTransform();
object->tick(dt);
}
for (auto& g : world->garages) {
g->tick(dt);
}
for (auto& p : world->payphones) {
p->tick(dt);
}
world->destroyQueuedObjects();
state.text.tick(dt); state.text.tick(dt);
@ -564,8 +553,38 @@ void RWGame::tick(float dt) {
} }
} }
void RWGame::tickObjects(float dt) const {
RW_PROFILE_SCOPEC(__func__, MP_MAGENTA1);
world->updateEffects();
{
RW_PROFILE_SCOPEC("allObjects", MP_HOTPINK1);
RW_PROFILE_COUNTER_SET("tickObjects/allObjects", world->allObjects.size());
for (auto &object : world->allObjects) {
object->_updateLastTransform();
object->tick(dt);
}
}
{
RW_PROFILE_SCOPEC("garages", MP_HOTPINK2);
for (auto &g : world->garages) {
g->tick(dt);
}
}
{
RW_PROFILE_SCOPEC("payphones", MP_HOTPINK3);
for (auto &p : world->payphones) {
p->tick(dt);
}
}
world->destroyQueuedObjects();
}
void RWGame::render(float alpha, float time) { void RWGame::render(float alpha, float time) {
RW_PROFILE_SCOPE(__func__); RW_PROFILE_SCOPEC(__func__, MP_CORNFLOWERBLUE);
lastDraws = getRenderer().getRenderer()->getDrawCount(); lastDraws = getRenderer().getRenderer()->getDrawCount();

View File

@ -137,6 +137,8 @@ private:
float tickWorld(const float deltaTime, float accumulatedTime); float tickWorld(const float deltaTime, float accumulatedTime);
void renderDebugView(float time, ViewCamera &viewCam); void renderDebugView(float time, ViewCamera &viewCam);
void tickObjects(float dt) const;
}; };
#endif #endif