summaryrefslogtreecommitdiff
path: root/drivers/gles2
diff options
context:
space:
mode:
authorHolger Dammertz <holger.dammertz@googlemail.com>2019-11-03 17:50:46 +0100
committerHolger Dammertz <holger.dammertz@googlemail.com>2019-11-04 20:14:52 +0100
commit418b035ddaaf9b40892ba88632c3aa6f3bf128b5 (patch)
tree864e7ee1ca4669bed15e2db8355b669d84a7f756 /drivers/gles2
parentdc114fa2ef336646f56d71322ba0236c00f8228e (diff)
fix #33188 MSAA depth buffer not used for external texture
When rendering to an external texture and MSAA was active (as happened in the Oculus Mobile ARVR plugin) no MSAA was rendered as the correct depth buffer and multisample texture target was not used. This also fixes https://github.com/GodotVR/godot_oculus_mobile/issues/54
Diffstat (limited to 'drivers/gles2')
-rw-r--r--drivers/gles2/rasterizer_storage_gles2.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp
index 9d9bceb243..b101a091fe 100644
--- a/drivers/gles2/rasterizer_storage_gles2.cpp
+++ b/drivers/gles2/rasterizer_storage_gles2.cpp
@@ -5156,14 +5156,26 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
// is there a point to setting the internal formats? we don't know them..
- // set our texture as the destination for our framebuffer
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0);
-
- // seeing we're rendering into this directly, better also use our depth buffer, just use our existing one :)
- if (config.support_depth_texture) {
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
+ // check if MSAA is active to set the correct depth buffer and target texture for android
+ if (rt->multisample_active) {
+#if defined(GLES_OVER_GL) || defined(IPHONE_ENABLED)
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, p_texture_id);
+#elif ANDROID_ENABLED
+ static const int msaa_value[] = { 0, 2, 4, 8, 16 };
+ int msaa = msaa_value[rt->msaa];
+ glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0, msaa);
+#endif
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->multisample_depth);
} else {
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
+ // set our texture as the destination for our framebuffer
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0);
+
+ // seeing we're rendering into this directly, better also use our depth buffer, just use our existing one :)
+ if (config.support_depth_texture) {
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, rt->depth, 0);
+ } else {
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
+ }
}
// check status and unbind