Blender  V2.93
gpu_immediate.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2016 by Mike Erwin.
17  * All rights reserved.
18  */
19 
26 #ifndef GPU_STANDALONE
27 # include "UI_resources.h"
28 #endif
29 
30 #include "GPU_immediate.h"
31 #include "GPU_matrix.h"
32 #include "GPU_texture.h"
33 
34 #include "gpu_context_private.hh"
35 #include "gpu_immediate_private.hh"
36 #include "gpu_shader_private.hh"
39 
40 using namespace blender::gpu;
41 
42 static thread_local Immediate *imm = nullptr;
43 
45 {
46  imm = Context::get()->imm;
47 }
48 
50 {
51  imm = nullptr;
52 }
53 
55 {
57  return &imm->vertex_format;
58 }
59 
61 {
62  BLI_assert(imm->shader == nullptr);
63 
64  imm->shader = shader;
65  imm->builtin_shader_bound = GPU_SHADER_TEXT; /* Default value. */
66 
67  if (!imm->vertex_format.packed) {
69  imm->enabled_attr_bits = 0xFFFFu & ~(0xFFFFu << imm->vertex_format.attr_len);
70  }
71 
75 }
76 
78 {
81  imm->builtin_shader_bound = shader_id;
82 }
83 
85 {
86  BLI_assert(imm->shader != nullptr);
87 
89  imm->shader = nullptr;
90 }
91 
92 /* XXX do not use it. Special hack to use OCIO with batch API. */
94 {
95  return imm->shader;
96 }
97 
98 #ifndef NDEBUG
99 static bool vertex_count_makes_sense_for_primitive(uint vertex_len, GPUPrimType prim_type)
100 {
101  /* does vertex_len make sense for this primitive type? */
102  if (vertex_len == 0) {
103  return false;
104  }
105 
106  switch (prim_type) {
107  case GPU_PRIM_POINTS:
108  return true;
109  case GPU_PRIM_LINES:
110  return vertex_len % 2 == 0;
111  case GPU_PRIM_LINE_STRIP:
112  case GPU_PRIM_LINE_LOOP:
113  return vertex_len >= 2;
115  return vertex_len >= 4;
116  case GPU_PRIM_TRIS:
117  return vertex_len % 3 == 0;
118  case GPU_PRIM_TRI_STRIP:
119  case GPU_PRIM_TRI_FAN:
120  return vertex_len >= 3;
121  default:
122  return false;
123  }
124 }
125 #endif
126 
127 /* -------------------------------------------------------------------- */
135 {
137  return;
138  }
139 
140  float line_width = GPU_line_width_get();
141 
142  if (line_width == 1.0f) {
143  /* No need to change the shader. */
144  return;
145  }
146 
147  eGPUBuiltinShader polyline_sh;
148  switch (imm->builtin_shader_bound) {
151  break;
155  break;
158  polyline_sh = GPU_SHADER_3D_POLYLINE_FLAT_COLOR;
159  break;
163  break;
164  default:
165  /* Cannot replace the current shader with a polyline shader. */
166  return;
167  }
168 
170 
172 
173  /* TODO(fclem): Don't use geometry shader and use quad instancing with double load. */
174  // GPU_vertformat_multiload_enable(imm->vertex_format, 2);
175 
176  immBindBuiltinProgram(polyline_sh);
177 
178  float viewport[4];
179  GPU_viewport_size_get_f(viewport);
180  immUniform2fv("viewportSize", &viewport[2]);
181  immUniform1f("lineWidth", line_width);
182 
183  if (GPU_blend_get() == GPU_BLEND_NONE) {
184  /* Disable line smoothing when blending is disabled (see T81827). */
185  immUniform1i("lineSmooth", 0);
186  }
187 
188  if (ELEM(polyline_sh,
192  }
193 }
194 
196 {
197  if (imm->prev_builtin_shader) {
198  if (GPU_blend_get() == GPU_BLEND_NONE) {
199  /* Restore default. */
200  immUniform1i("lineSmooth", 1);
201  }
203 
206  }
207 }
208 
211 void immBegin(GPUPrimType prim_type, uint vertex_len)
212 {
213  BLI_assert(imm->prim_type == GPU_PRIM_NONE); /* Make sure we haven't already begun. */
214  BLI_assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type));
215 
216  wide_line_workaround_start(prim_type);
217 
218  imm->prim_type = prim_type;
219  imm->vertex_len = vertex_len;
220  imm->vertex_idx = 0;
222 
223  imm->vertex_data = imm->begin();
224 }
225 
226 void immBeginAtMost(GPUPrimType prim_type, uint vertex_len)
227 {
228  BLI_assert(vertex_len > 0);
229  imm->strict_vertex_len = false;
230  immBegin(prim_type, vertex_len);
231 }
232 
233 GPUBatch *immBeginBatch(GPUPrimType prim_type, uint vertex_len)
234 {
235  BLI_assert(imm->prim_type == GPU_PRIM_NONE); /* Make sure we haven't already begun. */
236  BLI_assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type));
237 
238  imm->prim_type = prim_type;
239  imm->vertex_len = vertex_len;
240  imm->vertex_idx = 0;
242 
244  GPU_vertbuf_data_alloc(verts, vertex_len);
245 
247 
248  imm->batch = GPU_batch_create_ex(prim_type, verts, nullptr, GPU_BATCH_OWNS_VBO);
249  imm->batch->flag |= GPU_BATCH_BUILDING;
250 
251  return imm->batch;
252 }
253 
255 {
256  BLI_assert(vertex_len > 0);
257  imm->strict_vertex_len = false;
258  return immBeginBatch(prim_type, vertex_len);
259 }
260 
261 void immEnd()
262 {
263  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* Make sure we're between a Begin/End pair. */
265 
266  if (imm->strict_vertex_len) {
267  BLI_assert(imm->vertex_idx == imm->vertex_len); /* With all vertices defined. */
268  }
269  else {
271  BLI_assert(imm->vertex_idx == 0 ||
273  }
274 
275  if (imm->batch) {
276  if (imm->vertex_idx < imm->vertex_len) {
278  /* TODO: resize only if vertex count is much smaller */
279  }
281  imm->batch->flag &= ~GPU_BATCH_BUILDING;
282  imm->batch = nullptr; /* don't free, batch belongs to caller */
283  }
284  else {
285  imm->end();
286  }
287 
288  /* Prepare for next immBegin. */
290  imm->strict_vertex_len = true;
291  imm->vertex_data = nullptr;
292 
294 }
295 
297 {
298  uint16_t mask = 1 << attr_id;
299  BLI_assert(imm->unassigned_attr_bits & mask); /* not already set */
301 }
302 
303 /* --- generic attribute functions --- */
304 
305 void immAttr1f(uint attr_id, float x)
306 {
308  BLI_assert(attr_id < imm->vertex_format.attr_len);
310  BLI_assert(attr->comp_len == 1);
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 }
320 
321 void immAttr2f(uint attr_id, float x, float y)
322 {
324  BLI_assert(attr_id < imm->vertex_format.attr_len);
326  BLI_assert(attr->comp_len == 2);
328  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
330 
331  float *data = (float *)(imm->vertex_data + attr->offset);
332  /* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data); */
333 
334  data[0] = x;
335  data[1] = y;
336 }
337 
338 void immAttr3f(uint attr_id, float x, float y, float z)
339 {
341  BLI_assert(attr_id < imm->vertex_format.attr_len);
343  BLI_assert(attr->comp_len == 3);
345  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
347 
348  float *data = (float *)(imm->vertex_data + attr->offset);
349  /* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data); */
350 
351  data[0] = x;
352  data[1] = y;
353  data[2] = z;
354 }
355 
356 void immAttr4f(uint attr_id, float x, float y, float z, float w)
357 {
359  BLI_assert(attr_id < imm->vertex_format.attr_len);
361  BLI_assert(attr->comp_len == 4);
363  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
365 
366  float *data = (float *)(imm->vertex_data + attr->offset);
367  /* printf("%s %td %p\n", __FUNCTION__, (GLubyte*)data - imm->buffer_data, data); */
368 
369  data[0] = x;
370  data[1] = y;
371  data[2] = z;
372  data[3] = w;
373 }
374 
376 {
378  BLI_assert(attr_id < imm->vertex_format.attr_len);
380  BLI_assert(attr->comp_len == 1);
382  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
384 
385  uint *data = (uint *)(imm->vertex_data + attr->offset);
386 
387  data[0] = x;
388 }
389 
390 void immAttr2i(uint attr_id, int x, int y)
391 {
393  BLI_assert(attr_id < imm->vertex_format.attr_len);
395  BLI_assert(attr->comp_len == 2);
397  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
399 
400  int *data = (int *)(imm->vertex_data + attr->offset);
401 
402  data[0] = x;
403  data[1] = y;
404 }
405 
406 void immAttr2s(uint attr_id, short x, short y)
407 {
409  BLI_assert(attr_id < imm->vertex_format.attr_len);
411  BLI_assert(attr->comp_len == 2);
413  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
415 
416  short *data = (short *)(imm->vertex_data + attr->offset);
417 
418  data[0] = x;
419  data[1] = y;
420 }
421 
422 void immAttr2fv(uint attr_id, const float data[2])
423 {
424  immAttr2f(attr_id, data[0], data[1]);
425 }
426 
427 void immAttr3fv(uint attr_id, const float data[3])
428 {
429  immAttr3f(attr_id, data[0], data[1], data[2]);
430 }
431 
432 void immAttr4fv(uint attr_id, const float data[4])
433 {
434  immAttr4f(attr_id, data[0], data[1], data[2], data[3]);
435 }
436 
438 {
440  BLI_assert(attr_id < imm->vertex_format.attr_len);
441  BLI_assert(attr->comp_type == GPU_COMP_U8);
442  BLI_assert(attr->comp_len == 3);
444  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
446 
447  uchar *data = imm->vertex_data + attr->offset;
448  /* printf("%s %td %p\n", __FUNCTION__, data - imm->buffer_data, data); */
449 
450  data[0] = r;
451  data[1] = g;
452  data[2] = b;
453 }
454 
456 {
458  BLI_assert(attr_id < imm->vertex_format.attr_len);
459  BLI_assert(attr->comp_type == GPU_COMP_U8);
460  BLI_assert(attr->comp_len == 4);
462  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
464 
465  uchar *data = imm->vertex_data + attr->offset;
466  /* printf("%s %td %p\n", __FUNCTION__, data - imm->buffer_data, data); */
467 
468  data[0] = r;
469  data[1] = g;
470  data[2] = b;
471  data[3] = a;
472 }
473 
475 {
476  immAttr3ub(attr_id, data[0], data[1], data[2]);
477 }
478 
480 {
481  immAttr4ub(attr_id, data[0], data[1], data[2], data[3]);
482 }
483 
485 {
486  BLI_assert(attr_id < imm->vertex_format.attr_len);
488  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
490 }
491 
492 static void immEndVertex() /* and move on to the next vertex */
493 {
494  BLI_assert(imm->prim_type != GPU_PRIM_NONE); /* make sure we're between a Begin/End pair */
496 
497  /* Have all attributes been assigned values?
498  * If not, copy value from previous vertex. */
499  if (imm->unassigned_attr_bits) {
500  BLI_assert(imm->vertex_idx > 0); /* first vertex must have all attributes specified */
501  for (uint a_idx = 0; a_idx < imm->vertex_format.attr_len; a_idx++) {
502  if ((imm->unassigned_attr_bits >> a_idx) & 1) {
503  const GPUVertAttr *a = &imm->vertex_format.attrs[a_idx];
504 
505 #if 0
506  printf("copying %s from vertex %u to %u\n", a->name, imm->vertex_idx - 1, imm->vertex_idx);
507 #endif
508 
509  uchar *data = imm->vertex_data + a->offset;
510  memcpy(data, data - imm->vertex_format.stride, a->sz);
511  /* TODO: consolidate copy of adjacent attributes */
512  }
513  }
514  }
515 
516  imm->vertex_idx++;
519 }
520 
521 void immVertex2f(uint attr_id, float x, float y)
522 {
523  immAttr2f(attr_id, x, y);
524  immEndVertex();
525 }
526 
527 void immVertex3f(uint attr_id, float x, float y, float z)
528 {
529  immAttr3f(attr_id, x, y, z);
530  immEndVertex();
531 }
532 
533 void immVertex4f(uint attr_id, float x, float y, float z, float w)
534 {
535  immAttr4f(attr_id, x, y, z, w);
536  immEndVertex();
537 }
538 
539 void immVertex2i(uint attr_id, int x, int y)
540 {
541  immAttr2i(attr_id, x, y);
542  immEndVertex();
543 }
544 
545 void immVertex2s(uint attr_id, short x, short y)
546 {
547  immAttr2s(attr_id, x, y);
548  immEndVertex();
549 }
550 
551 void immVertex2fv(uint attr_id, const float data[2])
552 {
553  immAttr2f(attr_id, data[0], data[1]);
554  immEndVertex();
555 }
556 
557 void immVertex3fv(uint attr_id, const float data[3])
558 {
559  immAttr3f(attr_id, data[0], data[1], data[2]);
560  immEndVertex();
561 }
562 
563 void immVertex2iv(uint attr_id, const int data[2])
564 {
565  immAttr2i(attr_id, data[0], data[1]);
566  immEndVertex();
567 }
568 
569 /* --- generic uniform functions --- */
570 
571 void immUniform1f(const char *name, float x)
572 {
574 }
575 
576 void immUniform2f(const char *name, float x, float y)
577 {
578  GPU_shader_uniform_2f(imm->shader, name, x, y);
579 }
580 
581 void immUniform2fv(const char *name, const float data[2])
582 {
584 }
585 
586 void immUniform3f(const char *name, float x, float y, float z)
587 {
588  GPU_shader_uniform_3f(imm->shader, name, x, y, z);
589 }
590 
591 void immUniform3fv(const char *name, const float data[3])
592 {
594 }
595 
596 void immUniform4f(const char *name, float x, float y, float z, float w)
597 {
598  GPU_shader_uniform_4f(imm->shader, name, x, y, z, w);
599 }
600 
601 void immUniform4fv(const char *name, const float data[4])
602 {
604 }
605 
606 /* Note array index is not supported for name (i.e: "array[0]"). */
607 void immUniformArray4fv(const char *name, const float *data, int count)
608 {
609  GPU_shader_uniform_4fv_array(imm->shader, name, count, (const float(*)[4])data);
610 }
611 
612 void immUniformMatrix4fv(const char *name, const float data[4][4])
613 {
615 }
616 
617 void immUniform1i(const char *name, int x)
618 {
620 }
621 
622 void immBindTexture(const char *name, GPUTexture *tex)
623 {
624  int binding = GPU_shader_get_texture_binding(imm->shader, name);
625  GPU_texture_bind(tex, binding);
626 }
627 
629 {
630  int binding = GPU_shader_get_texture_binding(imm->shader, name);
631  GPU_texture_bind_ex(tex, state, binding, true);
632 }
633 
634 /* --- convenience functions for setting "uniform vec4 color" --- */
635 
636 void immUniformColor4f(float r, float g, float b, float a)
637 {
639  BLI_assert(uniform_loc != -1);
640  float data[4] = {r, g, b, a};
641  GPU_shader_uniform_vector(imm->shader, uniform_loc, 4, 1, data);
642  /* For wide Line workaround. */
644 }
645 
646 void immUniformColor4fv(const float rgba[4])
647 {
648  immUniformColor4f(rgba[0], rgba[1], rgba[2], rgba[3]);
649 }
650 
651 void immUniformColor3f(float r, float g, float b)
652 {
653  immUniformColor4f(r, g, b, 1.0f);
654 }
655 
656 void immUniformColor3fv(const float rgb[3])
657 {
658  immUniformColor4f(rgb[0], rgb[1], rgb[2], 1.0f);
659 }
660 
661 void immUniformColor3fvAlpha(const float rgb[3], float a)
662 {
663  immUniformColor4f(rgb[0], rgb[1], rgb[2], a);
664 }
665 
667 {
668  const float scale = 1.0f / 255.0f;
669  immUniformColor4f(scale * r, scale * g, scale * b, 1.0f);
670 }
671 
673 {
674  const float scale = 1.0f / 255.0f;
675  immUniformColor4f(scale * r, scale * g, scale * b, scale * a);
676 }
677 
678 void immUniformColor3ubv(const uchar rgb[3])
679 {
680  immUniformColor3ub(rgb[0], rgb[1], rgb[2]);
681 }
682 
684 {
685  immUniformColor4ub(rgb[0], rgb[1], rgb[2], alpha);
686 }
687 
688 void immUniformColor4ubv(const uchar rgba[4])
689 {
690  immUniformColor4ub(rgba[0], rgba[1], rgba[2], rgba[3]);
691 }
692 
693 #ifndef GPU_STANDALONE
694 
695 void immUniformThemeColor(int color_id)
696 {
697  float color[4];
698  UI_GetThemeColor4fv(color_id, color);
699  immUniformColor4fv(color);
700 }
701 
702 void immUniformThemeColorAlpha(int color_id, float a)
703 {
704  float color[4];
705  UI_GetThemeColor3fv(color_id, color);
706  color[3] = a;
707  immUniformColor4fv(color);
708 }
709 
710 void immUniformThemeColor3(int color_id)
711 {
712  float color[3];
713  UI_GetThemeColor3fv(color_id, color);
714  immUniformColor3fv(color);
715 }
716 
717 void immUniformThemeColorShade(int color_id, int offset)
718 {
719  float color[4];
720  UI_GetThemeColorShade4fv(color_id, offset, color);
721  immUniformColor4fv(color);
722 }
723 
724 void immUniformThemeColorShadeAlpha(int color_id, int color_offset, int alpha_offset)
725 {
726  float color[4];
727  UI_GetThemeColorShadeAlpha4fv(color_id, color_offset, alpha_offset, color);
728  immUniformColor4fv(color);
729 }
730 
731 void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int offset)
732 {
733  float color[4];
734  UI_GetThemeColorBlendShade4fv(color_id1, color_id2, fac, offset, color);
735  immUniformColor4fv(color);
736 }
737 
738 void immUniformThemeColorBlend(int color_id1, int color_id2, float fac)
739 {
740  uint8_t color[3];
741  UI_GetThemeColorBlend3ubv(color_id1, color_id2, fac, color);
742  immUniformColor3ubv(color);
743 }
744 
745 void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
746 {
747  uchar col[4];
748  UI_GetThemeColorShadeAlpha4ubv(colorid, coloffset, alphaoffset, col);
749  immUniformColor4ub(col[0], col[1], col[2], col[3]);
750 }
751 
752 #endif /* GPU_STANDALONE */
#define BLI_assert(a)
Definition: BLI_assert.h:58
MINLINE void copy_v4_v4(float r[4], const float a[4])
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
#define ELEM(...)
GPUBatch
Definition: GPU_batch.h:93
void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader)
Definition: gpu_batch.cc:222
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
Definition: gpu_batch.cc:60
@ GPU_BATCH_OWNS_VBO
Definition: GPU_batch.h:45
@ GPU_BATCH_BUILDING
Definition: GPU_batch.h:59
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void GPU_matrix_bind(struct GPUShader *shader)
Definition: gpu_matrix.cc:646
GPUPrimType
Definition: GPU_primitive.h:34
@ GPU_PRIM_TRI_FAN
Definition: GPU_primitive.h:41
@ GPU_PRIM_LINE_LOOP
Definition: GPU_primitive.h:39
@ GPU_PRIM_LINE_STRIP_ADJ
Definition: GPU_primitive.h:45
@ GPU_PRIM_NONE
Definition: GPU_primitive.h:47
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:35
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:38
@ GPU_PRIM_TRI_STRIP
Definition: GPU_primitive.h:40
@ GPU_PRIM_TRIS
Definition: GPU_primitive.h:37
void GPU_shader_unbind(void)
Definition: gpu_shader.cc:516
void GPU_shader_uniform_2fv(GPUShader *sh, const char *name, const float data[2])
Definition: gpu_shader.cc:674
void GPU_shader_set_srgb_uniform(GPUShader *shader)
Definition: gpu_shader.cc:731
struct GPUShader GPUShader
Definition: GPU_shader.h:33
void GPU_shader_uniform_1i(GPUShader *sh, const char *name, int value)
Definition: gpu_shader.cc:639
void GPU_shader_uniform_3f(GPUShader *sh, const char *name, float x, float y, float z)
Definition: gpu_shader.cc:656
void GPU_shader_uniform_2f(GPUShader *sh, const char *name, float x, float y)
Definition: gpu_shader.cc:650
void GPU_shader_uniform_1f(GPUShader *sh, const char *name, float value)
Definition: gpu_shader.cc:668
void GPU_shader_uniform_vector(GPUShader *shader, int location, int length, int arraysize, const float *value)
Definition: gpu_shader.cc:617
void GPU_shader_uniform_3fv(GPUShader *sh, const char *name, const float data[3])
Definition: gpu_shader.cc:680
void GPU_shader_uniform_4fv_array(GPUShader *sh, const char *name, int len, const float(*val)[4])
Definition: gpu_shader.cc:704
GPUShader * GPU_shader_get_builtin_shader(eGPUBuiltinShader shader)
void GPU_shader_bind(GPUShader *shader)
Definition: gpu_shader.cc:494
@ GPU_UNIFORM_COLOR
Definition: GPU_shader.h:106
void GPU_shader_uniform_4fv(GPUShader *sh, const char *name, const float data[4])
Definition: gpu_shader.cc:686
void GPU_shader_uniform_4f(GPUShader *sh, const char *name, float x, float y, float z, float w)
Definition: gpu_shader.cc:662
eGPUBuiltinShader
Definition: GPU_shader.h:159
@ GPU_SHADER_3D_SMOOTH_COLOR
Definition: GPU_shader.h:215
@ GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR
Definition: GPU_shader.h:240
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
Definition: GPU_shader.h:223
@ GPU_SHADER_TEXT
Definition: GPU_shader.h:161
@ GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR
Definition: GPU_shader.h:201
@ GPU_SHADER_2D_SMOOTH_COLOR
Definition: GPU_shader.h:185
@ GPU_SHADER_2D_UNIFORM_COLOR
Definition: GPU_shader.h:171
@ GPU_SHADER_3D_UNIFORM_COLOR
Definition: GPU_shader.h:200
@ GPU_SHADER_3D_FLAT_COLOR
Definition: GPU_shader.h:208
@ GPU_SHADER_3D_POLYLINE_FLAT_COLOR
Definition: GPU_shader.h:232
@ GPU_SHADER_2D_FLAT_COLOR
Definition: GPU_shader.h:178
@ GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR
Definition: GPU_shader.h:224
void GPU_shader_uniform_mat4(GPUShader *sh, const char *name, const float data[4][4])
Definition: gpu_shader.cc:692
int GPU_shader_get_texture_binding(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:585
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
Definition: gpu_shader.cc:558
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
float GPU_line_width_get(void)
Definition: gpu_state.cc:268
eGPUBlend GPU_blend_get(void)
Definition: gpu_state.cc:237
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:279
eGPUSamplerState
Definition: GPU_texture.h:40
void GPU_texture_bind_ex(GPUTexture *tex, eGPUSamplerState state, int unit, const bool set_number)
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
void GPU_texture_bind(GPUTexture *tex, int unit)
Definition: gpu_texture.cc:415
#define GPU_vertbuf_create_with_format(format)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void * GPU_vertbuf_get_data(const GPUVertBuf *verts)
void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len)
void GPU_vertformat_clear(GPUVertFormat *)
@ GPU_COMP_F32
@ GPU_COMP_I32
@ GPU_COMP_U32
@ GPU_COMP_I16
@ GPU_COMP_U8
void UI_GetThemeColorShadeAlpha4ubv(int colorid, int coloffset, int alphaoffset, unsigned char col[4])
Definition: resources.c:1103
void UI_GetThemeColor3fv(int colorid, float col[3])
Definition: resources.c:1191
void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3])
Definition: resources.c:1122
void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
Definition: resources.c:1326
void UI_GetThemeColorShadeAlpha4fv(int colorid, int coloffset, int alphaoffset, float col[4])
Definition: resources.c:1286
void UI_GetThemeColor4fv(int colorid, float col[4])
Definition: resources.c:1199
void UI_GetThemeColorShade4fv(int colorid, int offset, float col[4])
Definition: resources.c:1359
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
static Context * get(void)
Definition: gpu_context.cc:88
eGPUBuiltinShader builtin_shader_bound
virtual void end(void)=0
virtual uchar * begin(void)=0
eGPUBuiltinShader prev_builtin_shader
static CCL_NAMESPACE_BEGIN const double alpha
static float verts[][3]
struct @612::@615 attr_id
uint col
void immVertex2iv(uint attr_id, const int data[2])
GPUBatch * immBeginBatchAtMost(GPUPrimType prim_type, uint vertex_len)
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])
void immAttrSkip(uint attr_id)
void immAttr3ubv(uint attr_id, const uchar data[3])
GPUShader * immGetShader()
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 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)
GPUBatch * immBeginBatch(GPUPrimType prim_type, uint vertex_len)
void immAttr1u(uint attr_id, uint x)
void immVertex2i(uint attr_id, int x, int y)
static thread_local Immediate * imm
void immUniform1f(const char *name, float x)
static void wide_line_workaround_end()
void immBindTextureSampler(const char *name, GPUTexture *tex, eGPUSamplerState state)
static void setAttrValueBit(uint attr_id)
GPUVertFormat * immVertexFormat()
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)
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
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
static ulong state[N]
static unsigned a[3]
Definition: RandGen.cpp:92
unsigned short uint16_t
Definition: stdint.h:82
signed int int32_t
Definition: stdint.h:80
unsigned char uint8_t
Definition: stdint.h:81
GPUVertAttr attrs[GPU_VERT_ATTR_MAX_LEN]
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)