20 #define GPU_BATCH_VBO_MAX_LEN 16
21 #define GPU_BATCH_INST_VBO_MAX_LEN 2
22 #define GPU_BATCH_VAO_STATIC_LEN 3
23 #define GPU_BATCH_VAO_DYN_ALLOC_COUNT 16
49 #define GPU_BATCH_OWNS_NONE GPU_BATCH_INVALID
52 "eGPUBatchFlag: Error: status flags are shadowed by the ownership bits!")
95 #define GPU_batch_create(prim, verts, elem) GPU_batch_create_ex(prim, verts, elem, 0)
96 #define GPU_batch_init(batch, prim, verts, elem) GPU_batch_init_ex(batch, prim, verts, elem, 0)
124 #define GPU_batch_vertbuf_add(batch, verts) GPU_batch_vertbuf_add_ex(batch, verts, false)
142 #define GPU_batch_uniform_1i(batch, name, x) GPU_shader_uniform_1i((batch)->shader, name, x);
143 #define GPU_batch_uniform_1b(batch, name, x) GPU_shader_uniform_1b((batch)->shader, name, x);
144 #define GPU_batch_uniform_1f(batch, name, x) GPU_shader_uniform_1f((batch)->shader, name, x);
145 #define GPU_batch_uniform_2f(batch, name, x, y) GPU_shader_uniform_2f((batch)->shader, name, x, y);
146 #define GPU_batch_uniform_3f(batch, name, x, y, z) \
147 GPU_shader_uniform_3f((batch)->shader, name, x, y, z);
148 #define GPU_batch_uniform_4f(batch, name, x, y, z, w) \
149 GPU_shader_uniform_4f((batch)->shader, name, x, y, z, w);
150 #define GPU_batch_uniform_2fv(batch, name, val) GPU_shader_uniform_2fv((batch)->shader, name, val);
151 #define GPU_batch_uniform_3fv(batch, name, val) GPU_shader_uniform_3fv((batch)->shader, name, val);
152 #define GPU_batch_uniform_4fv(batch, name, val) GPU_shader_uniform_4fv((batch)->shader, name, val);
153 #define GPU_batch_uniform_2fv_array(batch, name, len, val) \
154 GPU_shader_uniform_2fv_array((batch)->shader, name, len, val);
155 #define GPU_batch_uniform_4fv_array(batch, name, len, val) \
156 GPU_shader_uniform_4fv_array((batch)->shader, name, len, val);
157 #define GPU_batch_uniform_mat4(batch, name, val) \
158 GPU_shader_uniform_mat4((batch)->shader, name, val);
159 #define GPU_batch_uniformbuf_bind(batch, name, ubo) \
160 GPU_uniformbuf_bind(ubo, GPU_shader_get_uniform_block_binding((batch)->shader, name));
161 #define GPU_batch_texture_bind(batch, name, tex) \
162 GPU_texture_bind(tex, GPU_shader_get_texture_binding((batch)->shader, name));
183 typedef struct BatchWithOwnVertexBuffer {
186 } BatchWithOwnVertexBuffer;
188 typedef struct BatchWithOwnElementList {
191 } BatchWithOwnElementList;
193 typedef struct BatchWithOwnVertexBufferAndElementList {
197 } BatchWithOwnVertexBufferAndElementList;
216 #define GPU_BATCH_DISCARD_SAFE(batch) \
218 if (batch != NULL) { \
219 GPU_batch_discard(batch); \
224 #define GPU_BATCH_CLEAR_SAFE(batch) \
226 if (batch != NULL) { \
227 GPU_batch_clear(batch); \
228 memset(batch, 0, sizeof(*(batch))); \
232 #define GPU_BATCH_DISCARD_ARRAY_SAFE(_batch_array, _len) \
234 if (_batch_array != NULL) { \
235 BLI_assert(_len > 0); \
236 for (int _i = 0; _i < _len; _i++) { \
237 GPU_BATCH_DISCARD_SAFE(_batch_array[_i]); \
239 MEM_freeN(_batch_array); \
#define ENUM_OPERATORS(_type, _max)
GPUBatch * GPU_batch_calloc(void)
void GPU_batch_draw_instanced(GPUBatch *batch, int i_count)
void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch *batch_src)
BLI_STATIC_ASSERT(GPU_BATCH_OWNS_INDEX< GPU_BATCH_INIT, "eGPUBatchFlag: Error: status flags are shadowed by the ownership bits!") typedef struct GPUBatch
void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader)
void GPU_batch_init_ex(GPUBatch *batch, GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
void GPU_batch_draw_range(GPUBatch *batch, int v_first, int v_count)
void gpu_batch_init(void)
void GPU_batch_elembuf_set(GPUBatch *batch, GPUIndexBuf *elem, bool own_ibo)
void GPU_batch_discard(GPUBatch *)
void GPU_batch_program_set_builtin_with_config(GPUBatch *batch, eGPUBuiltinShader shader_id, eGPUShaderConfig sh_cfg)
void GPU_batch_draw_advanced(GPUBatch *, int v_first, int v_count, int i_first, int i_count)
int GPU_batch_vertbuf_add_ex(GPUBatch *, GPUVertBuf *, bool own_vbo)
#define GPU_BATCH_INST_VBO_MAX_LEN
void GPU_batch_program_set_imm_shader(GPUBatch *batch)
#define GPU_BATCH_VBO_MAX_LEN
void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
void GPU_batch_clear(GPUBatch *)
int GPU_batch_instbuf_add_ex(GPUBatch *, GPUVertBuf *, bool own_vbo)
bool GPU_batch_vertbuf_has(GPUBatch *, GPUVertBuf *)
void gpu_batch_exit(void)
void GPU_batch_instbuf_set(GPUBatch *, GPUVertBuf *, bool own_vbo)
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
void GPU_batch_draw(GPUBatch *batch)
@ GPU_BATCH_OWNS_INST_VBO
@ GPU_BATCH_OWNS_INST_VBO_MAX
@ GPU_BATCH_OWNS_INST_VBO_ANY
struct GPUIndexBuf GPUIndexBuf
struct GPUShader GPUShader
struct GPUVertBuf GPUVertBuf