summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2021-07-15 10:16:39 -0300
committerGitHub <noreply@github.com>2021-07-15 10:16:39 -0300
commit3f12765a7e3489d1d3b687c84efbfcab58442bc9 (patch)
treeaa9e193841a52fdf07bbf6fe104535261bf098aa
parentf79e79d479e687cbc8448bf38dec62491e85c88b (diff)
parent8a29208fc47a76510bf56045a64f038054098249 (diff)
Merge pull request #49678 from BastiaanOlij/mobile_renderer_select_color_format
Use 32bit instead of 64bit 3D render buffer on mobile renderer
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp15
-rw-r--r--servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h2
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp8
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.h1
4 files changed, 22 insertions, 4 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 29cb597798..03419ec8f5 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
@@ -65,9 +65,13 @@ void RenderForwardMobile::RenderBufferDataForwardMobile::configure(RID p_color_b
color = p_color_buffer;
depth = p_depth_buffer;
- // re-introduce setting up msaa? For now we ignore this...
+ RD::DataFormat color_format = RenderForwardMobile::singleton->_render_buffers_get_color_format();
if (p_msaa == RS::VIEWPORT_MSAA_DISABLED) {
+ if (color_format == RD::DATA_FORMAT_B10G11R11_UFLOAT_PACK32) {
+ // @TODO add a second color buffer for alpha as this format is RGB only
+ }
+
Vector<RID> fb;
fb.push_back(p_color_buffer);
fb.push_back(depth);
@@ -80,7 +84,7 @@ void RenderForwardMobile::RenderBufferDataForwardMobile::configure(RID p_color_b
} else {
tf.texture_type = RD::TEXTURE_TYPE_2D;
}
- tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
+ tf.format = color_format;
tf.width = p_width;
tf.height = p_height;
tf.array_layers = view_count; // create a layer for every view
@@ -131,6 +135,13 @@ bool RenderForwardMobile::free(RID p_rid) {
/* Render functions */
+RD::DataFormat RenderForwardMobile::_render_buffers_get_color_format() {
+ // Using 32bit buffers enables AFBC on mobile devices which should have a definate performance improvement (MALI G710 and newer support this on 64bit RTs)
+ // NO ALPHA and unsigned float.
+ // @TODO No alpha is an issue, recommendation here is to add a second RT for alpha
+ return RD::DATA_FORMAT_B10G11R11_UFLOAT_PACK32;
+}
+
RID RenderForwardMobile::_setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas, int p_index) {
//there should always be enough uniform buffers for render passes, otherwise bugs
ERR_FAIL_INDEX_V(p_index, (int)scene_state.uniform_buffers.size(), RID());
diff --git a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h
index 53650a7a5e..bf3aa7ed5c 100644
--- a/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h
+++ b/servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.h
@@ -151,6 +151,8 @@ protected:
}
};
+ virtual RD::DataFormat _render_buffers_get_color_format() override;
+
RID _setup_render_pass_uniform_set(RenderListType p_render_list, const RenderDataRD *p_render_data, RID p_radiance_texture, bool p_use_directional_shadow_atlas = false, int p_index = 0);
virtual void _render_scene(RenderDataRD *p_render_data, const Color &p_default_bg_color) override;
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index 3b7c14d4ff..9b32971e30 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -654,7 +654,7 @@ bool RendererSceneRenderRD::reflection_probe_instance_begin_render(RID p_instanc
//reflection atlas was unused, create:
RD::TextureFormat tf;
tf.array_layers = 6 * atlas->count;
- tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
+ tf.format = _render_buffers_get_color_format();
tf.texture_type = RD::TEXTURE_TYPE_CUBE_ARRAY;
tf.mipmaps = mipmaps;
tf.width = atlas->size;
@@ -2118,6 +2118,10 @@ float RendererSceneRenderRD::render_buffers_get_volumetric_fog_detail_spread(RID
return rb->volumetric_fog->spread;
}
+RD::DataFormat RendererSceneRenderRD::_render_buffers_get_color_format() {
+ return RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
+}
+
void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RenderingServer::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) {
ERR_FAIL_COND_MSG(p_view_count == 0, "Must have atleast 1 view");
@@ -2144,7 +2148,7 @@ void RendererSceneRenderRD::render_buffers_configure(RID p_render_buffers, RID p
if (rb->view_count > 1) {
tf.texture_type = RD::TEXTURE_TYPE_2D_ARRAY;
}
- tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
+ tf.format = _render_buffers_get_color_format();
tf.width = rb->width;
tf.height = rb->height;
tf.array_layers = rb->view_count; // create a layer for every view
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
index 69c56cf4a7..58d9a765d0 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
@@ -1130,6 +1130,7 @@ public:
/* render buffers */
+ virtual RD::DataFormat _render_buffers_get_color_format();
virtual RID render_buffers_create() override;
virtual void render_buffers_configure(RID p_render_buffers, RID p_render_target, int p_width, int p_height, RS::ViewportMSAA p_msaa, RS::ViewportScreenSpaceAA p_screen_space_aa, bool p_use_debanding, uint32_t p_view_count) override;
virtual void gi_set_use_half_resolution(bool p_enable) override;