Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Limitations on size of VBOs?  (Read 1830 times)
0 Members and 1 Guest are viewing this topic.
Offline StrideColossus
« Posted 2013-11-18 18:47:20 »

I've been playing around with my terrain rendering code recently and come across some odd behaviour.

Quick summary: application loads a gray-scale image, generates a mesh, uploads to a VBO, renders with multiple textures to blend grass, rock, snow, etc.  Nothing amazingly complex and it's been working solid for quite some time.  Recently I've been extending the code to handle multiple terrain 'chunks' and dynamically loading/trashing as the camera moves.  Again it's all working nicely (or at least seems to be).

Now I've downloaded some massive grey-scale images (of parts of Italy cos went there recently) which will be cut up into smaller chunks, but I thought I'd test the software with a much larger image just to see how well it coped (or not).  Normally the chunks are 256x256 sized, the image I tried was 2100x2100 pixels.  The software took some time to load and process this as you can imagine, and at the end I got - nothing.

Debugged the code but it seemed to be working correctly.  So I bodged the terrain generator so that it did 500x500 (i.e. the top-left part) and it worked fine, ditto 1000x1000, ditto 1500x1500, but the full image still fails!  No errors, just nothing being rendered.  The frame-rate indicates that it's basically rendering nothing.  Very odd.

Is there some limit on the size of NIO buffers and/or VBOs?  Or has anyone come across similar behaviour?  By my calculations the 2100x2100 should be about 70Mb worth of vertex data.

Note that the same terrain image broken down into the normal 256x256 chunks with multiple VBOs also works fine.  Obviously this isn't a big deal as the 'proper' chunked solution works, but I'm just surprised that the big image failed but without any errors.

Any suggestions?

Cheers

- stride
Offline trollwarrior1
« Reply #1 - Posted 2013-11-18 18:50:48 »

Just try it Cheesy
Offline HeroesGraveDev

JGO Kernel


Medals: 212
Projects: 11
Exp: 2 years


If it wasn't Awesome, it wasn't me.


« Reply #2 - Posted 2013-11-18 19:54:19 »

When you call glDrawArrays or whatever, make sure the vertex count isn't negative.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wessles

JGO Ninja


Medals: 49
Projects: 4
Exp: 3 years


Coding with bad posture since 2011... Nonstop.


« Reply #3 - Posted 2013-11-18 22:24:59 »

I usually just find the amount of vertices that are about to be drawn, and if they go over, say, 1000, then I render all of the points, clear the Vertices, and add the extra vertices that caused the restart. That way you do not go too high on the buffers.

When my Buffers get too big, I get some kind of Core dump on java, meaning you did not just throw an error, you broke java (still works, but the buffers need to be smaller). So do not screw around with buffers...
I did not know that it was just my code, panicked (reinstalled java, then linux login, then OS), and ended up screwing with my OS, and wiping my computer drive, losing all of my work. (See MERCury thread.) Major failure, all because I overloaded my Buffers.

You don't know nerdiness yet; you haven't even met me!
www.wessles.com
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #4 - Posted 2013-11-18 23:27:30 »

I feel like something is wrong with your drivers. You should be able to render millions of vertices without Java running out of memory. That's odd!

Offline wessles

JGO Ninja


Medals: 49
Projects: 4
Exp: 3 years


Coding with bad posture since 2011... Nonstop.


« Reply #5 - Posted 2013-11-18 23:36:34 »

Yes, but you can overflow buffers, no?

You don't know nerdiness yet; you haven't even met me!
www.wessles.com
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #6 - Posted 2013-11-19 00:30:57 »

Well, of course you can. But I think the limit would be higher than 1000 vertices. That's really odd.

Offline wessles

JGO Ninja


Medals: 49
Projects: 4
Exp: 3 years


Coding with bad posture since 2011... Nonstop.


« Reply #7 - Posted 2013-11-19 00:35:58 »

When I set it higher it gets laggy.
Probably  just my CPU though (on a notebook here)

You don't know nerdiness yet; you haven't even met me!
www.wessles.com
Offline StumpyStrust
« Reply #8 - Posted 2013-11-19 00:53:00 »

GL12.GL_MAX_ELEMENTS_VERTICES

Even on my integrated chip this give over 60k.

Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #9 - Posted 2013-11-19 01:04:45 »

Well vertex arrays are CPU centered. If you need to process large amounts of static data, use a VBO as they are stored on the GPU.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wessles

JGO Ninja


Medals: 49
Projects: 4
Exp: 3 years


Coding with bad posture since 2011... Nonstop.


« Reply #10 - Posted 2013-11-19 01:07:52 »

Yeah, I was using Vertex Array Objects. A little slower, but if you can get 60K, then I must have done something  wrong.

So I did a little stress test, and made mine 50K. It did well, so I geuss I made a problem, fixed it, then fixed the core solution, and went back testing it now? Whatever. I remember testing VAO, and over 1000 lagged it up a bit. But now it works. No idea how, but it worked Smiley.

You don't know nerdiness yet; you haven't even met me!
www.wessles.com
Offline StrideColossus
« Reply #11 - Posted 2013-11-19 01:19:12 »

Hmmm done some more tests after the various feedback but still no clearer.

When you call glDrawArrays or whatever, make sure the vertex count isn't negative.

No definitely has the the correct (and positive) number of vertices in the index buffer.

I though HeroesGraveDev might have been on to something, maybe I was exceeding some maximum number size or something (the size of the index buffer is an integer) but no it's not even close.

Will do some more tests tomorrow to see if I can work out what the 'threshold' is where it stops working.

Very odd.
Offline gouessej

« In padded room »



TUER


« Reply #12 - Posted 2013-11-19 10:33:47 »

Hi

GL_MAX_ELEMENTS_VERTICES

Even on my integrated chip this give over 60k.
This value is sometimes completely wrong and is no longer supported in OpenGL-ES. Use it with care.

I feel like something is wrong with your drivers. You should be able to render millions of vertices without Java running out of memory. That's odd!
Well vertex arrays are CPU centered. If you need to process large amounts of static data, use a VBO as they are stored on the GPU.
If you still use CPU sourced data, you have to create a direct NIO buffer and you can run out of memory on the native heap. Anyway, you have to pass the data to the GPU data store even though you use a VBO, for example when calling glBufferData.

Offline StrideColossus
« Reply #13 - Posted 2013-11-19 10:55:24 »

Did a bit more research on this but didn't come up with anything definitive.  There are limitations on the size of a VBO but it looks like it's vendor-specific, anecdotally that limit appears to be 32Mb on most cards.  Presumably I went over that limit when I tried to render the large terrain.

In any case the 'correct' way to do this is to split the mesh into multiple VBOs which is what I was doing anyway Smiley, a chunk size of around 4Mb seems to be the general recommendation.

Cheers for all the responses.

- stride
Offline gouessej

« In padded room »



TUER


« Reply #14 - Posted 2013-11-19 16:22:05 »

a chunk size of around 4Mb seems to be the general recommendation.
It seems plausible. If the constant has an absurd value, I put only a few thousands of elements into a VBO.

Pages: [1]
  ignore  |  Print  
 
 

 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (247 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!