No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)?

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
kokonut
Gnoblar
Posts: 7
Joined: Wed Feb 27, 2013 8:07 pm
Location: USA

No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)?

Post by kokonut »

Can anyone with a Nexus 7 (2012, with Tegra3, running Android 4.3) please check their OGRE logs to make sure I'm not crazy or the device is broken?
It seems that all the "depth/stencil support" lines for all the FBO pixel formats are empty, meaning any FBOs can't have a depth buffer, and it crashes in:

Code: Select all

Ogre::GLES2FBOManager::getBestDepthStencil(unsigned int, unsigned int*, unsigned int*)
because

Code: Select all

props.modes.size() == 0
after putting some debug print statements.

The same APK works on a Samsung Galaxy S3 (Adreno 225 GPU).

Are depth map texture shadows triggering an FBO creation with an attached depth buffer? If so, are there anyways to avoid this?
Also is the main Android RenderWindow implemented internally using an FBO with a depth buffer attachment and triggering this?

Thank you for any possible help.

Code: Select all

I/OGRE    (16737): Creating resource group General
I/OGRE    (16737): Creating resource group Internal
I/OGRE    (16737): Creating resource group Autodetect
I/OGRE    (16737): SceneManagerFactory for type 'DefaultSceneManager' registered.
I/OGRE    (16737): Registering ResourceManager for type Material
I/OGRE    (16737): Registering ResourceManager for type Mesh
I/OGRE    (16737): Registering ResourceManager for type Skeleton
I/OGRE    (16737): MovableObjectFactory for type 'ParticleSystem' registered.
I/OGRE    (16737): ArchiveFactory for archive type FileSystem registered.
I/OGRE    (16737): ArchiveFactory for archive type Zip registered.
I/OGRE    (16737): ArchiveFactory for archive type EmbeddedZip registered.
I/OGRE    (16737): DDS codec registering
I/OGRE    (16737): FreeImage version: 3.15.3
I/OGRE    (16737): This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
I/OGRE    (16737): Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi,exr,j2k,j2c,jp2,pfm,pct,pict,pic,3fr,arw,bay,bmq,cap,cine,cr2,crw,cs1,dc2,dcr,drf,dsc,dng,erf,fff,ia,iiq,k25,kc2,kdc,mdc,mef,mos,mrw,nef,nrw,orf,pef,ptx,pxn,qtk,raf,raw,rdc,rw2,rwl,rwz,sr2,srf,srw,sti
I/OGRE    (16737): PVRTC codec registering
I/OGRE    (16737): ETC codec registering
I/OGRE    (16737): Registering ResourceManager for type HighLevelGpuProgram
I/OGRE    (16737): Registering ResourceManager for type Compositor
I/OGRE    (16737): MovableObjectFactory for type 'Entity' registered.
I/OGRE    (16737): MovableObjectFactory for type 'Light' registered.
I/OGRE    (16737): MovableObjectFactory for type 'BillboardSet' registered.
I/OGRE    (16737): MovableObjectFactory for type 'ManualObject' registered.
I/OGRE    (16737): MovableObjectFactory for type 'BillboardChain' registered.
I/OGRE    (16737): MovableObjectFactory for type 'RibbonTrail' registered.
I/OGRE    (16737): *-*-* OGRE Initialising
I/OGRE    (16737): *-*-* Version 1.9.0unstable (Ghadamon)
I/OGRE    (16737): ArchiveFactory for archive type APKFileSystem registered.
I/OGRE    (16737): ArchiveFactory for archive type APKZip registered.
I/OGRE    (16737): Installing plugin: Octree Scene Manager
I/OGRE    (16737): Plugin successfully installed
I/OGRE    (16737): Installing plugin: ParticleFX
I/OGRE    (16737): Particle Emitter Type 'Point' registered
I/OGRE    (16737): Particle Emitter Type 'Box' registered
I/OGRE    (16737): Particle Emitter Type 'Ellipsoid' registered
I/OGRE    (16737): Particle Emitter Type 'Cylinder' registered
I/OGRE    (16737): Particle Emitter Type 'Ring' registered
I/OGRE    (16737): Particle Emitter Type 'HollowEllipsoid' registered
I/OGRE    (16737): Particle Affector Type 'LinearForce' registered
I/OGRE    (16737): Particle Affector Type 'ColourFader' registered
I/OGRE    (16737): Particle Affector Type 'ColourFader2' registered
I/OGRE    (16737): Particle Affector Type 'ColourImage' registered
I/OGRE    (16737): Particle Affector Type 'ColourInterpolator' registered
I/OGRE    (16737): Particle Affector Type 'Scaler' registered
I/OGRE    (16737): Particle Affector Type 'Rotator' registered
I/OGRE    (16737): Particle Affector Type 'DirectionRandomiser' registered
I/OGRE    (16737): Particle Affector Type 'DeflectorPlane' registered
I/OGRE    (16737): Plugin successfully installed
V/SyandusPlatform(16737): SyApp is about to intialize renderer.
V/SyandusPlatform(16737): choosing OpenGL rendersystem
I/OGRE    (16737): Installing plugin: OpenGL ES 2.0 RenderSystem
I/OGRE    (16737): OpenGL ES 2.x Rendering Subsystem created.
D/libEGL  (16737): loaded /system/lib/egl/libEGL_tegra.so
D/libEGL  (16737): loaded /system/lib/egl/libGLESv1_CM_tegra.so
D/libEGL  (16737): loaded /system/lib/egl/libGLESv2_tegra.so
I/OGRE    (16737): Plugin successfully installed
I/OGRE    (16737): CPU Identifier & Features
I/OGRE    (16737): -------------------------
I/OGRE    (16737):  *   CPU ID: ARMv7
I/OGRE    (16737):  *      VFP: yes
I/OGRE    (16737):  *     NEON: yes
I/OGRE    (16737): -------------------------
I/OGRE    (16737): Registering ResourceManager for type Texture
I/OGRE    (16737): GLES2RenderSystem::_createRenderWindow "OGRE Render Window", 0x0 fullscreen  miscParams: FSAA=0 externalWindowHandle=1074323472 gamma=false vsync=true
I/OGRE    (16737): GL_VERSION = OpenGL ES 2.0 14.01003
I/OGRE    (16737): GL_VENDOR = NVIDIA Corporation
I/OGRE    (16737): GL_RENDERER = NVIDIA Tegra 3
I/OGRE    (16737): GL_EXTENSIONS = GL_OES_rgb8_rgba8 GL_OES_EGL_sync GL_OES_fbo_render_mipmap GL_NV_depth_nonlinear GL_NV_draw_path GL_NV_texture_npot_2D_mipmap GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_vertex_half_float GL_OES_mapbuffer GL_NV_draw_buffers GL_NV_multiview_draw_buffers GL_EXT_Cg_shader GL_EXT_packed_float GL_OES_texture_half_float GL_EXT_texture_array GL_OES_compressed_ETC1_RGB8_texture GL_EXT_texture_compression_latc GL_NV_texture_compression_latc GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_NV_texture_compression_s3tc GL_EXT_texture_filter_anisotropic GL_NV_get_tex_image GL_NV_read_buffer GL_NV_shader_framebuffer_fetch GL_NV_copy_image GL_NV_fbo_color_attachments GL_EXT_bgra GL_EXT_texture_format_BGRA8888 GL_EXT_unpack_subimage GL_NV_pack_subimage GL_NV_texture_compression_s3tc_update GL_NV_read_depth GL_NV_read_stencil GL_NV_uniform_buffer_object GL_EXT_robustness GL_OES_standard_derivatives GL_NV_EGL_stream_consumer_external GL_NV_3dvision_settings GL_EXT_debug_marker GL_EXT_de
I/OGRE    (16737): EXT:GL_OES_rgb8_rgba8
I/OGRE    (16737): EXT:GL_OES_EGL_sync
I/OGRE    (16737): EXT:GL_OES_fbo_render_mipmap
I/OGRE    (16737): EXT:GL_NV_depth_nonlinear
I/OGRE    (16737): EXT:GL_NV_draw_path
I/OGRE    (16737): EXT:GL_NV_texture_npot_2D_mipmap
I/OGRE    (16737): EXT:GL_OES_EGL_image
I/OGRE    (16737): EXT:GL_OES_EGL_image_external
I/OGRE    (16737): EXT:GL_OES_vertex_half_float
I/OGRE    (16737): EXT:GL_OES_mapbuffer
I/OGRE    (16737): EXT:GL_NV_draw_buffers
I/OGRE    (16737): EXT:GL_NV_multiview_draw_buffers
I/OGRE    (16737): EXT:GL_EXT_Cg_shader
I/OGRE    (16737): EXT:GL_EXT_packed_float
I/OGRE    (16737): EXT:GL_OES_texture_half_float
I/OGRE    (16737): EXT:GL_EXT_texture_array
I/OGRE    (16737): EXT:GL_OES_compressed_ETC1_RGB8_texture
I/OGRE    (16737): EXT:GL_EXT_texture_compression_latc
I/OGRE    (16737): EXT:GL_NV_texture_compression_latc
I/OGRE    (16737): EXT:GL_EXT_texture_compression_dxt1
I/OGRE    (16737): EXT:GL_EXT_texture_compression_s3tc
I/OGRE    (16737): EXT:GL_NV_texture_compression_s3tc
I/OGRE    (16737): EXT:GL_EXT_texture_filter_anisotropic
I/OGRE    (16737): EXT:GL_NV_get_tex_image
I/OGRE    (16737): EXT:GL_NV_read_buffer
I/OGRE    (16737): EXT:GL_NV_shader_framebuffer_fetch
I/OGRE    (16737): EXT:GL_NV_copy_image
I/OGRE    (16737): EXT:GL_NV_fbo_color_attachments
I/OGRE    (16737): EXT:GL_EXT_bgra
I/OGRE    (16737): EXT:GL_EXT_texture_format_BGRA8888
I/OGRE    (16737): EXT:GL_EXT_unpack_subimage
I/OGRE    (16737): EXT:GL_NV_pack_subimage
I/OGRE    (16737): EXT:GL_NV_texture_compression_s3tc_update
I/OGRE    (16737): EXT:GL_NV_read_depth
I/OGRE    (16737): EXT:GL_NV_read_stencil
I/OGRE    (16737): EXT:GL_NV_uniform_buffer_object
I/OGRE    (16737): EXT:GL_EXT_robustness
I/OGRE    (16737): EXT:GL_OES_standard_derivatives
I/OGRE    (16737): EXT:GL_NV_EGL_stream_consumer_external
I/OGRE    (16737): EXT:GL_NV_3dvision_settings
I/OGRE    (16737): EXT:GL_EXT_debug_marker
I/OGRE    (16737): EXT:GL_EXT_debug_label
I/OGRE    (16737): EXT:GL_NV_coverage_sample
I/OGRE    (16737): EXT:GL_EXT_occlusion_query_boolean
I/OGRE    (16737): EXT:GL_NV_timer_query
I/OGRE    (16737): **************************************
I/OGRE    (16737): *** OpenGL ES 2.x Renderer Started ***
I/OGRE    (16737): **************************************
I/OGRE    (16737): GLSL ES support detected
I/OGRE    (16737): Registering ResourceManager for type GpuProgram
I/OGRE    (16737): GL ES 2: Using FBOs for rendering to textures
I/OGRE    (16737): FBO PF_UNKNOWN depth/stencil support:
I/OGRE    (16737): FBO PF_L8 depth/stencil support:
I/OGRE    (16737): FBO PF_L16 depth/stencil support:
I/OGRE    (16737): FBO PF_A8 depth/stencil support:
I/OGRE    (16737): FBO PF_BYTE_LA depth/stencil support:
I/OGRE    (16737): FBO PF_R5G6B5 depth/stencil support:
I/OGRE    (16737): FBO PF_B5G6R5 depth/stencil support:
I/OGRE    (16737): FBO PF_A4R4G4B4 depth/stencil support:
I/OGRE    (16737): FBO PF_A1R5G5B5 depth/stencil support:
I/OGRE    (16737): FBO PF_R8G8B8 depth/stencil support:
I/OGRE    (16737): FBO PF_B8G8R8 depth/stencil support:
I/OGRE    (16737): FBO PF_A8R8G8B8 depth/stencil support:
I/OGRE    (16737): FBO PF_A8B8G8R8 depth/stencil support:
I/OGRE    (16737): FBO PF_B8G8R8A8 depth/stencil support:
I/OGRE    (16737): FBO PF_FLOAT16_RGB depth/stencil support:
I/OGRE    (16737): FBO PF_X8R8G8B8 depth/stencil support:
I/OGRE    (16737): FBO PF_SHORT_RGBA depth/stencil support:
I/OGRE    (16737): [GLES2] : Valid FBO targets PF_UNKNOWN PF_L8 PF_L16 PF_A8 PF_BYTE_LA PF_R5G6B5 PF_B5G6R5 PF_A4R4G4B4 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_A8B8G8R8 PF_B8G8R8A8 PF_FLOAT16_RGB PF_X8R8G8B8 PF_SHORT_RGBA
I/OGRE    (16737): RenderSystem capabilities
I/OGRE    (16737): -------------------------
I/OGRE    (16737): RenderSystem Name: OpenGL ES 2.x Rendering Subsystem
I/OGRE    (16737): GPU Vendor: nvidia
I/OGRE    (16737): Device Name: NVIDIA Tegra 3
I/OGRE    (16737): Driver Version: 0.0.0.0
Point of crash

