GPU: New API for clearing SSBOs #105492

Closed
opened 2023-03-06 16:07:59 +01:00 by Jeroen Bakker · 2 comments
Member

Current GPU_storagebuf_clear uses texture format to determine the size of the data to clear. But this results in confusion and additional development inside the gpu backends that isn't actually used.

Proposal would be to have a public function to clear storage buffer based on a int or float with a specific number of elements given to the function.

GPU_storagebuf_clear_int(GPUStorageBuf* ssbo, int32_t* clear_data, int clear_data_len);
GPU_storagebuf_clear_uint(GPUStorageBuf* ssbo, uint32_t* clear_data, int clear_data_len);
GPU_storagebuf_clear_float(GPUStorageBuf* ssbo, float* clear_data, int clear_data_len);

[x] We should check the actual usage, perhaps the next API should be sufficient and optimum as clearing buffers is only supported for 32bit clear data.
GPU_storagebuf_clear_int(GPUStorageBuf* ssbo, int clear_data);
GPU_storagebuf_clear_float(GPUStorageBuf* ssbo, float clear_data);

This should be done before the metal/vulkan ssbo support as it will reduce the complexity of those code-paths.

Usage

Eevee-next shadow mapping uses a non-uniform clearing of an ssbo and requires the clear_data_len.

 union {
      ShadowTileMapClip clip;
      int4 i;
    } u;
    u.clip.clip_near_stored = 0.0f;
    u.clip.clip_far_stored = 0.0f;
    u.clip.clip_near = int(0xFF7FFFFFu ^ 0x7FFFFFFFu); /* floatBitsToOrderedInt(-FLT_MAX) */
    u.clip.clip_far = 0x7F7FFFFF;                      /* floatBitsToOrderedInt(FLT_MAX) */
    GPU_storagebuf_clear(tilemap_pool.tilemaps_clip, GPU_RGBA32I, GPU_DATA_INT, &u.i);
    ```
 All other usages uses a uniform clear (-1 as uint or int)
Current `GPU_storagebuf_clear` uses texture format to determine the size of the data to clear. But this results in confusion and additional development inside the gpu backends that isn't actually used. Proposal would be to have a public function to clear storage buffer based on a int or float with a specific number of elements given to the function. `GPU_storagebuf_clear_int(GPUStorageBuf* ssbo, int32_t* clear_data, int clear_data_len);` `GPU_storagebuf_clear_uint(GPUStorageBuf* ssbo, uint32_t* clear_data, int clear_data_len);` ~~`GPU_storagebuf_clear_float(GPUStorageBuf* ssbo, float* clear_data, int clear_data_len);`~~ [x] ~~We should check the actual usage, perhaps the next API should be sufficient and optimum as clearing buffers is only supported for 32bit clear data. `GPU_storagebuf_clear_int(GPUStorageBuf* ssbo, int clear_data);` `GPU_storagebuf_clear_float(GPUStorageBuf* ssbo, float clear_data);`~~ This should be done before the metal/vulkan ssbo support as it will reduce the complexity of those code-paths. **Usage** Eevee-next shadow mapping uses a non-uniform clearing of an ssbo and requires the `clear_data_len`. ``` union { ShadowTileMapClip clip; int4 i; } u; u.clip.clip_near_stored = 0.0f; u.clip.clip_far_stored = 0.0f; u.clip.clip_near = int(0xFF7FFFFFu ^ 0x7FFFFFFFu); /* floatBitsToOrderedInt(-FLT_MAX) */ u.clip.clip_far = 0x7F7FFFFF; /* floatBitsToOrderedInt(FLT_MAX) */ GPU_storagebuf_clear(tilemap_pool.tilemaps_clip, GPU_RGBA32I, GPU_DATA_INT, &u.i); ``` All other usages uses a uniform clear (-1 as uint or int)
Jeroen Bakker added the
Type
To Do
label 2023-03-06 16:07:59 +01:00
Jeroen Bakker added this to the EEVEE & Viewport project 2023-03-06 16:08:00 +01:00
Jeroen Bakker added this to the 3.6 LTS milestone 2023-03-06 16:08:51 +01:00

Looks good for Metal, clearing buffers to a set value over a range is quite straightforward using: https://developer.apple.com/documentation/metal/mtlblitcommandencoder/1400761-fillbuffer?language=objc

So this will be fine to implement.

Looks good for Metal, clearing buffers to a set value over a range is quite straightforward using: https://developer.apple.com/documentation/metal/mtlblitcommandencoder/1400761-fillbuffer?language=objc So this will be fine to implement.

LGTM!

LGTM!
Blender Bot added the
Status
Archived
label 2023-06-24 10:56:21 +02: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
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105492
No description provided.