Blender  V3.3
Namespaces
gpu_vertex_buffer.cc File Reference
#include "MEM_guardedalloc.h"
#include "gpu_backend.hh"
#include "gpu_vertex_format_private.h"
#include "gpu_context_private.hh"
#include "gpu_vertex_buffer_private.hh"
#include <cstring>

Go to the source code of this file.

Namespaces

 blender
 
 blender::gpu
 

Functions

C-API
GPUVertBufGPU_vertbuf_calloc ()
 
GPUVertBufGPU_vertbuf_create_with_format_ex (const GPUVertFormat *format, GPUUsageType usage)
 
void GPU_vertbuf_init_with_format_ex (GPUVertBuf *verts_, const GPUVertFormat *format, GPUUsageType usage)
 
void GPU_vertbuf_init_build_on_device (GPUVertBuf *verts, GPUVertFormat *format, uint v_len)
 
GPUVertBufGPU_vertbuf_duplicate (GPUVertBuf *verts_)
 
const voidGPU_vertbuf_read (GPUVertBuf *verts)
 
voidGPU_vertbuf_unmap (const GPUVertBuf *verts, const void *mapped_data)
 
void GPU_vertbuf_clear (GPUVertBuf *verts)
 
void GPU_vertbuf_discard (GPUVertBuf *verts)
 
void GPU_vertbuf_handle_ref_add (GPUVertBuf *verts)
 
void GPU_vertbuf_handle_ref_remove (GPUVertBuf *verts)
 
void GPU_vertbuf_data_alloc (GPUVertBuf *verts, uint v_len)
 
void GPU_vertbuf_data_resize (GPUVertBuf *verts, uint v_len)
 
void GPU_vertbuf_data_len_set (GPUVertBuf *verts_, uint v_len)
 
void GPU_vertbuf_attr_set (GPUVertBuf *verts_, uint a_idx, uint v_idx, const void *data)
 
void GPU_vertbuf_attr_fill (GPUVertBuf *verts_, uint a_idx, const void *data)
 
void GPU_vertbuf_vert_set (GPUVertBuf *verts_, uint v_idx, const void *data)
 
void GPU_vertbuf_attr_fill_stride (GPUVertBuf *verts_, uint a_idx, uint stride, const void *data)
 
void GPU_vertbuf_attr_get_raw_data (GPUVertBuf *verts_, uint a_idx, GPUVertBufRaw *access)
 
voidGPU_vertbuf_get_data (const GPUVertBuf *verts)
 
voidGPU_vertbuf_steal_data (GPUVertBuf *verts_)
 
const GPUVertFormatGPU_vertbuf_get_format (const GPUVertBuf *verts)
 
uint GPU_vertbuf_get_vertex_alloc (const GPUVertBuf *verts)
 
uint GPU_vertbuf_get_vertex_len (const GPUVertBuf *verts)
 
GPUVertBufStatus GPU_vertbuf_get_status (const GPUVertBuf *verts)
 
void GPU_vertbuf_tag_dirty (GPUVertBuf *verts)
 
uint GPU_vertbuf_get_memory_usage ()
 
void GPU_vertbuf_use (GPUVertBuf *verts)
 
void GPU_vertbuf_wrap_handle (GPUVertBuf *verts, uint64_t handle)
 
void GPU_vertbuf_bind_as_ssbo (struct GPUVertBuf *verts, int binding)
 
void GPU_vertbuf_bind_as_texture (struct GPUVertBuf *verts, int binding)
 
