Blender V5.0
gpu_framebuffer.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_math_base.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "GPU_capabilities.hh"
#include "GPU_texture.hh"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
#include "gpu_texture_private.hh"
#include "gpu_framebuffer_private.hh"

Go to the source code of this file.

Classes

struct  GPUOffScreen

Namespaces

namespace  blender
namespace  blender::gpu

Functions

C-API
gpu::FrameBufferGPU_framebuffer_create (const char *name)
void GPU_framebuffer_free (gpu::FrameBuffer *fb)
const char * GPU_framebuffer_get_name (gpu::FrameBuffer *fb)
void GPU_framebuffer_bind (gpu::FrameBuffer *fb)
void GPU_framebuffer_bind_loadstore (gpu::FrameBuffer *fb, const GPULoadStore *load_store_actions, uint actions_len)
void GPU_framebuffer_subpass_transition_array (gpu::FrameBuffer *fb, const GPUAttachmentState *attachment_states, uint attachment_len)
void GPU_framebuffer_bind_no_srgb (gpu::FrameBuffer *fb)
void GPU_backbuffer_bind (GPUBackBuffer back_buffer_type)
void GPU_framebuffer_restore ()
gpu::FrameBufferGPU_framebuffer_active_get ()
gpu::FrameBufferGPU_framebuffer_back_get ()
bool GPU_framebuffer_bound (gpu::FrameBuffer *gpu_fb)
bool GPU_framebuffer_check_valid (gpu::FrameBuffer *gpu_fb, char err_out[256])
static void gpu_framebuffer_texture_attach_ex (gpu::FrameBuffer *gpu_fb, GPUAttachment attachment, int slot)
void GPU_framebuffer_texture_attach (gpu::FrameBuffer *fb, blender::gpu::Texture *tex, int slot, int mip)
void GPU_framebuffer_texture_layer_attach (gpu::FrameBuffer *fb, blender::gpu::Texture *tex, int slot, int layer, int mip)
void GPU_framebuffer_texture_cubeface_attach (gpu::FrameBuffer *fb, blender::gpu::Texture *tex, int slot, int face, int mip)
void GPU_framebuffer_texture_detach (gpu::FrameBuffer *fb, blender::gpu::Texture *tex)
void GPU_framebuffer_config_array (gpu::FrameBuffer *fb, const GPUAttachment *config, int config_len)
void GPU_framebuffer_default_size (gpu::FrameBuffer *gpu_fb, int width, int height)
void GPU_framebuffer_viewport_set (gpu::FrameBuffer *gpu_fb, int x, int y, int width, int height)
void GPU_framebuffer_multi_viewports_set (gpu::FrameBuffer *gpu_fb, const int viewport_rects[GPU_MAX_VIEWPORTS][4])
void GPU_framebuffer_viewport_get (gpu::FrameBuffer *gpu_fb, int r_viewport[4])
void GPU_framebuffer_viewport_reset (gpu::FrameBuffer *gpu_fb)
void GPU_framebuffer_clear (gpu::FrameBuffer *gpu_fb, GPUFrameBufferBits buffers, const float clear_col[4], float clear_depth, uint clear_stencil)
void GPU_framebuffer_clear_color (gpu::FrameBuffer *fb, const float clear_col[4])
void GPU_framebuffer_clear_depth (gpu::FrameBuffer *fb, float clear_depth)
void GPU_framebuffer_clear_color_depth (gpu::FrameBuffer *fb, const float clear_col[4], float clear_depth)
void GPU_framebuffer_clear_stencil (gpu::FrameBuffer *fb, uint clear_stencil)
void GPU_framebuffer_clear_depth_stencil (gpu::FrameBuffer *fb, float clear_depth, uint clear_stencil)
void GPU_framebuffer_clear_color_depth_stencil (gpu::FrameBuffer *fb, const float clear_col[4], float clear_depth, uint clear_stencil)
void GPU_framebuffer_multi_clear (gpu::FrameBuffer *fb, const float(*clear_colors)[4])
void GPU_clear_color (float red, float green, float blue, float alpha)
void GPU_clear_depth (float depth)
void GPU_framebuffer_read_depth (gpu::FrameBuffer *fb, int x, int y, int w, int h, eGPUDataFormat format, void *data)
void GPU_framebuffer_read_color (gpu::FrameBuffer *fb, int x, int y, int w, int h, int channels, int slot, eGPUDataFormat format, void *data)
void GPU_frontbuffer_read_color (int x, int y, int w, int h, int channels, eGPUDataFormat format, void *data)
void GPU_framebuffer_blit (gpu::FrameBuffer *fb_read, int read_slot, gpu::FrameBuffer *fb_write, int write_slot, GPUFrameBufferBits blit_buffers)
void ** GPU_framebuffer_py_reference_get (gpu::FrameBuffer *fb)
void GPU_framebuffer_py_reference_set (gpu::FrameBuffer *fb, void **py_ref)
GPUOffScreen

Container that holds a frame-buffer and its textures. Might be bound to multiple contexts.

