• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
RobMaddison

Rendering more gives higher FPS

6 posts in this topic

The way I currently draw text in my engine (for stats, etc) is to draw a screen-aligned 2-triangle quad poly per line. I have a 256x12 texture which has my characters laid out in a grid format. My text shader takes as input a string of ASCII numbers (an int array currently) and per pixel, calculates which character in the string it's on and then calculates the correct pixel to take from the font texture. All works beautifully, or so I thought...

My current test scene is very simple, I've only got a ground quad for this test with a simple diffuse shader but the view direction has the ground quad covering most of the screen.

If I draw one line of text I get 160 FPS, but if I add another line of text, I get 260 FPS. I know FPS isn't linear in relation to frame time, but this is a massive difference. If I add more lines of text (e.g. more drawindexedprimitive calls) it gradually comes down again but only by a small fraction (like 1 FPS or thereabouts). If I move my camera up so the ground quad isn't covering most of the screen my FPS goes up beyond 1700 FPS as expected.

I am literally only rendering 2 things and My FPS calc is very simple so I doubt that would be why. In my render loop (based on Gaffer's fix your timestep) I increase my rendered frames count and then just divide that by the game time. It's an average over the whole game time which perhaps isn't quite as accurate as one that counts frames on a second by second basis, but when I start the app each time, the FPS is immediately low or high (depending on how many lines of text I draw).

Would this have anything to do with context switching on the GPU? Normally I wouldn't bother myself with profiling at this stage but, the fact that the FPS went up when it should have gone down and because of the amount, is very confusing.

Incidentally, if I fill my screen with animated models and other meshes, the FPS goes down as expected so it's almost certainly not that. My render loop is pretty solid as far as I can see, all my animations play in perfect time and my physics stepping works correctly too.

Any thoughts? (I'm using DX9 with c++ by the way).

By the way, my text renderer will eventually render multiple lines of text in one quad rather than a quad per line - I just did it with one line to do a proof of concept.
0

Share this post


Link to post
Share on other sites

are you rendering the text first and then the ground quad? does the text output depth? what is your platform? some mobile powerVR?

can you try to render at a much smaller resolution, if this is reproduceable? 

 

I suspect your ground quad might be very slow and covering the pixel speeds rendering up, maybe no mipmap in your texture? 

 

screenshot ;)

1

Share this post


Link to post
Share on other sites

are you rendering the text first and then the ground quad? does the text output depth? what is your platform? some mobile powerVR?
can you try to render at a much smaller resolution, if this is reproduceable?

I suspect your ground quad might be very slow and covering the pixel speeds rendering up, maybe no mipmap in your texture?

screenshot ;)


Thanks Krypt0n. The ground quad is definitely rendered first and I am rendering depth with the text - that's not something I had considered.

It's currently running on my laptop machine on Windows 7, Intel i7 2.2GHz, nVidia GTX560M (1.5GB).

I can try at a smaller resolution when I get home later (it's precisely reproducable). I'm pretty sure the ground texture has mipmaps, but I'll check that later too - all great tips, thanks.
0

Share this post


Link to post
Share on other sites
I've tried this at different resolutions, FPS is still much higher (with 2+ lines of text). I've tried switching off depth output on the font shader (zen able=false) and it made no difference, although it also makes no difference whether the ground object is rendered or not or, if it is, whether the ground is beneath the text not. I also noted that the ground texture had mipmaps.

This is very confusing. My render loop does something like this:

[source]
while (true)
{
// usual fixing time step stuff (world updates, etc)
...
renderTime = timer->Stop();
renderingEngine->RenderFrame(renderComponentQueue);
renderTime = timer->Stop() - renderTime;
renderedFrames++;
}
[/source]

A lot of code has obviously been removed for brevity but the point I wanted to make was that the renderTime timer actually takes a lot longer inside the RenderFrame(...) method if there is only one text object being rendered than it does if there are 2+. By a lot longer I mean having just one text line takes 2-6ms (obviously wrong), but 2 or more makes it around 0.3ms (much more like it).

It's worth noting that at the moment, each of the two lines of text use their own instance of a font shader rather than just one shared shader. This is currently just because I haven't got round to changing it yet. That being said, I'd have thought the RenderFrame method would take even longer again with 2+ objects as it has to swap shader..

Any more ideas guys? Edited by RobMaddison
0

Share this post


Link to post
Share on other sites

I've tried this at different resolutions, FPS is still much higher

is it still 160 vs 260 fps? half resolution is way faster, I would expect it's not related to context switching.

 

how does your timer work? is it some highly accurate timer or something like gettickcount?

 

I would suggest to not take the render time around 'renderframe', but start the time at frame 0, stop it at frame 100, divide 100 by the seconds you got.

I don't know what else you're doing beside 'renderframe', but there is a chance your drawcalls have not even be send out to the gpu when this function returns and in that case, while the actual rendering is going on, you are doing 'world update' etc. 

it's quite common that driver queue up to 5 frame, so to really get the average fps, you need to measure across several frames.

 

 

if some results are fishy, it's common the measurement is buggy :), so no offense, but that's something to verify.

1

Share this post


Link to post
Share on other sites

is it still 160 vs 260 fps? half resolution is way faster, I would expect it's not related to context switching.


No, but the difference is roughly the same.

The timer is the normal queryperformancecounter.

I've tried it over several frames, doing an overall FPS, an FPS each second and over 5 and 10 seconds. It's still the same.

It's interesting that you pointed out that the GPU will queue calls. If this was the case, wouldn't rendering 2 text lines be slower than rendering one?
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0