Blender V5.3
gpu_immediate.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2016 by Mike Erwin. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#ifndef GPU_STANDALONE
12# include "UI_resources.hh"
13#endif
14
15#include "GPU_immediate.hh"
16#include "GPU_matrix.hh"
17#include "GPU_texture.hh"
18#include "GPU_uniform_buffer.hh"
19
22#include "gpu_shader_private.hh"
24
25namespace blender {
26
27using namespace blender::gpu;
28
29static thread_local Immediate *imm = nullptr;
30
32{
33 imm = Context::get()->imm;
34}
35
37{
38 imm = nullptr;
39}
40
46
48{
49 BLI_assert(imm->shader == nullptr);
50
51 imm->shader = shader;
52 imm->builtin_shader_bound = std::nullopt;
53
54 if (!imm->vertex_format.packed) {
56 imm->enabled_attr_bits = 0xFFFFu & ~(0xFFFFu << imm->vertex_format.attr_len);
57 }
58
61}
62
69
71{
72 BLI_assert(imm->shader != nullptr);
73
75 imm->shader = nullptr;
76}
77
79{
80 return imm->shader != nullptr;
81}
82
84{
85 return imm->shader;
86}
87
88#ifndef NDEBUG
90{
91 /* does vertex_len make sense for this primitive type? */
92 if (vertex_len == 0) {
93 return false;
94 }
95
96 switch (prim_type) {
97 case GPU_PRIM_POINTS:
98 return true;
99 case GPU_PRIM_LINES:
100 return vertex_len % 2 == 0;
103 return vertex_len >= 2;
105 return vertex_len >= 4;
106 case GPU_PRIM_TRIS:
107 return vertex_len % 3 == 0;
109 case GPU_PRIM_TRI_FAN:
110 return vertex_len >= 3;
111 default:
112 return false;
113 }
114}
115#endif
116
117/* -------------------------------------------------------------------- */
123
125{
127 return;
128 }
129
130 float line_width = GPU_line_width_get();
131
132 if (line_width == 1.0f && !GPU_line_smooth_get()) {
133 /* No need to change the shader. */
134 return;
135 }
137 return;
138 }
139
140 GPUBuiltinShader polyline_sh;
141 switch (*imm->builtin_shader_bound) {
144 break;
147 break;
150 break;
153 break;
154 default:
155 /* Cannot replace the current shader with a polyline shader. */
156 return;
157 }
158
160
162
163 /* TODO(fclem): Don't use geometry shader and use quad instancing with double load. */
164 // GPU_vertformat_multiload_enable(imm->vertex_format, 2);
165
166 immBindBuiltinProgram(polyline_sh);
167
168 float viewport[4];
169 GPU_viewport_size_get_f(viewport);
170 immUniform2fv("viewportSize", &viewport[2]);
171 immUniform1f("lineWidth", line_width);
172
173 if (GPU_blend_get() == GPU_BLEND_NONE) {
174 /* Disable line smoothing when blending is disabled (see #81827). */
175 immUniform1i("lineSmooth", 0);
176 }
177
178 if (ELEM(polyline_sh,
181 {
183 }
184}
185
187{
189 if (GPU_blend_get() == GPU_BLEND_NONE) {
190 /* Restore default. */
191 immUniform1i("lineSmooth", 1);
192 }
194
196 imm->prev_builtin_shader = std::nullopt;
197 }
198}
199
201
202void immBegin(GPUPrimType prim_type, uint vertex_len)
203{
204 BLI_assert(imm->prim_type == GPU_PRIM_NONE); /* Make sure we haven't already begun. */
206
208
209 imm->prim_type = prim_type;
210 imm->vertex_len = vertex_len;
211 imm->vertex_idx = 0;
213
214 imm->vertex_data = imm->begin();
215}
216
217void immBeginAtMost(GPUPrimType prim_type, uint vertex_len)
218{
219 BLI_assert(vertex_len > 0);
220 imm->strict_vertex_len = false;
221 immBegin(prim_type, vertex_len);
222}
223
224gpu::Batch *immBeginBatch(GPUPrimType prim_type, uint vertex_len)
225{
226 BLI_assert(imm->prim_type == GPU_PRIM_NONE); /* Make sure we haven't already begun. */
228
229 imm->prim_type = prim_type;
230 imm->vertex_len = vertex_len;
231 imm->vertex_idx = 0;
233
234 VertBuf *verts = GPU_vertbuf_create_with_format(imm->vertex_format);
235 GPU_vertbuf_data_alloc(*verts, vertex_len);
236
237 imm->vertex_data = verts->data<uchar>().data();
238
239 imm->batch = GPU_batch_create_ex(prim_type, verts, nullptr, GPU_BATCH_OWNS_VBO);
240 imm->batch->flag |= GPU_BATCH_BUILDING;
241
242 return imm->batch;
243}
244
245gpu::Batch *immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len)
246{
247 BLI_assert(vertex_len > 0);
248 imm->strict_vertex_len = false;
249 return immBeginBatch(prim_type, vertex_len);
250}
251
252void immEnd()
253{
254 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* Make sure we're between a Begin/End pair. */
256
257 if (imm->strict_vertex_len) {
258 BLI_assert(imm->vertex_idx == imm->vertex_len); /* With all vertices defined. */
259 }
260 else {
262 BLI_assert(imm->vertex_idx == 0 ||
264 }
265
266 if (imm->batch) {
267 if (imm->vertex_idx < imm->vertex_len) {
269 /* TODO: resize only if vertex count is much smaller */
270 }
272 imm->batch->flag &= ~GPU_BATCH_BUILDING;
273 imm->batch = nullptr; /* don't free, batch belongs to caller */
274 }
275 else {
277 imm->end();
278 }
279
280 /* Prepare for next immBegin. */
282 imm->strict_vertex_len = true;
283 imm->vertex_data = nullptr;
284
286}
287
289{
290 /* Check compatible input primitive. */
292
293 Batch *tri_batch = Context::get()->procedural_triangles_batch_get();
294 GPU_batch_set_shader(tri_batch, imm->shader);
295
296 BLI_assert(offset % 4 == 0);
297
298 /* Setup primitive and index buffer. */
299 int stride = (imm->prim_type == GPU_PRIM_LINES) ? 2 : 1;
300 int data[3] = {stride, int(imm->vertex_idx), int(offset / 4)};
301 GPU_shader_uniform_3iv(imm->shader, "gpu_vert_stride_count_offset", data);
302 GPU_shader_uniform_1b(imm->shader, "gpu_index_no_buffer", true);
303
304 {
305 /* Setup attributes metadata uniforms. */
306 const GPUVertFormat &format = imm->vertex_format;
307 /* Only support 4byte aligned formats. */
308 BLI_assert((format.stride % 4) == 0);
309 BLI_assert(format.attr_len > 0);
310
311 int pos_attr_id = -1;
312 int col_attr_id = -1;
313
314 for (uint a_idx = 0; a_idx < format.attr_len; a_idx++) {
315 const GPUVertAttr *a = &format.attrs[a_idx];
316 const char *name = GPU_vertformat_attr_name_get(&format, a, 0);
317 if (pos_attr_id == -1 && StringRefNull(name) == "pos") {
318 int descriptor[2] = {int(format.stride) / 4, int(a->offset) / 4};
319 const bool fetch_int = false;
320 BLI_assert(is_fetch_float(a->type.format) || fetch_int);
321 BLI_assert_msg((a->offset % 4) == 0, "Only support 4byte aligned attributes");
323 GPU_shader_uniform_1i(imm->shader, "gpu_attr_0_len", a->type.comp_len());
324 GPU_shader_uniform_1b(imm->shader, "gpu_attr_0_fetch_int", fetch_int);
325 pos_attr_id = a_idx;
326 }
327 else if (col_attr_id == -1 && StringRefNull(name) == "color") {
328 int descriptor[2] = {int(format.stride) / 4, int(a->offset) / 4};
329 /* Maybe we can relax this if needed. */
331 VertAttrType::SFLOAT_32,
332 VertAttrType::SFLOAT_32_32,
333 VertAttrType::SFLOAT_32_32_32,
334 VertAttrType::SFLOAT_32_32_32_32,
335 VertAttrType::UNORM_8_8_8_8),
336 "Only support float attributes or uchar4");
337 const bool fetch_unorm8 = a->type.format == VertAttrType::UNORM_8_8_8_8;
338 BLI_assert_msg((a->offset % 4) == 0, "Only support 4byte aligned attributes");
340 GPU_shader_uniform_1i(imm->shader, "gpu_attr_1_len", a->type.comp_len());
341 GPU_shader_uniform_1i(imm->shader, "gpu_attr_1_fetch_unorm8", fetch_unorm8);
342 col_attr_id = a_idx;
343 }
344 if (pos_attr_id != -1 && col_attr_id != -1) {
345 break;
346 }
347 }
348
349 BLI_assert(pos_attr_id != -1);
350 /* Could check for color attribute but we need to know which variant of the polyline shader is
351 * the one we are rendering with. */
352 // BLI_assert(pos_attr_id != -1);
353 }
354
357 GPU_batch_draw_advanced(tri_batch, range.start(), range.size(), 0, 0);
358}
359
360static void setAttrValueBit(uint attr_id)
361{
362 uint16_t mask = 1 << attr_id;
363 BLI_assert(imm->unassigned_attr_bits & mask); /* not already set */
365}
366
367/* --- generic attribute functions --- */
368
369void immAttr1f(uint attr_id, float x)
370{
371 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
372 BLI_assert(attr_id < imm->vertex_format.attr_len);
373 BLI_assert(ELEM(attr->type.format, VertAttrType::SFLOAT_32));
375 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
376 setAttrValueBit(attr_id);
377
378 float *data = reinterpret_cast<float *>(imm->vertex_data + attr->offset);
379 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
380
381 data[0] = x;
382}
383
384void immAttr2f(uint attr_id, float x, float y)
385{
386 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
387 BLI_assert(attr_id < imm->vertex_format.attr_len);
388 BLI_assert(ELEM(attr->type.format, VertAttrType::SFLOAT_32_32));
390 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
391 setAttrValueBit(attr_id);
392
393 float *data = reinterpret_cast<float *>(imm->vertex_data + attr->offset);
394 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
395
396 data[0] = x;
397 data[1] = y;
398}
399
400void immAttr3f(uint attr_id, float x, float y, float z)
401{
402 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
403 BLI_assert(attr_id < imm->vertex_format.attr_len);
404 BLI_assert(ELEM(attr->type.format, VertAttrType::SFLOAT_32_32_32));
406 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
407 setAttrValueBit(attr_id);
408
409 float *data = reinterpret_cast<float *>(imm->vertex_data + attr->offset);
410 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
411
412 data[0] = x;
413 data[1] = y;
414 data[2] = z;
415}
416
417void immAttr4f(uint attr_id, float x, float y, float z, float w)
418{
419 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
420 BLI_assert(attr_id < imm->vertex_format.attr_len);
421 BLI_assert(ELEM(attr->type.format, VertAttrType::SFLOAT_32_32_32_32));
423 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
424 setAttrValueBit(attr_id);
425
426 float *data = reinterpret_cast<float *>(imm->vertex_data + attr->offset);
427 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
428
429 data[0] = x;
430 data[1] = y;
431 data[2] = z;
432 data[3] = w;
433}
434
435void immAttr1u(uint attr_id, uint x)
436{
437 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
438 BLI_assert(attr_id < imm->vertex_format.attr_len);
439 BLI_assert(ELEM(attr->type.format, VertAttrType::UINT_32));
441 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
442 setAttrValueBit(attr_id);
443
444 uint *data = reinterpret_cast<uint *>(imm->vertex_data + attr->offset);
445
446 data[0] = x;
447}
448
449void immAttr2i(uint attr_id, int x, int y)
450{
451 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
452 BLI_assert(attr_id < imm->vertex_format.attr_len);
453 BLI_assert(ELEM(attr->type.format, VertAttrType::SINT_32_32));
455 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
456 setAttrValueBit(attr_id);
457
458 int *data = reinterpret_cast<int *>(imm->vertex_data + attr->offset);
459
460 data[0] = x;
461 data[1] = y;
462}
463
464void immAttr2fv(uint attr_id, const float data[2])
465{
466 immAttr2f(attr_id, data[0], data[1]);
467}
468
469void immAttr3fv(uint attr_id, const float data[3])
470{
471 immAttr3f(attr_id, data[0], data[1], data[2]);
472}
473
474void immAttr4fv(uint attr_id, const float data[4])
475{
476 immAttr4f(attr_id, data[0], data[1], data[2], data[3]);
477}
478
479void immAttr4ub(uint attr_id, uchar r, uchar g, uchar b, uchar a)
480{
481 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
482 BLI_assert(attr_id < imm->vertex_format.attr_len);
483 BLI_assert(ELEM(attr->type.format, VertAttrType::UINT_8_8_8_8, VertAttrType::UNORM_8_8_8_8));
485 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
486 setAttrValueBit(attr_id);
487
488 uchar *data = imm->vertex_data + attr->offset;
489 // printf("%s %td %p\n", __FUNCTION__, data - imm->buffer_data, data);
490
491 data[0] = r;
492 data[1] = g;
493 data[2] = b;
494 data[3] = a;
495}
496
497void immAttr4ubv(uint attr_id, const uchar data[4])
498{
499 immAttr4ub(attr_id, data[0], data[1], data[2], data[3]);
500}
501
502void immAttrSkip(uint attr_id)
503{
504 BLI_assert(attr_id < imm->vertex_format.attr_len);
506 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
507 setAttrValueBit(attr_id);
508}
509
510static void immEndVertex() /* and move on to the next vertex */
511{
512 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
514
515 /* Have all attributes been assigned values?
516 * If not, copy value from previous vertex. */
518 BLI_assert(imm->vertex_idx > 0); /* first vertex must have all attributes specified */
519 for (uint a_idx = 0; a_idx < imm->vertex_format.attr_len; a_idx++) {
520 if ((imm->unassigned_attr_bits >> a_idx) & 1) {
521 const GPUVertAttr *a = &imm->vertex_format.attrs[a_idx];
522
523#if 0
524 printf("copying %s from vertex %u to %u\n", a->name, imm->vertex_idx - 1, imm->vertex_idx);
525#endif
526
528 memcpy(data, data - imm->vertex_format.stride, a->type.size());
529 /* TODO: consolidate copy of adjacent attributes */
530 }
531 }
532 }
533
534 imm->vertex_idx++;
537}
538
539void immVertex2f(uint attr_id, float x, float y)
540{
541 immAttr2f(attr_id, x, y);
542 immEndVertex();
543}
544
545void immVertex3f(uint attr_id, float x, float y, float z)
546{
547 immAttr3f(attr_id, x, y, z);
548 immEndVertex();
549}
550
551void immVertex4f(uint attr_id, float x, float y, float z, float w)
552{
553 immAttr4f(attr_id, x, y, z, w);
554 immEndVertex();
555}
556
557void immVertex2i(uint attr_id, int x, int y)
558{
559 immAttr2i(attr_id, x, y);
560 immEndVertex();
561}
562
563void immVertex2fv(uint attr_id, const float data[2])
564{
565 immAttr2f(attr_id, data[0], data[1]);
566 immEndVertex();
567}
568
569void immVertex3fv(uint attr_id, const float data[3])
570{
571 immAttr3f(attr_id, data[0], data[1], data[2]);
572 immEndVertex();
573}
574
575void immVertex2iv(uint attr_id, const int data[2])
576{
577 immAttr2i(attr_id, data[0], data[1]);
578 immEndVertex();
579}
580
581/* --- generic uniform functions --- */
582
583void immUniform1f(const char *name, float x)
584{
586}
587
588void immUniform2f(const char *name, float x, float y)
589{
591}
592
593void immUniform2fv(const char *name, const float data[2])
594{
596}
597
598void immUniform3f(const char *name, float x, float y, float z)
599{
600 GPU_shader_uniform_3f(imm->shader, name, x, y, z);
601}
602
603void immUniform3fv(const char *name, const float data[3])
604{
606}
607
608void immUniform4f(const char *name, float x, float y, float z, float w)
609{
610 GPU_shader_uniform_4f(imm->shader, name, x, y, z, w);
611}
612
613void immUniform4fv(const char *name, const float data[4])
614{
616}
617
618void immUniformArray4fv(const char *name, const float *data, int count)
619{
621 imm->shader, name, count, reinterpret_cast<const float (*)[4]>(data));
622}
623
624void immUniformMatrix4fv(const char *name, const float data[4][4])
625{
627}
628
629void immUniform1i(const char *name, int x)
630{
632}
633
634void immBindTexture(const char *name, gpu::Texture *tex)
635{
636 int binding = GPU_shader_get_sampler_binding(imm->shader, name);
637 GPU_texture_bind(tex, binding);
638}
639
641{
642 int binding = GPU_shader_get_sampler_binding(imm->shader, name);
643 GPU_texture_bind_ex(tex, state, binding);
644}
645
646void immBindUniformBuf(const char *name, gpu::UniformBuf *ubo)
647{
648 int binding = GPU_shader_get_ubo_binding(imm->shader, name);
649 GPU_uniformbuf_bind(ubo, binding);
650}
651
652/* --- convenience functions for setting "uniform vec4 color" --- */
653
654void immUniformColor4f(float r, float g, float b, float a)
655{
657 BLI_assert(uniform_loc != -1);
658 float data[4] = {r, g, b, a};
659 GPU_shader_uniform_float_ex(imm->shader, uniform_loc, 4, 1, data);
660 /* For wide Line workaround. */
662}
663
664void immUniformColor4fv(const float rgba[4])
665{
666 immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
667}
668
669void immUniformColor3f(float r, float g, float b)
670{
671 immUniformColor4f(r, g, b, 1.0f);
672}
673
674void immUniformColor3fv(const float rgb[3])
675{
676 immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f);
677}
678
679void immUniformColor3fvAlpha(const float rgb[3], float a)
680{
681 immUniformColor4f(rgb[0], rgb[1], rgb[2], a);
682}
683
685{
686 const float scale = 1.0f / 255.0f;
687 immUniformColor4f(scale * r, scale * g, scale * b, 1.0f);
688}
689
691{
692 const float scale = 1.0f / 255.0f;
693 immUniformColor4f(scale * r, scale * g, scale * b, scale * a);
694}
695
696void immUniformColor3ubv(const uchar rgb[3])
697{
698 immUniformColor3ub(rgb[0], rgb[1], rgb[2]);
699}
700
701void immUniformColor3ubvAlpha(const uchar rgb[3], uchar alpha)
702{
703 immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha);
704}
705
706void immUniformColor4ubv(const uchar rgba[4])
707{
708 immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]);
709}
710
711#ifndef GPU_STANDALONE
712
713void immUniformThemeColor(int color_id)
714{
715 float color[4];
718}
719
720void immUniformThemeColorAlpha(int color_id, float a)
721{
722 float color[4];
724 color[3] = a;
726}
727
728void immUniformThemeColor3(int color_id)
729{
730 float color[3];
733}
734
735void immUniformThemeColorShade(int color_id, int offset)
736{
737 float color[4];
738 ui::theme::get_color_shade_4fv(color_id, offset, color);
740}
741
742void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
743{
744 float color[4];
745 ui::theme::get_color_shade_alpha_4fv(color_id, color_offset, alpha_offset, color);
747}
748
749void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int offset)
750{
751 float color[4];
752 ui::theme::get_color_blend_shade_4fv(color_id1, color_id2, fac, offset, color);
754}
755
756void immUniformThemeColorBlend(int color_id1, int color_id2, float fac)
757{
758 uint8_t color[3];
759 ui::theme::get_color_blend_3ubv(color_id1, color_id2, fac, color);
761}
762
763void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
764{
765 uchar col[4];
766 ui::theme::get_color_shade_alpha_4ubv(colorid, coloffset, alphaoffset, col);
767 immUniformColor4ub(col[0], col[1], col[2], col[3]);
768}
769
770#endif /* !GPU_STANDALONE */
771
772} // namespace blender
#define ELEM(...)
#define BLI_assert_msg(a, msg)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
constexpr int64_t size() const
constexpr int64_t start() const
constexpr StringRefNull()
static Context * get()
Batch * procedural_triangles_batch_get()
void assert_framebuffer_shader_compatibility(Shader *sh)
std::optional< GPUBuiltinShader > prev_builtin_shader
virtual uchar * begin()=0
virtual void end()=0
void polyline_draw_workaround(uint64_t offset)
std::optional< GPUBuiltinShader > builtin_shader_bound
MutableSpan< T > data()
float3x3 scale(float3x3 mat, float2 scale)
const int state
bool is_fetch_float(VertAttrType attr_type)
void get_color_3fv(int colorid, float col[3])
void get_color_4fv(int colorid, float col[4])
void get_color_shade_4fv(int colorid, int offset, float col[4])
void get_color_blend_shade_4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
void get_color_shade_alpha_4ubv(int colorid, int coloffset, int alphaoffset, unsigned char col[4])
void get_color_blend_3ubv(int colorid1, int colorid2, float fac, unsigned char col[3])
void get_color_shade_alpha_4fv(int colorid, int coloffset, int alphaoffset, float col[4])
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void GPU_shader_uniform_2iv(gpu::Shader *sh, const char *name, const int data[2])
int GPU_shader_get_sampler_binding(gpu::Shader *shader, const char *name)
void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int offset)
unsigned __int64 uint64_t
Definition BKE_text.h:91
void immUniformThemeColorBlend(int color_id1, int color_id2, float fac)
void immAttr4f(uint attr_id, float x, float y, float z, float w)
gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, gpu::VertBuf *vertex_buf, gpu::IndexBuf *index_buf, GPUBatchFlag owns_flag)
Definition gpu_batch.cc:53
static void immEndVertex()
void immAttr3f(uint attr_id, float x, float y, float z)
void immEnd()
void GPU_shader_uniform_2f(gpu::Shader *sh, const char *name, float x, float y)
void immUniformColor3f(float r, float g, float b)
unsigned int uint
Definition BKE_text.h:55
void immAttr4ubv(uint attr_id, const unsigned char data[4])
void GPU_shader_uniform_mat4(gpu::Shader *sh, const char *name, const float data[4][4])
void immUniformColor4ub(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void immVertex2iv(uint attr_id, const int data[2])
void immUniform2f(const char *name, float x, float y)
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
static Immediate * imm
void immAttrSkip(uint attr_id)
GPUVertFormat * immVertexFormat()
static bool vertex_count_makes_sense_for_primitive(uint vertex_len, GPUPrimType prim_type)
void GPU_shader_uniform_3f(gpu::Shader *sh, const char *name, float x, float y, float z)
void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
void immBegin(GPUPrimType, uint vertex_len)
BLI_INLINE const char * GPU_vertformat_attr_name_get(const GPUVertFormat *format, const GPUVertAttr *attr, uint n_idx)
@ GPU_PRIM_TRI_STRIP
@ GPU_PRIM_LINE_STRIP_ADJ
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_LINE_LOOP
void GPU_shader_uniform_4fv(gpu::Shader *sh, const char *name, const float data[4])
void GPU_shader_uniform_3iv(gpu::Shader *sh, const char *name, const int data[3])
void GPU_batch_set_shader(gpu::Batch *batch, gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void immUniformColor4fv(const float rgba[4])
gpu::Batch * immBeginBatchAtMost(GPUPrimType, uint vertex_len)
void immUniformThemeColorAlpha(int color_id, float a)
void immAttr2f(uint attr_id, float x, float y)
void immUnbindProgram()
void GPU_shader_uniform_1b(gpu::Shader *sh, const char *name, bool value)
void immUniformColor3ubv(const unsigned char rgb[3])
bool immIsShaderBound()
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_UNIFORM_COLOR
float GPU_line_width_get()
Definition gpu_state.cc:241
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)
Definition gpu_batch.cc:329
unsigned short uint16_t
Definition BKE_text.h:80
void immAttr3fv(uint attr_id, const float data[3])
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void GPU_shader_uniform_4fv_array(gpu::Shader *sh, const char *name, int len, const float(*val)[4])
void GPU_matrix_bind(gpu::Shader *shader)
void immUniformThemeColor(int color_id)
void immAttr2fv(uint attr_id, const float data[2])
void immUniform1f(const char *name, float x)
void immVertex2f(uint attr_id, float x, float y)
unsigned char uchar
Definition BKE_text.h:58
void immVertex2i(uint attr_id, int x, int y)
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
void immAttr4fv(uint attr_id, const float data[4])
BMesh const char void * data
static void wide_line_workaround_end()
void GPU_shader_unbind()
void GPU_shader_uniform_3fv(gpu::Shader *sh, const char *name, const float data[3])
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_POLYLINE_FLAT_COLOR
@ GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR
@ GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR
@ GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR
void immUniform4fv(const char *name, const float data[4])
void GPU_shader_uniform_float_ex(gpu::Shader *shader, int location, int length, int array_size, const float *value)
void immUniformThemeColor3(int color_id)
void immUniformThemeColorShade(int color_id, int offset)
unsigned char uint8_t
Definition BKE_text.h:79
void immUniformArray4fv(const char *bare_name, const float *data, int count)
void immUniformMatrix4fv(const char *name, const float data[4][4])
void immUniformColor4f(float r, float g, float b, float a)
void VertexFormat_pack(GPUVertFormat *format)
void immUniformColor3ub(unsigned char r, unsigned char g, unsigned char b)
@ GPU_BATCH_OWNS_VBO
Definition GPU_batch.hh:44
@ GPU_BATCH_BUILDING
Definition GPU_batch.hh:53
gpu::Batch * immBeginBatch(GPUPrimType, uint vertex_len)
void immBindTexture(const char *name, gpu::Texture *tex)
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_1i(gpu::Shader *sh, const char *name, int value)
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
void GPU_uniformbuf_bind(gpu::UniformBuf *ubo, int slot)
void GPU_texture_bind_ex(gpu::Texture *texture, GPUSamplerState state, int unit)
static void wide_line_workaround_start(GPUPrimType prim_type)
void GPU_shader_uniform_2fv(gpu::Shader *sh, const char *name, const float data[2])
void immAttr4ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void immBindTextureSampler(const char *name, gpu::Texture *tex, GPUSamplerState state)
void immVertex4f(uint attr_id, float x, float y, float z, float w)
gpu::Shader * GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
void immAttr1f(uint attr_id, float x)
void immVertex3fv(uint attr_id, const float data[3])
void GPU_shader_uniform_1f(gpu::Shader *sh, const char *name, float value)
void immUniform3fv(const char *name, const float data[3])
void immUniform4f(const char *name, float x, float y, float z, float w)
bool GPU_line_smooth_get()
Definition gpu_state.cc:247
GPUBlend GPU_blend_get()
Definition gpu_state.cc:211
gpu::Shader * immGetShader()
void GPU_texture_bind(gpu::Texture *texture, int unit)
static void setAttrValueBit(uint attr_id)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_data_resize(gpu::VertBuf &verts, uint v_len)
void immBindShader(gpu::Shader *shader)
int GPU_shader_get_ubo_binding(gpu::Shader *shader, const char *name)
signed int int32_t
Definition BKE_text.h:78
void immAttr2i(uint attr_id, int x, int y)
void GPU_batch_draw_advanced(gpu::Batch *batch, int vertex_first, int vertex_count, int instance_first, int instance_count)
void GPU_vertformat_clear(GPUVertFormat *)
void immDeactivate()
void immActivate()
void immUniform2fv(const char *name, const float data[2])
MINLINE void copy_v4_v4(float r[4], const float a[4])
void immAttr1u(uint attr_id, uint x)
void immUniformColor3fv(const float rgb[3])
void immVertex3f(uint attr_id, float x, float y, float z)
void immUniform3f(const char *name, float x, float y, float z)
void immUniform1i(const char *name, int x)
void immUniformColor4ubv(const unsigned char rgba[4])
int GPU_shader_get_builtin_uniform(gpu::Shader *shader, int builtin)
void immVertex2fv(uint attr_id, const float data[2])
void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a)
void immUniformColor3fvAlpha(const float rgb[3], float a)
void GPU_shader_uniform_4f(gpu::Shader *sh, const char *name, float x, float y, float z, float w)
void immBindUniformBuf(const char *name, gpu::UniformBuf *ubo)
struct blender::GPUVertAttr::Type type
GPUVertAttr attrs[GPU_VERT_ATTR_MAX_LEN]