Blender V4.3
gpu_batch.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_math_base.h"
#include "BLI_utildefines.h"
#include "GPU_batch.hh"
#include "GPU_batch_presets.hh"
#include "GPU_platform.hh"
#include "GPU_shader.hh"
#include "GPU_index_buffer.hh"
#include "GPU_vertex_buffer.hh"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
#include "gpu_shader_private.hh"
#include <cstring>

Go to the source code of this file.

Functions

Creation & Deletion
void GPU_batch_zero (Batch *batch)
 
Batch * GPU_batch_calloc ()
 
Batch * GPU_batch_create_ex (GPUPrimType primitive_type, VertBuf *vertex_buf, IndexBuf *index_buf, eGPUBatchFlag owns_flag)
 
void GPU_batch_init_ex (Batch *batch, GPUPrimType primitive_type, VertBuf *vertex_buf, IndexBuf *index_buf, eGPUBatchFlag owns_flag)
 
void GPU_batch_copy (Batch *batch_dst, Batch *batch_src)
 
void GPU_batch_clear (Batch *batch)
 
void GPU_batch_discard (Batch *batch)
 
Buffers Management
void GPU_batch_instbuf_set (Batch *batch, VertBuf *vertex_buf, bool own_vbo)
 
void GPU_batch_elembuf_set (Batch *batch, blender::gpu::IndexBuf *index_buf, bool own_ibo)
 
int GPU_batch_instbuf_add (Batch *batch, VertBuf *vertex_buf, bool own_vbo)
 
int GPU_batch_vertbuf_add (Batch *batch, VertBuf *vertex_buf, bool own_vbo)
 
bool GPU_batch_vertbuf_has (const Batch *batch, const VertBuf *vertex_buf)
 
void GPU_batch_resource_id_buf_set (Batch *batch, GPUStorageBuf *resource_id_buf)
 
Uniform setters
void GPU_batch_set_shader (Batch *batch, GPUShader *shader)
 
static uint16_t bind_attribute_as_ssbo (const ShaderInterface *interface, GPUShader *shader, VertBuf *vbo)
 
void GPU_batch_bind_as_resources (Batch *batch, GPUShader *shader)
 
Drawing / Drawcall functions
void GPU_batch_draw_parameter_get (Batch *gpu_batch, int *r_vertex_count, int *r_vertex_first, int *r_base_index, int *r_instance_count)
 
blender::IndexRange GPU_batch_draw_expanded_parameter_get (const blender::gpu::Batch *batch, GPUPrimType expanded_prim_type, int vertex_count, int vertex_first)
 
void GPU_batch_draw (Batch *batch)
 
void GPU_batch_draw_range (Batch *batch, int vertex_first, int vertex_count)
 
void GPU_batch_draw_instance_range (Batch *batch, int instance_first, int instance_count)
 
