Blender V5.0
GPU_vertex_buffer.hh File Reference
#include "BLI_math_base.h"
#include "BLI_span.hh"
#include "BLI_utildefines.h"
#include "BLI_virtual_array.hh"
#include "GPU_common.hh"
#include "GPU_vertex_format.hh"

Go to the source code of this file.

Classes

class  blender::gpu::VertBufDeleter
class  blender::gpu::VertBuf
struct  GPUVertBufRaw

Namespaces

namespace  blender
namespace  blender::gpu

Macros

#define GPU_vertbuf_init_with_format(verts, format)
#define GPU_VERTBUF_DISCARD_SAFE(verts)

Typedefs

using blender::gpu::VertBufPtr = std::unique_ptr<gpu::VertBuf, gpu::VertBufDeleter>

Enumerations

enum  GPUVertBufStatus { GPU_VERTBUF_INVALID = 0 , GPU_VERTBUF_INIT = (1 << 0) , GPU_VERTBUF_DATA_DIRTY = (1 << 1) , GPU_VERTBUF_DATA_UPLOADED = (1 << 2) }
enum  GPUUsageType {
  GPU_USAGE_STREAM = 0 , GPU_USAGE_STATIC = 1 , GPU_USAGE_DYNAMIC = 2 , GPU_USAGE_DEVICE_ONLY = 3 ,
  GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY = 1 << 3
}

Functions

 ENUM_OPERATORS (GPUUsageType, GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY)
