Sign in to follow this  
Terminatore3

OpenGL using the video card

Recommended Posts

Hi, I'm sure there is a simple answer to this, but I can't find anything that can tell me how to utilize the graphix card on a computer in OpenGL. Right now, i'm pretty sure anyways, all my graphics commands are processed by the CPU and that would slow down the computer. Is there an easy way to use my OpenGL commands, such as glVertex3f();, on the gfx card? any replies are appreciated

Share this post


Link to post
Share on other sites
I don't have a lot of experience in utilizing the graphics card for specific things (without having the graphics API as a level of abstraction between me and the gfx card), but I know that you can use VBOs (vertex buffer objects), which basically means that a set of geometry is stored on the graphics card, which makes rendering that set much faster.

And, you really shouldn't be using 'glVertexf', it would be better to start with vertex buffers.

But, no, I don't think that there is a lot that can be done to speed up a call to glVertex3f or anything else, as the vertex position still needs to be multiplied by the current model matrix and sent to the graphics card. Sending data to the gfx card will pretty much always take the same amount of time.

If you are interested, I believe that you'll find your answer, with the ARB Open GL extensions.

Share this post


Link to post
Share on other sites
Given any semi recent, not complete trash video card, transformation and Lighting will be done on the video card (I think the nVidia drivers may do some work on the CPU if they think there is a performance advantage). I'm fairly sure that the model matrix multiplication is included in Transformation and Lighting. Or in other words it's done on the card.

Now as for way your program is slow is because glVertex3f is a slow way to send geometry to the video card (As Endar said). Since each vertex requires a function call. There are two ways (that I can think of) to efficiently send geometry in large chunks, display lists and vertex arrays. Display lists are typically used for static geometry (they have some other uses). They can be setup with the glVertex3f syntax. Vertex Arrays allow you send arrays of vertexes and other per vertex values. So 1 function call for 10,000 vertexes, instead of 10,000 glVertex3f calls. VBOs allow you store the vertex arrays on the video card's memory. I think display lists are also stored on board the card.

All of the above have been standard for a quite a while and are no longer extensions. Although to use some of them may require going through the extension system (thanks Microsoft...). Glee or Glew will make using the extension system much easier.

Share this post


Link to post
Share on other sites
shaders.

CG for example.

anything handled by the shader goed over the GPU. however, this GPU / CPU tradeoff is not simply to does as much as possible over the GPU.

and for the rest you should turn to vertex array for speed boosts of vertex buffer object like mentoined before.

the speed will be maximal when giving fixed vertices to the shader through a buffer/array and altering their position in the shader. However, as I said, beware of the tradeoffs, they are everywhere. Their is no simple way too speed up everything at once.

The most speedgains however will result from your skillz as a programmer, differentiate proper between static stuff and dynamic stuff (both types are maximized differently) , proper debugging and converting a good release file (this alone gives about 30fps)

Share this post


Link to post
Share on other sites
what you are all saying is "mostly" correct. The reason shaders, and transformation & lighting (T & L) are done on the card is because OpenGL is really a state machine. Now there's two parts to this state machine and they are known as the client and the server. The server is essentially the graphics card, so any operations performed by the server, such as T & L, inherently happen on the GPU.

If you want to utilize the GPU even more you can move your vertex (along with normals, colors, texture coords, etc.) over to "server" memory, or graphics card memory. This can be done by using VBOs or vertex buffer objects, which essentially load and store arbitrary data into the graphics card memory. This means we don't have to transfer this data from "client" memory (standard RAM) across the bus to the graphics card memory for these operations to be performed, thereby improving performance even further.

I'd recommend reading up on how the OpenGL state machine works, it will give you some good insight on these issues and plenty more :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Endar
I don't have a lot of experience in utilizing the graphics card for specific things (without having the graphics API as a level of abstraction between me and the gfx card), but I know that you can use VBOs (vertex buffer objects), which basically means that a set of geometry is stored on the graphics card, which makes rendering that set much faster.


Not necessarily. The driver chooses where it will store something. If there is space in VRAM and your stuff is STATIC, it will likely be in VRAM.
If you use streaming, then AGP will likely b used. IN the case of PCIEx, regular RAM reserved by the driver.

BTW, VBOs are core since GL 1.5, so it doesn't make sense not to use them, whether you are a newbie or not.
The only reason to not use them is if you want to support very very old stuff.

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