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