Jump to content
TonyF

C++ Lagging

Recommended Posts

Hi,

 

I have started a c++ project and am using the zombie DLC as an initial placeholder.

 

I have noticed that i can load in a maximum of about 5 zombie models (no animations or scripts running) and then the framerate goes down for every additional zombie i add to a max of 10.

 

If i put the default prefab zombie into the map then i can put 10 in without lag.

 

I have tried both debug and release modes.

Oddly when i add in extra models and my framerate goes down so does my GPU usage which i have no idea why (Goes from 10% to more or less nothing / CPU sits on about 12%).

 

I do suppress GL_Invalid_Operation as that prevents debug mode in both lua only and C++ debug modes.

 

Any ideas why i am getting such poor performance?

 

I have also tried publishing the game and running it on a separate computer and the performance was identical. The other PC was NVIDIA and this one is AMD.

Share this post


Link to post

What processor do you have? If you have an eight-core, then you are maxing it out (and who knows, there might be other limits imposed by the OS to limit your program's CPU usage). Your GPU usage probably goes down because of this since it's waiting for the CPU to catch up.

 

Anyway, what does your map (if you have one) and code look like?

Share this post


Link to post

I have a quad core i7 with hyperthreading enabled (8 cores).

 

My map is a square base with a texture on it and a couple stock cubes. (I have also used the default 'start' map).

 

I am currently doing a test with 10 zombies. The framerate has gone down to 10fps and camera movement is laggy.

 

In regards to the CPU, the game process is running at 8% CPU capacity and the total CPU usage is 12%. There is also no single core that is remotely maxing out.

 

Maybe i am running animations incorrectly? I just did an ultra simplified test using the default C++ project and a single ground floor cube.

 

In the startup function i have

Vec3 Pos = Vec3(0,0,0);

for (int i = 0; i < 10; i++) {

entity = Prefab::Load("Prefabs/Enemy/zombie1.pfb");

Pos.x += 1;

entity->SetPosition(Pos);

}

 

And in the main loop i have

 

float t = Time::GetCurrent() * 0.02;

for (int i = 0; i < 10; i++) {

entity->SetAnimationFrame(t, 1.0, 2, true);

}

 

This will give me an FPS of 50 and release mode then subsequent models will drop it lower.

 

I also just did a test of commenting the above out and using the zombie prefab which uses the lua script and i get about 35fps on release mode.

 

I am coming to a bit of a loss as to whats going on or what i can try.

Share this post


Link to post

What happens if you just load the models not the prefabs? Just trying to see if it's the prefab causing issue or the script. Just play around with different combinations of things.

Share this post


Link to post

Thanks for the replies guys.

 

I tried this 'Model* ent = Prefab::Load("Prefabs/Enemy/zombie1.pfb");' Although Prefab::Load returns an entity.

 

10 Zombies loaded the way i initially had is about 43 fps.

If i load a single prefab entity and then call ->Instance() as suggested i get 15 fps

If i load a single prefab entity and then call ->Copy() as suggested i get 15 fps AND i dont see the models ??

If i load the model (Not the prefab) and then call ->Instance() i get 43 fps

If i load the model (Not the prefab) and then call ->Copy() i get 39 fps AND i dont see the models ??

 

Out of the above options loading the Prefab each time (is more efficient that instancing) or loading the model and then instancing it gives identical performance (which is interesting in my case).

Share this post


Link to post

Each time you load the prefab, are the textures and materials loaded as well, or are they only loaded once during the load of the first prefab? I would guess they're only loaded once and then just referred to for each prefab, but if they're not, that would impair performance somewhat.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...