# FBO problem on Powervr Gpus on an android app

**URL:** <https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978>\
**Category:** PowerVR Insider\
**Created:** [January 13, 2014, 11:46pm UTC](https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978 "2014-01-13T23:46:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mckimiaklopa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mckimiaklopa](https://forums.imgtec.com/u/mckimiaklopa)\
**Post date:** [January 13, 2014, 11:46pm UTC](https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978/1 "2014-01-13T23:46:56Z")

</div>

There is an app for android called PPSSPP(psp emulator)  
  
  
  
One of it’s feautres is called buffered rendering wherein it allocates an OpenGL fbo for every Psp framebuffer location  
  
  
  
On other gpus,it’s perfect  
  
On all powervr gpus,many things are missing(specifically,stencil is not correctly rendered using this mode)  
  
  
  
The error is most likely found in the fbo setup in the fbo.cpp  
  
  
  
For detailed info, go here [forums.ppsspp.org/showthread.php?tid=8479](http://forums.ppsspp.org/showthread.php?tid=8479)r  
  
  
  
If you want to browse the code in fbo.cpp,go here [https://github.com/hrydgard/native/blob/master/gfx\_es2/fbo.cpp](https://github.com/hrydgard/native/blob/master/gfx_es2/fbo.cpp)  
  
  
  
If you want to make a ppsspp modified apk with fixes,download sources(including the native and ffmpeg) here[https://github.com/hrydgard/ppsspp](https://github.com/hrydgard/ppsspp)  
  
  
  
If the problem is not in the fbo.cpp in the native,it is most likely in the framebuffer.cpp  
  
  
  
THE devs of the app are very puzzled why this is happening,so I was hopinh some of you might help  
  
  
  
Thanks in advance

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [January 27, 2014, 11:58am UTC](https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978/2 "2014-01-27T11:58:15Z")

</div>

Hi,  
  
  
  
Apologies for the delayed response. Based on the [OES\_packed\_depth\_stencil](http://www.khronos.org/registry/gles/extensions/OES/OES_packed_depth_stencil.txt) extension spec, I believe the code should be:

````auto
fbo->stencil_buffer = 0;<br />
fbo->z_buffer = 0;<br />
// 24-bit Z, 8-bit stencil<br />
glGenRenderbuffers(1, &fbo->z_stencil_buffer);<br />
glBindRenderbuffer(GL_RENDERBUFFER, fbo->z_stencil_buffer);<br />
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height);<br />
<br />
// Bind it all together<br />
glBindFramebuffer(GL_FRAMEBUFFER, fbo->handle);<br />
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fbo->color_texture, 0);<br />
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo->z_stencil_buffer);<br />
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, fbo->z_stencil_buffer);
```<br />
<br />
Note that I've removed the 'EXT' and '_EXT' parts as the functions and most arguments are core in OpenGL ES 2.0. For best performance, you should also avoid changing framebuffer attachments or sharing attachments across FBOs.<br />
<br />
Let us know if you have any more issues after making these modifications.<br />
<br />
Thanks,<br />
Joe
````

---

<div class="post-metadata">

**Author:** ![mckimiaklopa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mckimiaklopa](https://forums.imgtec.com/u/mckimiaklopa)\
**Post date:** [January 27, 2014, 12:30pm UTC](https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978/3 "2014-01-27T12:30:48Z")

</div>

THANK YOU VERY much for your reply  
  
but errr,what was ur change?  
  
i’m sorry cos i cant see the changes when compare here [https://github.com/hrydgard/native/blob/master/gfx\_es2/fbo.cpp](https://github.com/hrydgard/native/blob/master/gfx_es2/fbo.cpp)  
  
though i appreciate the effort  
  
Due note that fbo.cpp is also used on windows which explains everything about the EXT  
  
Also note that it is the second half of the code that corresponds to android while the first part(with the ext)corresponds to windows.So by removing the EXT bits,the code is now the same with the second part which in reality does not do anything to the problem.Also check out the Framebuffer.cpp and shadergenerator file in github ppsspp [https://github.com/hrydgard/ppsspp/tree/master/GPU/GLES,thanks](https://github.com/hrydgard/ppsspp/tree/master/GPU/GLES,thanks)  
  
Hope for a reply

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [January 27, 2014, 1:49pm UTC](https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978/4 "2014-01-27T13:49:34Z")

</div>

Ah, sorry. I saw the first code block using packed depth+stencil, and didn’t think to check the rest of the file…  
  
You’re right. The code I’ve suggested is the same as the block that’s already there.  
  
  
  
Are attachments always unique to each FBO?  
  
  
  
Which PowerVR devices have you reproduced the issue on? Are there any PowerVR devices where the error doesn’t occur?  
  
  
  
I’ll clone the source now so I can take a proper look at it.

---

<div class="post-metadata">

**Author:** ![mckimiaklopa](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@mckimiaklopa](https://forums.imgtec.com/u/mckimiaklopa)\
**Post date:** [January 27, 2014, 9:49pm UTC](https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978/5 "2014-01-27T21:49:44Z")

</div>

AFAIK,each fbo needa all attachments  
  
AFAIK,it happens to all POwer vr devices  
  
Also,its best to also make contact to the sole dev of the app(email found on the above links)

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [March 12, 2014, 11:24am UTC](https://forums.imgtec.com/t/fbo-problem-on-powervr-gpus-on-an-android-app/1978/6 "2014-03-12T11:24:29Z")

</div>

Sorry for going quiet. I haven’t had a chance to revisit this problem. Do you know if the developers are actively investigating the issue?  
  
  
  
Thanks.  
  
Joe
