Merge pull request #33444 from BastiaanOlij/external_msaa
Make MSAA in GLES2 work with external textures for VR
This commit is contained in:
commit
28294b1f19
|
@ -2767,6 +2767,8 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
|
||||||
|
|
||||||
if (use_post_process) {
|
if (use_post_process) {
|
||||||
next_buffer = storage->frame.current_rt->mip_maps[0].sizes[0].fbo;
|
next_buffer = storage->frame.current_rt->mip_maps[0].sizes[0].fbo;
|
||||||
|
} else if (storage->frame.current_rt->external.fbo != 0) {
|
||||||
|
next_buffer = storage->frame.current_rt->external.fbo;
|
||||||
} else {
|
} else {
|
||||||
// set next_buffer to front buffer so multisample blit can happen if needed
|
// set next_buffer to front buffer so multisample blit can happen if needed
|
||||||
next_buffer = storage->frame.current_rt->fbo;
|
next_buffer = storage->frame.current_rt->fbo;
|
||||||
|
@ -2795,10 +2797,16 @@ void RasterizerSceneGLES2::_post_process(Environment *env, const CameraMatrix &p
|
||||||
|
|
||||||
// In GLES2 Android Blit is not available, so just copy color texture manually
|
// In GLES2 Android Blit is not available, so just copy color texture manually
|
||||||
_copy_texture_to_buffer(storage->frame.current_rt->multisample_color, next_buffer);
|
_copy_texture_to_buffer(storage->frame.current_rt->multisample_color, next_buffer);
|
||||||
|
#else
|
||||||
|
// TODO: any other platform not supported? this will fail.. maybe we should just call _copy_texture_to_buffer here as well?
|
||||||
#endif
|
#endif
|
||||||
} else if (use_post_process) {
|
} else if (use_post_process) {
|
||||||
|
if (storage->frame.current_rt->external.fbo != 0) {
|
||||||
|
_copy_texture_to_buffer(storage->frame.current_rt->external.color, storage->frame.current_rt->mip_maps[0].sizes[0].fbo);
|
||||||
|
} else {
|
||||||
_copy_texture_to_buffer(storage->frame.current_rt->color, storage->frame.current_rt->mip_maps[0].sizes[0].fbo);
|
_copy_texture_to_buffer(storage->frame.current_rt->color, storage->frame.current_rt->mip_maps[0].sizes[0].fbo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!use_post_process) {
|
if (!use_post_process) {
|
||||||
return;
|
return;
|
||||||
|
@ -3220,15 +3228,13 @@ void RasterizerSceneGLES2::render_scene(const Transform &p_cam_transform, const
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
state.render_no_shadows = false;
|
state.render_no_shadows = false;
|
||||||
if (storage->frame.current_rt->external.fbo != 0) {
|
|
||||||
current_fb = storage->frame.current_rt->external.fbo;
|
|
||||||
} else {
|
|
||||||
if (storage->frame.current_rt->multisample_active) {
|
if (storage->frame.current_rt->multisample_active) {
|
||||||
current_fb = storage->frame.current_rt->multisample_fbo;
|
current_fb = storage->frame.current_rt->multisample_fbo;
|
||||||
|
} else if (storage->frame.current_rt->external.fbo != 0) {
|
||||||
|
current_fb = storage->frame.current_rt->external.fbo;
|
||||||
} else {
|
} else {
|
||||||
current_fb = storage->frame.current_rt->fbo;
|
current_fb = storage->frame.current_rt->fbo;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
env = environment_owner.getornull(p_environment);
|
env = environment_owner.getornull(p_environment);
|
||||||
|
|
||||||
viewport_width = storage->frame.current_rt->width;
|
viewport_width = storage->frame.current_rt->width;
|
||||||
|
|
|
@ -5156,17 +5156,6 @@ 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..
|
// is there a point to setting the internal formats? we don't know them..
|
||||||
|
|
||||||
// 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 {
|
|
||||||
// set our texture as the destination for our framebuffer
|
// set our texture as the destination for our framebuffer
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, p_texture_id, 0);
|
||||||
|
|
||||||
|
@ -5176,7 +5165,6 @@ void RasterizerStorageGLES2::render_target_set_external_texture(RID p_render_tar
|
||||||
} else {
|
} else {
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check status and unbind
|
// check status and unbind
|
||||||
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
|
|
Loading…
Reference in New Issue