From 6b03621c018acc3b343caa1d8d2aad746fcffc08 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 28 May 2021 08:16:26 +0200 Subject: DrawManager: Use Compute Shader to Update Hair. This patch will use compute shaders to create the VBO for hair. The previous implementation uses transform feedback. Timings before: between 0.000069s and 0.000362s. Timings after: between 0.000032s and 0.000092s. Speedup isn't noticeable by end-users. The patch is used to test the new compute shader pipeline and integrate it with the draw manager. Allowing EEVEE, Workbench and other draw engines to use compute shaders with the introduction of `DRW_shgroup_call_compute` and `DRW_shgroup_vertex_buffer`. Future improvements are possible by generating the index buffer of hair directly on the GPU. NOTE: that compute shaders aren't supported by Apple and still use the transform feedback workaround. Reviewed By: fclem Differential Revision: https://developer.blender.org/D11057 --- source/blender/draw/intern/draw_manager_exec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/draw/intern/draw_manager_exec.c') diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 4c8fcb0e016..f29caebeb84 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -29,6 +29,7 @@ #include "BKE_global.h" +#include "GPU_compute.h" #include "GPU_platform.h" #include "GPU_shader.h" #include "GPU_state.h" @@ -672,6 +673,9 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup, *use_tfeedback = GPU_shader_transform_feedback_enable(shgroup->shader, ((GPUVertBuf *)uni->pvalue)); break; + case DRW_UNIFORM_VERTEX_BUFFER_AS_STORAGE: + GPU_vertbuf_bind_as_ssbo((GPUVertBuf *)uni->pvalue, uni->location); + break; /* Legacy/Fallback support. */ case DRW_UNIFORM_BASE_INSTANCE: state->baseinst_loc = uni->location; @@ -1050,6 +1054,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) cmd->instance_range.inst_count, false); break; + case DRW_CMD_COMPUTE: + GPU_compute_dispatch(shgroup->shader, + cmd->compute.groups_x_len, + cmd->compute.groups_y_len, + cmd->compute.groups_z_len); + break; } } -- cgit v1.2.3