Skip to content

Commit

Permalink
Merge pull request #33291 from NeoSpark314/fix_#33188
Browse files Browse the repository at this point in the history
fix #33188 MSAA depth buffer not used for external texture
  • Loading branch information
akien-mga committed Nov 8, 2019
2 parents 665ee70 + 418b035 commit a3ac7a9
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions drivers/gles2/rasterizer_storage_gles2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a3ac7a9

Please sign in to comment.