void GPU_vertbuf_update_sub (GPUVertBuf *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()

void GPU_vertbuf_attr_fill ( GPUVertBuf verts_,
uint  a_idx,
const void data 
)

◆ GPU_vertbuf_attr_fill_stride()

void GPU_vertbuf_attr_fill_stride ( GPUVertBuf verts_,
uint  a_idx,
uint  stride,
const void data 
)

◆ GPU_vertbuf_attr_get_raw_data()

void GPU_vertbuf_attr_get_raw_data ( GPUVertBuf verts_,
uint  a_idx,
GPUVertBufRaw access 
)

◆ GPU_vertbuf_attr_set()

void GPU_vertbuf_attr_set ( GPUVertBuf verts_,
uint  a_idx,
uint  v_idx,
const void data 
)

◆ GPU_vertbuf_bind_as_ssbo()

void GPU_vertbuf_bind_as_ssbo ( struct GPUVertBuf verts,
int  binding 
)

◆ GPU_vertbuf_bind_as_texture()

void GPU_vertbuf_bind_as_texture ( struct GPUVertBuf verts,
int  binding 
)

Definition at line 330 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

Referenced by draw_update_uniforms().

◆ GPU_vertbuf_calloc()

GPUVertBuf* GPU_vertbuf_calloc ( void  )

◆ GPU_vertbuf_clear()

void GPU_vertbuf_clear ( GPUVertBuf verts)

Same as discard but does not free.

Definition at line 151 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

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

◆ GPU_vertbuf_create_with_format_ex()

GPUVertBuf* GPU_vertbuf_create_with_format_ex ( const GPUVertFormat format,
GPUUsageType  usage 
)

◆ GPU_vertbuf_data_alloc()

void GPU_vertbuf_data_alloc ( GPUVertBuf verts,
uint  v_len 
)

Create a new allocation, discarding any existing data.

Definition at line 174 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

Referenced by batch_screen_edges_get(), batch_sphere_wire(), blf_batch_draw_init(), curve_create_curves_pos(), curve_create_edit_curves_nor(), curve_create_edit_data_and_handles(), curves_batch_cache_ensure_procedural_final_attr(), curves_batch_cache_ensure_procedural_final_points(), curves_batch_cache_ensure_procedural_indices(), curves_batch_cache_ensure_procedural_pos(), curves_batch_cache_ensure_procedural_strand_data(), curves_batch_ensure_attribute(), draw_cache_view_init_fn(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), draw_seq_fcurve_overlay(), draw_subdiv_cache_update_extra_coarse_face_data(), draw_subdiv_init_origindex_buffer(), draw_subdiv_topology_info_cb(), DRW_cache_bone_arrows_get(), DRW_cache_bone_box_get(), DRW_cache_bone_dof_lines_get(), DRW_cache_bone_dof_sphere_get(), DRW_cache_bone_envelope_outline_get(), DRW_cache_bone_envelope_solid_get(), DRW_cache_bone_octahedral_get(), DRW_cache_bone_point_get(), DRW_cache_bone_point_wire_outline_get(), DRW_cache_bone_stick_get(), DRW_cache_camera_distances_get(), DRW_cache_camera_frame_get(), DRW_cache_camera_tria_get(), DRW_cache_camera_tria_wire_get(), DRW_cache_camera_volume_get(), DRW_cache_camera_volume_wire_get(), DRW_cache_circle_get(), DRW_cache_cube_get(), DRW_cache_cursor_get(), DRW_cache_empty_capsule_body_get(), DRW_cache_empty_capsule_cap_get(), DRW_cache_empty_cone_get(), DRW_cache_empty_cube_get(), DRW_cache_empty_cylinder_get(), DRW_cache_field_cone_limit_get(), DRW_cache_field_curve_get(), DRW_cache_field_force_get(), DRW_cache_field_sphere_limit_get(), DRW_cache_field_tube_limit_get(), DRW_cache_field_vortex_get(), DRW_cache_field_wind_get(), DRW_cache_fullscreen_quad_get(), DRW_cache_grid_get(), DRW_cache_groundline_get(), DRW_cache_light_area_disk_lines_get(), DRW_cache_light_area_square_lines_get(), DRW_cache_light_point_lines_get(), DRW_cache_light_spot_lines_get(), DRW_cache_light_spot_volume_get(), DRW_cache_light_sun_lines_get(), DRW_cache_lightprobe_cube_get(), DRW_cache_lightprobe_grid_get(), DRW_cache_lightprobe_planar_get(), DRW_cache_normal_arrow_get(), DRW_cache_particles_get_prim(), DRW_cache_plain_axes_get(), drw_cache_procedural_lines_get(), drw_cache_procedural_points_get(), drw_cache_procedural_triangles_get(), DRW_cache_quad_get(), DRW_cache_quad_wires_get(), DRW_cache_single_arrow_get(), DRW_cache_speaker_get(), DRW_cache_sphere_get(), DRW_curves_init(), DRW_displist_vertbuf_create_pos_and_nor(), DRW_gpencil_dummy_buffer_get(), DRW_hair_init(), DRW_temp_buffer_request(), DRW_vertbuf_create_wiredata(), drw_volume_selection_surface_cb(), drw_volume_wireframe_cb(), ED_draw_object_facemap(), blender::draw::extract_attr_init_subdiv(), blender::draw::extract_edge_fac_finish(), blender::draw::extract_edge_fac_init(), blender::draw::extract_edit_data_init(), blender::draw::extract_edit_data_init_subdiv(), blender::draw::extract_edituv_data_init_common(), blender::draw::extract_edituv_stretch_angle_init(), blender::draw::extract_edituv_stretch_area_init(), blender::draw::extract_edituv_stretch_area_init_subdiv(), blender::draw::extract_fdots_edituv_data_init(), blender::draw::extract_fdots_nor_hq_init(), blender::draw::extract_fdots_nor_init(), blender::draw::extract_fdots_pos_init(), blender::draw::extract_fdots_uv_init(), blender::draw::extract_lines_loose_geom_subdiv(), blender::draw::extract_lnor_hq_init(), blender::draw::extract_lnor_init(), blender::draw::extract_mesh_analysis_init(), blender::draw::extract_orco_init(), blender::draw::extract_pos_nor_hq_init(), blender::draw::extract_pos_nor_init(), blender::draw::extract_pos_nor_init_subdiv(), blender::draw::extract_sculpt_data_init(), blender::draw::extract_sculpt_data_init_subdiv(), blender::draw::extract_select_idx_init_impl(), blender::draw::extract_skin_roots_init(), blender::draw::extract_tan_ex_init(), blender::draw::extract_tan_init_subdiv(), blender::draw::extract_uv_init(), blender::draw::extract_weights_init(), gpencil_batches_ensure(), gpencil_edit_batches_ensure(), gpencil_sbuffer_stroke_ensure(), gpu_batch_preset_panel_drag_widget(), GPU_batch_preset_quad(), gpu_batch_sphere(), GPU_batch_tris_from_poly_2d_encoded(), GPU_batch_wire_from_poly_2d_encoded(), gpu_pbvh_vert_buf_data_set(), gpu_vertbuf_create_from_format(), GPU_vertbuf_init_build_on_device(), gpu_viewport_batch_create(), immBeginBatch(), blender::draw::init_vbo_for_attribute(), knifetool_draw(), lattice_batch_cache_create_overlay_batches(), lattice_batch_cache_get_pos(), mpath_vbo_get(), blender::ed::space_node::nodelink_batch_init(), particle_batch_cache_ensure_edit_inner_pos(), particle_batch_cache_ensure_edit_pos_and_seg(), particle_batch_cache_ensure_edit_tip_pos(), particle_batch_cache_ensure_pos(), particle_batch_cache_ensure_pos_and_seg(), particle_batch_cache_ensure_procedural_final_points(), particle_batch_cache_ensure_procedural_indices(), particle_batch_cache_ensure_procedural_pos(), particle_batch_cache_ensure_procedural_strand_data(), pointcloud_batch_cache_ensure_geom(), pointcloud_batch_cache_ensure_pos(), pygpu_vertbuf__tp_new(), sphere_wire_vbo(), stitch_draw(), blender::gpu::tests::test_gpu_shader_compute_vbo(), ui_batch_roundbox_shadow_get(), ui_batch_roundbox_widget_get(), vertbuf_alloc(), vertbuf_device_alloc(), waveform_draw_one(), wm_gizmo_geometryinfo_draw(), and wm_xr_controller_model_batch_create().

◆ GPU_vertbuf_data_len_set()

void GPU_vertbuf_data_len_set ( GPUVertBuf 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 184 of file gpu_vertex_buffer.cc.

References BLI_assert, blender::gpu::unwrap(), and verts.

Referenced by blf_batch_draw(), draw_cache_view_batch(), draw_seq_fcurve_overlay(), DRW_instance_buffer_finish(), blender::draw::extract_skin_roots_init(), and blender::ed::space_node::nodelink_batch_draw().

◆ GPU_vertbuf_data_resize()

void GPU_vertbuf_data_resize ( GPUVertBuf verts,
uint  v_len 
)

◆ GPU_vertbuf_discard()

void GPU_vertbuf_discard ( GPUVertBuf verts)

◆ GPU_vertbuf_duplicate()

GPUVertBuf* GPU_vertbuf_duplicate ( GPUVertBuf verts_)

Definition at line 136 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and blender::gpu::wrap().

Referenced by EEVEE_motion_blur_cache_finish().

◆ GPU_vertbuf_get_data()

void* GPU_vertbuf_get_data ( const GPUVertBuf verts)
Note
Be careful when using this. The data needs to match the expected format.

Definition at line 269 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

Referenced by build_vertex_face_adjacency_maps(), curves_batch_cache_ensure_procedural_pos(), curves_batch_ensure_attribute(), draw_select_buffer(), draw_subdiv_build_cache(), draw_subdiv_cache_update_extra_coarse_face_data(), draw_subdiv_init_origindex_buffer(), draw_subdiv_topology_info_cb(), DRW_vertbuf_create_wiredata(), blender::draw::extract_analysis_iter_finish_mesh(), blender::draw::extract_attr_generic(), blender::draw::extract_edge_fac_finish(), blender::draw::extract_edge_fac_init(), blender::draw::extract_edge_fac_init_subdiv(), blender::draw::extract_edge_idx_init_subdiv(), blender::draw::extract_edge_idx_loose_geom_subdiv(), blender::draw::extract_edit_data_init(), blender::draw::extract_edit_data_init_subdiv(), blender::draw::extract_edit_data_iter_subdiv_bm(), blender::draw::extract_edituv_data_init_common(), blender::draw::extract_edituv_data_iter_subdiv_bm(), blender::draw::extract_edituv_lines_iter_subdiv_bm(), blender::draw::extract_edituv_lines_iter_subdiv_mesh(), blender::draw::extract_edituv_points_iter_subdiv_bm(), blender::draw::extract_edituv_points_iter_subdiv_mesh(), blender::draw::extract_edituv_stretch_angle_init(), blender::draw::extract_edituv_stretch_area_finish(), blender::draw::extract_edituv_stretch_area_init_subdiv(), blender::draw::extract_fdots_edituv_data_init(), blender::draw::extract_fdots_nor_finish(), blender::draw::extract_fdots_nor_hq_finish(), blender::draw::extract_fdots_pos_init(), blender::draw::extract_fdots_uv_init(), blender::draw::extract_lines_loose_geom_subdiv(), blender::draw::extract_lines_paint_mask_iter_subdiv_mesh(), blender::draw::extract_lnor_hq_init(), blender::draw::extract_lnor_init(), blender::draw::extract_orco_init(), blender::draw::extract_points_iter_subdiv_common(), blender::draw::extract_poly_idx_init_subdiv(), blender::draw::extract_pos_nor_hq_init(), blender::draw::extract_pos_nor_init(), blender::draw::extract_pos_nor_init_subdiv(), blender::draw::extract_sculpt_data_init(), blender::draw::extract_sculpt_data_init_subdiv(), blender::draw::extract_select_idx_init_impl(), blender::draw::extract_skin_roots_init(), blender::draw::extract_tan_ex_init(), blender::draw::extract_tan_init_subdiv(), blender::draw::extract_uv_init(), blender::draw::extract_vert_idx_init_subdiv(), blender::draw::extract_vert_idx_loose_geom_subdiv(), blender::draw::extract_weights_init(), gpencil_batches_ensure(), gpencil_edit_batches_ensure(), gpencil_sbuffer_stroke_ensure(), GPU_pbvh_buffers_update_flush(), gpu_pbvh_vert_buf_data_set(), immBeginBatch(), mpath_vbo_get(), pointcloud_batch_cache_ensure_pos(), pygpu_vertbuf_fill(), vertbuf_alloc(), and wm_xr_controller_model_batch_create().

◆ GPU_vertbuf_get_format()

const GPUVertFormat* GPU_vertbuf_get_format ( const GPUVertBuf verts)

◆ GPU_vertbuf_get_memory_usage()

uint GPU_vertbuf_get_memory_usage ( void  )

Definition at line 310 of file gpu_vertex_buffer.cc.

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

Referenced by DRW_stats_draw().

◆ GPU_vertbuf_get_status()

GPUVertBufStatus GPU_vertbuf_get_status ( const GPUVertBuf verts)

◆ GPU_vertbuf_get_vertex_alloc()

uint GPU_vertbuf_get_vertex_alloc ( const GPUVertBuf verts)

◆ GPU_vertbuf_get_vertex_len()

uint GPU_vertbuf_get_vertex_len ( const GPUVertBuf verts)

◆ GPU_vertbuf_handle_ref_add()

void GPU_vertbuf_handle_ref_add ( GPUVertBuf verts)

Avoid GPUVertBuf data-block being free but not its data.

Definition at line 162 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

Referenced by instancing_batch_references_add().

◆ GPU_vertbuf_handle_ref_remove()

void GPU_vertbuf_handle_ref_remove ( GPUVertBuf verts)

Definition at line 167 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

Referenced by instancing_batch_references_remove().

◆ GPU_vertbuf_init_build_on_device()

void GPU_vertbuf_init_build_on_device ( GPUVertBuf verts,
GPUVertFormat format,
uint  v_len 
)

◆ GPU_vertbuf_init_with_format_ex()

void GPU_vertbuf_init_with_format_ex ( GPUVertBuf verts_,
const GPUVertFormat format,
GPUUsageType  usage 
)

◆ GPU_vertbuf_read()

const void* GPU_vertbuf_read ( GPUVertBuf verts)

(Download and) return a pointer containing the data of a vertex buffer.

Note that the returned pointer is still owned by the driver. To get an local copy, use GPU_vertbuf_unmap after calling GPU_vertbuf_read.

Definition at line 141 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

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

◆ GPU_vertbuf_steal_data()

void* GPU_vertbuf_steal_data ( GPUVertBuf verts)

Returns the data buffer and set it to null internally to avoid freeing.

Note
Be careful when using this. The data needs to match the expected format.

Definition at line 275 of file gpu_vertex_buffer.cc.

References BLI_assert, data, blender::gpu::unwrap(), and verts.

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

◆ GPU_vertbuf_tag_dirty()

void GPU_vertbuf_tag_dirty ( GPUVertBuf verts)

◆ GPU_vertbuf_unmap()

void* GPU_vertbuf_unmap ( const GPUVertBuf verts,
const void mapped_data 
)

Definition at line 146 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

◆ GPU_vertbuf_update_sub()

void GPU_vertbuf_update_sub ( GPUVertBuf verts,
uint  start,
uint  len,
const void data 
)

XXX: do not use! This is just a wrapper for the use of the Hair refine workaround. To be used with GPU_vertbuf_use().

Definition at line 335 of file gpu_vertex_buffer.cc.

References data, len, blender::gpu::unwrap(), and verts.

Referenced by DRW_curves_update(), DRW_hair_update(), blender::draw::extract_edge_fac_loose_geom_subdiv(), blender::draw::extract_pos_nor_loose_geom_subdiv(), and vertbuf_update_data().

◆ GPU_vertbuf_use()

void GPU_vertbuf_use ( GPUVertBuf verts)

◆ GPU_vertbuf_vert_set()

void GPU_vertbuf_vert_set ( GPUVertBuf verts,
uint  v_idx,
const void data 
)

◆ GPU_vertbuf_wrap_handle()

void GPU_vertbuf_wrap_handle ( GPUVertBuf verts,
uint64_t  handle 
)

Definition at line 320 of file gpu_vertex_buffer.cc.

References blender::gpu::unwrap(), and verts.

Referenced by vertbuf_wrap_device_handle().