how to create GL_DEPTH24_STENCIL8_OES tex ?

Hi,





I am trying to create a depth24_stencil8 texture for my framebuffer. I need it to be a texture and not render buffer.


here is the code for it





////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


glGenFramebuffers(1, &preLightFBO);


glBindFramebuffer(GL_FRAMEBUFFER, preLightFBO);








glGenTextures(1, &preLight_depthTex);


glBindTexture(GL_TEXTURE_2D, preLight_depthTex);





glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8_OES, prePassBuffersWidth, prePassBuffersHeight, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 0);


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);





glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, preLight_depthTex, 0);


glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,GL_TEXTURE_2D, preLight_depthTex, 0);


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////





I am getting GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT. I check with glError after glTexImage2D, I get GL_INVALID_OPERATION.





Using these params


glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, prePassBuffersWidth, prePassBuffersHeight, 0, GL_DEPTH_STENCIL_OES , GL_UNSIGNED_INT_24_8_OES, NULL)





I get GL_INVALID_VALUE





I am not doing anything different than whats here


http://www.khronos.org/registry/gles/extensions/OES/OES_packed_depth_stencil.txt








Can someone please help me understand why this will not work ?





Hi,





Your call to glTexImage2D has GL_DEPTH24_STENCIL8_OES as <internalFormat>. According to the spec, only GL_DEPTH_STENCIL_OES is valid. GL_DEPTH24_STENCIL8_OES is valid as <internalFormat> for glRenderbufferStorage.

Hi,





Thanks for the reply !


Doing


glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, prePassBuffersWidth, prePassBuffersHeight, 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 0);


     


is giving me GL_INVALID_VALUE.





What would cause this then ?

Hi,

do you need the stencil buffer at all?
Have you checked that the OES_packed_depth_stencil externsion is supported on your device?

If you don’t need the stencil buffer, we’ve got an example in our SDK that boils down to:

//Create the shadow map texture
glGenTextures(1, &m_uiShadowMapTexture);
glBindTexture(GL_TEXTURE_2D, m_uiShadowMapTexture);

// Create the depth texture.
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_ui32ShadowMapSize, m_ui32ShadowMapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
[…]
glGenFramebuffers(1, &m_uiFrameBufferObject);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_uiShadowMapTexture, 0);



Hi Marco,





I have the depth component based FBO texture working and I do need the stencil bufffer for this case.


My target device is iPhone and iPad which I am sure supports the stencil buffer.





I am running the PVR SDK windows emulation. What I don’t understand is why


CPVRTgles2Ext::IsGLExtensionSupported(“GL_OES_packed_depth_stencil”) is returning false on my PC. My graphic card supports shader model 4.0 and even DX9 supports the packed depth stencil !!











Hi mkandula,

the emulation only exposes extensions that are actually available on PowerVR platforms.



mkandula, what version of the SDK are you using?

OGLES2_WINDOWS_X86EMULATION_2.08.28.0634





mkandula,
Could you download and install the most recent SDK version (2.09.29.0649) and try again?
It should be supported in that release.

Edit : Whoops, Marco beat me to it.





GL_OES_packed_depth_stencil was introduced in the 2.9 version of VFrame so you will need to upgrade to use that extension.peter.quayle2012-02-14 13:13:53

But can someone tell me if this feature is supported on iPad and iPhone4 atleast ?





A good way to check these things is to take a look at the GLBenchmark website.





Here is the page to the iPhone4 GL environment: http://www.glbenchmark.com/phonedetails.jsp?benchmark=glpro21&D=Apple+iPhone+4&testgroup=gl.





In this case, the iPhone4 does indeed support GL_OES_packed_depth_stencil.





You should be able to find all major consumer devices on that website.

Wohoo !! updating sorted this issue out !!


You guys are the GODs of PVR !!





Thank you very much !