Code: Select all

I/OGRE    (16737): Texture: spot_shadow_fade.png: Loading 1 faces(PF_R8G8B8,128x128x1) with 7 hardware generated mipmaps from Image. Internal format is PF_R8G8B8,128x128x1.
I/OGRE    (16737): inside getBestDepthStencil()
I/OGRE    (16737): depthFormat pointer: 0xbee701f8
I/OGRE    (16737): stencilFormat pointer: 0xbee701fc
I/OGRE    (16737): props.modes.size(): 0
F/libc    (16737): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 16737 (dus.redacted)
I/DEBUG   (  120): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   (  120): Build fingerprint: 'google/nakasi/grouper:4.3/JWR66Y/776638:user/release-keys'
I/DEBUG   (  120): Revision: '0'
I/DEBUG   (  120): pid: 16737, tid: 16737, name: dus.redacted  >>> com.redacted.redacted <<<
I/DEBUG   (  120): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
I/DEBUG   (  120):     r0 6a1831e8  r1 bee700e8  r2 00000000  r3 00000000
I/DEBUG   (  120):     r4 bee700c4  r5 00000000  r6 006bd884  r7 bee700e8
I/DEBUG   (  120):     r8 59851348  r9 bee70230  sl bee700f8  fp 6a948674
I/DEBUG   (  120):     ip 6593d514  sp bee70070  lr 699204c3  pc 69920704  cpsr 40000030
I/DEBUG   (  120):     d0  6f6d2e73203a2928  d1  657a69732e736564
I/DEBUG   (  120):     d2  627830203a726574  d3  0a38663130376565
I/DEBUG   (  120):     d4  466c69636e657473  d5  6f702074616d726f
I/DEBUG   (  120):     d6  30203a7265746e69  d7  01790d0065656278
I/DEBUG   (  120):     d8  3fda82793f5413cd  d9  3f19999a3f333333
I/DEBUG   (  120):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   (  120):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   (  120):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   (  120):     d16 3fe0000000000000  d17 417790d000000000
I/DEBUG   (  120):     d18 3fc3bd3cdc2cab20  d19 3fc233f5a2f727d2
I/DEBUG   (  120):     d20 0000000000000000  d21 3fabbd76807614f3
I/DEBUG   (  120):     d22 3f82391ed3d83df8  d23 3f967b6faf8d2e07
I/DEBUG   (  120):     d24 3f57f48a38a4a052  d25 3f6d8a8e44e27de7
I/DEBUG   (  120):     d26 3f3043b3a18f8aef  d27 3f43545b10f5feaa
I/DEBUG   (  120):     d28 3fda8279a7bc2207  d29 3f1460ea3eff5d8f
I/DEBUG   (  120):     d30 bef375cbdb605373  d31 3f55c2778a8be9cf
I/DEBUG   (  120):     scr 2000001d
I/DEBUG   (  120):
I/DEBUG   (  120): backtrace:
I/DEBUG   (  120):     #00  pc 0061a704  /data/app-lib/com.redacted.redacted-1/libredacted.so (Ogre::GLES2FBOManager::getBestDepthStencil(unsigned int, unsigned int*, unsigned int*)+931)
I/DEBUG   (  120):     #01  pc 0061a4bf  /data/app-lib/com.redacted.redacted-1/libredacted.so (Ogre::GLES2FBOManager::getBestDepthStencil(unsigned int, unsigned int*, unsigned int*)+350)
I/DEBUG   (  120):
I/DEBUG   (  120): stack:
I/DEBUG   (  120):          bee70030  bee700f8  [stack]
I/DEBUG   (  120):          bee70034  697301bc  /data/app-lib/com.redacted.redacted-1/libredacted.so
I/DEBUG   (  120):          bee70038  6a1831f4
I/DEBUG   (  120):          bee7003c  00000000
I/DEBUG   (  120):          bee70040  bee700f8  [stack]
I/DEBUG   (  120):          bee70044  6593d314
I/DEBUG   (  120):          bee70048  00000001
I/DEBUG   (  120):          bee7004c  00000010
I/DEBUG   (  120):          bee70050  00000000
I/DEBUG   (  120):          bee70054  00000000
I/DEBUG   (  120):          bee70058  bee700f8  [stack]
I/DEBUG   (  120):          bee7005c  bee700c4  [stack]
I/DEBUG   (  120):          bee70060  6a82b258
I/DEBUG   (  120):          bee70064  59851344
I/DEBUG   (  120):          bee70068  df0027ad
I/DEBUG   (  120):          bee7006c  00000000
I/DEBUG   (  120):     #00  bee70070  bee700e4  [stack]
I/DEBUG   (  120):          bee70074  6aa2cb38
I/DEBUG   (  120):          bee70078  6a128ad0  /data/app-lib/com.redacted.redacted-1/libredacted.so
I/DEBUG   (  120):          bee7007c  6aa2cb68
I/DEBUG   (  120):          bee70080  bee700f8  [stack]
I/DEBUG   (  120):          bee70084  bee700e0  [stack]
I/DEBUG   (  120):          bee70088  bee70160  [stack]
I/DEBUG   (  120):          bee7008c  00000000
I/DEBUG   (  120):          bee70090  6b02b008
I/DEBUG   (  120):          bee70094  3f74b8a5
I/DEBUG   (  120):          bee70098  00000000
I/DEBUG   (  120):          bee7009c  3e964cb8
I/DEBUG   (  120):          bee700a0  bee700f4  [stack]
I/DEBUG   (  120):          bee700a4  bee701f8  [stack]
I/DEBUG   (  120):          bee700a8  bee701fc  [stack]
I/DEBUG   (  120):          bee700ac  bee700ec  [stack]
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 139

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by c6burns »

