Blender  V2.93
gpu_viewport.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  * The Original Code is Copyright (C) 2006 Blender Foundation.
17  * All rights reserved.
18  */
19 
26 #include <string.h>
27 
28 #include "BLI_listbase.h"
29 #include "BLI_math_vector.h"
30 #include "BLI_memblock.h"
31 #include "BLI_rect.h"
32 
33 #include "BKE_colortools.h"
34 
35 #include "IMB_colormanagement.h"
36 
37 #include "DNA_userdef_types.h"
38 #include "DNA_vec_types.h"
39 
40 #include "GPU_framebuffer.h"
41 #include "GPU_immediate.h"
42 #include "GPU_matrix.h"
43 #include "GPU_texture.h"
44 #include "GPU_uniform_buffer.h"
45 #include "GPU_viewport.h"
46 
47 #include "DRW_engine.h"
48 
49 #include "MEM_guardedalloc.h"
50 
51 static const int default_fbl_len = (sizeof(DefaultFramebufferList)) / sizeof(void *);
52 static const int default_txl_len = (sizeof(DefaultTextureList)) / sizeof(void *);
53 
54 #define MAX_ENABLE_ENGINE 8
55 
56 /* Maximum number of simultaneous engine enabled at the same time.
57  * Setting it lower than the real number will do lead to
58  * higher VRAM usage due to sub-efficient buffer reuse. */
59 #define MAX_ENGINE_BUFFER_SHARING 5
60 
61 typedef struct ViewportTempTexture {
66 
67 /* Struct storing a viewport specific GPUBatch.
68  * The end-goal is to have a single batch shared across viewport and use a model matrix to place
69  * the batch. Due to OCIO and Image/UV editor we are not able to use an model matrix yet. */
72  struct {
76 };
77 
78 static struct {
80  struct {
83 } g_viewport = {{0}};
84 
85 struct GPUViewport {
86  int size[2];
87  int flag;
88 
89  /* Set the active view (for stereoscopic viewport rendering). */
91 
92  /* If engine_handles mismatch we free all #ViewportEngineData in this viewport. */
93  struct {
94  void *handle;
97 
100 
101  ViewportMemoryPool vmempool; /* Used for rendering data structure. */
102  struct DRWInstanceDataList *idatalist; /* Used for rendering data structure. */
103 
104  ListBase
105  tex_pool; /* ViewportTempTexture list : Temporary textures shared across draw engines. */
106 
107  /* Profiling data. */
108  double cache_time;
109 
110  /* Color management. */
114  float dither;
115  /* TODO(fclem): the uvimage display use the viewport but do not set any view transform for the
116  * moment. The end goal would be to let the GPUViewport do the color management. */
118  struct GPUViewportBatch batch;
119 };
120 
121 enum {
122  DO_UPDATE = (1 << 0),
124 };
125 
126 static void gpu_viewport_buffers_free(
127  FramebufferList *fbl, int fbl_len, TextureList *txl, TextureList *txl_stereo, int txl_len);
128 static void gpu_viewport_storage_free(StorageList *stl, int stl_len);
129 static void gpu_viewport_passes_free(PassList *psl, int psl_len);
130 static void gpu_viewport_texture_pool_free(GPUViewport *viewport);
131 
133 {
134  viewport->flag |= DO_UPDATE;
135 }
136 
138 {
139  bool ret = (viewport->flag & DO_UPDATE);
140  viewport->flag &= ~DO_UPDATE;
141  return ret;
142 }
143 
145 {
146  GPUViewport *viewport = MEM_callocN(sizeof(GPUViewport), "GPUViewport");
147  viewport->fbl = MEM_callocN(sizeof(DefaultFramebufferList), "FramebufferList");
148  viewport->txl = MEM_callocN(sizeof(DefaultTextureList), "TextureList");
150  viewport->do_color_management = false;
151  viewport->size[0] = viewport->size[1] = -1;
152  viewport->active_view = -1;
153  return viewport;
154 }
155 
157 {
158  GPUViewport *viewport = GPU_viewport_create();
159  viewport->flag = GPU_VIEWPORT_STEREO;
160  return viewport;
161 }
162 
164 {
165  /* Early check if the view is the latest requested. */
166  if (viewport->active_view == view) {
167  return;
168  }
169  DefaultFramebufferList *dfbl = viewport->fbl;
170  DefaultTextureList *dtxl = viewport->txl;
171 
172  /* Only swap the texture when this is a Stereo Viewport. */
173  if (((viewport->flag & GPU_VIEWPORT_STEREO) != 0)) {
174  SWAP(GPUTexture *, dtxl->color, dtxl->color_stereo);
176 
177  for (int i = 0; i < MAX_ENABLE_ENGINE; i++) {
178  if (viewport->engine_data[i].handle != NULL) {
179  ViewportEngineData *data = viewport->engine_data[i].data;
180  SWAP(StorageList *, data->stl, data->stl_stereo);
181  SWAP(TextureList *, data->txl, data->txl_stereo);
182  }
183  else {
184  break;
185  }
186  }
187  }
188 
189  GPU_framebuffer_ensure_config(&dfbl->default_fb,
190  {
191  GPU_ATTACHMENT_TEXTURE(dtxl->depth),
192  GPU_ATTACHMENT_TEXTURE(dtxl->color),
193  });
194 
195  GPU_framebuffer_ensure_config(&dfbl->overlay_fb,
196  {
197  GPU_ATTACHMENT_TEXTURE(dtxl->depth),
198  GPU_ATTACHMENT_TEXTURE(dtxl->color_overlay),
199  });
200 
201  GPU_framebuffer_ensure_config(&dfbl->depth_only_fb,
202  {
203  GPU_ATTACHMENT_TEXTURE(dtxl->depth),
204  GPU_ATTACHMENT_NONE,
205  });
206 
207  GPU_framebuffer_ensure_config(&dfbl->color_only_fb,
208  {
209  GPU_ATTACHMENT_NONE,
210  GPU_ATTACHMENT_TEXTURE(dtxl->color),
211  });
212 
213  GPU_framebuffer_ensure_config(&dfbl->overlay_only_fb,
214  {
215  GPU_ATTACHMENT_NONE,
216  GPU_ATTACHMENT_TEXTURE(dtxl->color_overlay),
217  });
218 
219  viewport->active_view = view;
220 }
221 
222 void *GPU_viewport_engine_data_create(GPUViewport *viewport, void *engine_type)
223 {
224  ViewportEngineData *data = MEM_callocN(sizeof(ViewportEngineData), "ViewportEngineData");
225  int fbl_len, txl_len, psl_len, stl_len;
226 
227  DRW_engine_viewport_data_size_get(engine_type, &fbl_len, &txl_len, &psl_len, &stl_len);
228 
229  data->engine_type = engine_type;
230 
231  data->fbl = MEM_callocN((sizeof(void *) * fbl_len) + sizeof(FramebufferList), "FramebufferList");
232  data->txl = MEM_callocN((sizeof(void *) * txl_len) + sizeof(TextureList), "TextureList");
233  data->psl = MEM_callocN((sizeof(void *) * psl_len) + sizeof(PassList), "PassList");
234  data->stl = MEM_callocN((sizeof(void *) * stl_len) + sizeof(StorageList), "StorageList");
235 
236  if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0) {
237  data->txl_stereo = MEM_callocN((sizeof(void *) * txl_len) + sizeof(TextureList),
238  "TextureList");
239  data->stl_stereo = MEM_callocN((sizeof(void *) * stl_len) + sizeof(StorageList),
240  "StorageList");
241  }
242 
243  for (int i = 0; i < MAX_ENABLE_ENGINE; i++) {
244  if (viewport->engine_data[i].handle == NULL) {
245  viewport->engine_data[i].handle = engine_type;
246  viewport->engine_data[i].data = data;
247  return data;
248  }
249  }
250 
251  BLI_assert(!"Too many draw engines enabled at the same time");
252  return NULL;
253 }
254 
256 {
257  int fbl_len, txl_len, psl_len, stl_len;
258 
259  for (int i = 0; i < MAX_ENABLE_ENGINE && viewport->engine_data[i].handle; i++) {
260  ViewportEngineData *data = viewport->engine_data[i].data;
261 
262  DRW_engine_viewport_data_size_get(data->engine_type, &fbl_len, &txl_len, &psl_len, &stl_len);
263 
264  gpu_viewport_buffers_free(data->fbl, fbl_len, data->txl, data->txl_stereo, txl_len);
265  gpu_viewport_passes_free(data->psl, psl_len);
266  gpu_viewport_storage_free(data->stl, stl_len);
267 
268  MEM_freeN(data->fbl);
269  MEM_freeN(data->txl);
270  MEM_freeN(data->psl);
271  MEM_freeN(data->stl);
272 
273  if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0) {
274  gpu_viewport_storage_free(data->stl_stereo, stl_len);
275  MEM_freeN(data->txl_stereo);
276  MEM_freeN(data->stl_stereo);
277  }
278  /* We could handle this in the DRW module */
279  if (data->text_draw_cache) {
280  extern void DRW_text_cache_destroy(struct DRWTextStore * dt);
281  DRW_text_cache_destroy(data->text_draw_cache);
282  data->text_draw_cache = NULL;
283  }
284 
285  MEM_freeN(data);
286 
287  /* Mark as unused*/
288  viewport->engine_data[i].handle = NULL;
289  }
290 
292 }
293 
294 void *GPU_viewport_engine_data_get(GPUViewport *viewport, void *engine_handle)
295 {
296  BLI_assert(engine_handle != NULL);
297 
298  for (int i = 0; i < MAX_ENABLE_ENGINE; i++) {
299  if (viewport->engine_data[i].handle == engine_handle) {
300  return viewport->engine_data[i].data;
301  }
302  }
303  return NULL;
304 }
305 
307 {
308  return &viewport->vmempool;
309 }
310 
312 {
313  return viewport->idatalist;
314 }
315 
316 /* Note this function is only allowed to be called from `DRW_notify_view_update`. The rest
317  * should bind the correct viewport.
318  *
319  * The reason is that DRW_notify_view_update can be called from a different thread, but needs
320  * access to the engine data. */
322 {
324 }
325 
327 {
328  return viewport->fbl;
329 }
330 
332 {
333  return viewport->txl;
334 }
335 
336 void GPU_viewport_size_get(const GPUViewport *viewport, int size[2])
337 {
338  copy_v2_v2_int(size, viewport->size);
339 }
340 
346 void GPU_viewport_size_set(GPUViewport *viewport, const int size[2])
347 {
348  copy_v2_v2_int(viewport->size, size);
349 }
350 
352 {
353  return &viewport->cache_time;
354 }
355 
361  GPUViewport *viewport, void *engine, int width, int height, int format)
362 {
363  GPUTexture *tex;
364 
365  LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) {
366  if ((GPU_texture_format(tmp_tex->texture) == format) &&
367  (GPU_texture_width(tmp_tex->texture) == width) &&
368  (GPU_texture_height(tmp_tex->texture) == height)) {
369  /* Search if the engine is not already using this texture */
370  for (int i = 0; i < MAX_ENGINE_BUFFER_SHARING; i++) {
371  if (tmp_tex->user[i] == engine) {
372  break;
373  }
374 
375  if (tmp_tex->user[i] == NULL) {
376  tmp_tex->user[i] = engine;
377  return tmp_tex->texture;
378  }
379  }
380  }
381  }
382 
383  tex = GPU_texture_create_2d("temp_from_pool", width, height, 1, format, NULL);
384  /* Doing filtering for depth does not make sense when not doing shadow mapping,
385  * and enabling texture filtering on integer texture make them unreadable. */
386  bool do_filter = !GPU_texture_depth(tex) && !GPU_texture_integer(tex);
387  GPU_texture_filter_mode(tex, do_filter);
388 
389  ViewportTempTexture *tmp_tex = MEM_callocN(sizeof(ViewportTempTexture), "ViewportTempTexture");
390  tmp_tex->texture = tex;
391  tmp_tex->user[0] = engine;
392  BLI_addtail(&viewport->tex_pool, tmp_tex);
393 
394  return tex;
395 }
396 
398 {
399  ViewportTempTexture *tmp_tex_next;
400 
401  for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex_next) {
402  tmp_tex_next = tmp_tex->next;
403  bool no_user = true;
404  for (int i = 0; i < MAX_ENGINE_BUFFER_SHARING; i++) {
405  if (tmp_tex->user[i] != NULL) {
406  tmp_tex->user[i] = NULL;
407  no_user = false;
408  }
409  }
410 
411  if (no_user) {
412  GPU_texture_free(tmp_tex->texture);
413  BLI_freelinkN(&viewport->tex_pool, tmp_tex);
414  }
415  }
416 }
417 
419 {
420  LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) {
421  GPU_texture_free(tmp_tex->texture);
422  }
423 
424  BLI_freelistN(&viewport->tex_pool);
425 }
426 
427 /* Takes an NULL terminated array of engine_handle. Returns true is data is still valid. */
428 bool GPU_viewport_engines_data_validate(GPUViewport *viewport, void **engine_handle_array)
429 {
430  for (int i = 0; i < MAX_ENABLE_ENGINE && engine_handle_array[i]; i++) {
431  if (viewport->engine_data[i].handle != engine_handle_array[i]) {
433  return false;
434  }
435  }
436  return true;
437 }
438 
440 {
441  for (int i = 0; i < MAX_ENABLE_ENGINE && viewport->engine_data[i].handle; i++) {
442  ViewportEngineData *data = viewport->engine_data[i].data;
443  int psl_len;
444  DRW_engine_viewport_data_size_get(data->engine_type, NULL, NULL, &psl_len, NULL);
445  gpu_viewport_passes_free(data->psl, psl_len);
446  }
447 }
448 
450 {
451  DefaultFramebufferList *dfbl = viewport->fbl;
452  DefaultTextureList *dtxl = viewport->txl;
453  int *size = viewport->size;
454  bool ok = true;
455 
456  dtxl->color = GPU_texture_create_2d("dtxl_color", UNPACK2(size), 1, GPU_RGBA16F, NULL);
458  "dtxl_color_overlay", UNPACK2(size), 1, GPU_SRGB8_A8, NULL);
459 
460  if (viewport->flag & GPU_VIEWPORT_STEREO) {
462  "dtxl_color_stereo", UNPACK2(size), 1, GPU_RGBA16F, NULL);
464  "dtxl_color_overlay_stereo", UNPACK2(size), 1, GPU_SRGB8_A8, NULL);
465  }
466 
467  /* Can be shared with GPUOffscreen. */
468  if (dtxl->depth == NULL) {
470  "dtxl_depth", UNPACK2(size), 1, GPU_DEPTH24_STENCIL8, NULL);
471  }
472 
473  if (!dtxl->depth || !dtxl->color) {
474  ok = false;
475  goto cleanup;
476  }
477 
479 
480  ok = ok && GPU_framebuffer_check_valid(dfbl->default_fb, NULL);
481  ok = ok && GPU_framebuffer_check_valid(dfbl->overlay_fb, NULL);
485 cleanup:
486  if (!ok) {
487  GPU_viewport_free(viewport);
489  return;
490  }
491 
493 }
494 
495 void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
496 {
497  DefaultFramebufferList *dfbl = viewport->fbl;
498  int fbl_len, txl_len;
499 
500  int rect_size[2];
501  /* add one pixel because of scissor test */
502  rect_size[0] = BLI_rcti_size_x(rect) + 1;
503  rect_size[1] = BLI_rcti_size_y(rect) + 1;
504 
506 
507  if (dfbl->default_fb) {
508  if (!equals_v2v2_int(viewport->size, rect_size)) {
511  (TextureList *)viewport->txl,
512  NULL,
514 
515  for (int i = 0; i < MAX_ENABLE_ENGINE && viewport->engine_data[i].handle; i++) {
516  ViewportEngineData *data = viewport->engine_data[i].data;
517  DRW_engine_viewport_data_size_get(data->engine_type, &fbl_len, &txl_len, NULL, NULL);
518  gpu_viewport_buffers_free(data->fbl, fbl_len, data->txl, data->txl_stereo, txl_len);
519  }
520 
522  viewport->active_view = -1;
523  }
524  }
525 
526  copy_v2_v2_int(viewport->size, rect_size);
527 
529 
530  if (!dfbl->default_fb) {
532  }
534 }
535 
537 {
538  DefaultFramebufferList *dfbl = viewport->fbl;
539  DefaultTextureList *dtxl = viewport->txl;
540  GPUTexture *color, *depth;
542  viewport->size[0] = GPU_offscreen_width(ofs);
543  viewport->size[1] = GPU_offscreen_height(ofs);
544 
545  GPU_offscreen_viewport_data_get(ofs, &fb, &color, &depth);
546 
547  /* This is the only texture we can share. */
548  dtxl->depth = depth;
549 
551 
552  if (!dfbl->default_fb) {
554  }
555 }
556 
558  ColorManagedViewSettings *view_settings,
559  ColorManagedDisplaySettings *display_settings,
560  float dither)
561 {
569  if (view_settings->curve_mapping) {
570  if (viewport->view_settings.curve_mapping) {
571  if (view_settings->curve_mapping->changed_timestamp !=
574  }
575  }
576  }
577 
578  if (viewport->orig_curve_mapping != view_settings->curve_mapping) {
579  viewport->orig_curve_mapping = view_settings->curve_mapping;
581  }
582  /* Don't copy the curve mapping already. */
583  CurveMapping *tmp_curve_mapping = view_settings->curve_mapping;
584  CurveMapping *tmp_curve_mapping_vp = viewport->view_settings.curve_mapping;
585  view_settings->curve_mapping = NULL;
586  viewport->view_settings.curve_mapping = NULL;
587 
588  BKE_color_managed_view_settings_copy(&viewport->view_settings, view_settings);
589  /* Restore. */
590  view_settings->curve_mapping = tmp_curve_mapping;
591  viewport->view_settings.curve_mapping = tmp_curve_mapping_vp;
592  /* Only copy curve-mapping if needed. Avoid unneeded OCIO cache miss. */
593  if (tmp_curve_mapping && viewport->view_settings.curve_mapping == NULL) {
595  viewport->view_settings.curve_mapping = BKE_curvemapping_copy(tmp_curve_mapping);
596  }
597 
598  BKE_color_managed_display_settings_copy(&viewport->display_settings, display_settings);
599  viewport->dither = dither;
600  viewport->do_color_management = true;
601 }
602 
603 /* Merge the stereo textures. `color` and `overlay` texture will be modified. */
605 {
607  /* Early Exit: the other display modes need access to the full screen and cannot be
608  * done from a single viewport. See `wm_stereo.c` */
609  return;
610  }
612  DefaultTextureList *dtxl = viewport->txl;
613  DefaultFramebufferList *dfbl = viewport->fbl;
614 
615  /* The composite framebuffer object needs to be created in the window context. */
616  GPU_framebuffer_ensure_config(&dfbl->stereo_comp_fb,
617  {
618  GPU_ATTACHMENT_NONE,
619  GPU_ATTACHMENT_TEXTURE(dtxl->color_overlay),
620  GPU_ATTACHMENT_TEXTURE(dtxl->color),
621  });
622 
623  GPUVertFormat *vert_format = immVertexFormat();
624  uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
626  GPU_matrix_push();
631  immUniform1i("overlayTexture", 0);
632  immUniform1i("imageTexture", 1);
633  int settings = stereo_format->display_mode;
634  if (settings == S3D_DISPLAY_ANAGLYPH) {
635  switch (stereo_format->anaglyph_type) {
637  GPU_color_mask(false, true, true, true);
638  break;
640  GPU_color_mask(true, false, true, true);
641  break;
643  GPU_color_mask(false, false, true, true);
644  break;
645  }
646  }
647  else if (settings == S3D_DISPLAY_INTERLACE) {
648  settings |= stereo_format->interlace_type << 3;
649  SET_FLAG_FROM_TEST(settings, stereo_format->flag & S3D_INTERLACE_SWAP, 1 << 6);
650  }
651  immUniform1i("stereoDisplaySettings", settings);
652 
653  GPU_texture_bind(dtxl->color_stereo, 0);
655 
657 
658  immVertex2f(pos, -1.0f, -1.0f);
659  immVertex2f(pos, 1.0f, -1.0f);
660  immVertex2f(pos, -1.0f, 1.0f);
661  immVertex2f(pos, 1.0f, 1.0f);
662 
663  immEnd();
664 
667 
670  GPU_matrix_pop();
671 
672  if (settings == S3D_DISPLAY_ANAGLYPH) {
673  GPU_color_mask(true, true, true, true);
674  }
675 
677 }
678 /* -------------------------------------------------------------------- */
683 {
684  if (g_viewport.format.attr_len == 0) {
685  GPUVertFormat *format = &g_viewport.format;
686  g_viewport.attr_id.pos = GPU_vertformat_attr_add(
687  format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
688  g_viewport.attr_id.tex_coord = GPU_vertformat_attr_add(
689  format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
690  }
691  return &g_viewport.format;
692 }
693 
694 static GPUBatch *gpu_viewport_batch_create(const rctf *rect_pos, const rctf *rect_uv)
695 {
697  const uint vbo_len = 4;
698  GPU_vertbuf_data_alloc(vbo, vbo_len);
699 
700  GPUVertBufRaw pos_step, tex_coord_step;
701  GPU_vertbuf_attr_get_raw_data(vbo, g_viewport.attr_id.pos, &pos_step);
702  GPU_vertbuf_attr_get_raw_data(vbo, g_viewport.attr_id.tex_coord, &tex_coord_step);
703 
704  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmin, rect_pos->ymin);
705  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmin, rect_uv->ymin);
706  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmax, rect_pos->ymin);
707  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmax, rect_uv->ymin);
708  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmin, rect_pos->ymax);
709  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmin, rect_uv->ymax);
710  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmax, rect_pos->ymax);
711  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmax, rect_uv->ymax);
712 
714 }
715 
717  const rctf *rect_pos,
718  const rctf *rect_uv)
719 {
720  const float compare_limit = 0.0001f;
721  const bool parameters_changed =
723  &viewport->batch.last_used_parameters.rect_pos, rect_pos, compare_limit) ||
724  !BLI_rctf_compare(&viewport->batch.last_used_parameters.rect_uv, rect_uv, compare_limit));
725 
726  if (viewport->batch.batch && parameters_changed) {
727  GPU_batch_discard(viewport->batch.batch);
728  viewport->batch.batch = NULL;
729  }
730 
731  if (!viewport->batch.batch) {
732  viewport->batch.batch = gpu_viewport_batch_create(rect_pos, rect_uv);
733  viewport->batch.last_used_parameters.rect_pos = *rect_pos;
734  viewport->batch.last_used_parameters.rect_uv = *rect_uv;
735  }
736  return viewport->batch.batch;
737 }
738 
739 static void gpu_viewport_batch_free(GPUViewport *viewport)
740 {
741  if (viewport->batch.batch) {
742  GPU_batch_discard(viewport->batch.batch);
743  viewport->batch.batch = NULL;
744  }
745 }
746 
750  const rctf *rect_pos,
751  const rctf *rect_uv,
752  bool display_colorspace,
753  bool do_overlay_merge)
754 {
755  DefaultTextureList *dtxl = viewport->txl;
756  GPUTexture *color = dtxl->color;
757  GPUTexture *color_overlay = dtxl->color_overlay;
758 
759  bool use_ocio = false;
760 
761  if (viewport->do_color_management && display_colorspace) {
762  /* During the binding process the last used VertexFormat is tested and can assert as it is not
763  * valid. By calling the `immVertexFormat` the last used VertexFormat is reset and the assert
764  * does not happen. This solves a chicken and egg problem when using GPUBatches. GPUBatches
765  * contain the correct vertex format, but can only bind after the shader is bound.
766  *
767  * Image/UV editor still uses imm, after that has been changed we could move this fix to the
768  * OCIO. */
769  immVertexFormat();
771  &viewport->display_settings,
772  NULL,
773  viewport->dither,
774  false,
775  do_overlay_merge);
776  }
777 
778  GPUBatch *batch = gpu_viewport_batch_get(viewport, rect_pos, rect_uv);
779  if (use_ocio) {
781  }
782  else {
784  GPU_batch_uniform_1i(batch, "overlay", do_overlay_merge);
785  GPU_batch_uniform_1i(batch, "display_transform", display_colorspace);
786  GPU_batch_uniform_1i(batch, "image_texture", 0);
787  GPU_batch_uniform_1i(batch, "overlays_texture", 1);
788  }
789 
790  GPU_texture_bind(color, 0);
791  GPU_texture_bind(color_overlay, 1);
793  GPU_texture_unbind(color);
794  GPU_texture_unbind(color_overlay);
795 
796  if (use_ocio) {
798  }
799 }
800 
806  int view,
807  const rcti *rect,
808  bool display_colorspace,
809  bool do_overlay_merge)
810 {
812  DefaultFramebufferList *dfbl = viewport->fbl;
813  DefaultTextureList *dtxl = viewport->txl;
814  GPUTexture *color = dtxl->color;
815 
816  if (dfbl->default_fb == NULL) {
817  return;
818  }
819 
820  const float w = (float)GPU_texture_width(color);
821  const float h = (float)GPU_texture_height(color);
822 
823  /* We allow rects with min/max swapped, but we also need correctly assigned coordinates. */
824  rcti sanitized_rect = *rect;
825  BLI_rcti_sanitize(&sanitized_rect);
826 
827  BLI_assert(w == BLI_rcti_size_x(&sanitized_rect) + 1);
828  BLI_assert(h == BLI_rcti_size_y(&sanitized_rect) + 1);
829 
830  /* wmOrtho for the screen has this same offset */
831  const float halfx = GLA_PIXEL_OFS / w;
832  const float halfy = GLA_PIXEL_OFS / h;
833 
834  rctf pos_rect = {
835  .xmin = sanitized_rect.xmin,
836  .ymin = sanitized_rect.ymin,
837  .xmax = sanitized_rect.xmin + w,
838  .ymax = sanitized_rect.ymin + h,
839  };
840 
841  rctf uv_rect = {
842  .xmin = halfx,
843  .ymin = halfy,
844  .xmax = halfx + 1.0f,
845  .ymax = halfy + 1.0f,
846  };
847  /* Mirror the UV rect in case axis-swapped drawing is requested (by passing a rect with min and
848  * max values swapped). */
849  if (BLI_rcti_size_x(rect) < 0) {
850  SWAP(float, uv_rect.xmin, uv_rect.xmax);
851  }
852  if (BLI_rcti_size_y(rect) < 0) {
853  SWAP(float, uv_rect.ymin, uv_rect.ymax);
854  }
855 
857  viewport, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
858 }
859 
867 void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
868 {
869  GPU_viewport_draw_to_screen_ex(viewport, view, rect, true, true);
870 }
871 
876  struct GPUOffScreen *ofs,
877  bool display_colorspace,
878  bool do_overlay_merge)
879 {
880  DefaultFramebufferList *dfbl = viewport->fbl;
881  DefaultTextureList *dtxl = viewport->txl;
882 
883  if (dfbl->default_fb == NULL) {
884  return;
885  }
886 
888  GPU_offscreen_bind(ofs, false);
889 
890  rctf pos_rect = {
891  .xmin = -1.0f,
892  .ymin = -1.0f,
893  .xmax = 1.0f,
894  .ymax = 1.0f,
895  };
896 
897  rctf uv_rect = {
898  .xmin = 0.0f,
899  .ymin = 0.0f,
900  .xmax = 1.0f,
901  .ymax = 1.0f,
902  };
903 
905  viewport, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
906 
907  /* This one is from the offscreen. Don't free it with the viewport. */
908  dtxl->depth = NULL;
909 }
910 
912 {
915 }
916 
918 {
919  DefaultFramebufferList *dfbl = viewport->fbl;
920 
921  if (dfbl->default_fb) {
922  DefaultTextureList *dtxl = viewport->txl;
923  if (viewport->active_view == view) {
924  return dtxl->color;
925  }
926 
927  return dtxl->color_stereo;
928  }
929 
930  return NULL;
931 }
932 
934  FramebufferList *fbl, int fbl_len, TextureList *txl, TextureList *txl_stereo, int txl_len)
935 {
936  for (int i = 0; i < fbl_len; i++) {
937  GPUFrameBuffer *fb = fbl->framebuffers[i];
938  if (fb) {
940  fbl->framebuffers[i] = NULL;
941  }
942  }
943  for (int i = 0; i < txl_len; i++) {
944  GPUTexture *tex = txl->textures[i];
945  if (tex) {
947  txl->textures[i] = NULL;
948  }
949  }
950  if (txl_stereo != NULL) {
951  for (int i = 0; i < txl_len; i++) {
952  GPUTexture *tex = txl_stereo->textures[i];
953  if (tex) {
955  txl_stereo->textures[i] = NULL;
956  }
957  }
958  }
959 }
960 
961 static void gpu_viewport_storage_free(StorageList *stl, int stl_len)
962 {
963  for (int i = 0; i < stl_len; i++) {
964  void *storage = stl->storage[i];
965  if (storage) {
966  MEM_freeN(storage);
967  stl->storage[i] = NULL;
968  }
969  }
970 }
971 
972 static void gpu_viewport_passes_free(PassList *psl, int psl_len)
973 {
974  memset(psl->passes, 0, sizeof(*psl->passes) * psl_len);
975 }
976 
977 /* Must be executed inside Draw-manager OpenGL Context. */
979 {
981 
984  (TextureList *)viewport->txl,
985  NULL,
987 
989 
990  MEM_freeN(viewport->fbl);
991  MEM_freeN(viewport->txl);
992 
993  if (viewport->vmempool.commands != NULL) {
995  }
996  if (viewport->vmempool.commands_small != NULL) {
998  }
999  if (viewport->vmempool.callbuffers != NULL) {
1001  }
1002  if (viewport->vmempool.obmats != NULL) {
1004  }
1005  if (viewport->vmempool.obinfos != NULL) {
1007  }
1008  if (viewport->vmempool.cullstates != NULL) {
1010  }
1011  if (viewport->vmempool.shgroups != NULL) {
1013  }
1014  if (viewport->vmempool.uniforms != NULL) {
1016  }
1017  if (viewport->vmempool.views != NULL) {
1019  }
1020  if (viewport->vmempool.passes != NULL) {
1022  }
1023  if (viewport->vmempool.images != NULL) {
1024  BLI_memblock_iter iter;
1025  GPUTexture **tex;
1026  BLI_memblock_iternew(viewport->vmempool.images, &iter);
1027  while ((tex = BLI_memblock_iterstep(&iter))) {
1029  }
1031  }
1032  if (viewport->vmempool.obattrs_ubo_pool != NULL) {
1034  }
1035 
1036  for (int i = 0; i < viewport->vmempool.ubo_len; i++) {
1039  }
1040  MEM_SAFE_FREE(viewport->vmempool.matrices_ubo);
1041  MEM_SAFE_FREE(viewport->vmempool.obinfos_ubo);
1042 
1044  MEM_freeN(viewport->idatalist);
1045 
1047  gpu_viewport_batch_free(viewport);
1048 
1049  MEM_freeN(viewport);
1050 }
1051 
1053 {
1055  return fbl->default_fb;
1056 }
1057 
1059 {
1061  return fbl->overlay_fb;
1062 }
typedef float(TangentPoint)[2]
void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings, const struct ColorManagedDisplaySettings *settings)
struct CurveMapping * BKE_curvemapping_copy(const struct CurveMapping *cumap)
void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings)
Definition: colortools.c:1820
void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings, const struct ColorManagedViewSettings *settings)
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:281
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
MINLINE bool equals_v2v2_int(const int v1[2], const int v2[2]) ATTR_WARN_UNUSED_RESULT
void BLI_memblock_destroy(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1)
Definition: BLI_memblock.c:82
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
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, const float limit)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:157
void BLI_rcti_sanitize(struct rcti *rect)
Definition: rct.c:488
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:153
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNPACK2(a)
#define SWAP(type, a, b)
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
@ S3D_ANAGLYPH_REDCYAN
@ S3D_ANAGLYPH_YELLOWBLUE
@ S3D_ANAGLYPH_GREENMAGENTA
@ S3D_INTERLACE_SWAP
@ S3D_DISPLAY_ANAGLYPH
@ S3D_DISPLAY_INTERLACE
void DRW_opengl_context_enable(void)
void DRW_instance_data_list_free(struct DRWInstanceDataList *idatalist)
void DRW_uniform_attrs_pool_free(struct GHash *table)
void DRW_opengl_context_disable(void)
void DRW_engine_viewport_data_size_get(const void *engine_type, int *r_fbl_len, int *r_txl_len, int *r_psl_len, int *r_stl_len)
Definition: draw_manager.c:411
struct DRWInstanceDataList * DRW_instance_data_list_create(void)
struct DefaultFramebufferList DefaultFramebufferList
struct DefaultTextureList DefaultTextureList
static AppView * view
GPUBatch
Definition: GPU_batch.h:93
void GPU_batch_discard(GPUBatch *)
Definition: gpu_batch.cc:127
void GPU_batch_program_set_imm_shader(GPUBatch *batch)
Definition: gpu_batch.cc:307
void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
Definition: gpu_batch.cc:299
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
Definition: gpu_batch.cc:60
void GPU_batch_draw(GPUBatch *batch)
Definition: gpu_batch.cc:234
@ GPU_BATCH_OWNS_VBO
Definition: GPU_batch.h:45
#define GPU_batch_uniform_1i(batch, name, x)
Definition: GPU_batch.h:132
struct GPUFrameBuffer GPUFrameBuffer
bool GPU_framebuffer_check_valid(GPUFrameBuffer *fb, char err_out[256])
void GPU_framebuffer_restore(void)
void GPU_framebuffer_free(GPUFrameBuffer *fb)
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
void immUnbindProgram(void)
void immVertex2f(uint attr_id, float x, float y)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniform1i(const char *name, int x)
GPUVertFormat * immVertexFormat(void)
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
_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 width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:142
void GPU_matrix_identity_projection_set(void)
Definition: gpu_matrix.cc:170
void GPU_matrix_pop_projection(void)
Definition: gpu_matrix.cc:156
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
void GPU_matrix_identity_set(void)
Definition: gpu_matrix.cc:184
void GPU_matrix_push_projection(void)
Definition: gpu_matrix.cc:149
@ GPU_PRIM_TRI_STRIP
Definition: GPU_primitive.h:40
@ GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE
Definition: GPU_shader.h:250
@ GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE
Definition: GPU_shader.h:249
void GPU_color_mask(bool r, bool g, bool b, bool a)
Definition: gpu_state.cc:105
@ GPU_DEPTH_NONE
Definition: GPU_state.h:78
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:75
int GPU_texture_height(const GPUTexture *tex)
Definition: gpu_texture.cc:532
struct GPUTexture GPUTexture
Definition: GPU_texture.h:33
int GPU_texture_width(const GPUTexture *tex)
Definition: gpu_texture.cc:527
bool GPU_texture_integer(const GPUTexture *tex)
Definition: gpu_texture.cc:569
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:508
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:468
void GPU_texture_unbind(GPUTexture *tex)
Definition: gpu_texture.cc:421
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:250
@ GPU_SRGB8_A8
Definition: GPU_texture.h:122
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:121
@ GPU_RGBA16F
Definition: GPU_texture.h:94
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
Definition: gpu_texture.cc:554
bool GPU_texture_depth(const GPUTexture *tex)
Definition: gpu_texture.cc:559
void GPU_texture_bind(GPUTexture *tex, int unit)
Definition: gpu_texture.cc:415
void GPU_uniformbuf_free(GPUUniformBuf *ubo)
#define GPU_vertbuf_create_with_format(format)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *, uint a_idx, GPUVertBufRaw *access)
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
void IMB_colormanagement_finish_glsl_draw(void)
bool IMB_colormanagement_setup_glsl_draw_from_space(const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, struct ColorSpace *colorspace, float dither, bool predivide, bool do_overlay_merge)
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
void DRW_text_cache_destroy(struct DRWTextStore *dt)
GPUBatch * batch
Definition: drawnode.c:3779
void GPU_offscreen_viewport_data_get(GPUOffScreen *ofs, GPUFrameBuffer **r_fb, GPUTexture **r_color, GPUTexture **r_depth)
int GPU_offscreen_width(const GPUOffScreen *ofs)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
int GPU_offscreen_height(const GPUOffScreen *ofs)
double * GPU_viewport_cache_time_get(GPUViewport *viewport)
Definition: gpu_viewport.c:351
static void gpu_viewport_texture_pool_free(GPUViewport *viewport)
Definition: gpu_viewport.c:418
struct @640::@643 attr_id
void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
Definition: gpu_viewport.c:495
static void gpu_viewport_storage_free(StorageList *stl, int stl_len)
Definition: gpu_viewport.c:961
GPUVertFormat format
Definition: gpu_viewport.c:79
uint pos
Definition: gpu_viewport.c:81
@ GPU_VIEWPORT_STEREO
Definition: gpu_viewport.c:123
@ DO_UPDATE
Definition: gpu_viewport.c:122
static void gpu_viewport_texture_pool_clear_users(GPUViewport *viewport)
Definition: gpu_viewport.c:397
GPUTexture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
Definition: gpu_viewport.c:917
void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
Definition: gpu_viewport.c:867
void GPU_viewport_active_view_set(GPUViewport *viewport, int view)
Definition: gpu_viewport.c:321
void GPU_viewport_colorspace_set(GPUViewport *viewport, ColorManagedViewSettings *view_settings, ColorManagedDisplaySettings *display_settings, float dither)
Definition: gpu_viewport.c:557
void GPU_viewport_draw_to_screen_ex(GPUViewport *viewport, int view, const rcti *rect, bool display_colorspace, bool do_overlay_merge)
Definition: gpu_viewport.c:805
static void gpu_viewport_buffers_free(FramebufferList *fbl, int fbl_len, TextureList *txl, TextureList *txl_stereo, int txl_len)
Definition: gpu_viewport.c:933
static void gpu_viewport_passes_free(PassList *psl, int psl_len)
Definition: gpu_viewport.c:972
void * GPU_viewport_engine_data_get(GPUViewport *viewport, void *engine_handle)
Definition: gpu_viewport.c:294
struct DRWInstanceDataList * GPU_viewport_instance_data_list_get(GPUViewport *viewport)
Definition: gpu_viewport.c:311
GPUTexture * GPU_viewport_texture_pool_query(GPUViewport *viewport, void *engine, int width, int height, int format)
Definition: gpu_viewport.c:360
bool GPU_viewport_engines_data_validate(GPUViewport *viewport, void **engine_handle_array)
Definition: gpu_viewport.c:428
GPUViewport * GPU_viewport_create(void)
Definition: gpu_viewport.c:144
GPUFrameBuffer * GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport)
static GPUBatch * gpu_viewport_batch_create(const rctf *rect_pos, const rctf *rect_uv)
Definition: gpu_viewport.c:694
bool GPU_viewport_do_update(GPUViewport *viewport)
Definition: gpu_viewport.c:137
void GPU_viewport_unbind_from_offscreen(GPUViewport *viewport, struct GPUOffScreen *ofs, bool display_colorspace, bool do_overlay_merge)
Definition: gpu_viewport.c:875
static void gpu_viewport_framebuffer_view_set(GPUViewport *viewport, int view)
Definition: gpu_viewport.c:163
GPUViewport * GPU_viewport_stereo_create(void)
Definition: gpu_viewport.c:156
void * GPU_viewport_texture_list_get(GPUViewport *viewport)
Definition: gpu_viewport.c:331
static void gpu_viewport_default_fb_create(GPUViewport *viewport)
Definition: gpu_viewport.c:449
uint tex_coord
Definition: gpu_viewport.c:81
static const int default_fbl_len
Definition: gpu_viewport.c:51
void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, struct GPUOffScreen *ofs)
Definition: gpu_viewport.c:536
void GPU_viewport_free(GPUViewport *viewport)
Definition: gpu_viewport.c:978
struct ViewportTempTexture ViewportTempTexture
static const int default_txl_len
Definition: gpu_viewport.c:52
void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format)
Definition: gpu_viewport.c:604
static void gpu_viewport_batch_free(GPUViewport *viewport)
Definition: gpu_viewport.c:739
#define MAX_ENABLE_ENGINE
Definition: gpu_viewport.c:54
GPUFrameBuffer * GPU_viewport_framebuffer_default_get(GPUViewport *viewport)
void GPU_viewport_size_set(GPUViewport *viewport, const int size[2])
Definition: gpu_viewport.c:346
void GPU_viewport_tag_update(GPUViewport *viewport)
Definition: gpu_viewport.c:132
void GPU_viewport_unbind(GPUViewport *UNUSED(viewport))
Definition: gpu_viewport.c:911
void * GPU_viewport_framebuffer_list_get(GPUViewport *viewport)
Definition: gpu_viewport.c:326
void GPU_viewport_cache_release(GPUViewport *viewport)
Definition: gpu_viewport.c:439
static void gpu_viewport_draw_colormanaged(GPUViewport *viewport, const rctf *rect_pos, const rctf *rect_uv, bool display_colorspace, bool do_overlay_merge)
Definition: gpu_viewport.c:749
static GPUBatch * gpu_viewport_batch_get(GPUViewport *viewport, const rctf *rect_pos, const rctf *rect_uv)
Definition: gpu_viewport.c:716
#define MAX_ENGINE_BUFFER_SHARING
Definition: gpu_viewport.c:59
void * GPU_viewport_engine_data_create(GPUViewport *viewport, void *engine_type)
Definition: gpu_viewport.c:222
static GPUVertFormat * gpu_viewport_batch_format(void)
Definition: gpu_viewport.c:682
static struct @640 g_viewport
ViewportMemoryPool * GPU_viewport_mempool_get(GPUViewport *viewport)
Definition: gpu_viewport.c:306
static void gpu_viewport_engines_data_free(GPUViewport *viewport)
Definition: gpu_viewport.c:255
void GPU_viewport_size_get(const GPUViewport *viewport, int size[2])
Definition: gpu_viewport.c:336
BLI_INLINE float fb(float length, float L)
format
Definition: logImageCore.h:47
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
return ret
struct CurveMapping * curve_mapping
struct GPUFrameBuffer * overlay_only_fb
struct GPUFrameBuffer * depth_only_fb
struct GPUFrameBuffer * overlay_fb
struct GPUFrameBuffer * stereo_comp_fb
struct GPUFrameBuffer * default_fb
struct GPUFrameBuffer * color_only_fb
struct GPUTexture * depth
struct GPUTexture * color_overlay_stereo
struct GPUTexture * color_overlay
struct GPUTexture * color
struct GPUTexture * color_stereo
struct GPUFrameBuffer * framebuffers[0]
Definition: GPU_viewport.h:67
struct GPUViewportBatch::@642 last_used_parameters
GPUBatch * batch
Definition: gpu_viewport.c:71
ListBase tex_pool
Definition: gpu_viewport.c:105
DefaultFramebufferList * fbl
Definition: gpu_viewport.c:98
DefaultTextureList * txl
Definition: gpu_viewport.c:99
void * handle
Definition: gpu_viewport.c:94
ColorManagedViewSettings view_settings
Definition: gpu_viewport.c:111
struct GPUViewportBatch batch
Definition: gpu_viewport.c:118
ColorManagedDisplaySettings display_settings
Definition: gpu_viewport.c:112
struct GPUViewport::@644 engine_data[MAX_ENABLE_ENGINE]
double cache_time
Definition: gpu_viewport.c:108
ViewportMemoryPool vmempool
Definition: gpu_viewport.c:101
ViewportEngineData * data
Definition: gpu_viewport.c:95
int size[2]
Definition: gpu_viewport.c:86
struct DRWInstanceDataList * idatalist
Definition: gpu_viewport.c:102
CurveMapping * orig_curve_mapping
Definition: gpu_viewport.c:113
bool do_color_management
Definition: gpu_viewport.c:117
void * first
Definition: DNA_listBase.h:47
struct DRWPass * passes[0]
Definition: GPU_viewport.h:75
void * storage[0]
Definition: GPU_viewport.h:79
struct GPUTexture * textures[0]
Definition: GPU_viewport.h:71
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
struct ViewportTempTexture * next
Definition: gpu_viewport.c:62
struct ViewportTempTexture * prev
Definition: gpu_viewport.c:62
GPUTexture * texture
Definition: gpu_viewport.c:64
void * user[MAX_ENGINE_BUFFER_SHARING]
Definition: gpu_viewport.c:63
float xmax
Definition: DNA_vec_types.h:85
float xmin
Definition: DNA_vec_types.h:85
float ymax
Definition: DNA_vec_types.h:86
float ymin
Definition: DNA_vec_types.h:86
int ymin
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
ccl_device_inline int rect_size(int4 rect)
Definition: util_rect.h:65