static gpu::FrameBuffergpu_offscreen_fb_get (GPUOffScreen *ofs)
GPUOffScreenGPU_offscreen_create (int width, int height, bool with_depth_buffer, blender::gpu::TextureFormat format, eGPUTextureUsage usage, bool clear, char err_out[256])
void GPU_offscreen_free (GPUOffScreen *offscreen)
void GPU_offscreen_bind (GPUOffScreen *offscreen, bool save)
void GPU_offscreen_unbind (GPUOffScreen *, bool restore)
void GPU_offscreen_draw_to_screen (GPUOffScreen *offscreen, int x, int y)
void GPU_offscreen_read_color_region (GPUOffScreen *offscreen, eGPUDataFormat format, int x, int y, int w, int h, void *r_data)
void GPU_offscreen_read_color (GPUOffScreen *offscreen, eGPUDataFormat format, void *r_data)
int GPU_offscreen_width (const GPUOffScreen *offscreen)
int GPU_offscreen_height (const GPUOffScreen *offscreen)
blender::gpu::TextureGPU_offscreen_color_texture (const GPUOffScreen *offscreen)
blender::gpu::TextureFormat GPU_offscreen_format (const GPUOffScreen *offscreen)
void GPU_offscreen_viewport_data_get (GPUOffScreen *offscreen, gpu::FrameBuffer **r_fb, blender::gpu::Texture **r_color, blender::gpu::Texture **r_depth)

Frame-Buffer Stack

Keeps track of frame-buffer binding operation to restore previously bound frame-buffers.

