Blender V5.3
GPU_batch.hh File Reference
#include "BLI_enum_flags.hh"
#include "BLI_index_range.hh"
#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.

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::gpu

Macros

#define GPU_BATCH_OWNS_NONE   GPU_BATCH_INVALID

Enumerations

enum  blender::GPUBatchFlag {
  blender::GPU_BATCH_INVALID = 0 , blender::GPU_BATCH_OWNS_VBO = (1 << 0) , blender::GPU_BATCH_OWNS_VBO_MAX = (GPU_BATCH_OWNS_VBO << (GPU_BATCH_VBO_MAX_LEN - 1)) , blender::GPU_BATCH_OWNS_VBO_ANY = ((GPU_BATCH_OWNS_VBO << GPU_BATCH_VBO_MAX_LEN) - 1) ,
  blender::GPU_BATCH_OWNS_INDEX = (GPU_BATCH_OWNS_VBO_MAX << 1) , blender::GPU_BATCH_INIT = (1 << 26) , blender::GPU_BATCH_BUILDING = (1 << 26) , blender::GPU_BATCH_DIRTY = (1 << 27)
}

Functions

 blender::BLI_STATIC_ASSERT (GPU_BATCH_OWNS_INDEX< GPU_BATCH_INIT, "GPUBatchFlag: Error: status flags are shadowed by the ownership bits!") namespace gpu
Buffers Management
int blender::GPU_batch_vertbuf_add (gpu::Batch *batch, gpu::VertBuf *vertex_buf, bool own_vbo)
void blender::GPU_batch_elembuf_set (gpu::Batch *batch, gpu::IndexBuf *index_buf, bool own_ibo)
bool blender::GPU_batch_vertbuf_has (const gpu::Batch *batch, const gpu::VertBuf *vertex_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.

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

Variables

static constexpr int blender::GPU_BATCH_VBO_MAX_LEN = 16
static constexpr int blender::GPU_BATCH_VAO_STATIC_LEN = 3
static constexpr int blender::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)
gpu::Batch * blender::GPU_batch_calloc ()
gpu::Batch * blender::GPU_batch_create_ex (GPUPrimType primitive_type, gpu::VertBuf *vertex_buf, gpu::IndexBuf *index_buf, GPUBatchFlag owns_flag)
gpu::Batch * blender::GPU_batch_create_procedural (GPUPrimType primitive_type, int32_t vertex_count)
void blender::GPU_batch_init_ex (gpu::Batch *batch, GPUPrimType primitive_type, gpu::VertBuf *vertex_buf, gpu::IndexBuf *index_buf, GPUBatchFlag owns_flag)
void blender::GPU_batch_copy (gpu::Batch *batch_dst, gpu::Batch *batch_src)

Deletion

