Blender  V3.3
gpu_viewport.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2006 Blender Foundation. All rights reserved. */
3 
10 #include <string.h>
11 
12 #include "BLI_math_vector.h"
13 #include "BLI_rect.h"
14 
15 #include "BKE_colortools.h"
16 
17 #include "IMB_colormanagement.h"
18 
19 #include "DNA_vec_types.h"
20 
21 #include "GPU_capabilities.h"
22 #include "GPU_framebuffer.h"
23 #include "GPU_immediate.h"
24 #include "GPU_matrix.h"
25 #include "GPU_texture.h"
26 #include "GPU_uniform_buffer.h"
27 #include "GPU_viewport.h"
28 
29 #include "DRW_engine.h"
30 
31 #include "MEM_guardedalloc.h"
32 
33 /* Struct storing a viewport specific GPUBatch.
34  * The end-goal is to have a single batch shared across viewport and use a model matrix to place
35  * the batch. Due to OCIO and Image/UV editor we are not able to use an model matrix yet. */
38  struct {
42 };
43 
44 static struct {
46  struct {
49 } g_viewport = {{0}};
50 
51 struct GPUViewport {
52  int size[2];
53  int flag;
54 
55  /* Set the active view (for stereoscopic viewport rendering). */
57 
58  /* Viewport Resources. */
59  struct DRWData *draw_data;
69 
70  /* Color management. */
74  float dither;
75  /* TODO(fclem): the uvimage display use the viewport but do not set any view transform for the
76  * moment. The end goal would be to let the GPUViewport do the color management. */
78  struct GPUViewportBatch batch;
79 };
80 
81 enum {
82  DO_UPDATE = (1 << 0),
83  GPU_VIEWPORT_STEREO = (1 << 1),
84 };
85 
87 {
88  viewport->flag |= DO_UPDATE;
89 }
90 
92 {
93  bool ret = (viewport->flag & DO_UPDATE);
94  viewport->flag &= ~DO_UPDATE;
95  return ret;
96 }
97 
99 {
100  GPUViewport *viewport = MEM_callocN(sizeof(GPUViewport), "GPUViewport");
101  viewport->do_color_management = false;
102  viewport->size[0] = viewport->size[1] = -1;
103  viewport->active_view = 0;
104  return viewport;
105 }
106 
108 {
109  GPUViewport *viewport = GPU_viewport_create();
110  viewport->flag = GPU_VIEWPORT_STEREO;
111  return viewport;
112 }
113 
115 {
116  return &viewport->draw_data;
117 }
118 
120 {
121  int *size = viewport->size;
122  float empty_pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f};
123 
124  if (viewport->color_render_tx[0] == NULL) {
125  viewport->color_render_tx[0] = GPU_texture_create_2d(
126  "dtxl_color", UNPACK2(size), 1, GPU_RGBA16F, NULL);
128  "dtxl_color_overlay", UNPACK2(size), 1, GPU_SRGB8_A8, NULL);
130  GPU_texture_clear(viewport->color_render_tx[0], GPU_DATA_FLOAT, empty_pixel);
131  GPU_texture_clear(viewport->color_overlay_tx[0], GPU_DATA_FLOAT, empty_pixel);
132  }
133  }
134 
135  if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0 && viewport->color_render_tx[1] == NULL) {
136  viewport->color_render_tx[1] = GPU_texture_create_2d(
137  "dtxl_color_stereo", UNPACK2(size), 1, GPU_RGBA16F, NULL);
139  "dtxl_color_overlay_stereo", UNPACK2(size), 1, GPU_SRGB8_A8, NULL);
141  GPU_texture_clear(viewport->color_render_tx[1], GPU_DATA_FLOAT, empty_pixel);
142  GPU_texture_clear(viewport->color_overlay_tx[1], GPU_DATA_FLOAT, empty_pixel);
143  }
144  }
145 
146  /* Can be shared with GPUOffscreen. */
147  if (viewport->depth_tx == NULL) {
148  viewport->depth_tx = GPU_texture_create_2d(
149  "dtxl_depth", UNPACK2(size), 1, GPU_DEPTH24_STENCIL8, NULL);
150  }
151 
152  if (!viewport->depth_tx || !viewport->color_render_tx[0] || !viewport->color_overlay_tx[0]) {
153  GPU_viewport_free(viewport);
154  }
155 }
156 
158 {
159  GPU_FRAMEBUFFER_FREE_SAFE(viewport->stereo_comp_fb);
160  GPU_FRAMEBUFFER_FREE_SAFE(viewport->overlay_fb);
161 
162  for (int i = 0; i < 2; i++) {
165  }
166 
167  GPU_TEXTURE_FREE_SAFE(viewport->depth_tx);
168 }
169 
170 void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
171 {
172  int rect_size[2];
173  /* add one pixel because of scissor test */
174  rect_size[0] = BLI_rcti_size_x(rect) + 1;
175  rect_size[1] = BLI_rcti_size_y(rect) + 1;
176 
178 
179  if (!equals_v2v2_int(viewport->size, rect_size)) {
180  copy_v2_v2_int(viewport->size, rect_size);
181  gpu_viewport_textures_free(viewport);
183  }
184 
185  viewport->active_view = view;
186 }
187 
189  struct GPUOffScreen *ofs,
190  bool is_xr_surface)
191 {
192  GPUTexture *color, *depth;
194  viewport->size[0] = GPU_offscreen_width(ofs);
195  viewport->size[1] = GPU_offscreen_height(ofs);
196 
197  GPU_offscreen_viewport_data_get(ofs, &fb, &color, &depth);
198 
199  /* XR surfaces will already check for texture size changes and free if necessary (see
200  * #wm_xr_session_surface_offscreen_ensure()), so don't free here as it has a significant
201  * performance impact (leads to texture re-creation in #gpu_viewport_textures_create() every VR
202  * drawing iteration). */
203  if (!is_xr_surface) {
204  gpu_viewport_textures_free(viewport);
205  }
206 
207  /* This is the only texture we can share. */
208  viewport->depth_tx = depth;
209 
211 }
212 
214  ColorManagedViewSettings *view_settings,
215  const ColorManagedDisplaySettings *display_settings,
216  float dither)
217 {
225  if (view_settings->curve_mapping) {
226  if (viewport->view_settings.curve_mapping) {
227  if (view_settings->curve_mapping->changed_timestamp !=
230  }
231  }
232  }
233 
234  if (viewport->orig_curve_mapping != view_settings->curve_mapping) {
235  viewport->orig_curve_mapping = view_settings->curve_mapping;
237  }
238  /* Don't copy the curve mapping already. */
239  CurveMapping *tmp_curve_mapping = view_settings->curve_mapping;
240  CurveMapping *tmp_curve_mapping_vp = viewport->view_settings.curve_mapping;
241  view_settings->curve_mapping = NULL;
242  viewport->view_settings.curve_mapping = NULL;
243 
244  BKE_color_managed_view_settings_copy(&viewport->view_settings, view_settings);
245  /* Restore. */
246  view_settings->curve_mapping = tmp_curve_mapping;
247  viewport->view_settings.curve_mapping = tmp_curve_mapping_vp;
248  /* Only copy curve-mapping if needed. Avoid unneeded OCIO cache miss. */
249  if (tmp_curve_mapping && viewport->view_settings.curve_mapping == NULL) {
251  viewport->view_settings.curve_mapping = BKE_curvemapping_copy(tmp_curve_mapping);
252  }
253 
254  BKE_color_managed_display_settings_copy(&viewport->display_settings, display_settings);
255  viewport->dither = dither;
256  viewport->do_color_management = true;
257 }
258 
260 {
262  /* Early Exit: the other display modes need access to the full screen and cannot be
263  * done from a single viewport. See `wm_stereo.c` */
264  return;
265  }
266  /* The composite framebuffer object needs to be created in the window context. */
267  GPU_framebuffer_ensure_config(
268  &viewport->stereo_comp_fb,
269  {
270  GPU_ATTACHMENT_NONE,
271  /* We need the sRGB attachment to be first for GL_FRAMEBUFFER_SRGB to be turned on.
272  * Note that this is the opposite of what the texture binding is. */
273  GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[0]),
274  GPU_ATTACHMENT_TEXTURE(viewport->color_render_tx[0]),
275  });
276 
277  GPUVertFormat *vert_format = immVertexFormat();
278  uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
280  GPU_matrix_push();
285  int settings = stereo_format->display_mode;
286  if (settings == S3D_DISPLAY_ANAGLYPH) {
287  switch (stereo_format->anaglyph_type) {
289  GPU_color_mask(false, true, true, true);
290  break;
292  GPU_color_mask(true, false, true, true);
293  break;
295  GPU_color_mask(false, false, true, true);
296  break;
297  }
298  }
299  else if (settings == S3D_DISPLAY_INTERLACE) {
300  settings |= stereo_format->interlace_type << 3;
301  SET_FLAG_FROM_TEST(settings, stereo_format->flag & S3D_INTERLACE_SWAP, 1 << 6);
302  }
303  immUniform1i("stereoDisplaySettings", settings);
304 
305  GPU_texture_bind(viewport->color_render_tx[1], 0);
306  GPU_texture_bind(viewport->color_overlay_tx[1], 1);
307 
309 
310  immVertex2f(pos, -1.0f, -1.0f);
311  immVertex2f(pos, 1.0f, -1.0f);
312  immVertex2f(pos, -1.0f, 1.0f);
313  immVertex2f(pos, 1.0f, 1.0f);
314 
315  immEnd();
316 
317  GPU_texture_unbind(viewport->color_render_tx[1]);
318  GPU_texture_unbind(viewport->color_overlay_tx[1]);
319 
322  GPU_matrix_pop();
323 
324  if (settings == S3D_DISPLAY_ANAGLYPH) {
325  GPU_color_mask(true, true, true, true);
326  }
327 
329 }
330 /* -------------------------------------------------------------------- */
335 {
336  if (g_viewport.format.attr_len == 0) {
337  GPUVertFormat *format = &g_viewport.format;
338  g_viewport.attr_id.pos = GPU_vertformat_attr_add(
339  format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
340  g_viewport.attr_id.tex_coord = GPU_vertformat_attr_add(
341  format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
342  }
343  return &g_viewport.format;
344 }
345 
346 static GPUBatch *gpu_viewport_batch_create(const rctf *rect_pos, const rctf *rect_uv)
347 {
349  const uint vbo_len = 4;
350  GPU_vertbuf_data_alloc(vbo, vbo_len);
351 
352  GPUVertBufRaw pos_step, tex_coord_step;
353  GPU_vertbuf_attr_get_raw_data(vbo, g_viewport.attr_id.pos, &pos_step);
354  GPU_vertbuf_attr_get_raw_data(vbo, g_viewport.attr_id.tex_coord, &tex_coord_step);
355 
356  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmin, rect_pos->ymin);
357  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmin, rect_uv->ymin);
358  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmax, rect_pos->ymin);
359  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmax, rect_uv->ymin);
360  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmin, rect_pos->ymax);
361  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmin, rect_uv->ymax);
362  copy_v2_fl2(GPU_vertbuf_raw_step(&pos_step), rect_pos->xmax, rect_pos->ymax);
363  copy_v2_fl2(GPU_vertbuf_raw_step(&tex_coord_step), rect_uv->xmax, rect_uv->ymax);
364 
366 }
367 
369  const rctf *rect_pos,
370  const rctf *rect_uv)
371 {
372  const float compare_limit = 0.0001f;
373  const bool parameters_changed =
375  &viewport->batch.last_used_parameters.rect_pos, rect_pos, compare_limit) ||
376  !BLI_rctf_compare(&viewport->batch.last_used_parameters.rect_uv, rect_uv, compare_limit));
377 
378  if (viewport->batch.batch && parameters_changed) {
379  GPU_batch_discard(viewport->batch.batch);
380  viewport->batch.batch = NULL;
381  }
382 
383  if (!viewport->batch.batch) {
384  viewport->batch.batch = gpu_viewport_batch_create(rect_pos, rect_uv);
385  viewport->batch.last_used_parameters.rect_pos = *rect_pos;
386  viewport->batch.last_used_parameters.rect_uv = *rect_uv;
387  }
388  return viewport->batch.batch;
389 }
390 
391 static void gpu_viewport_batch_free(GPUViewport *viewport)
392 {
393  if (viewport->batch.batch) {
394  GPU_batch_discard(viewport->batch.batch);
395  viewport->batch.batch = NULL;
396  }
397 }
398 
402  int view,
403  const rctf *rect_pos,
404  const rctf *rect_uv,
405  bool display_colorspace,
406  bool do_overlay_merge)
407 {
408  GPUTexture *color = viewport->color_render_tx[view];
409  GPUTexture *color_overlay = viewport->color_overlay_tx[view];
410 
411  bool use_ocio = false;
412 
413  if (viewport->do_color_management && display_colorspace) {
414  /* During the binding process the last used VertexFormat is tested and can assert as it is not
415  * valid. By calling the `immVertexFormat` the last used VertexFormat is reset and the assert
416  * does not happen. This solves a chicken and egg problem when using GPUBatches. GPUBatches
417  * contain the correct vertex format, but can only bind after the shader is bound.
418  *
419  * Image/UV editor still uses imm, after that has been changed we could move this fix to the
420  * OCIO. */
421  immVertexFormat();
423  &viewport->display_settings,
424  NULL,
425  viewport->dither,
426  false,
427  do_overlay_merge);
428  }
429 
430  GPUBatch *batch = gpu_viewport_batch_get(viewport, rect_pos, rect_uv);
431  if (use_ocio) {
433  }
434  else {
436  GPU_batch_uniform_1i(batch, "overlay", do_overlay_merge);
437  GPU_batch_uniform_1i(batch, "display_transform", display_colorspace);
438  }
439 
441  GPU_texture_bind(color_overlay, 1);
444  GPU_texture_unbind(color_overlay);
445 
446  if (use_ocio) {
448  }
449 }
450 
452  int view,
453  const rcti *rect,
454  bool display_colorspace,
455  bool do_overlay_merge)
456 {
457  GPUTexture *color = viewport->color_render_tx[view];
458 
459  if (color == NULL) {
460  return;
461  }
462 
463  const float w = (float)GPU_texture_width(color);
464  const float h = (float)GPU_texture_height(color);
465 
466  /* We allow rects with min/max swapped, but we also need correctly assigned coordinates. */
467  rcti sanitized_rect = *rect;
468  BLI_rcti_sanitize(&sanitized_rect);
469 
470  BLI_assert(w == BLI_rcti_size_x(&sanitized_rect) + 1);
471  BLI_assert(h == BLI_rcti_size_y(&sanitized_rect) + 1);
472 
473  /* wmOrtho for the screen has this same offset */
474  const float halfx = GLA_PIXEL_OFS / w;
475  const float halfy = GLA_PIXEL_OFS / h;
476 
477  rctf pos_rect = {
478  .xmin = sanitized_rect.xmin,
479  .ymin = sanitized_rect.ymin,
480  .xmax = sanitized_rect.xmin + w,
481  .ymax = sanitized_rect.ymin + h,
482  };
483 
484  rctf uv_rect = {
485  .xmin = halfx,
486  .ymin = halfy,
487  .xmax = halfx + 1.0f,
488  .ymax = halfy + 1.0f,
489  };
490  /* Mirror the UV rect in case axis-swapped drawing is requested (by passing a rect with min and
491  * max values swapped). */
492  if (BLI_rcti_size_x(rect) < 0) {
493  SWAP(float, uv_rect.xmin, uv_rect.xmax);
494  }
495  if (BLI_rcti_size_y(rect) < 0) {
496  SWAP(float, uv_rect.ymin, uv_rect.ymax);
497  }
498 
500  viewport, view, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
501 }
502 
503 void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
504 {
505  GPU_viewport_draw_to_screen_ex(viewport, view, rect, true, true);
506 }
507 
509  struct GPUOffScreen *ofs,
510  bool display_colorspace,
511  bool do_overlay_merge)
512 {
513  const int view = 0;
514 
515  if (viewport->color_render_tx[view] == NULL) {
516  return;
517  }
518 
520  GPU_offscreen_bind(ofs, false);
521 
522  rctf pos_rect = {
523  .xmin = -1.0f,
524  .ymin = -1.0f,
525  .xmax = 1.0f,
526  .ymax = 1.0f,
527  };
528 
529  rctf uv_rect = {
530  .xmin = 0.0f,
531  .ymin = 0.0f,
532  .xmax = 1.0f,
533  .ymax = 1.0f,
534  };
535 
537  viewport, view, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
538 
539  /* This one is from the offscreen. Don't free it with the viewport. */
540  viewport->depth_tx = NULL;
541 }
542 
544 {
547 }
548 
550 {
551  return viewport->active_view;
552 }
553 
555 {
556  return (viewport->flag & GPU_VIEWPORT_STEREO) != 0;
557 }
558 
560 {
561  return viewport->color_render_tx[view];
562 }
563 
565 {
566  return viewport->color_overlay_tx[view];
567 }
568 
570 {
571  return viewport->depth_tx;
572 }
573 
575 {
576  GPU_framebuffer_ensure_config(
577  &viewport->overlay_fb,
578  {
579  GPU_ATTACHMENT_TEXTURE(viewport->depth_tx),
580  GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[viewport->active_view]),
581  });
582  return viewport->overlay_fb;
583 }
584 
586 {
587  if (viewport->draw_data) {
589  }
590 
591  gpu_viewport_textures_free(viewport);
592 
594  gpu_viewport_batch_free(viewport);
595 
596  MEM_freeN(viewport);
597 }
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:1856
void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings, const struct ColorManagedViewSettings *settings)
#define BLI_assert(a)
Definition: BLI_assert.h:46
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
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition: BLI_rect.h:190
void BLI_rcti_sanitize(struct rcti *rect)
Definition: rct.c:449
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition: BLI_rect.h:186
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
unsigned int uint
Definition: BLI_sys_types.h:67
#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_viewport_data_free(struct DRWData *drw_data)
Definition: draw_manager.c:440
void DRW_opengl_context_disable(void)
static AppView * view
GPUBatch
Definition: GPU_batch.h:78
void GPU_batch_discard(GPUBatch *)
Definition: gpu_batch.cc:109
void GPU_batch_program_set_imm_shader(GPUBatch *batch)
Definition: gpu_batch.cc:292
void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
Definition: gpu_batch.cc:287
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
Definition: gpu_batch.cc:43
void GPU_batch_draw(GPUBatch *batch)
Definition: gpu_batch.cc:223
@ GPU_BATCH_OWNS_VBO
Definition: GPU_batch.h:30
#define GPU_batch_uniform_1i(batch, name, x)
Definition: GPU_batch.h:142
bool GPU_clear_viewport_workaround(void)
struct GPUFrameBuffer GPUFrameBuffer
void GPU_framebuffer_restore(void)
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)
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:126
void GPU_matrix_identity_projection_set(void)
Definition: gpu_matrix.cc:154
void GPU_matrix_pop_projection(void)
Definition: gpu_matrix.cc:140
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:119
void GPU_matrix_identity_set(void)
Definition: gpu_matrix.cc:168
void GPU_matrix_push_projection(void)
Definition: gpu_matrix.cc:133
@ GPU_PRIM_TRI_STRIP
Definition: GPU_primitive.h:24
@ GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE
Definition: GPU_shader.h:280
@ GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE
Definition: GPU_shader.h:279
void GPU_color_mask(bool r, bool g, bool b, bool a)
Definition: gpu_state.cc:95
@ GPU_DEPTH_NONE
Definition: GPU_state.h:83
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:65
int GPU_texture_height(const GPUTexture *tex)
Definition: gpu_texture.cc:607
void GPU_texture_clear(GPUTexture *tex, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:438
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
int GPU_texture_width(const GPUTexture *tex)
Definition: gpu_texture.cc:602
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:171
void GPU_texture_unbind(GPUTexture *tex)
Definition: gpu_texture.cc:472
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:291
#define GPU_TEXTURE_FREE_SAFE(texture)
Definition: GPU_texture.h:40
@ GPU_SRGB8_A8
Definition: GPU_texture.h:121
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
void GPU_texture_bind(GPUTexture *tex, int unit)
Definition: gpu_texture.cc:466
#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.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
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
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
struct @653::@655 batch
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)
void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
Definition: gpu_viewport.c:170
@ GPU_VIEWPORT_STEREO
Definition: gpu_viewport.c:83
@ DO_UPDATE
Definition: gpu_viewport.c:82
GPUVertFormat format
Definition: gpu_viewport.c:45
uint pos
Definition: gpu_viewport.c:47
struct @680::@683 attr_id
void GPU_viewport_colorspace_set(GPUViewport *viewport, ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float dither)
Definition: gpu_viewport.c:213
GPUTexture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
Definition: gpu_viewport.c:559
void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
Definition: gpu_viewport.c:503
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:451
void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, struct GPUOffScreen *ofs, bool is_xr_surface)
Definition: gpu_viewport.c:188
GPUViewport * GPU_viewport_create(void)
Definition: gpu_viewport.c:98
GPUFrameBuffer * GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport)
Definition: gpu_viewport.c:574
static void gpu_viewport_draw_colormanaged(GPUViewport *viewport, int view, const rctf *rect_pos, const rctf *rect_uv, bool display_colorspace, bool do_overlay_merge)
Definition: gpu_viewport.c:401
static void gpu_viewport_textures_create(GPUViewport *viewport)
Definition: gpu_viewport.c:119
static GPUBatch * gpu_viewport_batch_create(const rctf *rect_pos, const rctf *rect_uv)
Definition: gpu_viewport.c:346
bool GPU_viewport_is_stereo_get(GPUViewport *viewport)
Definition: gpu_viewport.c:554
bool GPU_viewport_do_update(GPUViewport *viewport)
Definition: gpu_viewport.c:91
void GPU_viewport_unbind_from_offscreen(GPUViewport *viewport, struct GPUOffScreen *ofs, bool display_colorspace, bool do_overlay_merge)
Definition: gpu_viewport.c:508
GPUViewport * GPU_viewport_stereo_create(void)
Definition: gpu_viewport.c:107
uint tex_coord
Definition: gpu_viewport.c:47
int GPU_viewport_active_view_get(GPUViewport *viewport)
Definition: gpu_viewport.c:549
static void gpu_viewport_textures_free(GPUViewport *viewport)
Definition: gpu_viewport.c:157
void GPU_viewport_free(GPUViewport *viewport)
Definition: gpu_viewport.c:585
struct DRWData ** GPU_viewport_data_get(GPUViewport *viewport)
Definition: gpu_viewport.c:114
static struct @680 g_viewport
void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format)
Definition: gpu_viewport.c:259
static void gpu_viewport_batch_free(GPUViewport *viewport)
Definition: gpu_viewport.c:391
GPUTexture * GPU_viewport_overlay_texture(GPUViewport *viewport, int view)
Definition: gpu_viewport.c:564
void GPU_viewport_tag_update(GPUViewport *viewport)
Definition: gpu_viewport.c:86
void GPU_viewport_unbind(GPUViewport *UNUSED(viewport))
Definition: gpu_viewport.c:543
static GPUBatch * gpu_viewport_batch_get(GPUViewport *viewport, const rctf *rect_pos, const rctf *rect_uv)
Definition: gpu_viewport.c:368
GPUTexture * GPU_viewport_depth_texture(GPUViewport *viewport)
Definition: gpu_viewport.c:569
static GPUVertFormat * gpu_viewport_batch_format(void)
Definition: gpu_viewport.c:334
BLI_INLINE float fb(float length, float L)
format
Definition: logImageCore.h:38
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
return ret
ccl_device_inline int rect_size(int4 rect)
Definition: rect.h:55
struct CurveMapping * curve_mapping
struct GPUViewportBatch::@682 last_used_parameters
GPUBatch * batch
Definition: gpu_viewport.c:37
GPUTexture * depth_tx
Definition: gpu_viewport.c:64
GPUFrameBuffer * overlay_fb
Definition: gpu_viewport.c:68
ColorManagedViewSettings view_settings
Definition: gpu_viewport.c:71
struct GPUViewportBatch batch
Definition: gpu_viewport.c:78
ColorManagedDisplaySettings display_settings
Definition: gpu_viewport.c:72
float dither
Definition: gpu_viewport.c:74
GPUTexture * color_overlay_tx[2]
Definition: gpu_viewport.c:62
GPUTexture * color_render_tx[2]
Definition: gpu_viewport.c:61
struct DRWData * draw_data
Definition: gpu_viewport.c:59
int size[2]
Definition: gpu_viewport.c:52
GPUFrameBuffer * stereo_comp_fb
Definition: gpu_viewport.c:66
CurveMapping * orig_curve_mapping
Definition: gpu_viewport.c:73
bool do_color_management
Definition: gpu_viewport.c:77
float xmax
Definition: DNA_vec_types.h:69
float xmin
Definition: DNA_vec_types.h:69
float ymax
Definition: DNA_vec_types.h:70
float ymin
Definition: DNA_vec_types.h:70
int ymin
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63