#define FRAMEBUFFER_STACK_DEPTH   16
struct { 
   gpu::FrameBuffer *   framebuffers [FRAMEBUFFER_STACK_DEPTH
   uint   top 
FrameBufferStack = {{nullptr}}
void GPU_framebuffer_push (gpu::FrameBuffer *fb)
gpu::FrameBufferGPU_framebuffer_pop ()
uint GPU_framebuffer_stack_level_get ()

Macro Definition Documentation

◆ FRAMEBUFFER_STACK_DEPTH

#define FRAMEBUFFER_STACK_DEPTH   16

Definition at line 576 of file gpu_framebuffer.cc.

Referenced by GPU_framebuffer_push().

Function Documentation

◆ GPU_backbuffer_bind()

void GPU_backbuffer_bind ( GPUBackBuffer back_buffer_type)

Binds the active context's window frame-buffer. Note that GPU_BACKBUFFER_RIGHT is only available if the window was created using stereo-view.

Definition at line 274 of file gpu_framebuffer.cc.

References blender::gpu::Context::back_left, blender::gpu::Context::back_right, blender::gpu::FrameBuffer::bind(), blender::gpu::Context::get(), and GPU_BACKBUFFER_LEFT.

Referenced by wm_draw_window().

◆ GPU_clear_color()

void GPU_clear_color ( float red,
float green,
float blue,
float alpha )

Clear all color attachment textures of the active frame-buffer with the given red, green, blue, alpha values.

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended. DEPRECATED: Use GPU_framebuffer_clear_color with explicit frame-buffer.

Definition at line 470 of file gpu_framebuffer.cc.

References blender::gpu::Context::active_fb, BLI_assert_msg, blender::gpu::FrameBuffer::clear(), blender::gpu::Context::get(), and GPU_COLOR_BIT.

Referenced by blender::ed::space_node::draw_background_color(), DRW_draw_render_loop_offscreen(), ED_region_clear(), hud_region_draw(), blender::ed::greasepencil::image_render::image_render_begin(), playanim_toscreen_ex(), region_clear_fully_transparent(), region_draw_status_text(), screen_opengl_render_doit(), UI_ThemeClearColor(), wm_draw_window_offscreen(), wm_draw_window_onscreen(), wm_main_playanim_intern(), and wm_window_ghostwindow_add().

◆ GPU_clear_depth()

void GPU_clear_depth ( float depth)

Clear the depth attachment texture of the active frame-buffer with the given depth value.

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended. DEPRECATED: Use GPU_framebuffer_clear_color with explicit frame-buffer.

Definition at line 479 of file gpu_framebuffer.cc.

References blender::gpu::Context::active_fb, BLI_assert_msg, blender::gpu::FrameBuffer::clear(), blender::gpu::Context::get(), and GPU_DEPTH_BIT.

Referenced by gpu_select_pick_begin(), gpu_select_pick_load_id(), gpu_select_query_begin(), blender::ed::greasepencil::image_render::image_render_begin(), screen_opengl_render_doit(), and wm_xr_draw_view().

◆ GPU_framebuffer_active_get()

◆ GPU_framebuffer_back_get()

gpu::FrameBuffer * GPU_framebuffer_back_get ( )

◆ GPU_framebuffer_bind()

void GPU_framebuffer_bind ( blender::gpu::FrameBuffer * fb)

Binds a #FrameBuffer making it the active framebuffer for all geometry rendering.

Definition at line 239 of file gpu_framebuffer.cc.

References fb().

Referenced by blender::eevee::Film::accumulate(), blender::draw::gpencil::Instance::antialiasing_accumulate(), blender::draw::edit_select::Instance::begin_sync(), blender::draw::Framebuffer::bind(), blender::eevee::GBuffer::bind(), blender::render::hydra::GPURenderTaskDelegate::bind(), blender::gpu::GLTexture::clear(), blender::gpu::MTLTexture::clear(), blender::eevee::DeferredPipeline::debug_draw(), blender::eevee::HiZBuffer::debug_draw(), blender::eevee::LightModule::debug_draw(), blender::eevee::ShadowModule::debug_draw(), blender::eevee::Film::display(), blender::eevee::LookdevModule::display(), blender::draw::edit_select::Instance::draw(), blender::draw::gpencil::Instance::draw(), blender::draw::overlay::Facing::draw(), blender::draw::overlay::Fade::draw(), blender::draw::overlay::MeshUVs::draw(), blender::draw::overlay::ModeTransfer::draw(), blender::draw::overlay::Paints::draw(), blender::draw::overlay::Particles::draw(), blender::draw::overlay::Text::draw(), blender::draw::overlay::Cameras::draw_background_images(), blender::draw::overlay::Empties::draw_background_images(), blender::draw::overlay::Curves::draw_color_only(), blender::draw::overlay::GreasePencil::draw_color_only(), blender::draw::overlay::Grid::draw_color_only(), blender::draw::overlay::LightProbes::draw_color_only(), blender::draw::overlay::Meshes::draw_color_only(), blender::draw::overlay::MotionPath::draw_color_only(), blender::draw::overlay::Origins::draw_color_only(), blender::draw::overlay::XrayFade::draw_color_only(), blender::draw::overlay::Empties::draw_images(), blender::draw::overlay::Cameras::draw_in_front(), blender::draw::overlay::Empties::draw_in_front_images(), blender::draw::overlay::Armatures::draw_line(), blender::draw::overlay::AttributeViewer::draw_line(), blender::draw::overlay::Axes::draw_line(), blender::draw::overlay::Bounds::draw_line(), blender::draw::overlay::Cameras::draw_line(), blender::draw::overlay::Curves::draw_line(), blender::draw::overlay::Empties::draw_line(), blender::draw::overlay::Fluids::draw_line(), blender::draw::overlay::ForceFields::draw_line(), blender::draw::overlay::GreasePencil::draw_line(), blender::draw::overlay::Lattices::draw_line(), blender::draw::overlay::LightProbes::draw_line(), blender::draw::overlay::Lights::draw_line(), blender::draw::overlay::Meshes::draw_line(), blender::draw::overlay::Metaballs::draw_line(), blender::draw::overlay::Particles::draw_line(), blender::draw::overlay::PointClouds::draw_line(), blender::draw::overlay::Prepass::draw_line(), blender::draw::overlay::Relations::draw_line(), blender::draw::overlay::Sculpts::draw_line(), blender::draw::overlay::Speakers::draw_line(), blender::draw::overlay::Wireframe::draw_line(), blender::draw::overlay::Outline::draw_line_only_ex(), blender::draw::overlay::ImagePrepass::draw_on_render(), blender::draw::overlay::MeshUVs::draw_on_render(), blender::draw::overlay::Sculpts::draw_on_render(), blender::draw::overlay::Cursor::draw_output(), blender::ed::vse::draw_registered_callbacks(), blender::draw::overlay::Cameras::draw_scene_background_images(), blender::ed::vse::draw_timeline_post_view_callbacks(), blender::ed::vse::draw_timeline_pre_view_callbacks(), blender::image_engine::ScreenSpaceDrawingMode::draw_viewport(), drw_callbacks_post_scene(), drw_callbacks_post_scene_2D(), DRW_draw_depth_loop(), drw_draw_render_loop_2d(), drw_draw_render_loop_3d(), DRW_draw_select_loop(), DRW_select_buffer_read(), ED_region_do_draw(), ED_view3d_draw_offscreen_imbuf(), blender::draw::command::FramebufferBind::execute(), gizmo_find_intersected_3d(), GPU_offscreen_create(), GPU_offscreen_unbind(), blender::gpu::tests::gpu_shader_lib_test(), GPU_viewport_stereo_composite(), blender::ed::vse::preview_draw_color_render_begin(), pygpu_framebuffer_stack_pop_and_restore_or_error(), pygpu_framebuffer_stack_push_and_bind_or_error(), blender::eevee::BackgroundPipeline::render(), blender::eevee::DeferredLayer::render(), blender::eevee::DeferredProbePipeline::render(), blender::eevee::DepthOfField::render(), blender::eevee::PlanarProbePipeline::render(), blender::eevee::ShadingView::render(), blender::render::hydra::ViewportEngine::render(), blender::draw::gpencil::render_init_buffers(), blender::eevee::CaptureView::render_probes(), blender::draw::gpencil::render_result_combined(), blender::draw::gpencil::render_result_separated_pass(), blender::eevee::CaptureView::render_world(), blender::ed::vse::sequencer_ibuf_get(), blender::eevee::ShadowModule::set_view(), blender::gpu::tests::test_framebuffer_clear_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_clear_color_single_attachment(), blender::gpu::tests::test_framebuffer_clear_depth(), blender::gpu::tests::test_framebuffer_clear_multiple_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_cube(), blender::gpu::tests::test_framebuffer_multi_viewport(), blender::gpu::tests::test_framebuffer_scissor_test(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::ed::vse::update_gpu_scopes(), blender::gpu::tests::ShaderSpecializationConst::validate(), view3d_gpu_read_Z_pixels(), write_render_color_output(), and write_render_z_output().

◆ GPU_framebuffer_bind_loadstore()

void GPU_framebuffer_bind_loadstore ( blender::gpu::FrameBuffer * fb,
const GPULoadStore * load_store_actions,
uint load_store_actions_len )

Load store config array (load_store_actions) matches attachment structure of GPU_framebuffer_config_array. This allows us to explicitly specify whether attachment data needs to be loaded and stored on a per-attachment basis. This enables a number of bandwidth optimizations:

  • No need to load contents if subsequent work is over-writing every pixel.
  • No need to store attachments whose contents are not used beyond this pass e.g. depth buffer.
  • State can be customized at bind-time rather than applying to the frame-buffer object as a whole.

NOTE: Using GPU_framebuffer_clear_* functions in conjunction with a custom load-store configuration is invalid. Instead, utilize GPU_LOADACTION_CLEAR and provide a clear color as the third parameter in GPULoadStore action.

For Color attachments: {GPU_LOADACTION_CLEAR, GPU_STOREACTION_STORE, {Rf, Gf, Bf, Af}} For Depth attachments: {GPU_LOADACTION_CLEAR, GPU_STOREACTION_STORE, {Df}}

Example:

{GPU_LOADACTION_LOAD, GPU_STOREACTION_STORE}, // Color attachment 0
})
@ GPU_LOADACTION_LOAD
@ GPU_LOADACTION_DONT_CARE
@ GPU_STOREACTION_STORE
@ GPU_STOREACTION_DONT_CARE
void GPU_framebuffer_bind_loadstore(blender::gpu::FrameBuffer *fb, const GPULoadStore *load_store_actions, uint load_store_actions_len)
BLI_INLINE float fb(float length, float L)

Definition at line 247 of file gpu_framebuffer.cc.

References fb().

◆ GPU_framebuffer_bind_no_srgb()

◆ GPU_framebuffer_blit()

void GPU_framebuffer_blit ( blender::gpu::FrameBuffer * fb_read,
int read_slot,
blender::gpu::FrameBuffer * fb_write,
int write_slot,
GPUFrameBufferBits blit_buffers )

Copy the content of fb_read attachments to the fb_read attachments. The attachments types are chosen by blit_buffers . Only one color buffer can by copied at a time and its index is chosen by read_slot and write_slot. The source and destination frame-buffers dimensions have to match. DEPRECATED: Prefer using GPU_texture_copy().

Definition at line 517 of file gpu_framebuffer.cc.

References blender::gpu::Context::active_fb, blender::gpu::FrameBuffer::bind(), BLI_assert, blender::gpu::FrameBuffer::blit_to(), blender::gpu::FrameBuffer::color_tex(), blender::gpu::FrameBuffer::depth_tex(), blender::gpu::Context::get(), GPU_DEPTH_BIT, GPU_STENCIL_BIT, GPU_texture_format(), GPU_texture_has_depth_format(), and GPU_texture_has_stencil_format().

◆ GPU_framebuffer_bound()

bool GPU_framebuffer_bound ( blender::gpu::FrameBuffer * fb)

Return true if framebuffer is the active framebuffer of the active context.

Note
return false if no context is active.
this is undefined behavior if framebuffer is nullptr. DEPRECATED: Kept only because of Python GPU API.

Definition at line 303 of file gpu_framebuffer.cc.

References GPU_framebuffer_active_get().

Referenced by pygpu_framebuffer_clear(), pygpu_framebuffer_is_bound(), and pygpu_framebuffer_stack_pop_and_restore_or_error().

◆ GPU_framebuffer_check_valid()

bool GPU_framebuffer_check_valid ( blender::gpu::FrameBuffer * fb,
char err_out[256] )

Checks a framebuffer current configuration for errors. Checks for texture size mismatch, incompatible attachment, incomplete textures etc...

Note
This binds the framebuffer to the active context. err_out is an error output buffer.
Returns
false if the framebuffer is invalid.

Definition at line 310 of file gpu_framebuffer.cc.

References blender::gpu::FrameBuffer::check().

Referenced by draw_select_framebuffer_depth_only_setup(), GPU_offscreen_create(), and workbench_render_framebuffers_init().

◆ GPU_framebuffer_clear()

void GPU_framebuffer_clear ( blender::gpu::FrameBuffer * fb,
GPUFrameBufferBits buffers,
const float clear_col[4],
float clear_depth,
unsigned int clear_stencil )

Clear the frame-buffer attachments. buffers controls the types of attachments to clear. Setting GPU_COLOR_BIT will clear all the color attachment. Each attachment gets cleared to the value of its type:

