Blender V4.3
gpu_viewport.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11#include <cstring>
12
13#include "BLI_math_vector.h"
14#include "BLI_rect.h"
15
16#include "BKE_colortools.hh"
17
19
20#include "DNA_vec_types.h"
21
22#include "GPU_capabilities.hh"
23#include "GPU_framebuffer.hh"
24#include "GPU_immediate.hh"
25#include "GPU_matrix.hh"
26#include "GPU_texture.hh"
27#include "GPU_uniform_buffer.hh"
28#include "GPU_viewport.hh"
29
30#include "DRW_engine.hh"
31
32#include "MEM_guardedalloc.h"
33
34/* Struct storing a viewport specific blender::gpu::Batch.
35 * The end-goal is to have a single batch shared across viewport and use a model matrix to place
36 * the batch. Due to OCIO and Image/UV editor we are not able to use an model matrix yet. */
38 blender::gpu::Batch *batch;
39 struct {
43};
44
45static struct {
47 struct {
50} g_viewport = {{0}};
51
53 int size[2];
54 int flag;
55
56 /* Set the active view (for stereoscopic viewport rendering). */
58
59 /* Viewport Resources. */
62 GPUTexture *color_render_tx[2];
63 GPUTexture *color_overlay_tx[2];
65 GPUTexture *depth_tx;
67 GPUFrameBuffer *stereo_comp_fb;
69 GPUFrameBuffer *overlay_fb;
70
71 /* Color management. */
75 float dither;
76 /* TODO(@fclem): the UV-image display use the viewport but do not set any view transform for the
77 * moment. The end goal would be to let the GPUViewport do the color management. */
80};
81
82enum {
83 DO_UPDATE = (1 << 0),
85};
86
88{
89 viewport->flag |= DO_UPDATE;
90}
91
93{
94 bool ret = (viewport->flag & DO_UPDATE);
95 viewport->flag &= ~DO_UPDATE;
96 return ret;
97}
98
100{
101 GPUViewport *viewport = static_cast<GPUViewport *>(
102 MEM_callocN(sizeof(GPUViewport), "GPUViewport"));
103 viewport->do_color_management = false;
104 viewport->size[0] = viewport->size[1] = -1;
105 viewport->active_view = 0;
106 return viewport;
107}
108
110{
111 GPUViewport *viewport = GPU_viewport_create();
112 viewport->flag = GPU_VIEWPORT_STEREO;
113 return viewport;
114}
115
117{
118 return &viewport->draw_data;
119}
120
122{
123 int *size = viewport->size;
124 float const empty_pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f};
126
127 if (viewport->color_render_tx[0] == nullptr) {
128
129 /* NOTE: dtxl_color texture requires write support as it may be written to by the realtime
130 * compositor. */
131 viewport->color_render_tx[0] = GPU_texture_create_2d("dtxl_color",
132 UNPACK2(size),
133 1,
136 nullptr);
137 viewport->color_overlay_tx[0] = GPU_texture_create_2d(
138 "dtxl_color_overlay", UNPACK2(size), 1, GPU_SRGB8_A8, usage, nullptr);
139
141 GPU_texture_clear(viewport->color_render_tx[0], GPU_DATA_FLOAT, empty_pixel);
142 GPU_texture_clear(viewport->color_overlay_tx[0], GPU_DATA_FLOAT, empty_pixel);
143 }
144 }
145
146 if ((viewport->flag & GPU_VIEWPORT_STEREO) != 0 && viewport->color_render_tx[1] == nullptr) {
147 viewport->color_render_tx[1] = GPU_texture_create_2d("dtxl_color_stereo",
148 UNPACK2(size),
149 1,
152 nullptr);
153 viewport->color_overlay_tx[1] = GPU_texture_create_2d(
154 "dtxl_color_overlay_stereo", UNPACK2(size), 1, GPU_SRGB8_A8, usage, nullptr);
155
157 GPU_texture_clear(viewport->color_render_tx[1], GPU_DATA_FLOAT, empty_pixel);
158 GPU_texture_clear(viewport->color_overlay_tx[1], GPU_DATA_FLOAT, empty_pixel);
159 }
160 }
161
162 /* Can be shared with #GPUOffscreen. */
163 if (viewport->depth_tx == nullptr) {
164 /* Depth texture can be read back by gizmos #view3d_depths_create. */
165 /* Swizzle flag is needed by Workbench Volumes to read the stencil view. */
166 viewport->depth_tx = GPU_texture_create_2d("dtxl_depth",
167 UNPACK2(size),
168 1,
172 nullptr);
174 static int depth_clear = 0;
175 GPU_texture_clear(viewport->depth_tx, GPU_DATA_UINT_24_8, &depth_clear);
176 }
177 }
178
179 if (!viewport->depth_tx || !viewport->color_render_tx[0] || !viewport->color_overlay_tx[0]) {
180 GPU_viewport_free(viewport);
181 }
182}
183
185{
186 GPU_FRAMEBUFFER_FREE_SAFE(viewport->stereo_comp_fb);
187 GPU_FRAMEBUFFER_FREE_SAFE(viewport->overlay_fb);
188
189 for (int i = 0; i < 2; i++) {
190 GPU_TEXTURE_FREE_SAFE(viewport->color_render_tx[i]);
191 GPU_TEXTURE_FREE_SAFE(viewport->color_overlay_tx[i]);
192 }
193
194 GPU_TEXTURE_FREE_SAFE(viewport->depth_tx);
195}
196
197void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
198{
199 int rect_size[2];
200 /* add one pixel because of scissor test */
201 rect_size[0] = BLI_rcti_size_x(rect) + 1;
202 rect_size[1] = BLI_rcti_size_y(rect) + 1;
203
205
206 if (!equals_v2v2_int(viewport->size, rect_size)) {
207 copy_v2_v2_int(viewport->size, rect_size);
210 }
211
212 viewport->active_view = view;
213}
214
215void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool is_xr_surface)
216{
217 GPUTexture *color, *depth;
218 GPUFrameBuffer *fb;
219 viewport->size[0] = GPU_offscreen_width(ofs);
220 viewport->size[1] = GPU_offscreen_height(ofs);
221
222 GPU_offscreen_viewport_data_get(ofs, &fb, &color, &depth);
223
224 /* XR surfaces will already check for texture size changes and free if necessary (see
225 * #wm_xr_session_surface_offscreen_ensure()), so don't free here as it has a significant
226 * performance impact (leads to texture re-creation in #gpu_viewport_textures_create() every VR
227 * drawing iteration). */
228 if (!is_xr_surface) {
230 }
231
232 /* This is the only texture we can share. */
233 viewport->depth_tx = depth;
234
236}
237
239 ColorManagedViewSettings *view_settings,
240 const ColorManagedDisplaySettings *display_settings,
241 float dither)
242{
250 if (view_settings->curve_mapping) {
251 if (viewport->view_settings.curve_mapping) {
252 if (view_settings->curve_mapping->changed_timestamp !=
253 viewport->view_settings.curve_mapping->changed_timestamp)
254 {
255 BKE_color_managed_view_settings_free(&viewport->view_settings);
256 }
257 }
258 }
259
260 if (viewport->orig_curve_mapping != view_settings->curve_mapping) {
261 viewport->orig_curve_mapping = view_settings->curve_mapping;
262 BKE_color_managed_view_settings_free(&viewport->view_settings);
263 }
264 /* Don't copy the curve mapping already. */
265 CurveMapping *tmp_curve_mapping = view_settings->curve_mapping;
266 CurveMapping *tmp_curve_mapping_vp = viewport->view_settings.curve_mapping;
267 view_settings->curve_mapping = nullptr;
268 viewport->view_settings.curve_mapping = nullptr;
269
270 BKE_color_managed_view_settings_copy(&viewport->view_settings, view_settings);
271 /* Restore. */
272 view_settings->curve_mapping = tmp_curve_mapping;
273 viewport->view_settings.curve_mapping = tmp_curve_mapping_vp;
274 /* Only copy curve-mapping if needed. Avoid unneeded OCIO cache miss. */
275 if (tmp_curve_mapping && viewport->view_settings.curve_mapping == nullptr) {
276 BKE_color_managed_view_settings_free(&viewport->view_settings);
277 viewport->view_settings.curve_mapping = BKE_curvemapping_copy(tmp_curve_mapping);
278 }
279
280 BKE_color_managed_display_settings_copy(&viewport->display_settings, display_settings);
281 viewport->dither = dither;
282 viewport->do_color_management = true;
283}
284
286{
288 /* Early Exit: the other display modes need access to the full screen and cannot be
289 * done from a single viewport. See `wm_stereo.cc`. */
290 return;
291 }
292 /* The composite framebuffer object needs to be created in the window context. */
294 &viewport->stereo_comp_fb,
295 {
296 GPU_ATTACHMENT_NONE,
297 /* We need the sRGB attachment to be first for GL_FRAMEBUFFER_SRGB to be turned on.
298 * Note that this is the opposite of what the texture binding is. */
299 GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[0]),
300 GPU_ATTACHMENT_TEXTURE(viewport->color_render_tx[0]),
301 });
302
303 GPUVertFormat *vert_format = immVertexFormat();
305 GPU_framebuffer_bind(viewport->stereo_comp_fb);
311 int settings = stereo_format->display_mode;
312 if (settings == S3D_DISPLAY_ANAGLYPH) {
313 switch (stereo_format->anaglyph_type) {
315 GPU_color_mask(false, true, true, true);
316 break;
318 GPU_color_mask(true, false, true, true);
319 break;
321 GPU_color_mask(false, false, true, true);
322 break;
323 }
324 }
325 else if (settings == S3D_DISPLAY_INTERLACE) {
326 settings |= stereo_format->interlace_type << 3;
327 SET_FLAG_FROM_TEST(settings, stereo_format->flag & S3D_INTERLACE_SWAP, 1 << 6);
328 }
329 immUniform1i("stereoDisplaySettings", settings);
330
331 GPU_texture_bind(viewport->color_render_tx[1], 0);
332 GPU_texture_bind(viewport->color_overlay_tx[1], 1);
333
335
336 immVertex2f(pos, -1.0f, -1.0f);
337 immVertex2f(pos, 1.0f, -1.0f);
338 immVertex2f(pos, -1.0f, 1.0f);
339 immVertex2f(pos, 1.0f, 1.0f);
340
341 immEnd();
342
343 GPU_texture_unbind(viewport->color_render_tx[1]);
344 GPU_texture_unbind(viewport->color_overlay_tx[1]);
345
349
350 if (settings == S3D_DISPLAY_ANAGLYPH) {
351 GPU_color_mask(true, true, true, true);
352 }
353
355}
356/* -------------------------------------------------------------------- */
361{
362 if (g_viewport.format.attr_len == 0) {
366 g_viewport.attr_id.tex_coord = GPU_vertformat_attr_add(
367 format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
368 }
369 return g_viewport.format;
370}
371
372static blender::gpu::Batch *gpu_viewport_batch_create(const rctf *rect_pos, const rctf *rect_uv)
373{
375 const uint vbo_len = 4;
376 GPU_vertbuf_data_alloc(*vbo, vbo_len);
377
378 GPUVertBufRaw pos_step, tex_coord_step;
379 GPU_vertbuf_attr_get_raw_data(vbo, g_viewport.attr_id.pos, &pos_step);
380 GPU_vertbuf_attr_get_raw_data(vbo, g_viewport.attr_id.tex_coord, &tex_coord_step);
381
383 static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), rect_pos->xmin, rect_pos->ymin);
385 static_cast<float *>(GPU_vertbuf_raw_step(&tex_coord_step)), rect_uv->xmin, rect_uv->ymin);
387 static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), rect_pos->xmax, rect_pos->ymin);
389 static_cast<float *>(GPU_vertbuf_raw_step(&tex_coord_step)), rect_uv->xmax, rect_uv->ymin);
391 static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), rect_pos->xmin, rect_pos->ymax);
393 static_cast<float *>(GPU_vertbuf_raw_step(&tex_coord_step)), rect_uv->xmin, rect_uv->ymax);
395 static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), rect_pos->xmax, rect_pos->ymax);
397 static_cast<float *>(GPU_vertbuf_raw_step(&tex_coord_step)), rect_uv->xmax, rect_uv->ymax);
398
400}
401
402static blender::gpu::Batch *gpu_viewport_batch_get(GPUViewport *viewport,
403 const rctf *rect_pos,
404 const rctf *rect_uv)
405{
406 const float compare_limit = 0.0001f;
407 const bool parameters_changed =
409 &viewport->batch.last_used_parameters.rect_pos, rect_pos, compare_limit) ||
410 !BLI_rctf_compare(&viewport->batch.last_used_parameters.rect_uv, rect_uv, compare_limit));
411
412 if (viewport->batch.batch && parameters_changed) {
413 GPU_batch_discard(viewport->batch.batch);
414 viewport->batch.batch = nullptr;
415 }
416
417 if (!viewport->batch.batch) {
418 viewport->batch.batch = gpu_viewport_batch_create(rect_pos, rect_uv);
419 viewport->batch.last_used_parameters.rect_pos = *rect_pos;
420 viewport->batch.last_used_parameters.rect_uv = *rect_uv;
421 }
422 return viewport->batch.batch;
423}
424
426{
427 if (viewport->batch.batch) {
428 GPU_batch_discard(viewport->batch.batch);
429 viewport->batch.batch = nullptr;
430 }
431}
432
436 int view,
437 const rctf *rect_pos,
438 const rctf *rect_uv,
439 bool display_colorspace,
440 bool do_overlay_merge)
441{
442 GPUTexture *color = viewport->color_render_tx[view];
443 GPUTexture *color_overlay = viewport->color_overlay_tx[view];
444
445 bool use_ocio = false;
446 bool use_hdr = GPU_hdr_support() &&
447 ((viewport->view_settings.flag & COLORMANAGE_VIEW_USE_HDR) != 0);
448
449 if (viewport->do_color_management && display_colorspace) {
450 /* During the binding process the last used VertexFormat is tested and can assert as it is not
451 * valid. By calling the `immVertexFormat` the last used VertexFormat is reset and the assert
452 * does not happen. This solves a chicken and egg problem when using GPUBatches. GPUBatches
453 * contain the correct vertex format, but can only bind after the shader is bound.
454 *
455 * Image/UV editor still uses imm, after that has been changed we could move this fix to the
456 * OCIO. */
458 use_ocio = IMB_colormanagement_setup_glsl_draw_from_space(&viewport->view_settings,
459 &viewport->display_settings,
460 nullptr,
461 viewport->dither,
462 false,
463 do_overlay_merge);
464 }
465
466 blender::gpu::Batch *batch = gpu_viewport_batch_get(viewport, rect_pos, rect_uv);
467 if (use_ocio) {
469 }
470 else {
472 GPU_batch_uniform_1i(batch, "overlay", do_overlay_merge);
473 GPU_batch_uniform_1i(batch, "display_transform", display_colorspace);
474 GPU_batch_uniform_1i(batch, "use_hdr", use_hdr);
475 }
476
477 GPU_texture_bind(color, 0);
478 GPU_texture_bind(color_overlay, 1);
480 GPU_texture_unbind(color);
481 GPU_texture_unbind(color_overlay);
482
483 if (use_ocio) {
485 }
486}
487
489 int view,
490 const rcti *rect,
491 bool display_colorspace,
492 bool do_overlay_merge)
493{
494 GPUTexture *color = viewport->color_render_tx[view];
495
496 if (color == nullptr) {
497 return;
498 }
499
500 const float w = float(GPU_texture_width(color));
501 const float h = float(GPU_texture_height(color));
502
503 /* We allow rects with min/max swapped, but we also need correctly assigned coordinates. */
504 rcti sanitized_rect = *rect;
505 BLI_rcti_sanitize(&sanitized_rect);
506
507 BLI_assert(w == BLI_rcti_size_x(&sanitized_rect) + 1);
508 BLI_assert(h == BLI_rcti_size_y(&sanitized_rect) + 1);
509
510 /* wmOrtho for the screen has this same offset */
511 const float halfx = GLA_PIXEL_OFS / w;
512 const float halfy = GLA_PIXEL_OFS / h;
513
514 rctf pos_rect{};
515 pos_rect.xmin = sanitized_rect.xmin;
516 pos_rect.ymin = sanitized_rect.ymin;
517 pos_rect.xmax = sanitized_rect.xmin + w;
518 pos_rect.ymax = sanitized_rect.ymin + h;
519
520 rctf uv_rect{};
521 uv_rect.xmin = halfx;
522 uv_rect.ymin = halfy;
523 uv_rect.xmax = halfx + 1.0f;
524 uv_rect.ymax = halfy + 1.0f;
525
526 /* Mirror the UV rect in case axis-swapped drawing is requested (by passing a rect with min and
527 * max values swapped). */
528 if (BLI_rcti_size_x(rect) < 0) {
529 std::swap(uv_rect.xmin, uv_rect.xmax);
530 }
531 if (BLI_rcti_size_y(rect) < 0) {
532 std::swap(uv_rect.ymin, uv_rect.ymax);
533 }
534
536 viewport, view, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
537}
538
539void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
540{
541 GPU_viewport_draw_to_screen_ex(viewport, view, rect, true, true);
542}
543
545 GPUOffScreen *ofs,
546 bool display_colorspace,
547 bool do_overlay_merge)
548{
549 const int view = 0;
550
551 if (viewport->color_render_tx[view] == nullptr) {
552 return;
553 }
554
556 GPU_offscreen_bind(ofs, false);
557
558 rctf pos_rect{};
559 pos_rect.xmin = -1.0f;
560 pos_rect.ymin = -1.0f;
561 pos_rect.xmax = 1.0f;
562 pos_rect.ymax = 1.0f;
563
564 rctf uv_rect{};
565 uv_rect.xmin = 0.0f;
566 uv_rect.ymin = 0.0f;
567 uv_rect.xmax = 1.0f;
568 uv_rect.ymax = 1.0f;
569
571 viewport, view, &pos_rect, &uv_rect, display_colorspace, do_overlay_merge);
572
573 /* This one is from the offscreen. Don't free it with the viewport. */
574 viewport->depth_tx = nullptr;
575}
576
582
584{
585 return viewport->active_view;
586}
587
589{
590 return (viewport->flag & GPU_VIEWPORT_STEREO) != 0;
591}
592
593GPUTexture *GPU_viewport_color_texture(GPUViewport *viewport, int view)
594{
595 return viewport->color_render_tx[view];
596}
597
598GPUTexture *GPU_viewport_overlay_texture(GPUViewport *viewport, int view)
599{
600 return viewport->color_overlay_tx[view];
601}
602
604{
605 return viewport->depth_tx;
606}
607
609{
611 &viewport->overlay_fb,
612 {
613 GPU_ATTACHMENT_TEXTURE(viewport->depth_tx),
614 GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[viewport->active_view]),
615 });
616 return viewport->overlay_fb;
617}
618
620{
621 if (viewport->draw_data) {
622 DRW_viewport_data_free(viewport->draw_data);
623 }
624
626
627 BKE_color_managed_view_settings_free(&viewport->view_settings);
628 gpu_viewport_batch_free(viewport);
629
630 MEM_freeN(viewport);
631}
void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings, const ColorManagedDisplaySettings *settings)
void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings)
CurveMapping * BKE_curvemapping_copy(const CurveMapping *cumap)
void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings, const ColorManagedViewSettings *settings)
#define BLI_assert(a)
Definition BLI_assert.h:50
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:193
void BLI_rcti_sanitize(struct rcti *rect)
Definition rct.c:450
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:189
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
unsigned int uint
#define UNPACK2(a)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
@ COLORMANAGE_VIEW_USE_HDR
@ S3D_ANAGLYPH_REDCYAN
@ S3D_ANAGLYPH_YELLOWBLUE
@ S3D_ANAGLYPH_GREENMAGENTA
@ S3D_INTERLACE_SWAP
@ S3D_DISPLAY_ANAGLYPH
@ S3D_DISPLAY_INTERLACE
void DRW_gpu_context_disable()
void DRW_gpu_context_enable()
void DRW_viewport_data_free(DRWData *drw_data)
static AppView * view
blender::gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, blender::gpu::VertBuf *vertex_buf, blender::gpu::IndexBuf *index_buf, eGPUBatchFlag owns_flag)
Definition gpu_batch.cc:56
void GPU_batch_discard(blender::gpu::Batch *batch)
void GPU_batch_program_set_imm_shader(blender::gpu::Batch *batch)
void GPU_batch_program_set_builtin(blender::gpu::Batch *batch, eGPUBuiltinShader shader_id)
void GPU_batch_draw(blender::gpu::Batch *batch)
@ GPU_BATCH_OWNS_VBO
Definition GPU_batch.hh:42
#define GPU_batch_uniform_1i(batch, name, x)
Definition GPU_batch.hh:297
bool GPU_hdr_support()
bool GPU_clear_viewport_workaround()
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
int GPU_offscreen_width(const GPUOffScreen *offscreen)
void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save)
void GPU_offscreen_viewport_data_get(GPUOffScreen *offscreen, GPUFrameBuffer **r_fb, GPUTexture **r_color, GPUTexture **r_depth)
void GPU_framebuffer_restore()
int GPU_offscreen_height(const GPUOffScreen *offscreen)
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
#define GPU_framebuffer_ensure_config(_fb,...)
void immEnd()
void immUnbindProgram()
void immVertex2f(uint attr_id, float x, float y)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniform1i(const char *name, int x)
GPUVertFormat * immVertexFormat()
void immBegin(GPUPrimType, uint vertex_len)
void GPU_matrix_identity_projection_set()
void GPU_matrix_identity_set()
void GPU_matrix_push()
void GPU_matrix_push_projection()
void GPU_matrix_pop_projection()
void GPU_matrix_pop()
@ GPU_PRIM_TRI_STRIP
@ GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE
@ GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE
void GPU_color_mask(bool r, bool g, bool b, bool a)
Definition gpu_state.cc:98
@ GPU_DEPTH_NONE
Definition GPU_state.hh:108
void GPU_depth_test(eGPUDepthTest test)
Definition gpu_state.cc:68
int GPU_texture_height(const GPUTexture *texture)
void GPU_texture_bind(GPUTexture *texture, int unit)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
int GPU_texture_width(const GPUTexture *texture)
void GPU_texture_clear(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_unbind(GPUTexture *texture)
@ GPU_DATA_UINT_24_8
@ GPU_DATA_FLOAT
eGPUTextureUsage
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_FORMAT_VIEW
#define GPU_TEXTURE_FREE_SAFE(texture)
@ GPU_SRGB8_A8
@ GPU_DEPTH24_STENCIL8
void GPU_vertbuf_attr_get_raw_data(blender::gpu::VertBuf *, uint a_idx, GPUVertBufRaw *access)
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
#define GLA_PIXEL_OFS
void IMB_colormanagement_finish_glsl_draw()
bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, ColorSpace *from_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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
draw_view in_light_buf[] float
struct @620::@622 batch
void GPU_viewport_bind(GPUViewport *viewport, int view, const rcti *rect)
GPUVertFormat format
uint pos
GPUTexture * GPU_viewport_color_texture(GPUViewport *viewport, int view)
void GPU_viewport_unbind(GPUViewport *)
static const GPUVertFormat & gpu_viewport_batch_format()
void GPU_viewport_unbind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool display_colorspace, bool do_overlay_merge)
void GPU_viewport_colorspace_set(GPUViewport *viewport, ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float dither)
void GPU_viewport_draw_to_screen(GPUViewport *viewport, int view, const rcti *rect)
void GPU_viewport_draw_to_screen_ex(GPUViewport *viewport, int view, const rcti *rect, bool display_colorspace, bool do_overlay_merge)
GPUViewport * GPU_viewport_create()
GPUViewport * GPU_viewport_stereo_create()
static blender::gpu::Batch * gpu_viewport_batch_create(const rctf *rect_pos, const rctf *rect_uv)
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)
void GPU_viewport_bind_from_offscreen(GPUViewport *viewport, GPUOffScreen *ofs, bool is_xr_surface)
static void gpu_viewport_textures_create(GPUViewport *viewport)
bool GPU_viewport_is_stereo_get(GPUViewport *viewport)
bool GPU_viewport_do_update(GPUViewport *viewport)
static blender::gpu::Batch * gpu_viewport_batch_get(GPUViewport *viewport, const rctf *rect_pos, const rctf *rect_uv)
uint tex_coord
int GPU_viewport_active_view_get(GPUViewport *viewport)
static void gpu_viewport_textures_free(GPUViewport *viewport)
void GPU_viewport_free(GPUViewport *viewport)
GPUTexture * GPU_viewport_depth_texture(GPUViewport *viewport)
struct @645::@648 attr_id
void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo_format)
static void gpu_viewport_batch_free(GPUViewport *viewport)
static struct @645 g_viewport
void GPU_viewport_tag_update(GPUViewport *viewport)
GPUFrameBuffer * GPU_viewport_framebuffer_overlay_get(GPUViewport *viewport)
GPUTexture * GPU_viewport_overlay_texture(GPUViewport *viewport, int view)
@ GPU_VIEWPORT_STEREO
@ DO_UPDATE
DRWData ** GPU_viewport_data_get(GPUViewport *viewport)
BLI_INLINE float fb(float length, float L)
format
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
return ret
ccl_device_inline int rect_size(int4 rect)
Definition rect.h:56
struct CurveMapping * curve_mapping
blender::gpu::Batch * batch
struct GPUViewportBatch::@647 last_used_parameters
GPUTexture * depth_tx
GPUFrameBuffer * overlay_fb
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
GPUTexture * color_overlay_tx[2]
GPUTexture * color_render_tx[2]
GPUViewportBatch batch
DRWData * draw_data
GPUFrameBuffer * stereo_comp_fb
CurveMapping * orig_curve_mapping
bool do_color_management
float xmax
float xmin
float ymax
float ymin
int ymin
int xmin