Trying to figure out FPS


I’m trying to figure out what’s killing my FPS. I have a I7-2700k CPU, 16 gig ram, EVGA GTX 950 ti, 128 GB ssd, and huge HD. I’m not sure why the framerate isn’t about 60 fps.

Test Video


I’m using these base code for this scene. I disabled all rigidbody and collisions since this is pretty much pre-defined.



void MainMenuView::CreateManualScene(void)
// Update Renderer
AnimationManager * pAnimationManager = g_pApp->GetGameLogic()->GetAnimationsManager();

// Update renderer setting decrease rendering quality and increase frame rate

// Update scene
m_pScene = SharedPtr<Scene>(new Scene(context_));

// Reset Scene for Applications Manager

// Add octree

// Load a demo file
LevelManager* pLevelManager = g_pApp->GetGameLogic()->GetLevelManager();
pLevelManager->LoadLevel(m_pScene, "Levels/LoginScene1.xml", false);

// Create a temporary Vector
PODVector<CameraComponent *> Cameras;

// Get scene camera components
m_pScene->GetComponents(Cameras, "CameraComponent");

// Create a iternator
PODVector<CameraComponent *>::Iterator thisComponent;

// Loop through each component
for(thisComponent = Cameras.Begin(); thisComponent!=Cameras.End(); ++thisComponent)
    if((*thisComponent)->GetDefault() == true)
        // Get the Camera Component Node
        m_pCameraNode = (*thisComponent)->GetNode();

        // Set new Viewport using CameraComponent
        m_pViewport = new Viewport(context_, m_pScene, m_pCameraNode->GetComponent<CameraComponent>());


// If Camera Node is not Null then there must have been a default camera
    // Create a scene node for the camera, which we will move around
    // The camera will use default settings (1000 far clip distance, 45 degrees FOV, set aspect ratio automatically)
    m_pCameraNode = m_pScene->CreateChild(String("Camera").ToHash(), CreateMode::LOCAL);

    // Set Position

    // Test Look at

    // Set new Viewport using Camera
    m_pViewport = new Viewport(context_, m_pScene, m_pCameraNode->GetComponent<Camera>());


// Set Viewport
m_pRenderer->SetViewport(0, m_pViewport);

SharedPtr<RenderPath> m_pFXRenderPath= m_pViewport->GetRenderPath()->Clone();


// Make the bloom mixing parameter more pronounced
m_pFXRenderPath->SetShaderParameter("BloomMix", Vector2(0.98f, 0.02f));
m_pFXRenderPath->SetEnabled("Bloom", true);
m_pFXRenderPath->SetEnabled("FXAA3", true);

// Set active path

// Create a temporary Vector
PODVector<AnimationControllerComponent *> AnimationControllers;

// Get scene AnimationController components
m_pScene->GetComponents(AnimationControllers, "AnimationControllerComponent");

// Create a iternator
PODVector<AnimationControllerComponent *>::Iterator thisControllerComponent;

// Loop through each component
for(thisControllerComponent = AnimationControllers.Begin(); thisControllerComponent!=AnimationControllers.End(); ++thisControllerComponent)



Present = 850 ms (try without imgui interface)

At least add additional profiling to imgui to get a better idea of what impact it’s making. However I will agree that it is the most likely culprit.

At least add additional profiling to imgui to get a better idea of what impact it’s making. However I will agree that it is the most likely culprit.[/quote]

Maybe. Itook out the ImGui base elements which did not help much Now I’m looking at this. I might remove firstly the get screen size every frame which is overkill. The Update Scene and Physics part average around 60, just everything else isn’t.

[code]void ImGuiInterface::HandleBeginFrame(StringHash eventType, VariantMap& eventData)
using namespace BeginFrame;
float timeStep = eventData[P_TIMESTEP].GetFloat();

// Setup display size (every frame to accommodate for window resizing)
ImGuiIO& io = ImGui::GetIO();
io.DisplaySize = ImVec2((float)graphics_->GetWidth(), (float)graphics_->GetHeight());

// Setup time step
io.DeltaTime = timeStep > 0.0f ? timeStep : 1.0f / 60.0f;

// Setup inputs
// mouse input handling
if (input_->IsMouseVisible() && !input_->GetTouchEmulation())
    IntVector2 pos = input_->GetMousePosition();
    // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
    io.MousePos.x = (float)pos.x_;
    io.MousePos.y = (float)pos.y_;
    io.MousePos.x = -1.0f;
    io.MousePos.y = -1.0f;
// TODO: Joystick input handling

// TODO: touch input handling
if (touchId_ != -1)
    io.MousePos.x = (float)touchPos_.x_;
    io.MousePos.y = (float)touchPos_.y_;
    io.MouseDown[0] = touch_;
    // disable tracking
    if (!touch_)
        touchId_ = -1;
    io.MouseDown[0] = input_->GetMouseButtonDown(MOUSEB_LEFT);

io.MouseDown[1] = input_->GetMouseButtonDown(MOUSEB_RIGHT);
io.MouseDown[2] = input_->GetMouseButtonDown(MOUSEB_MIDDLE);
io.MouseWheel = (float)input_->GetMouseMoveWheel();

io.KeyCtrl = input_->GetQualifierDown(QUAL_CTRL);
io.KeyShift = input_->GetQualifierDown(QUAL_SHIFT);
io.KeyAlt = input_->GetQualifierDown(QUAL_ALT);

// Start the frame

// show screenkeyboard on text edit
if (useScreenKeyboard_)


void ImGuiInterface::HandleEndRendering(StringHash eventType, VariantMap& eventData)

That should work. What does it say now when you run the game?

Roughly the same numbers.

You need to look all the functions that are used in E_ENDRENDERING

A large amount of time spent in Present can simply mean that the GPU has a lot of work to do. You seem to be doing at least several shadowed lights and postprocesses. Have you tried disabling these? (note that the profiler entries under Render but before Present don’t accurately represent GPU work, it’s just the CPU time taken to submit those render commands). Also, do you have Vsync on? If yes, disable it to see your actual framerate, otherwise it’s always 60 divided by something. Vsync waiting goes under Present in the profiler.

I took everyone advice. ImGui wasn’t the problem but I should optimize that code. The main culprit is the light, shadows, and the VSync.

I got the FPS up from 22/30 to 54 with everything put back. The rest is optimizing the scene.

I was able to pull this off and the video is a bit smoother compared to the original.

Ironically, the ground map works better and I get the full 200 fps.