  • color attachments gets cleared to clear_col .
  • depth attachment gets cleared to clear_depth .
  • stencil attachment gets cleared to clear_stencil .
Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended.

Definition at line 412 of file gpu_framebuffer.cc.

References BLI_assert_msg, buffers, blender::gpu::FrameBuffer::clear(), and blender::gpu::FrameBuffer::get_use_explicit_loadstore().

Referenced by blender::draw::command::Clear::execute(), GPU_framebuffer_clear_color(), GPU_framebuffer_clear_color_depth(), GPU_framebuffer_clear_color_depth_stencil(), GPU_framebuffer_clear_depth(), GPU_framebuffer_clear_depth_stencil(), GPU_framebuffer_clear_stencil(), and pygpu_framebuffer_clear().

◆ GPU_framebuffer_clear_color()

◆ GPU_framebuffer_clear_color_depth()

void GPU_framebuffer_clear_color_depth ( blender::gpu::FrameBuffer * fb,
const float clear_col[4],
float clear_depth )

Clear all color attachment textures with the value clear_col and the depth attachment texture with the value clear_depth .

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended.

Definition at line 434 of file gpu_framebuffer.cc.

References fb(), GPU_COLOR_BIT, GPU_DEPTH_BIT, and GPU_framebuffer_clear().

Referenced by blender::draw::edit_select::Instance::begin_sync(), blender::render::hydra::GPURenderTaskDelegate::bind(), blender::eevee::Instance::draw_viewport(), GPU_offscreen_create(), blender::eevee::ShadingView::render(), and blender::eevee::CaptureView::render_probes().

◆ GPU_framebuffer_clear_color_depth_stencil()

void GPU_framebuffer_clear_color_depth_stencil ( blender::gpu::FrameBuffer * fb,
const float clear_col[4],
float clear_depth,
uint clear_stencil )

Clear the depth attachment texture with the value clear_depth , the stencil attachment with the value clear_stencil and all the color attachments with the value clear_col .

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended.

Definition at line 453 of file gpu_framebuffer.cc.

References fb(), GPU_COLOR_BIT, GPU_DEPTH_BIT, GPU_framebuffer_clear(), and GPU_STENCIL_BIT.

◆ GPU_framebuffer_clear_depth()

void GPU_framebuffer_clear_depth ( blender::gpu::FrameBuffer * fb,
float clear_depth )

Clear the depth attachment texture with the value clear_depth .

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended.

Definition at line 429 of file gpu_framebuffer.cc.

References fb(), GPU_DEPTH_BIT, and GPU_framebuffer_clear().

Referenced by blender::draw::Framebuffer::clear_depth(), blender::draw::edit_select::Instance::draw(), DRW_draw_depth_loop(), DRW_draw_select_loop(), blender::eevee::PlanarProbePipeline::render(), blender::draw::gpencil::render_init_buffers(), and blender::gpu::tests::test_framebuffer_clear_depth().

◆ GPU_framebuffer_clear_depth_stencil()

void GPU_framebuffer_clear_depth_stencil ( blender::gpu::FrameBuffer * fb,
float clear_depth,
uint clear_stencil )

Clear the depth attachment texture with the value clear_depth and the stencil attachment with the value clear_stencil .

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended.

Definition at line 446 of file gpu_framebuffer.cc.

References fb(), GPU_DEPTH_BIT, GPU_framebuffer_clear(), and GPU_STENCIL_BIT.

Referenced by blender::workbench::Instance::draw(), drw_draw_render_loop_2d(), and drw_draw_render_loop_3d().

◆ GPU_framebuffer_clear_stencil()

void GPU_framebuffer_clear_stencil ( blender::gpu::FrameBuffer * fb,
uint clear_stencil )

Clear the stencil attachment with the value clear_stencil .

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended.

Definition at line 441 of file gpu_framebuffer.cc.

References fb(), GPU_framebuffer_clear(), and GPU_STENCIL_BIT.

Referenced by blender::eevee::GBuffer::bind(), and blender::workbench::OpaquePass::draw().

◆ GPU_framebuffer_config_array()

void GPU_framebuffer_config_array ( blender::gpu::FrameBuffer * fb,
const GPUAttachment * config,
int config_len )

First GPUAttachment in *config is always the depth/depth_stencil buffer. Following #GPUAttachments are color buffers. Setting GPUAttachment.mip to -1 will leave the texture in this slot. Setting GPUAttachment.tex to nullptr will detach the texture in this slot.

Definition at line 352 of file gpu_framebuffer.cc.

References fb(), GPU_FB_COLOR_ATTACHMENT0, GPU_FB_DEPTH_ATTACHMENT, GPU_FB_DEPTH_STENCIL_ATTACHMENT, GPU_texture_has_stencil_format(), GPUAttachment::mip, and GPUAttachment::tex.

Referenced by blender::draw::Framebuffer::ensure(), and pygpu_framebuffer__tp_new().

◆ GPU_framebuffer_create()

◆ GPU_framebuffer_default_size()

void GPU_framebuffer_default_size ( blender::gpu::FrameBuffer * fb,
int width,
int height )

Default size is used if the frame-buffer contains no attachments. It needs to be re-specified each time an attachment is added.

Definition at line 381 of file gpu_framebuffer.cc.

References blender::gpu::FrameBuffer::default_size_set().

Referenced by blender::draw::Framebuffer::ensure(), and blender::gpu::tests::ShaderSpecializationConst::validate().

◆ GPU_framebuffer_free()

◆ GPU_framebuffer_get_name()

const char * GPU_framebuffer_get_name ( gpu::FrameBuffer * fb)

Definition at line 232 of file gpu_framebuffer.cc.

References fb().

Referenced by blender::draw::command::FramebufferBind::serialize().

◆ GPU_framebuffer_multi_clear()

void GPU_framebuffer_multi_clear ( blender::gpu::FrameBuffer * fb,
const float(*) clear_colors[4] )

Clear each color attachment texture attached to this frame-buffer with a different color. IMPORTANT: The size of clear_colors must match the number of color attachments.

Note
GPU_write_mask, and stencil test do not affect this command.
Viewport and scissor regions affect this command but are not efficient nor recommended.

Definition at line 462 of file gpu_framebuffer.cc.

References BLI_assert_msg, and fb().

Referenced by blender::draw::gpencil::Instance::draw(), blender::workbench::Instance::draw(), blender::draw::command::ClearMulti::execute(), and blender::gpu::tests::test_framebuffer_clear_multiple_color_multiple_attachments().

◆ GPU_framebuffer_multi_viewports_set()

void GPU_framebuffer_multi_viewports_set ( blender::gpu::FrameBuffer * gpu_fb,
const int viewport_rects[GPU_MAX_VIEWPORTS][4] )

Similar to GPU_framebuffer_viewport_set() but specify the bounds of all 16 viewports. By default geometry renders only to the first viewport. That can be changed by setting gpu_ViewportIndex in the vertex.

Note
Viewport and scissor size is stored per frame-buffer.
Must be called after first bind.

Definition at line 394 of file gpu_framebuffer.cc.

References GPU_MAX_VIEWPORTS, and blender::gpu::FrameBuffer::viewport_multi_set().

Referenced by blender::eevee::ShadowModule::set_view(), and blender::gpu::tests::test_framebuffer_multi_viewport().

◆ GPU_framebuffer_pop()

gpu::FrameBuffer * GPU_framebuffer_pop ( )

◆ GPU_framebuffer_push()

void GPU_framebuffer_push ( blender::gpu::FrameBuffer * fb)

Keep a stack of bound frame-buffer to allow scoped binding of frame-buffer in python. This is also used by GPUOffScreen to save/restore the current frame-buffers.

Note
This isn't thread safe.

Definition at line 583 of file gpu_framebuffer.cc.

References BLI_assert, fb(), FRAMEBUFFER_STACK_DEPTH, and FrameBufferStack.

Referenced by GPU_offscreen_bind(), and pygpu_framebuffer_stack_push_and_bind_or_error().

◆ GPU_framebuffer_py_reference_get()

void ** GPU_framebuffer_py_reference_get ( blender::gpu::FrameBuffer * fb)

Reference of a pointer that needs to be cleaned when deallocating the frame-buffer. Points to BPyGPUFrameBuffer.fb

Definition at line 556 of file gpu_framebuffer.cc.

References fb().

Referenced by BPyGPUFrameBuffer_CreatePyObject().

◆ GPU_framebuffer_py_reference_set()

void GPU_framebuffer_py_reference_set ( gpu::FrameBuffer * fb,
void ** py_ref )

Definition at line 561 of file gpu_framebuffer.cc.

References BLI_assert, and fb().

Referenced by BPyGPUFrameBuffer_CreatePyObject(), and pygpu_framebuffer_free_safe().

◆ GPU_framebuffer_read_color()

void GPU_framebuffer_read_color ( blender::gpu::FrameBuffer * fb,
int x,
int y,
int width,
int height,
int channels,
int slot,
eGPUDataFormat data_format,
void * r_data )

Read a region of a framebuffer color attachment and copy it to r_data . The pixel data will be converted to data_format but it needs to be compatible with the attachment type. DEPRECATED: Prefer using GPU_texture_read().

Definition at line 495 of file gpu_framebuffer.cc.

References data, fb(), GPU_COLOR_BIT, w(), x, and y.

Referenced by DRW_select_buffer_read(), GPU_offscreen_read_color_region(), pygpu_framebuffer_read_color(), blender::draw::gpencil::render_result_combined(), blender::draw::gpencil::render_result_separated_pass(), and write_render_color_output().

◆ GPU_framebuffer_read_depth()

void GPU_framebuffer_read_depth ( blender::gpu::FrameBuffer * fb,
int x,
int y,
int width,
int height,
eGPUDataFormat data_format,
void * r_data )

Read a region of the framebuffer depth attachment and copy it to r_data . The pixel data will be converted to data_format but it needs to be compatible with the attachment type. DEPRECATED: Prefer using GPU_texture_read().

Definition at line 488 of file gpu_framebuffer.cc.

References data, fb(), GPU_DEPTH_BIT, w(), x, and y.

Referenced by gpu_select_pick_load_id(), pygpu_framebuffer_read_depth(), blender::draw::gpencil::render_result_z(), view3d_gpu_read_Z_pixels(), and write_render_z_output().

◆ GPU_framebuffer_restore()

◆ GPU_framebuffer_stack_level_get()

◆ GPU_framebuffer_subpass_transition_array()

void GPU_framebuffer_subpass_transition_array ( blender::gpu::FrameBuffer * fb,
const GPUAttachmentState * attachment_states,
uint attachment_len )

Sub-pass config array matches attachment structure of GPU_framebuffer_config_array. This allows to explicitly specify attachment state within the next sub-pass. This enables a number of bandwidth optimizations specially on Tile Based Deferred Renderers where the attachments can be kept into tile memory and used in place for later sub-passes.

IMPORTANT: When using this, the framebuffer initial state is undefined. A sub-pass transition need to be issued before any draw-call.

Example:

GPU_ATTACHMENT_WRITE, // must be depth buffer
GPU_ATTACHMENT_READ, // Color attachment 0
GPU_ATTACHMENT_IGNORE, // Color attachment 1
GPU_ATTACHMENT_WRITE} // Color attachment 2
})
@ GPU_ATTACHMENT_WRITE
@ GPU_ATTACHMENT_READ
@ GPU_ATTACHMENT_IGNORE
Note
Excess attachments will have no effect as long as they are GPU_ATTACHMENT_IGNORE.

