From 87055dc71b0d50cd25660969b55cda7d44af6a12 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 26 May 2021 16:49:17 +0200 Subject: GPU: Compute Pipeline. With the compute pipeline calculation can be offloaded to the GPU. This patch only adds the framework for compute. So no changes for users at this moment. NOTE: As this is an OpenGL4.3 feature it must always have a fallback. Use `GPU_compute_shader_support` to check if compute pipeline can be used. Check `gpu_shader_compute*` test cases for usage. This patch also adds support for shader storage buffer objects and device only vertex/index buffers. An alternative that had been discussed was adding this to the `GPUBatch`, this was eventually not chosen as it would lead to more code when used as part of a shading group. The idea is that we add an `eDRWCommandType` in the near future. Reviewed By: fclem Differential Revision: https://developer.blender.org/D10913 --- source/blender/gpu/intern/gpu_capabilities_private.hh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/gpu/intern/gpu_capabilities_private.hh') diff --git a/source/blender/gpu/intern/gpu_capabilities_private.hh b/source/blender/gpu/intern/gpu_capabilities_private.hh index 7c1d4590ce8..ee7ef1e69e6 100644 --- a/source/blender/gpu/intern/gpu_capabilities_private.hh +++ b/source/blender/gpu/intern/gpu_capabilities_private.hh @@ -51,6 +51,8 @@ struct GPUCapabilities { const char *(*extension_get)(int); bool mem_stats_support = false; + bool compute_shader_support = false; + bool shader_storage_buffer_objects_support = false; bool shader_image_load_store_support = false; /* OpenGL related workarounds. */ bool mip_render_workaround = false; -- cgit v1.2.3 From 8f9599d17e80254928d2d72081a4c7e0dee64038 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 26 May 2021 17:02:32 +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 tranform feedback. Timings master (transform feedback with GPU_USAGE_STATIC between 0.000069s and 0.000362s Timings transform feedback with GPU_USAGE_DEVICE_ONLY. between 0.000057s and 0.000122s Timings compute shader between 0.000032 and 0.000092s Future improvements: * Generate hair Index buffer using compute shaders: currently done single threaded on CPU, easy to add as compute shader. Reviewed By: fclem Differential Revision: https://developer.blender.org/D11057 --- source/blender/gpu/intern/gpu_capabilities_private.hh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/gpu/intern/gpu_capabilities_private.hh') diff --git a/source/blender/gpu/intern/gpu_capabilities_private.hh b/source/blender/gpu/intern/gpu_capabilities_private.hh index ee7ef1e69e6..95cf7fd335d 100644 --- a/source/blender/gpu/intern/gpu_capabilities_private.hh +++ b/source/blender/gpu/intern/gpu_capabilities_private.hh @@ -41,6 +41,8 @@ struct GPUCapabilities { int max_textures_vert = 0; int max_textures_geom = 0; int max_textures_frag = 0; + int max_work_group_count[3] = {0, 0, 0}; + int max_work_group_size[3] = {0, 0, 0}; int max_uniforms_vert = 0; int max_uniforms_frag = 0; int max_batch_indices = 0; -- cgit v1.2.3 From 2c607ec2f6b9df98da5150ca49e4405385dd4e27 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Wed, 26 May 2021 20:32:05 +0200 Subject: Revert "DrawManager: Use Compute Shader to Update Hair." This reverts commit 8f9599d17e80254928d2d72081a4c7e0dee64038. Mac seems to have an error with this change. ``` ERROR: /Users/blender/git/blender-vdev/blender.git/source/blender/draw/intern/draw_hair.c:115:44: error: use of undeclared identifier 'shader_src' ERROR: /Users/blender/git/blender-vdev/blender.git/source/blender/draw/intern/draw_hair.c:123:13: error: use of undeclared identifier 'shader_src' ERROR: make[2]: *** [source/blender/draw/CMakeFiles/bf_draw.dir/intern/draw_hair.c.o] Error 1 ERROR: make[1]: *** [source/blender/draw/CMakeFiles/bf_draw.dir/all] Error 2 ERROR: make: *** [all] Error 2 ``` --- source/blender/gpu/intern/gpu_capabilities_private.hh | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/gpu/intern/gpu_capabilities_private.hh') diff --git a/source/blender/gpu/intern/gpu_capabilities_private.hh b/source/blender/gpu/intern/gpu_capabilities_private.hh index 95cf7fd335d..ee7ef1e69e6 100644 --- a/source/blender/gpu/intern/gpu_capabilities_private.hh +++ b/source/blender/gpu/intern/gpu_capabilities_private.hh @@ -41,8 +41,6 @@ struct GPUCapabilities { int max_textures_vert = 0; int max_textures_geom = 0; int max_textures_frag = 0; - int max_work_group_count[3] = {0, 0, 0}; - int max_work_group_size[3] = {0, 0, 0}; int max_uniforms_vert = 0; int max_uniforms_frag = 0; int max_batch_indices = 0; -- cgit v1.2.3 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/gpu/intern/gpu_capabilities_private.hh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/gpu/intern/gpu_capabilities_private.hh') diff --git a/source/blender/gpu/intern/gpu_capabilities_private.hh b/source/blender/gpu/intern/gpu_capabilities_private.hh index ee7ef1e69e6..95cf7fd335d 100644 --- a/source/blender/gpu/intern/gpu_capabilities_private.hh +++ b/source/blender/gpu/intern/gpu_capabilities_private.hh @@ -41,6 +41,8 @@ struct GPUCapabilities { int max_textures_vert = 0; int max_textures_geom = 0; int max_textures_frag = 0; + int max_work_group_count[3] = {0, 0, 0}; + int max_work_group_size[3] = {0, 0, 0}; int max_uniforms_vert = 0; int max_uniforms_frag = 0; int max_batch_indices = 0; -- cgit v1.2.3