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

glDrawElements without indices?

16 posts in this topic

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!

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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

 

0

Share this post


Link to post
Share on other sites

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 ?

1

Share this post


Link to post
Share on other sites

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.

1

Share this post


Link to post
Share on other sites

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?

0

Share this post


Link to post
Share on other sites

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

2

Share this post


Link to post
Share on other sites

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.

2

Share this post


Link to post
Share on other sites

 

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?

0

Share this post


Link to post
Share on other sites

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?

0

Share this post


Link to post
Share on other sites

 

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. 

0

Share this post


Link to post
Share on other sites
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.

0

Share this post


Link to post
Share on other sites

 

"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.

1

Share this post


Link to post
Share on other sites

 

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.

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