depth texture on PowerVR SGX540

I’ve got an application that renders the color and depth buffers to textures via a frame buffer object using OpenGL ES 2.0. Using the PC Emulator everything works fine, but when I try to run the application on the actual hardware (PowerVR SGX540), the color texture is valid, but the depth texture appears to be all black. I don’t appear to be getting any OpenGL or driver errors, but it appears that no data is being written to the depth texture. I’m using GL_DEPTH_COMPONENT for the depth texture format and GL_UNSIGNED_SHORT for the type.



Is there any reason this configuration wouldn’t work on the SGX540? Does anyone know of anything I need to look out for in trying to make this work?


Please disregard, I figured it out. Oddly enough, it was the depth texture wrapping mode. Changing this from GL_REPEAT to GL_CLAMP_TO_EDGE fixed the problem. Go figure.

The reason for this is that non-power-of-two textures are only partially supported in OpenGL ES and the emulator is not currently imitating the hardware correctly. Specifically, a black texture should be produced for NPOT textures if:


  • GL_TEXTURE_MIN_FILTER is set to anything other than GL_NEAREST or GL_LINEAR
  • The repeat mode is set to anything other than GL_CLAMP_TO_EDGE



    If you’d like to use a wrapping texture then the dimensions of your texture should be powers of two.

Thanks for the explanation. However, my texture size was 512x512. Is it possible that these restrictions apply even for non-power of two textures?



The wrap mode was originally set to GL_REPEAT by accident, so using GL_CLAMP_TO_EDGE is fine for me.