Jump to content

  • Log In with Google      Sign In   
  • Create Account


Strange Video Memory Increase


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 madgallagher   Members   -  Reputation: 104

Like
0Likes
Like

Posted 28 March 2013 - 06:37 AM

Hi Guys

 

I have a weird issue on opengl. I am rendering a lot of tris (millions) using vertex arrays.

Here is the issue.

 

If I load up the tris and display as shaded with a constant color, the video memory is showing around 600MB.

 

If I then change the color array values to be varied at different vertex, the memory usage increases to around 1GB.

If I then spin the model around, the memory usage slowly decreases to around 600MB (after a couple of minutes).

 

But, if I load up the model straight away with varied shading, the memory is only 600MB.

 

This is on linux, so is it a driver issue ? Or is there something more obvious I am neglecting.

 

I am using nvidia-smi to check the graphics memory usage.

 

Cheers in advance for any help !



Sponsor:

#2 Josh Vega   Crossbones+   -  Reputation: 1147

Like
0Likes
Like

Posted 28 March 2013 - 07:06 AM

My first question is "Are you using the Linux drivers from your graphics card manufacturer or Nouveau?" If you are Nouveau I recommend you get the official Linux drivers for you video card before moving on.

 

Once thats all set and done and it still doesn't work, they my next question is "Are you using any type of culling?" If you are, its possible that when switching from the constant color to the varied shading the culling gets reset and isn't re-called until you move the camera (spin the model) or load the model right away with the varied shading. You'll need to find way to make sure that the culler is "always active". If you are attempting to use deferred shading rendering, there could also be some issues there, but I wouldn't be able to help you much as I'm just starting to learn about using defShading with OpenGL.

 

Also, have you tried testing it with a lower-poly model (maybe in the thousands of tris)?

 

Lastly, what version of OpenGL are you using and what is your graphics card?


Some favourite quotes:
Spoiler

#3 madgallagher   Members   -  Reputation: 104

Like
0Likes
Like

Posted 28 March 2013 - 07:52 AM

Hi

 

I am using the latest linux driver from Nvidia. The card is pretty old. Its an FX3800, but we see the same issue on an FX4000.

The same routines are used for both types of shading. I'm simply changing the values in the color array. Nothing else.

 

We get the same "doubling" of memory usage on smaller models too. Its like when the color array is updated, the memory

is not re-allocated on the card properly.



#4 Hodgman   Moderators   -  Reputation: 27668

Like
0Likes
Like

Posted 28 March 2013 - 08:17 AM

I'm simply changing the values in the color array.

How are you doing this? Is it a VBO or a client-side vertex array? What hints was it created with?

 

the memory usage slowly decreases to around 600MB (after a couple of minutes).

Is this actually a problem? If the driver doesn't need that memory for other tasks right now, they it's ok for it to delay releasing it.


Edited by Hodgman, 28 March 2013 - 08:18 AM.


#5 madgallagher   Members   -  Reputation: 104

Like
0Likes
Like

Posted 28 March 2013 - 08:51 AM

OK, the render code is basically as follows:

 

glShadeModel(GL_SMOOTH);

glEnable(GL_COLOR_MATERIAL)

glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT);

glColorMaterial(GL_FRONT_AND_BACK,GL_SPECULAR);

glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);

 

glEnableClientState(GL_VERTEX_ARRAY);

glVertexPointer(....);

glEnableClientState(GL_NORMAL_ARRAY);

glNormalPointer(...);

glEnableClientState(GL_COLOR_ARRAY);

glColorPointer(....);

glDrawElements(........);

 

So, I am just using arrays, not VBOs. All I do is update the values in the color array that glColorPointer points to before I come into this routine.

 

The problem is, on a 1GB graphics card, if I am using 600MB and then change the color, it swamps the card and

the system starts badly lagging because it is trying to double the memory usage.



#6 Josh Vega   Crossbones+   -  Reputation: 1147

Like
0Likes
Like

Posted 28 March 2013 - 09:28 AM

By you use of glColorPointer() and the FX3000/4000, I'm guessing your using OpenGL 2.0. I personally don't have too much experience with anything earlier than OpenGL 3.1, so please take my help as a grain of salt.

 

Do you disable client state after you are finished writing to it or at program close? If you use the later, try disabling it after you are finished drawing everything. I'm not sure weather or not it will help, but its worth a shot in my opinion.

 

Is it possible for you to use VBOs rather than arrays? My understanding is that even back in OpenGL 2, it was more efficient to use buffers rather than arrays.


Some favourite quotes:
Spoiler

#7 madgallagher   Members   -  Reputation: 104

Like
0Likes
Like

Posted 28 March 2013 - 09:39 AM

Yes, sorry I forgot to add in the glDisableClientState commands. These are all deleted after the tris are drawn each time.

 

