diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-02-04 17:19:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 17:19:35 +0100 |
commit | 2ba66c1457850fa0eb6e1c8d144e311d2b59619a (patch) | |
tree | 56948448bed54f75ef4bee8e7a50faea464a68c8 /servers/rendering/renderer_rd/cluster_builder_rd.cpp | |
parent | a405a249a60fc6b88b0c2880d85dc6dc9c1d3e10 (diff) | |
parent | f20999f6feba2af6ae7d246c40fcfc5404bdd429 (diff) |
Merge pull request #45672 from reduz/barrier-optimization
Rewrote how barriers work for faster rendering
Diffstat (limited to 'servers/rendering/renderer_rd/cluster_builder_rd.cpp')
-rw-r--r-- | servers/rendering/renderer_rd/cluster_builder_rd.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/servers/rendering/renderer_rd/cluster_builder_rd.cpp b/servers/rendering/renderer_rd/cluster_builder_rd.cpp index c35e5e1730..e052a2b0ce 100644 --- a/servers/rendering/renderer_rd/cluster_builder_rd.cpp +++ b/servers/rendering/renderer_rd/cluster_builder_rd.cpp @@ -400,12 +400,14 @@ void ClusterBuilderRD::begin(const Transform &p_view_transform, const CameraMatr void ClusterBuilderRD::bake_cluster() { RENDER_TIMESTAMP(">Bake Cluster"); + RD::get_singleton()->draw_command_begin_label("Bake Light Cluster"); + //clear cluster buffer - RD::get_singleton()->buffer_clear(cluster_buffer, 0, cluster_buffer_size); + RD::get_singleton()->buffer_clear(cluster_buffer, 0, cluster_buffer_size, 0); if (render_element_count > 0) { //clear render buffer - RD::get_singleton()->buffer_clear(cluster_render_buffer, 0, cluster_render_buffer_size); + RD::get_singleton()->buffer_clear(cluster_render_buffer, 0, cluster_render_buffer_size, 0); { //fill state uniform @@ -420,15 +422,16 @@ void ClusterBuilderRD::bake_cluster() { state.cluster_depth_offset = (render_element_max / 32); state.cluster_data_size = state.cluster_depth_offset + render_element_max; - RD::get_singleton()->buffer_update(state_uniform, 0, sizeof(StateUniform), &state); + RD::get_singleton()->buffer_update(state_uniform, 0, sizeof(StateUniform), &state, 0); } //update instances - RD::get_singleton()->buffer_update(element_buffer, 0, sizeof(RenderElementData) * render_element_count, render_elements); + RD::get_singleton()->buffer_update(element_buffer, 0, sizeof(RenderElementData) * render_element_count, render_elements, 0); RENDER_TIMESTAMP("Render Elements"); + RD::get_singleton()->barrier(RD::BARRIER_MASK_TRANSFER, RD::BARRIER_MASK_RASTER); //render elements { RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(framebuffer, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD, RD::INITIAL_ACTION_DROP, RD::FINAL_ACTION_DISCARD); @@ -469,7 +472,7 @@ void ClusterBuilderRD::bake_cluster() { RD::get_singleton()->draw_list_draw(draw_list, true, instances); i += instances; } - RD::get_singleton()->draw_list_end(); + RD::get_singleton()->draw_list_end(RD::BARRIER_MASK_COMPUTE); } //store elements RENDER_TIMESTAMP("Pack Elements"); @@ -491,12 +494,15 @@ void ClusterBuilderRD::bake_cluster() { RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(ClusterBuilderSharedDataRD::ClusterStore::PushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, cluster_screen_size.x, cluster_screen_size.y, 1, 8, 8, 1); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, cluster_screen_size.x, cluster_screen_size.y, 1); - RD::get_singleton()->compute_list_end(); + RD::get_singleton()->compute_list_end(RD::BARRIER_MASK_RASTER | RD::BARRIER_MASK_COMPUTE); } + } else { + RD::get_singleton()->barrier(RD::BARRIER_MASK_TRANSFER, RD::BARRIER_MASK_RASTER | RD::BARRIER_MASK_COMPUTE); } RENDER_TIMESTAMP("<Bake Cluster"); + RD::get_singleton()->draw_command_end_label(); } void ClusterBuilderRD::debug(ElementType p_element) { @@ -519,7 +525,7 @@ void ClusterBuilderRD::debug(ElementType p_element) { RD::get_singleton()->compute_list_set_push_constant(compute_list, &push_constant, sizeof(ClusterBuilderSharedDataRD::ClusterDebug::PushConstant)); - RD::get_singleton()->compute_list_dispatch_threads(compute_list, screen_size.x, screen_size.y, 1, 8, 8, 1); + RD::get_singleton()->compute_list_dispatch_threads(compute_list, screen_size.x, screen_size.y, 1); RD::get_singleton()->compute_list_end(); } |