Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Immediate Mode Versus Vertex Array Performance Confusion  (Read 1056 times)
0 Members and 1 Guest are viewing this topic.
Offline Vladiedoo
« Posted 2013-02-26 05:46:02 »

Hi, I'm trying to advance my OpenGL knowledge past immediate mode. From Riven's (thanks Riven) tutorial I was able to get a vertex array rendering properly but I was not able to see an increase in performance.
Here is how I tested it, if this is the wrong approach to bench-marking please inform me.

To test the performance of immediate mode and vertex arrays I drew a quad repeated, in this test it was 88573 quads. When I one big vertex array hold all 88573 quads it got close to the performance of immediate mode but not quite there.
Pastebin: http://pastebin.java-gaming.org/3dddd044049 (It's messy)

Here is sample console output:
(I should have labeled these). The first columns is individual vertex arrays, the second columns is immediate mode, and the third columns is one big vertex array.
1  
2  
3  
4  
5  
67900774   13660101   15001607   n: 88573
371488407   14153266   19133484   n: 88573
116280710   13882860   14012185   n: 88573
68273896   13738066   15345957   n: 88573
71455953   15008723   12876111   n: 88573


Q1: Could someone please explain why this occurred?
Q2: Does it matter how I render (immediate, vertex array, VBO) when I decide to fully use shaders?


Sorry, these questions must have been asked a lot, thank you for your time.

EDIT: This was done in 3D if that makes a significant difference.
Offline StumpyStrust
« Reply #1 - Posted 2013-02-26 06:58:00 »

You will probably get a guy that goes by something agent  Wink that will inevitably clear all things up but I will take a whack at it.

What you are trying to do is basically render as many sprites (textured quads) as possible. When doing this with VBO and VA, it is better to batch them in groups of 1500-3000 sprites then one giant VBO/VA that holds all 88573. Also, it is better to use triangle strips to form the quads then actual quads. Little faster. It is generally not a good idea to recreate your buffers every render which can slow thins down alot.

I think something must be off here as VA should vastly out perform fixed function (immediate mode). I made a sprite batcher tut on here which uses very simple VA that you could try as I know that works. Also, davedes as some great tutorials on modern opengl along with a sprite batcher tutorial which is the main thing you need for 2d games. Once you get a VBO sprite batcher going look into rivens post about a blazingly fast method for sprite batching.

As for when you use shaders, you can do it with all of them but it is better to not use depreciated methods i.e fixed-function/vertex array.

I hope this helped.

Offline princec

JGO Kernel


Medals: 363
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2013-02-26 09:38:46 »

Microbenchmarking will never give you useful results really.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #3 - Posted 2013-02-26 11:36:17 »

You're benchmark is flawed in so many ways that the numbers don't mean anything.

1. Microbencharking, like Cas said. Plus, OpenGL doesn't execute commands right when you call them. It queues them up and then periodically (or when the queue's full) sends them off to the GPU. That means that the command that causes the queue to become full is the one that'll take time, which will most likely not be the one that actually takes time to execute.

2. You're not using vertex arrays in a very good way, and you'd probably benefit a lot from using VBOs instead. First of all, the whole point of vertex arrays is the ability to batch up geometry data so you can render them with fewer OpenGL commands. The way you're using them now, you're barely gaining anything since you're not using less calls, hence your first vertex array method is slower than immediate mode. Your batched version is almost as fast as immediate mode but it's not very efficient. You should at least reuse the FloatBuffers between frames, not create new ones every time. If the data doesn't change between frames, just fill the FloatBuffers once and reuse the same data too. As mentioned, if you want even better performance, take a look at VBOs.

3. This is kind of hypothetical, but how big are those quads? If each quad is 100x100 pixels on the screen, one quad would cover 10 000 pixels. 88 573 quads would therefore cover 885 730 000 pixels each frame, or 53 143 800 000 pixels per second at 60 FPS, which obviously might be a bottleneck. How you send the coordinates doesn't affect how the pixels are filled, so if you hit a bottleneck there you won't see much of an improvement no matter what you do.

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (23 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (28 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (27 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!