PDA

View Full Version : Can I change texture's internal format freely



pango
09-18-2008, 08:41 PM
My program need to create its textures with different internal format for some init params,I want to know whether can I create textures with different internal format(GL_RGBA,GL_RGBA16F,or GL_RGBA32F),and leave other code unchanged?my program include some blending operation,vertex shader,and pixel shader.

yooyo
09-19-2008, 01:41 AM
For each texture you can choose any hw-supported internal format at creation time (in glTexImage2D call). Later changing internal format without image data loose in not possible.
You can reuse texture name and call glTexImage2D with different internal format.

pango
09-19-2008, 05:21 AM
Mr yooyo,you mistake my means,I only create textures in program started,but the internal format of them is not changed when program is running;every program started,it may choose different texture internal format by init params(all textures use the same),but the rendering & shader code is unchanged;now my code was only tested with GL_RGBA format texture,so whether my code will work with GL_RGBA16F or GL_RGBA32F texture?

yooyo
09-19-2008, 08:01 AM
Not sure...
in glTexImage2D call you have to specify internal format and data format that you uploading. In some cases driver is not able to convert pixels formats between app and host, so app must handle such cases.

If you are using PBO's and RGBA as internal format for textures then use BGRA format for faster uploading. But, when you switch internal format to GL_RGBA8UI_ARB then you must change type and format.

pango
09-19-2008, 08:25 AM
take no account of image upload & download,because I allocate a GL_RGBA8UI_ARB texture to take charge the issue,the texture with dynamic internal format only response for rendering work

pango
09-19-2008, 08:33 AM
Hi,Mr yooyo,how many 16bit and 32 bit texture internal format exist in OpenGL 2.0?I tested below 16bit & 32bit format in my program:
- GL_RGBA16
- GL_RGBA16F_ARB
- GL_RGBA32F_ARB
I found they are all slower than GL_RGBA format(the fastest one is GL_RGBA16F_ARB),is there any other 16bit or 32bit format can I use?

V-man
09-19-2008, 04:55 PM
The GL_ARB_texture_float spec describes the formats available.
Yes, I would imagine GL_RGBA16F_ARB and GL_RGBA32F_ARB would be slow since they consume more memory space and so it might reduce the cache performance.

It would depends on the GPU as well. Some GPUs can only do NEAREST filtering with float targets. Some can handle GL_RGBA16F_ARB but not GL_RGBA32F_ARB. Some can handle both.