I added in VBOs and got the same effect even when deleting the VBO. Even simply using glBegin/End for the rendering (shock horror !!) causes the same effect.

 

It is kind of driving me crazy..................



#8 Josh Vega   Crossbones+   -  Reputation: 1147

Like
0Likes
Like

Posted 28 March 2013 - 09:47 AM

It's driving me crazy that I don't know how else I can help you...blink.png

 

Just one quick question... Are you using C++ or C or another language? Also, if you are using C++ or C, are you using any libraries like GLEW or SDL?


Some favourite quotes:
Spoiler

#9 madgallagher   Members   -  Reputation: 104

Like
0Likes
Like

Posted 28 March 2013 - 09:52 AM

Its all in C baby. I am not using anything like GLEW or SDL. Its pretty basic stuff.

 

Do you think it is a driver issue which is out of my control ??



#10 Josh Vega   Crossbones+   -  Reputation: 1147

Like
0Likes
Like

Posted 28 March 2013 - 09:58 AM

It could possibly be a driver issue. Have you tried it on an AMD/ATI card? What linux distro are you using?


Some favourite quotes:
Spoiler

#11 mhagain   Crossbones+   -  Reputation: 7436

Like
2Likes
Like

Posted 28 March 2013 - 10:46 AM

I suspect that this may be normal behaviour rather than a driver issue. The fact that you're seeing this kind of video RAM usage at all with client arrays indicates that the geometry is being cached in video RAM. So you specify the arrays and draw, all good. Then you change the color array and now you've got two copies cached - the original (which the driver is presumably keeping around in case you need to go back to it) and the new. After a while, if you haven't gone back to the original, the driver decides to throw out it's old copy.

You may be able to control some of this behaviour with some use of GL_EXT_compiled_vertex_array, or you may be better off not using a vertex array for your constant color case (just glColor4f it instead).

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.


#12 madgallagher   Members   -  Reputation: 104

Like
0Likes
Like

Posted 28 March 2013 - 10:59 AM

Thanks, I'll check out the GL_EXT_compiled _vertex_array. I get the same problem when I have varied colours

at the vertex and just change the values to say RGB ->RBG. Basically, any change to the colour array causes

the problem.

 

I appreciate all your comments gentlemen.



#13 slicer4ever   Crossbones+   -  Reputation: 3205

Like
0Likes
Like

Posted 29 March 2013 - 05:00 AM

mhagain, on 28 Mar 2013 - 12:50, said:
I suspect that this may be normal behaviour rather than a driver issue. The fact that you're seeing this kind of video RAM usage at all with client arrays indicates that the geometry is being cached in video RAM. So you specify the arrays and draw, all good. Then you change the color array and now you've got two copies cached - the original (which the driver is presumably keeping around in case you need to go back to it) and the new. After a while, if you haven't gone back to the original, the driver decides to throw out it's old copy.

You may be able to control some of this behaviour with some use of GL_EXT_compiled_vertex_array, or you may be better off not using a vertex array for your constant color case (just glColor4f it instead).

Pretty much this. For the most part, the driver knows best. If your changing values in your submitted data, it's highly likely the driver is simply caching the data, without releasing the old buffer immediately.

This is not uncommon to see in windows either. In short, i'd recommend not worrying about what the driver is doing, unless it's actually causing a problem.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#14 Josh Vega   Crossbones+   -  Reputation: 1147

Like
0Likes
Like

Posted 29 March 2013 - 09:34 AM

Well I think it is a problem for him as he said that when he changes the value, his graphics card's memory usage shoots up from 600M to 1G and then it starts to lag. If the driver is caching the data, then he would need to find a way to remove the values he's editing from the cache.


Some favourite quotes:
Spoiler

#15 Aks9   Members   -  Reputation: 770

Like
0Likes
Like

Posted 29 March 2013 - 11:27 AM

The problem is in the "idea" to store 600MB in a single vertex array and transfer it in each draw call. That is not the way to go. I guess the performace is terrible if the data is not cached. The driver is probably trying to save performance by caching data and that's the problem. It could be solved by making smaller buffers.

#16 mhagain   Crossbones+   -  Reputation: 7436

Like
0Likes
Like

Posted 29 March 2013 - 11:53 AM

The only real way to handle this that I can think of is to use two different fragment shaders, one with the constant colour as a uniform. From the looks of the OP's sample code he's not using shaders at all, but running on prehistoric hardware shouldnt be a problem here; the kind of hardware that can handle this volume of data will always have shaders available anyway.

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.


#17 slicer4ever   Crossbones+   -  Reputation: 3205

Like
0Likes
Like

Posted 29 March 2013 - 01:11 PM

Well I think it is a problem for him as he said that when he changes the value, his graphics card's memory usage shoots up from 600M to 1G and then it starts to lag. If the driver is caching the data, then he would need to find a way to remove the values he's editing from the cache.

ah, i missed where he said it was lagging, my bad.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.




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