• Advertisement
Sign in to follow this  

Less Draw Calls the Better?

This topic is 2354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently learning Directx 11 in VC++. I am new to game programming and have been working on a font system which is going well. Basically, I noticed that every draw call my FPS drops considerably. I was originally calling Draw for every string I put on the screen. I decided to map multiple strings and have it go through one draw call. The performance improved, but my code looks sloppier and more confusing as a result. Is this normal? Does shooting for efficiency leave more complicated code? I am coding only in 2d and that is what my game will be, but nonetheless should I be spending so much time on figuring out ways on calling draw less?

Share this post


Link to post
Share on other sites
Advertisement
The performance improved, but my code looks sloppier and more confusing as a result. Is this normal?
I wouldn't say it's normal, but it is widespread for sure.
Problem is, many optimizations are based on exploiting some properties which hold true across multiple objects, so there must be some kind of "merging". The key is to spend more effort in designing the system so instead of having a big ball of yarn, you have clearly separated subsystems, each with a task and more-or-less well defined bounduaries. Those systems collaborate in producing the result. How many systems do you need? Each system must be just as big as you can manage (but hopefully less and much less if it makes sense).

In general, less draw calls --> better. No way around this. It has been like that for years and I think it's highly unlikely to change in the next years.
Keep in mind that if you find this difficult (with a single material around) you might have to iterate on the other systems a bit to get a better picture, then come back.


I am coding only in 2d and that is what my game will be, but nonetheless should I be spending so much time on figuring out ways on calling draw less?[/quote]Probably not. Your first objective is to get a "more or less complete" proof of concept of the whole system. Then, iterate. Going for a waterfall-like development, where each subsystem is developed and tuned in sequence is borderline dangerous. Even if you have extensive experience, the chance to get screwed in the details is fairly high for every non-trivial system.


BTW, I hardly believe you're already pushing your system to the limits... Unless you have a Pentium3 800 Mhz with a GeForce 2 MX... but then you wouldn't be using D3D11.
So you have text. Good. Now what?

Share this post


Link to post
Share on other sites

I am currently learning Directx 11 in VC++. I am new to game programming and have been working on a font system which is going well. Basically, I noticed that every draw call my FPS drops considerably. I was originally calling Draw for every string I put on the screen. I decided to map multiple strings and have it go through one draw call. The performance improved, but my code looks sloppier and more confusing as a result. Is this normal? Does shooting for efficiency leave more complicated code? I am coding only in 2d and that is what my game will be, but nonetheless should I be spending so much time on figuring out ways on calling draw less?

“Batch, Batch, Batch:” What Does It Really Mean?

Share this post


Link to post
Share on other sites

I am currently learning Directx 11 in VC++. I am new to game programming and have been working on a font system which is going well. Basically, I noticed that every draw call my FPS drops considerably. I was originally calling Draw for every string I put on the screen. I decided to map multiple strings and have it go through one draw call. The performance improved, but my code looks sloppier and more confusing as a result. Is this normal? Does shooting for efficiency leave more complicated code? I am coding only in 2d and that is what my game will be, but nonetheless should I be spending so much time on figuring out ways on calling draw less?

How big is your FPS to begin with? And how much does it drop? And how much draw calls are you doing?

I cannot imagine a situation in game, where you would draw so much text, that the number of render calls can make any real difference.

In general, yes, it is good idea to make less draw calls but you should determine by profiling semi-complete release build whether or not any given subsystem is worth optimizing.

Share this post


Link to post
Share on other sites

[quote name='ILoveJesus' timestamp='1315974604' post='4861386']The performance improved, but my code looks sloppier and more confusing as a result. Is this normal?
I wouldn't say it's normal, but it is widespread for sure.
Problem is, many optimizations are based on exploiting some properties which hold true across multiple objects, so there must be some kind of "merging". The key is to spend more effort in designing the system so instead of having a big ball of yarn, you have clearly separated subsystems, each with a task and more-or-less well defined bounduaries. Those systems collaborate in producing the result. How many systems do you need? Each system must be just as big as you can manage (but hopefully less and much less if it makes sense).

In general, less draw calls --> better. No way around this. It has been like that for years and I think it's highly unlikely to change in the next years.
Keep in mind that if you find this difficult (with a single material around) you might have to iterate on the other systems a bit to get a better picture, then come back.


I am coding only in 2d and that is what my game will be, but nonetheless should I be spending so much time on figuring out ways on calling draw less?[/quote]Probably not. Your first objective is to get a "more or less complete" proof of concept of the whole system. Then, iterate. Going for a waterfall-like development, where each subsystem is developed and tuned in sequence is borderline dangerous. Even if you have extensive experience, the chance to get screwed in the details is fairly high for every non-trivial system.


BTW, I hardly believe you're already pushing your system to the limits... Unless you have a Pentium3 800 Mhz with a GeForce 2 MX... but then you wouldn't be using D3D11.
So you have text. Good. Now what?
[/quote]

The game I had in mind would be quite simple. It would be an arena based 2D RPG game. The most I could see happening on the screen is the battle screen where I draw a background during combat, a sprite for the enemy monster(planning on having only one per battle) which has an animation. Possible hit animations for different attacks. Player would be invis. Sprites for text boxes and menu system. Problem is I am new to this and I don't know how I could go about let's say, drawing several different text boxes of different sizes on the screen in one draw call? Can I do that? Can I draw several different vertex buffers in one draw call? IS that allowed? Can I map sprites with different colormaps in the same vertex buffer? If I can how? Something I really want to know. Can I have several mapped vertex buffers in one draw call?

Share this post


Link to post
Share on other sites
To be honest, with your few requirements, I suggest you skip the complications of batch rendering. Even an iPhone can handle what you intend to draw, and at your stage in self-development it is more important to focus on game logic than to be anal about these kinds of optimizations. You can focus on them later.


L. Spiro

Share this post


Link to post
Share on other sites
I took a good hard look at my draw function for fonts and found a ton of overhead. There was unnecessary function calls done 100s of times in a loop. I got back about 1000 FPS, literally, by storing these values in default variables before the loops begin. I thought the draw call itself was the culprit, nope, it is just the amateur me. I still have yet to figure out a better way to go through a kerning list efficiently. Right now I go through each 300+ lines of a kerning list for each letter drawn. I am sure that is a ton of overhead, but I do not know how to do it any different. Any suggestions?

Share this post


Link to post
Share on other sites

I am currently learning Directx 11 in VC++. I am new to game programming and have been working on a font system which is going well.

Why not just use DirectWrite? :huh:

Share this post


Link to post
Share on other sites

[quote name='ILoveJesus' timestamp='1315974604' post='4861386']
I am currently learning Directx 11 in VC++. I am new to game programming and have been working on a font system which is going well.

Why not just use DirectWrite? :huh:
[/quote]

The book I am learning from makes it clear that Directx 11 does not offer a built in solution for rendering text and must be done manually. If it lied to me I would be quite upset. I spent days getting these fonts up and running.

Share this post


Link to post
Share on other sites
Why not just use DirectWrite?
Very interesting question. Have you tried it? As I already have interanational text running, I am in the position of being unable to run extensive tests "just for checks". Mind sharing some experience on that?
For the time being, I can only recall the main reason I didn't use it in the first place: steep OS requirements and the (not quite sure about that) apparent inability to deal with "3D" text.

Share this post


Link to post
Share on other sites

The book I am learning from makes it clear that Directx 11 does not offer a built in solution for rendering text and must be done manually. If it lied to me I would be quite upset. I spent days getting these fonts up and running.

I believe this was discussed here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement