Jump to content
  • Advertisement
Sign in to follow this  
RPTD

OpenGL 4 Texture units reported but 7 work. A problem?

This topic is 3691 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

I wrote a little code to test for OpenGL capabilities on my system to check out what optimizations are feasible. Upon fetching GL_MAX_TEXTURE_UNITS I receive 4. I have though shaders in use which use 6 or 7 texture units and it works all fine. The graphic card is a GeForce 6600 GT/PCI/SSE2. What's going on? Is the driver just buggy and returns 4 although it suports 8 ( I think 6600 has 8 )? Is something else ( probably bad ) happening that I do not see yet?

Share this post


Link to post
Share on other sites
Advertisement
I'm betting it supports doing an extra cycle to fetch more (ie it can fetch 4 at a time, up to its maximum #registers), but you're paying for it with speed.

Share this post


Link to post
Share on other sites
MAX_TEXTURE_UNITS is the maximum for the fixed function pipeline, where one texture unit consists of a texture sampler (which extracts a colour from a texture) and a texture coordinate set.

GLSL separates the two concepts - GL_MAX_TEXTURE_IMAGE_UNITS is how many textures you can have bound, and GL_MAX_TEXTURE_COORDS is how many different sets of texture coords you can have. You'll probably find you've got 4 fixed-function texture units and in glsl 4 texture coord sets but 16 texture image units.

Share this post


Link to post
Share on other sites
Can you elaborate on this a bit more? So far I thought graphic cards have up to 8 ( high end ones 10 ) texture units. So for optimal performance on those systems I should not use more than 8 texture units in one shader. If the graphic card now reports let's say 16 texture image units does this mean I could use those 16 or would this be bad?

EDIT: Updated the tests. This is what I get:
- Texture Compression Formats:
- S3TC DXT1 ( RGB )
- S3TC DXT3 ( RGBA )
- S3TC DXT5 ( RGBA )
- Maximum Texture Size: 4096
- Number of FPL Texture Units: 4
- Maximum Viewport Size: 4096 x 4096
- Maximum number of Shader Texture Image Units: 16
- Maximum number of Shader Texture Coordinates: 8


So how many texture units could I use now in my shaders now?

Share this post


Link to post
Share on other sites
Quote:
Original post by RPTD
So how many texture units could I use now in my shaders now?

As indicated, 16 is your maximum number of textures you can have bound and access in a shader. This is a hard and fast limit.

You can also sample the same texture multiple times if you want. Actual shader speed will depend on how many times you access the textures and what other computation your shader is performing.

Share this post


Link to post
Share on other sites
Okay, so if I have for example 4 texture layers with each 3 textures ( various material parameters ) then I could do the following setup and it would work?

Unit 1: mask ( 1 component per layer )
Unit 2,3,4: first layer textures
Unit 5,6,7: second layer textures
Unit 8,9,10: third layer textures
Unit 11,12,13: fourth layer textures

This would open up a couple of new possibilities to my shaders if this would work and would be fast ( i need to tap each texture once anyways but this way I would have to write out to the 3 color attachments only once processing geometry also only once ).

Share this post


Link to post
Share on other sites
u can access 16texture units at once, however u split them up is up to you

>> Maximum number of Shader Texture Coordinates: 8
this is gl_TexCoord0...7 + has nothing to do with the actual textures

sampling 16textures in one shader is gonna be pretty slow, so try to use as few as possible or merge textures together

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!