GPU: Refactor API for Clearing Storage Buffers #105521

Merged
Clément Foucault merged 15 commits from Jeroen-Bakker/blender:gpu-storage-buffer-clear-api into main 2023-03-09 18:46:41 +01:00

15 Commits

Author SHA1 Message Date
Jeroen Bakker 31e4936a97 Merge branch 'main' into gpu-storage-buffer-clear-api 2023-03-09 18:30:56 +01:00
Jeroen Bakker 945022a931 Merge branch 'eevee-next-init-shadow-clip-buffer' into gpu-storage-buffer-clear-api 2023-03-09 15:08:06 +01:00
Jeroen Bakker 556ef545b3 Merge branch 'main' into eevee-next-init-shadow-clip-buffer 2023-03-09 15:06:50 +01:00
Jeroen Bakker 05d98893d1 Merge branch 'main' into eevee-next-init-shadow-clip-buffer 2023-03-09 07:59:13 +01:00
Jeroen Bakker 27fab835cf Limit to the number of items to clear. 2023-03-09 07:58:20 +01:00
Jeroen Bakker f24852e13c Merge branch 'main' into gpu-storage-buffer-clear-api 2023-03-08 14:53:59 +01:00
Jeroen Bakker 0bc9e2e661 Fix incorrect parameters in OpenGL storage buffer clear. 2023-03-08 14:49:32 +01:00
Jeroen Bakker dc13925901 Updated API to only support a single 32bit value. 2023-03-08 14:48:11 +01:00
Jeroen Bakker f9fec1abdc Merge branch 'eevee-next-init-shadow-clip-buffer' into gpu-storage-buffer-clear-api 2023-03-08 14:31:45 +01:00
Jeroen Bakker 3739fc7aea Eevee-next: Use Compute Shader to Clear Clipmaps.
Clearing of clipmaps is the only place in Blender that uses non
uniform data (not all components of the cleared data to be exact
the same).

Vulkan has only the possibility to clear buffers with using a single
uint32_t. There were two solutions:
- Add compute shader to Vulkan backend.
- Make Eevee-next responsible to clear the clipmaps.

When fixing this in the Vulkan backend it could lead to other issues
as the backend isn't aware what is exactly required and might overwrite
active bindings. We chose to make it a responsibility of Eevee-next
as there it is clear what is needed.

Related issue: #105492
2023-03-08 10:40:59 +01:00
Jeroen Bakker 83b62f2562 Resolve review comments.
- Make clear_data_size an int.
- Use GL_RED_INTEGER when initializing variable.
2023-03-07 15:27:12 +01:00
Jeroen Bakker 1967026b22 Fix Shadow rendering in Eevee-next/Workbench-next.
Used the integer gl formats and not the float ones.
2023-03-07 15:01:10 +01:00
Jeroen Bakker 04aa6f381e Revert partial change in eevee-next shadows. 2023-03-07 14:45:07 +01:00
Jeroen Bakker 57004af96e Revert cleanup change. 2023-03-07 14:38:58 +01:00
Jeroen Bakker 96af333650 GPU: Refactor API for Clearing Storage Buffers.
The previous API for clearing storage buffers was extracted from OpenGL.
OpenGL has many options to support for data conversions, striding and
sizzling. Metal and Vulkan don't have this inside the API and we have to
deal it ourselves.

Blender internally only uses a tiny subset for what is possible in OpenGL.
making the current API to difficult to implement on our future platforms
as we had to implement all cases, most even not used at all.

By changing the API we make future development easier as we only need to
implement what we are actually using.

*New API*

`GPU_storagebuf_clear_int(GPUStorageBuf* ssbo, int32_t* clear_data,
                          uint8_t clear_data_len);`
`GPU_storagebuf_clear_uint(GPUStorageBuf* ssbo, uint32_t* clear_data,
                           uint8_t clear_data_len);`

Related issue: #105492
2023-03-07 08:51:47 +01:00