void GPU_batch_draw_advanced (Batch *gpu_batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
 
void GPU_batch_draw_indirect (Batch *gpu_batch, GPUStorageBuf *indirect_buf, intptr_t offset)
 
void GPU_batch_multi_draw_indirect (Batch *gpu_batch, GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride)
 
Utilities
void GPU_batch_program_set_builtin_with_config (Batch *batch, eGPUBuiltinShader shader_id, eGPUShaderConfig sh_cfg)
 
void GPU_batch_program_set_builtin (Batch *batch, eGPUBuiltinShader shader_id)
 
void GPU_batch_program_set_imm_shader (Batch *batch)
 
Init/Exit
void gpu_batch_init ()
 
void gpu_batch_exit ()
 

Detailed Description

GPU geometry batch Contains VAOs + VBOs + Shader representing a drawable entity.

Definition in file gpu_batch.cc.

Function Documentation

◆ bind_attribute_as_ssbo()

◆ GPU_batch_bind_as_resources()

◆ GPU_batch_calloc()

◆ GPU_batch_clear()

◆ GPU_batch_copy()

void GPU_batch_copy ( Batch * batch_dst,
Batch * batch_src )

◆ GPU_batch_create_ex()

Batch * GPU_batch_create_ex ( GPUPrimType primitive_type,
blender::gpu::VertBuf * vertex_buf,
blender::gpu::IndexBuf * index_buf,
eGPUBatchFlag owns_flag )

Allocate a #blender::gpu::Batch with a cleared state. The returned #blender::gpu::Batch needs to be passed to GPU_batch_init before being usable. Creates a #blender::gpu::Batch with explicit buffer ownership.

Definition at line 56 of file gpu_batch.cc.

References batch, GPU_batch_calloc(), and GPU_batch_init_ex().

Referenced by batch_screen_edges_get(), batch_sphere_wire(), blf_batch_draw_init(), blender::draw::calc_final_indices(), circle_draw_rgb(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), blender::render::hydra::DrawTexture::DrawTexture(), DRW_cache_bone_arrows_get(), DRW_cache_bone_box_get(), DRW_cache_bone_box_wire_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_octahedral_wire_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_empty_sphere_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_icon_inner_lines_get(), DRW_cache_light_icon_outer_lines_get(), DRW_cache_light_icon_sun_rays_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_triangle_strips_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_gpencil_dummy_buffer_get(), blender::draw::drw_volume_selection_surface_cb(), blender::draw::drw_volume_wireframe_cb(), 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(), blender::gpu::tests::gpu_shader_lib_test(), gpu_viewport_batch_create(), immBeginBatch(), knifetool_draw(), blender::draw::lattice_batch_cache_create_overlay_batches(), blender::ed::space_node::nodelink_batch_init(), blender::draw::particle_batch_cache_ensure_procedural_indices(), SeqQuadsBatch::SeqQuadsBatch(), blender::draw::overlay::ShapeCache::ShapeCache(), stitch_draw_vbo(), blender::gpu::tests::test_framebuffer_multi_viewport(), blender::gpu::tests::test_framebuffer_subpass_input(), ui_batch_roundbox_shadow_get(), ui_batch_roundbox_widget_get(), blender::gpu::tests::ShaderSpecializationConst::validate(), waveform_draw_one(), waveform_draw_rgb(), wm_gizmo_geometryinfo_draw(), and wm_xr_controller_model_batch_create().

◆ GPU_batch_discard()

void GPU_batch_discard ( Batch * batch)

Definition at line 124 of file gpu_batch.cc.

References batch, and GPU_batch_clear().

◆ GPU_batch_draw()

void GPU_batch_draw ( Batch * batch)

Definition at line 375 of file gpu_batch.cc.

References batch, GPU_batch_draw_advanced(), and GPU_shader_bind().

◆ GPU_batch_draw_advanced()

void GPU_batch_draw_advanced ( Batch * gpu_batch,
int vertex_first,
int vertex_count,
int instance_first,
int instance_count )

◆ GPU_batch_draw_expanded_parameter_get()

blender::IndexRange GPU_batch_draw_expanded_parameter_get ( const blender::gpu::Batch * batch,
GPUPrimType expanded_prim_type,
int vertex_count,
int vertex_first )

Return vertex range for this #blender::gpu::Batch when using primitive expansions.

Definition at line 355 of file gpu_batch.cc.

References batch, BLI_assert_msg, and blender::gpu::indices_per_primitive().

Referenced by blender::draw::command::DrawMultiBuf::bind(), and blender::draw::command::Draw::execute().

◆ GPU_batch_draw_indirect()

void GPU_batch_draw_indirect ( Batch * gpu_batch,
GPUStorageBuf * indirect_buf,
intptr_t offset )

Definition at line 425 of file gpu_batch.cc.

References batch, BLI_assert, and blender::gpu::Context::get().

◆ GPU_batch_draw_instance_range()

void GPU_batch_draw_instance_range ( Batch * batch,
int instance_first,
int instance_count )

Definition at line 387 of file gpu_batch.cc.

References batch, BLI_assert, GPU_batch_draw_advanced(), and GPU_shader_bind().

◆ GPU_batch_draw_parameter_get()

void GPU_batch_draw_parameter_get ( Batch * gpu_batch,
int * r_vertex_count,
int * r_vertex_first,
int * r_base_index,
int * r_instance_count )

Definition at line 328 of file gpu_batch.cc.

References batch, and min_ii().

◆ GPU_batch_draw_range()

void GPU_batch_draw_range ( Batch * batch,
int vertex_first,
int vertex_count )

Definition at line 381 of file gpu_batch.cc.

References batch, GPU_batch_draw_advanced(), and GPU_shader_bind().

◆ GPU_batch_elembuf_set()

void GPU_batch_elembuf_set ( Batch * batch,
blender::gpu::IndexBuf * index_buf,
bool own_ibo )

◆ gpu_batch_exit()

void gpu_batch_exit ( )

Definition at line 479 of file gpu_batch.cc.

References gpu_batch_presets_exit().

Referenced by GPU_exit().

◆ gpu_batch_init()

void gpu_batch_init ( )

Definition at line 474 of file gpu_batch.cc.

References gpu_batch_presets_init().

Referenced by GPU_init().

◆ GPU_batch_init_ex()

void GPU_batch_init_ex ( Batch * batch,
GPUPrimType primitive_type,
VertBuf * vertex_buf,
IndexBuf * index_buf,
eGPUBatchFlag owns_flag )

◆ GPU_batch_instbuf_add()

int GPU_batch_instbuf_add ( Batch * batch,
VertBuf * vertex_buf,
bool own_vbo )

◆ GPU_batch_instbuf_set()

void GPU_batch_instbuf_set ( Batch * batch,
VertBuf * vertex_buf,
bool own_vbo )

◆ GPU_batch_multi_draw_indirect()

void GPU_batch_multi_draw_indirect ( Batch * gpu_batch,
GPUStorageBuf * indirect_buf,
int count,
intptr_t offset,
intptr_t stride )

Definition at line 434 of file gpu_batch.cc.

References batch, BLI_assert, count, and blender::gpu::Context::get().

◆ GPU_batch_program_set_builtin()

void GPU_batch_program_set_builtin ( Batch * batch,
eGPUBuiltinShader shader_id )

◆ GPU_batch_program_set_builtin_with_config()

void GPU_batch_program_set_builtin_with_config ( Batch * batch,
eGPUBuiltinShader shader_id,
eGPUShaderConfig sh_cfg )

◆ GPU_batch_program_set_imm_shader()

void GPU_batch_program_set_imm_shader ( Batch * batch)

Definition at line 463 of file gpu_batch.cc.

References batch, GPU_batch_set_shader(), and immGetShader().

◆ GPU_batch_resource_id_buf_set()

void GPU_batch_resource_id_buf_set ( Batch * batch,
GPUStorageBuf * resource_id_buf )

Definition at line 217 of file gpu_batch.cc.

References batch, BLI_assert, and GPU_BATCH_DIRTY.

◆ GPU_batch_set_shader()

void GPU_batch_set_shader ( Batch * batch,
GPUShader * shader )

◆ GPU_batch_vertbuf_add()

int GPU_batch_vertbuf_add ( Batch * batch,
VertBuf * vertex_buf,
bool own_vbo )

◆ GPU_batch_vertbuf_has()

bool GPU_batch_vertbuf_has ( const Batch * batch,
const VertBuf * vertex_buf )

Definition at line 207 of file gpu_batch.cc.

References batch, GPU_BATCH_VBO_MAX_LEN, and v.

◆ GPU_batch_zero()

void GPU_batch_zero ( Batch * batch)

Definition at line 38 of file gpu_batch.cc.

References ARRAY_SIZE, and batch.

Referenced by GPU_batch_calloc().