Blender V5.0
gpu_index_buffer.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_array_utils.hh"
#include "BLI_math_base.h"
#include "BLI_utildefines.h"
#include "gpu_backend.hh"
#include "GPU_index_buffer.hh"
#include "GPU_capabilities.hh"
#include "GPU_compute.hh"
#include "GPU_platform.hh"
#include "GPU_state.hh"
#include <algorithm>
#include <cstring>

Go to the source code of this file.

Namespaces

namespace  blender
namespace  blender::gpu

Functions

IndexBufBuilder
void GPU_indexbuf_init_ex (GPUIndexBufBuilder *builder, GPUPrimType prim_type, uint index_len, uint vertex_len)
void GPU_indexbuf_init (GPUIndexBufBuilder *builder, GPUPrimType prim_type, uint prim_len, uint vertex_len)
IndexBufGPU_indexbuf_build_on_device (uint index_len)
void GPU_indexbuf_init_build_on_device (IndexBuf *elem, uint index_len)
blender::MutableSpan< uint32_t > GPU_indexbuf_get_data (GPUIndexBufBuilder *builder)
void GPU_indexbuf_join (GPUIndexBufBuilder *builder_to, const GPUIndexBufBuilder *builder_from)
void GPU_indexbuf_add_generic_vert (GPUIndexBufBuilder *builder, uint v)
void GPU_indexbuf_add_primitive_restart (GPUIndexBufBuilder *builder)
void GPU_indexbuf_add_point_vert (GPUIndexBufBuilder *builder, uint v)
void GPU_indexbuf_add_line_verts (GPUIndexBufBuilder *builder, uint v1, uint v2)
void GPU_indexbuf_add_tri_verts (GPUIndexBufBuilder *builder, uint v1, uint v2, uint v3)
void GPU_indexbuf_add_line_adj_verts (GPUIndexBufBuilder *builder, uint v1, uint v2, uint v3, uint v4)
void GPU_indexbuf_set_point_vert (GPUIndexBufBuilder *builder, uint elem, uint v1)
void GPU_indexbuf_set_line_verts (GPUIndexBufBuilder *builder, uint elem, uint v1, uint v2)
void GPU_indexbuf_set_tri_verts (GPUIndexBufBuilder *builder, uint elem, uint v1, uint v2, uint v3)
void GPU_indexbuf_set_point_restart (GPUIndexBufBuilder *builder, uint elem)
void GPU_indexbuf_set_line_restart (GPUIndexBufBuilder *builder, uint elem)
void GPU_indexbuf_set_tri_restart (GPUIndexBufBuilder *builder, uint elem)
IndexBufGPU_indexbuf_build_curves_on_device (GPUPrimType prim_type, uint curves_num, uint verts_per_curve)
C-API
IndexBufGPU_indexbuf_calloc ()
IndexBufGPU_indexbuf_build (GPUIndexBufBuilder *builder)
IndexBufGPU_indexbuf_create_subrange (IndexBuf *elem_src, uint start, uint length)
void GPU_indexbuf_build_in_place (GPUIndexBufBuilder *builder, IndexBuf *elem)
void GPU_indexbuf_build_in_place_ex (GPUIndexBufBuilder *builder, const uint index_min, const uint index_max, const bool uses_restart_indices, IndexBuf *elem)
IndexBufGPU_indexbuf_build_ex (GPUIndexBufBuilder *builder, const uint index_min, const uint index_max, const bool uses_restart_indices)
IndexBufGPU_indexbuf_build_from_memory (const GPUPrimType prim_type, const uint32_t *data, const int32_t data_len, const int32_t index_min, const int32_t index_max, const bool uses_restart_indices)
void GPU_indexbuf_create_subrange_in_place (IndexBuf *elem, IndexBuf *elem_src, uint start, uint length)
void GPU_indexbuf_read (IndexBuf *elem, uint32_t *data)
void GPU_indexbuf_discard (IndexBuf *elem)
bool GPU_indexbuf_is_init (IndexBuf *elem)
int GPU_indexbuf_primitive_len (GPUPrimType prim_type)
void GPU_indexbuf_use (IndexBuf *elem)
void GPU_indexbuf_bind_as_ssbo (IndexBuf *elem, int binding)
void GPU_indexbuf_update_sub (IndexBuf *elem, uint start, uint len, const void *data)

Detailed Description

GPU element list (AKA index buffer)

Definition in file gpu_index_buffer.cc.

Function Documentation

◆ GPU_indexbuf_add_generic_vert()

◆ GPU_indexbuf_add_line_adj_verts()

