@@ -58,19 +58,19 @@ RenderSceneBuffersGLES3::~RenderSceneBuffersGLES3() {
5858 free_render_buffer_data ();
5959}
6060
61- void RenderSceneBuffersGLES3::_rt_attach_textures (GLuint p_color, GLuint p_depth, GLsizei p_samples, uint32_t p_view_count) {
61+ void RenderSceneBuffersGLES3::_rt_attach_textures (GLuint p_color, GLuint p_depth, GLsizei p_samples, uint32_t p_view_count, bool p_depth_has_stencil ) {
6262 if (p_view_count > 1 ) {
6363 if (p_samples > 1 ) {
6464#if defined(ANDROID_ENABLED) || defined(WEB_ENABLED)
6565 glFramebufferTextureMultisampleMultiviewOVR (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, p_color, 0 , p_samples, 0 , p_view_count);
66- glFramebufferTextureMultisampleMultiviewOVR (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, p_depth, 0 , p_samples, 0 , p_view_count);
66+ glFramebufferTextureMultisampleMultiviewOVR (GL_FRAMEBUFFER, p_depth_has_stencil ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT , p_depth, 0 , p_samples, 0 , p_view_count);
6767#else
6868 ERR_PRINT_ONCE (" Multiview MSAA isn't supported on this platform." );
6969#endif
7070 } else {
7171#ifndef IOS_ENABLED
7272 glFramebufferTextureMultiviewOVR (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, p_color, 0 , 0 , p_view_count);
73- glFramebufferTextureMultiviewOVR (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, p_depth, 0 , 0 , p_view_count);
73+ glFramebufferTextureMultiviewOVR (GL_FRAMEBUFFER, p_depth_has_stencil ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT , p_depth, 0 , 0 , p_view_count);
7474#else
7575 ERR_PRINT_ONCE (" Multiview isn't supported on this platform." );
7676#endif
@@ -79,13 +79,13 @@ void RenderSceneBuffersGLES3::_rt_attach_textures(GLuint p_color, GLuint p_depth
7979 if (p_samples > 1 ) {
8080#ifdef ANDROID_ENABLED
8181 glFramebufferTexture2DMultisampleEXT (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_color, 0 , p_samples);
82- glFramebufferTexture2DMultisampleEXT (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, p_depth, 0 , p_samples);
82+ glFramebufferTexture2DMultisampleEXT (GL_FRAMEBUFFER, p_depth_has_stencil ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT , GL_TEXTURE_2D, p_depth, 0 , p_samples);
8383#else
8484 ERR_PRINT_ONCE (" MSAA via EXT_multisampled_render_to_texture isn't supported on this platform." );
8585#endif
8686 } else {
8787 glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_color, 0 );
88- glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, p_depth, 0 );
88+ glFramebufferTexture2D (GL_FRAMEBUFFER, p_depth_has_stencil ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT , GL_TEXTURE_2D, p_depth, 0 );
8989 }
9090 }
9191}
@@ -107,7 +107,7 @@ GLuint RenderSceneBuffersGLES3::_rt_get_cached_fbo(GLuint p_color, GLuint p_dept
107107 glGenFramebuffers (1 , &new_fbo.fbo );
108108 glBindFramebuffer (GL_FRAMEBUFFER, new_fbo.fbo );
109109
110- _rt_attach_textures (p_color, p_depth, p_samples, p_view_count);
110+ _rt_attach_textures (p_color, p_depth, p_samples, p_view_count, true );
111111
112112 GLenum status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
113113 if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -383,7 +383,7 @@ void RenderSceneBuffersGLES3::_check_render_buffers() {
383383 glGenFramebuffers (1 , &msaa3d.fbo );
384384 glBindFramebuffer (GL_FRAMEBUFFER, msaa3d.fbo );
385385
386- _rt_attach_textures (internal3d.color , internal3d.depth , msaa3d.samples , view_count);
386+ _rt_attach_textures (internal3d.color , internal3d.depth , msaa3d.samples , view_count, true );
387387
388388 GLenum status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
389389 if (status != GL_FRAMEBUFFER_COMPLETE) {
@@ -662,9 +662,10 @@ GLuint RenderSceneBuffersGLES3::get_render_fbo() {
662662 if (texture_storage->render_target_is_reattach_textures (render_target)) {
663663 GLuint color = texture_storage->render_target_get_color (render_target);
664664 GLuint depth = texture_storage->render_target_get_depth (render_target);
665+ bool depth_has_stencil = texture_storage->render_target_get_depth_has_stencil (render_target);
665666
666667 glBindFramebuffer (GL_FRAMEBUFFER, rt_fbo);
667- _rt_attach_textures (color, depth, msaa3d.samples , view_count);
668+ _rt_attach_textures (color, depth, msaa3d.samples , view_count, depth_has_stencil );
668669 glBindFramebuffer (GL_FRAMEBUFFER, texture_storage->system_fbo );
669670 }
670671
0 commit comments