summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2023-03-01 18:59:59 +1100
committerYuri Sizov <yuris@humnom.net>2023-03-13 21:48:02 +0100
commitc8f64c68a5437242212311afa3dc83cac754fc43 (patch)
tree7525d304a01335317d1868a4149cabf9221108b7 /servers
parent4e90cc55ecf379a7cfe426fa7263cc604220b644 (diff)
Use MSAA 2D texture in multipass tonemapper
(cherry picked from commit 903aa0e385ac79ca747029c0e12823b2671304a8)
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp12
-rw-r--r--servers/rendering/renderer_rd/storage_rd/texture_storage.cpp7
-rw-r--r--servers/rendering/renderer_rd/storage_rd/texture_storage.h1
3 files changed, 17 insertions, 3 deletions
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
index 6c39560729..6bfbc2e0a7 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -271,7 +271,12 @@ RID RenderForwardMobile::RenderBufferDataForwardMobile::get_color_fbs(Framebuffe
// - add blit to 2D pass
RID render_target = render_buffers->get_render_target();
ERR_FAIL_COND_V(render_target.is_null(), RID());
- RID target_buffer = texture_storage->render_target_get_rd_texture(render_target);
+ RID target_buffer;
+ if (texture_storage->render_target_get_msaa(render_target) == RS::VIEWPORT_MSAA_DISABLED) {
+ target_buffer = texture_storage->render_target_get_rd_texture(render_target);
+ } else {
+ target_buffer = texture_storage->render_target_get_rd_texture_msaa(render_target);
+ }
ERR_FAIL_COND_V(target_buffer.is_null(), RID());
int target_buffer_id = textures.size();
@@ -742,14 +747,15 @@ void RenderForwardMobile::_render_scene(RenderDataRD *p_render_data, const Color
}
// We do this last because our get_color_fbs creates and caches the framebuffer if we need it.
- if (using_subpass_post_process && rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_FOUR_SUBPASSES).is_null()) {
+ RID four_subpasses = rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_FOUR_SUBPASSES);
+ if (using_subpass_post_process && four_subpasses.is_null()) {
// can't do blit subpass because we don't have all subpasses
using_subpass_post_process = false;
}
if (using_subpass_post_process) {
// all as subpasses
- framebuffer = rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_FOUR_SUBPASSES);
+ framebuffer = four_subpasses;
} else if (using_subpass_transparent) {
// our tonemap pass is separate
framebuffer = rb_data->get_color_fbs(RenderBufferDataForwardMobile::FB_CONFIG_THREE_SUBPASSES);
diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
index a1346661e1..1aab52d1c3 100644
--- a/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.cpp
@@ -2911,6 +2911,13 @@ RID TextureStorage::render_target_get_rd_texture_slice(RID p_render_target, uint
}
}
+RID TextureStorage::render_target_get_rd_texture_msaa(RID p_render_target) {
+ RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
+ ERR_FAIL_COND_V(!rt, RID());
+
+ return rt->color_multisample;
+}
+
RID TextureStorage::render_target_get_rd_backbuffer(RID p_render_target) {
RenderTarget *rt = render_target_owner.get_or_null(p_render_target);
ERR_FAIL_COND_V(!rt, RID());
diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h
index b6bb9fa52f..f710de1100 100644
--- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h
@@ -741,6 +741,7 @@ public:
RID render_target_get_rd_framebuffer(RID p_render_target);
RID render_target_get_rd_texture(RID p_render_target);
RID render_target_get_rd_texture_slice(RID p_render_target, uint32_t p_layer);
+ RID render_target_get_rd_texture_msaa(RID p_render_target);
RID render_target_get_rd_backbuffer(RID p_render_target);
RID render_target_get_rd_backbuffer_framebuffer(RID p_render_target);