void GPU_vertbuf_discard (blender::gpu::VertBuf *)
blender::gpu::VertBufGPU_vertbuf_calloc ()
blender::gpu::VertBufGPU_vertbuf_create_with_format_ex (const GPUVertFormat &format, GPUUsageType usage)
static blender::gpu::VertBufGPU_vertbuf_create_with_format (const GPUVertFormat &format)
void GPU_vertbuf_read (const blender::gpu::VertBuf *verts, void *data)
void GPU_vertbuf_clear (blender::gpu::VertBuf *verts)
void GPU_vertbuf_handle_ref_add (blender::gpu::VertBuf *verts)
void GPU_vertbuf_handle_ref_remove (blender::gpu::VertBuf *verts)
void GPU_vertbuf_init_with_format_ex (blender::gpu::VertBuf &verts, const GPUVertFormat &format, GPUUsageType)
void GPU_vertbuf_init_build_on_device (blender::gpu::VertBuf &verts, const GPUVertFormat &format, uint v_len)
blender::gpu::VertBufGPU_vertbuf_create_on_device (const GPUVertFormat &format, uint v_len)
void GPU_vertbuf_data_alloc (blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_data_resize (blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_data_len_set (blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_attr_set (blender::gpu::VertBuf *, uint a_idx, uint v_idx, const void *data)
void GPU_vertbuf_vert_set (blender::gpu::VertBuf *verts, uint v_idx, const void *data)
void GPU_vertbuf_attr_fill (blender::gpu::VertBuf *, uint a_idx, const void *data)
void GPU_vertbuf_attr_fill_stride (blender::gpu::VertBuf *, uint a_idx, uint stride, const void *data)
GPU_INLINE void * GPU_vertbuf_raw_step (GPUVertBufRaw *a)
GPU_INLINE uint GPU_vertbuf_raw_used (const GPUVertBufRaw *a)
void GPU_vertbuf_attr_get_raw_data (blender::gpu::VertBuf *, uint a_idx, GPUVertBufRaw *access)
const GPUVertFormatGPU_vertbuf_get_format (const blender::gpu::VertBuf *verts)
uint GPU_vertbuf_get_vertex_alloc (const blender::gpu::VertBuf *verts)
uint GPU_vertbuf_get_vertex_len (const blender::gpu::VertBuf *verts)
GPUVertBufStatus GPU_vertbuf_get_status (const blender::gpu::VertBuf *verts)
void GPU_vertbuf_tag_dirty (blender::gpu::VertBuf *verts)
void GPU_vertbuf_use (blender::gpu::VertBuf *)
void GPU_vertbuf_bind_as_ssbo (blender::gpu::VertBuf *verts, int binding)
void GPU_vertbuf_bind_as_texture (blender::gpu::VertBuf *verts, int binding)
void GPU_vertbuf_wrap_handle (blender::gpu::VertBuf *verts, uint64_t handle)
void GPU_vertbuf_update_sub (blender::gpu::VertBuf *verts, uint start, uint len, const void *data)
uint GPU_vertbuf_get_memory_usage ()

Detailed Description

GPU vertex buffer

Definition in file GPU_vertex_buffer.hh.

Macro Definition Documentation

◆ GPU_VERTBUF_DISCARD_SAFE

#define GPU_VERTBUF_DISCARD_SAFE ( verts)
Value:
do { \
if (verts != nullptr) { \
GPU_vertbuf_discard(verts); \
verts = nullptr; \
} \
} while (0)
static float verts[][3]

Definition at line 356 of file GPU_vertex_buffer.hh.

Referenced by animviz_calc_motionpaths(), animviz_free_motionpath_cache(), blender::draw::clear_edit_data(), blender::draw::curve_batch_cache_clear(), blender::draw::draw_patch_map_free(), blender::draw::draw_subdiv_cache_free(), blender::draw::draw_subdiv_cache_free_material_data(), blender::draw::draw_subdiv_free_edit_mode_cache(), blender::draw::DRW_curve_batch_cache_dirty_tag(), blender::draw::DRW_particles_batch_cache_get_edit_strands(), blender::gpu::Context::free_resources(), GPU_batch_clear(), blender::draw::grease_pencil_batch_cache_clear(), blender::draw::lattice_batch_cache_clear(), motionpaths_calc_bake_targets(), blender::draw::particle_batch_cache_clear(), blender::draw::particle_batch_cache_clear_hair(), blender::draw::particle_batch_cache_clear_point(), blender::draw::particle_batch_cache_ensure_edit_pos_and_seg(), blender::draw::particle_batch_cache_ensure_pos(), blender::draw::particle_batch_cache_ensure_pos_and_seg(), blender::draw::pointcloud_batch_cache_clear(), blender::draw::pointcloud_discard_attributes(), blender::draw::pointcloud_surface_shaded_get(), blender::draw::test_draw_curves_interpolate_attributes(), blender::draw::test_draw_curves_interpolate_position(), blender::draw::test_draw_curves_lib(), blender::draw::test_draw_curves_topology(), blender::draw::volume_batch_cache_clear(), blender::draw::CurvesModule::~CurvesModule(), and blender::draw::PointCloudModule::~PointCloudModule().

◆ GPU_vertbuf_init_with_format

Enumeration Type Documentation

◆ GPUUsageType

How to create a #VertBuf: 1) verts = GPU_vertbuf_calloc() 2) GPU_vertformat_attr_add(verts->format, ...) 3) GPU_vertbuf_data_alloc(verts, vertex_len) <– finalizes/packs vertex format 4) GPU_vertbuf_attr_fill(verts, pos, application_pos_buffer)

Enumerator
GPU_USAGE_STREAM 
GPU_USAGE_STATIC 
GPU_USAGE_DYNAMIC 
GPU_USAGE_DEVICE_ONLY 
GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY 

Extended usage flags.

Definition at line 42 of file GPU_vertex_buffer.hh.

◆ GPUVertBufStatus

Enumerator
GPU_VERTBUF_INVALID 

Initial state.

GPU_VERTBUF_INIT 

Was init with a vertex format.

GPU_VERTBUF_DATA_DIRTY 

Data has been touched and need to be re-uploaded.

GPU_VERTBUF_DATA_UPLOADED 

The buffer has been created inside GPU memory.

Definition at line 21 of file GPU_vertex_buffer.hh.

Function Documentation

◆ ENUM_OPERATORS()

◆ GPU_vertbuf_attr_fill()

◆ GPU_vertbuf_attr_fill_stride()

◆ GPU_vertbuf_attr_get_raw_data()

◆ GPU_vertbuf_attr_set()

◆ GPU_vertbuf_bind_as_ssbo()

◆ GPU_vertbuf_bind_as_texture()

void GPU_vertbuf_bind_as_texture ( blender::gpu::VertBuf * verts,
int binding )

◆ GPU_vertbuf_calloc()

◆ GPU_vertbuf_clear()

void GPU_vertbuf_clear ( blender::gpu::VertBuf * verts)

Same as discard but does not free.

Definition at line 148 of file gpu_vertex_buffer.cc.

References verts.

◆ GPU_vertbuf_create_on_device()

◆ GPU_vertbuf_create_with_format()

blender::gpu::VertBuf * GPU_vertbuf_create_with_format ( const GPUVertFormat & format)
inlinestatic

Definition at line 68 of file GPU_vertex_buffer.hh.

References GPU_USAGE_STATIC, and GPU_vertbuf_create_with_format_ex().

Referenced by batch_screen_edges_get(), batch_sphere_wire(), circle_draw_rgb(), blender::draw::create_vbo(), blender::ed::greasepencil::image_render::draw_grease_pencil_stroke(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), blender::render::hydra::DrawTexture::DrawTexture(), blender::draw::drw_volume_selection_surface_cb(), blender::draw::drw_volume_wireframe_cb(), blender::gpu::Context::dummy_vbo_get(), blender::draw::pbvh::ensure_vbos_allocated_bmesh(), blender::draw::pbvh::ensure_vbos_allocated_grids(), blender::draw::pbvh::ensure_vbos_allocated_mesh(), blender::draw::extract_attr_viewer(), blender::draw::extract_edge_factor(), blender::draw::extract_edit_data(), blender::draw::extract_edit_data_subdiv(), blender::draw::extract_edituv_data(), blender::draw::extract_edituv_data_subdiv(), blender::draw::extract_edituv_stretch_angle(), blender::draw::extract_edituv_stretch_area(), blender::draw::extract_face_dot_normals(), blender::draw::extract_face_dots_edituv_data(), blender::draw::extract_face_dots_position(), blender::draw::extract_face_dots_uv(), blender::draw::extract_mesh_analysis(), blender::draw::extract_normals(), blender::draw::extract_normals_subdiv(), blender::draw::extract_orco(), blender::draw::extract_paint_overlay_flags(), blender::draw::extract_positions(), blender::draw::extract_sculpt_data(), blender::draw::extract_skin_roots(), blender::draw::extract_tangents(), blender::draw::extract_uv_maps(), blender::draw::extract_vert_normals(), blender::draw::extract_weights(), GPU_batch_preset_quad(), gpu_batch_sphere(), GPU_batch_tris_from_poly_2d_encoded(), GPU_batch_unit_cube(), GPU_batch_wire_from_poly_2d_encoded(), gpu_viewport_batch_create(), immBeginBatch(), blender::draw::init_empty_dummy_batch(), knifetool_draw(), blender::draw::lattice_batch_cache_create_overlay_batches(), blender::draw::lattice_batch_cache_get_pos(), blender::draw::particle_batch_cache_ensure_edit_inner_pos(), blender::draw::particle_batch_cache_ensure_edit_pos_and_seg(), blender::draw::particle_batch_cache_ensure_edit_tip_pos(), blender::draw::particle_batch_cache_ensure_pos(), blender::draw::particle_batch_cache_ensure_pos_and_seg(), pygpu_vertbuf__tp_new(), stitch_draw(), blender::draw::test_draw_curves_interpolate_attributes(), blender::draw::test_draw_curves_interpolate_position(), blender::draw::test_draw_curves_topology(), blender::gpu::tests::test_storage_buffer_copy_from_vertex_buffer(), ui_batch_roundbox_shadow_get(), ui_batch_roundbox_widget_get(), blender::gpu::tests::vertex_buffer_fetch_mode(), waveform_draw_one(), waveform_draw_rgb(), wm_gizmo_geometryinfo_draw(), and wm_xr_controller_model_batch_create().

◆ GPU_vertbuf_create_with_format_ex()

◆ GPU_vertbuf_data_alloc()

void GPU_vertbuf_data_alloc ( blender::gpu::VertBuf & verts,
uint v_len )

Create a new allocation, discarding any existing data.

Definition at line 171 of file gpu_vertex_buffer.cc.

References verts.

Referenced by blender::draw::alloc_evaluated_point_attribute_vbo(), batch_screen_edges_get(), batch_sphere_wire(), blender::draw::build_poly_other_map_vbo(), circle_draw_rgb(), blender::opensubdiv::GPUVertexBuffer::Create(), blender::draw::create_edit_points_data(), blender::draw::create_edit_points_position(), blender::draw::create_edit_points_position_vbo(), blender::draw::create_edit_points_selection(), blender::draw::create_vbo(), blender::draw::curve_create_attribute(), blender::draw::curve_create_curves_pos(), blender::draw::curve_create_edit_curves_nor(), blender::draw::curve_create_edit_data_and_handles(), blender::ed::greasepencil::image_render::draw_grease_pencil_stroke(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), blender::draw::draw_subdiv_cache_update_extra_coarse_face_data(), blender::draw::draw_subdiv_init_origindex_buffer(), blender::draw::draw_subdiv_init_origindex_buffer(), blender::render::hydra::DrawTexture::DrawTexture(), blender::draw::DRW_vertbuf_create_wiredata(), blender::draw::drw_volume_selection_surface_cb(), blender::draw::drw_volume_wireframe_cb(), blender::gpu::Context::dummy_vbo_get(), blender::draw::ensure_control_point_attribute(), blender::draw::pbvh::ensure_vbos_allocated_bmesh(), blender::draw::pbvh::ensure_vbos_allocated_grids(), blender::draw::pbvh::ensure_vbos_allocated_mesh(), blender::draw::extract_attr_viewer(), blender::draw::extract_edge_factor(), blender::draw::extract_edit_data(), blender::draw::extract_edit_data_subdiv(), blender::draw::extract_edituv_data(), blender::draw::extract_edituv_data_subdiv(), blender::draw::extract_edituv_stretch_angle(), blender::draw::extract_edituv_stretch_area(), blender::draw::extract_edituv_stretch_area_subdiv(), blender::draw::extract_face_dot_normals(), blender::draw::extract_face_dots_edituv_data(), blender::draw::extract_face_dots_position(), blender::draw::extract_face_dots_uv(), blender::draw::extract_lines_loose_geom_subdiv(), blender::draw::extract_mesh_analysis(), blender::draw::extract_normals(), blender::draw::extract_normals_subdiv(), blender::draw::extract_orco(), blender::draw::extract_paint_overlay_flags(), blender::draw::extract_positions(), blender::draw::extract_sculpt_data(), blender::draw::extract_sculpt_data_subdiv(), blender::draw::extract_skin_roots(), blender::draw::extract_tangents(), blender::draw::extract_tangents_subdiv(), blender::draw::extract_uv_maps(), blender::draw::extract_vert_normals(), blender::draw::extract_weights(), blender::gpu::MTLContext::get_dummy_texture(), blender::opensubdiv::EvalOutputAPI::getPatchMap(), GPU_batch_preset_quad(), gpu_batch_sphere(), GPU_batch_tris_from_poly_2d_encoded(), GPU_batch_unit_cube(), GPU_batch_wire_from_poly_2d_encoded(), GPU_vertbuf_create_on_device(), GPU_vertbuf_init_build_on_device(), gpu_viewport_batch_create(), blender::draw::grease_pencil_edit_batch_ensure(), blender::draw::grease_pencil_geom_batch_ensure(), blender::draw::grease_pencil_weight_batch_ensure(), immBeginBatch(), blender::draw::init_coarse_data(), blender::draw::init_empty_dummy_batch(), blender::draw::init_vbo_for_attribute(), knifetool_draw(), blender::draw::lattice_batch_cache_create_overlay_batches(), blender::draw::lattice_batch_cache_get_pos(), blender::ed::space_node::nodelink_batch_init(), blender::draw::particle_batch_cache_ensure_edit_inner_pos(), blender::draw::particle_batch_cache_ensure_edit_pos_and_seg(), blender::draw::particle_batch_cache_ensure_edit_tip_pos(), blender::draw::particle_batch_cache_ensure_pos(), blender::draw::particle_batch_cache_ensure_pos_and_seg(), blender::draw::pointcloud_extract_attribute(), blender::draw::pointcloud_extract_position_and_radius(), pygpu_vertbuf__tp_new(), blender::ed::vse::SeqQuadsBatch::SeqQuadsBatch(), stitch_draw(), blender::gpu::tests::test_buffer_texture(), blender::gpu::tests::test_shader_compute_vbo(), blender::gpu::tests::test_storage_buffer_copy_from_vertex_buffer(), ui_batch_roundbox_shadow_get(), ui_batch_roundbox_widget_get(), blender::gpu::tests::vertex_buffer_fetch_mode(), waveform_draw_one(), waveform_draw_rgb(), wm_gizmo_geometryinfo_draw(), and wm_xr_controller_model_batch_create().

◆ GPU_vertbuf_data_len_set()

void GPU_vertbuf_data_len_set ( blender::gpu::VertBuf & verts,
uint v_len )

Set vertex count but does not change allocation. Only this many verts will be uploaded to the GPU and rendered. This is useful for streaming data.

Definition at line 181 of file gpu_vertex_buffer.cc.

References BLI_assert, and verts.

Referenced by blender::draw::init_empty_dummy_batch().

◆ GPU_vertbuf_data_resize()

void GPU_vertbuf_data_resize ( blender::gpu::VertBuf & verts,
uint v_len )

Resize buffer keeping existing data.

Definition at line 176 of file gpu_vertex_buffer.cc.

References verts.

Referenced by blender::draw::curve_create_edit_data_and_handles(), immEnd(), and blender::draw::particle_batch_cache_ensure_pos().

◆ GPU_vertbuf_discard()

◆ GPU_vertbuf_get_format()

◆ GPU_vertbuf_get_memory_usage()

uint GPU_vertbuf_get_memory_usage ( )

Definition at line 289 of file gpu_vertex_buffer.cc.

References blender::gpu::VertBuf::memory_usage.

◆ GPU_vertbuf_get_status()

GPUVertBufStatus GPU_vertbuf_get_status ( const blender::gpu::VertBuf * verts)

Definition at line 279 of file gpu_vertex_buffer.cc.

References verts.

Referenced by DRW_vbo_requested().

◆ GPU_vertbuf_get_vertex_alloc()

uint GPU_vertbuf_get_vertex_alloc ( const blender::gpu::VertBuf * verts)

Definition at line 269 of file gpu_vertex_buffer.cc.

References verts.

◆ GPU_vertbuf_get_vertex_len()

◆ GPU_vertbuf_handle_ref_add()

void GPU_vertbuf_handle_ref_add ( blender::gpu::VertBuf * verts)

Avoid blender::gpu::VertBuf data-block being free but not its data.

Definition at line 159 of file gpu_vertex_buffer.cc.

References verts.

◆ GPU_vertbuf_handle_ref_remove()

void GPU_vertbuf_handle_ref_remove ( blender::gpu::VertBuf * verts)

Definition at line 164 of file gpu_vertex_buffer.cc.

References verts.

◆ GPU_vertbuf_init_build_on_device()

◆ GPU_vertbuf_init_with_format_ex()

◆ GPU_vertbuf_raw_step()

◆ GPU_vertbuf_raw_used()

◆ GPU_vertbuf_read()

void GPU_vertbuf_read ( const blender::gpu::VertBuf * verts,
void * data )

(Download and) fill data with the data from the vertex buffer. NOTE: caller is responsible to reserve enough memory of the data parameter.

Definition at line 143 of file gpu_vertex_buffer.cc.

References data, and verts.

Referenced by blender::gpu::tests::test_shader_compute_vbo().

◆ GPU_vertbuf_tag_dirty()

◆ GPU_vertbuf_update_sub()

void GPU_vertbuf_update_sub ( blender::gpu::VertBuf * verts,
uint start,
uint len,
const void * data )

◆ GPU_vertbuf_use()

◆ GPU_vertbuf_vert_set()

void GPU_vertbuf_vert_set ( blender::gpu::VertBuf * verts,
uint v_idx,
const void * data )

Fills a whole vertex (all attributes). Data must match packed layout.

Definition at line 210 of file gpu_vertex_buffer.cc.

References BLI_assert, data, GPU_USAGE_DEVICE_ONLY, GPU_VERTBUF_DATA_DIRTY, and verts.

Referenced by GPU_batch_unit_cube(), blender::gpu::tests::test_storage_buffer_copy_from_vertex_buffer(), and blender::gpu::tests::vertex_buffer_fetch_mode().

◆ GPU_vertbuf_wrap_handle()

void GPU_vertbuf_wrap_handle ( blender::gpu::VertBuf * verts,
uint64_t handle )

Definition at line 299 of file gpu_vertex_buffer.cc.

References verts.