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
Member

The previous API for clearing storage buffers was following the OpenGL
api. OpenGL has many options to support for data conversions, striding
and sizzling. Metal and Vulkan don't have these features 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(GPUStorageBuf* ssbo, uint32_t clear_value)

Related issue: #105492

The previous API for clearing storage buffers was following the OpenGL api. OpenGL has many options to support for data conversions, striding and sizzling. Metal and Vulkan don't have these features 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(GPUStorageBuf* ssbo, uint32_t clear_value)` Related issue: #105492
Jeroen Bakker added 1 commit 2023-03-07 09:01:31 +01:00
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
Jeroen Bakker requested review from Clément Foucault 2023-03-07 09:01:37 +01:00
Jeroen Bakker requested review from Bastien Montagne 2023-03-07 09:01:50 +01:00
Jeroen Bakker added this to the 3.6 LTS milestone 2023-03-07 09:02:01 +01:00
Jeroen Bakker added this to the EEVEE & Viewport project 2023-03-07 09:02:07 +01:00
Jeroen Bakker self-assigned this 2023-03-07 09:02:12 +01:00
Author
Member

Currently this fails rendering eevee-next shadows. On linux the OpenGL raises an GL_INVALID_OPERATION. GL_INVALID_OPERATION in glClearNamedBufferData(integer vs non-integer).

Currently this fails rendering eevee-next shadows. On linux the OpenGL raises an GL_INVALID_OPERATION. `GL_INVALID_OPERATION in glClearNamedBufferData(integer vs non-integer)`.
Jeroen Bakker reviewed 2023-03-07 09:43:40 +01:00
Jeroen Bakker left a comment
Author
Member

Eevee-next shadows not working

Eevee-next shadows not working
@ -234,3 +234,3 @@
tiles_tx_.acquire(tiles_extent, GPU_RGBA16F);
GPU_storagebuf_clear_to_zero(tile_indirection_buf_);
tile_indirection_buf_.clear_to_zero();
Author
Member

Apply to main directly (if fine by @fclem )

Apply to main directly (if fine by @fclem )
Jeroen-Bakker marked this conversation as resolved
@ -835,3 +835,3 @@
union {
ShadowTileMapClip clip;
int4 i;
uint4 i;
Author
Member

Partially revert this change.

Partially revert this change.
Jeroen-Bakker marked this conversation as resolved
Jeroen Bakker added 1 commit 2023-03-07 14:39:15 +01:00
Jeroen Bakker added 2 commits 2023-03-07 15:02:10 +01:00
Clément Foucault requested changes 2023-03-07 15:16:34 +01:00
@ -48,0 +47,4 @@
*
* NOTE: clear_data_len must be in range 1 to 4 (inclusive).
*/
void GPU_storagebuf_clear_uint(GPUStorageBuf *ssbo, uint32_t *clear_data, uint8_t clear_data_len);

There is no reason to clear_data_len a uint8_t. Just make it a int type.

There is no reason to `clear_data_len` a `uint8_t`. Just make it a `int` type.
Jeroen-Bakker marked this conversation as resolved
@ -124,2 +124,4 @@
}
GLenum internal_format = GL_R32UI;
GLenum format = GL_RED;

You forgot to change this.

You forgot to change this.
Jeroen-Bakker marked this conversation as resolved
Jeroen Bakker added 1 commit 2023-03-07 15:28:12 +01:00
83b62f2562 Resolve review comments.
- Make clear_data_size an int.
- Use GL_RED_INTEGER when initializing variable.
Clément Foucault approved these changes 2023-03-07 15:37:18 +01:00
Hans Goudey changed title from GPU: Refactor API for Clearing Storage Buffers. to GPU: Refactor API for Clearing Storage Buffers 2023-03-07 15:49:37 +01:00
Jeroen Bakker changed title from GPU: Refactor API for Clearing Storage Buffers to WIP: GPU: Refactor API for Clearing Storage Buffers 2023-03-08 10:02:40 +01:00
Jeroen Bakker added a new dependency 2023-03-08 10:49:08 +01:00
Jeroen Bakker added 4 commits 2023-03-08 14:50:43 +01:00
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
Jeroen Bakker changed title from WIP: GPU: Refactor API for Clearing Storage Buffers to GPU: Refactor API for Clearing Storage Buffers 2023-03-08 14:50:56 +01:00
Jeroen Bakker added 1 commit 2023-03-08 14:54:15 +01:00
Jeroen Bakker added 4 commits 2023-03-09 15:08:22 +01:00
Jeroen Bakker added 1 commit 2023-03-09 18:31:03 +01:00
Clément Foucault merged commit af5a115f65 into main 2023-03-09 18:46:41 +01:00
Jeroen Bakker deleted branch gpu-storage-buffer-clear-api 2023-03-09 18:53:23 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Reference: blender/blender#105521
No description provided.