37 batch->elem =
nullptr;
38 batch->resource_id_buf =
nullptr;
41 batch->shader =
nullptr;
72 batch->verts[0] = vertex_buf;
76 for (
auto &
v :
batch->inst) {
79 batch->elem = index_buf;
80 batch->prim_type = primitive_type;
82 batch->shader =
nullptr;
91 batch_dst->prim_type = batch_src->prim_type;
93 batch_dst->verts[
v] = batch_src->verts[
v];
139 batch->inst[0] = vertex_buf;
152 batch->elem = index_buf;
163 if (
batch->inst[
v] ==
nullptr) {
165 if (
batch->inst[0]) {
170 batch->inst[
v] = vertex_buf;
186 if (
batch->verts[
v] ==
nullptr) {
188 if (
batch->verts[0] !=
nullptr) {
192 batch->verts[
v] = vertex_buf;
205 if (
batch->verts[
v] == vertex_buf) {
216 batch->resource_id_buf = resource_id_buf;
244 char uniform_name[] =
"gpu_attr_0";
247 uint16_t bound_attr = 0u;
248 for (
uint a_idx = 0; a_idx <
format->attr_len; a_idx++) {
251 if (
format->deinterleaved) {
252 offset += ((a_idx == 0) ? 0 :
format->attrs[a_idx - 1].size) * vbo->
vertex_len;
262 if (
input ==
nullptr ||
input->location == -1) {
266 bound_attr |= (1 <<
input->location);
270 uniform_name[9] =
'0' +
input->location;
275 int descriptor[2] = {int(stride) / 4, int(offset) / 4};
279 char uniform_name_len[] =
"gpu_attr_0_len";
280 uniform_name_len[9] =
'0' +
input->location;
296 uint16_t ssbo_attributes =
interface->ssbo_attr_mask_;
323 BLI_assert_msg(ssbo_attributes == 0,
"Not all attribute storage buffer fulfilled");
337 int *r_instance_count)
340 *r_vertex_count =
batch->elem_()->index_len_get();
341 *r_vertex_first =
batch->elem_()->index_start_get();
342 *r_base_index =
batch->elem_()->index_base_get();
345 *r_vertex_count =
batch->verts_(0)->vertex_len;
350 int i_count = (
batch->inst[0]) ?
batch->inst_(0)->vertex_len : 1;
352 if (
batch->inst[1] !=
nullptr) {
353 i_count =
min_ii(i_count,
batch->inst_(1)->vertex_len);
355 *r_instance_count = i_count;
362 int output_primitive_cout)
367 int prim_first = vertex_first / vert_per_original_primitive;
368 int prim_len = vertex_count / vert_per_original_primitive;
371 "Primitive expansion only works for primitives with known amount of vertices");
375 prim_len = vertex_count - 1;
378 int out_vertex_first = prim_first * vert_per_expanded_primitive * output_primitive_cout;
379 int out_vertex_count = prim_len * vert_per_expanded_primitive * output_primitive_cout;
385 Batch *
batch,
int vertex_first,
int vertex_count,
int instance_first,
int instance_count)
388 if (vertex_count == 0) {
400 int vert_stride_count[3] = {(
batch->prim_type ==
GPU_PRIM_LINES) ? 2 : 1, vertex_count, 0};
412 "color attribute for polylines can only use GPU_FETCH_INT_TO_FLOAT_UNIT or "
415 "gpu_attr_1_fetch_unorm8",
458 Batch *
batch,
int vertex_first,
int vertex_count,
int instance_first,
int instance_count)
464 if (vertex_count == 0) {
466 vertex_count =
batch->elem_()->index_len_get();
469 vertex_count =
batch->verts_(0)->vertex_len;
472 if (instance_count == 0) {
473 instance_count = (
batch->inst[0]) ?
batch->inst_(0)->vertex_len : 1;
475 if (
batch->inst[1] !=
nullptr) {
476 instance_count =
min_ii(instance_count,
batch->inst_(1)->vertex_len);
480 if (vertex_count == 0 || instance_count == 0) {
485 batch->draw(vertex_first, vertex_count, instance_first, instance_count);
495 batch->draw_indirect(indirect_buf, offset);
499 Batch *
batch, GPUStorageBuf *indirect_buf,
int count, intptr_t offset, intptr_t stride)
506 batch->multi_draw_indirect(indirect_buf,
count, offset, stride);
#define BLI_assert_msg(a, msg)
MINLINE int min_ii(int a, int b)
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
static constexpr int GPU_BATCH_VBO_MAX_LEN
static constexpr int GPU_BATCH_INST_VBO_MAX_LEN
@ GPU_BATCH_OWNS_INST_VBO
@ GPU_BATCH_OWNS_INST_VBO_ANY
void gpu_batch_presets_init()
void gpu_batch_presets_exit()
void GPU_indexbuf_discard(blender::gpu::IndexBuf *elem)
void GPU_indexbuf_bind_as_ssbo(blender::gpu::IndexBuf *elem, int binding)
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
void GPU_shader_uniform_3iv(GPUShader *sh, const char *name, const int data[3])
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_2iv(GPUShader *sh, const char *name, const int data[2])
void GPU_shader_uniform_1b(GPUShader *sh, const char *name, bool value)
GPUShader * GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader, eGPUShaderConfig sh_cfg)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
const GPUVertFormat * GPU_vertbuf_get_format(const blender::gpu::VertBuf *verts)
void GPU_vertbuf_bind_as_ssbo(blender::gpu::VertBuf *verts, int binding)
void GPU_vertbuf_discard(blender::gpu::VertBuf *)
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr int64_t size() const
constexpr int64_t start() const
Batch * procedural_triangles_batch_get()
void assert_framebuffer_shader_compatibility(Shader *sh)
Batch * procedural_triangle_strips_batch_get()
Batch * procedural_lines_batch_get()
Batch * procedural_points_batch_get()
static GPUBackend * get()
virtual Batch * batch_alloc()=0
void GPU_batch_resource_id_buf_set(Batch *batch, GPUStorageBuf *resource_id_buf)
blender::gpu::Batch * GPU_batch_procedural_triangle_strips_get()
void GPU_batch_multi_draw_indirect(Batch *batch, GPUStorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride)
void GPU_batch_draw_parameter_get(Batch *batch, int *r_vertex_count, int *r_vertex_first, int *r_base_index, int *r_instance_count)
void GPU_batch_discard(Batch *batch)
int GPU_batch_instbuf_add(Batch *batch, VertBuf *vertex_buf, bool own_vbo)
Batch * GPU_batch_create_ex(GPUPrimType primitive_type, VertBuf *vertex_buf, IndexBuf *index_buf, eGPUBatchFlag owns_flag)
bool GPU_batch_vertbuf_has(const Batch *batch, const VertBuf *vertex_buf)
static void polyline_draw_workaround(Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
blender::gpu::Batch * GPU_batch_procedural_lines_get()
void GPU_batch_program_set_imm_shader(Batch *batch)
void GPU_batch_draw(Batch *batch)
void GPU_batch_draw_instance_range(Batch *batch, int instance_first, int instance_count)
static uint16_t bind_attribute_as_ssbo(const ShaderInterface *interface, GPUShader *shader, VertBuf *vbo)
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)
Batch * GPU_batch_calloc()
void GPU_batch_draw_range(Batch *batch, int vertex_first, int vertex_count)
void GPU_batch_draw_indirect(Batch *batch, GPUStorageBuf *indirect_buf, intptr_t offset)
int GPU_batch_vertbuf_add(Batch *batch, VertBuf *vertex_buf, bool own_vbo)
void GPU_batch_set_shader(Batch *batch, GPUShader *shader, const shader::SpecializationConstants *constants_state)
blender::gpu::Batch * GPU_batch_procedural_points_get()
void GPU_batch_program_set_builtin(Batch *batch, eGPUBuiltinShader shader_id)
void GPU_batch_init_ex(Batch *batch, GPUPrimType primitive_type, VertBuf *vertex_buf, IndexBuf *index_buf, eGPUBatchFlag owns_flag)
void GPU_batch_instbuf_set(Batch *batch, VertBuf *vertex_buf, bool own_vbo)
blender::gpu::Batch * GPU_batch_procedural_triangles_get()
void GPU_batch_zero(Batch *batch)
void GPU_batch_bind_as_resources(Batch *batch, GPUShader *shader, const shader::SpecializationConstants *constants)
void GPU_batch_copy(Batch *batch_dst, Batch *batch_src)
void GPU_batch_program_set_builtin_with_config(Batch *batch, eGPUBuiltinShader shader_id, eGPUShaderConfig sh_cfg)
void GPU_batch_clear(Batch *batch)
void GPU_batch_elembuf_set(Batch *batch, blender::gpu::IndexBuf *index_buf, bool own_ibo)
void GPU_batch_draw_advanced(Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
struct @242053044010324116347033273112253060004051364061::@051143074301336237271216303350234260141112266062 batch
#define GPU_SSBO_INDEX_BUF_SLOT
static Context * unwrap(GPUContext *ctx)
int indices_per_primitive(GPUPrimType prim_type)