◆ GPU_indexbuf_add_line_verts()

◆ GPU_indexbuf_add_point_vert()

◆ GPU_indexbuf_add_primitive_restart()

◆ GPU_indexbuf_add_tri_verts()

◆ GPU_indexbuf_bind_as_ssbo()

◆ GPU_indexbuf_build()

◆ GPU_indexbuf_build_curves_on_device()

◆ GPU_indexbuf_build_ex()

◆ GPU_indexbuf_build_from_memory()

IndexBuf * GPU_indexbuf_build_from_memory ( GPUPrimType prim_type,
const uint32_t * data,
int32_t data_len,
int32_t index_min,
int32_t index_max,
bool uses_restart_indices )

Fill an IBO by uploading the referenced data directly to the GPU, bypassing the separate storage in the IBO. This should be used whenever the equivalent indices already exist in a contiguous array on the CPU.

Todo
The optimization to avoid the local copy currently isn't implemented.

Definition at line 482 of file gpu_index_buffer.cc.

References blender::array_utils::copy(), copy(), data, GPU_indexbuf_calloc(), blender::gpu::indices_per_primitive(), MEM_malloc_arrayN(), and blender::threading::memory_bandwidth_bound_task().

Referenced by blender::draw::extract_edituv_tris_mesh(), and blender::draw::extract_tris_mesh().

◆ GPU_indexbuf_build_in_place()

◆ GPU_indexbuf_build_in_place_ex()

◆ GPU_indexbuf_build_on_device()

◆ GPU_indexbuf_calloc()

◆ GPU_indexbuf_create_subrange()

◆ GPU_indexbuf_create_subrange_in_place()

void GPU_indexbuf_create_subrange_in_place ( IndexBuf * elem,
IndexBuf * elem_src,
uint start,
uint length )

Definition at line 501 of file gpu_index_buffer.cc.

References blender::gpu::IndexBuf::init_subrange(), and length().

Referenced by GPU_indexbuf_create_subrange().

◆ GPU_indexbuf_discard()

◆ GPU_indexbuf_get_data()

blender::MutableSpan< uint32_t > GPU_indexbuf_get_data ( GPUIndexBufBuilder * builder)

Definition at line 95 of file gpu_index_buffer.cc.

References GPUIndexBufBuilder::data, and GPUIndexBufBuilder::max_index_len.

Referenced by blender::draw::build_tris_from_subdiv_quad_selection(), blender::draw::calc_edit_handles_ibo(), blender::draw::create_lines_ibo_no_cyclic(), blender::draw::create_lines_ibo_with_cyclic(), blender::draw::pbvh::create_lines_index_bmesh(), blender::draw::pbvh::create_lines_index_faces(), blender::draw::pbvh::create_lines_index_grids(), blender::draw::pbvh::create_tri_index_grids(), blender::draw::pbvh::create_tri_index_mesh(), blender::draw::extract_edituv_face_dots_bm(), blender::draw::extract_edituv_face_dots_mesh(), blender::draw::extract_edituv_lines_bm(), blender::draw::extract_edituv_lines_mesh(), blender::draw::extract_edituv_lines_subdiv_bm(), blender::draw::extract_edituv_lines_subdiv_mesh(), blender::draw::extract_edituv_tris_bm(), blender::draw::extract_edituv_tris_mesh(), blender::draw::extract_lines_bm(), blender::draw::extract_lines_mesh(), blender::draw::extract_lines_paint_mask(), blender::draw::extract_lines_paint_mask_subdiv(), blender::draw::extract_points_bm(), blender::draw::extract_points_mesh(), blender::draw::extract_points_subdiv_bm(), blender::draw::extract_points_subdiv_mesh(), blender::draw::extract_tris_bmesh(), blender::draw::extract_tris_mesh(), blender::draw::grease_pencil_edit_batch_ensure(), blender::draw::grease_pencil_geom_batch_ensure(), blender::draw::grease_pencil_weight_batch_ensure(), blender::draw::grease_pencil_wire_batch_ensure(), blender::draw::index_mask_to_ibo(), blender::draw::index_mask_to_ibo(), blender::draw::lattice_batch_cache_get_edges(), and blender::draw::pointcloud_extract_indices().

◆ GPU_indexbuf_init()

void GPU_indexbuf_init ( GPUIndexBufBuilder * builder,
GPUPrimType prim_type,
uint prim_len,
uint vertex_len )

Supports only GPU_PRIM_POINTS, GPU_PRIM_LINES and GPU_PRIM_TRIS.

Definition at line 72 of file gpu_index_buffer.cc.

