Blender V4.3
GPU_batch.hh File Reference

Go to the source code of this file.

Macros

#define GPU_BATCH_VBO_MAX_LEN   16
 
#define GPU_BATCH_INST_VBO_MAX_LEN   2
 
#define GPU_BATCH_VAO_STATIC_LEN   3
 
#define GPU_BATCH_VAO_DYN_ALLOC_COUNT   16
 
#define GPU_BATCH_OWNS_NONE   GPU_BATCH_INVALID
 

Enumerations

enum  eGPUBatchFlag {
  GPU_BATCH_INVALID = 0 , GPU_BATCH_OWNS_VBO = (1 << 0) , GPU_BATCH_OWNS_VBO_MAX = (GPU_BATCH_OWNS_VBO << (GPU_BATCH_VBO_MAX_LEN - 1)) , GPU_BATCH_OWNS_VBO_ANY = ((GPU_BATCH_OWNS_VBO << GPU_BATCH_VBO_MAX_LEN) - 1) ,
  GPU_BATCH_OWNS_INST_VBO = (GPU_BATCH_OWNS_VBO_MAX << 1) , GPU_BATCH_OWNS_INST_VBO_MAX = (GPU_BATCH_OWNS_INST_VBO << (GPU_BATCH_INST_VBO_MAX_LEN - 1)) , GPU_BATCH_OWNS_INST_VBO_ANY , GPU_BATCH_OWNS_INDEX = (GPU_BATCH_OWNS_INST_VBO_MAX << 1) ,
  GPU_BATCH_INIT = (1 << 26) , GPU_BATCH_BUILDING = (1 << 26) , GPU_BATCH_DIRTY = (1 << 27)
}
 

Functions

Buffers Management
int GPU_batch_vertbuf_add (blender::gpu::Batch *batch, blender::gpu::VertBuf *vertex_buf, bool own_vbo)
 
int GPU_batch_instbuf_add (blender::gpu::Batch *batch, blender::gpu::VertBuf *vertex_buf, bool own_vbo)
 
void GPU_batch_instbuf_set (blender::gpu::Batch *batch, blender::gpu::VertBuf *vertex_buf, bool own_vbo)
 
void GPU_batch_elembuf_set (blender::gpu::Batch *batch, blender::gpu::IndexBuf *index_buf, bool own_ibo)
 
bool GPU_batch_vertbuf_has (const blender::gpu::Batch *batch, const blender::gpu::VertBuf *vertex_buf)
 
void GPU_batch_resource_id_buf_set (blender::gpu::Batch *batch, GPUStorageBuf *resource_id_buf)
 
Module init/exit
void gpu_batch_init ()
 
void gpu_batch_exit ()
 

Creation

#define GPU_batch_create(primitive_type, vertex_buf, index_buf)    GPU_batch_create_ex(primitive_type, vertex_buf, index_buf, (eGPUBatchFlag)0)
 
#define GPU_batch_init(batch, primitive_type, vertex_buf, index_buf)    GPU_batch_init_ex(batch, primitive_type, vertex_buf, index_buf, (eGPUBatchFlag)0)
 
