Jump to content

  • Log In with Google      Sign In   
  • Create Account

glDrawElements without indices?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
16 replies to this topic

#1 floatingwoods   Members   -  Reputation: 292

Like
0Likes
Like

Posted 06 July 2014 - 10:00 AM

Hello,

 

I am using VBO's together with glDrawElements to quickly render a bunch of triangles. In my case, since each triangle has exactly 3 vertices, 3 normals and 3 texture coordinates, I could get rid of the indices and avoid having another VBO taking memory on the GPU.

My indices are always starting at zero and continuous.

 

Is there a way to avoid having to upload those indices?

 

Another option would be to have one single index buffer on the GPU that serves all the geometries that I need to render, but that is still taking some memory on the GPU.

 

Finally, and linked to the VBO's: how do people usually handle situations where there is no more free memory on the GPU for VBOs:

 

- how to notice that?

- how to overcome that?

 

Thanks!



Sponsor:

#2 C0lumbo   Crossbones+   -  Reputation: 2501

Like
6Likes
Like

Posted 06 July 2014 - 10:07 AM

Is glDrawArrays what you're after?

 

"Another option would be to have one single index buffer on the GPU that serves all the geometries that I need to render, but that is still taking some memory on the GPU." - This is an option I use for the common case of quads, but for separate triangles, glDrawArrays should be better I think.



#3 floatingwoods   Members   -  Reputation: 292

Like
0Likes
Like

Posted 06 July 2014 - 04:43 PM

Thank you COlumbo, that's exactly what I was looking for!

 

For the second part, how can I find out if my GPU's memory is already saturated?

 

Thanks



#4 L. Spiro   Crossbones+   -  Reputation: 14419

Like
4Likes
Like

Posted 06 July 2014 - 07:37 PM

- how to notice that?

http://nasutechtips.blogspot.jp/2011/02/how-to-get-gpu-memory-size-and-usage-in.html

- how to overcome that?

The OpenGL driver manages GPU memory for you, automatically flushing when necessary.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 floatingwoods   Members   -  Reputation: 292

Like
0Likes
Like

Posted 07 July 2014 - 01:09 PM

Thank you for the clarification L. Spiro, which actually confuses me a little bit ;)

 

Take texture memory. Does that mean that if you try to put too many textures onto the GPU, some textures will automatically be flushed? If yes, then this means I might have to upload textures more than one time!?

 

I somehow feel that texure memory is yet another story. But take VBOs: I creating them via Qt, like:

QGLBuffer* myVBO=new QGLBuffer(QGLBuffer::VertexBuffer);
myVBO->create();
myVBO->bind();
myVBO->setUsagePattern(QGLBuffer::StaticDraw);
myVBO->allocate(vertices,3*verticesCnt*sizeof(float));

and everytime, in order to use them, I call:

myVBO->bind();
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,0,0);
glDrawArrays(GL_TRIANGLES,0,verticesCnt);
glDisableClientState(GL_VERTEX_ARRAY);

And that works fine. I never have to upload the vertices to the GPU again. So is there something that happens behind the scene?

 

Thanks

 



#6 cgrant   Members   -  Reputation: 762

Like
1Likes
Like

Posted 07 July 2014 - 01:37 PM

GPU Memory management shouldn't be treated any differently that CPU memory management. If the driver virtualize the memory and handling flushing on overcomit, thats great, but does that mean one should do it? The major graphics API provide means to check out of memory situation, though reactive instead of pro-active, its better than nothing. Properly design software should check these conditions and react accordingly. Also, just to clarify memory is memory wrt to the GPU, there is no separate texture memory, VBO, FBO, IBO memory. To the driver, they are just a block of memory with semantics attached to them( covering usage, access etc ).
 In the example you gave above, the memory is allocated by the driver and there is no need to upload anything else unless you are changing the content of the memory. The binding call and the client state setup is just telling the driver that all subsequent draw call will use the bounded buffer as the source for vertex data. There is no upload taking place in this case.

I guess the most important question is are you running on a memory constraint hw for you to be worried about running out of memory for such small amount of vertex data ?



#7 mhagain   Crossbones+   -  Reputation: 8284

Like
1Likes
Like

Posted 07 July 2014 - 03:42 PM

Take texture memory. Does that mean that if you try to put too many textures onto the GPU, some textures will automatically be flushed? If yes, then this means I might have to upload textures more than one time!?

 