#define GPU_BATCH_CLEAR_SAFE(batch)
#define GPU_BATCH_DISCARD_SAFE(batch)
void blender::GPU_batch_clear (gpu::Batch *batch)
void blender::GPU_batch_zero (gpu::Batch *batch)
void blender::GPU_batch_discard (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 blender::GPU_batch_set_shader (gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void blender::GPU_batch_program_set_builtin (gpu::Batch *batch, GPUBuiltinShader shader_id)
void blender::GPU_batch_program_set_builtin_with_config (gpu::Batch *batch, GPUBuiltinShader shader_id, GPUShaderConfig sh_cfg)
void blender::GPU_batch_program_set_imm_shader (gpu::Batch *batch)
void blender::GPU_batch_bind_as_resources (gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants=nullptr)
void blender::GPU_batch_draw (gpu::Batch *batch)
void blender::GPU_batch_draw_range (gpu::Batch *batch, int vertex_first, int vertex_count)
void blender::GPU_batch_draw_instance_range (gpu::Batch *batch, int instance_first, int instance_count)
void blender::GPU_batch_draw_advanced (gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
void blender::GPU_batch_draw_indirect (gpu::Batch *batch, gpu::StorageBuf *indirect_buf, intptr_t offset)
void blender::GPU_batch_multi_draw_indirect (gpu::Batch *batch, gpu::StorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride)
void blender::GPU_batch_draw_parameter_get (gpu::Batch *batch, int *r_vertex_count, int *r_vertex_first, int *r_base_index, int *r_instance_count)
IndexRange blender::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)

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

#define GPU_BATCH_DISCARD_SAFE ( batch)
Value:
do { \
if (batch != nullptr) { \
GPU_batch_discard(batch); \
batch = nullptr; \
} \
} while (0)

Definition at line 199 of file GPU_batch.hh.

Referenced by blender::animviz_calc_motionpaths(), blender::blf_batch_draw_exit(), blender::draw::CurvesEvalCache::clear(), blender::draw::clear_edit_data(), blender::bke::motionpath::clear_preview_location(), blender::draw::curve_batch_cache_clear(), blender::draw::discard_buffers(), blender::draw::GSplatEvalCache::discard_buffers(), blender::draw::DRW_curve_batch_cache_dirty_tag(), blender::draw::DRW_lattice_batch_cache_dirty_tag(), blender::draw::DRW_particles_batch_cache_get_edit_strands(), blender::draw::pbvh::free_batches(), blender::bke::motionpath::free_cache(), blender::gpu::Context::free_resources(), blender::gizmo_button2d_free(), blender::draw::grease_pencil_batch_cache_clear(), blender::draw::lattice_batch_cache_clear(), blender::draw::mesh_batch_cache_clear(), blender::draw::particle_batch_cache_clear(), blender::draw::particle_batch_cache_clear_hair(), blender::draw::particle_batch_cache_clear_point(), blender::draw::pointcloud_batch_cache_clear(), blender::bke::motionpath::set_preview_location(), blender::draw::test_draw_curves_lib(), blender::draw::test_eevee_shadow_tag_update(), blender::draw::volume_batch_cache_clear(), blender::eevee::LookdevModule::~LookdevModule(), blender::workbench::SceneResources::~SceneResources(), blender::eevee::ShadowModule::~ShadowModule(), and blender::eevee::VolumeModule::~VolumeModule().

◆ 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, (GPUBatchFlag)0)

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

Definition at line 161 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 58 of file GPU_batch.hh.

◆ GPU_batch_texture_bind

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

Definition at line 284 of file GPU_batch.hh.

Referenced by blender::blf_batch_draw().

◆ GPU_batch_uniform_1b

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

Definition at line 266 of file GPU_batch.hh.

◆ GPU_batch_uniform_1f

◆ GPU_batch_uniform_1i

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

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

Definition at line 265 of file GPU_batch.hh.

Referenced by blender::blf_batch_draw(), blender::ED_screen_draw_edges(), blender::gpu_viewport_draw_colormanaged(), and blender::ed::vse::sequencer_draw_scopes().

◆ GPU_batch_uniform_2f

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

Definition at line 268 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);

Definition at line 273 of file GPU_batch.hh.

Referenced by blender::button2d_draw_intern(), blender::draw_line_bounds(), blender::draw_line_loop(), and blender::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);
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263

Definition at line 276 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);
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117

Definition at line 269 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);

Definition at line 274 of file GPU_batch.hh.

Referenced by blender::curve_draw_stroke_3d(), blender::ed::curves::curve_draw_stroke_3d(), blender::ui::draw_widgetbase_batch(), and blender::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);
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119

Definition at line 271 of file GPU_batch.hh.

Referenced by blender::ui::waveform_draw_one().

◆ GPU_batch_uniform_4fv

◆ GPU_batch_uniform_4fv_array

#define GPU_batch_uniform_4fv_array ( batch,
name,
len,
val )

◆ GPU_batch_uniform_mat4

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

Definition at line 280 of file GPU_batch.hh.

◆ GPU_batch_uniformbuf_bind

#define GPU_batch_uniformbuf_bind ( batch,
name,
ubo )
Value:
GPU_uniformbuf_bind(ubo, GPU_shader_get_ubo_binding((batch)->shader, name));

Definition at line 282 of file GPU_batch.hh.

Referenced by blender::ui::draw_but_UNITVEC(), and blender::ed::space_node::nodelink_batch_draw().