Blender V4.3
GPU_storage_buffer.hh File Reference
#include "GPU_texture.hh"
#include "GPU_vertex_buffer.hh"

Go to the source code of this file.

Macros

#define GPU_storagebuf_create(size)    GPU_storagebuf_create_ex(size, nullptr, GPU_USAGE_DYNAMIC, __func__);
 

Functions

GPUStorageBuf * GPU_storagebuf_create_ex (size_t size, const void *data, GPUUsageType usage, const char *name)
 
void GPU_storagebuf_free (GPUStorageBuf *ssbo)
 
void GPU_storagebuf_update (GPUStorageBuf *ssbo, const void *data)
 
void GPU_storagebuf_bind (GPUStorageBuf *ssbo, int slot)
 
void GPU_storagebuf_unbind (GPUStorageBuf *ssbo)
 
void GPU_storagebuf_debug_unbind_all ()
 
void GPU_storagebuf_clear_to_zero (GPUStorageBuf *ssbo)
 
void GPU_storagebuf_clear (GPUStorageBuf *ssbo, uint32_t clear_value)
 
void GPU_storagebuf_sync_to_host (GPUStorageBuf *ssbo)
 
void GPU_storagebuf_read (GPUStorageBuf *ssbo, void *data)
 
void GPU_storagebuf_copy_sub_from_vertbuf (GPUStorageBuf *ssbo, blender::gpu::VertBuf *src, uint dst_offset, uint src_offset, uint copy_size)
 Copy a part of a vertex buffer to a storage buffer.
 
void GPU_storagebuf_sync_as_indirect_buffer (GPUStorageBuf *ssbo)
 

Detailed Description

Storage buffers API. Used to handle many way bigger buffers than Uniform buffers update at once. Make sure that the data structure is compatible with what the implementation expect. (see "7.8 Shader Buffer Variables and Shader Storage Blocks" from the OpenGL spec for more info about std430 layout) Rule of thumb: Padding to 16bytes, don't use vec3.

Definition in file GPU_storage_buffer.hh.

Macro Definition Documentation

◆ GPU_storagebuf_create

#define GPU_storagebuf_create ( size)     GPU_storagebuf_create_ex(size, nullptr, GPU_USAGE_DYNAMIC, __func__);

Definition at line 28 of file GPU_storage_buffer.hh.

Referenced by blender::gpu::printf_begin().

Function Documentation

◆ GPU_storagebuf_bind()

◆ GPU_storagebuf_clear()

void GPU_storagebuf_clear ( GPUStorageBuf * ssbo,
uint32_t clear_value )

◆ GPU_storagebuf_clear_to_zero()

◆ GPU_storagebuf_copy_sub_from_vertbuf()

void GPU_storagebuf_copy_sub_from_vertbuf ( GPUStorageBuf * ssbo,
blender::gpu::VertBuf * src,
uint dst_offset,
uint src_offset,
uint copy_size )

Copy a part of a vertex buffer to a storage buffer.

Parameters
ssbodestination storage buffer
srcsource vertex buffer
dst_offsetwhere to start copying to (in bytes).
src_offsetwhere to start copying from (in bytes).
copy_sizebyte size of the segment to copy.

Definition at line 104 of file gpu_storage_buffer.cc.

References blender::gpu::unwrap().

Referenced by blender::eevee::VelocityModule::geometry_steps_fill(), and blender::gpu::tests::test_storage_buffer_copy_from_vertex_buffer().

◆ GPU_storagebuf_create_ex()

◆ GPU_storagebuf_debug_unbind_all()

void GPU_storagebuf_debug_unbind_all ( )

Resets the internal slot usage tracking. But there is no guarantee that this actually undo the bindings for the next draw call. Only has effect when G_DEBUG_GPU is set.

Definition at line 89 of file gpu_storage_buffer.cc.

References blender::gpu::Context::debug_unbind_all_ssbo(), and blender::gpu::Context::get().

Referenced by blender::draw::command::RecordingState::cleanup(), draw_shgroup(), and DRW_state_reset().

◆ GPU_storagebuf_free()

◆ GPU_storagebuf_read()

void GPU_storagebuf_read ( GPUStorageBuf * ssbo,
void * data )

Read back content of the buffer to CPU for inspection. Slow! Only use for inspection / debugging.

NOTE: If GPU_storagebuf_sync_to_host is called, this command is synchronized against that call. If pending GPU updates to the storage buffer are not yet visible to the host, the command will stall until dependent GPU work has completed.

Otherwise, this command is synchronized against this call and will stall the CPU until the buffer content can be read by the host.

Definition at line 118 of file gpu_storage_buffer.cc.

References blender::gpu::unwrap().

Referenced by blender::gpu::printf_end(), blender::draw::detail::StorageCommon< T, len, device_only >::read(), blender::gpu::tests::CallData::read_back(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_shader_compute_ssbo(), blender::gpu::tests::test_storage_buffer_clear(), blender::gpu::tests::test_storage_buffer_clear_zero(), blender::gpu::tests::test_storage_buffer_copy_from_vertex_buffer(), blender::gpu::tests::test_storage_buffer_create_update_read(), and blender::gpu::tests::ShaderSpecializationConst::validate().

◆ GPU_storagebuf_sync_as_indirect_buffer()

void GPU_storagebuf_sync_as_indirect_buffer ( GPUStorageBuf * ssbo)

Ensure the ssbo is ready to be used as an indirect buffer in GPU_batch_draw_indirect. NOTE: Internally, this is only required for the OpenGL backend.

Definition at line 123 of file gpu_storage_buffer.cc.

References blender::gpu::unwrap().

Referenced by blender::draw::command::DrawMultiBuf::bind().

◆ GPU_storagebuf_sync_to_host()

void GPU_storagebuf_sync_to_host ( GPUStorageBuf * ssbo)

Explicitly sync updated storage buffer contents back to host within the GPU command stream. This ensures any changes made by the GPU are visible to the host. NOTE: This command is only valid for host-visible storage buffers.

Definition at line 113 of file gpu_storage_buffer.cc.

References blender::gpu::unwrap().

Referenced by blender::draw::detail::StorageCommon< T, len, device_only >::async_flush_to_host().

◆ GPU_storagebuf_unbind()

◆ GPU_storagebuf_update()