Blender  V2.93
draw_manager_data.c
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  * Copyright 2016, Blender Foundation.
17  */
18 
23 #include "draw_manager.h"
24 
25 #include "BKE_curve.h"
26 #include "BKE_duplilist.h"
27 #include "BKE_global.h"
28 #include "BKE_image.h"
29 #include "BKE_mesh.h"
30 #include "BKE_object.h"
31 #include "BKE_paint.h"
32 #include "BKE_pbvh.h"
33 
34 #include "DNA_curve_types.h"
35 #include "DNA_mesh_types.h"
36 #include "DNA_meta_types.h"
37 
38 #include "BLI_alloca.h"
39 #include "BLI_hash.h"
40 #include "BLI_link_utils.h"
41 #include "BLI_listbase.h"
42 #include "BLI_memblock.h"
43 #include "BLI_mempool.h"
44 
45 #ifdef DRW_DEBUG_CULLING
46 # include "BLI_math_bits.h"
47 #endif
48 
49 #include "GPU_buffers.h"
50 #include "GPU_material.h"
51 #include "GPU_uniform_buffer.h"
52 
53 #include "intern/gpu_codegen.h"
54 
55 /* -------------------------------------------------------------------- */
59 static void draw_call_sort(DRWCommand *array, DRWCommand *array_tmp, int array_len)
60 {
61  /* Count unique batches. Tt's not really important if
62  * there is collisions. If there is a lot of different batches,
63  * the sorting benefit will be negligible.
64  * So at least sort fast! */
65  uchar idx[128] = {0};
66  /* Shift by 6 positions knowing each GPUBatch is > 64 bytes */
67 #define KEY(a) ((((size_t)((a).draw.batch)) >> 6) % ARRAY_SIZE(idx))
68  BLI_assert(array_len <= ARRAY_SIZE(idx));
69 
70  for (int i = 0; i < array_len; i++) {
71  /* Early out if nothing to sort. */
72  if (++idx[KEY(array[i])] == array_len) {
73  return;
74  }
75  }
76  /* Cumulate batch indices */
77  for (int i = 1; i < ARRAY_SIZE(idx); i++) {
78  idx[i] += idx[i - 1];
79  }
80  /* Traverse in reverse to not change the order of the resource ID's. */
81  for (int src = array_len - 1; src >= 0; src--) {
82  array_tmp[--idx[KEY(array[src])]] = array[src];
83  }
84 #undef KEY
85 
86  memcpy(array, array_tmp, sizeof(*array) * array_len);
87 }
88 
90 {
91  int chunk_id = DRW_handle_chunk_get(&DST.resource_handle);
92  int elem_id = DRW_handle_id_get(&DST.resource_handle);
93  int ubo_len = 1 + chunk_id - ((elem_id == 0) ? 1 : 0);
94  size_t list_size = sizeof(GPUUniformBuf *) * ubo_len;
95 
96  /* TODO find a better system. currently a lot of obinfos UBO are going to be unused
97  * if not rendering with Eevee. */
98 
99  if (vmempool->matrices_ubo == NULL) {
100  vmempool->matrices_ubo = MEM_callocN(list_size, __func__);
101  vmempool->obinfos_ubo = MEM_callocN(list_size, __func__);
102  vmempool->ubo_len = ubo_len;
103  }
104 
105  /* Remove unnecessary buffers */
106  for (int i = ubo_len; i < vmempool->ubo_len; i++) {
107  GPU_uniformbuf_free(vmempool->matrices_ubo[i]);
108  GPU_uniformbuf_free(vmempool->obinfos_ubo[i]);
109  }
110 
111  if (ubo_len != vmempool->ubo_len) {
112  vmempool->matrices_ubo = MEM_recallocN(vmempool->matrices_ubo, list_size);
113  vmempool->obinfos_ubo = MEM_recallocN(vmempool->obinfos_ubo, list_size);
114  vmempool->ubo_len = ubo_len;
115  }
116 
117  /* Create/Update buffers. */
118  for (int i = 0; i < ubo_len; i++) {
119  void *data_obmat = BLI_memblock_elem_get(vmempool->obmats, i, 0);
120  void *data_infos = BLI_memblock_elem_get(vmempool->obinfos, i, 0);
121  if (vmempool->matrices_ubo[i] == NULL) {
122  vmempool->matrices_ubo[i] = GPU_uniformbuf_create(sizeof(DRWObjectMatrix) *
124  vmempool->obinfos_ubo[i] = GPU_uniformbuf_create(sizeof(DRWObjectInfos) *
126  }
127  GPU_uniformbuf_update(vmempool->matrices_ubo[i], data_obmat);
128  GPU_uniformbuf_update(vmempool->obinfos_ubo[i], data_infos);
129  }
130 
132 
133  /* Aligned alloc to avoid unaligned memcpy. */
134  DRWCommandChunk *chunk_tmp = MEM_mallocN_aligned(sizeof(DRWCommandChunk), 16, "tmp call chunk");
135  DRWCommandChunk *chunk;
136  BLI_memblock_iter iter;
137  BLI_memblock_iternew(vmempool->commands, &iter);
138  while ((chunk = BLI_memblock_iterstep(&iter))) {
139  bool sortable = true;
140  /* We can only sort chunks that contain #DRWCommandDraw only. */
141  for (int i = 0; i < ARRAY_SIZE(chunk->command_type) && sortable; i++) {
142  if (chunk->command_type[i] != 0) {
143  sortable = false;
144  }
145  }
146  if (sortable) {
147  draw_call_sort(chunk->commands, chunk_tmp->commands, chunk->command_used);
148  }
149  }
150  MEM_freeN(chunk_tmp);
151 }
152 
155 /* -------------------------------------------------------------------- */
160  int loc,
162  const void *value,
163  eGPUSamplerState sampler_state,
164  int length,
165  int arraysize)
166 {
167  if (loc == -1) {
168  /* Nice to enable eventually, for now EEVEE uses uniforms that might not exist. */
169  // BLI_assert(0);
170  return;
171  }
172 
173  DRWUniformChunk *unichunk = shgroup->uniforms;
174  /* Happens on first uniform or if chunk is full. */
175  if (!unichunk || unichunk->uniform_used == unichunk->uniform_len) {
177  unichunk->uniform_len = ARRAY_SIZE(shgroup->uniforms->uniforms);
178  unichunk->uniform_used = 0;
179  BLI_LINKS_PREPEND(shgroup->uniforms, unichunk);
180  }
181 
182  DRWUniform *uni = unichunk->uniforms + unichunk->uniform_used++;
183 
184  uni->location = loc;
185  uni->type = type;
186  uni->length = length;
187  uni->arraysize = arraysize;
188 
189  switch (type) {
191  BLI_assert(length <= 4);
192  memcpy(uni->ivalue, value, sizeof(int) * length);
193  break;
195  BLI_assert(length <= 4);
196  memcpy(uni->fvalue, value, sizeof(float) * length);
197  break;
198  case DRW_UNIFORM_BLOCK:
199  uni->block = (GPUUniformBuf *)value;
200  break;
202  uni->block_ref = (GPUUniformBuf **)value;
203  break;
204  case DRW_UNIFORM_IMAGE:
205  case DRW_UNIFORM_TEXTURE:
206  uni->texture = (GPUTexture *)value;
207  uni->sampler_state = sampler_state;
208  break;
211  uni->texture_ref = (GPUTexture **)value;
212  uni->sampler_state = sampler_state;
213  break;
215  uni->uniform_attrs = (GPUUniformAttrList *)value;
216  break;
217  default:
218  uni->pvalue = (const float *)value;
219  break;
220  }
221 }
222 
224  const char *name,
226  const void *value,
227  int length,
228  int arraysize)
229 {
230  BLI_assert(arraysize > 0 && arraysize <= 16);
231  BLI_assert(length >= 0 && length <= 16);
237  int location = GPU_shader_get_uniform(shgroup->shader, name);
238  drw_shgroup_uniform_create_ex(shgroup, location, type, value, 0, length, arraysize);
239 }
240 
242  const char *name,
243  const GPUTexture *tex,
244  eGPUSamplerState sampler_state)
245 {
246  BLI_assert(tex != NULL);
247  int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
248  drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_TEXTURE, tex, sampler_state, 0, 1);
249 }
250 
251 void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
252 {
254 }
255 
257  const char *name,
258  GPUTexture **tex,
259  eGPUSamplerState sampler_state)
260 {
261  BLI_assert(tex != NULL);
262  int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
263  drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_TEXTURE_REF, tex, sampler_state, 0, 1);
264 }
265 
267 {
269 }
270 
271 void DRW_shgroup_uniform_image(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
272 {
273  BLI_assert(tex != NULL);
274  int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
275  drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_IMAGE, tex, 0, 0, 1);
276 }
277 
278 void DRW_shgroup_uniform_image_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
279 {
280  BLI_assert(tex != NULL);
281  int loc = GPU_shader_get_texture_binding(shgroup->shader, name);
283 }
284 
286  const char *name,
287  const GPUUniformBuf *ubo)
288 {
289  BLI_assert(ubo != NULL);
290  int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
291  drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_BLOCK, ubo, 0, 0, 1);
292 }
293 
294 void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup, const char *name, GPUUniformBuf **ubo)
295 {
296  BLI_assert(ubo != NULL);
297  int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
298  drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_BLOCK_REF, ubo, 0, 0, 1);
299 }
300 
302  const char *name,
303  const int *value,
304  int arraysize)
305 {
306  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT, value, 1, arraysize);
307 }
308 
310  const char *name,
311  const float *value,
312  int arraysize)
313 {
314  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 1, arraysize);
315 }
316 
318  const char *name,
319  const float *value,
320  int arraysize)
321 {
322  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 2, arraysize);
323 }
324 
326  const char *name,
327  const float *value,
328  int arraysize)
329 {
330  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 3, arraysize);
331 }
332 
334  const char *name,
335  const float *value,
336  int arraysize)
337 {
338  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 4, arraysize);
339 }
340 
342  const char *name,
343  const int *value,
344  int arraysize)
345 {
346  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT, value, 1, arraysize);
347 }
348 
350  const char *name,
351  const int *value,
352  int arraysize)
353 {
354  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT, value, 2, arraysize);
355 }
356 
358  const char *name,
359  const int *value,
360  int arraysize)
361 {
362  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT, value, 3, arraysize);
363 }
364 
366  const char *name,
367  const int *value,
368  int arraysize)
369 {
370  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT, value, 4, arraysize);
371 }
372 
373 void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float (*value)[3])
374 {
375  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, (float *)value, 9, 1);
376 }
377 
378 void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float (*value)[4])
379 {
380  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, (float *)value, 16, 1);
381 }
382 
383 /* Stores the int instead of a pointer. */
384 void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
385 {
386  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, &value, 1, 1);
387 }
388 
389 void DRW_shgroup_uniform_ivec2_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
390 {
391  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, value, 2, 1);
392 }
393 
394 void DRW_shgroup_uniform_ivec3_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
395 {
396  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, value, 3, 1);
397 }
398 
399 void DRW_shgroup_uniform_ivec4_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
400 {
401  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, value, 4, 1);
402 }
403 
404 void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
405 {
406  int ival = value;
407  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, &ival, 1, 1);
408 }
409 
410 void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
411 {
412  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT_COPY, &value, 1, 1);
413 }
414 
415 void DRW_shgroup_uniform_vec2_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
416 {
417  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT_COPY, value, 2, 1);
418 }
419 
420 void DRW_shgroup_uniform_vec3_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
421 {
422  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT_COPY, value, 3, 1);
423 }
424 
425 void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
426 {
427  drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT_COPY, value, 4, 1);
428 }
429 
431  const char *name,
432  const float (*value)[4],
433  int arraysize)
434 {
435  int location = GPU_shader_get_uniform(shgroup->shader, name);
436 
437  if (location == -1) {
438  /* Nice to enable eventually, for now EEVEE uses uniforms that might not exist. */
439  // BLI_assert(0);
440  return;
441  }
442 
443  for (int i = 0; i < arraysize; i++) {
445  shgroup, location + i, DRW_UNIFORM_FLOAT_COPY, &value[i], 0, 4, 1);
446  }
447 }
448 
451 /* -------------------------------------------------------------------- */
455 static void drw_call_calc_orco(Object *ob, float (*r_orcofacs)[4])
456 {
457  ID *ob_data = (ob) ? ob->data : NULL;
458  float *texcoloc = NULL;
459  float *texcosize = NULL;
460  if (ob_data != NULL) {
461  switch (GS(ob_data->name)) {
462  case ID_ME:
463  BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, &texcosize);
464  break;
465  case ID_CU: {
466  Curve *cu = (Curve *)ob_data;
468  texcoloc = cu->loc;
469  texcosize = cu->size;
470  break;
471  }
472  case ID_MB: {
473  MetaBall *mb = (MetaBall *)ob_data;
474  texcoloc = mb->loc;
475  texcosize = mb->size;
476  break;
477  }
478  default:
479  break;
480  }
481  }
482 
483  if ((texcoloc != NULL) && (texcosize != NULL)) {
484  mul_v3_v3fl(r_orcofacs[1], texcosize, 2.0f);
485  invert_v3(r_orcofacs[1]);
486  sub_v3_v3v3(r_orcofacs[0], texcoloc, texcosize);
487  negate_v3(r_orcofacs[0]);
488  mul_v3_v3(r_orcofacs[0], r_orcofacs[1]); /* result in a nice MADD in the shader */
489  }
490  else {
491  copy_v3_fl(r_orcofacs[0], 0.0f);
492  copy_v3_fl(r_orcofacs[1], 1.0f);
493  }
494 }
495 
496 BLI_INLINE void drw_call_matrix_init(DRWObjectMatrix *ob_mats, Object *ob, float (*obmat)[4])
497 {
498  copy_m4_m4(ob_mats->model, obmat);
499  if (ob) {
500  copy_m4_m4(ob_mats->modelinverse, ob->imat);
501  }
502  else {
503  /* WATCH: Can be costly. */
504  invert_m4_m4(ob_mats->modelinverse, ob_mats->model);
505  }
506 }
507 
508 static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
509 {
510  BLI_assert(ob);
511  /* Index. */
512  ob_infos->ob_index = ob->index;
513  /* Orco factors. */
514  drw_call_calc_orco(ob, ob_infos->orcotexfac);
515  /* Random float value. */
518  /* TODO(fclem): this is rather costly to do at runtime. Maybe we can
519  * put it in ob->runtime and make depsgraph ensure it is up to date. */
520  BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0);
521  ob_infos->ob_random = random * (1.0f / (float)0xFFFFFFFF);
522  /* Object State. */
523  ob_infos->ob_flag = 1.0f; /* Required to have a correct sign */
524  ob_infos->ob_flag += (ob->base_flag & BASE_SELECTED) ? (1 << 1) : 0;
525  ob_infos->ob_flag += (ob->base_flag & BASE_FROM_DUPLI) ? (1 << 2) : 0;
526  ob_infos->ob_flag += (ob->base_flag & BASE_FROM_SET) ? (1 << 3) : 0;
527  ob_infos->ob_flag += (ob == DST.draw_ctx.obact) ? (1 << 4) : 0;
528  /* Negative scaling. */
529  ob_infos->ob_flag *= (ob->transflag & OB_NEG_SCALE) ? -1.0f : 1.0f;
530  /* Object Color. */
531  copy_v4_v4(ob_infos->ob_color, ob->color);
532 }
533 
535 {
536  BoundBox *bbox;
537  if (ob != NULL && (bbox = BKE_object_boundbox_get(ob))) {
538  float corner[3];
539  /* Get BoundSphere center and radius from the BoundBox. */
540  mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]);
541  mul_v3_m4v3(corner, ob->obmat, bbox->vec[0]);
542  mul_m4_v3(ob->obmat, cull->bsphere.center);
543  cull->bsphere.radius = len_v3v3(cull->bsphere.center, corner);
544 
545  /* Bypass test for very large objects (see T67319). */
546  if (UNLIKELY(cull->bsphere.radius > 1e12)) {
547  cull->bsphere.radius = -1.0f;
548  }
549  }
550  else {
551  /* Bypass test. */
552  cull->bsphere.radius = -1.0f;
553  }
554  /* Reset user data */
555  cull->user_data = NULL;
556 }
557 
558 static DRWResourceHandle drw_resource_handle_new(float (*obmat)[4], Object *ob)
559 {
562  /* FIXME Meh, not always needed but can be accessed after creation.
563  * Also it needs to have the same resource handle. */
565  UNUSED_VARS(ob_infos);
566 
569 
570  if (ob && (ob->transflag & OB_NEG_SCALE)) {
572  }
573 
574  drw_call_matrix_init(ob_mats, ob, obmat);
575  drw_call_culling_init(culling, ob);
576  /* ob_infos is init only if needed. */
577 
578  return handle;
579 }
580 
582 {
584  if (handle == 0) {
585  /* Handle not yet allocated. Return next handle. */
586  handle = DST.resource_handle;
587  }
588  return handle & ~(1u << 31);
589 }
590 
592  float (*obmat)[4],
593  Object *ob)
594 {
595  if (ob == NULL) {
596  if (obmat == NULL) {
597  DRWResourceHandle handle = 0;
598  return handle;
599  }
600 
601  return drw_resource_handle_new(obmat, NULL);
602  }
603 
604  if (DST.ob_handle == 0) {
606  DST.ob_state_obinfo_init = false;
607  }
608 
609  if (shgroup->objectinfo) {
610  if (!DST.ob_state_obinfo_init) {
611  DST.ob_state_obinfo_init = true;
613  &DST.ob_handle);
614 
615  drw_call_obinfos_init(ob_infos, ob);
616  }
617  }
618 
619  if (shgroup->uniform_attrs) {
621  shgroup->uniform_attrs,
622  &DST.ob_handle,
623  ob,
625  DST.dupli_source);
626  }
627 
628  return DST.ob_handle;
629 }
630 
631 static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommandType type)
632 {
633  command_type_bits[index / 16] |= ((uint64_t)type) << ((index % 16) * 4);
634 }
635 
636 eDRWCommandType command_type_get(const uint64_t *command_type_bits, int index)
637 {
638  return ((command_type_bits[index / 16] >> ((index % 16) * 4)) & 0xF);
639 }
640 
642 {
643  DRWCommandChunk *chunk = shgroup->cmd.last;
644 
645  if (chunk == NULL) {
647  smallchunk->command_len = ARRAY_SIZE(smallchunk->commands);
648  smallchunk->command_used = 0;
649  smallchunk->command_type[0] = 0x0lu;
650  chunk = (DRWCommandChunk *)smallchunk;
651  BLI_LINKS_APPEND(&shgroup->cmd, chunk);
652  }
653  else if (chunk->command_used == chunk->command_len) {
655  chunk->command_len = ARRAY_SIZE(chunk->commands);
656  chunk->command_used = 0;
657  memset(chunk->command_type, 0x0, sizeof(chunk->command_type));
658  BLI_LINKS_APPEND(&shgroup->cmd, chunk);
659  }
660 
662 
663  return chunk->commands + chunk->command_used++;
664 }
665 
667 {
669  cmd->batch = batch;
670  cmd->handle = handle;
671 }
672 
674  DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint start, uint count)
675 {
677  cmd->batch = batch;
678  cmd->handle = handle;
679  cmd->vert_first = start;
680  cmd->vert_count = count;
681 }
682 
684  DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint count, bool use_attr)
685 {
687  cmd->batch = batch;
688  cmd->handle = handle;
689  cmd->inst_count = count;
690  cmd->use_attrs = use_attr;
691 }
692 
694  DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint start, uint count)
695 {
697  cmd->batch = batch;
698  cmd->handle = handle;
699  cmd->inst_first = start;
700  cmd->inst_count = count;
701 }
702 
704  GPUBatch *batch,
705  DRWResourceHandle handle,
706  uint vert_count)
707 {
709  cmd->batch = batch;
710  cmd->handle = handle;
711  cmd->vert_count = vert_count;
712 }
713 
714 static void drw_command_set_select_id(DRWShadingGroup *shgroup, GPUVertBuf *buf, uint select_id)
715 {
716  /* Only one can be valid. */
717  BLI_assert(buf == NULL || select_id == -1);
719  cmd->select_buf = buf;
720  cmd->select_id = select_id;
721 }
722 
724  uint write_mask,
725  uint reference,
726  uint compare_mask)
727 {
728  BLI_assert(write_mask <= 0xFF);
729  BLI_assert(reference <= 0xFF);
730  BLI_assert(compare_mask <= 0xFF);
732  cmd->write_mask = write_mask;
733  cmd->comp_mask = compare_mask;
734  cmd->ref = reference;
735 }
736 
737 static void drw_command_clear(DRWShadingGroup *shgroup,
738  eGPUFrameBufferBits channels,
739  uchar r,
740  uchar g,
741  uchar b,
742  uchar a,
743  float depth,
744  uchar stencil)
745 {
747  cmd->clear_channels = channels;
748  cmd->r = r;
749  cmd->g = g;
750  cmd->b = b;
751  cmd->a = a;
752  cmd->depth = depth;
753  cmd->stencil = stencil;
754 }
755 
757  DRWState enable,
758  DRWState disable)
759 {
760  /* TODO Restrict what state can be changed. */
762  cmd->enable = enable;
763  cmd->disable = disable;
764 }
765 
767  Object *ob,
768  float (*obmat)[4],
769  struct GPUBatch *geom,
770  bool bypass_culling,
771  void *user_data)
772 {
773  BLI_assert(geom != NULL);
774  if (G.f & G_FLAG_PICKSEL) {
776  }
777  DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : obmat, ob);
778  drw_command_draw(shgroup, geom, handle);
779 
780  /* Culling data. */
781  if (user_data || bypass_culling) {
783  &DST.ob_handle);
784 
785  if (user_data) {
786  culling->user_data = user_data;
787  }
788  if (bypass_culling) {
789  /* NOTE this will disable culling for the whole object. */
790  culling->bsphere.radius = -1.0f;
791  }
792  }
793 }
794 
796  DRWShadingGroup *shgroup, struct Object *ob, GPUBatch *geom, uint v_sta, uint v_ct)
797 {
798  BLI_assert(geom != NULL);
799  if (G.f & G_FLAG_PICKSEL) {
801  }
802  DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : NULL, ob);
803  drw_command_draw_range(shgroup, geom, handle, v_sta, v_ct);
804 }
805 
806 /* A count of 0 instance will use the default number of instance in the batch. */
808  DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint i_sta, uint i_ct)
809 {
810  BLI_assert(geom != NULL);
811  if (G.f & G_FLAG_PICKSEL) {
813  }
814  DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : NULL, ob);
815  drw_command_draw_intance_range(shgroup, geom, handle, i_sta, i_ct);
816 }
817 
819  GPUBatch *geom,
820  Object *ob,
821  uint vert_count)
822 {
823  BLI_assert(vert_count > 0);
824  BLI_assert(geom != NULL);
825  if (G.f & G_FLAG_PICKSEL) {
827  }
828  DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : NULL, ob);
829  drw_command_draw_procedural(shgroup, geom, handle, vert_count);
830 }
831 
833 {
834  struct GPUBatch *geom = drw_cache_procedural_points_get();
835  drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, point_count);
836 }
837 
839 {
840  struct GPUBatch *geom = drw_cache_procedural_lines_get();
841  drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, line_count * 2);
842 }
843 
845 {
847  drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, tri_count * 3);
848 }
849 
850 /* Should be removed */
852  Object *ob,
853  struct GPUBatch *geom,
854  uint count)
855 {
856  BLI_assert(geom != NULL);
857  if (G.f & G_FLAG_PICKSEL) {
859  }
860  DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : NULL, ob);
861  drw_command_draw_instance(shgroup, geom, handle, count, false);
862 }
863 
865  Object *ob,
866  struct GPUBatch *geom,
867  struct GPUBatch *inst_attributes)
868 {
869  BLI_assert(geom != NULL);
870  BLI_assert(inst_attributes != NULL);
871  if (G.f & G_FLAG_PICKSEL) {
873  }
874  DRWResourceHandle handle = drw_resource_handle(shgroup, ob ? ob->obmat : NULL, ob);
875  GPUBatch *batch = DRW_temp_batch_instance_request(DST.idatalist, NULL, inst_attributes, geom);
876  drw_command_draw_instance(shgroup, batch, handle, 0, true);
877 }
878 
879 #define SCULPT_DEBUG_BUFFERS (G.debug_value == 889)
880 typedef struct DRWSculptCallbackData {
884  bool use_wire;
885  bool use_mats;
886  bool use_mask;
887  bool use_fsets;
888  bool fast_mode; /* Set by draw manager. Do not init. */
889 
892 
893 #define SCULPT_DEBUG_COLOR(id) (sculpt_debug_colors[id % 9])
894 static float sculpt_debug_colors[9][4] = {
895  {1.0f, 0.2f, 0.2f, 1.0f},
896  {0.2f, 1.0f, 0.2f, 1.0f},
897  {0.2f, 0.2f, 1.0f, 1.0f},
898  {1.0f, 1.0f, 0.2f, 1.0f},
899  {0.2f, 1.0f, 1.0f, 1.0f},
900  {1.0f, 0.2f, 1.0f, 1.0f},
901  {1.0f, 0.7f, 0.2f, 1.0f},
902  {0.2f, 1.0f, 0.7f, 1.0f},
903  {0.7f, 0.2f, 1.0f, 1.0f},
904 };
905 
907 {
908  if (!buffers) {
909  return;
910  }
911 
912  /* Meh... use_mask is a bit misleading here. */
913  if (scd->use_mask && !GPU_pbvh_buffers_has_overlays(buffers)) {
914  return;
915  }
916 
917  GPUBatch *geom = GPU_pbvh_buffers_batch_get(buffers, scd->fast_mode, scd->use_wire);
918  short index = 0;
919 
920  if (scd->use_mats) {
921  index = GPU_pbvh_buffers_material_index_get(buffers);
922  if (index >= scd->num_shading_groups) {
923  index = 0;
924  }
925  }
926 
927  DRWShadingGroup *shgrp = scd->shading_groups[index];
928  if (geom != NULL && shgrp != NULL) {
929  if (SCULPT_DEBUG_BUFFERS) {
930  /* Color each buffers in different colors. Only work in solid/Xray mode. */
931  shgrp = DRW_shgroup_create_sub(shgrp);
933  shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->debug_node_nr++), 1);
934  }
935  /* DRW_shgroup_call_no_cull reuses matrices calculations for all the drawcalls of this
936  * object. */
937  DRW_shgroup_call_no_cull(shgrp, geom, scd->ob);
938  }
939 }
940 
941 static void sculpt_debug_cb(void *user_data,
942  const float bmin[3],
943  const float bmax[3],
944  PBVHNodeFlags flag)
945 {
946  int *debug_node_nr = (int *)user_data;
947  BoundBox bb;
948  BKE_boundbox_init_from_minmax(&bb, bmin, bmax);
949 
950 #if 0 /* Nodes hierarchy. */
951  if (flag & PBVH_Leaf) {
952  DRW_debug_bbox(&bb, (float[4]){0.0f, 1.0f, 0.0f, 1.0f});
953  }
954  else {
955  DRW_debug_bbox(&bb, (float[4]){0.5f, 0.5f, 0.5f, 0.6f});
956  }
957 #else /* Color coded leaf bounds. */
958  if (flag & PBVH_Leaf) {
959  DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*debug_node_nr)++));
960  }
961 #endif
962 }
963 
964 static void drw_sculpt_get_frustum_planes(Object *ob, float planes[6][4])
965 {
966  /* TODO: take into account partial redraw for clipping planes. */
968 
969  /* Transform clipping planes to object space. Transforming a plane with a
970  * 4x4 matrix is done by multiplying with the transpose inverse.
971  * The inverse cancels out here since we transform by inverse(obmat). */
972  float tmat[4][4];
973  transpose_m4_m4(tmat, ob->obmat);
974  for (int i = 0; i < 6; i++) {
975  mul_m4_v4(tmat, planes[i]);
976  }
977 }
978 
980 {
981  /* PBVH should always exist for non-empty meshes, created by depsgraph eval. */
982  PBVH *pbvh = (scd->ob->sculpt) ? scd->ob->sculpt->pbvh : NULL;
983  if (!pbvh) {
984  return;
985  }
986 
987  const DRWContextState *drwctx = DRW_context_state_get();
988  RegionView3D *rv3d = drwctx->rv3d;
989  const bool navigating = rv3d && (rv3d->rflag & RV3D_NAVIGATING);
990 
991  Paint *p = NULL;
992  if (drwctx->evil_C != NULL) {
994  }
995 
996  /* Frustum planes to show only visible PBVH nodes. */
997  float update_planes[6][4];
998  float draw_planes[6][4];
999  PBVHFrustumPlanes update_frustum;
1000  PBVHFrustumPlanes draw_frustum;
1001 
1002  if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) {
1003  update_frustum.planes = update_planes;
1004  update_frustum.num_planes = 6;
1005  BKE_pbvh_get_frustum_planes(pbvh, &update_frustum);
1006  if (!navigating) {
1007  drw_sculpt_get_frustum_planes(scd->ob, update_planes);
1008  update_frustum.planes = update_planes;
1009  update_frustum.num_planes = 6;
1010  BKE_pbvh_set_frustum_planes(pbvh, &update_frustum);
1011  }
1012  }
1013  else {
1014  drw_sculpt_get_frustum_planes(scd->ob, update_planes);
1015  update_frustum.planes = update_planes;
1016  update_frustum.num_planes = 6;
1017  }
1018 
1019  drw_sculpt_get_frustum_planes(scd->ob, draw_planes);
1020  draw_frustum.planes = draw_planes;
1021  draw_frustum.num_planes = 6;
1022 
1023  /* Fast mode to show low poly multires while navigating. */
1024  scd->fast_mode = false;
1025  if (p && (p->flags & PAINT_FAST_NAVIGATE)) {
1026  scd->fast_mode = rv3d && (rv3d->rflag & RV3D_NAVIGATING);
1027  }
1028 
1029  /* Update draw buffers only for visible nodes while painting.
1030  * But do update them otherwise so navigating stays smooth. */
1031  bool update_only_visible = rv3d && !(rv3d->rflag & RV3D_PAINTING);
1032  if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) {
1033  update_only_visible = true;
1034  }
1035 
1036  Mesh *mesh = scd->ob->data;
1038 
1039  BKE_pbvh_draw_cb(pbvh,
1040  update_only_visible,
1041  &update_frustum,
1042  &draw_frustum,
1043  (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb,
1044  scd);
1045 
1046  if (SCULPT_DEBUG_BUFFERS) {
1047  int debug_node_nr = 0;
1048  DRW_debug_modelmat(scd->ob->obmat);
1050  pbvh,
1051  (void (*)(
1052  void *d, const float min[3], const float max[3], PBVHNodeFlags f))sculpt_debug_cb,
1053  &debug_node_nr);
1054  }
1055 }
1056 
1057 void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask)
1058 {
1059  DRWSculptCallbackData scd = {
1060  .ob = ob,
1061  .shading_groups = &shgroup,
1062  .num_shading_groups = 1,
1063  .use_wire = use_wire,
1064  .use_mats = false,
1065  .use_mask = use_mask,
1066  };
1068 }
1069 
1071  int num_shgroups,
1072  Object *ob)
1073 {
1074  DRWSculptCallbackData scd = {
1075  .ob = ob,
1076  .shading_groups = shgroups,
1077  .num_shading_groups = num_shgroups,
1078  .use_wire = false,
1079  .use_mats = true,
1080  .use_mask = false,
1081  };
1083 }
1084 
1086 
1088  struct GPUVertFormat *format,
1089  GPUPrimType prim_type)
1090 {
1092  BLI_assert(format != NULL);
1093 
1095  callbuf->buf = DRW_temp_buffer_request(DST.idatalist, format, &callbuf->count);
1096  callbuf->buf_select = NULL;
1097  callbuf->count = 0;
1098 
1099  if (G.f & G_FLAG_PICKSEL) {
1100  /* Not actually used for rendering but alloced in one chunk. */
1101  if (inst_select_format.attr_len == 0) {
1103  }
1105  DST.idatalist, &inst_select_format, &callbuf->count);
1106  drw_command_set_select_id(shgroup, callbuf->buf_select, -1);
1107  }
1108 
1109  DRWResourceHandle handle = drw_resource_handle(shgroup, NULL, NULL);
1110  GPUBatch *batch = DRW_temp_batch_request(DST.idatalist, callbuf->buf, prim_type);
1111  drw_command_draw(shgroup, batch, handle);
1112 
1113  return callbuf;
1114 }
1115 
1117  struct GPUVertFormat *format,
1118  GPUBatch *geom)
1119 {
1120  BLI_assert(geom != NULL);
1121  BLI_assert(format != NULL);
1122 
1124  callbuf->buf = DRW_temp_buffer_request(DST.idatalist, format, &callbuf->count);
1125  callbuf->buf_select = NULL;
1126  callbuf->count = 0;
1127 
1128  if (G.f & G_FLAG_PICKSEL) {
1129  /* Not actually used for rendering but alloced in one chunk. */
1130  if (inst_select_format.attr_len == 0) {
1132  }
1134  DST.idatalist, &inst_select_format, &callbuf->count);
1135  drw_command_set_select_id(shgroup, callbuf->buf_select, -1);
1136  }
1137 
1138  DRWResourceHandle handle = drw_resource_handle(shgroup, NULL, NULL);
1140  drw_command_draw(shgroup, batch, handle);
1141 
1142  return callbuf;
1143 }
1144 
1146 {
1147  GPUVertBuf *buf = callbuf->buf;
1148  const bool resize = (callbuf->count == GPU_vertbuf_get_vertex_alloc(buf));
1149 
1150  if (UNLIKELY(resize)) {
1152  }
1153 
1154  GPU_vertbuf_vert_set(buf, callbuf->count, data);
1155 
1156  if (G.f & G_FLAG_PICKSEL) {
1157  if (UNLIKELY(resize)) {
1159  }
1160  GPU_vertbuf_attr_set(callbuf->buf_select, 0, callbuf->count, &DST.select_id);
1161  }
1162 
1163  callbuf->count++;
1164 }
1165 
1166 void DRW_buffer_add_entry_array(DRWCallBuffer *callbuf, const void *attr[], uint attr_len)
1167 {
1168  GPUVertBuf *buf = callbuf->buf;
1169  const bool resize = (callbuf->count == GPU_vertbuf_get_vertex_alloc(buf));
1170 
1171  BLI_assert(attr_len == GPU_vertbuf_get_format(buf)->attr_len);
1172  UNUSED_VARS_NDEBUG(attr_len);
1173 
1174  if (UNLIKELY(resize)) {
1176  }
1177 
1178  for (int i = 0; i < attr_len; i++) {
1179  GPU_vertbuf_attr_set(buf, i, callbuf->count, attr[i]);
1180  }
1181 
1182  if (G.f & G_FLAG_PICKSEL) {
1183  if (UNLIKELY(resize)) {
1185  }
1186  GPU_vertbuf_attr_set(callbuf->buf_select, 0, callbuf->count, &DST.select_id);
1187  }
1188 
1189  callbuf->count++;
1190 }
1191 
1194 /* -------------------------------------------------------------------- */
1199 {
1200  shgroup->uniforms = NULL;
1201  shgroup->uniform_attrs = NULL;
1202 
1204  int model_ubo_location = GPU_shader_get_builtin_block(shader, GPU_UNIFORM_BLOCK_MODEL);
1209 
1210  if (chunkid_location != -1) {
1212  shgroup, chunkid_location, DRW_UNIFORM_RESOURCE_CHUNK, NULL, 0, 0, 1);
1213  }
1214 
1215  if (resourceid_location != -1) {
1217  shgroup, resourceid_location, DRW_UNIFORM_RESOURCE_ID, NULL, 0, 0, 1);
1218  }
1219 
1220  if (baseinst_location != -1) {
1222  shgroup, baseinst_location, DRW_UNIFORM_BASE_INSTANCE, NULL, 0, 0, 1);
1223  }
1224 
1225  if (model_ubo_location != -1) {
1227  shgroup, model_ubo_location, DRW_UNIFORM_BLOCK_OBMATS, NULL, 0, 0, 1);
1228  }
1229  else {
1230  /* Note: This is only here to support old hardware fallback where uniform buffer is still
1231  * too slow or buggy. */
1234  if (model != -1) {
1235  drw_shgroup_uniform_create_ex(shgroup, model, DRW_UNIFORM_MODEL_MATRIX, NULL, 0, 0, 1);
1236  }
1237  if (modelinverse != -1) {
1239  shgroup, modelinverse, DRW_UNIFORM_MODEL_MATRIX_INVERSE, NULL, 0, 0, 1);
1240  }
1241  }
1242 
1243  if (info_ubo_location != -1) {
1245  shgroup, info_ubo_location, DRW_UNIFORM_BLOCK_OBINFOS, NULL, 0, 0, 1);
1246 
1247  /* Abusing this loc to tell shgroup we need the obinfos. */
1248  shgroup->objectinfo = 1;
1249  }
1250  else {
1251  shgroup->objectinfo = 0;
1252  }
1253 
1254  if (view_ubo_location != -1) {
1256  shgroup, view_ubo_location, DRW_UNIFORM_BLOCK, G_draw.view_ubo, 0, 0, 1);
1257  }
1258 
1259  /* Not supported. */
1271 }
1272 
1274 {
1276 
1277  BLI_LINKS_APPEND(&pass->shgroups, shgroup);
1278 
1279  shgroup->shader = shader;
1280  shgroup->cmd.first = NULL;
1281  shgroup->cmd.last = NULL;
1282  shgroup->pass_handle = pass->handle;
1283 
1284  return shgroup;
1285 }
1286 
1288 {
1289  if (!gpupass) {
1290  /* Shader compilation error */
1291  return NULL;
1292  }
1293 
1294  GPUShader *sh = GPU_pass_shader_get(gpupass);
1295 
1296  if (!sh) {
1297  /* Shader not yet compiled */
1298  return NULL;
1299  }
1300 
1301  DRWShadingGroup *grp = drw_shgroup_create_ex(sh, pass);
1302  return grp;
1303 }
1304 
1306  GPUTexture *gputex,
1307  const char *name,
1309 {
1310  DRW_shgroup_uniform_texture_ex(grp, name, gputex, state);
1311 
1312  GPUTexture **gputex_ref = BLI_memblock_alloc(DST.vmempool->images);
1313  *gputex_ref = gputex;
1314  GPU_texture_ref(gputex);
1315 }
1316 
1318 {
1320 
1321  /* Bind all textures needed by the material. */
1323  if (tex->ima) {
1324  /* Image */
1325  GPUTexture *gputex;
1326  if (tex->tiled_mapping_name[0]) {
1327  gputex = BKE_image_get_gpu_tiles(tex->ima, tex->iuser, NULL);
1328  drw_shgroup_material_texture(grp, gputex, tex->sampler_name, tex->sampler_state);
1330  drw_shgroup_material_texture(grp, gputex, tex->tiled_mapping_name, tex->sampler_state);
1331  }
1332  else {
1334  drw_shgroup_material_texture(grp, gputex, tex->sampler_name, tex->sampler_state);
1335  }
1336  }
1337  else if (tex->colorband) {
1338  /* Color Ramp */
1339  DRW_shgroup_uniform_texture(grp, tex->sampler_name, *tex->colorband);
1340  }
1341  }
1342 
1344  if (ubo != NULL) {
1346  }
1347 
1349  if (uattrs != NULL) {
1351  drw_shgroup_uniform_create_ex(grp, loc, DRW_UNIFORM_BLOCK_OBATTRS, uattrs, 0, 0, 1);
1352  grp->uniform_attrs = uattrs;
1353  }
1354 }
1355 
1357  int arraysize)
1358 {
1359  GPUVertFormat *format = MEM_callocN(sizeof(GPUVertFormat), "GPUVertFormat");
1360 
1361  for (int i = 0; i < arraysize; i++) {
1363  attrs[i].name,
1364  (attrs[i].type == DRW_ATTR_INT) ? GPU_COMP_I32 : GPU_COMP_F32,
1365  attrs[i].components,
1366  (attrs[i].type == DRW_ATTR_INT) ? GPU_FETCH_INT : GPU_FETCH_FLOAT);
1367  }
1368  return format;
1369 }
1370 
1372 {
1374  DRWShadingGroup *shgroup = drw_shgroup_material_create_ex(gpupass, pass);
1375 
1376  if (shgroup) {
1377  drw_shgroup_init(shgroup, GPU_pass_shader_get(gpupass));
1379  }
1380  return shgroup;
1381 }
1382 
1384 {
1385  DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
1386  drw_shgroup_init(shgroup, shader);
1387  return shgroup;
1388 }
1389 
1391  DRWPass *pass,
1392  GPUVertBuf *tf_target)
1393 {
1394  BLI_assert(tf_target != NULL);
1395  DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
1396  drw_shgroup_init(shgroup, shader);
1397  drw_shgroup_uniform_create_ex(shgroup, 0, DRW_UNIFORM_TFEEDBACK_TARGET, tf_target, 0, 0, 1);
1398  return shgroup;
1399 }
1400 
1406 {
1407  drw_command_set_mutable_state(shgroup, state, 0x0);
1408 }
1409 
1411 {
1412  drw_command_set_mutable_state(shgroup, 0x0, state);
1413 }
1414 
1416  uint write_mask,
1417  uint reference,
1418  uint compare_mask)
1419 {
1420  drw_command_set_stencil_mask(shgroup, write_mask, reference, compare_mask);
1421 }
1422 
1423 /* TODO remove this function. */
1425 {
1426  drw_command_set_stencil_mask(shgroup, 0xFF, mask, 0xFF);
1427 }
1428 
1430  eGPUFrameBufferBits channels,
1431  uchar r,
1432  uchar g,
1433  uchar b,
1434  uchar a,
1435  float depth,
1436  uchar stencil)
1437 {
1438  drw_command_clear(shgroup, channels, r, g, b, a, depth, stencil);
1439 }
1440 
1442 {
1443  DRWCommandChunk *chunk = shgroup->cmd.first;
1444  for (; chunk; chunk = chunk->next) {
1445  for (int i = 0; i < chunk->command_used; i++) {
1447  return false;
1448  }
1449  }
1450  }
1451  return true;
1452 }
1453 
1455 {
1457 
1458  *shgroup_new = *shgroup;
1459  drw_shgroup_init(shgroup_new, shgroup_new->shader);
1460  shgroup_new->cmd.first = NULL;
1461  shgroup_new->cmd.last = NULL;
1462 
1464  &shgroup->pass_handle);
1465 
1466  BLI_LINKS_INSERT_AFTER(&parent_pass->shgroups, shgroup, shgroup_new);
1467 
1468  return shgroup_new;
1469 }
1470 
1473 /* -------------------------------------------------------------------- */
1477 /* Extract the 8 corners from a Projection Matrix.
1478  * Although less accurate, this solution can be simplified as follows:
1479  * BKE_boundbox_init_from_minmax(&bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const
1480  * float[3]){1.0f, 1.0f, 1.0f}); for (int i = 0; i < 8; i++) {mul_project_m4_v3(projinv,
1481  * bbox.vec[i]);}
1482  */
1483 static void draw_frustum_boundbox_calc(const float (*viewinv)[4],
1484  const float (*projmat)[4],
1485  BoundBox *r_bbox)
1486 {
1487  float left, right, bottom, top, near, far;
1488  bool is_persp = projmat[3][3] == 0.0f;
1489 
1490 #if 0 /* Equivalent to this but it has accuracy problems. */
1492  &bbox, (const float[3]){-1.0f, -1.0f, -1.0f}, (const float[3]){1.0f, 1.0f, 1.0f});
1493  for (int i = 0; i < 8; i++) {
1494  mul_project_m4_v3(projinv, bbox.vec[i]);
1495  }
1496 #endif
1497 
1498  projmat_dimensions(projmat, &left, &right, &bottom, &top, &near, &far);
1499 
1500  if (is_persp) {
1501  left *= near;
1502  right *= near;
1503  bottom *= near;
1504  top *= near;
1505  }
1506 
1507  r_bbox->vec[0][2] = r_bbox->vec[3][2] = r_bbox->vec[7][2] = r_bbox->vec[4][2] = -near;
1508  r_bbox->vec[0][0] = r_bbox->vec[3][0] = left;
1509  r_bbox->vec[4][0] = r_bbox->vec[7][0] = right;
1510  r_bbox->vec[0][1] = r_bbox->vec[4][1] = bottom;
1511  r_bbox->vec[7][1] = r_bbox->vec[3][1] = top;
1512 
1513  /* Get the coordinates of the far plane. */
1514  if (is_persp) {
1515  float sca_far = far / near;
1516  left *= sca_far;
1517  right *= sca_far;
1518  bottom *= sca_far;
1519  top *= sca_far;
1520  }
1521 
1522  r_bbox->vec[1][2] = r_bbox->vec[2][2] = r_bbox->vec[6][2] = r_bbox->vec[5][2] = -far;
1523  r_bbox->vec[1][0] = r_bbox->vec[2][0] = left;
1524  r_bbox->vec[6][0] = r_bbox->vec[5][0] = right;
1525  r_bbox->vec[1][1] = r_bbox->vec[5][1] = bottom;
1526  r_bbox->vec[2][1] = r_bbox->vec[6][1] = top;
1527 
1528  /* Transform into world space. */
1529  for (int i = 0; i < 8; i++) {
1530  mul_m4_v3(viewinv, r_bbox->vec[i]);
1531  }
1532 }
1533 
1534 static void draw_frustum_culling_planes_calc(const float (*persmat)[4], float (*frustum_planes)[4])
1535 {
1536  planes_from_projmat(persmat,
1537  frustum_planes[0],
1538  frustum_planes[5],
1539  frustum_planes[3],
1540  frustum_planes[1],
1541  frustum_planes[4],
1542  frustum_planes[2]);
1543 
1544  /* Normalize. */
1545  for (int p = 0; p < 6; p++) {
1546  frustum_planes[p][3] /= normalize_v3(frustum_planes[p]);
1547  }
1548 }
1549 
1551  const float (*viewinv)[4],
1552  const float (*projmat)[4],
1553  const float (*projinv)[4],
1554  BoundSphere *bsphere)
1555 {
1556  /* Extract Bounding Sphere */
1557  if (projmat[3][3] != 0.0f) {
1558  /* Orthographic */
1559  /* The most extreme points on the near and far plane. (normalized device coords). */
1560  const float *nearpoint = bbox->vec[0];
1561  const float *farpoint = bbox->vec[6];
1562 
1563  /* just use median point */
1564  mid_v3_v3v3(bsphere->center, farpoint, nearpoint);
1565  bsphere->radius = len_v3v3(bsphere->center, farpoint);
1566  }
1567  else if (projmat[2][0] == 0.0f && projmat[2][1] == 0.0f) {
1568  /* Perspective with symmetrical frustum. */
1569 
1570  /* We obtain the center and radius of the circumscribed circle of the
1571  * isosceles trapezoid composed by the diagonals of the near and far clipping plane */
1572 
1573  /* center of each clipping plane */
1574  float mid_min[3], mid_max[3];
1575  mid_v3_v3v3(mid_min, bbox->vec[3], bbox->vec[4]);
1576  mid_v3_v3v3(mid_max, bbox->vec[2], bbox->vec[5]);
1577 
1578  /* square length of the diagonals of each clipping plane */
1579  float a_sq = len_squared_v3v3(bbox->vec[3], bbox->vec[4]);
1580  float b_sq = len_squared_v3v3(bbox->vec[2], bbox->vec[5]);
1581 
1582  /* distance squared between clipping planes */
1583  float h_sq = len_squared_v3v3(mid_min, mid_max);
1584 
1585  float fac = (4 * h_sq + b_sq - a_sq) / (8 * h_sq);
1586 
1587  /* The goal is to get the smallest sphere,
1588  * not the sphere that passes through each corner */
1589  CLAMP(fac, 0.0f, 1.0f);
1590 
1591  interp_v3_v3v3(bsphere->center, mid_min, mid_max, fac);
1592 
1593  /* distance from the center to one of the points of the far plane (1, 2, 5, 6) */
1594  bsphere->radius = len_v3v3(bsphere->center, bbox->vec[1]);
1595  }
1596  else {
1597  /* Perspective with asymmetrical frustum. */
1598 
1599  /* We put the sphere center on the line that goes from origin
1600  * to the center of the far clipping plane. */
1601 
1602  /* Detect which of the corner of the far clipping plane is the farthest to the origin */
1603  float nfar[4]; /* most extreme far point in NDC space */
1604  float farxy[2]; /* far-point projection onto the near plane */
1605  float farpoint[3] = {0.0f}; /* most extreme far point in camera coordinate */
1606  float nearpoint[3]; /* most extreme near point in camera coordinate */
1607  float farcenter[3] = {0.0f}; /* center of far clipping plane in camera coordinate */
1608  float F = -1.0f, N; /* square distance of far and near point to origin */
1609  float f, n; /* distance of far and near point to z axis. f is always > 0 but n can be < 0 */
1610  float e, s; /* far and near clipping distance (<0) */
1611  float c; /* slope of center line = distance of far clipping center
1612  * to z axis / far clipping distance. */
1613  float z; /* projection of sphere center on z axis (<0) */
1614 
1615  /* Find farthest corner and center of far clip plane. */
1616  float corner[3] = {1.0f, 1.0f, 1.0f}; /* in clip space */
1617  for (int i = 0; i < 4; i++) {
1618  float point[3];
1619  mul_v3_project_m4_v3(point, projinv, corner);
1620  float len = len_squared_v3(point);
1621  if (len > F) {
1622  copy_v3_v3(nfar, corner);
1623  copy_v3_v3(farpoint, point);
1624  F = len;
1625  }
1626  add_v3_v3(farcenter, point);
1627  /* rotate by 90 degree to walk through the 4 points of the far clip plane */
1628  float tmp = corner[0];
1629  corner[0] = -corner[1];
1630  corner[1] = tmp;
1631  }
1632 
1633  /* the far center is the average of the far clipping points */
1634  mul_v3_fl(farcenter, 0.25f);
1635  /* the extreme near point is the opposite point on the near clipping plane */
1636  copy_v3_fl3(nfar, -nfar[0], -nfar[1], -1.0f);
1637  mul_v3_project_m4_v3(nearpoint, projinv, nfar);
1638  /* this is a frustum projection */
1639  N = len_squared_v3(nearpoint);
1640  e = farpoint[2];
1641  s = nearpoint[2];
1642  /* distance to view Z axis */
1643  f = len_v2(farpoint);
1644  /* get corresponding point on the near plane */
1645  mul_v2_v2fl(farxy, farpoint, s / e);
1646  /* this formula preserve the sign of n */
1647  sub_v2_v2(nearpoint, farxy);
1648  n = f * s / e - len_v2(nearpoint);
1649  c = len_v2(farcenter) / e;
1650  /* the big formula, it simplifies to (F-N)/(2(e-s)) for the symmetric case */
1651  z = (F - N) / (2.0f * (e - s + c * (f - n)));
1652 
1653  bsphere->center[0] = farcenter[0] * z / e;
1654  bsphere->center[1] = farcenter[1] * z / e;
1655  bsphere->center[2] = z;
1656  bsphere->radius = len_v3v3(bsphere->center, farpoint);
1657 
1658  /* Transform to world space. */
1659  mul_m4_v3(viewinv, bsphere->center);
1660  }
1661 }
1662 
1664  const float viewmat[4][4],
1665  const float winmat[4][4])
1666 {
1667  copy_m4_m4(storage->viewmat, viewmat);
1668  invert_m4_m4(storage->viewinv, storage->viewmat);
1669 
1670  copy_m4_m4(storage->winmat, winmat);
1671  invert_m4_m4(storage->wininv, storage->winmat);
1672 
1673  mul_m4_m4m4(storage->persmat, winmat, viewmat);
1674  invert_m4_m4(storage->persinv, storage->persmat);
1675 
1676  const bool is_persp = (winmat[3][3] == 0.0f);
1677 
1678  /* Near clip distance. */
1679  storage->viewvecs[0][3] = (is_persp) ? -winmat[3][2] / (winmat[2][2] - 1.0f) :
1680  -(winmat[3][2] + 1.0f) / winmat[2][2];
1681 
1682  /* Far clip distance. */
1683  storage->viewvecs[1][3] = (is_persp) ? -winmat[3][2] / (winmat[2][2] + 1.0f) :
1684  -(winmat[3][2] - 1.0f) / winmat[2][2];
1685 
1686  /* view vectors for the corners of the view frustum.
1687  * Can be used to recreate the world space position easily */
1688  float view_vecs[4][3] = {
1689  {-1.0f, -1.0f, -1.0f},
1690  {1.0f, -1.0f, -1.0f},
1691  {-1.0f, 1.0f, -1.0f},
1692  {-1.0f, -1.0f, 1.0f},
1693  };
1694 
1695  /* convert the view vectors to view space */
1696  for (int i = 0; i < 4; i++) {
1697  mul_project_m4_v3(storage->wininv, view_vecs[i]);
1698  /* normalized trick see:
1699  * http://www.derschmale.com/2014/01/26/reconstructing-positions-from-the-depth-buffer */
1700  if (is_persp) {
1701  /* Divide XY by Z. */
1702  mul_v2_fl(view_vecs[i], 1.0f / view_vecs[i][2]);
1703  }
1704  }
1705 
1715  copy_v3_v3(storage->viewvecs[0], view_vecs[0]);
1716 
1717  /* we need to store the differences */
1718  storage->viewvecs[1][0] = view_vecs[1][0] - view_vecs[0][0];
1719  storage->viewvecs[1][1] = view_vecs[2][1] - view_vecs[0][1];
1720  storage->viewvecs[1][2] = view_vecs[3][2] - view_vecs[0][2];
1721 }
1722 
1723 /* Create a view with culling. */
1724 DRWView *DRW_view_create(const float viewmat[4][4],
1725  const float winmat[4][4],
1726  const float (*culling_viewmat)[4],
1727  const float (*culling_winmat)[4],
1728  DRWCallVisibilityFn *visibility_fn)
1729 {
1731 
1733  view->culling_mask = 1u << DST.primary_view_ct++;
1734  }
1735  else {
1736  BLI_assert(0);
1737  view->culling_mask = 0u;
1738  }
1739  view->clip_planes_len = 0;
1740  view->visibility_fn = visibility_fn;
1741  view->parent = NULL;
1742 
1743  copy_v4_fl4(view->storage.viewcamtexcofac, 1.0f, 1.0f, 0.0f, 0.0f);
1744 
1745  DRW_view_update(view, viewmat, winmat, culling_viewmat, culling_winmat);
1746 
1747  return view;
1748 }
1749 
1750 /* Create a view with culling done by another view. */
1752  const float viewmat[4][4],
1753  const float winmat[4][4])
1754 {
1755  /* Search original parent. */
1756  const DRWView *ori_view = parent_view;
1757  while (ori_view->parent != NULL) {
1758  ori_view = ori_view->parent;
1759  }
1760 
1762 
1763  /* Perform copy. */
1764  *view = *ori_view;
1765  view->parent = (DRWView *)ori_view;
1766 
1767  DRW_view_update_sub(view, viewmat, winmat);
1768 
1769  return view;
1770 }
1771 
1778 /* Update matrices of a view created with DRW_view_create_sub. */
1779 void DRW_view_update_sub(DRWView *view, const float viewmat[4][4], const float winmat[4][4])
1780 {
1781  BLI_assert(view->parent != NULL);
1782 
1783  view->is_dirty = true;
1784  view->is_inverted = (is_negative_m4(viewmat) == is_negative_m4(winmat));
1785 
1786  draw_view_matrix_state_update(&view->storage, viewmat, winmat);
1787 }
1788 
1789 /* Update matrices of a view created with DRW_view_create. */
1791  const float viewmat[4][4],
1792  const float winmat[4][4],
1793  const float (*culling_viewmat)[4],
1794  const float (*culling_winmat)[4])
1795 {
1796  /* DO NOT UPDATE THE DEFAULT VIEW.
1797  * Create sub-views instead, or a copy. */
1799  BLI_assert(view->parent == NULL);
1800 
1801  view->is_dirty = true;
1802  view->is_inverted = (is_negative_m4(viewmat) == is_negative_m4(winmat));
1803 
1804  draw_view_matrix_state_update(&view->storage, viewmat, winmat);
1805 
1806  /* Prepare frustum culling. */
1807 
1808 #ifdef DRW_DEBUG_CULLING
1809  static float mv[MAX_CULLED_VIEWS][4][4], mw[MAX_CULLED_VIEWS][4][4];
1810 
1811  /* Select view here. */
1812  if (view->culling_mask != 0) {
1813  uint index = bitscan_forward_uint(view->culling_mask);
1814 
1815  if (G.debug_value == 0) {
1816  copy_m4_m4(mv[index], culling_viewmat ? culling_viewmat : viewmat);
1817  copy_m4_m4(mw[index], culling_winmat ? culling_winmat : winmat);
1818  }
1819  else {
1820  culling_winmat = mw[index];
1821  culling_viewmat = mv[index];
1822  }
1823  }
1824 #endif
1825 
1826  float wininv[4][4];
1827  if (culling_winmat) {
1828  winmat = culling_winmat;
1829  invert_m4_m4(wininv, winmat);
1830  }
1831  else {
1832  copy_m4_m4(wininv, view->storage.wininv);
1833  }
1834 
1835  float viewinv[4][4];
1836  if (culling_viewmat) {
1837  viewmat = culling_viewmat;
1838  invert_m4_m4(viewinv, viewmat);
1839  }
1840  else {
1841  copy_m4_m4(viewinv, view->storage.viewinv);
1842  }
1843 
1844  draw_frustum_boundbox_calc(viewinv, winmat, &view->frustum_corners);
1845  draw_frustum_culling_planes_calc(view->storage.persmat, view->frustum_planes);
1847  &view->frustum_corners, viewinv, winmat, wininv, &view->frustum_bsphere);
1848 
1849 #ifdef DRW_DEBUG_CULLING
1850  if (G.debug_value != 0) {
1852  view->frustum_bsphere.center, view->frustum_bsphere.radius, (const float[4]){1, 1, 0, 1});
1853  DRW_debug_bbox(&view->frustum_corners, (const float[4]){1, 1, 0, 1});
1854  }
1855 #endif
1856 }
1857 
1858 /* Return default view if it is a viewport render. */
1860 {
1861  return DST.view_default;
1862 }
1863 
1864 /* WARNING: Only use in render AND only if you are going to set view_default again. */
1865 void DRW_view_reset(void)
1866 {
1867  DST.view_default = NULL;
1868  DST.view_active = NULL;
1870 }
1871 
1872 /* MUST only be called once per render and only in render mode. Sets default view. */
1874 {
1876  DST.view_default = view;
1877 }
1878 
1884 void DRW_view_clip_planes_set(DRWView *view, float (*planes)[4], int plane_len)
1885 {
1886  BLI_assert(plane_len <= MAX_CLIP_PLANES);
1887  view->clip_planes_len = plane_len;
1888  if (plane_len > 0) {
1889  memcpy(view->storage.clipplanes, planes, sizeof(float[4]) * plane_len);
1890  }
1891 }
1892 
1893 void DRW_view_camtexco_set(DRWView *view, float texco[4])
1894 {
1895  copy_v4_v4(view->storage.viewcamtexcofac, texco);
1896 }
1897 
1898 /* Return world space frustum corners. */
1900 {
1901  memcpy(corners, &view->frustum_corners, sizeof(view->frustum_corners));
1902 }
1903 
1904 /* Return world space frustum sides as planes.
1905  * See draw_frustum_culling_planes_calc() for the plane order. */
1906 void DRW_view_frustum_planes_get(const DRWView *view, float planes[6][4])
1907 {
1908  memcpy(planes, &view->frustum_planes, sizeof(view->frustum_planes));
1909 }
1910 
1912 {
1913  view = (view) ? view : DST.view_default;
1914  return view->storage.winmat[3][3] == 0.0f;
1915 }
1916 
1918 {
1919  view = (view) ? view : DST.view_default;
1920  const float(*projmat)[4] = view->storage.winmat;
1921 
1922  if (DRW_view_is_persp_get(view)) {
1923  return -projmat[3][2] / (projmat[2][2] - 1.0f);
1924  }
1925 
1926  return -(projmat[3][2] + 1.0f) / projmat[2][2];
1927 }
1928 
1930 {
1931  view = (view) ? view : DST.view_default;
1932  const float(*projmat)[4] = view->storage.winmat;
1933 
1934  if (DRW_view_is_persp_get(view)) {
1935  return -projmat[3][2] / (projmat[2][2] + 1.0f);
1936  }
1937 
1938  return -(projmat[3][2] - 1.0f) / projmat[2][2];
1939 }
1940 
1941 void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
1942 {
1943  view = (view) ? view : DST.view_default;
1944  const DRWViewUboStorage *storage = &view->storage;
1945  copy_m4_m4(mat, (inverse) ? storage->viewinv : storage->viewmat);
1946 }
1947 
1948 void DRW_view_winmat_get(const DRWView *view, float mat[4][4], bool inverse)
1949 {
1950  view = (view) ? view : DST.view_default;
1951  const DRWViewUboStorage *storage = &view->storage;
1952  copy_m4_m4(mat, (inverse) ? storage->wininv : storage->winmat);
1953 }
1954 
1955 void DRW_view_persmat_get(const DRWView *view, float mat[4][4], bool inverse)
1956 {
1957  view = (view) ? view : DST.view_default;
1958  const DRWViewUboStorage *storage = &view->storage;
1959  copy_m4_m4(mat, (inverse) ? storage->persinv : storage->persmat);
1960 }
1961 
1964 /* -------------------------------------------------------------------- */
1969 {
1972  if (G.debug & G_DEBUG_GPU) {
1973  BLI_strncpy(pass->name, name, MAX_PASS_NAME);
1974  }
1975 
1976  pass->shgroups.first = NULL;
1977  pass->shgroups.last = NULL;
1978  pass->handle = DST.pass_handle;
1980 
1981  pass->original = NULL;
1982  pass->next = NULL;
1983 
1984  return pass;
1985 }
1986 
1987 /* Create an instance of the original pass that will execute the same drawcalls but with its own
1988  * DRWState. */
1990 {
1991  DRWPass *pass = DRW_pass_create(name, state);
1992  pass->original = original;
1993 
1994  return pass;
1995 }
1996 
1997 /* Link two passes so that they are both rendered if the first one is being drawn. */
1998 void DRW_pass_link(DRWPass *first, DRWPass *second)
1999 {
2000  BLI_assert(first != second);
2001  BLI_assert(first->next == NULL);
2002  first->next = second;
2003 }
2004 
2006 {
2007  if (pass->original) {
2008  return DRW_pass_is_empty(pass->original);
2009  }
2010 
2011  LISTBASE_FOREACH (DRWShadingGroup *, shgroup, &pass->shgroups) {
2012  if (!DRW_shgroup_is_empty(shgroup)) {
2013  return false;
2014  }
2015  }
2016  return true;
2017 }
2018 
2020  void (*callback)(void *userData, DRWShadingGroup *shgrp),
2021  void *userData)
2022 {
2023  LISTBASE_FOREACH (DRWShadingGroup *, shgroup, &pass->shgroups) {
2024  callback(userData, shgroup);
2025  }
2026 }
2027 
2028 static int pass_shgroup_dist_sort(const void *a, const void *b)
2029 {
2030  const DRWShadingGroup *shgrp_a = (const DRWShadingGroup *)a;
2031  const DRWShadingGroup *shgrp_b = (const DRWShadingGroup *)b;
2032 
2033  if (shgrp_a->z_sorting.distance < shgrp_b->z_sorting.distance) {
2034  return 1;
2035  }
2036  if (shgrp_a->z_sorting.distance > shgrp_b->z_sorting.distance) {
2037  return -1;
2038  }
2039 
2040  /* If distances are the same, keep original order. */
2041  if (shgrp_a->z_sorting.original_index > shgrp_b->z_sorting.original_index) {
2042  return -1;
2043  }
2044 
2045  return 0;
2046 }
2047 
2048 /* ------------------ Shading group sorting --------------------- */
2049 
2050 #define SORT_IMPL_LINKTYPE DRWShadingGroup
2051 
2052 #define SORT_IMPL_FUNC shgroup_sort_fn_r
2053 #include "../../blenlib/intern/list_sort_impl.h"
2054 #undef SORT_IMPL_FUNC
2055 
2056 #undef SORT_IMPL_LINKTYPE
2057 
2063 {
2064  const float(*viewinv)[4] = DST.view_active->storage.viewinv;
2065 
2066  if (!(pass->shgroups.first && pass->shgroups.first->next)) {
2067  /* Nothing to sort */
2068  return;
2069  }
2070 
2071  uint index = 0;
2072  DRWShadingGroup *shgroup = pass->shgroups.first;
2073  do {
2074  DRWResourceHandle handle = 0;
2075  /* Find first DRWCommandDraw. */
2076  DRWCommandChunk *cmd_chunk = shgroup->cmd.first;
2077  for (; cmd_chunk && handle == 0; cmd_chunk = cmd_chunk->next) {
2078  for (int i = 0; i < cmd_chunk->command_used && handle == 0; i++) {
2079  if (DRW_CMD_DRAW == command_type_get(cmd_chunk->command_type, i)) {
2080  handle = cmd_chunk->commands[i].draw.handle;
2081  }
2082  }
2083  }
2084  /* To be sorted a shgroup needs to have at least one draw command. */
2085  /* FIXME(fclem) In some case, we can still have empty shading group to sort. However their
2086  * final order is not well defined.
2087  * (see T76730 & D7729). */
2088  // BLI_assert(handle != 0);
2089 
2091 
2092  /* Compute distance to camera. */
2093  float tmp[3];
2094  sub_v3_v3v3(tmp, viewinv[3], obmats->model[3]);
2095  shgroup->z_sorting.distance = dot_v3v3(viewinv[2], tmp);
2096  shgroup->z_sorting.original_index = index++;
2097 
2098  } while ((shgroup = shgroup->next));
2099 
2100  /* Sort using computed distances. */
2101  pass->shgroups.first = shgroup_sort_fn_r(pass->shgroups.first, pass_shgroup_dist_sort);
2102 
2103  /* Find the new last */
2104  DRWShadingGroup *last = pass->shgroups.first;
2105  while ((last = last->next)) {
2106  /* Reset the pass id for debugging. */
2107  last->pass_handle = pass->handle;
2108  }
2109  pass->shgroups.last = last;
2110 }
2111 
2116 {
2117  pass->shgroups.last = pass->shgroups.first;
2118  /* WARNING: Assume that DRWShadingGroup->next is the first member. */
2120 }
2121 
typedef float(TangentPoint)[2]
void BKE_curve_texspace_ensure(struct Curve *cu)
Definition: curve.c:554
@ G_DEBUG_GPU
Definition: BKE_global.h:151
@ G_FLAG_PICKSEL
Definition: BKE_global.h:111
struct GPUTexture * BKE_image_get_gpu_tiles(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.c:444
struct GPUTexture * BKE_image_get_gpu_texture(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.c:439
struct GPUTexture * BKE_image_get_gpu_tilemap(struct Image *image, struct ImageUser *iuser, struct ImBuf *ibuf)
Definition: image_gpu.c:449
void BKE_mesh_texspace_get_reference(struct Mesh *me, short **r_texflag, float **r_loc, float **r_size)
Definition: mesh.c:1135
General operations, lookup, etc. for blender objects.
void BKE_boundbox_init_from_minmax(struct BoundBox *bb, const float min[3], const float max[3])
Definition: object.c:3778
struct BoundBox * BKE_object_boundbox_get(struct Object *ob)
Definition: object.c:3817
struct Paint * BKE_paint_get_active_from_context(const struct bContext *C)
A BVH for high poly meshes.
void BKE_pbvh_set_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes)
Definition: pbvh.c:3026
void BKE_pbvh_get_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes)
Definition: pbvh.c:3034
void BKE_pbvh_draw_debug_cb(PBVH *pbvh, void(*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag), void *user_data)
Definition: pbvh.c:2752
void BKE_pbvh_update_normals(PBVH *pbvh, struct SubdivCCG *subdiv_ccg)
Definition: pbvh.c:2650
void BKE_pbvh_draw_cb(PBVH *pbvh, bool update_only_visible, PBVHFrustumPlanes *update_frustum, PBVHFrustumPlanes *draw_frustum, void(*draw_fn)(void *user_data, struct GPU_PBVH_Buffers *buffers), void *user_data)
PBVHNodeFlags
Definition: BKE_pbvh.h:63
@ PBVH_Leaf
Definition: BKE_pbvh.h:64
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_INLINE
BLI_INLINE unsigned int BLI_hash_string(const char *str)
Definition: BLI_hash.h:83
BLI_INLINE unsigned int BLI_hash_int_2d(unsigned int kx, unsigned int ky)
Definition: BLI_hash.h:67
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
MINLINE unsigned int bitscan_forward_uint(unsigned int a)
void projmat_dimensions(const float projmat[4][4], float *r_left, float *r_right, float *r_bottom, float *r_top, float *r_near, float *r_far)
Definition: math_geom.c:4964
void planes_from_projmat(const float mat[4][4], float left[4], float right[4], float top[4], float bottom[4], float near[4], float far[4])
Definition: math_geom.c:4911
void mul_project_m4_v3(const float M[4][4], float vec[3])
Definition: math_matrix.c:824
void mul_v3_project_m4_v3(float r[3], const float mat[4][4], const float vec[3])
Definition: math_matrix.c:835
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:262
void mul_m4_v4(const float M[4][4], float r[4])
Definition: math_matrix.c:866
void transpose_m4_m4(float R[4][4], const float M[4][4])
Definition: math_matrix.c:1384
bool invert_m4_m4(float R[4][4], const float A[4][4])
Definition: math_matrix.c:1278
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:732
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
bool is_negative_m4(const float mat[4][4])
Definition: math_matrix.c:2590
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:742
MINLINE void copy_v4_v4(float r[4], const float a[4])
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], const float t)
Definition: math_vector.c:49
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v4_fl4(float v[4], float x, float y, float z, float w)
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE float normalize_v3(float r[3])
MINLINE void mul_v3_v3(float r[3], const float a[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void negate_v3(float r[3])
MINLINE void invert_v3(float r[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
Definition: math_vector.c:270
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
void * BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_memblock.c:197
void BLI_memblock_iternew(BLI_memblock *mblk, BLI_memblock_iter *iter) ATTR_NONNULL()
Definition: BLI_memblock.c:163
void * BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_memblock.c:175
void * BLI_memblock_alloc(BLI_memblock *mblk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: BLI_memblock.c:133
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
#define UNLIKELY(x)
#define ELEM(...)
@ ID_ME
Definition: DNA_ID_enums.h:60
@ ID_MB
Definition: DNA_ID_enums.h:62
@ ID_CU
Definition: DNA_ID_enums.h:61
@ BASE_FROM_DUPLI
@ BASE_FROM_SET
@ BASE_SELECTED
@ OB_NEG_SCALE
@ PAINT_SCULPT_DELAY_UPDATES
@ PAINT_FAST_NAVIGATE
#define RV3D_PAINTING
#define RV3D_NAVIGATING
@ DRW_ATTR_INT
Definition: DRW_render.h:379
bool() DRWCallVisibilityFn(bool vis_in, void *user_data)
Definition: DRW_render.h:410
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
Definition: DRW_render.h:433
DRWState
Definition: DRW_render.h:312
@ DRW_STATE_PROGRAM_POINT_SIZE
Definition: DRW_render.h:357
static AppView * view
GPUBatch
Definition: GPU_batch.h:93
short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers)
Definition: gpu_buffers.c:1078
struct GPUBatch * GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast, bool wires)
Definition: gpu_buffers.c:1064
bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers)
Definition: gpu_buffers.c:1073
eGPUFrameBufferBits
_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 type
_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 right
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint * textures
_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 top
_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 bottom
GPUUniformAttrList * GPU_material_uniform_attributes(GPUMaterial *material)
Definition: gpu_material.c:587
ListBase GPU_material_textures(GPUMaterial *material)
Definition: gpu_material.c:577
struct GPUPass * GPU_material_get_pass(GPUMaterial *material)
Definition: gpu_material.c:207
struct GPUUniformBuf * GPU_material_uniform_buffer_get(GPUMaterial *material)
Definition: gpu_material.c:223
GPUPrimType
Definition: GPU_primitive.h:34
@ GPU_PRIM_TRI_FAN
Definition: GPU_primitive.h:41
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:35
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:551
struct GPUShader GPUShader
Definition: GPU_shader.h:33
int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
Definition: gpu_shader.cc:564
int GPU_shader_get_uniform_block_binding(GPUShader *shader, const char *name)
Definition: gpu_shader.cc:578
@ GPU_UNIFORM_VIEWPROJECTION_INV
Definition: GPU_shader.h:100
@ GPU_UNIFORM_PROJECTION
Definition: GPU_shader.h:92
@ GPU_UNIFORM_RESOURCE_ID
Definition: GPU_shader.h:109
@ GPU_UNIFORM_VIEWPROJECTION
Definition: GPU_shader.h:93
@ GPU_UNIFORM_VIEW
Definition: GPU_shader.h:90
@ GPU_UNIFORM_MODEL
Definition: GPU_shader.h:89
@ GPU_UNIFORM_MODELVIEW
Definition: GPU_shader.h:91
@ GPU_UNIFORM_BASE_INSTANCE
Definition: GPU_shader.h:107
@ GPU_UNIFORM_VIEW_INV
Definition: GPU_shader.h:97
@ GPU_UNIFORM_MODEL_INV
Definition: GPU_shader.h:96
@ GPU_UNIFORM_PROJECTION_INV
Definition: GPU_shader.h:99
@ GPU_UNIFORM_CLIPPLANES
Definition: GPU_shader.h:104
@ GPU_UNIFORM_MODELVIEW_INV
Definition: GPU_shader.h:98
@ GPU_UNIFORM_NORMAL
Definition: GPU_shader.h:102
@ GPU_UNIFORM_RESOURCE_CHUNK
Definition: GPU_shader.h:108
@ GPU_UNIFORM_MVP
Definition: GPU_shader.h:94
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_UNIFORM_BLOCK_MODEL
Definition: GPU_shader.h:117
@ GPU_UNIFORM_BLOCK_VIEW
Definition: GPU_shader.h:116
@ GPU_UNIFORM_BLOCK_INFO
Definition: GPU_shader.h:118
eGPUSamplerState
Definition: GPU_texture.h:40
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
void GPU_texture_ref(GPUTexture *tex)
Definition: gpu_texture.cc:522
static const int GPU_SAMPLER_MAX
Definition: GPU_texture.h:58
struct GPUUniformBuf GPUUniformBuf
#define GPU_UBO_BLOCK_NAME
#define GPU_uniformbuf_create(size)
void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data)
void GPU_uniformbuf_free(GPUUniformBuf *ubo)
#define GPU_ATTRIBUTE_UBO_BLOCK_NAME
uint GPU_vertbuf_get_vertex_alloc(const GPUVertBuf *verts)
const GPUVertFormat * GPU_vertbuf_get_format(const GPUVertBuf *verts)
void GPU_vertbuf_vert_set(GPUVertBuf *verts, uint v_idx, const void *data)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_attr_set(GPUVertBuf *, uint a_idx, uint v_idx, const void *data)
void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len)
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_I32
#define MEM_recallocN(vmemh, len)
Group RGB to Bright Vector Camera CLAMP
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
btMatrix3x3 inverse() const
Return the inverse of the matrix.
Definition: btTransform.h:182
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
Material material
void * user_data
DEGForeachIDComponentCallback callback
GPUBatch * drw_cache_procedural_points_get(void)
Definition: draw_cache.c:170
GPUBatch * drw_cache_procedural_triangles_get(void)
Definition: draw_cache.c:198
GPUBatch * drw_cache_procedural_lines_get(void)
Definition: draw_cache.c:184
struct DRW_Global G_draw
Definition: draw_common.c:45
void DRW_debug_modelmat(const float modelmat[4][4])
Definition: draw_debug.c:48
void DRW_debug_sphere(const float center[3], const float radius, const float color[4])
Definition: draw_debug.c:126
void DRW_debug_bbox(const BoundBox *bbox, const float color[4])
Definition: draw_debug.c:89
void DRW_uniform_attrs_pool_flush_all(GHash *table)
GPUVertBuf * DRW_temp_buffer_request(DRWInstanceDataList *idatalist, GPUVertFormat *format, int *vert_len)
GPUBatch * DRW_temp_batch_instance_request(DRWInstanceDataList *idatalist, GPUVertBuf *buf, GPUBatch *instancer, GPUBatch *geom)
void drw_uniform_attrs_pool_update(GHash *table, GPUUniformAttrList *key, DRWResourceHandle *handle, Object *ob, Object *dupli_parent, DupliObject *dupli_source)
GPUBatch * DRW_temp_batch_request(DRWInstanceDataList *idatalist, GPUVertBuf *buf, GPUPrimType prim_type)
#define DRW_BUFFER_VERTS_CHUNK
DRWManager DST
Definition: draw_manager.c:111
const DRWContextState * DRW_context_state_get(void)
#define DRW_MAX_DRAW_CMD_TYPE
Definition: draw_manager.h:198
DRWUniformType
Definition: draw_manager.h:277
@ DRW_UNIFORM_BLOCK_OBINFOS
Definition: draw_manager.h:291
@ DRW_UNIFORM_TFEEDBACK_TARGET
Definition: draw_manager.h:288
@ DRW_UNIFORM_TEXTURE_REF
Definition: draw_manager.h:283
@ DRW_UNIFORM_MODEL_MATRIX
Definition: draw_manager.h:297
@ DRW_UNIFORM_FLOAT_COPY
Definition: draw_manager.h:281
@ DRW_UNIFORM_MODEL_MATRIX_INVERSE
Definition: draw_manager.h:298
@ DRW_UNIFORM_FLOAT
Definition: draw_manager.h:280
@ DRW_UNIFORM_BASE_INSTANCE
Definition: draw_manager.h:296
@ DRW_UNIFORM_BLOCK_OBMATS
Definition: draw_manager.h:290
@ DRW_UNIFORM_IMAGE_REF
Definition: draw_manager.h:285
@ DRW_UNIFORM_RESOURCE_ID
Definition: draw_manager.h:294
@ DRW_UNIFORM_BLOCK
Definition: draw_manager.h:286
@ DRW_UNIFORM_TEXTURE
Definition: draw_manager.h:282
@ DRW_UNIFORM_RESOURCE_CHUNK
Definition: draw_manager.h:293
@ DRW_UNIFORM_IMAGE
Definition: draw_manager.h:284
@ DRW_UNIFORM_BLOCK_OBATTRS
Definition: draw_manager.h:292
@ DRW_UNIFORM_INT
Definition: draw_manager.h:278
@ DRW_UNIFORM_BLOCK_REF
Definition: draw_manager.h:287
@ DRW_UNIFORM_INT_COPY
Definition: draw_manager.h:279
BLI_INLINE uint32_t DRW_handle_chunk_get(const DRWResourceHandle *handle)
Definition: draw_manager.h:138
#define MAX_CLIP_PLANES
Definition: draw_manager.h:484
#define DRW_RESOURCE_CHUNK_LEN
Definition: draw_manager.h:115
BLI_INLINE void * DRW_memblock_elem_from_handle(struct BLI_memblock *memblock, const DRWResourceHandle *handle)
Definition: draw_manager.h:158
eDRWCommandType
Definition: draw_manager.h:183
@ DRW_CMD_DRAW
Definition: draw_manager.h:185
@ DRW_CMD_DRWSTATE
Definition: draw_manager.h:192
@ DRW_CMD_DRAW_RANGE
Definition: draw_manager.h:186
@ DRW_CMD_CLEAR
Definition: draw_manager.h:191
@ DRW_CMD_STENCIL
Definition: draw_manager.h:193
@ DRW_CMD_DRAW_INSTANCE_RANGE
Definition: draw_manager.h:188
@ DRW_CMD_DRAW_PROCEDURAL
Definition: draw_manager.h:189
@ DRW_CMD_SELECTID
Definition: draw_manager.h:194
@ DRW_CMD_DRAW_INSTANCE
Definition: draw_manager.h:187
#define MAX_CULLED_VIEWS
Definition: draw_manager.h:401
BLI_INLINE void DRW_handle_increment(DRWResourceHandle *handle)
Definition: draw_manager.h:148
BLI_INLINE uint32_t DRW_handle_id_get(const DRWResourceHandle *handle)
Definition: draw_manager.h:143
uint32_t DRWResourceHandle
Definition: draw_manager.h:131
#define MAX_PASS_NAME
Definition: draw_manager.h:362
BLI_INLINE void DRW_handle_negative_scale_enable(DRWResourceHandle *handle)
Definition: draw_manager.h:153
void DRW_view_frustum_corners_get(const DRWView *view, BoundBox *corners)
DRWShadingGroup * DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass)
float DRW_view_near_distance_get(const DRWView *view)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_call_ex(DRWShadingGroup *shgroup, Object *ob, float(*obmat)[4], struct GPUBatch *geom, bool bypass_culling, void *user_data)
static void drw_call_calc_orco(Object *ob, float(*r_orcofacs)[4])
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo)
void DRW_view_persmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state)
bool DRW_shgroup_is_empty(DRWShadingGroup *shgroup)
static void drw_shgroup_uniform_create_ex(DRWShadingGroup *shgroup, int loc, DRWUniformType type, const void *value, eGPUSamplerState sampler_state, int length, int arraysize)
static void drw_command_draw_range(DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint start, uint count)
void DRW_view_frustum_planes_get(const DRWView *view, float planes[6][4])
void DRW_shgroup_uniform_vec4(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
eDRWCommandType command_type_get(const uint64_t *command_type_bits, int index)
static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommandType type)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_uniform_ivec3_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
static int pass_shgroup_dist_sort(const void *a, const void *b)
static DRWResourceHandle drw_resource_handle(DRWShadingGroup *shgroup, float(*obmat)[4], Object *ob)
void DRW_shgroup_call_procedural_lines(DRWShadingGroup *shgroup, Object *ob, uint line_count)
struct DRWSculptCallbackData DRWSculptCallbackData
const DRWView * DRW_view_default_get(void)
void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint count)
void DRW_shgroup_call_instance_range(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint i_sta, uint i_ct)
void DRW_buffer_add_entry_struct(DRWCallBuffer *callbuf, const void *data)
void DRW_shgroup_stencil_set(DRWShadingGroup *shgroup, uint write_mask, uint reference, uint compare_mask)
void DRW_buffer_add_entry_array(DRWCallBuffer *callbuf, const void *attr[], uint attr_len)
static void draw_call_sort(DRWCommand *array, DRWCommand *array_tmp, int array_len)
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state)
void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup, const char *name, GPUUniformBuf **ubo)
void DRW_shgroup_uniform_ivec2_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
void DRW_pass_link(DRWPass *first, DRWPass *second)
void DRW_shgroup_uniform_vec3_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
bool DRW_view_is_persp_get(const DRWView *view)
DRWCallBuffer * DRW_shgroup_call_buffer_instance(DRWShadingGroup *shgroup, struct GPUVertFormat *format, GPUBatch *geom)
DRWPass * DRW_pass_create_instance(const char *name, DRWPass *original, DRWState state)
void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, struct GPUBatch *inst_attributes)
void DRW_shgroup_uniform_texture_ref_ex(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex, eGPUSamplerState sampler_state)
static void drw_call_culling_init(DRWCullingState *cull, Object *ob)
static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers)
void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup, Object *ob, uint point_count)
static void drw_command_set_mutable_state(DRWShadingGroup *shgroup, DRWState enable, DRWState disable)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tri_count)
void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
void DRW_shgroup_uniform_vec4_array_copy(DRWShadingGroup *shgroup, const char *name, const float(*value)[4], int arraysize)
void DRW_view_winmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
static void drw_shgroup_material_texture(DRWShadingGroup *grp, GPUTexture *gputex, const char *name, eGPUSamplerState state)
void DRW_pass_sort_shgroup_z(DRWPass *pass)
bool DRW_pass_is_empty(DRWPass *pass)
#define SCULPT_DEBUG_BUFFERS
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float(*value)[3])
DRWView * DRW_view_create(const float viewmat[4][4], const float winmat[4][4], const float(*culling_viewmat)[4], const float(*culling_winmat)[4], DRWCallVisibilityFn *visibility_fn)
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask)
static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
void DRW_shgroup_uniform_texture_ex(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex, eGPUSamplerState sampler_state)
GPUVertFormat * DRW_shgroup_instance_format_array(const DRWInstanceAttrFormat attrs[], int arraysize)
DRWView * DRW_view_create_sub(const DRWView *parent_view, const float viewmat[4][4], const float winmat[4][4])
void DRW_view_update(DRWView *view, const float viewmat[4][4], const float winmat[4][4], const float(*culling_viewmat)[4], const float(*culling_winmat)[4])
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
BLI_INLINE void drw_call_matrix_init(DRWObjectMatrix *ob_mats, Object *ob, float(*obmat)[4])
static float sculpt_debug_colors[9][4]
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
static void drw_command_set_stencil_mask(DRWShadingGroup *shgroup, uint write_mask, uint reference, uint compare_mask)
DRWCallBuffer * DRW_shgroup_call_buffer(DRWShadingGroup *shgroup, struct GPUVertFormat *format, GPUPrimType prim_type)
static void drw_command_draw_instance(DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint count, bool use_attr)
static void draw_view_matrix_state_update(DRWViewUboStorage *storage, const float viewmat[4][4], const float winmat[4][4])
static void * drw_command_create(DRWShadingGroup *shgroup, eDRWCommandType type)
static void drw_shgroup_uniform(DRWShadingGroup *shgroup, const char *name, DRWUniformType type, const void *value, int length, int arraysize)
DRWShadingGroup * DRW_shgroup_transform_feedback_create(struct GPUShader *shader, DRWPass *pass, GPUVertBuf *tf_target)
void DRW_shgroup_uniform_ivec4(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
float DRW_view_far_distance_get(const DRWView *view)
void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial *material)
uint32_t DRW_object_resource_id_get(Object *UNUSED(ob))
void DRW_view_clip_planes_set(DRWView *view, float(*planes)[4], int plane_len)
void DRW_view_default_set(DRWView *view)
static void drw_command_draw_procedural(DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint vert_count)
void DRW_pass_foreach_shgroup(DRWPass *pass, void(*callback)(void *userData, DRWShadingGroup *shgrp), void *userData)
static GPUVertFormat inst_select_format
static void drw_command_draw(DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
static void drw_command_set_select_id(DRWShadingGroup *shgroup, GPUVertBuf *buf, uint select_id)
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
DRWPass * DRW_pass_create(const char *name, DRWState state)
static DRWShadingGroup * drw_shgroup_material_create_ex(GPUPass *gpupass, DRWPass *pass)
void DRW_shgroup_clear_framebuffer(DRWShadingGroup *shgroup, eGPUFrameBufferBits channels, uchar r, uchar g, uchar b, uchar a, float depth, uchar stencil)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
static DRWShadingGroup * drw_shgroup_create_ex(struct GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float(*value)[4])
void DRW_shgroup_uniform_image_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
void DRW_shgroup_call_range(DRWShadingGroup *shgroup, struct Object *ob, GPUBatch *geom, uint v_sta, uint v_ct)
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
static void draw_frustum_culling_planes_calc(const float(*persmat)[4], float(*frustum_planes)[4])
void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, int num_shgroups, Object *ob)
static void draw_frustum_boundbox_calc(const float(*viewinv)[4], const float(*projmat)[4], BoundBox *r_bbox)
void DRW_shgroup_uniform_vec2_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
static void sculpt_debug_cb(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag)
static void draw_frustum_bound_sphere_calc(const BoundBox *bbox, const float(*viewinv)[4], const float(*projmat)[4], const float(*projinv)[4], BoundSphere *bsphere)
static void drw_shgroup_call_procedural_add_ex(DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, uint vert_count)
static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
void DRW_pass_sort_shgroup_reverse(DRWPass *pass)
void DRW_view_update_sub(DRWView *view, const float viewmat[4][4], const float winmat[4][4])
void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_shgroup_uniform_image(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
static DRWResourceHandle drw_resource_handle_new(float(*obmat)[4], Object *ob)
void DRW_shgroup_uniform_ivec4_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
void DRW_view_camtexco_set(DRWView *view, float texco[4])
void DRW_shgroup_stencil_mask(DRWShadingGroup *shgroup, uint mask)
static void drw_command_draw_intance_range(DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint start, uint count)
#define KEY(a)
static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
static void drw_sculpt_get_frustum_planes(Object *ob, float planes[6][4])
void DRW_view_reset(void)
static void drw_command_clear(DRWShadingGroup *shgroup, eGPUFrameBufferBits channels, uchar r, uchar g, uchar b, uchar a, float depth, uchar stencil)
#define SCULPT_DEBUG_COLOR(id)
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
void drw_resource_buffer_finish(ViewportMemoryPool *vmempool)
GPUBatch * batch
Definition: drawnode.c:3779
IMETHOD void random(Vector &a)
addDelta operator for displacement rotational velocity.
Definition: frames.inl:1282
GPUShader * GPU_pass_shader_get(GPUPass *pass)
Definition: gpu_codegen.c:826
int count
#define GS(x)
Definition: iris.c:241
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
format
Definition: logImageCore.h:47
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN_aligned)(size_t len, size_t alignment, const char *str)
Definition: mallocn.c:49
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static ulong state[N]
static int left
#define F
static unsigned c
Definition: RandGen.cpp:97
static unsigned a[3]
Definition: RandGen.cpp:92
params N
#define min(a, b)
Definition: sort.c:51
unsigned int uint32_t
Definition: stdint.h:83
unsigned __int64 uint64_t
Definition: stdint.h:93
float vec[8][3]
float center[3]
Definition: DRW_render.h:87
float radius
Definition: DRW_render.h:87
float loc[3]
float size[3]
GPUVertBuf * buf_select
Definition: draw_manager.h:272
GPUVertBuf * buf
Definition: draw_manager.h:271
struct DRWCommandChunk * next
Definition: draw_manager.h:442
uint32_t command_len
Definition: draw_manager.h:443
uint32_t command_used
Definition: draw_manager.h:444
DRWCommand commands[96]
Definition: draw_manager.h:448
uint64_t command_type[6]
Definition: draw_manager.h:446
eGPUFrameBufferBits clear_channels
Definition: draw_manager.h:251
DRWResourceHandle handle
Definition: draw_manager.h:222
DRWResourceHandle handle
Definition: draw_manager.h:215
DRWResourceHandle handle
Definition: draw_manager.h:229
DRWResourceHandle handle
Definition: draw_manager.h:208
GPUBatch * batch
Definition: draw_manager.h:201
DRWResourceHandle handle
Definition: draw_manager.h:202
GPUVertBuf * select_buf
Definition: draw_manager.h:246
DRWCommand commands[6]
Definition: draw_manager.h:459
uint64_t command_type[6]
Definition: draw_manager.h:458
struct Object * obact
Definition: DRW_render.h:749
const struct bContext * evil_C
Definition: DRW_render.h:763
struct RegionView3D * rv3d
Definition: DRW_render.h:741
BoundSphere bsphere
Definition: draw_manager.h:106
uint select_id
Definition: draw_manager.h:559
struct DupliObject * dupli_source
Definition: draw_manager.h:502
DRWResourceHandle ob_handle
Definition: draw_manager.h:493
DRWResourceHandle pass_handle
Definition: draw_manager.h:499
DRWView * view_active
Definition: draw_manager.h:551
DRWContextState draw_ctx
Definition: draw_manager.h:539
DRWView * view_previous
Definition: draw_manager.h:552
DRWResourceHandle resource_handle
Definition: draw_manager.h:497
uint primary_view_ct
Definition: draw_manager.h:553
struct Object * dupli_parent
Definition: draw_manager.h:503
bool ob_state_obinfo_init
Definition: draw_manager.h:495
ViewportMemoryPool * vmempool
Definition: draw_manager.h:490
DRWInstanceDataList * idatalist
Definition: draw_manager.h:491
DRWView * view_default
Definition: draw_manager.h:550
float orcotexfac[2][4]
Definition: draw_manager.h:172
float ob_color[4]
Definition: draw_manager.h:173
float modelinverse[4][4]
Definition: draw_manager.h:168
float model[4][4]
Definition: draw_manager.h:167
DRWResourceHandle handle
Definition: draw_manager.h:378
DRWState state
Definition: draw_manager.h:379
char name[MAX_PASS_NAME]
Definition: draw_manager.h:380
DRWShadingGroup * last
Definition: draw_manager.h:368
DRWShadingGroup * first
Definition: draw_manager.h:367
DRWPass * original
Definition: draw_manager.h:374
struct DRWPass::@294 shgroups
DRWPass * next
Definition: draw_manager.h:376
DRWShadingGroup ** shading_groups
struct DRWCommandChunk * first
Definition: draw_manager.h:341
struct DRWShadingGroup::@289::@293 z_sorting
struct GPUUniformAttrList * uniform_attrs
Definition: draw_manager.h:351
struct DRWUniformChunk * uniforms
Definition: draw_manager.h:337
DRWResourceHandle pass_handle
Definition: draw_manager.h:348
DRWShadingGroup * next
Definition: draw_manager.h:334
struct DRWShadingGroup::@288 cmd
struct DRWCommandChunk * last
Definition: draw_manager.h:341
GPUShader * shader
Definition: draw_manager.h:336
uint32_t uniform_used
Definition: draw_manager.h:437
DRWUniform uniforms[10]
Definition: draw_manager.h:438
uint32_t uniform_len
Definition: draw_manager.h:436
int ivalue[4]
Definition: draw_manager.h:323
uint8_t arraysize
Definition: draw_manager.h:330
struct GPUUniformAttrList * uniform_attrs
Definition: draw_manager.h:325
GPUTexture ** texture_ref
Definition: draw_manager.h:311
GPUUniformBuf ** block_ref
Definition: draw_manager.h:318
GPUUniformBuf * block
Definition: draw_manager.h:317
uint8_t type
Definition: draw_manager.h:328
uint8_t length
Definition: draw_manager.h:329
GPUTexture * texture
Definition: draw_manager.h:310
eGPUSamplerState sampler_state
Definition: draw_manager.h:313
float fvalue[4]
Definition: draw_manager.h:321
const void * pvalue
Definition: draw_manager.h:306
float persmat[4][4]
Definition: draw_manager.h:386
float winmat[4][4]
Definition: draw_manager.h:390
float viewinv[4][4]
Definition: draw_manager.h:389
float viewmat[4][4]
Definition: draw_manager.h:388
float wininv[4][4]
Definition: draw_manager.h:391
float viewvecs[2][4]
Definition: draw_manager.h:394
float persinv[4][4]
Definition: draw_manager.h:387
DRWViewUboStorage storage
Definition: draw_manager.h:407
struct DRWView * parent
Definition: draw_manager.h:405
struct GPUUniformBuf * view_ubo
Definition: draw_common.h:215
unsigned int random_id
Definition: BKE_duplilist.h:60
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
struct SubdivCCG * subdiv_ccg
Mesh_Runtime runtime
float size[3]
float loc[3]
short transflag
short base_flag
float imat[4][4]
float obmat[4][4]
float color[4]
struct SculptSession * sculpt
void * data
float(* planes)[4]
Definition: BKE_pbvh.h:84
struct PBVH * pbvh
Definition: BKE_paint.h:504
struct ImageUser iuser
struct Image * ima
struct BLI_memblock * commands_small
Definition: GPU_viewport.h:49
struct BLI_memblock * obmats
Definition: GPU_viewport.h:51
struct BLI_memblock * cullstates
Definition: GPU_viewport.h:53
struct BLI_memblock * views
Definition: GPU_viewport.h:56
struct GPUUniformBuf ** matrices_ubo
Definition: GPU_viewport.h:59
struct BLI_memblock * obinfos
Definition: GPU_viewport.h:52
struct BLI_memblock * passes
Definition: GPU_viewport.h:57
struct BLI_memblock * images
Definition: GPU_viewport.h:58
struct GHash * obattrs_ubo_pool
Definition: GPU_viewport.h:61
struct BLI_memblock * callbuffers
Definition: GPU_viewport.h:50
struct BLI_memblock * shgroups
Definition: GPU_viewport.h:54
struct BLI_memblock * commands
Definition: GPU_viewport.h:48
struct GPUUniformBuf ** obinfos_ubo
Definition: GPU_viewport.h:60
struct BLI_memblock * uniforms
Definition: GPU_viewport.h:55
float max
DRWCommandDraw draw
Definition: draw_manager.h:258
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
#define G(x, y, z)
uint len