• 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
robolee

Drastic performance loss

7 posts in this topic

When using immediate mode drawing I get roughly 500 fps (60 rendered frames per second so roughly 9 frames of logic per rendered frame), when changing absolutely nothing other than changing to vertex array and glDrawArrays, I drop down to roughly 120fps.

http://i.imgur.com/ToaW9Ur.png (linked because it's a pretty big image, also "frames displayed last second" is a mistake, it's not the displayed frames any more -used to be- it's the number of logic loops, actual rendered fps is a solid 60)

 

The reason I tried vertex arrays was because I thought it was supposed to be faster than immediate mode (single operation stream instead of multiple). Am I doing something drastically wrong?

 

Would vertex buffer objects be faster? How would I implement that in the current code?

 

Note: I don't show any other code because they are otherwise identical, and I made sure of that.

0

Share this post


Link to post
Share on other sites

are you doing an optimized build ?

 

You are creating new arrays on the stack on each function call (create them outside the function and pass them by reference)

 

It is also a good idea to move the clientstate calls outside the function, enabling and disabling things isn't free and you seem to be doing so for each tile you draw (even though all tiles seem to have vertex array and texture_coord array enabled)

 

if you are drawing rectangles only you can use a fixed square vertex array and only re-bind the texture coordinate array for each tile to further speed things up. (you can change the shape and size of the rectangle  by scaling it)

Edited by SimonForsman
1

Share this post


Link to post
Share on other sites

Ah yes, taking out the Enable/disable, should have thought of that, however it made little if no difference at all.

 

And the builds are exactly the same, same compiler settings, same code except for that draw code.

 

The array thing can't be avoided to an extent, the tiles are called from the same texture but with differing sub-bitmap positions, and are not pre-set, so regardless that array will have to be set to differing values every tile, unless I set hundreds of bytes of data aside... Which I'd rather not do when immediate mode is so much faster, at around 300fps when I put the array creation into it for no reason at all other than to see how much it would bog it down. And the draw code is generic, not just for drawing tilemaps, any further optimization to that regard set-multi-array grids, would make it less useful for freely positioned sprites.

 

Seeing as how immediate mode is so much faster and making this work with optimized array creation etc. would take more work than it's worth I think it would be pointless.

 

So is there a better way of doing it? A more OpenGL ES way? FBOs (I'm too tired to look into that right now)

0

Share this post


Link to post
Share on other sites
The reason I tried vertex arrays was because I thought it was supposed to be faster than immediate mode (single operation stream instead of multiple). Am I doing something drastically wrong?

Vertex arrays and buffers work well for small (and a quad is very small in this meaning) vertex count per object if and only if objects are batched. When not batching, many  small draw calls are executed, so the cost-benefit ratio is high and the overhead per draw call is killing your performance. The "immediate" in "immediate mode" is nowadays just a relict. In fact, the driver does batching internally, and you never really know when rendering actually happens.

 

The array thing can't be avoided to an extent, the tiles are called from the same texture but with differing sub-bitmap positions, and are not pre-set, so regardless that array will have to be set to differing values every tile, unless I set hundreds of bytes of data aside...

The usual way is to allocate arrays big enough to hold a couple of, say, some hundreds sprites, invoke a rendering routine that actually batches by writing the quads to the arrays, and cause an OpenGL level draw call only if either the arrays are full, the scene is finished, or alternative settings (texture, blending, shader, …) enforce a draw call.

 

… Which I'd rather not do when immediate mode is so much faster, at around 300fps when I put the array creation into it for no reason at all other than to see how much it would bog it down.

The reason to get rid of immediate mode, as well as the matrix stack and some other stuff, if possible is because it is deprecated. 

Edited by haegarr
0

Share this post


Link to post
Share on other sites

I guess that integer image coordinates are not supported by GPU and they are convertex to floats on the way

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