I can confirm the same issue with Tegra3 (nexus7 and ouya), and I believe it is down to lack of hardware support for stencil buffer.
kokonut
Gnoblar
Posts: 7
Joined: Wed Feb 27, 2013 8:07 pm
Location: USA

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by kokonut »

So just to confirm, you can't have depth shadow mapping via shaders and render to texture a 3D object with depth buffer on the Tegra 3?

If so that's pretty sad for a 2012 flagship device by Google, and it means that the game that we are working on will have be redesigned.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 139

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by c6burns »

It's not unheard of to lack a stencil buffer, but yes it's definitely a downer. Older iphones, PS2 and Wii didn't have one either IIRC. I seem to remember Unity users complaining about stencil support on Tegra3 as well. If you want to be absolutely certain, you could always ask nvidia support.
kokonut
Gnoblar
Posts: 7
Joined: Wed Feb 27, 2013 8:07 pm
Location: USA

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by kokonut »

After doing some research, it seems that the Tegra 3 does indeed NOT support rendering a depth map to an FBO with a depth attachment. According to the Unity manual http://docs.unity3d.com/Documentation/M ... adows.html, it is missing the GL_OES_depth_texture extension and thus preventing this.

Nevertheless, it seems that some sort of hacked shadows is possible, possible because the floor is flat, and at a know hardcoded height:
https://play.google.com/store/apps/deta ... ball&hl=en
From a quote I found:
They could be using a cheap hack like simply drawing shadow casters from the light perspective using a pixel shader that just writes out black (first clearing the buffer to white), then having only specific geometry read the "shadow buffer" and use it to modulate lighting without any depth comparisons. Its an old approach that requires you to guarantee that shadow receivers are always behind shadow casters, and there is no self shadowing, but it looks correct in those cases.
-Owen
So, my one question, probably targeted at the OGRE devs, is it possible to render to an FBO with no depth and/or stencil attachments? Sure, not having a Z-Buffer will mess up all but the simplest geometry, but maybe I can experiment to see if it suits my purposes. At the very least, is it possible to not have OGRE crash at GLES2FBOManager::getBestDepthStencil() if props.modes.size() == 0 (bestmode remains at -1, and crashes when it tries to access props.mode[-1]) and just dump a warning? Or is it too late in the dev cycle since 1.9 is coming out soon? It looks like getBestDepthStencil() is one of those "can't possibly fail" functions.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by dark_sylinc »

