Jump to content
  • Advertisement
Sign in to follow this  
n00body

OpenGL # of usable Tex Units

This topic is 3882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, my dilemma is that when queried, OpenGL tells me I have a maximum of 4 Texture Units available for multi-texturing/uploading to shader. However, when I ran the most recent Code Sampler HDR demo, I noticed that they used 5 texture units. So what gives? What is the actual number I have to work with? Or am I limited for good performance, and can get more for a performance hit? Any help would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
The GL limit 'GL_MAX_TEXTURE_UNITS_ARB' gives you the maximum number of usable texture units in FFP. But when you are in programmable pipeline, you can use upto 'GL_MAX_TEXTURE_IMAGE_UNITS_ARB' texture units. Moreover GL_MAX_TEXTURE_IMAGE_UNITS_ARB >= GL_MAX_TEXTURE_UNITS_ARB.

For instance in my X1600 card GL_MAX_TEXTURE_UNITS_ARB = 8 and GL_MAX_TEXTURE_IMAGE_UNITS_ARB = 16.

Share this post


Link to post
Share on other sites
Now that I've made that change, it says I have 16. Thanks for the info. ;)

However, that number needs clarification. That can't possibly mean I can have 16 textures bound, can it?

Share this post


Link to post
Share on other sites
Quote:
Original post by n00body
That can't possibly mean I can have 16 textures bound, can it?
Yes, exactly. Take care however that only the first
GL_MAX_TEXTURE_UNITS do have complete state (such as tcGen and possibly texCoords).

Share this post


Link to post
Share on other sites
Quote:
Original post by Krohm
Quote:
Original post by n00body
That can't possibly mean I can have 16 textures bound, can it?
Yes, exactly. Take care however that only the first
GL_MAX_TEXTURE_UNITS do have complete state (such as tcGen and possibly texCoords).


There is no TexGen because TexGen is for the fixed function. You should not even call glTexEnv. TexEnv is for fixed pipeline as well.
For texcoords, you need to query it. I think it was GL_MAX_TEXCOORDS or something like that.
Some of these cards have 16 image units and 8 texcoords.

Share this post


Link to post
Share on other sites
FYI max texture coordinates will be tied to the max vertex attributes, e.g. normals, vertices, texture coordinates, color ect... Last I checked there was only 16 registers for this on current cards so this is why we have 8 texture coordinates still.

attribute vec4 gl_Vertex;
attribute vec3 gl_Normal;
attribute vec4 gl_Color;
attribute vec4 gl_SecondaryColor;
attribute vec4 gl_MultiTexCoord0;
attribute vec4 gl_MultiTexCoord1;
attribute vec4 gl_MultiTexCoord2;
attribute vec4 gl_MultiTexCoord3;
attribute vec4 gl_MultiTexCoord4;
attribute vec4 gl_MultiTexCoord5;
attribute vec4 gl_MultiTexCoord6;
attribute vec4 gl_MultiTexCoord7;
attribute float gl_FogCoord;

is the list of attributes, and I think you have a few open slots, which I use for tangents and bitangents.

Share this post


Link to post
Share on other sites
Quote:
Original post by V-man
There is no TexGen because TexGen is for the fixed function. You should not even call glTexEnv. TexEnv is for fixed pipeline as well.

This is not quite the reason. In fact, texGen is a geometry operation and you can mix and match vertex-FFP with pixel shading. But even assuming you cannot, the wording, if you read the spec is quite similar...
Quote:
From ARB_f_s spec
(16) Should aux texture units be additional units on top of existing
full-featured texture units, or should this spec fully deprecate
"legacy" texture units and only expose texture coordinate sets and
texture image units?

Background: Some implementations are able to expose more
"texture image units" (texture maps and associated parameters)
than "texture coordinate sets" (current texcoords, texgen, and
texture matrices). A conventional GL "texture unit" encompasses
both a texture image unit and a texture coordinate set as well as
texture environment state.

RESOLVED: Yes, deprecate "legacy" texture units. This is a more
flexible model.

...

specifies the active texture unit selector, ACTIVE_TEXTURE. Each
texture unit contains up to two distinct sub-units: a texture
coordinate processing unit (consisting of a texture matrix stack and
texture coordinate generation state
) and a texture image unit
(consisting of all the texture state defined in Section 3.8). In
implementations with a different number of supported texture
coordinate sets and texture image units, some texture units may
consist of only one of the two sub-units.

The active texture unit selector specifies the texture coordinate
set accessed by commands involving texture coordinate processing.
Such commands include those accessing the current matrix stack (if
MATRIX_MODE is TEXTURE), TexGen (section 2.10.4), Enable/Disable (if
any texture coordinate generation enum is selected), as well as
queries of the current texture coordinates and current raster
texture coordinates. If the texture coordinate set number
corresponding to the current value of ACTIVE_TEXTURE is greater than
or equal to the implementation-dependent constant
MAX_TEXTURE_COORDS_ARB, the error INVALID_OPERATION is generated by
any such command.

In general, a good reading of the spec is absolutely necessary to understand the key differences between image units and fully fledged texture units, it's heavily suggested, before you learn it the hard way.

Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999
FYI max texture coordinates will be tied to the max vertex attributes, e.g. normals, vertices, texture coordinates, color ect... Last I checked there was only 16 registers for this on current cards so this is why we have 8 texture coordinates still.

attribute vec4 gl_Vertex;
attribute vec3 gl_Normal;
attribute vec4 gl_Color;
attribute vec4 gl_SecondaryColor;
attribute vec4 gl_MultiTexCoord0;
attribute vec4 gl_MultiTexCoord1;
attribute vec4 gl_MultiTexCoord2;
attribute vec4 gl_MultiTexCoord3;
attribute vec4 gl_MultiTexCoord4;
attribute vec4 gl_MultiTexCoord5;
attribute vec4 gl_MultiTexCoord6;
attribute vec4 gl_MultiTexCoord7;
attribute float gl_FogCoord;

is the list of attributes, and I think you have a few open slots, which I use for tangents and bitangents.


I thought that use of those conventions was being deprecated in favor of glVertexAttribPointers.

Share this post


Link to post
Share on other sites
Quote:
This is not quite the reason. In fact, texGen is a geometry operation and you can mix and match vertex-FFP with pixel shading. But even assuming you cannot, the wording, if you read the spec is quite similar...


What I mean is that you might have 16 image units, but texGen will not work on tex unit 8 and above.
Image units are just for binding the texture and you sample it in your shader.

If you want don't want to use a vertex shader, that's fine but you still can't use all the image units the way you typically want to use them.

[Edited by - V-man on February 7, 2008 7:44:52 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!