Definition at line 260 of file gpu_framebuffer.cc.

References fb().

Referenced by blender::draw::command::SubPassTransition::execute().

◆ GPU_framebuffer_texture_attach()

void GPU_framebuffer_texture_attach ( blender::gpu::FrameBuffer * fb,
blender::gpu::Texture * texture,
int slot,
int mip )

Attach an entire texture mip level to a #FrameBuffer. Changes will only take effect next time GPU_framebuffer_bind() is called. slot is the color texture slot to bind this texture to. Must be 0 if it is the depth texture. mip is the mip level of this texture to attach to the framebuffer. DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with GPU_framebuffer_config_array().

Definition at line 324 of file gpu_framebuffer.cc.

References fb(), GPU_ATTACHMENT_TEXTURE_MIP, and gpu_framebuffer_texture_attach_ex().

Referenced by draw_select_framebuffer_depth_only_setup().

◆ gpu_framebuffer_texture_attach_ex()

◆ GPU_framebuffer_texture_cubeface_attach()

void GPU_framebuffer_texture_cubeface_attach ( blender::gpu::FrameBuffer * fb,
blender::gpu::Texture * texture,
int slot,
int face,
int mip )

Attach a single cube-face of an cube-map texture mip level to a #FrameBuffer. Changes will only take effect next time GPU_framebuffer_bind() is called. slot is the color texture slot to bind this texture to. Must be 0 if it is the depth texture. face is the cube-face of this cube-map texture to attach to the framebuffer. mip is the mip level of this texture to attach to the framebuffer. DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with GPU_framebuffer_config_array().

