Blender  V3.3
gpu_framebuffer.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "BLI_math_base.h"
11 #include "BLI_utildefines.h"
12 
13 #include "GPU_batch.h"
14 #include "GPU_capabilities.h"
15 #include "GPU_shader.h"
16 #include "GPU_texture.h"
17 
18 #include "gpu_backend.hh"
19 #include "gpu_context_private.hh"
20 #include "gpu_texture_private.hh"
21 
23 
24 namespace blender::gpu {
25 
26 /* -------------------------------------------------------------------- */
30 FrameBuffer::FrameBuffer(const char *name)
31 {
32  if (name) {
33  BLI_strncpy(name_, name, sizeof(name_));
34  }
35  else {
36  name_[0] = '\0';
37  }
38  /* Force config on first use. */
39  dirty_attachments_ = true;
40  dirty_state_ = true;
41 
42  for (GPUAttachment &attachment : attachments_) {
43  attachment.tex = nullptr;
44  attachment.mip = -1;
45  attachment.layer = -1;
46  }
47 }
48 
50 {
51  for (GPUAttachment &attachment : attachments_) {
52  if (attachment.tex != nullptr) {
53  reinterpret_cast<Texture *>(attachment.tex)->detach_from(this);
54  }
55  }
56 
57 #ifndef GPU_NO_USE_PY_REFERENCES
58  if (this->py_ref) {
59  *this->py_ref = nullptr;
60  }
61 #endif
62 }
63 
66 /* -------------------------------------------------------------------- */
71 {
72  if (new_attachment.mip == -1) {
73  return; /* GPU_ATTACHMENT_LEAVE */
74  }
75 
76  if (type >= GPU_FB_MAX_ATTACHMENT) {
77  fprintf(stderr,
78  "GPUFramebuffer: Error: Trying to attach texture to type %d but maximum slot is %d.\n",
81  return;
82  }
83 
84  if (new_attachment.tex) {
85  if (new_attachment.layer > 0) {
86  BLI_assert(GPU_texture_cube(new_attachment.tex) || GPU_texture_array(new_attachment.tex));
87  }
88  if (GPU_texture_stencil(new_attachment.tex)) {
90  }
91  else if (GPU_texture_depth(new_attachment.tex)) {
93  }
94  }
95 
96  GPUAttachment &attachment = attachments_[type];
97 
98  if (attachment.tex == new_attachment.tex && attachment.layer == new_attachment.layer &&
99  attachment.mip == new_attachment.mip) {
100  return; /* Exact same texture already bound here. */
101  }
102  /* Unbind previous and bind new. */
103  /* TODO(fclem): cleanup the casts. */
104  if (attachment.tex) {
105  reinterpret_cast<Texture *>(attachment.tex)->detach_from(this);
106  }
107 
108  attachment = new_attachment;
109 
110  /* Might be null if this is for unbinding. */
111  if (attachment.tex) {
112  reinterpret_cast<Texture *>(attachment.tex)->attach_to(this, type);
113  }
114  else {
115  /* GPU_ATTACHMENT_NONE */
116  }
117 
118  dirty_attachments_ = true;
119 }
120 
122 {
123  attachments_[type] = GPU_ATTACHMENT_NONE;
124  dirty_attachments_ = true;
125 }
126 
127 void FrameBuffer::load_store_config_array(const GPULoadStore *load_store_actions, uint actions_len)
128 {
129  /* Follows attachment structure of GPU_framebuffer_config_array/GPU_framebuffer_ensure_config */
130  const GPULoadStore &depth_action = load_store_actions[0];
131  Span<GPULoadStore> color_attachments(load_store_actions + 1, actions_len - 1);
132 
135  GPU_FB_DEPTH_STENCIL_ATTACHMENT, depth_action.load_action, depth_action.store_action);
136  }
137  if (this->attachments_[GPU_FB_DEPTH_ATTACHMENT].tex) {
139  GPU_FB_DEPTH_ATTACHMENT, depth_action.load_action, depth_action.store_action);
140  }
141 
143  for (const GPULoadStore &actions : color_attachments) {
144  if (this->attachments_[type].tex) {
145  this->attachment_set_loadstore_op(type, actions.load_action, actions.store_action);
146  }
147  ++type;
148  }
149 }
150 
152 {
153  unsigned int total_bits = 0;
154  for (GPUAttachment &attachment : attachments_) {
155  Texture *tex = reinterpret_cast<Texture *>(attachment.tex);
156  if (tex != nullptr) {
157  int bits = to_bytesize(tex->format_get()) * to_component_len(tex->format_get());
158  total_bits += bits;
159  }
160  }
161  return total_bits;
162 }
163 
165  void (*callback)(void *userData, int level),
166  void *userData)
167 {
168  /* Bind to make sure the frame-buffer is up to date. */
169  this->bind(true);
170 
171  /* FIXME(fclem): This assumes all mips are defined which may not be the case. */
172  max_lvl = min_ii(max_lvl, floor(log2(max_ii(width_, height_))));
173 
174  for (int mip_lvl = 1; mip_lvl <= max_lvl; mip_lvl++) {
175  /* Replace attached mip-level for each attachment. */
176  for (GPUAttachment &attachment : attachments_) {
177  Texture *tex = reinterpret_cast<Texture *>(attachment.tex);
178  if (tex != nullptr) {
179  /* Some Intel HDXXX have issue with rendering to a mipmap that is below
180  * the texture GL_TEXTURE_MAX_LEVEL. So even if it not correct, in this case
181  * we allow GL_TEXTURE_MAX_LEVEL to be one level lower. In practice it does work! */
182  int mip_max = (GPU_mip_render_workaround()) ? mip_lvl : (mip_lvl - 1);
183  /* Restrict fetches only to previous level. */
184  tex->mip_range_set(mip_lvl - 1, mip_max);
185  /* Bind next level. */
186  attachment.mip = mip_lvl;
187  }
188  }
189 
190  /* Update the internal attachments and viewport size. */
191  dirty_attachments_ = true;
192  this->bind(true);
193 
194  /* Optimize load-store state. */
196  for (GPUAttachment &attachment : attachments_) {
197  Texture *tex = reinterpret_cast<Texture *>(attachment.tex);
198  if (tex != nullptr) {
200  }
201  ++type;
202  }
203 
204  callback(userData, mip_lvl);
205  }
206 
207  for (GPUAttachment &attachment : attachments_) {
208  if (attachment.tex != nullptr) {
209  /* Reset mipmap level range. */
210  reinterpret_cast<Texture *>(attachment.tex)->mip_range_set(0, max_lvl);
211  /* Reset base level. NOTE: might not be the one bound at the start of this function. */
212  attachment.mip = 0;
213  }
214  }
215  dirty_attachments_ = true;
216 }
217 
220 } // namespace blender::gpu
221 
222 /* -------------------------------------------------------------------- */
226 using namespace blender;
227 using namespace blender::gpu;
228 
230 {
231  /* We generate the FB object later at first use in order to
232  * create the frame-buffer in the right opengl context. */
233  return wrap(GPUBackend::get()->framebuffer_alloc(name));
234 }
235 
237 {
238  delete unwrap(gpu_fb);
239 }
240 
241 /* ---------- Binding ----------- */
242 
244 {
245  const bool enable_srgb = true;
246  unwrap(gpu_fb)->bind(enable_srgb);
247 }
248 
250  const GPULoadStore *load_store_actions,
251  uint actions_len)
252 {
253  /* Bind */
254  GPU_framebuffer_bind(gpu_fb);
255 
256  /* Update load store */
257  FrameBuffer *fb = unwrap(gpu_fb);
258  fb->load_store_config_array(load_store_actions, actions_len);
259 }
260 
262 {
263  const bool enable_srgb = false;
264  unwrap(gpu_fb)->bind(enable_srgb);
265 }
266 
268 {
269  Context *ctx = Context::get();
270 
271  if (buffer == GPU_BACKBUFFER_LEFT) {
272  ctx->back_left->bind(false);
273  }
274  else {
275  ctx->back_right->bind(false);
276  }
277 }
278 
280 {
281  Context::get()->back_left->bind(false);
282 }
283 
285 {
286  Context *ctx = Context::get();
287  return wrap(ctx ? ctx->active_fb : nullptr);
288 }
289 
291 {
292  Context *ctx = Context::get();
293  return wrap(ctx ? ctx->back_left : nullptr);
294 }
295 
297 {
298  return (gpu_fb == GPU_framebuffer_active_get());
299 }
300 
301 /* ---------- Attachment Management ----------- */
302 
303 bool GPU_framebuffer_check_valid(GPUFrameBuffer *gpu_fb, char err_out[256])
304 {
305  return unwrap(gpu_fb)->check(err_out);
306 }
307 
309 {
310  Texture *tex = reinterpret_cast<Texture *>(attachment.tex);
311  GPUAttachmentType type = tex->attachment_type(slot);
312  unwrap(gpu_fb)->attachment_set(type, attachment);
313 }
314 
316 {
317  GPUAttachment attachment = GPU_ATTACHMENT_TEXTURE_MIP(tex, mip);
318  GPU_framebuffer_texture_attach_ex(fb, attachment, slot);
319 }
320 
322  GPUFrameBuffer *fb, GPUTexture *tex, int slot, int layer, int mip)
323 {
324  GPUAttachment attachment = GPU_ATTACHMENT_TEXTURE_LAYER_MIP(tex, layer, mip);
325  GPU_framebuffer_texture_attach_ex(fb, attachment, slot);
326 }
327 
329  GPUFrameBuffer *fb, GPUTexture *tex, int slot, int face, int mip)
330 {
331  GPUAttachment attachment = GPU_ATTACHMENT_TEXTURE_CUBEFACE_MIP(tex, face, mip);
332  GPU_framebuffer_texture_attach_ex(fb, attachment, slot);
333 }
334 
336 {
337  unwrap(tex)->detach_from(unwrap(fb));
338 }
339 
341  const GPUAttachment *config,
342  int config_len)
343 {
344  FrameBuffer *fb = unwrap(gpu_fb);
345 
346  const GPUAttachment &depth_attachment = config[0];
347  Span<GPUAttachment> color_attachments(config + 1, config_len - 1);
348 
349  if (depth_attachment.mip == -1) {
350  /* GPU_ATTACHMENT_LEAVE */
351  }
352  else if (depth_attachment.tex == nullptr) {
353  /* GPU_ATTACHMENT_NONE: Need to clear both targets. */
354  fb->attachment_set(GPU_FB_DEPTH_STENCIL_ATTACHMENT, depth_attachment);
355  fb->attachment_set(GPU_FB_DEPTH_ATTACHMENT, depth_attachment);
356  }
357  else {
358  GPUAttachmentType type = GPU_texture_stencil(depth_attachment.tex) ?
361  fb->attachment_set(type, depth_attachment);
362  }
363 
365  for (const GPUAttachment &attachment : color_attachments) {
366  fb->attachment_set(type, attachment);
367  ++type;
368  }
369 }
370 
371 /* ---------- Viewport & Scissor Region ----------- */
372 
373 void GPU_framebuffer_viewport_set(GPUFrameBuffer *gpu_fb, int x, int y, int width, int height)
374 {
375  int viewport_rect[4] = {x, y, width, height};
376  unwrap(gpu_fb)->viewport_set(viewport_rect);
377 }
378 
379 void GPU_framebuffer_viewport_get(GPUFrameBuffer *gpu_fb, int r_viewport[4])
380 {
381  unwrap(gpu_fb)->viewport_get(r_viewport);
382 }
383 
385 {
386  unwrap(gpu_fb)->viewport_reset();
387 }
388 
389 /* ---------- Frame-buffer Operations ----------- */
390 
392  eGPUFrameBufferBits buffers,
393  const float clear_col[4],
394  float clear_depth,
395  uint clear_stencil)
396 {
397  unwrap(gpu_fb)->clear(buffers, clear_col, clear_depth, clear_stencil);
398 }
399 
400 void GPU_framebuffer_multi_clear(GPUFrameBuffer *gpu_fb, const float (*clear_cols)[4])
401 {
402  unwrap(gpu_fb)->clear_multi(clear_cols);
403 }
404 
405 void GPU_clear_color(float red, float green, float blue, float alpha)
406 {
407  float clear_col[4] = {red, green, blue, alpha};
408  Context::get()->active_fb->clear(GPU_COLOR_BIT, clear_col, 0.0f, 0x0);
409 }
410 
411 void GPU_clear_depth(float depth)
412 {
413  float clear_col[4] = {0};
414  Context::get()->active_fb->clear(GPU_DEPTH_BIT, clear_col, depth, 0x0);
415 }
416 
418  GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, eGPUDataFormat format, void *data)
419 {
420  int rect[4] = {x, y, w, h};
421  unwrap(gpu_fb)->read(GPU_DEPTH_BIT, format, rect, 1, 1, data);
422 }
423 
425  int x,
426  int y,
427  int w,
428  int h,
429  int channels,
430  int slot,
432  void *data)
433 {
434  int rect[4] = {x, y, w, h};
435  unwrap(gpu_fb)->read(GPU_COLOR_BIT, format, rect, channels, slot, data);
436 }
437 
438 /* TODO(fclem): rename to read_color. */
440  int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data)
441 {
442  int rect[4] = {x, y, w, h};
444 }
445 
446 /* TODO(fclem): port as texture operation. */
448  int read_slot,
449  GPUFrameBuffer *gpufb_write,
450  int write_slot,
451  eGPUFrameBufferBits blit_buffers)
452 {
453  FrameBuffer *fb_read = unwrap(gpufb_read);
454  FrameBuffer *fb_write = unwrap(gpufb_write);
455  BLI_assert(blit_buffers != 0);
456 
457  FrameBuffer *prev_fb = Context::get()->active_fb;
458 
459 #ifndef NDEBUG
460  GPUTexture *read_tex, *write_tex;
461  if (blit_buffers & (GPU_DEPTH_BIT | GPU_STENCIL_BIT)) {
462  read_tex = fb_read->depth_tex();
463  write_tex = fb_write->depth_tex();
464  }
465  else {
466  read_tex = fb_read->color_tex(read_slot);
467  write_tex = fb_write->color_tex(write_slot);
468  }
469 
470  if (blit_buffers & GPU_DEPTH_BIT) {
471  BLI_assert(GPU_texture_depth(read_tex) && GPU_texture_depth(write_tex));
472  BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex));
473  }
474  if (blit_buffers & GPU_STENCIL_BIT) {
475  BLI_assert(GPU_texture_stencil(read_tex) && GPU_texture_stencil(write_tex));
476  BLI_assert(GPU_texture_format(read_tex) == GPU_texture_format(write_tex));
477  }
478 #endif
479 
480  fb_read->blit_to(blit_buffers, read_slot, fb_write, write_slot, 0, 0);
481 
482  /* FIXME(@fclem): sRGB is not saved. */
483  prev_fb->bind(true);
484 }
485 
487  int max_lvl,
488  void (*callback)(void *userData, int level),
489  void *userData)
490 {
491  unwrap(gpu_fb)->recursive_downsample(max_lvl, callback, userData);
492 }
493 
494 #ifndef GPU_NO_USE_PY_REFERENCES
496 {
497  return unwrap(gpu_fb)->py_ref;
498 }
499 
501 {
502  BLI_assert(py_ref == nullptr || unwrap(gpu_fb)->py_ref == nullptr);
503  unwrap(gpu_fb)->py_ref = py_ref;
504 }
505 #endif
506 
509 /* -------------------------------------------------------------------- */
515 #define FRAMEBUFFER_STACK_DEPTH 16
516 
517 static struct {
520 } FrameBufferStack = {{nullptr}};
521 
523 {
525  FrameBufferStack.framebuffers[FrameBufferStack.top] = fb;
526  FrameBufferStack.top++;
527 }
528 
530 {
531  BLI_assert(FrameBufferStack.top > 0);
532  FrameBufferStack.top--;
533  return FrameBufferStack.framebuffers[FrameBufferStack.top];
534 }
535 
537 {
538  return FrameBufferStack.top;
539 }
540 
541 #undef FRAMEBUFFER_STACK_DEPTH
542 
545 /* -------------------------------------------------------------------- */
552 #define MAX_CTX_FB_LEN 3
553 
554 struct GPUOffScreen {
555  struct {
559 
562 };
563 
568 {
569  Context *ctx = Context::get();
570  BLI_assert(ctx);
571 
572  for (auto &framebuffer : ofs->framebuffers) {
573  if (framebuffer.fb == nullptr) {
574  framebuffer.ctx = ctx;
575  GPU_framebuffer_ensure_config(&framebuffer.fb,
576  {
577  GPU_ATTACHMENT_TEXTURE(ofs->depth),
578  GPU_ATTACHMENT_TEXTURE(ofs->color),
579  });
580  }
581 
582  if (framebuffer.ctx == ctx) {
583  return framebuffer.fb;
584  }
585  }
586 
587  /* List is full, this should never happen or
588  * it might just slow things down if it happens
589  * regularly. In this case we just empty the list
590  * and start over. This is most likely never going
591  * to happen under normal usage. */
592  BLI_assert(0);
593  printf(
594  "Warning: GPUOffscreen used in more than 3 GPUContext. "
595  "This may create performance drop.\n");
596 
597  for (auto &framebuffer : ofs->framebuffers) {
598  GPU_framebuffer_free(framebuffer.fb);
599  framebuffer.fb = nullptr;
600  }
601 
602  return gpu_offscreen_fb_get(ofs);
603 }
604 
606  int width, int height, bool depth, eGPUTextureFormat format, char err_out[256])
607 {
608  GPUOffScreen *ofs = MEM_cnew<GPUOffScreen>(__func__);
609 
610  /* Sometimes areas can have 0 height or width and this will
611  * create a 1D texture which we don't want. */
612  height = max_ii(1, height);
613  width = max_ii(1, width);
614 
615  ofs->color = GPU_texture_create_2d("ofs_color", width, height, 1, format, nullptr);
616 
617  if (depth) {
619  "ofs_depth", width, height, 1, GPU_DEPTH24_STENCIL8, nullptr);
620  }
621 
622  if ((depth && !ofs->depth) || !ofs->color) {
623  const char error[] = "GPUTexture: Texture allocation failed.";
624  if (err_out) {
625  BLI_snprintf(err_out, 256, error);
626  }
627  else {
628  fprintf(stderr, error);
629  }
630  GPU_offscreen_free(ofs);
631  return nullptr;
632  }
633 
635 
636  /* check validity at the very end! */
637  if (!GPU_framebuffer_check_valid(fb, err_out)) {
638  GPU_offscreen_free(ofs);
639  return nullptr;
640  }
642  return ofs;
643 }
644 
646 {
647  for (auto &framebuffer : ofs->framebuffers) {
648  if (framebuffer.fb) {
649  GPU_framebuffer_free(framebuffer.fb);
650  }
651  }
652  if (ofs->color) {
653  GPU_texture_free(ofs->color);
654  }
655  if (ofs->depth) {
656  GPU_texture_free(ofs->depth);
657  }
658 
659  MEM_freeN(ofs);
660 }
661 
662 void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
663 {
664  if (save) {
667  }
668  unwrap(gpu_offscreen_fb_get(ofs))->bind(false);
669 }
670 
671 void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
672 {
673  GPUFrameBuffer *fb = nullptr;
674  if (restore) {
676  }
677 
678  if (fb) {
680  }
681  else {
683  }
684 }
685 
687 {
688  Context *ctx = Context::get();
689  FrameBuffer *ofs_fb = unwrap(gpu_offscreen_fb_get(ofs));
690  ofs_fb->blit_to(GPU_COLOR_BIT, 0, ctx->active_fb, 0, x, y);
691 }
692 
694 {
696 
697  const int w = GPU_texture_width(ofs->color);
698  const int h = GPU_texture_height(ofs->color);
699 
700  GPUFrameBuffer *ofs_fb = gpu_offscreen_fb_get(ofs);
701  GPU_framebuffer_read_color(ofs_fb, 0, 0, w, h, 4, 0, format, pixels);
702 }
703 
705 {
706  return GPU_texture_width(ofs->color);
707 }
708 
710 {
711  return GPU_texture_height(ofs->color);
712 }
713 
715 {
716  return ofs->color;
717 }
718 
720  GPUFrameBuffer **r_fb,
721  GPUTexture **r_color,
722  GPUTexture **r_depth)
723 {
724  *r_fb = gpu_offscreen_fb_get(ofs);
725  *r_color = ofs->color;
726  *r_depth = ofs->depth;
727 }
728 
#define BLI_assert(a)
Definition: BLI_assert.h:46
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED(x)
#define ELEM(...)
bool GPU_mip_render_workaround(void)
@ GPU_LOADACTION_DONT_CARE
@ GPU_STOREACTION_STORE
struct GPUFrameBuffer GPUFrameBuffer
eGPUFrameBufferBits
@ GPU_DEPTH_BIT
@ GPU_STENCIL_BIT
@ GPU_COLOR_BIT
eGPUBackBuffer
@ GPU_BACKBUFFER_LEFT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_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 blue
_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 green
bool GPU_texture_cube(const GPUTexture *tex)
Definition: gpu_texture.cc:659
int GPU_texture_height(const GPUTexture *tex)
Definition: gpu_texture.cc:607
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
int GPU_texture_width(const GPUTexture *tex)
Definition: gpu_texture.cc:602
eGPUDataFormat
Definition: GPU_texture.h:170
@ GPU_DATA_UBYTE
Definition: GPU_texture.h:174
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:171
bool GPU_texture_array(const GPUTexture *tex)
Definition: gpu_texture.cc:664
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:564
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
eGPUTextureFormat
Definition: GPU_texture.h:83
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
bool GPU_texture_stencil(const GPUTexture *tex)
Definition: gpu_texture.cc:649
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
Definition: gpu_texture.cc:639
bool GPU_texture_depth(const GPUTexture *tex)
Definition: gpu_texture.cc:644
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 producing a negative Combine Generate a color from its red
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 producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
static Context * get()
Definition: gpu_context.cc:82
void attachment_remove(GPUAttachmentType type)
virtual void attachment_set_loadstore_op(GPUAttachmentType type, eGPULoadOp load_action, eGPUStoreOp store_action)=0
virtual void read(eGPUFrameBufferBits planes, eGPUDataFormat format, const int area[4], int channel_len, int slot, void *r_data)=0
virtual void bind(bool enabled_srgb)=0
FrameBuffer(const char *name)
GPUTexture * color_tex(int slot) const
virtual void clear(eGPUFrameBufferBits buffers, const float clear_col[4], float clear_depth, uint clear_stencil)=0
void recursive_downsample(int max_lvl, void(*callback)(void *userData, int level), void *userData)
GPUAttachment attachments_[GPU_FB_MAX_ATTACHMENT]
void load_store_config_array(const GPULoadStore *load_store_actions, uint actions_len)
virtual void blit_to(eGPUFrameBufferBits planes, int src_slot, FrameBuffer *dst, int dst_slot, int dst_offset_x, int dst_offset_y)=0
void attachment_set(GPUAttachmentType type, const GPUAttachment &new_attachment)
static GPUBackend * get()
Definition: gpu_context.cc:292
DEGForeachIDComponentCallback callback
void GPU_framebuffer_bind_loadstore(GPUFrameBuffer *gpu_fb, const GPULoadStore *load_store_actions, uint actions_len)
static struct @659 FrameBufferStack
#define FRAMEBUFFER_STACK_DEPTH
#define MAX_CTX_FB_LEN
void GPU_framebuffer_clear(GPUFrameBuffer *gpu_fb, eGPUFrameBufferBits buffers, const float clear_col[4], float clear_depth, uint clear_stencil)
static GPUFrameBuffer * gpu_offscreen_fb_get(GPUOffScreen *ofs)
void GPU_framebuffer_bind(GPUFrameBuffer *gpu_fb)
void GPU_framebuffer_texture_attach_ex(GPUFrameBuffer *gpu_fb, GPUAttachment attachment, int slot)
void GPU_framebuffer_texture_layer_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int layer, int mip)
void GPU_framebuffer_config_array(GPUFrameBuffer *gpu_fb, const GPUAttachment *config, int config_len)
void GPU_framebuffer_bind_no_srgb(GPUFrameBuffer *gpu_fb)
void GPU_framebuffer_multi_clear(GPUFrameBuffer *gpu_fb, const float(*clear_cols)[4])
void GPU_framebuffer_texture_cubeface_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int face, int mip)
void GPU_framebuffer_free(GPUFrameBuffer *gpu_fb)
void GPU_offscreen_free(GPUOffScreen *ofs)
void GPU_framebuffer_read_color(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, int channels, int slot, eGPUDataFormat format, void *data)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
void GPU_framebuffer_restore()
GPUFrameBuffer * framebuffers[FRAMEBUFFER_STACK_DEPTH]
void GPU_framebuffer_py_reference_set(GPUFrameBuffer *gpu_fb, void **py_ref)
void GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slot, int mip)
GPUOffScreen * GPU_offscreen_create(int width, int height, bool depth, eGPUTextureFormat format, char err_out[256])
void GPU_offscreen_read_pixels(GPUOffScreen *ofs, eGPUDataFormat format, void *pixels)
GPUFrameBuffer * GPU_framebuffer_active_get()
void ** GPU_framebuffer_py_reference_get(GPUFrameBuffer *gpu_fb)
bool GPU_framebuffer_bound(GPUFrameBuffer *gpu_fb)
void GPU_framebuffer_viewport_get(GPUFrameBuffer *gpu_fb, int r_viewport[4])
uint GPU_framebuffer_stack_level_get()
void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *gpu_fb, int max_lvl, void(*callback)(void *userData, int level), void *userData)
void GPU_backbuffer_bind(eGPUBackBuffer buffer)
void GPU_clear_color(float red, float green, float blue, float alpha)
bool GPU_framebuffer_check_valid(GPUFrameBuffer *gpu_fb, char err_out[256])
void GPU_offscreen_viewport_data_get(GPUOffScreen *ofs, GPUFrameBuffer **r_fb, GPUTexture **r_color, GPUTexture **r_depth)
void GPU_framebuffer_texture_detach(GPUFrameBuffer *fb, GPUTexture *tex)
void GPU_offscreen_draw_to_screen(GPUOffScreen *ofs, int x, int y)
void GPU_frontbuffer_read_pixels(int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data)
void GPU_framebuffer_push(GPUFrameBuffer *fb)
int GPU_offscreen_width(const GPUOffScreen *ofs)
void GPU_framebuffer_viewport_reset(GPUFrameBuffer *gpu_fb)
void GPU_framebuffer_blit(GPUFrameBuffer *gpufb_read, int read_slot, GPUFrameBuffer *gpufb_write, int write_slot, eGPUFrameBufferBits blit_buffers)
void GPU_clear_depth(float depth)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
GPUTexture * GPU_offscreen_color_texture(const GPUOffScreen *ofs)
void GPU_framebuffer_viewport_set(GPUFrameBuffer *gpu_fb, int x, int y, int width, int height)
uint top
GPUFrameBuffer * GPU_framebuffer_back_get()
int GPU_offscreen_height(const GPUOffScreen *ofs)
void GPU_framebuffer_read_depth(GPUFrameBuffer *gpu_fb, int x, int y, int w, int h, eGPUDataFormat format, void *data)
GPUFrameBuffer * GPU_framebuffer_pop()
GPUFrameBuffer * GPU_framebuffer_create(const char *name)
@ GPU_FB_DEPTH_STENCIL_ATTACHMENT
@ GPU_FB_MAX_ATTACHMENT
@ GPU_FB_COLOR_ATTACHMENT0
@ GPU_FB_DEPTH_ATTACHMENT
#define GPU_FB_MAX_COLOR_ATTACHMENT
BLI_INLINE float fb(float length, float L)
ccl_global float * buffer
format
Definition: logImageCore.h:38
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
static void error(const char *str)
Definition: meshlaplacian.c:51
static GPUContext * wrap(Context *ctx)
static Context * unwrap(GPUContext *ctx)
static size_t to_bytesize(GPUIndexBufType type)
int to_component_len(eGPUTextureFormat format)
T floor(const T &a)
struct GPUTexture * tex
eGPULoadOp load_action
eGPUStoreOp store_action
GPUTexture * color
GPUTexture * depth
struct GPUOffScreen::@660 framebuffers[MAX_CTX_FB_LEN]
GPUFrameBuffer * fb