Blender  V3.3
gpu_batch.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_math_base.h"
#include "GPU_batch.h"
#include "GPU_batch_presets.h"
#include "GPU_platform.h"
#include "GPU_shader.h"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
#include "gpu_index_buffer_private.hh"
#include "gpu_shader_private.hh"
#include "gpu_vertex_buffer_private.hh"
#include "gpu_batch_private.hh"
#include <cstring>

Go to the source code of this file.

Functions

Creation & Deletion
GPUBatchGPU_batch_calloc ()
 
GPUBatchGPU_batch_create_ex (GPUPrimType prim_type, GPUVertBuf *verts, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
 
void GPU_batch_init_ex (GPUBatch *batch, GPUPrimType prim_type, GPUVertBuf *verts, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
 
void GPU_batch_copy (GPUBatch *batch_dst, GPUBatch *batch_src)
 
void GPU_batch_clear (GPUBatch *batch)
 
void GPU_batch_discard (GPUBatch *batch)
 
Buffers Management
void GPU_batch_instbuf_set (GPUBatch *batch, GPUVertBuf *inst, bool own_vbo)
 
void GPU_batch_elembuf_set (GPUBatch *batch, GPUIndexBuf *elem, bool own_ibo)
 
int GPU_batch_instbuf_add_ex (GPUBatch *batch, GPUVertBuf *insts, bool own_vbo)
 
int GPU_batch_vertbuf_add_ex (GPUBatch *batch, GPUVertBuf *verts, bool own_vbo)
 
bool GPU_batch_vertbuf_has (GPUBatch *batch, GPUVertBuf *verts)
 
Uniform setters

TODO(fclem): port this to GPUShader.

void GPU_batch_set_shader (GPUBatch *batch, GPUShader *shader)
 
Drawing / Drawcall functions
void GPU_batch_draw (GPUBatch *batch)
 
void GPU_batch_draw_range (GPUBatch *batch, int v_first, int v_count)
 
void GPU_batch_draw_instanced (GPUBatch *batch, int i_count)
 
void GPU_batch_draw_advanced (GPUBatch *gpu_batch, int v_first, int v_count, int i_first, int i_count)
 
Utilities
void GPU_batch_program_set_builtin_with_config (GPUBatch *batch, eGPUBuiltinShader shader_id, eGPUShaderConfig sh_cfg)
 
void GPU_batch_program_set_builtin (GPUBatch *batch, eGPUBuiltinShader shader_id)
 
void GPU_batch_program_set_imm_shader (GPUBatch *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

◆ GPU_batch_calloc()

GPUBatch* GPU_batch_calloc ( void  )

◆ GPU_batch_clear()

void GPU_batch_clear ( GPUBatch batch)

◆ GPU_batch_copy()

void GPU_batch_copy ( GPUBatch batch_dst,
GPUBatch batch_src 
)

This will share the VBOs with the new batch.

Definition at line 76 of file gpu_batch.cc.

References GPU_batch_init_ex(), GPU_BATCH_INVALID, GPU_BATCH_VBO_MAX_LEN, GPU_PRIM_POINTS, and v.

Referenced by DRW_instance_buffer_finish().

◆ GPU_batch_create_ex()

GPUBatch* GPU_batch_create_ex ( GPUPrimType  prim_type,
GPUVertBuf verts,
GPUIndexBuf elem,
eGPUBatchFlag  owns_flag 
)

Definition at line 43 of file gpu_batch.cc.

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

Referenced by batch_screen_edges_get(), batch_sphere_wire(), blf_batch_draw_init(), curves_batch_cache_ensure_procedural_indices(), draw_cache_view_batch(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), draw_seq_fcurve_overlay(), 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_gpencil_face_wireframe_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_gpencil_dummy_buffer_get(), DRW_metaball_batch_cache_get_triangles_with_normals(), DRW_metaball_batch_cache_get_wireframes_face(), drw_volume_selection_surface_cb(), drw_volume_wireframe_cb(), 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_viewport_batch_create(), immBeginBatch(), knifetool_draw(), lattice_batch_cache_create_overlay_batches(), blender::ed::space_node::nodelink_batch_init(), particle_batch_cache_ensure_procedural_indices(), stitch_draw_vbo(), ui_batch_roundbox_shadow_get(), ui_batch_roundbox_widget_get(), waveform_draw_one(), wm_gizmo_geometryinfo_draw(), and wm_xr_controller_model_batch_create().

◆ GPU_batch_discard()

void GPU_batch_discard ( GPUBatch batch)

◆ GPU_batch_draw()

void GPU_batch_draw ( GPUBatch batch)

◆ GPU_batch_draw_advanced()

void GPU_batch_draw_advanced ( GPUBatch gpu_batch,
int  v_first,
int  v_count,
int  i_first,
int  i_count 
)

◆ GPU_batch_draw_instanced()

void GPU_batch_draw_instanced ( GPUBatch batch,
int  i_count 
)

Draw multiple instance of a batch without having any instance attributes.

Definition at line 235 of file gpu_batch.cc.

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

Referenced by icon_draw_cache_texture_flush_ex(), and UI_widgetbase_draw_cache_flush().

◆ GPU_batch_draw_range()

void GPU_batch_draw_range ( GPUBatch batch,
int  v_first,
int  v_count 
)

Definition at line 229 of file gpu_batch.cc.

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

Referenced by knifetool_draw(), and wm_xr_controller_model_draw().

◆ GPU_batch_elembuf_set()

void GPU_batch_elembuf_set ( GPUBatch batch,
GPUIndexBuf elem,
bool  own_ibo 
)
Note
Override any previously assigned elem (and free it if owned).

Definition at line 135 of file gpu_batch.cc.

References batch, BLI_assert, GPU_BATCH_DIRTY, GPU_BATCH_OWNS_INDEX, GPU_indexbuf_discard(), and SET_FLAG_FROM_TEST.

Referenced by DRW_ibo_request().

◆ gpu_batch_exit()

void gpu_batch_exit ( void  )

Definition at line 308 of file gpu_batch.cc.

References gpu_batch_presets_exit().

Referenced by GPU_exit().

◆ gpu_batch_init()

void gpu_batch_init ( void  )

Definition at line 303 of file gpu_batch.cc.

References gpu_batch_presets_init().

Referenced by GPU_init().

◆ GPU_batch_init_ex()

void GPU_batch_init_ex ( GPUBatch batch,
GPUPrimType  prim_type,
GPUVertBuf verts,
GPUIndexBuf elem,
eGPUBatchFlag  owns_flag 
)

◆ GPU_batch_instbuf_add_ex()

int GPU_batch_instbuf_add_ex ( GPUBatch batch,
GPUVertBuf insts,
bool  own_vbo 
)

◆ GPU_batch_instbuf_set()

void GPU_batch_instbuf_set ( GPUBatch batch,
GPUVertBuf inst,
bool  own_vbo 
)
Note
Override ONLY the first instance VBO (and free them if owned).

Definition at line 122 of file gpu_batch.cc.

References batch, BLI_assert, GPU_BATCH_DIRTY, GPU_BATCH_OWNS_INST_VBO, GPU_vertbuf_discard(), and SET_FLAG_FROM_TEST.

Referenced by blf_batch_draw_init(), and blender::ed::space_node::nodelink_batch_init().

◆ GPU_batch_program_set_builtin()

void GPU_batch_program_set_builtin ( GPUBatch batch,
eGPUBuiltinShader  shader_id 
)

◆ GPU_batch_program_set_builtin_with_config()

void GPU_batch_program_set_builtin_with_config ( GPUBatch batch,
eGPUBuiltinShader  shader_id,
eGPUShaderConfig  sh_cfg 
)

◆ GPU_batch_program_set_imm_shader()

void GPU_batch_program_set_imm_shader ( GPUBatch batch)

Bind program bound to IMM to the batch.

XXX Use this with much care. Drawing with the GPUBatch API is not compatible with IMM. DO NOT DRAW WITH THE BATCH BEFORE CALLING immUnbindProgram.

Definition at line 292 of file gpu_batch.cc.

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

Referenced by gpu_viewport_draw_colormanaged().

◆ GPU_batch_set_shader()

void GPU_batch_set_shader ( GPUBatch batch,
GPUShader shader 
)

◆ GPU_batch_vertbuf_add_ex()

int GPU_batch_vertbuf_add_ex ( GPUBatch batch,
GPUVertBuf verts,
bool  own_vbo 
)

◆ GPU_batch_vertbuf_has()

bool GPU_batch_vertbuf_has ( GPUBatch batch,
GPUVertBuf verts 
)

Definition at line 193 of file gpu_batch.cc.

References batch, GPU_BATCH_VBO_MAX_LEN, v, and verts.

Referenced by EEVEE_motion_blur_cache_finish().