Definition at line 340 of file gpu_framebuffer.cc.

References fb(), GPU_ATTACHMENT_TEXTURE_CUBEFACE_MIP, and gpu_framebuffer_texture_attach_ex().

◆ GPU_framebuffer_texture_detach()

void GPU_framebuffer_texture_detach ( blender::gpu::FrameBuffer * fb,
blender::gpu::Texture * texture )

Detach a texture from a #FrameBuffer. The texture must be attached. Changes will only take effect next time GPU_framebuffer_bind() is called. DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with GPU_framebuffer_config_array().

Definition at line 347 of file gpu_framebuffer.cc.

References blender::gpu::Texture::detach_from(), and fb().

◆ GPU_framebuffer_texture_layer_attach()

void GPU_framebuffer_texture_layer_attach ( blender::gpu::FrameBuffer * fb,
blender::gpu::Texture * texture,
int slot,
int layer,
int mip )

Attach a single layer of an array texture mip level to a #FrameBuffer. Changes will only take effect next time GPU_framebuffer_bind() is called. slot is the color texture slot to bind this texture to. Must be 0 if it is the depth texture. layer is the layer of this array texture to attach to the framebuffer. mip is the mip level of this texture to attach to the framebuffer. DEPRECATED: Prefer using multiple #FrameBuffer with different configurations with GPU_framebuffer_config_array().

Definition at line 333 of file gpu_framebuffer.cc.

References fb(), GPU_ATTACHMENT_TEXTURE_LAYER_MIP, and gpu_framebuffer_texture_attach_ex().

◆ GPU_framebuffer_viewport_get()

void GPU_framebuffer_viewport_get ( blender::gpu::FrameBuffer * fb,
int r_viewport[4] )

Return the viewport offset and size in a int quadruple: (x, y, width, height).

Note
Viewport and scissor size is stored per frame-buffer.

Definition at line 400 of file gpu_framebuffer.cc.

References blender::gpu::FrameBuffer::viewport_get().

Referenced by pygpu_framebuffer_viewport_get().

◆ GPU_framebuffer_viewport_reset()

void GPU_framebuffer_viewport_reset ( blender::gpu::FrameBuffer * fb)

Reset a frame-buffer viewport bounds to its attachment(s) size.

Note
Viewport and scissor size is stored per frame-buffer.

Definition at line 405 of file gpu_framebuffer.cc.

References blender::gpu::FrameBuffer::viewport_reset().

Referenced by blender::eevee::LookdevModule::display(), and blender::eevee::Instance::draw().

◆ GPU_framebuffer_viewport_set()

void GPU_framebuffer_viewport_set ( blender::gpu::FrameBuffer * fb,
int x,
int y,
int width,
int height )

Set the viewport offset and size. These are reset to the original dimensions explicitly (using GPU_framebuffer_viewport_reset()) or when binding the frame-buffer after modifying its attachments.

Note
Viewport and scissor size is stored per frame-buffer.
Setting a singular viewport will only change the state of the first viewport.
Must be called after first bind.

Definition at line 388 of file gpu_framebuffer.cc.

References blender::gpu::FrameBuffer::viewport_set(), x, and y.

Referenced by blender::eevee::Film::accumulate(), blender::eevee::Film::display(), and pygpu_framebuffer_viewport_set().

◆ GPU_frontbuffer_read_color()

void GPU_frontbuffer_read_color ( int x,
int y,
int width,
int height,
int channels,
eGPUDataFormat data_format,
void * r_data )

Read the color of the window screen as it is currently displayed (so the previously rendered back-buffer). DEPRECATED: This isn't even working correctly on some implementation. TODO: Emulate this by doing some slow texture copy on the backend side or try to read the areas offscreen textures directly.

Definition at line 509 of file gpu_framebuffer.cc.

References data, blender::gpu::Context::front_left, blender::gpu::Context::get(), GPU_COLOR_BIT, blender::gpu::FrameBuffer::read(), w(), x, and y.

Referenced by WM_window_pixels_read_from_frontbuffer(), and WM_window_pixels_read_sample_from_frontbuffer().

◆ GPU_offscreen_bind()

◆ GPU_offscreen_color_texture()

blender::gpu::Texture * GPU_offscreen_color_texture ( const GPUOffScreen * offscreen)

Return the color texture of a GPUOffScreen. Does not give ownership.

Note
only to be used by viewport code!

Definition at line 814 of file gpu_framebuffer.cc.

References GPUOffScreen::color.

Referenced by blender::gpu::tests::blend_test(), pygpu_offscreen_texture_color_get(), blender::gpu::tests::vertex_buffer_fetch_mode(), wm_draw_offscreen_texture_parameters(), wm_draw_region_texture(), and wm_draw_window().

◆ GPU_offscreen_create()

