Less Draw Calls the Better?
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?
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?
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?
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.
I wouldn't say it's normal, but it is widespread for sure.
[quote name='ILoveJesus' timestamp='1315974604' post='4861386']The performance improved, but my code looks sloppier and more confusing as a result. Is this normal?
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?
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
L. Spiro
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?
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?
[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?
[/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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement