diff options
author | Bastiaan Olij <mux213@gmail.com> | 2021-06-17 20:37:08 +1000 |
---|---|---|
committer | Bastiaan Olij <mux213@gmail.com> | 2021-07-13 10:26:28 +1000 |
commit | 8a29208fc47a76510bf56045a64f038054098249 (patch) | |
tree | 43a0116ba0b07406546c1077bf7dc42496cc246f | |
parent | fc00a8390193220cea702d9ab684fb6c53d97a6b (diff) |
Use 32bit instead of 64bit 3D render buffer on mobile
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 7fbd6e23b0..4c7bf1b490 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 f40f713c03..687b79b1c4 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 a70514e9e5..0e1b38312a 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 be3d3551c7..c83cb24d93 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -1129,6 +1129,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; |