37 batch->elem =
nullptr;
40 batch->shader =
nullptr;
41 batch->procedural_vertices = -1;
72 batch->verts[0] = vertex_buf;
76 batch->elem = index_buf;
77 batch->prim_type = primitive_type;
79 batch->shader =
nullptr;
80 batch->procedural_vertices = -1;
87 for (
auto &
v :
batch->verts) {
90 batch->elem =
nullptr;
91 batch->prim_type = primitive_type;
93 batch->shader =
nullptr;
94 batch->procedural_vertices = vertex_count;
104 batch_dst->prim_type = batch_src->prim_type;
106 batch_dst->verts[
v] = batch_src->verts[
v];
108 batch_dst->procedural_vertices = batch_src->procedural_vertices;
124 batch->procedural_vertices = -1;
147 batch->elem = index_buf;
158 if (
batch->verts[
v] ==
nullptr) {
160 if (
batch->verts[0] !=
nullptr) {
164 batch->verts[
v] = vertex_buf;
177 if (
batch->verts[
v] == vertex_buf) {
209 char uniform_name[] =
"gpu_attr_0";
212 uint16_t bound_attr = 0u;
213 for (
uint a_idx = 0; a_idx <
format->attr_len; a_idx++) {
216 if (
format->deinterleaved) {
217 offset += ((a_idx == 0) ? 0 :
format->attrs[a_idx - 1].type.size()) * vbo->
vertex_len;
227 if (
input ==
nullptr ||
input->location == -1) {
231 bound_attr |= (1 <<
input->location);
235 uniform_name[9] =
'0' +
input->location;
240 int descriptor[2] = {int(stride) / 4, int(offset) / 4};
244 char uniform_name_len[] =
"gpu_attr_0_len";
245 uniform_name_len[9] =
'0' +
input->location;
261 uint16_t ssbo_attributes =
interface->ssbo_attr_mask_;
288 BLI_assert_msg(ssbo_attributes == 0,
"Not all attribute storage buffer fulfilled");
302 int *r_instance_count)
304 if (
batch->procedural_vertices >= 0) {
305 *r_vertex_count =
batch->procedural_vertices;
309 else if (
batch->elem) {
310 *r_vertex_count =
batch->elem_()->index_len_get();
311 *r_vertex_first =
batch->elem_()->index_start_get();
312 *r_base_index =
batch->elem_()->index_base_get();
315 *r_vertex_count =
batch->verts_(0)->vertex_len;
320 *r_instance_count = 1;
327 int output_primitive_cout)
332 int prim_first = vertex_first / vert_per_original_primitive;
333 int prim_len = vertex_count / vert_per_original_primitive;
336 "Primitive expansion only works for primitives with known amount of vertices");
340 prim_len = vertex_count - 1;
343 int out_vertex_first = prim_first * vert_per_expanded_primitive * output_primitive_cout;
344 int out_vertex_count = prim_len * vert_per_expanded_primitive * output_primitive_cout;
350 Batch *
batch,
int vertex_first,
int vertex_count,
int instance_first,
int instance_count)
353 if (vertex_count == 0) {
365 int vert_stride_count[3] = {(
batch->prim_type ==
GPU_PRIM_LINES) ? 2 : 1, vertex_count, 0};
376 const bool is_unorm8 = attr.
type.
format == blender::gpu::VertAttrType::UNORM_8_8_8_8;
378 "color attribute for polylines can only use GPU_FETCH_INT_TO_FLOAT_UNIT or "
390 if (
batch->shader->is_polyline) {
402 if (
batch->shader->is_polyline) {
421 Batch *
batch,
int vertex_first,
int vertex_count,
int instance_first,
int instance_count)
427 if (vertex_count == 0) {
428 if (
batch->procedural_vertices > 0) {
429 vertex_count =
batch->procedural_vertices;
431 else if (
batch->elem) {
432 vertex_count =
batch->elem_()->index_len_get();
435 vertex_count =
batch->verts_(0)->vertex_len;
438 if (instance_count == 0) {
442 if (vertex_count == 0 || instance_count == 0) {
451 batch->draw(vertex_first, vertex_count, instance_first, instance_count);
465 batch->draw_indirect(indirect_buf, offset);
483 batch->multi_draw_indirect(indirect_buf,
count, offset, stride);
#define BLI_assert_msg(a, msg)
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
static constexpr int GPU_BATCH_VBO_MAX_LEN
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_1b(blender::gpu::Shader *sh, const char *name, bool value)
void GPU_shader_bind(blender::gpu::Shader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_1i(blender::gpu::Shader *sh, const char *name, int value)
void GPU_shader_uniform_2iv(blender::gpu::Shader *sh, const char *name, const int data[2])
void GPU_shader_uniform_3iv(blender::gpu::Shader *sh, const char *name, const int data[3])
blender::gpu::Shader * GPU_shader_get_builtin_shader_with_config(GPUBuiltinShader shader, GPUShaderConfig 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)
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
static uint16_t bind_attribute_as_ssbo(const ShaderInterface *interface, blender::gpu::Shader *shader, VertBuf *vbo)
blender::gpu::Batch * GPU_batch_procedural_triangle_strips_get()
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)
void GPU_batch_program_set_builtin_with_config(Batch *batch, GPUBuiltinShader shader_id, GPUShaderConfig sh_cfg)
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_set_shader(Batch *batch, blender::gpu::Shader *shader, const shader::SpecializationConstants *constants_state)
void GPU_batch_program_set_imm_shader(Batch *batch)
Batch * GPU_batch_create_procedural(GPUPrimType primitive_type, int32_t vertex_count)
void GPU_batch_draw(Batch *batch)
void GPU_batch_draw_instance_range(Batch *batch, int instance_first, int instance_count)
void GPU_batch_draw_indirect(Batch *batch, blender::gpu::StorageBuf *indirect_buf, intptr_t offset)
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)
Batch * GPU_batch_create_ex(GPUPrimType primitive_type, VertBuf *vertex_buf, IndexBuf *index_buf, GPUBatchFlag owns_flag)
int GPU_batch_vertbuf_add(Batch *batch, VertBuf *vertex_buf, bool own_vbo)
blender::gpu::Batch * GPU_batch_procedural_points_get()
void GPU_batch_init_ex(Batch *batch, GPUPrimType primitive_type, VertBuf *vertex_buf, IndexBuf *index_buf, GPUBatchFlag owns_flag)
void GPU_batch_multi_draw_indirect(Batch *batch, blender::gpu::StorageBuf *indirect_buf, int count, intptr_t offset, intptr_t stride)
void GPU_batch_program_set_builtin(Batch *batch, GPUBuiltinShader shader_id)
blender::gpu::Batch * GPU_batch_procedural_triangles_get()
void GPU_batch_zero(Batch *batch)
void GPU_batch_copy(Batch *batch_dst, Batch *batch_src)
void GPU_batch_clear(Batch *batch)
void GPU_batch_elembuf_set(Batch *batch, blender::gpu::IndexBuf *index_buf, bool own_ibo)
void GPU_batch_bind_as_resources(Batch *batch, blender::gpu::Shader *shader, const shader::SpecializationConstants *constants)
void GPU_batch_draw_advanced(Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
#define GPU_SSBO_INDEX_BUF_SLOT
int indices_per_primitive(GPUPrimType prim_type)
void debug_validate_binding_image_format()
blender::gpu::VertAttrType format
GPUVertFetchMode fetch_mode() const
struct GPUVertAttr::Type type