# depth texture on PowerVR SGX540

**URL:** <https://forums.imgtec.com/t/depth-texture-on-powervr-sgx540/1700>\
**Category:** PowerVR Insider\
**Created:** [March 11, 2013, 1:10pm UTC](https://forums.imgtec.com/t/depth-texture-on-powervr-sgx540/1700 "2013-03-11T13:10:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deep](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@deep](https://forums.imgtec.com/u/deep)\
**Post date:** [March 11, 2013, 1:10pm UTC](https://forums.imgtec.com/t/depth-texture-on-powervr-sgx540/1700/1 "2013-03-11T13:10:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![deep](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@deep](https://forums.imgtec.com/u/deep)\
**Post date:** [March 11, 2013, 8:23pm UTC](https://forums.imgtec.com/t/depth-texture-on-powervr-sgx540/1700/2 "2013-03-11T20:23:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ChrisPenrose](https://avatars.discourse-cdn.com/v4/letter/c/e36b37/32.png) [@ChrisPenrose](https://forums.imgtec.com/u/ChrisPenrose)\
**Post date:** [March 12, 2013, 9:02am UTC](https://forums.imgtec.com/t/depth-texture-on-powervr-sgx540/1700/3 "2013-03-12T09:02:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![deep](https://avatars.discourse-cdn.com/v4/letter/d/ce7236/32.png) [@deep](https://forums.imgtec.com/u/deep)\
**Post date:** [March 12, 2013, 11:45am UTC](https://forums.imgtec.com/t/depth-texture-on-powervr-sgx540/1700/4 "2013-03-12T11:45:40Z")

</div>

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.
