Blender V4.3
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 <algorithm>
#include <cstring>

Go to the source code of this file.

Namespaces

namespace  blender
 
namespace  blender::gpu
 

Macros

#define KEEP_SINGLE_COPY   1
 

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_tGPU_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)
 
void GPU_indexbuf_build_in_place_from_memory (IndexBuf *ibo, 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.

Macro Definition Documentation

◆ KEEP_SINGLE_COPY

#define KEEP_SINGLE_COPY   1

Definition at line 28 of 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_in_place()

◆ GPU_indexbuf_build_in_place_ex()

◆ GPU_indexbuf_build_in_place_from_memory()

void GPU_indexbuf_build_in_place_from_memory ( blender::gpu::IndexBuf * ibo,
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 517 of file gpu_index_buffer.cc.

References blender::array_utils::copy(), copy(), blender::gpu::indices_per_primitive(), blender::gpu::IndexBuf::init(), MEM_malloc_arrayN, and blender::threading::memory_bandwidth_bound_task().

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

◆ GPU_indexbuf_build_on_device()

IndexBuf * GPU_indexbuf_build_on_device ( uint index_len)

◆ GPU_indexbuf_calloc()

◆ GPU_indexbuf_create_subrange()

IndexBuf * GPU_indexbuf_create_subrange ( IndexBuf * elem_src,
uint start,
uint length )

◆ GPU_indexbuf_create_subrange_in_place()

◆ GPU_indexbuf_discard()

◆ GPU_indexbuf_get_data()

◆ 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 73 of file gpu_index_buffer.cc.

References GPU_indexbuf_init_ex(), and GPU_indexbuf_primitive_len().

Referenced by blender::draw::pbvh::create_index_bmesh(), blender::draw::pbvh::create_index_faces(), blender::draw::pbvh::create_lines_index_grids(), 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(), DRW_cache_bone_box_wire_get(), DRW_cache_bone_octahedral_wire_get(), DRW_cache_cube_get(), 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(), blender::draw::extract_edituv_lines_subdiv(), blender::draw::extract_edituv_points(), blender::draw::extract_edituv_points_subdiv(), blender::draw::extract_edituv_tris(), blender::draw::extract_edituv_tris_subdiv(), 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(), blender::draw::grease_pencil_geom_batch_ensure(), blender::draw::index_mask_to_ibo(), blender::draw::lattice_batch_cache_get_edges(), 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()

◆ GPU_indexbuf_init_ex()

◆ GPU_indexbuf_is_init()

bool GPU_indexbuf_is_init ( IndexBuf * elem)

Definition at line 554 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 544 of file gpu_index_buffer.cc.

References 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 574 of file gpu_index_buffer.cc.

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

◆ GPU_indexbuf_use()

void GPU_indexbuf_use ( IndexBuf * elem)

Definition at line 564 of file gpu_index_buffer.cc.

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