blender::gpu::Batch * GPU_batch_create_ex (GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
 
void GPU_batch_init_ex (blender::gpu::Batch *batch, GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
 
void GPU_batch_copy (blender::gpu::Batch *batch_dst, blender::gpu::Batch *batch_src)
 

Deletion

#define GPU_BATCH_CLEAR_SAFE(batch)
 
#define GPU_BATCH_DISCARD_SAFE(batch)
 
void GPU_batch_clear (blender::gpu::Batch *batch)
 
void GPU_batch_zero (blender::gpu::Batch *batch)
 
void GPU_batch_discard (blender::gpu::Batch *batch)
 

Shader Binding & Uniforms

#define GPU_batch_uniform_1i(batch, name, x)   GPU_shader_uniform_1i((batch)->shader, name, x);
 
#define GPU_batch_uniform_1b(batch, name, x)   GPU_shader_uniform_1b((batch)->shader, name, x);
 
#define GPU_batch_uniform_1f(batch, name, x)   GPU_shader_uniform_1f((batch)->shader, name, x);
 
#define GPU_batch_uniform_2f(batch, name, x, y)   GPU_shader_uniform_2f((batch)->shader, name, x, y);
 
#define GPU_batch_uniform_3f(batch, name, x, y, z)    GPU_shader_uniform_3f((batch)->shader, name, x, y, z);
 
#define GPU_batch_uniform_4f(batch, name, x, y, z, w)    GPU_shader_uniform_4f((batch)->shader, name, x, y, z, w);
 
#define GPU_batch_uniform_2fv(batch, name, val)   GPU_shader_uniform_2fv((batch)->shader, name, val);
 
#define GPU_batch_uniform_3fv(batch, name, val)   GPU_shader_uniform_3fv((batch)->shader, name, val);
 
#define GPU_batch_uniform_4fv(batch, name, val)   GPU_shader_uniform_4fv((batch)->shader, name, val);
 
#define GPU_batch_uniform_2fv_array(batch, name, len, val)    GPU_shader_uniform_2fv_array((batch)->shader, name, len, val);
 
#define GPU_batch_uniform_4fv_array(batch, name, len, val)    GPU_shader_uniform_4fv_array((batch)->shader, name, len, val);
 
#define GPU_batch_uniform_mat4(batch, name, val)    GPU_shader_uniform_mat4((batch)->shader, name, val);
 
#define GPU_batch_uniformbuf_bind(batch, name, ubo)    GPU_uniformbuf_bind(ubo, GPU_shader_get_ubo_binding((batch)->shader, name));
 
#define GPU_batch_texture_bind(batch, name, tex)    GPU_texture_bind(tex, GPU_shader_get_sampler_binding((batch)->shader, name));
 
void GPU_batch_set_shader (blender::gpu::Batch *batch, GPUShader *shader)
 
void GPU_batch_program_set_builtin (blender::gpu::Batch *batch, eGPUBuiltinShader shader_id)
 
void GPU_batch_program_set_builtin_with_config (blender::gpu::Batch *batch, eGPUBuiltinShader shader_id, eGPUShaderConfig sh_cfg)
 
void GPU_batch_program_set_imm_shader (blender::gpu::Batch *batch)
 
void GPU_batch_bind_as_resources (blender::gpu::Batch *batch, GPUShader *shader)
 
void GPU_batch_draw (blender::gpu::Batch *batch)
 
void GPU_batch_draw_range (blender::gpu::Batch *batch, int vertex_first, int vertex_count)
 
void GPU_batch_draw_instance_range (blender::gpu::Batch *batch, int instance_first, int instance_count)
 
void GPU_batch_draw_advanced (blender::gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
 
void GPU_batch_draw_indirect (blender::gpu::Batch *batch, GPUStorageBuf *indirect_buf, intptr_t offset)
 
void GPU_batch_multi_draw_indirect (blender::gpu::Batch *batch, GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride)
 
void GPU_batch_draw_parameter_get (blender::gpu::Batch *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)
 

Detailed Description

GPU geometry batch.

Contains Vertex Buffers, Index Buffers, and Shader reference, altogether representing a drawable entity. It is meant to be used for drawing large (> 1000 vertices) reusable (drawn multiple times) model with complex data layout. In other words, it is meant for all cases where the immediate drawing module (imm) is inadequate.

Vertex & Index Buffers can be owned by a batch. In such case they will be freed when the batch gets cleared or discarded.

Definition in file GPU_batch.hh.

Macro Definition Documentation

◆ GPU_BATCH_CLEAR_SAFE

#define GPU_BATCH_CLEAR_SAFE ( batch)
Value:
do { \
if (batch != nullptr) { \
GPU_batch_clear(batch); \
GPU_batch_zero(batch); \
} \
} while (0)
struct @620::@622 batch

Definition at line 191 of file GPU_batch.hh.

Referenced by blender::draw::DRW_mesh_batch_cache_create_requested(), and blender::draw::mesh_batch_cache_check_vertex_group().

◆ GPU_batch_create

◆ GPU_BATCH_DISCARD_SAFE

◆ GPU_batch_init

#define GPU_batch_init ( batch,
primitive_type,
vertex_buf,
index_buf )    GPU_batch_init_ex(batch, primitive_type, vertex_buf, index_buf, (eGPUBatchFlag)0)

Initialize a cleared #blender::gpu::Batch without buffer ownership. A #blender::gpu::Batch is in cleared state if it was just allocated using GPU_batch_calloc() or cleared using GPU_batch_clear().

Definition at line 167 of file GPU_batch.hh.

Referenced by DRW_temp_batch_request().

◆ GPU_BATCH_INST_VBO_MAX_LEN

◆ GPU_BATCH_OWNS_NONE

#define GPU_BATCH_OWNS_NONE   GPU_BATCH_INVALID

Definition at line 61 of file GPU_batch.hh.

◆ GPU_batch_texture_bind

#define GPU_batch_texture_bind ( batch,
name,
tex )    GPU_texture_bind(tex, GPU_shader_get_sampler_binding((batch)->shader, name));

Definition at line 316 of file GPU_batch.hh.

Referenced by blf_batch_draw(), and DRW_transform_none().

◆ GPU_batch_uniform_1b

#define GPU_batch_uniform_1b ( batch,
name,
x )   GPU_shader_uniform_1b((batch)->shader, name, x);

Definition at line 298 of file GPU_batch.hh.

◆ GPU_batch_uniform_1f

#define GPU_batch_uniform_1f ( batch,
name,
x )   GPU_shader_uniform_1f((batch)->shader, name, x);

◆ GPU_batch_uniform_1i

#define GPU_batch_uniform_1i ( batch,
name,
x )   GPU_shader_uniform_1i((batch)->shader, name, x);

Set uniform variables for the shader currently bound to the #blender::gpu::Batch.

Definition at line 297 of file GPU_batch.hh.

Referenced by blf_batch_draw(), ED_screen_draw_edges(), and gpu_viewport_draw_colormanaged().

◆ GPU_batch_uniform_2f

#define GPU_batch_uniform_2f ( batch,
name,
x,
y )   GPU_shader_uniform_2f((batch)->shader, name, x, y);

Definition at line 300 of file GPU_batch.hh.

◆ GPU_batch_uniform_2fv

#define GPU_batch_uniform_2fv ( batch,
name,
val )   GPU_shader_uniform_2fv((batch)->shader, name, val);

◆ GPU_batch_uniform_2fv_array

#define GPU_batch_uniform_2fv_array ( batch,
name,
len,
val )    GPU_shader_uniform_2fv_array((batch)->shader, name, len, val);

Definition at line 308 of file GPU_batch.hh.

◆ GPU_batch_uniform_3f

#define GPU_batch_uniform_3f ( batch,
name,
x,
y,
z )    GPU_shader_uniform_3f((batch)->shader, name, x, y, z);

Definition at line 301 of file GPU_batch.hh.

◆ GPU_batch_uniform_3fv

#define GPU_batch_uniform_3fv ( batch,
name,
val )   GPU_shader_uniform_3fv((batch)->shader, name, val);

◆ GPU_batch_uniform_4f

#define GPU_batch_uniform_4f ( batch,
name,
x,
y,
z,
w )    GPU_shader_uniform_4f((batch)->shader, name, x, y, z, w);

Definition at line 303 of file GPU_batch.hh.

Referenced by DRW_transform_none(), and waveform_draw_one().

◆ GPU_batch_uniform_4fv

◆ GPU_batch_uniform_4fv_array

#define GPU_batch_uniform_4fv_array ( batch,
name,
len,
val )    GPU_shader_uniform_4fv_array((batch)->shader, name, len, val);

◆ GPU_batch_uniform_mat4

#define GPU_batch_uniform_mat4 ( batch,
name,
val )    GPU_shader_uniform_mat4((batch)->shader, name, val);

Definition at line 312 of file GPU_batch.hh.

◆ GPU_batch_uniformbuf_bind

◆ GPU_BATCH_VAO_DYN_ALLOC_COUNT

#define GPU_BATCH_VAO_DYN_ALLOC_COUNT   16

Definition at line 35 of file GPU_batch.hh.

Referenced by blender::gpu::GLVaoCache::insert().

◆ GPU_BATCH_VAO_STATIC_LEN

#define GPU_BATCH_VAO_STATIC_LEN   3

Definition at line 34 of file GPU_batch.hh.

◆ GPU_BATCH_VBO_MAX_LEN

Enumeration Type Documentation

◆ eGPUBatchFlag

Enumerator
GPU_BATCH_INVALID 

Invalid default state.

GPU_BATCH_OWNS_VBO 

blender::gpu::VertBuf ownership. (One bit per vbo)

GPU_BATCH_OWNS_VBO_MAX 
GPU_BATCH_OWNS_VBO_ANY 
GPU_BATCH_OWNS_INST_VBO 

Instance blender::gpu::VertBuf ownership. (One bit per vbo)

GPU_BATCH_OWNS_INST_VBO_MAX 
GPU_BATCH_OWNS_INST_VBO_ANY 
GPU_BATCH_OWNS_INDEX 

blender::gpu::IndexBuf ownership.

GPU_BATCH_INIT 

Has been initialized. At least one VBO is set.

GPU_BATCH_BUILDING 

Batch is initialized but its VBOs are still being populated. (optional)

GPU_BATCH_DIRTY 

Cached data need to be rebuild. (VAO, PSO, ...)

Definition at line 37 of file GPU_batch.hh.

Function Documentation

◆ GPU_batch_bind_as_resources()

void GPU_batch_bind_as_resources ( blender::gpu::Batch * batch,
GPUShader * shader )

Bind vertex and index buffers to SSBOs using Frequency::GEOMETRY.

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

◆ GPU_batch_clear()

void GPU_batch_clear ( blender::gpu::Batch * batch)

Clear a #blender::gpu::Batch without freeing its own memory. The #blender::gpu::Batch can then be reused using GPU_batch_init(). Discards all owned vertex and index buffers.

Referenced by DRW_temp_batch_instance_request(), and DRW_temp_batch_request().

◆ GPU_batch_copy()

void GPU_batch_copy ( blender::gpu::Batch * batch_dst,
blender::gpu::Batch * batch_src )

DEPRECATED: It is easy to loose ownership with this. To be removed. This will share the VBOs with the new batch.

Referenced by DRW_instance_buffer_finish().

◆ GPU_batch_create_ex()

blender::gpu::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()

◆ GPU_batch_draw()

◆ GPU_batch_draw_advanced()

void GPU_batch_draw_advanced ( blender::gpu::Batch * batch,
int vertex_first,
int vertex_count,
int instance_first,
int instance_count )

Draw the #blender::gpu::Batch custom parameters. IMPORTANT: This does not bind/unbind shader and does not call GPU_matrix_bind().

A vertex_count of 0 will use the default number of vertex. An instance_count of 0 will use the default number of instances.

Note
No out-of-bound access check is made on the vertex buffers since they are tricky to detect. Double check that the range of vertex has data or that the data isn't read by the shader.

Referenced by blender::gpu::GLDrawList::append(), blender::gpu::MTLDrawList::append(), draw_geometry_execute(), blender::draw::command::Draw::execute(), blender::gpu::tests::gpu_shader_lib_test(), blender::gpu::tests::test_framebuffer_multi_viewport(), and blender::gpu::tests::ShaderSpecializationConst::validate().

◆ 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 ( blender::gpu::Batch * batch,
GPUStorageBuf * indirect_buf,
intptr_t offset )

Issue a single draw call using arguments sourced from a #GPUStorageBuf. The argument are expected to be valid for the type of geometry contained by this #blender::gpu::Batch (index or non-indexed).

The indirect buffer needs to be synced after filling its contents and before calling this function using GPU_storagebuf_sync_as_indirect_buffer.

For more info see the GL documentation: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDrawArraysIndirect.xhtml

Referenced by draw_call_indirect(), blender::draw::command::DrawIndirect::execute(), and blender::draw::command::DrawMulti::execute().

◆ GPU_batch_draw_instance_range()

void GPU_batch_draw_instance_range ( blender::gpu::Batch * batch,
int instance_first,
int instance_count )

Draw multiple instances of the #blender::gpu::Batch with custom instance range. Ensures the associated shader is bound. TODO(fclem) remove this behavior.

An instance_count of 0 will use the default number of instances. The instance_first sets the start of the instance-rate attributes.

Note
this can be used even if the #blender::gpu::Batch contains no instance-rate attributes.
No out-of-bound access check is made on the vertex buffers since they are tricky to detect. Double check that the range of vertex has data or that the data isn't read by the shader.

Referenced by blender::ed::seq::StripsDrawBatch::flush_batch(), ThumbsDrawBatch::flush_batch(), pygpu_batch_draw_instanced(), and UI_widgetbase_draw_cache_flush().

◆ GPU_batch_draw_parameter_get()

void GPU_batch_draw_parameter_get ( blender::gpu::Batch * batch,
int * r_vertex_count,
int * r_vertex_first,
int * r_base_index,
int * r_instance_count )

Return indirect draw call parameters for this #blender::gpu::Batch. NOTE: r_base_index is set to -1 if not using an index buffer.

Referenced by blender::draw::command::DrawMultiBuf::bind().

◆ GPU_batch_draw_range()

void GPU_batch_draw_range ( blender::gpu::Batch * batch,
int vertex_first,
int vertex_count )

Draw the #blender::gpu::Batch with vertex count and instance count from its vertex buffers lengths. Ensures the associated shader is bound. TODO(fclem) remove this behavior.

A vertex_count of 0 will use the default number of vertex. The vertex_first sets the start of the instance-rate attributes.

Note
No out-of-bound access check is made on the vertex buffers since they are tricky to detect. Double check that the range of vertex has data or that the data isn't read by the shader.

Referenced by SeqQuadsBatch::draw(), knifetool_draw(), pygpu_batch_draw_range(), and wm_xr_controller_model_draw().

◆ GPU_batch_elembuf_set()

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

Set the index buffer of a #blender::gpu::Batch.

Note
Override any previously assigned index buffer (and free it if owned).

Referenced by DRW_ibo_request().

◆ 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 ( blender::gpu::Batch * batch,
GPUPrimType primitive_type,
blender::gpu::VertBuf * vertex_buf,
blender::gpu::IndexBuf * index_buf,
eGPUBatchFlag owns_flag )

Initialize a cleared #blender::gpu::Batch with explicit buffer ownership. A #blender::gpu::Batch is in cleared state if it was just allocated using GPU_batch_calloc() or cleared using GPU_batch_clear().

Referenced by DRW_batch_requested().

◆ GPU_batch_instbuf_add()

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

Add the given vertex_buf as instanced vertex buffer to a #blender::gpu::Batch.

Returns
the index of verts in the batch.

Referenced by DRW_instance_buffer_finish().

◆ GPU_batch_instbuf_set()

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

Set the first instanced vertex buffer of a #blender::gpu::Batch.

Note
Override ONLY the first instance VBO (and free them if owned).

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

◆ GPU_batch_multi_draw_indirect()

void GPU_batch_multi_draw_indirect ( blender::gpu::Batch * batch,
GPUStorageBuf * indirect_buf,
int count,
intptr_t offset,
intptr_t stride )

Issue count draw calls using arguments sourced from a #GPUStorageBuf. The stride (in bytes) control the spacing between each command description. The argument are expected to be valid for the type of geometry contained by this #blender::gpu::Batch (index or non-indexed).

The indirect buffer needs to be synced after filling its contents and before calling this function using GPU_storagebuf_sync_as_indirect_buffer.

For more info see the GL documentation: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glMultiDrawArraysIndirect.xhtml

◆ GPU_batch_program_set_builtin()

◆ GPU_batch_program_set_builtin_with_config()

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

Referenced by DRW_draw_depth_object().

◆ GPU_batch_program_set_imm_shader()

void GPU_batch_program_set_imm_shader ( blender::gpu::Batch * batch)

Bind program bound to IMM (immediate mode) to the #blender::gpu::Batch.

XXX: Use this with much care. Drawing with the #blender::gpu::Batch API is not compatible with IMM. DO NOT DRAW WITH THE BATCH BEFORE CALLING immUnbindProgram.

Referenced by gpu_viewport_draw_colormanaged().

◆ GPU_batch_resource_id_buf_set()

void GPU_batch_resource_id_buf_set ( blender::gpu::Batch * batch,
GPUStorageBuf * resource_id_buf )

Set resource id buffer to bind as instance attribute to workaround the lack of gl_BaseInstance on some hardware / platform.

Note
Only to be used by draw manager.

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

◆ GPU_batch_set_shader()

◆ GPU_batch_vertbuf_add()

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

◆ GPU_batch_vertbuf_has()

bool GPU_batch_vertbuf_has ( const blender::gpu::Batch * batch,
const blender::gpu::VertBuf * vertex_buf )

Returns true if the #GPUbatch has vertex_buf in its vertex buffer list.

Note
The search is only conducted on the non-instance rate vertex buffer list.

◆ GPU_batch_zero()

void GPU_batch_zero ( blender::gpu::Batch * batch)