The driver handles this automatically for you.  If your video RAM (there's no such thing as dedicated memory for textures any more) becomes overcommitted, the driver will swap textures out to system memory, and automatically swap them back in to video RAM as required, so there's no manual intervention required.

 

The best way of dealing with this is actually not to query GPU memory and make decisions based on that.  Instead you'll set a minimum required specification and use that as a guideline when sizing your assets.  Nowadays 1gb might be a realistic "run on all hardware" minimum, although if you want to target really old hardware you might set your minimum to 512mb.  Anything lower than that, you just don't bother supporting.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#8 floatingwoods   Members   -  Reputation: 292

Like
0Likes
Like

Posted 07 July 2014 - 05:54 PM

Interesting, thanks to both of you!

 

So what about following strategy:

 

I keep track of all textures and VBOs that I have registered with the GPU. If I notice that I am coming close to a saturation, then I release a few textures or VBOs that were not used for a while... (e.g. not used because out of sight). Does that sound reasonable?



#9 L. Spiro   Crossbones+   -  Reputation: 14419

Like
2Likes
Like

Posted 07 July 2014 - 06:58 PM

Does that sound reasonable?

Not as reasonable as, “Make all the VBO’s you need and let the driver worry about the rest.”
Just because you’ve made a VBO it doesn’t necessarily mean it is consuming GPU RAM.
As I said, let the driver page in and page out memory. No game needs 2 GPU memory managers.


L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#10 mhagain   Crossbones+   -  Reputation: 8284

Like
2Likes
Like

Posted 08 July 2014 - 01:40 AM

As I said, let the driver page in and page out memory. No game needs 2 GPU memory managers.

 

This, basically.

 

I'll add: just because you can it doesn't mean that you should.  The idea is that this should never even happen.  Just as you shouldn't write your own GPU memory manager, neither should the driver ever have to swap out resources.  If you're over-committing video RAM you don't start thinking about swapping out resources, you do start thinking about reducing the size of your resources.  So say you target a 1gb card and you find that you need 1.5gb - what you do is reduce the resolution of your textures, you reduce the polycount of your models, you think about using compressed textures or compressed vertex formats, you get everything to fit in that 1gb.

 

The reason why is because creating and destroying resources is expensive.  Disk access is now the primary bottleneck for a lot of computing tasks.  So you don't build something that has such heavy reliance on your slowest form of storage.  It all adds up to runtime hitches that affect the gameplay experience.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#11 floatingwoods   Members   -  Reputation: 292

Like
0Likes
Like

Posted 09 July 2014 - 12:15 PM

Thanks again to both of you. It is now much more clear!



#12 kalle_h   Members   -  Reputation: 1569

Like
0Likes
Like

Posted 09 July 2014 - 03:28 PM

 

As I said, let the driver page in and page out memory. No game needs 2 GPU memory managers.

 

This, basically.

 

I'll add: just because you can it doesn't mean that you should.  The idea is that this should never even happen.  Just as you shouldn't write your own GPU memory manager, neither should the driver ever have to swap out resources.  If you're over-committing video RAM you don't start thinking about swapping out resources, you do start thinking about reducing the size of your resources.  So say you target a 1gb card and you find that you need 1.5gb - what you do is reduce the resolution of your textures, you reduce the polycount of your models, you think about using compressed textures or compressed vertex formats, you get everything to fit in that 1gb.

 

The reason why is because creating and destroying resources is expensive.  Disk access is now the primary bottleneck for a lot of computing tasks.  So you don't build something that has such heavy reliance on your slowest form of storage.  It all adds up to runtime hitches that affect the gameplay experience.

 

So texture streaming never happened?



#13 mhagain   Crossbones+   -  Reputation: 8284

Like
0Likes
Like

Posted 09 July 2014 - 05:44 PM

So texture streaming never happened?

 

 

 

Did I say that?  I don't remember saying that.  Maybe you'd explain to me how you managed to take what I wrote and read it as that?


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#14 kalle_h   Members   -  Reputation: 1569

Like
0Likes
Like

Posted 10 July 2014 - 02:39 AM

 

So texture streaming never happened?

 

 

 

Did I say that?  I don't remember saying that.  Maybe you'd explain to me how you managed to take what I wrote and read it as that?

 

"If you're over-committing video RAM you don't start thinking about swapping out resources, you do start thinking about reducing the size of your resources."

 

Texture streaming is just one counter example what you were saying. 



#15 mhagain   Crossbones+   -  Reputation: 8284

Like
0Likes
Like

Posted 11 July 2014 - 04:28 AM

Texture streaming is just one counter example what you were saying. 

 

Maybe you could have said that originally?

 

In any event, you don't implement texture streaming by continually creating and destroying resources at runtime, and you don't implement it by swapping out entire resources from GPU memory to CPU memory at runtime either.  You implement it by creating a fixed number of resources (that will fit in your target platform's available memory) and you update those resources as required (in OpenGL it would be via glTexSubimage calls).  The resources to update are based on requirements of the scene, rather than of video RAM, since the video RAM allocation can be one-time-only and fixed.  Yes, it's a technique to reduce video RAM requirements, but it's not the same technique that the OP is asking about and not the same technique that myself and others are saying "don't do it" to.

 

In the context of the OP texture streaming is a strawman.  The OP is not asking about texture streaming, the OP is asking about creating and destroying resources on the fly and at runtime.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#16 JohnnyCode   Members   -  Reputation: 329

Like
1Likes
Like

Posted 16 July 2014 - 03:00 PM

 

"If you're over-committing video RAM you don't start thinking about swapping out resources, you do start thinking about reducing the size of your resources."

 

Texture streaming is just one counter example what you were saying.

It is not counter example, texture streaming alows one to minimize requirement over resources.

 

If you cannot create a resource, becouse of low memory or becouse of bad weather, than a memory counter to prove you you can do so will do nothing just to .. LOL, prove a retarded assumption,

 

You must handle refused instructions on your own responsibility, whaether it will mean you will render with one texture instead of needed 25 , or swap texture from harddrive to very gpu 25 times per frame to achieve the result. Like if you wanted to render a frame of doom 3 on a calculator.

 

You are rather confused on how to handle insifficient conditions of a station a program runs over, but remember, no matter what you learn, no program can overcome impossible.



#17 JohnnyCode   Members   -  Reputation: 329

Like
0Likes
Like

Posted 16 July 2014 - 03:10 PM

 

but remember, no matter what you learn, no program can overcome impossible.

I would correct myself here, it can over come impossible, but you will need to consume a lot of time. And time matters in the consumer interaction experience.

 

You can run doom 3 instructions on a calculator, and print the frames on a paper for example.  Since it is John Carmack it might have been frame per 3 minutes though. Or you could just emit  frame to electromagnetic space.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS