43 attachment.tex =
nullptr;
45 attachment.layer = -1;
52 if (attachment.tex !=
nullptr) {
53 reinterpret_cast<Texture *
>(attachment.tex)->detach_from(
this);
57 #ifndef GPU_NO_USE_PY_REFERENCES
72 if (new_attachment.
mip == -1) {
78 "GPUFramebuffer: Error: Trying to attach texture to type %d but maximum slot is %d.\n",
84 if (new_attachment.
tex) {
85 if (new_attachment.
layer > 0) {
98 if (attachment.
tex == new_attachment.
tex && attachment.
layer == new_attachment.
layer &&
99 attachment.
mip == new_attachment.
mip) {
104 if (attachment.
tex) {
105 reinterpret_cast<Texture *
>(attachment.
tex)->detach_from(
this);
108 attachment = new_attachment;
111 if (attachment.
tex) {
112 reinterpret_cast<Texture *
>(attachment.
tex)->attach_to(
this,
type);
130 const GPULoadStore &depth_action = load_store_actions[0];
153 unsigned int total_bits = 0;
156 if (
tex !=
nullptr) {
165 void (*
callback)(
void *userData,
int level),
174 for (
int mip_lvl = 1; mip_lvl <= max_lvl; mip_lvl++) {
178 if (
tex !=
nullptr) {
184 tex->mip_range_set(mip_lvl - 1, mip_max);
186 attachment.mip = mip_lvl;
198 if (
tex !=
nullptr) {
208 if (attachment.tex !=
nullptr) {
210 reinterpret_cast<Texture *
>(attachment.tex)->mip_range_set(0, max_lvl);
245 const bool enable_srgb =
true;
246 unwrap(gpu_fb)->bind(enable_srgb);
258 fb->load_store_config_array(load_store_actions, actions_len);
263 const bool enable_srgb =
false;
264 unwrap(gpu_fb)->bind(enable_srgb);
305 return unwrap(gpu_fb)->check(err_out);
312 unwrap(gpu_fb)->attachment_set(
type, attachment);
324 GPUAttachment attachment = GPU_ATTACHMENT_TEXTURE_LAYER_MIP(
tex, layer, mip);
331 GPUAttachment attachment = GPU_ATTACHMENT_TEXTURE_CUBEFACE_MIP(
tex, face, mip);
349 if (depth_attachment.
mip == -1) {
352 else if (depth_attachment.
tex ==
nullptr) {
361 fb->attachment_set(
type, depth_attachment);
366 fb->attachment_set(
type, attachment);
376 unwrap(gpu_fb)->viewport_set(viewport_rect);
381 unwrap(gpu_fb)->viewport_get(r_viewport);
386 unwrap(gpu_fb)->viewport_reset();
393 const float clear_col[4],
397 unwrap(gpu_fb)->clear(buffers, clear_col, clear_depth, clear_stencil);
402 unwrap(gpu_fb)->clear_multi(clear_cols);
413 float clear_col[4] = {0};
420 int rect[4] = {
x,
y,
w, h};
434 int rect[4] = {
x,
y,
w, h};
442 int rect[4] = {
x,
y,
w, h};
466 read_tex = fb_read->
color_tex(read_slot);
467 write_tex = fb_write->
color_tex(write_slot);
480 fb_read->
blit_to(blit_buffers, read_slot, fb_write, write_slot, 0, 0);
488 void (*
callback)(
void *userData,
int level),
491 unwrap(gpu_fb)->recursive_downsample(max_lvl,
callback, userData);
494 #ifndef GPU_NO_USE_PY_REFERENCES
497 return unwrap(gpu_fb)->py_ref;
503 unwrap(gpu_fb)->py_ref = py_ref;
515 #define FRAMEBUFFER_STACK_DEPTH 16
541 #undef FRAMEBUFFER_STACK_DEPTH
552 #define MAX_CTX_FB_LEN 3
573 if (framebuffer.fb ==
nullptr) {
574 framebuffer.ctx = ctx;
575 GPU_framebuffer_ensure_config(&framebuffer.fb,
577 GPU_ATTACHMENT_TEXTURE(ofs->depth),
578 GPU_ATTACHMENT_TEXTURE(ofs->color),
582 if (framebuffer.ctx == ctx) {
583 return framebuffer.fb;
594 "Warning: GPUOffscreen used in more than 3 GPUContext. "
595 "This may create performance drop.\n");
599 framebuffer.fb =
nullptr;
623 const char error[] =
"GPUTexture: Texture allocation failed.";
628 fprintf(stderr,
error);
648 if (framebuffer.fb) {
725 *r_color = ofs->
color;
726 *r_depth = ofs->
depth;
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()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
bool GPU_mip_render_workaround(void)
@ GPU_LOADACTION_DONT_CARE
struct GPUFrameBuffer GPUFrameBuffer
_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)
int GPU_texture_height(const GPUTexture *tex)
struct GPUTexture GPUTexture
int GPU_texture_width(const GPUTexture *tex)
bool GPU_texture_array(const GPUTexture *tex)
void GPU_texture_free(GPUTexture *tex)
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
bool GPU_texture_stencil(const GPUTexture *tex)
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex)
bool GPU_texture_depth(const GPUTexture *tex)
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.
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
uint get_bits_per_pixel()
GPUTexture * depth_tex() const
virtual void bind(bool enabled_srgb)=0
char name_[DEBUG_NAME_LEN]
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()
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
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)
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_COLOR_ATTACHMENT0
@ GPU_FB_DEPTH_ATTACHMENT
#define GPU_FB_MAX_COLOR_ATTACHMENT
BLI_INLINE float fb(float length, float L)
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
static void error(const char *str)
static GPUContext * wrap(Context *ctx)
static Context * unwrap(GPUContext *ctx)
static size_t to_bytesize(GPUIndexBufType type)
int to_component_len(eGPUTextureFormat format)
struct GPUOffScreen::@660 framebuffers[MAX_CTX_FB_LEN]