GPUOffScreen * GPU_offscreen_create ( int width,
int height,
bool with_depth_buffer,
blender::gpu::TextureFormat format,
eGPUTextureUsage usage,
bool clear,
char err_out[256] )

◆ GPU_offscreen_draw_to_screen()

void GPU_offscreen_draw_to_screen ( GPUOffScreen * offscreen,
int x,
int y )

Blit the offscreen color texture to the active framebuffer at the (x, y) location.

Definition at line 775 of file gpu_framebuffer.cc.

References blender::gpu::Context::active_fb, blender::gpu::FrameBuffer::blit_to(), blender::gpu::Context::get(), GPU_COLOR_BIT, gpu_offscreen_fb_get(), x, and y.

Referenced by wm_draw_region_blit().

◆ gpu_offscreen_fb_get()

◆ GPU_offscreen_format()

blender::gpu::TextureFormat GPU_offscreen_format ( const GPUOffScreen * offscreen)

Return the texture format of a GPUOffScreen.

Definition at line 819 of file gpu_framebuffer.cc.

References GPUOffScreen::color, and GPU_texture_format().

Referenced by ED_view3d_draw_offscreen_imbuf(), and wm_draw_region_buffer_create().

◆ GPU_offscreen_free()

◆ GPU_offscreen_height()

◆ GPU_offscreen_read_color()

void GPU_offscreen_read_color ( GPUOffScreen * offscreen,
eGPUDataFormat data_format,
void * r_data )

◆ GPU_offscreen_read_color_region()

void GPU_offscreen_read_color_region ( GPUOffScreen * offscreen,
eGPUDataFormat data_format,
int x,
int y,
int w,
int h,
void * r_data )

◆ GPU_offscreen_unbind()

◆ GPU_offscreen_viewport_data_get()

void GPU_offscreen_viewport_data_get ( GPUOffScreen * offscreen,
blender::gpu::FrameBuffer ** r_fb,
blender::gpu::Texture ** r_color,
blender::gpu::Texture ** r_depth )

Return the internals of a GPUOffScreen. Does not give ownership.

Note
only to be used by viewport code!

Definition at line 824 of file gpu_framebuffer.cc.

References GPUOffScreen::color, GPUOffScreen::depth, and gpu_offscreen_fb_get().

Referenced by GPU_viewport_bind_from_offscreen().

◆ GPU_offscreen_width()

Variable Documentation

◆ framebuffers

◆ [struct]

struct { ... } FrameBufferStack

◆ top

uint top

Definition at line 580 of file gpu_framebuffer.cc.

Referenced by blender::ed::vse::StripsDrawBatch::add_strip(), BKE_tracking_get_projection_matrix(), BLF_thumb_preview(), BLI_STATIC_ASSERT(), calc_text_rcts(), convexhull_2d_sorted(), convexhull_2d_sorted_impl(), convexhull_2d_stack_finalize(), convexhull_2d_stack_push(), blender::nodes::node_geo_curve_primitive_quadrilateral_cc::create_trapezoid_curve(), GHOST_ISystem::createWindow(), GHOST_SystemCocoa::createWindow(), GHOST_SystemHeadless::createWindow(), GHOST_SystemWayland::createWindow(), GHOST_SystemWin32::createWindow(), GHOST_SystemX11::createWindow(), cursor_bitmap_rgba_flip_y(), blender::ed::vse::draw_icon_centered(), blender::eevee::VolumeModule::draw_prepass(), blender::ed::vse::draw_seq_waveform_overlay(), draw_suggestion_list(), blender::ed::vse::drawmeta_contents(), blender::draw::View::frustum_boundbox_calc(), getOpenGLSubMatrix(), GHOST_CreateWindow(), GHOST_WindowSDL::GHOST_WindowSDL(), GHOST_WindowWin32::GHOST_WindowWin32(), GHOST_WindowX11::GHOST_WindowX11(), GPU_matrix_frustum_set(), GPU_matrix_ortho_2d_set(), GPU_matrix_ortho_set(), GPU_matrix_unproject_precalc(), IMB_flipy(), imm_draw_cylinder_fill_3d(), imm_draw_cylinder_fill_normal_3d(), imm_draw_cylinder_wire_3d(), immDrawPixelsTexTiled_scaling_clipping(), interp_weights_poly_v2(), SkyMultipleScattering::lookup_transmittance(), mat4_frustum_set(), mat4_ortho_set(), blender::nodes::node_geo_curve_primitive_quadrilateral_cc::node_declare(), Freestyle::NodePerspectiveCamera::NodePerspectiveCamera(), blender::math::projection::orthographic(), blender::math::projection::orthographic(), blender::math::projection::orthographic_infinite(), blender::math::projection::orthographic_infinite(), orthographic_m4(), osl_closure_layer_params(), blender::math::projection::perspective(), blender::math::projection::perspective(), blender::math::projection::perspective_infinite(), blender::math::projection::perspective_infinite(), perspective_m4(), planes_from_projmat(), screen_areas_align(), screen_draw_area_drag_tip(), blender::seq::sequencer_image_crop_init(), blender::ed::vse::sequencer_retiming_draw_continuity(), SKY_multiple_scattering_precompute_sun(), SKY_single_scattering_precompute_sun(), space_text_do_suggest_select(), space_text_get_line_pos_wrapped(), StereoProjection(), text_pop_suggest_list(), texttool_suggest_prefix(), thumb_data_vertical_flip(), timeline_cache_draw_geometry_nodes(), txt_clean_text(), ui_popup_block_position(), libmv::VerticalStack(), View(), and libmv::VStack().