Blender V5.0
gpu_vertex_buffer.cc File Reference
#include "MEM_guardedalloc.h"
#include "gpu_backend.hh"
#include "gpu_vertex_format_private.hh"
#include "GPU_vertex_buffer.hh"
#include "gpu_context_private.hh"
#include <cstring>

Go to the source code of this file.

Namespaces

namespace  blender
namespace  blender::gpu

Functions

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

Detailed Description

GPU vertex buffer

Definition in file gpu_vertex_buffer.cc.

Function Documentation

◆ GPU_vertbuf_attr_fill()

◆ GPU_vertbuf_attr_fill_stride()

void GPU_vertbuf_attr_fill_stride ( VertBuf * verts,
uint a_idx,
uint stride,
const void * data )

◆ 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 ( 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_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 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 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 ( 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_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 ( VertBuf * verts,
uint64_t handle )

Definition at line 299 of file gpu_vertex_buffer.cc.

References verts.