References BLI_assert, GPU_indexbuf_init_ex(), and GPU_indexbuf_primitive_len().

Referenced by blender::draw::build_tris_from_subdiv_quad_selection(), blender::draw::calc_edit_handles_ibo(), blender::draw::create_lines_ibo_no_cyclic(), blender::draw::create_lines_ibo_with_cyclic(), blender::draw::pbvh::create_lines_index_bmesh(), blender::draw::pbvh::create_lines_index_faces(), blender::draw::pbvh::create_lines_index_grids(), blender::ed::vse::create_quads_index_buffer(), blender::draw::pbvh::create_tri_index_grids(), blender::draw::pbvh::create_tri_index_mesh(), blender::draw::curve_create_edit_data_and_handles(), blender::draw::drw_volume_selection_surface_cb(), blender::draw::drw_volume_wireframe_cb(), blender::draw::extract_edituv_face_dots_bm(), blender::draw::extract_edituv_face_dots_mesh(), blender::draw::extract_edituv_lines_bm(), blender::draw::extract_edituv_lines_mesh(), blender::draw::extract_edituv_lines_subdiv_bm(), blender::draw::extract_edituv_lines_subdiv_mesh(), blender::draw::extract_edituv_points(), blender::draw::extract_edituv_points_subdiv(), blender::draw::extract_edituv_tris_bm(), blender::draw::extract_edituv_tris_mesh(), blender::draw::extract_lines_adjacency(), blender::draw::extract_lines_adjacency_subdiv(), blender::draw::extract_lines_bm(), blender::draw::extract_lines_mesh(), blender::draw::extract_lines_paint_mask(), blender::draw::extract_lines_paint_mask_subdiv(), blender::draw::extract_points_bm(), blender::draw::extract_points_mesh(), blender::draw::extract_points_subdiv_bm(), blender::draw::extract_points_subdiv_mesh(), blender::draw::extract_tris_bmesh(), blender::draw::extract_tris_mesh(), GPU_batch_tris_from_poly_2d_encoded(), GPU_batch_unit_cube(), blender::draw::grease_pencil_edit_batch_ensure(), blender::draw::grease_pencil_geom_batch_ensure(), blender::draw::grease_pencil_weight_batch_ensure(), blender::draw::index_mask_to_ibo(), blender::draw::index_mask_to_ibo(), blender::draw::lattice_batch_cache_get_edges(), blender::ed::space_node::nodesocket_batch_init(), blender::draw::pointcloud_extract_indices(), pygpu_IndexBuf__tp_new(), blender::draw::overlay::ShapeCache::ShapeCache(), blender::gpu::tests::test_index_buffer_subbuilders(), ui_batch_roundbox_widget_get(), wm_gizmo_geometryinfo_draw(), and wm_xr_controller_model_batch_create().

◆ GPU_indexbuf_init_build_on_device()

void GPU_indexbuf_init_build_on_device ( IndexBuf * elem,
uint index_len )

◆ GPU_indexbuf_init_ex()

◆ GPU_indexbuf_is_init()

bool GPU_indexbuf_is_init ( IndexBuf * elem)

Definition at line 519 of file gpu_index_buffer.cc.

References blender::gpu::IndexBuf::is_init().

Referenced by DRW_ibo_requested().

◆ GPU_indexbuf_join()

◆ GPU_indexbuf_primitive_len()

int GPU_indexbuf_primitive_len ( GPUPrimType prim_type)

◆ GPU_indexbuf_read()

void GPU_indexbuf_read ( blender::gpu::IndexBuf * elem,
uint32_t * data )

(Download and) fill data with the contents of the index buffer.

NOTE: caller is responsible to reserve enough memory.

Definition at line 509 of file gpu_index_buffer.cc.

References data, and blender::gpu::IndexBuf::read().

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

◆ GPU_indexbuf_set_line_restart()

◆ GPU_indexbuf_set_line_verts()

◆ GPU_indexbuf_set_point_restart()

◆ GPU_indexbuf_set_point_vert()

◆ GPU_indexbuf_set_tri_restart()

◆ GPU_indexbuf_set_tri_verts()

◆ GPU_indexbuf_update_sub()

void GPU_indexbuf_update_sub ( IndexBuf * elem,
uint start,
uint len,
const void * data )

Definition at line 539 of file gpu_index_buffer.cc.

References data, len, and blender::gpu::IndexBuf::update_sub().

◆ GPU_indexbuf_use()

void GPU_indexbuf_use ( IndexBuf * elem)

Definition at line 529 of file gpu_index_buffer.cc.

References blender::gpu::IndexBuf::upload_data().