Blender V4.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
21#include "gpu_shader_private.hh"
23
24using namespace blender::gpu;
25
26static thread_local Immediate *imm = nullptr;
27
29{
30 imm = Context::get()->imm;
31}
32
34{
35 imm = nullptr;
36}
37
39{
40 GPU_vertformat_clear(&imm->vertex_format);
41 return &imm->vertex_format;
42}
43
45{
46 BLI_assert(imm->shader == nullptr);
47
48 imm->shader = shader;
49 imm->builtin_shader_bound = std::nullopt;
50
51 if (!imm->vertex_format.packed) {
52 VertexFormat_pack(&imm->vertex_format);
53 imm->enabled_attr_bits = 0xFFFFu & ~(0xFFFFu << imm->vertex_format.attr_len);
54 }
55
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;
79}
80
81#ifndef NDEBUG
83{
84 /* does vertex_len make sense for this primitive type? */
85 if (vertex_len == 0) {
86 return false;
87 }
88
89 switch (prim_type) {
90 case GPU_PRIM_POINTS:
91 return true;
92 case GPU_PRIM_LINES:
93 return vertex_len % 2 == 0;
96 return vertex_len >= 2;
98 return vertex_len >= 4;
99 case GPU_PRIM_TRIS:
100 return vertex_len % 3 == 0;
102 case GPU_PRIM_TRI_FAN:
103 return vertex_len >= 3;
104 default:
105 return false;
106 }
107}
108#endif
109
110/* -------------------------------------------------------------------- */
116
118{
120 return;
121 }
122
123 float line_width = GPU_line_width_get();
124
125 if (line_width == 1.0f) {
126 /* No need to change the shader. */
127 return;
128 }
129 if (!imm->builtin_shader_bound) {
130 return;
131 }
132
133 eGPUBuiltinShader polyline_sh;
134 switch (*imm->builtin_shader_bound) {
137 break;
140 break;
143 break;
146 break;
147 default:
148 /* Cannot replace the current shader with a polyline shader. */
149 return;
150 }
151
152 imm->prev_builtin_shader = imm->builtin_shader_bound;
153
155
156 /* TODO(fclem): Don't use geometry shader and use quad instancing with double load. */
157 // GPU_vertformat_multiload_enable(imm->vertex_format, 2);
158
159 immBindBuiltinProgram(polyline_sh);
160
161 float viewport[4];
162 GPU_viewport_size_get_f(viewport);
163 immUniform2fv("viewportSize", &viewport[2]);
164 immUniform1f("lineWidth", line_width);
165
166 if (GPU_blend_get() == GPU_BLEND_NONE) {
167 /* Disable line smoothing when blending is disabled (see #81827). */
168 immUniform1i("lineSmooth", 0);
169 }
170
171 if (ELEM(polyline_sh,
174 {
175 immUniformColor4fv(imm->uniform_color);
176 }
177}
178
180{
181 if (imm->prev_builtin_shader) {
182 if (GPU_blend_get() == GPU_BLEND_NONE) {
183 /* Restore default. */
184 immUniform1i("lineSmooth", 1);
185 }
187
188 immBindBuiltinProgram(*imm->prev_builtin_shader);
189 imm->prev_builtin_shader = std::nullopt;
190 }
191}
192
194
195void immBegin(GPUPrimType prim_type, uint vertex_len)
196{
197 BLI_assert(imm->prim_type == GPU_PRIM_NONE); /* Make sure we haven't already begun. */
199
201
202 imm->prim_type = prim_type;
203 imm->vertex_len = vertex_len;
204 imm->vertex_idx = 0;
205 imm->unassigned_attr_bits = imm->enabled_attr_bits;
206
207 imm->vertex_data = imm->begin();
208}
209
210void immBeginAtMost(GPUPrimType prim_type, uint vertex_len)
211{
212 BLI_assert(vertex_len > 0);
213 imm->strict_vertex_len = false;
214 immBegin(prim_type, vertex_len);
215}
216
217blender::gpu::Batch *immBeginBatch(GPUPrimType prim_type, uint vertex_len)
218{
219 BLI_assert(imm->prim_type == GPU_PRIM_NONE); /* Make sure we haven't already begun. */
221
222 imm->prim_type = prim_type;
223 imm->vertex_len = vertex_len;
224 imm->vertex_idx = 0;
225 imm->unassigned_attr_bits = imm->enabled_attr_bits;
226
228 GPU_vertbuf_data_alloc(*verts, vertex_len);
229
230 imm->vertex_data = verts->data<uchar>().data();
231
232 imm->batch = GPU_batch_create_ex(prim_type, verts, nullptr, GPU_BATCH_OWNS_VBO);
233 imm->batch->flag |= GPU_BATCH_BUILDING;
234
235 return imm->batch;
236}
237
238blender::gpu::Batch *immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len)
239{
240 BLI_assert(vertex_len > 0);
241 imm->strict_vertex_len = false;
242 return immBeginBatch(prim_type, vertex_len);
243}
244
245void immEnd()
246{
247 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* Make sure we're between a Begin/End pair. */
248 BLI_assert(imm->vertex_data || imm->batch);
249
250 if (imm->strict_vertex_len) {
251 BLI_assert(imm->vertex_idx == imm->vertex_len); /* With all vertices defined. */
252 }
253 else {
254 BLI_assert(imm->vertex_idx <= imm->vertex_len);
255 BLI_assert(imm->vertex_idx == 0 ||
256 vertex_count_makes_sense_for_primitive(imm->vertex_idx, imm->prim_type));
257 }
258
259 if (imm->batch) {
260 if (imm->vertex_idx < imm->vertex_len) {
261 GPU_vertbuf_data_resize(*imm->batch->verts[0], imm->vertex_idx);
262 /* TODO: resize only if vertex count is much smaller */
263 }
264 GPU_batch_set_shader(imm->batch, imm->shader);
265 imm->batch->flag &= ~GPU_BATCH_BUILDING;
266 imm->batch = nullptr; /* don't free, batch belongs to caller */
267 }
268 else {
269 imm->end();
270 }
271
272 /* Prepare for next immBegin. */
273 imm->prim_type = GPU_PRIM_NONE;
274 imm->strict_vertex_len = true;
275 imm->vertex_data = nullptr;
276
278}
279
281{
282 uint16_t mask = 1 << attr_id;
283 BLI_assert(imm->unassigned_attr_bits & mask); /* not already set */
284 imm->unassigned_attr_bits &= ~mask;
285}
286
287/* --- generic attribute functions --- */
288
290{
291 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
292 BLI_assert(attr_id < imm->vertex_format.attr_len);
294 BLI_assert(attr->comp_len == 1);
295 BLI_assert(imm->vertex_idx < imm->vertex_len);
296 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
298
299 float *data = (float *)(imm->vertex_data + attr->offset);
300 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
301
302 data[0] = x;
303}
304
305void immAttr2f(uint attr_id, float x, float y)
306{
307 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
308 BLI_assert(attr_id < imm->vertex_format.attr_len);
310 BLI_assert(attr->comp_len == 2);
311 BLI_assert(imm->vertex_idx < imm->vertex_len);
312 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
314
315 float *data = (float *)(imm->vertex_data + attr->offset);
316 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
317
318 data[0] = x;
319 data[1] = y;
320}
321
322void immAttr3f(uint attr_id, float x, float y, float z)
323{
324 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
325 BLI_assert(attr_id < imm->vertex_format.attr_len);
327 BLI_assert(attr->comp_len == 3);
328 BLI_assert(imm->vertex_idx < imm->vertex_len);
329 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
331
332 float *data = (float *)(imm->vertex_data + attr->offset);
333 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
334
335 data[0] = x;
336 data[1] = y;
337 data[2] = z;
338}
339
340void immAttr4f(uint attr_id, float x, float y, float z, float w)
341{
342 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
343 BLI_assert(attr_id < imm->vertex_format.attr_len);
345 BLI_assert(attr->comp_len == 4);
346 BLI_assert(imm->vertex_idx < imm->vertex_len);
347 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
349
350 float *data = (float *)(imm->vertex_data + attr->offset);
351 // printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data);
352
353 data[0] = x;
354 data[1] = y;
355 data[2] = z;
356 data[3] = w;
357}
358
360{
361 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
362 BLI_assert(attr_id < imm->vertex_format.attr_len);
364 BLI_assert(attr->comp_len == 1);
365 BLI_assert(imm->vertex_idx < imm->vertex_len);
366 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
368
369 uint *data = (uint *)(imm->vertex_data + attr->offset);
370
371 data[0] = x;
372}
373
374void immAttr2i(uint attr_id, int x, int y)
375{
376 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
377 BLI_assert(attr_id < imm->vertex_format.attr_len);
379 BLI_assert(attr->comp_len == 2);
380 BLI_assert(imm->vertex_idx < imm->vertex_len);
381 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
383
384 int *data = (int *)(imm->vertex_data + attr->offset);
385
386 data[0] = x;
387 data[1] = y;
388}
389
390void immAttr2s(uint attr_id, short x, short y)
391{
392 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
393 BLI_assert(attr_id < imm->vertex_format.attr_len);
395 BLI_assert(attr->comp_len == 2);
396 BLI_assert(imm->vertex_idx < imm->vertex_len);
397 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
399
400 short *data = (short *)(imm->vertex_data + attr->offset);
401
402 data[0] = x;
403 data[1] = y;
404}
405
406void immAttr2fv(uint attr_id, const float data[2])
407{
408 immAttr2f(attr_id, data[0], data[1]);
409}
410
411void immAttr3fv(uint attr_id, const float data[3])
412{
413 immAttr3f(attr_id, data[0], data[1], data[2]);
414}
415
416void immAttr4fv(uint attr_id, const float data[4])
417{
418 immAttr4f(attr_id, data[0], data[1], data[2], data[3]);
419}
420
422{
423 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
424 BLI_assert(attr_id < imm->vertex_format.attr_len);
426 BLI_assert(attr->comp_len == 3);
427 BLI_assert(imm->vertex_idx < imm->vertex_len);
428 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
430
431 uchar *data = imm->vertex_data + attr->offset;
432 // printf("%s %td %p\n", __FUNCTION__, data - imm->buffer_data, data);
433
434 data[0] = r;
435 data[1] = g;
436 data[2] = b;
437}
438
440{
441 GPUVertAttr *attr = &imm->vertex_format.attrs[attr_id];
442 BLI_assert(attr_id < imm->vertex_format.attr_len);
444 BLI_assert(attr->comp_len == 4);
445 BLI_assert(imm->vertex_idx < imm->vertex_len);
446 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
448
449 uchar *data = imm->vertex_data + attr->offset;
450 // printf("%s %td %p\n", __FUNCTION__, data - imm->buffer_data, data);
451
452 data[0] = r;
453 data[1] = g;
454 data[2] = b;
455 data[3] = a;
456}
457
459{
460 immAttr3ub(attr_id, data[0], data[1], data[2]);
461}
462
464{
465 immAttr4ub(attr_id, data[0], data[1], data[2], data[3]);
466}
467
469{
470 BLI_assert(attr_id < imm->vertex_format.attr_len);
471 BLI_assert(imm->vertex_idx < imm->vertex_len);
472 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
474}
475
476static void immEndVertex() /* and move on to the next vertex */
477{
478 BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
479 BLI_assert(imm->vertex_idx < imm->vertex_len);
480
481 /* Have all attributes been assigned values?
482 * If not, copy value from previous vertex. */
483 if (imm->unassigned_attr_bits) {
484 BLI_assert(imm->vertex_idx > 0); /* first vertex must have all attributes specified */
485 for (uint a_idx = 0; a_idx < imm->vertex_format.attr_len; a_idx++) {
486 if ((imm->unassigned_attr_bits >> a_idx) & 1) {
487 const GPUVertAttr *a = &imm->vertex_format.attrs[a_idx];
488
489#if 0
490 printf("copying %s from vertex %u to %u\n", a->name, imm->vertex_idx - 1, imm->vertex_idx);
491#endif
492
493 uchar *data = imm->vertex_data + a->offset;
494 memcpy(data, data - imm->vertex_format.stride, a->size);
495 /* TODO: consolidate copy of adjacent attributes */
496 }
497 }
498 }
499
500 imm->vertex_idx++;
501 imm->vertex_data += imm->vertex_format.stride;
502 imm->unassigned_attr_bits = imm->enabled_attr_bits;
503}
504
505void immVertex2f(uint attr_id, float x, float y)
506{
507 immAttr2f(attr_id, x, y);
508 immEndVertex();
509}
510
511void immVertex3f(uint attr_id, float x, float y, float z)
512{
513 immAttr3f(attr_id, x, y, z);
514 immEndVertex();
515}
516
517void immVertex4f(uint attr_id, float x, float y, float z, float w)
518{
519 immAttr4f(attr_id, x, y, z, w);
520 immEndVertex();
521}
522
523void immVertex2i(uint attr_id, int x, int y)
524{
525 immAttr2i(attr_id, x, y);
526 immEndVertex();
527}
528
529void immVertex2s(uint attr_id, short x, short y)
530{
531 immAttr2s(attr_id, x, y);
532 immEndVertex();
533}
534
535void immVertex2fv(uint attr_id, const float data[2])
536{
537 immAttr2f(attr_id, data[0], data[1]);
538 immEndVertex();
539}
540
541void immVertex3fv(uint attr_id, const float data[3])
542{
543 immAttr3f(attr_id, data[0], data[1], data[2]);
544 immEndVertex();
545}
546
547void immVertex2iv(uint attr_id, const int data[2])
548{
549 immAttr2i(attr_id, data[0], data[1]);
550 immEndVertex();
551}
552
553/* --- generic uniform functions --- */
554
555void immUniform1f(const char *name, float x)
556{
557 GPU_shader_uniform_1f(imm->shader, name, x);
558}
559
560void immUniform2f(const char *name, float x, float y)
561{
562 GPU_shader_uniform_2f(imm->shader, name, x, y);
563}
564
565void immUniform2fv(const char *name, const float data[2])
566{
567 GPU_shader_uniform_2fv(imm->shader, name, data);
568}
569
570void immUniform3f(const char *name, float x, float y, float z)
571{
572 GPU_shader_uniform_3f(imm->shader, name, x, y, z);
573}
574
575void immUniform3fv(const char *name, const float data[3])
576{
577 GPU_shader_uniform_3fv(imm->shader, name, data);
578}
579
580void immUniform4f(const char *name, float x, float y, float z, float w)
581{
582 GPU_shader_uniform_4f(imm->shader, name, x, y, z, w);
583}
584
585void immUniform4fv(const char *name, const float data[4])
586{
587 GPU_shader_uniform_4fv(imm->shader, name, data);
588}
589
590void immUniformArray4fv(const char *name, const float *data, int count)
591{
592 GPU_shader_uniform_4fv_array(imm->shader, name, count, (const float(*)[4])data);
593}
594
595void immUniformMatrix4fv(const char *name, const float data[4][4])
596{
597 GPU_shader_uniform_mat4(imm->shader, name, data);
598}
599
600void immUniform1i(const char *name, int x)
601{
602 GPU_shader_uniform_1i(imm->shader, name, x);
603}
604
605void immBindTexture(const char *name, GPUTexture *tex)
606{
607 int binding = GPU_shader_get_sampler_binding(imm->shader, name);
608 GPU_texture_bind(tex, binding);
609}
610
611void immBindTextureSampler(const char *name, GPUTexture *tex, GPUSamplerState state)
612{
613 int binding = GPU_shader_get_sampler_binding(imm->shader, name);
614 GPU_texture_bind_ex(tex, state, binding);
615}
616
617void immBindUniformBuf(const char *name, GPUUniformBuf *ubo)
618{
619 int binding = GPU_shader_get_ubo_binding(imm->shader, name);
620 GPU_uniformbuf_bind(ubo, binding);
621}
622
623/* --- convenience functions for setting "uniform vec4 color" --- */
624
625void immUniformColor4f(float r, float g, float b, float a)
626{
628 BLI_assert(uniform_loc != -1);
629 float data[4] = {r, g, b, a};
630 GPU_shader_uniform_float_ex(imm->shader, uniform_loc, 4, 1, data);
631 /* For wide Line workaround. */
632 copy_v4_v4(imm->uniform_color, data);
633}
634
635void immUniformColor4fv(const float rgba[4])
636{
637 immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
638}
639
640void immUniformColor3f(float r, float g, float b)
641{
642 immUniformColor4f(r, g, b, 1.0f);
643}
644
645void immUniformColor3fv(const float rgb[3])
646{
647 immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f);
648}
649
650void immUniformColor3fvAlpha(const float rgb[3], float a)
651{
652 immUniformColor4f(rgb[0], rgb[1], rgb[2], a);
653}
654
656{
657 const float scale = 1.0f / 255.0f;
658 immUniformColor4f(scale * r, scale * g, scale * b, 1.0f);
659}
660
662{
663 const float scale = 1.0f / 255.0f;
664 immUniformColor4f(scale * r, scale * g, scale * b, scale * a);
665}
666
667void immUniformColor3ubv(const uchar rgb[3])
668{
669 immUniformColor3ub(rgb[0], rgb[1], rgb[2]);
670}
671
672void immUniformColor3ubvAlpha(const uchar rgb[3], uchar alpha)
673{
674 immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha);
675}
676
677void immUniformColor4ubv(const uchar rgba[4])
678{
679 immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]);
680}
681
682#ifndef GPU_STANDALONE
683
684void immUniformThemeColor(int color_id)
685{
686 float color[4];
687 UI_GetThemeColor4fv(color_id, color);
689}
690
691void immUniformThemeColorAlpha(int color_id, float a)
692{
693 float color[4];
694 UI_GetThemeColor3fv(color_id, color);
695 color[3] = a;
697}
698
699void immUniformThemeColor3(int color_id)
700{
701 float color[3];
702 UI_GetThemeColor3fv(color_id, color);
704}
705
706void immUniformThemeColorShade(int color_id, int offset)
707{
708 float color[4];
709 UI_GetThemeColorShade4fv(color_id, offset, color);
711}
712
713void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
714{
715 float color[4];
716 UI_GetThemeColorShadeAlpha4fv(color_id, color_offset, alpha_offset, color);
718}
719
720void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int offset)
721{
722 float color[4];
723 UI_GetThemeColorBlendShade4fv(color_id1, color_id2, fac, offset, color);
725}
726
727void immUniformThemeColorBlend(int color_id1, int color_id2, float fac)
728{
729 uint8_t color[3];
730 UI_GetThemeColorBlend3ubv(color_id1, color_id2, fac, color);
732}
733
734void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
735{
736 uchar col[4];
737 UI_GetThemeColorShadeAlpha4ubv(colorid, coloffset, alphaoffset, col);
738 immUniformColor4ub(col[0], col[1], col[2], col[3]);
739}
740
741#endif /* !GPU_STANDALONE */
#define BLI_assert(a)
Definition BLI_assert.h:50
MINLINE void copy_v4_v4(float r[4], const float a[4])
unsigned char uchar
unsigned int uint
#define ELEM(...)
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
Definition gpu_batch.cc:56
void GPU_batch_set_shader(blender::gpu::Batch *batch, GPUShader *shader)
@ GPU_BATCH_OWNS_VBO
Definition GPU_batch.hh:42
@ GPU_BATCH_BUILDING
Definition GPU_batch.hh:56
void GPU_matrix_bind(GPUShader *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_sampler_binding(GPUShader *shader, const char *name)
void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2])
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
int GPU_shader_get_ubo_binding(GPUShader *shader, const char *name)
void GPU_shader_uniform_3f(GPUShader *sh, const char *name, float x, float y, float z)
void GPU_shader_uniform_2f(GPUShader *sh, const char *name, float x, float y)
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)
void GPU_shader_uniform_3fv(GPUShader *sh, const char *name, const float data[3])
void GPU_shader_uniform_4fv_array(GPUShader *sh, const char *name, int len, const float(*val)[4])
void GPU_shader_uniform_float_ex(GPUShader *shader, int location, int length, int array_size, const float *value)
void GPU_shader_bind(GPUShader *shader)
@ GPU_UNIFORM_COLOR
void GPU_shader_uniform_4fv(GPUShader *sh, const char *name, const float data[4])
void GPU_shader_uniform_4f(GPUShader *sh, const char *name, float x, float y, float z, float w)
void GPU_shader_uniform_mat4(GPUShader *sh, const char *name, const float data[4][4])
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
void GPU_shader_unbind()
GPUShader * GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
eGPUBuiltinShader
@ 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
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
eGPUBlend GPU_blend_get()
Definition gpu_state.cc:221
float GPU_line_width_get()
Definition gpu_state.cc:251
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:262
void GPU_texture_bind(GPUTexture *texture, int unit)
void GPU_texture_bind_ex(GPUTexture *texture, GPUSamplerState state, int unit)
void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int slot)
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_data_resize(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertformat_clear(GPUVertFormat *)
@ GPU_COMP_F32
@ GPU_COMP_I32
@ GPU_COMP_U32
@ GPU_COMP_I16
@ GPU_COMP_U8
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
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])
struct GPUShader GPUShader
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
static Context * get()
static void set_srgb_uniform(GPUShader *shader)
local_group_size(16, 16) .push_constant(Type b
#define printf
static float verts[][3]
uint col
struct @157336070235062372277311340362362342103123126032::@132215023242101136103363133227133264017254024241 attr_id
void immVertex2iv(uint attr_id, const int data[2])
void immVertex4f(uint attr_id, float x, float y, float z, float w)
static void immEndVertex()
void immUniform4f(const char *name, float x, float y, float z, float w)
void immUniformThemeColorAlpha(int color_id, float a)
void immEnd()
void immUniform2fv(const char *name, const float data[2])
void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
void immUnbindProgram()
void immAttr4fv(uint attr_id, const float data[4])
void immUniform3fv(const char *name, const float data[3])
void immAttr2fv(uint attr_id, const float data[2])
blender::gpu::Batch * immBeginBatch(GPUPrimType prim_type, uint vertex_len)
void immAttrSkip(uint attr_id)
void immAttr3ubv(uint attr_id, const uchar data[3])
void immUniform2f(const char *name, float x, float y)
void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
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)
static bool vertex_count_makes_sense_for_primitive(uint vertex_len, GPUPrimType prim_type)
void immBindTextureSampler(const char *name, GPUTexture *tex, GPUSamplerState state)
void immVertex2f(uint attr_id, float x, float y)
void immAttr1f(uint attr_id, float x)
void immUniformThemeColor(int color_id)
void immAttr2s(uint attr_id, short x, short y)
void immUniformThemeColorShade(int color_id, int offset)
void immBeginAtMost(GPUPrimType prim_type, uint vertex_len)
void immUniformColor3ub(uchar r, uchar g, uchar b)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immBindTexture(const char *name, GPUTexture *tex)
void immBindShader(GPUShader *shader)
void immVertex3f(uint attr_id, float x, float y, float z)
void immVertex2fv(uint attr_id, const float data[2])
void immAttr3ub(uint attr_id, uchar r, uchar g, uchar b)
static void wide_line_workaround_start(GPUPrimType prim_type)
void immVertex2s(uint attr_id, short x, short y)
void immUniform1i(const char *name, int x)
void immDeactivate()
void immAttr4ubv(uint attr_id, const uchar data[4])
void immUniformThemeColor3(int color_id)
void immAttr1u(uint attr_id, uint x)
void immVertex2i(uint attr_id, int x, int y)
static thread_local Immediate * imm
void immBindUniformBuf(const char *name, GPUUniformBuf *ubo)
void immUniform1f(const char *name, float x)
GPUShader * immGetShader()
static void wide_line_workaround_end()
GPUVertFormat * immVertexFormat()
static void setAttrValueBit(uint attr_id)
void immActivate()
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)
blender::gpu::Batch * immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len)
void immUniformColor3ubv(const uchar rgb[3])
void immVertex3fv(uint attr_id, const float data[3])
void immUniformColor4ub(uchar r, uchar g, uchar b, uchar a)
void immUniformColor3ubvAlpha(const uchar rgb[3], uchar alpha)
void immUniformColor3fvAlpha(const float rgb[3], float a)
void immUniformArray4fv(const char *name, const float *data, int count)
void immUniformColor4ubv(const uchar rgba[4])
void immAttr3f(uint attr_id, float x, float y, float z)
void immBegin(GPUPrimType prim_type, uint vertex_len)
void immUniformColor3fv(const float rgb[3])
void immAttr4ub(uint attr_id, uchar r, uchar g, uchar b, uchar a)
void VertexFormat_pack(GPUVertFormat *format)
int count
ccl_device_inline float4 mask(const int4 mask, const float4 a)
static ulong state[N]
unsigned short uint16_t
Definition stdint.h:79
signed int int32_t
Definition stdint.h:77
unsigned char uint8_t
Definition stdint.h:78