Execessive Lag With Non-Uniform Textures ( Eg. 256x128 )

Started by
8 comments, last by V-man 16 years, 3 months ago
Hi guys, i've been programming a sprite class in OpenGL which also has the ability to render specific parts of a sprite. My code works perfectly at the moment except for one problem. With non-uniform textures such as 256x128 when trying to render the CPU usage of my program goes really high and causes windows to respond slowly etc. I've gone through my code and have realized that the bulk of the CPU usage comes from the following code:

	glTexCoord2f ( left, top );	
	glVertex2f ( 0, 0 );

	glTexCoord2f ( right, top ); 
	glVertex2f ( ( offset.w - offset.x ), 0 );

	glTexCoord2f ( right, bottom ); 
	glVertex2f ( ( offset.w - offset.x ), ( offset.h - offset.y ) );

	glTexCoord2f ( left, bottom ); 
	glVertex2f ( 0, ( offset.h - offset.y ) );
When commented out the remaining CPU usage is average 5-6. My code is perfectly fine when using uniform texture sizes but i absolutely need to use non-uniform textures... Any help is GREATLY appreciated. Thanks :)
Advertisement

hey ,

1) what kind of gfx do u have it?
2) do u have the latest driver?
3) which Window API are u using?
4) what is the setup code for the device ?
5) how can u setup the texutre in ogl?

Hi... Here's what my specifications are:

1) NVidia GeForce 8800 GTX
2) Yes
3) I'm using SDL with OpenGL
4) The device setup code is done through SDL
5) I use SDL_image to load the image into a surface, then set it through opengl using glTexImage2D etc.
Hey guys, a few hours of searching and i game up with a solution. I'm now using GL_TEXTURE_RECTANGLE_ARB instead of GL_TEXTURE_2D. The lag is completely gone.

Thanks. :)
NVidia GeForce 8800 GTX is a high-end customer product. Most of the recently GPU updates are available. In particular, non-power-of-2 texture is one of them.

You should have no problem to use non-power-of-2 dimension texture with ordinary texture target like GL_TEXTURE_2D on NVidia GeForce 8800 GTX.

For whatever reason, your display card is not functioning correctly. The first thing you should try is to update your display card driver. If it didn't work, you should check whether your computer have other kinds of hardware failures (e.g. having a power supply of not enough power).
Quote:Original post by ma_hty
NVidia GeForce 8800 GTX is a high-end customer product. Most of the recently GPU updates are available. In particular, non-power-of-2 texture is one of them.

You should have no problem to use non-power-of-2 dimension texture with ordinary texture target like GL_TEXTURE_2D on NVidia GeForce 8800 GTX.

For whatever reason, your display card is not functioning correctly. The first thing you should try is to update your display card driver. If it didn't work, you should check whether your computer have other kinds of hardware failures (e.g. having a power supply of not enough power).


2nd'ed

I have a GF8600 GTS and I can load non rectangle textures without lag, using the ordinary texture_2d target. However the same application on my laptop will lag to about 1 FPS (radeon 9600 mobile).
Check your drivers
____________________________Bjarni Arnasonbjarni.us
if the same code works heaps faster with GL_TEXTURE_RECTANGLE_ARB instead of GL_TEXTURE_2D on a gf8
i assume its cause youre not setting the texture corrdinates correctly

GL_TEXTURE_2D has normalized texture coords eg 0.0->1.0
GL_TEXTURE_RECTANGLE_ARB does 0->texture width


thus a 256x128 sized texture
glTexCoord2f(256,128) with GL_TEXTURE_RECTANGLE_ARB thats the corner of it, with G_TEXTURE_2D, this is tiling the texture 10000s of times (which is slow)
Quote:With non-uniform textures such as 256x128
What kind of a beast is "Non-Uniform Textures"?
Do you mean "non-power of 2"?
But 256 & 128 are exactly powers 2...

Do you by any chance have automatic mipmap generation enabled?
It can be slow for non-power of 2 textures.
Quote:Original post by bjarniaHowever the same application on my laptop will lag to about 1 FPS (radeon 9600 mobile).

Radeon 9600 has limited support for NPow2 textures - no mipmaping, must be clamped to edge...
Quote:Original post by bjarnia
Quote:Original post by ma_hty
NVidia GeForce 8800 GTX is a high-end customer product. Most of the recently GPU updates are available. In particular, non-power-of-2 texture is one of them.

You should have no problem to use non-power-of-2 dimension texture with ordinary texture target like GL_TEXTURE_2D on NVidia GeForce 8800 GTX.

For whatever reason, your display card is not functioning correctly. The first thing you should try is to update your display card driver. If it didn't work, you should check whether your computer have other kinds of hardware failures (e.g. having a power supply of not enough power).


2nd'ed

I have a GF8600 GTS and I can load non rectangle textures without lag, using the ordinary texture_2d target. However the same application on my laptop will lag to about 1 FPS (radeon 9600 mobile).
Check your drivers


learning what the hw can do is part of the learning process :)
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement