Blender V4.5
GPU_batch.hh File Reference
#include "BLI_index_range.hh"
#include "BLI_utildefines.h"
#include "GPU_index_buffer.hh"
#include "GPU_shader.hh"
#include "GPU_storage_buffer.hh"
#include "GPU_vertex_buffer.hh"

Go to the source code of this file.

Macros

#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)
Procedural drawing

A draw-call always need a batch to be issued. These are dummy batches that contains no vertex data and can be used to render geometry without per vertex inputs.

blender::gpu::Batch * GPU_batch_procedural_points_get ()
blender::gpu::Batch * GPU_batch_procedural_lines_get ()
blender::gpu::Batch * GPU_batch_procedural_triangles_get ()
blender::gpu::Batch * GPU_batch_procedural_triangle_strips_get ()
Module init/exit
void gpu_batch_init ()
void gpu_batch_exit ()

Variables

static constexpr int GPU_BATCH_VBO_MAX_LEN = 16
static constexpr int GPU_BATCH_INST_VBO_MAX_LEN = 2
static constexpr int GPU_BATCH_VAO_STATIC_LEN = 3
static constexpr int GPU_BATCH_VAO_DYN_ALLOC_COUNT = 16

Creation

#define GPU_batch_create(primitive_type, vertex_buf, index_buf)
#define GPU_batch_init(batch, primitive_type, vertex_buf, index_buf)
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)
#define GPU_batch_uniform_1b(batch, name, x)
#define GPU_batch_uniform_1f(batch, name, x)
#define GPU_batch_uniform_2f(batch, name, x, y)
#define GPU_batch_uniform_3f(batch, name, x, y, z)
#define GPU_batch_uniform_4f(batch, name, x, y, z, w)
#define GPU_batch_uniform_2fv(batch, name, val)
#define GPU_batch_uniform_3fv(batch, name, val)
#define GPU_batch_uniform_4fv(batch, name, val)
#define GPU_batch_uniform_2fv_array(batch, name, len, val)
#define GPU_batch_uniform_4fv_array(batch, name, len, val)
#define GPU_batch_uniform_mat4(batch, name, val)
#define GPU_batch_uniformbuf_bind(batch, name, ubo)
#define GPU_batch_texture_bind(batch, name, tex)
void GPU_batch_set_shader (blender::gpu::Batch *batch, GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
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, const blender::gpu::shader::SpecializationConstants *constants=nullptr)
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 (GPUPrimType input_prim_type, GPUPrimType output_prim_type, int vertex_count, int vertex_first, int output_primitive_cout)

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 @242053044010324116347033273112253060004051364061::@051143074301336237271216303350234260141112266062 batch

Definition at line 190 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

#define GPU_batch_create ( primitive_type,
vertex_buf,
index_buf )

◆ GPU_BATCH_DISCARD_SAFE

◆ GPU_batch_init

#define GPU_batch_init ( batch,
primitive_type,
vertex_buf,
index_buf )
Value:
GPU_batch_init_ex(batch, primitive_type, vertex_buf, index_buf, (eGPUBatchFlag)0)
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 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 166 of file GPU_batch.hh.

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

◆ GPU_BATCH_OWNS_NONE

#define GPU_BATCH_OWNS_NONE   GPU_BATCH_INVALID

Definition at line 60 of file GPU_batch.hh.

◆ GPU_batch_texture_bind

#define GPU_batch_texture_bind ( batch,
name,
tex )
Value:
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
void GPU_texture_bind(GPUTexture *texture, int unit)

Definition at line 318 of file GPU_batch.hh.

Referenced by blf_batch_draw().

◆ GPU_batch_uniform_1b

#define GPU_batch_uniform_1b ( batch,
name,
x )
Value:
GPU_shader_uniform_1b((batch)->shader, name, x);
void GPU_shader_uniform_1b(GPUShader *sh, const char *name, bool value)

Definition at line 300 of file GPU_batch.hh.

◆ GPU_batch_uniform_1f

#define GPU_batch_uniform_1f ( batch,
name,
x )
Value:
GPU_shader_uniform_1f((batch)->shader, name, x);
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)

Definition at line 301 of file GPU_batch.hh.

Referenced by button2d_draw_intern(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), ED_screen_draw_edges(), knifetool_draw(), ui_draw_dropshadow(), waveform_draw_one(), and waveform_draw_rgb().

◆ GPU_batch_uniform_1i

#define GPU_batch_uniform_1i ( batch,
name,
x )
Value:
GPU_shader_uniform_1i((batch)->shader, name, x);
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)

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

Definition at line 299 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 )
Value:
GPU_shader_uniform_2f((batch)->shader, name, x, y);
void GPU_shader_uniform_2f(GPUShader *sh, const char *name, float x, float y)

Definition at line 302 of file GPU_batch.hh.

◆ GPU_batch_uniform_2fv

#define GPU_batch_uniform_2fv ( batch,
name,
val )
Value:
GPU_shader_uniform_2fv((batch)->shader, name, val);
void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2])

Definition at line 307 of file GPU_batch.hh.

Referenced by button2d_draw_intern(), draw_line_bounds(), draw_line_loop(), and draw_line_pairs().

◆ GPU_batch_uniform_2fv_array

#define GPU_batch_uniform_2fv_array ( batch,
name,
len,
val )
Value:
GPU_shader_uniform_2fv_array((batch)->shader, name, len, val);
void GPU_shader_uniform_2fv_array(GPUShader *sh, const char *name, int len, const float(*val)[2])
uint len

Definition at line 310 of file GPU_batch.hh.

◆ GPU_batch_uniform_3f

#define GPU_batch_uniform_3f ( batch,
name,
x,
y,
z )
Value:
GPU_shader_uniform_3f((batch)->shader, name, x, y, z);
void GPU_shader_uniform_3f(GPUShader *sh, const char *name, float x, float y, float z)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117

Definition at line 303 of file GPU_batch.hh.

◆ GPU_batch_uniform_3fv

#define GPU_batch_uniform_3fv ( batch,
name,
val )
Value:
GPU_shader_uniform_3fv((batch)->shader, name, val);
void GPU_shader_uniform_3fv(GPUShader *sh, const char *name, const float data[3])

Definition at line 308 of file GPU_batch.hh.

Referenced by blender::ed::curves::curve_draw_stroke_3d(), curve_draw_stroke_3d(), draw_widgetbase_batch(), and UI_widgetbase_draw_cache_flush().

◆ GPU_batch_uniform_4f

#define GPU_batch_uniform_4f ( batch,
name,
x,
y,
z,
w )
Value:
GPU_shader_uniform_4f((batch)->shader, name, x, y, z, w);
void GPU_shader_uniform_4f(GPUShader *sh, const char *name, float x, float y, float z, float w)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119

Definition at line 305 of file GPU_batch.hh.

Referenced by waveform_draw_one().

◆ GPU_batch_uniform_4fv

#define GPU_batch_uniform_4fv ( batch,
name,
val )

◆ GPU_batch_uniform_4fv_array

#define GPU_batch_uniform_4fv_array ( batch,
name,
len,
val )
Value:
GPU_shader_uniform_4fv_array((batch)->shader, name, len, val);
void GPU_shader_uniform_4fv_array(GPUShader *sh, const char *name, int len, const float(*val)[4])

Definition at line 312 of file GPU_batch.hh.

Referenced by blender::ed::space_node::draw_node_socket_batch(), draw_widgetbase_batch(), blender::ed::space_node::nodesocket_cache_flush(), ui_draw_dropshadow(), UI_draw_roundbox_4fv_ex(), and UI_widgetbase_draw_cache_flush().

◆ GPU_batch_uniform_mat4

#define GPU_batch_uniform_mat4 ( batch,
name,
val )
Value:
GPU_shader_uniform_mat4((batch)->shader, name, val);
void GPU_shader_uniform_mat4(GPUShader *sh, const char *name, const float data[4][4])

Definition at line 314 of file GPU_batch.hh.

◆ GPU_batch_uniformbuf_bind

#define GPU_batch_uniformbuf_bind ( batch,
name,
ubo )
Value:
int GPU_shader_get_ubo_binding(GPUShader *shader, const char *name)
void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int slot)

Definition at line 316 of file GPU_batch.hh.

Referenced by blender::ed::space_node::node_draw_link_bezier_ex(), blender::ed::space_node::nodelink_batch_draw(), and ui_draw_but_UNITVEC().

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 36 of file GPU_batch.hh.

Function Documentation

◆ GPU_batch_bind_as_resources()

void GPU_batch_bind_as_resources ( blender::gpu::Batch * batch,
GPUShader * shader,
const blender::gpu::shader::SpecializationConstants * constants = nullptr )

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

References batch.

Referenced by blender::ed::greasepencil::image_render::draw_grease_pencil_stroke(), 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.

References batch.

◆ 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.

◆ 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 51 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(), blender::ed::greasepencil::image_render::draw_grease_pencil_stroke(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), blender::render::hydra::DrawTexture::DrawTexture(), blender::draw::drw_volume_selection_surface_cb(), blender::draw::drw_volume_wireframe_cb(), GPU_batch_preset_quad(), gpu_batch_sphere(), GPU_batch_tris_from_poly_2d_encoded(), GPU_batch_unit_cube(), 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::ed::space_node::nodesocket_batch_init(), blender::draw::particle_batch_cache_ensure_procedural_indices(), blender::ed::vse::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(), blender::gpu::tests::vertex_buffer_fetch_mode(), 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.

References batch.

Referenced by blender::ed::greasepencil::image_render::draw_grease_pencil_stroke(), blender::draw::command::Draw::execute(), blender::gpu::tests::gpu_shader_lib_test(), blender::gpu::Immediate::polyline_draw_workaround(), 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 ( GPUPrimType input_prim_type,
GPUPrimType output_prim_type,
int vertex_count,
int vertex_first,
int output_primitive_cout )

◆ 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

References batch.

Referenced by 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.

References batch.

Referenced by blender::ed::vse::StripsDrawBatch::flush_batch(), blender::ed::vse::ThumbsDrawBatch::flush_batch(), blender::ed::space_node::nodesocket_cache_flush(), 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.

References batch.

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

◆ 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.

References batch.

Referenced by blender::ed::vse::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).

References batch.

Referenced by DRW_ibo_request().

◆ gpu_batch_exit()

void gpu_batch_exit ( )

Definition at line 564 of file gpu_batch.cc.

References gpu_batch_presets_exit().

Referenced by GPU_exit().

◆ gpu_batch_init()

void gpu_batch_init ( )

Definition at line 559 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().

References batch.

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.

References batch.

◆ 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).

References batch.

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

References batch, and count.

◆ GPU_batch_procedural_lines_get()

blender::gpu::Batch * GPU_batch_procedural_lines_get ( )

Batch with no attributes, suited for rendering procedural geometry. IMPORTANT: The returned batch is only valid for the current context.

Definition at line 538 of file gpu_batch.cc.

References blender::gpu::Context::get(), and blender::gpu::Context::procedural_lines_batch_get().

Referenced by blender::draw::command::procedural_batch_get(), and blender::draw::detail::PassBase< DrawCommandBufType >::procedural_batch_get().

◆ GPU_batch_procedural_points_get()

blender::gpu::Batch * GPU_batch_procedural_points_get ( )

Batch with no attributes, suited for rendering procedural geometry. IMPORTANT: The returned batch is only valid for the current context.

Definition at line 533 of file gpu_batch.cc.

References blender::gpu::Context::get(), and blender::gpu::Context::procedural_points_batch_get().

Referenced by blender::draw::command::procedural_batch_get(), and blender::draw::detail::PassBase< DrawCommandBufType >::procedural_batch_get().

◆ GPU_batch_procedural_triangle_strips_get()

blender::gpu::Batch * GPU_batch_procedural_triangle_strips_get ( )

Batch with no attributes, suited for rendering procedural geometry. IMPORTANT: The returned batch is only valid for the current context.

Definition at line 548 of file gpu_batch.cc.

References blender::gpu::Context::get(), and blender::gpu::Context::procedural_triangle_strips_batch_get().

Referenced by blender::draw::command::procedural_batch_get(), and blender::draw::detail::PassBase< DrawCommandBufType >::procedural_batch_get().

◆ GPU_batch_procedural_triangles_get()

blender::gpu::Batch * GPU_batch_procedural_triangles_get ( )

Batch with no attributes, suited for rendering procedural geometry. IMPORTANT: The returned batch is only valid for the current context.

Definition at line 543 of file gpu_batch.cc.

References blender::gpu::Context::get(), and blender::gpu::Context::procedural_triangles_batch_get().

Referenced by blender::draw::command::procedural_batch_get(), and blender::draw::detail::PassBase< DrawCommandBufType >::procedural_batch_get().

◆ 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 )

References batch.

◆ 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.

References batch.

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.

References batch.

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

◆ GPU_batch_set_shader()

◆ GPU_batch_vertbuf_add()

◆ 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.

References batch.

◆ GPU_batch_zero()

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

References batch.

Variable Documentation

◆ GPU_BATCH_INST_VBO_MAX_LEN

int GPU_BATCH_INST_VBO_MAX_LEN = 2
staticconstexpr

◆ GPU_BATCH_VAO_DYN_ALLOC_COUNT

int GPU_BATCH_VAO_DYN_ALLOC_COUNT = 16
staticconstexpr

Definition at line 34 of file GPU_batch.hh.

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

◆ GPU_BATCH_VAO_STATIC_LEN

int GPU_BATCH_VAO_STATIC_LEN = 3
staticconstexpr

Definition at line 33 of file GPU_batch.hh.

◆ GPU_BATCH_VBO_MAX_LEN