Sign in to follow this  
okonomiyaki

OpenGL crazy speed difference between GL_REPEAT and GL_CLAMP_TO_EDGE (texture repeating)

Recommended Posts

Hey guys, I've recently hit a huge bottleneck in my program where I didn't think there would be one. I narrowed it down to a simple scenario: * Create an OpenGL texture with the following pseudo-code:
    (glTexEnvi GL_TEXTURE_ENV GL_TEXTURE_ENV_MODE GL_DECAL)
    (glTexImage2D GL_TEXTURE_2D
                  0
                  GL_RGBA
                  width
                  height
                  0
                  GL_RGBA
                  GL_UNSIGNED_BYTE
                  data)
    (glTexParameteri GL_TEXTURE_2D
                     GL_TEXTURE_MIN_FILTER
                     GL_LINEAR)
    (glTexParameteri GL_TEXTURE_2D
                     GL_TEXTURE_MAG_FILTER
                     GL_LINEAR)
    (glTexParameteri GL_TEXTURE_2D
                     GL_TEXTURE_WRAP_S
                     GL_REPEAT)
    (glTexParameteri GL_TEXTURE_2D
                     GL_TEXTURE_WRAP_T
                     GL_REPEAT)
* Create a loop that simply renders a quad that fills the window with the above texture applied to it (so you just see the image rendered in the window). That's basically it. Surprisingly, for a 465x638 window, each loop iteration takes ~.55s! However, here's the kicker, if I change the texture wrap parameters to GL_CLAMP_TO_EDGE instead of GL_REPEAT, I get the expected faster speeds of ~.002s per iteration:
    (glTexParameteri GL_TEXTURE_2D
                     GL_TEXTURE_WRAP_S
                     GL_CLAMP_TO_EDGE)
    (glTexParameteri GL_TEXTURE_2D
                     GL_TEXTURE_WRAP_T
                     GL_CLAMP_TO_EDGE)
Is there a simple explanation for this, or is it something in my opengl initialization or drivers? I'm on OS X 10.5 and here's some of my driver information: OpenGL vendor string: ATI Technologies Inc. OpenGL renderer string: ATI Radeon X1600 OpenGL Engine OpenGL version string: 2.0 ATI-1.5.36

Share this post


Link to post
Share on other sites
Completely fixed function. I can explain other parts of the system too but I'm not sure what would be helpful. I just realized that there's one thing I set in the initialization phase that could make a difference:


(glPixelStorei GL_UNPACK_ALIGNMENT 1)


Would setting the pixel alignment make a difference? I needed this for my textures to work, but I could be using it wrongly.

Share this post


Link to post
Share on other sites
Are you wrapping the texture many times? If so, then the chances are that your texture coordinate derivatives per pixel are so high that the videocard is thrashing the cache on each sample. If not, then maybe there is a bug in the drivers?

Share this post


Link to post
Share on other sites
are u using power of 2 sized textures,
I dont know perhaps the GL_REPEAT with NPOT textures arent supported on in hardware for ATI Radeon X1600 for some strange reason

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this