kokonut wrote: So, my one question, probably targeted at the OGRE devs, is it possible to render to an FBO with no depth and/or stencil attachments?
Yes, set the depth buffer pool ID to 0 of the RTT (DepthBuffer::POOL_NO_DEPTH). Can be done by calling RenderTarget::setDepthBufferPool or by setting the value in the compositor script.
User avatar
nuke
Halfling
Posts: 72
Joined: Wed Oct 01, 2014 1:16 am
Location: Crimea
x 5

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by nuke »

dark_sylinc wrote:
kokonut wrote: So, my one question, probably targeted at the OGRE devs, is it possible to render to an FBO with no depth and/or stencil attachments?
Yes, set the depth buffer pool ID to 0 of the RTT (DepthBuffer::POOL_NO_DEPTH). Can be done by calling RenderTarget::setDepthBufferPool or by setting the value in the compositor script.
Hi!
Sorry for the maybe stupid question, but I would really like to know where I need to add this code? And what exactly?

I was looking for a place in the sources of Ogre where it is called ( RenderTarget::setDepthBufferPool(POOL_DEFAULT) )
to change it to RenderTarget::setDepthBufferPool(POOL_NO_DEPTH),
but I have not found it :( :( :(

My HTC One X with Tegra 3 crashes for the same reason :(

P.S.
btw. which branch of Ogre (v1-9, v2-0 ,v2-1uav or v2-1) is most stable for use GLES2 / Android ?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by dark_sylinc »

nuke32 wrote: I was looking for a place in the sources of Ogre where it is called ( RenderTarget::setDepthBufferPool(POOL_DEFAULT) )
to change it to RenderTarget::setDepthBufferPool(POOL_NO_DEPTH),
but I have not found it :( :( :(
Just look at where you have a RenderTarget, RenderTexture or RenderWindow pointer, and perform renderTargetPointer->setDepthBufferPool( DepthBuffer::POOL_NO_DEPTH );
If you still don't understand what I mean with this, I'm afraid to tell you, you should spend some time making your C++ background a little more solid before continuing.
nuke32 wrote:btw. which branch of Ogre (v1-9, v2-0 ,v2-1uav or v2-1) is most stable for use GLES2 / Android ?
For Android development, either v1-9 or default (which is 1.10).
User avatar
nuke
Halfling
Posts: 72
Joined: Wed Oct 01, 2014 1:16 am
Location: Crimea
x 5

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by nuke »

Thank you so much, dark_sylinc !!!! !!!! !!!! !!!! :D :D :D

I've edited Ogre sources to solve this problem by disabling depth buffer pool.

#1 Now it starts and works great on my HTC One X (Tegra 3) without crashes on these Samples - Character, Fresnel, Skeletal Animation, and texture shadows are present and almost stable !!!! !!!!
#2 I've got significant FPS boost ~x2 times ( ~30fps --> ~60fps in some cases, and ~13fps --> ~30fps in other cases) because depth buffer pool was disabled !!!! !!!!

#3 Tested on LG L60 X145 (GPU - Mali 400) and HTC One X (GPU - Tegra 3).
In both cases I've got FPS boost ~x2 times !!!!

#4 Here is my ALL changes (related and not related to FBO) of sources (without *.cmake and CMakeLists.txt. They are skipped in this list.)

............................................................
Ogre version: branch "v1-9"
Revision : 7423
Android NDK version : r10e
Android build target : armeabi-v7a
Android build type : Release (-O3 flag and some flags like -fno-strict-aliasing -fomit-frame-pointer -DNDEBUG etc. ... )
Android STL : stlport_static
OS: xubuntu 14.04



Here is a list of changes:

OgreMain/include/OgrePrerequisites.h:

Code: Select all

@@ -30,6 +30,8 @@
 #include "OgrePlatform.h"
 
 #include <string>
+ #include <unordered_map>[/color]
+ #include <unordered_set>[/color]
 
// configure memory tracking
 #if OGRE_DEBUG_MODE 
@@ -99,8 +101,8 @@
     #           define HashSet ::std::unordered_set
     #       endif
     #   else
-    #       define HashMap ::std::unordered_map
-    #       define HashSet ::std::unordered_set
+    #       define HashMap std::tr1::unordered_map
+    #       define HashSet std::tr1::unordered_set
     #   endif
     #endif
OgreMain/src/OgreRenderTarget.cpp (related to this subject - Disabling Depth Buffer Pool) :

Code: Select all

@@ -42,7 +42,7 @@
 
     RenderTarget::RenderTarget()
 		: mPriority(OGRE_DEFAULT_RT_GROUP)
-		, mDepthBufferPoolId(DepthBuffer::POOL_DEFAULT)
+		, mDepthBufferPoolId(DepthBuffer::POOL_NO_DEPTH) // NUKE
 		, mDepthBuffer(0)
 		, mActive(true)
 		, mAutoUpdate(true)
OgreMain/src/OgreString.cpp:

Code: Select all


@@ -29,6 +29,8 @@
 #include "OgreString.h"
 #include "OgreStringVector.h"
 
+#include <ctype.h>
+
 namespace Ogre {

RenderSystems/GLES2/include/GLES2/gles2w.h (why: http://www.ogre3d.org/forums/viewtopic. ... 50#p516918):

Code: Select all


@@ -9,6 +9,7 @@
 #   include <GLES2/gl2.h>
 #endif
 
+/*  ]//////// COMMENTED by NUKE /////////
 #include <KHR/khrplatform.h>
 #include <GLES2/gl2platform.h>
 #include <GLES2/gl2ext.h>
@@ -12,6 +13,14 @@
 #include <KHR/khrplatform.h>
 #include <GLES2/gl2platform.h>
 #include <GLES2/gl2ext.h>
+*/
+// #include <KHR/khrplatform.h>
+// #include <GLES2/gl2platform.h>
+// #include <GLES2/gl2ext.h>
+#include "../KHR/khrplatform.h"
+#include "gl2platform.h"
+#include "gl2ext.h"
+
 typedef khronos_int64_t  GLint64EXT;
 typedef khronos_uint64_t GLuint64EXT;

RenderSystems/GLES2/src/GLSLES/src/OgreGLSLESPreprocessor.cpp:

Code: Select all


@@ -29,6 +29,8 @@
 #include "OgreGLSLESPreprocessor.h"
 #include "OgreLogManager.h"
 
+#include <cctype>
+
 namespace Ogre {
 // Limit max number of macro arguments to this

RenderSystems/GLES2/src/OgreGLES2FBORenderTexture.cpp (related to this subject - Disabling Depth Buffer Pool) :

Code: Select all


@@ -437,6 +437,11 @@
     void GLES2FBOManager::getBestDepthStencil(GLenum internalFormat, GLenum *depthFormat, GLenum *stencilFormat)
     {
         const FormatProperties &props = mProps[internalFormat];
+        if (props.modes.size() == 0 ) {
+            *depthFormat = 0;
+            *stencilFormat = 0;
+            return;
+        }		
         // Decide what stencil and depth formats to use
         // [best supported for internal format]
         size_t bestmode = 0;

RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp (related to this subject - Disabling Depth Buffer Pool) :

Code: Select all


@@ -66,6 +66,8 @@
 // Convenience macro from ARB_vertex_buffer_object spec
 #define VBO_BUFFER_OFFSET(i) ((char *)NULL + (i))
 
+#include <cctype>
+
 using namespace std;
 
 namespace Ogre {
@@ -619,7 +621,7 @@
 			// Only Copy does, but Copy means only one depth buffer...
 			GLES2Context *windowContext = 0;
 			win->getCustomAttribute( "GLCONTEXT", &windowContext );
-			GLES2DepthBuffer *depthBuffer = OGRE_NEW GLES2DepthBuffer( DepthBuffer::POOL_DEFAULT, this,
+			GLES2DepthBuffer *depthBuffer = OGRE_NEW GLES2DepthBuffer( DepthBuffer::/*POOL_DEFAULT*/POOL_NO_DEPTH, this, // NUKE
 															windowContext, 0, 0,
 															win->getWidth(), win->getHeight(),
 															win->getFSAA(), 0, true );
@@ -2295,7 +2297,7 @@
         
         _destroyDepthBuffer(win);
         
-        GLES2DepthBuffer *depthBuffer = OGRE_NEW GLES2DepthBuffer( DepthBuffer::POOL_DEFAULT, this,
+        GLES2DepthBuffer *depthBuffer = OGRE_NEW GLES2DepthBuffer( DepthBuffer::/*POOL_DEFAULT*/POOL_NO_DEPTH, this, // NUKE
                                                                   mMainContext, 0, 0,
                                                                   win->getWidth(), win->getHeight(),
                                                                   win->getFSAA(), 0, true );

Samples/Browser/include/SampleBrowser_Android.h:

Code: Select all


@@ -37,6 +37,12 @@
 #include "SampleBrowser.h"
 #include "Android/OgreAndroidEGLWindow.h"
 
+#include <unistd.h> //////////////////////////////
+
 #ifdef INCLUDE_RTSHADER_SYSTEM
 #   include "OgreRTShaderSystem.h"
 #endif
@@ -297,5 +303,6 @@
             switch (cmd) 
             {
                 case APP_CMD_SAVE_STATE:
+					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_SAVE_STATE-------------------------------------------------------------------------------------------------------------------");
                 break;
                 case APP_CMD_INIT_WINDOW:
@@ -300,6 +307,8 @@
                 break;
                 case APP_CMD_INIT_WINDOW:
-                    if (app->window && mRoot)
-                    {
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_INIT_WINDOW------------------------------------------------------------------------------------------------------------------");
+				
+					
+                    if(app->window && mRoot){
                         AConfiguration* config = AConfiguration_new();
                         AConfiguration_fromAssetManager(config, app->activity->assetManager);
@@ -304,11 +313,13 @@
                         AConfiguration* config = AConfiguration_new();
                         AConfiguration_fromAssetManager(config, app->activity->assetManager);
-                        
-                        if (!mRenderWnd) 
-                        {
+	 				__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_INIT_WINDOW  #1										..if(app->window && mRoot)..");
+                        if(!mRenderWnd){
+	 				__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_INIT_WINDOW  #1.1													..if(!mRenderWnd)..");
                             Ogre::NameValuePairList opt;
                             opt["externalWindowHandle"] = Ogre::StringConverter::toString((int)app->window);
                             opt["androidConfig"] = Ogre::StringConverter::toString((int)config);
                             
                             mRenderWnd = Ogre::Root::getSingleton().createRenderWindow("OgreWindow", 0, 0, false, &opt);
                             
@@ -309,8 +320,9 @@
                             Ogre::NameValuePairList opt;
                             opt["externalWindowHandle"] = Ogre::StringConverter::toString((int)app->window);
                             opt["androidConfig"] = Ogre::StringConverter::toString((int)config);
                             
                             mRenderWnd = Ogre::Root::getSingleton().createRenderWindow("OgreWindow", 0, 0, false, &opt);
                             
-                            if(!mTouch)
+                            if(!mTouch){
+	 				__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_INIT_WINDOW  #1.1.1															..if(!mTouch)..");
                                 mTouch = new AndroidMultiTouch();
@@ -316,2 +328,3 @@
                                 mTouch = new AndroidMultiTouch();
+							}
                             
@@ -317,3 +330,4 @@
                             
-                            if(!mKeyboard)
+                            if(!mKeyboard){
+	 				__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_INIT_WINDOW  #1.1.2															..if(!mKeyboard)..");
                                 mKeyboard = new AndroidKeyboard();
@@ -319,2 +333,3 @@
                                 mKeyboard = new AndroidKeyboard();
+							}
                             
@@ -320,9 +335,9 @@
                             
-                            if(!mBrowser)
-                            {
+                            if(!mBrowser){
+	 				__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_INIT_WINDOW  #1.1.3															..if(!mBrowser)..");
                                 mBrowser = OGRE_NEW SampleBrowser();
                                 mBrowser->initAppForAndroid(mRenderWnd, app, mTouch, mKeyboard);
                                 mBrowser->initApp();
                                 
                                 mInputInjector = new AndroidInputInjector(mBrowser, mTouch, mKeyboard);
                             }
@@ -323,13 +338,12 @@
                                 mBrowser = OGRE_NEW SampleBrowser();
                                 mBrowser->initAppForAndroid(mRenderWnd, app, mTouch, mKeyboard);
                                 mBrowser->initApp();
                                 
                                 mInputInjector = new AndroidInputInjector(mBrowser, mTouch, mKeyboard);
                             }
-                        }
-                        else
-                        {
+                        }else{
+	 				__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_INIT_WINDOW  #1.2										 				..else..if(!mRenderWnd)..else {.._createInternalResources()..}");
                             static_cast<AndroidEGLWindow*>(mRenderWnd)->_createInternalResources(app->window, config);
                         }
                         
                         AConfiguration_delete(config);
@@ -332,5 +346,26 @@
                             static_cast<AndroidEGLWindow*>(mRenderWnd)->_createInternalResources(app->window, config);
                         }
                         
                         AConfiguration_delete(config);
+						
+						
+						//.............................................................................
+						if(isFocused==false && isNeedRendering==false){
+							isNeedRendering=true;
+							__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "..............[APP_CMD_INIT_WINDOW] => app is not in focus => sleep 1.75s---------------------------------------------------------------");
+						}                    
+						//.............................................................................
+
                     }
@@ -336,3 +371,4 @@
                     }
+                    
                     break;
                 case APP_CMD_TERM_WINDOW:
@@ -337,6 +373,7 @@
                     break;
                 case APP_CMD_TERM_WINDOW:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_TERM_WINDOW------------------------------------------------------------------------------------------------------------------");
                     if(mRoot && mRenderWnd)
                         static_cast<AndroidEGLWindow*>(mRenderWnd)->_destroyInternalResources();
                     break;
                 case APP_CMD_GAINED_FOCUS:
@@ -339,6 +376,13 @@
                     if(mRoot && mRenderWnd)
                         static_cast<AndroidEGLWindow*>(mRenderWnd)->_destroyInternalResources();
                     break;
                 case APP_CMD_GAINED_FOCUS:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_GAINED_FOCUS-----------------------------------------------------------------------------------------------------------------");				
+					isFocused = true;
+					if(isNeedRendering==false){
+						isNeedRendering = true;
+						__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "..............[APP_CMD_GAINED_FOCUS] rendering flag is OFF => turn ON rendering---------------------------------------------------");
+					}
                     break;
                 case APP_CMD_LOST_FOCUS:
@@ -343,4 +387,6 @@
                     break;
                 case APP_CMD_LOST_FOCUS:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_LOST_FOCUS-------------------------------------------------------------------------------------------------------------------");
+					isFocused = false;
                     break;
                 case APP_CMD_CONFIG_CHANGED:
@@ -345,3 +391,4 @@
                     break;
                 case APP_CMD_CONFIG_CHANGED:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_CONFIG_CHANGED---------------------------------------------------------------------------------------------------------------");
                     break;
@@ -347,4 +394,31 @@
                     break;
+				case APP_CMD_PAUSE:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_PAUSE------------------------------------------------------------------------------------------------------------------------");
+					isNeedRendering = false;
+					break;
+				case APP_CMD_RESUME:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_RESUME-----------------------------------------------------------------------------------------------------------------------");
+					//..................................................................................
+					if(isFocused){
+						__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "..............[APP_CMD_RESUME] already FOCUSED => turn ON rendering--------------------------------------------------------------");
+						isNeedRendering = true;
+					}
+					//..................................................................................
+					break;
+				case APP_CMD_DESTROY:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_DESTROY----------------------------------------------------------------------------------------------------------------------");
+					break;
+				case APP_CMD_START:
+ 					__android_log_write(ANDROID_LOG_INFO, "OGRE_LOG_NUKE", "APP_CMD_START------------------------------------------------------------------------------------------------------------------------");
+					break;
             }
         }
         
@@ -355,20 +429,25 @@
             
             while (true)
             {
-                while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
-                {
-                    if (source != NULL)
-                        source->process(state, source);
-                    
-                    if (state->destroyRequested != 0)
-                        return;
-                }
-                
-                if(mRenderWnd != NULL && mRenderWnd->isActive())
-                {
-                    mRenderWnd->windowMovedOrResized();
-                    mRoot->renderOneFrame();
-                }
+				while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
+				{
+					if (source != NULL)
+						source->process(state, source);
+					
+					if (state->destroyRequested != 0)
+						return;
+				}
+				
+				if(isNeedRendering){
+					if(mRenderWnd != NULL && mRenderWnd->isActive()){
+						mRenderWnd->windowMovedOrResized();
+						mRoot->renderOneFrame();
+					}
+				}else{
+					////usleep(2000); // 2 ms
+					usleep(50000); // 50 ms (20Hz)
+				}
             }
         }
         
@@ -386,6 +465,9 @@
         static Ogre::Root* mRoot;
         static bool mInit;
         
+		static bool isNeedRendering; // NUKE
+		static bool isFocused;           // NUKE
+		
 #ifdef OGRE_STATIC_LIB
         static Ogre::StaticPluginLoader* mStaticPluginLoader;
 #endif


Samples/Browser/src/SampleBrowser.cpp:

Code: Select all

@@ -52,6 +52,8 @@
 Ogre::RenderWindow* OgreAndroidBridge::mRenderWnd = NULL;
 Ogre::Root* OgreAndroidBridge::mRoot = NULL;
 bool OgreAndroidBridge::mInit = false;
+bool OgreAndroidBridge::isNeedRendering=true; // NUKE
+bool OgreAndroidBridge::isFocused=false;// NUKE
 
 #   ifdef OGRE_STATIC_LIB
 StaticPluginLoader* OgreAndroidBridge::mStaticPluginLoader = NULL;
Samples/Character/include/CharacterSample.h (related to this subject - Disabling Depth Buffer Pool) :

Code: Select all

@@ -88,7 +88,8 @@
 		mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5));
 		mSceneMgr->setShadowTextureSize(1024);
 		mSceneMgr->setShadowTextureCount(1);
-
+		mSceneMgr->setShadowTextureConfig(0, 1024,1024,PF_FLOAT32_R,0, 0); // NUKE
+		
 		// disable default camera control so the character can do its own
 		mCameraMan->setStyle(CS_MANUAL); 
Samples/SkeletalAnimation/include/SkeletalAnimation.h:

Code: Select all


@@ -83,7 +83,7 @@
 		mSceneMgr->setShadowTextureSize(512);
 		mSceneMgr->setShadowColour(ColourValue(0.6, 0.6, 0.6));
 		mSceneMgr->setShadowTextureCount(2);
-
+		
 		// add a little ambient lighting
 		mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
 
@@ -134,6 +134,9 @@
 		mCameraMan->setTopSpeed(50);
 
 		setupModels();
+		
+		mSceneMgr->setShadowTextureConfig(0, 512,512,PF_FLOAT32_R,0, 0); // NUKE
+		mSceneMgr->setShadowTextureConfig(1, 512,512,PF_FLOAT32_R,0, 0); // NUKE
 	}
 
 	void setupModels()
@@ -154,8 +157,8 @@
 
 			// create and attach a jaiqua entity
 			ent = mSceneMgr->createEntity("Jaiqua" + StringConverter::toString(i + 1), "jaiqua.mesh");
-
-#ifdef INCLUDE_RTSHADER_SYSTEM
+/*
+#ifdef INCLUDE_RTSHADER_SYSTEM 
             if (mShaderGenerator->getTargetLanguage() == "glsles")
             {
                 MaterialPtr mat = MaterialManager::getSingleton().getByName("jaiqua");
@@ -159,6 +162,6 @@
             if (mShaderGenerator->getTargetLanguage() == "glsles")
             {
                 MaterialPtr mat = MaterialManager::getSingleton().getByName("jaiqua");
-                mat->getTechnique(0)->getPass(0)->setShadowCasterFragmentProgram("Ogre/BasicFragmentPrograms/PassthroughFpGLSLES");
+                mat->getTechnique(0)->getPass(0)->setShadowCasterFragmentProgram("Ogre/BasicFragmentPrograms/PassthroughFpGLSLES");  // NUKE !!!!!!!!!!!! 
             }
 #endif
@@ -163,5 +166,6 @@
             }
 #endif
+*/
             ent->setMaterialName("jaiqua"); //"jaiquaDualQuatTest"
 			sn->attachObject(ent);
 



................................................................
#5 SUMMARY
Disabling depth buffer pool:
1) fixes given issue on Tegra 3 : no crashes on application pause/resume and sample startup, etc.
2) boosts fps almost ~x2 times


THANX AGAIN, dark_sylinc !!!! !!!! !!!! !!!! :D :D :D !

................................................................
#6 Screenshots from my HTC One X:
You do not have the required permissions to view the files attached to this post.
Last edited by nuke on Mon Aug 20, 2018 3:01 pm, edited 4 times in total.
User avatar
TheOnlyJoey
Halfling
Posts: 53
Joined: Sun Apr 10, 2011 12:05 pm
Location: The Netherlands
x 6

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by TheOnlyJoey »

nuke32 wrote: I've edited Ogre sources to solve this problem by disabling depth buffer pool.

#1 Now it starts and works great on my HTC One X (Tegra 3) without crashes on these Samples - Character, Fresnel, Skeletal Animation, and texture shadows are present and almost stable !!!! !!!!
#2 I've got significant FPS boost ~x2 times ( ~30fps --> ~60fps in some cases, and ~13fps --> ~30fps in other cases) because depth buffer pool was disabled !!!! !!!!

#3 Tested on LG L60 X145 (GPU - Mali 400) and HTC One X (GPU - Tegra 3).
In both cases I've got FPS boost ~x2 times !!!!
If the increases are that significant it might be a good idea to do a pull request for this patch.
I had problems with Tegra 3 devices as well regarding the material pipeline and it seems that this could be a solution for that.

@Dark_Sylinc: could you maybe review these changes for 1.10 upstreaming?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

Re: No depth buffer attachments on FBOs on Nexus 7 (Tegra 3)

Post by dark_sylinc »

The crash indeed should something to look after, since it should not crash just because it doesn't have stencil support.
Edit: Seems a fix to that was already included in latest repo.

FBOs must support depth buffers as per GLES 2.0 specification. The OES_depth_texture extension allows reading from the depth buffer like a texture, which is something different.
TheOnlyJoey wrote:If the increases are that significant it might be a good idea to do a pull request for this patch.
I had problems with Tegra 3 devices as well regarding the material pipeline and it seems that this could be a solution for that.

@Dark_Sylinc: could you maybe review these changes for 1.10 upstreaming?
Disabling depth buffer well means... disabling the depth buffer. Meaning no depth buffer at all.

If he still has depth checks, it would be more interesting to know why that happens . If he gets a performance improvements, that's either because depth buffer isn't being used, or because some lower-precision or more compatible depth format is being automatically chosen (by accident).
Tile-based deferred renderers are very susceptible to how depth is being cleared, otherwise the GPU may think the Depth buffer is still needed and flush it to RAM. GLES APIs use heuristics for that. It's possible that his broken code triggers the right heuristics.

The problem is much deeper than it looks and I'm afraid those proposed changes would all but break desktop completely.

Long story short: it's completely broken code. It should not be working as expected. If it works, it should be investigated why it does while improving performance, then fix the code properly while retaining the fast behavior.