Blender V5.3
GPU_framebuffer.hh File Reference

Go to the source code of this file.

Classes

struct  blender::GPUAttachment
struct  blender::GPULoadStore

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::gpu

Enumerations

enum  blender::GPUFrameBufferBits { blender::GPU_COLOR_BIT = (1 << 0) , blender::GPU_DEPTH_BIT = (1 << 1) , blender::GPU_STENCIL_BIT = (1 << 2) }

Functions

Creation
gpu::FrameBuffer * blender::GPU_framebuffer_create (const char *name)
gpu::FrameBuffer * blender::GPU_framebuffer_active_get ()
gpu::FrameBuffer * blender::GPU_framebuffer_back_get ()
Empty frame-buffer

An empty frame-buffer is a frame-buffer with no attachments. This allow to rasterize geometry without creating any dummy attachments and write some computation results using other means (SSBOs, Images).

void blender::GPU_framebuffer_default_size (gpu::FrameBuffer *fb, int width, int height)
Internal state
int2 blender::GPU_framebuffer_extent_get (gpu::FrameBuffer *fb)
 Get the extent of the framebuffer.
void blender::GPU_framebuffer_viewport_set (gpu::FrameBuffer *fb, int x, int y, int width, int height)
void blender::GPU_framebuffer_multi_viewports_set (gpu::FrameBuffer *gpu_fb, const int viewport_rects[GPU_MAX_VIEWPORTS][4])
void blender::GPU_framebuffer_viewport_get (gpu::FrameBuffer *fb, int r_viewport[4])
void blender::GPU_framebuffer_viewport_reset (gpu::FrameBuffer *fb)
Clearing
void blender::GPU_framebuffer_clear (gpu::FrameBuffer *fb, GPUFrameBufferBits buffers, const double4 clear_col, float clear_depth, unsigned int clear_stencil)
void blender::GPU_framebuffer_clear_color (gpu::FrameBuffer *fb, const double4 clear_col)
void blender::GPU_framebuffer_clear_depth (gpu::FrameBuffer *fb, float clear_depth)
void blender::GPU_framebuffer_clear_stencil (gpu::FrameBuffer *fb, uint clear_stencil)
void blender::GPU_framebuffer_clear_color_depth (gpu::FrameBuffer *fb, const double4 clear_col, float clear_depth)
void blender::GPU_framebuffer_clear_depth_stencil (gpu::FrameBuffer *fb, float clear_depth, uint clear_stencil)
void blender::GPU_framebuffer_clear_color_depth_stencil (gpu::FrameBuffer *fb, const double4 clear_col, float clear_depth, uint clear_stencil)
void blender::GPU_framebuffer_multi_clear (gpu::FrameBuffer *fb, Span< double4 > clear_colors)
void blender::GPU_clear_color (float red, float green, float blue, float alpha)
void blender::GPU_clear_depth (float depth)
Debugging introspection API.
const char * blender::GPU_framebuffer_get_name (gpu::FrameBuffer *fb)
Python API & meta-data

These are not intrinsic properties of a texture but they are stored inside the gpu::Texture structure for tracking purpose.

void ** blender::GPU_framebuffer_py_reference_get (gpu::FrameBuffer *fb)
void blender::GPU_framebuffer_py_reference_set (gpu::FrameBuffer *fb, void **py_ref)
void blender::GPU_framebuffer_push (gpu::FrameBuffer *fb)
gpu::FrameBuffer * blender::GPU_framebuffer_pop ()
uint blender::GPU_framebuffer_stack_level_get ()
Deprecated
bool blender::GPU_framebuffer_bound (gpu::FrameBuffer *fb)
void blender::GPU_framebuffer_read_depth (gpu::FrameBuffer *fb, int x, int y, int width, int height, eGPUDataFormat data_format, void *r_data)
void blender::GPU_framebuffer_read_color (gpu::FrameBuffer *fb, int x, int y, int width, int height, int channels, int slot, eGPUDataFormat data_format, void *r_data)
void blender::GPU_frontbuffer_read_color (int x, int y, int width, int height, int channels, eGPUDataFormat data_format, void *r_data)
void blender::GPU_framebuffer_blit (gpu::FrameBuffer *fb_read, int read_slot, gpu::FrameBuffer *fb_write, int write_slot, GPUFrameBufferBits blit_buffers)
GPU OffScreen

A GPUOffScreen is a convenience type that holds a GPUFramebuffer and its associated gpu::Textures. It is useful for quick drawing surface configuration. NOTE: They are still limited by the same single context limitation as FrameBuffer.

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

Variables

static constexpr int blender::GPU_MAX_VIEWPORTS = 16

Free

#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
void blender::GPU_framebuffer_free (gpu::FrameBuffer *fb)

Advanced binding control

#define NULL_ATTACHMENT_COLOR   {0.0, 0.0, 0.0, 0.0}
#define NULL_LOAD_STORE   {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_DONT_CARE, NULL_ATTACHMENT_COLOR}
#define GPU_framebuffer_bind_ex(_fb, ...)
#define GPU_framebuffer_subpass_transition(_fb, ...)
void blender::GPU_framebuffer_bind_loadstore (gpu::FrameBuffer *fb, const GPULoadStore *load_store_actions, uint load_store_actions_len)
void blender::GPU_framebuffer_subpass_transition_array (gpu::FrameBuffer *fb, const GPUAttachmentState *attachment_states, uint attachment_len)

Attachments

#define GPU_framebuffer_ensure_config(_fb, ...)
#define GPU_ATTACHMENT_NONE
#define GPU_ATTACHMENT_LEAVE
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_TEXTURE_MIP(_texture, _mip)
#define GPU_ATTACHMENT_TEXTURE_LAYER(_texture, _layer)
#define GPU_ATTACHMENT_TEXTURE_LAYER_MIP(_texture, _layer, _mip)
#define GPU_ATTACHMENT_TEXTURE_CUBEFACE(_texture, _face)
#define GPU_ATTACHMENT_TEXTURE_CUBEFACE_MIP(_texture, _face, _mip)
void blender::GPU_framebuffer_config_array (gpu::FrameBuffer *fb, const GPUAttachment *config, int config_len)
void blender::GPU_framebuffer_texture_attach (gpu::FrameBuffer *fb, gpu::Texture *texture, int slot, int mip)
void blender::GPU_framebuffer_texture_layer_attach (gpu::FrameBuffer *fb, gpu::Texture *texture, int slot, int layer, int mip)
void blender::GPU_framebuffer_texture_cubeface_attach (gpu::FrameBuffer *fb, gpu::Texture *texture, int slot, int face, int mip)
void blender::GPU_framebuffer_texture_detach (gpu::FrameBuffer *fb, gpu::Texture *texture)
bool blender::GPU_framebuffer_check_valid (gpu::FrameBuffer *fb, char err_out[256])

Binding

enum  blender::GPUBackBuffer { blender::GPU_BACKBUFFER_LEFT = 0 , blender::GPU_BACKBUFFER_RIGHT }
void blender::GPU_backbuffer_bind (GPUBackBuffer back_buffer_type)
void blender::GPU_framebuffer_bind (gpu::FrameBuffer *fb)
void blender::GPU_framebuffer_bind_no_srgb (gpu::FrameBuffer *fb)
void blender::GPU_framebuffer_restore ()

Detailed Description

A GPUFramebuffer is a wrapper for a frame-buffer object (FBO) from the underlying graphic API.

A GPUFramebuffer is limited to one context and thus cannot be shared across different contexts. In the case this is needed, one must recreate the same GPUFramebuffer in each context.

Note that actual FBO creation & config is deferred until GPU_framebuffer_bind or GPU_framebuffer_check_valid is called. This means the context the GPUFramebuffer is bound with is the one active when GPU_framebuffer_bind is called.

When a gpu::Texture is attached to a GPUFramebuffer a reference is created. Deleting either does not require any unbinding.

A GPUOffScreen is a convenience type that holds a GPUFramebuffer and its associated gpu::Textures. It is useful for quick drawing surface configuration.

Definition in file GPU_framebuffer.hh.

Macro Definition Documentation

◆ GPU_ATTACHMENT_LEAVE

#define GPU_ATTACHMENT_LEAVE
Value:
GPUAttachment \
{ \
nullptr, -1, -1, \
}

Leave currently bound texture in this slot. DEPRECATED: Specify all textures for clarity.

Definition at line 269 of file GPU_framebuffer.hh.

◆ GPU_ATTACHMENT_NONE

#define GPU_ATTACHMENT_NONE
Value:
GPUAttachment \
{ \
nullptr, -1, 0, \
}

Empty bind point.

Definition at line 263 of file GPU_framebuffer.hh.

Referenced by blender::draw::overlay::Resources::acquire(), blender::draw::gpencil::Instance::acquire_resources(), blender::gpu::FrameBuffer::attachment_remove(), blender::gpu::GLFrameBuffer::attachment_set_loadstore_op(), blender::image_engine::ScreenSpaceDrawingMode::begin_sync(), blender::gpu::GLFrameBuffer::bind(), blender::gpu::tests::create_base_texture(), blender::workbench::AntiAliasingPass::draw(), blender::workbench::DofPass::draw(), blender::workbench::Instance::draw(), blender::workbench::OpaquePass::draw(), blender::workbench::OutlinePass::draw(), blender::workbench::TransparentDepthPass::draw(), blender::workbench::TransparentPass::draw(), blender::workbench::VolumePass::draw(), blender::eevee::VolumeModule::draw_resolve(), blender::DRW_draw_depth_loop(), blender::draw::Framebuffer::ensure(), blender::gizmo_find_intersected_3d(), blender::pygpu_framebuffer_new_parse_arg(), blender::eevee::DepthOfField::render(), blender::eevee::ShadingView::render(), blender::eevee::CaptureView::render_probes(), blender::draw::gpencil::render_result_color(), blender::eevee::CaptureView::render_world(), blender::eevee::PlanarProbeModule::set_view(), blender::gpu::GLFrameBuffer::subpass_transition_impl(), blender::eevee::LookdevModule::sync(), blender::draw::test_draw_resource_id_gen(), blender::draw::test_draw_submit_only(), blender::draw::test_draw_visibility(), blender::gpu::tests::test_framebuffer_clear_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_clear_color_single_attachment(), 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::gpu::tests::test_framebuffer_subpass_input_clearops(), blender::gpu::tests::test_ray_tracing_fragment(), blender::gpu::tests::test_shader_create_info_pipeline(), blender::gpu::tests::texture_view_create_format_test(), blender::ed::vse::update_gpu_scopes(), and blender::view3d_gpu_read_Z_pixels().

◆ GPU_ATTACHMENT_TEXTURE

#define GPU_ATTACHMENT_TEXTURE ( _texture)
Value:
GPUAttachment \
{ \
_texture, -1, 0, \
}

Bind the first mip level of a texture (all layers).

Definition at line 275 of file GPU_framebuffer.hh.

Referenced by blender::draw::overlay::Resources::acquire(), blender::draw::gpencil::Instance::acquire_resources(), blender::image_engine::ScreenSpaceDrawingMode::begin_sync(), blender::render::hydra::GPURenderTaskDelegate::bind(), blender::gpu::tests::create_base_texture(), blender::workbench::AntiAliasingPass::draw(), blender::workbench::DofPass::draw(), blender::workbench::Instance::draw(), blender::workbench::OpaquePass::draw(), blender::workbench::OutlinePass::draw(), blender::workbench::ShadowPass::draw(), blender::workbench::TransparentDepthPass::draw(), blender::workbench::TransparentPass::draw(), blender::workbench::VolumePass::draw(), blender::draw::overlay::Outline::draw_line_only_ex(), blender::eevee::VolumeModule::draw_resolve(), blender::DRW_draw_depth_loop(), blender::eevee::VolumeModule::end_sync(), blender::draw::command::TextureCopy::execute(), blender::gizmo_find_intersected_3d(), blender::eevee::DepthOfField::render(), blender::eevee::ForwardPipeline::render(), blender::eevee::ShadingView::render(), blender::draw::gpencil::render_init_buffers(), blender::eevee::CaptureView::render_probes(), blender::draw::gpencil::render_result_color(), blender::eevee::PlanarProbeModule::set_view(), blender::eevee::LookdevModule::sync(), blender::gpu::VKContext::sync_backbuffer(), blender::draw::test_draw_resource_id_gen(), blender::draw::test_draw_submit_only(), blender::draw::test_draw_visibility(), 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_multi_viewport(), blender::gpu::tests::test_framebuffer_scissor_test(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::gpu::tests::test_framebuffer_subpass_input_clearops(), blender::gpu::tests::test_ray_tracing_fragment(), blender::gpu::tests::test_shader_create_info_pipeline(), blender::gpu::tests::texture_view_create_format_test(), blender::ed::vse::update_gpu_scopes(), and blender::view3d_gpu_read_Z_pixels().

◆ GPU_ATTACHMENT_TEXTURE_CUBEFACE

#define GPU_ATTACHMENT_TEXTURE_CUBEFACE ( _texture,
_face )
Value:
GPUAttachment \
{ \
_texture, _face, 0, \
}

NOTE: The cube-face variants are equivalent to the layer ones but give better semantic. Bind the first mip level of a cube-map _face texture.

Definition at line 302 of file GPU_framebuffer.hh.

Referenced by blender::eevee::CaptureView::render_probes(), blender::eevee::CaptureView::render_world(), and blender::gpu::tests::test_framebuffer_cube().

◆ GPU_ATTACHMENT_TEXTURE_CUBEFACE_MIP

#define GPU_ATTACHMENT_TEXTURE_CUBEFACE_MIP ( _texture,
_face,
_mip )
Value:
GPUAttachment \
{ \
_texture, _face, _mip, \
}

Bind the _mip level of a cube-map _face texture.

Definition at line 308 of file GPU_framebuffer.hh.

Referenced by blender::GPU_framebuffer_texture_cubeface_attach().

◆ GPU_ATTACHMENT_TEXTURE_LAYER

#define GPU_ATTACHMENT_TEXTURE_LAYER ( _texture,
_layer )
Value:
GPUAttachment \
{ \
_texture, _layer, 0, \
}

Bind the _layer layer of the first mip level of a texture.

Definition at line 287 of file GPU_framebuffer.hh.

Referenced by blender::eevee::ShadingView::render(), blender::eevee::CaptureView::render_probes(), and blender::eevee::PlanarProbeModule::set_view().

◆ GPU_ATTACHMENT_TEXTURE_LAYER_MIP

#define GPU_ATTACHMENT_TEXTURE_LAYER_MIP ( _texture,
_layer,
_mip )
Value:
GPUAttachment \
{ \
_texture, _layer, _mip, \
}

Bind the _layer layer of the _mip level of a texture.

Definition at line 293 of file GPU_framebuffer.hh.

Referenced by blender::GPU_framebuffer_texture_layer_attach().

◆ GPU_ATTACHMENT_TEXTURE_MIP

#define GPU_ATTACHMENT_TEXTURE_MIP ( _texture,
_mip )
Value:
GPUAttachment \
{ \
_texture, -1, _mip, \
}

Bind the _mip level of a texture (all layers).

Definition at line 281 of file GPU_framebuffer.hh.

Referenced by blender::workbench::DofPass::draw(), and blender::GPU_framebuffer_texture_attach().

◆ GPU_framebuffer_bind_ex

#define GPU_framebuffer_bind_ex ( _fb,
... )
Value:
{ \
GPULoadStore actions[] = __VA_ARGS__; \
GPU_framebuffer_bind_loadstore(_fb, actions, (sizeof(actions) / sizeof(GPULoadStore))); \
}

Definition at line 180 of file GPU_framebuffer.hh.

Referenced by blender::eevee::GBuffer::bind(), and blender::gpu::tests::test_framebuffer_subpass_input_clearops().

◆ GPU_framebuffer_ensure_config

#define GPU_framebuffer_ensure_config ( _fb,
... )
Value:
do { \
if (*(_fb) == nullptr) { \
*(_fb) = GPU_framebuffer_create(#_fb); \
} \
GPUAttachment config[] = __VA_ARGS__; \
GPU_framebuffer_config_array(*(_fb), config, (sizeof(config) / sizeof(GPUAttachment))); \
} while (0)

How to use GPU_framebuffer_ensure_config().

Example:

GPU_ATTACHMENT_TEXTURE(depth), // must be depth buffer
})
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_TEXTURE_CUBEFACE(_texture, _face)
#define GPU_framebuffer_ensure_config(_fb,...)
#define GPU_ATTACHMENT_TEXTURE_LAYER_MIP(_texture, _layer, _mip)
Note
Unspecified attachments (i.e: those beyond the last GPU_ATTACHMENT_* in GPU_framebuffer_ensure_config list) are left unchanged.
Make sure that the dimensions of your textures matches otherwise you will have an invalid framebuffer error.

Definition at line 243 of file GPU_framebuffer.hh.

Referenced by blender::render::hydra::GPURenderTaskDelegate::bind(), blender::gpu::tests::create_base_texture(), blender::DRW_draw_depth_loop(), blender::DRW_view_data_default_lists_from_viewport(), blender::draw::overlay::Instance::end_sync(), blender::draw::command::TextureCopy::execute(), blender::gizmo_find_intersected_3d(), blender::gpu_offscreen_fb_get(), blender::GPU_viewport_framebuffer_overlay_get(), blender::GPU_viewport_framebuffer_render_get(), blender::GPU_viewport_stereo_composite(), 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::gpu::tests::test_framebuffer_subpass_input_clearops(), blender::gpu::tests::test_ray_tracing_fragment(), blender::gpu::tests::test_shader_create_info_pipeline(), blender::gpu::tests::texture_view_create_format_test(), blender::ed::vse::update_gpu_scopes(), blender::view3d_gpu_read_Z_pixels(), and blender::workbench_render_framebuffers_init().

◆ GPU_FRAMEBUFFER_FREE_SAFE

◆ GPU_framebuffer_subpass_transition

#define GPU_framebuffer_subpass_transition ( _fb,
... )
Value:
{ \
GPUAttachmentState actions[] = __VA_ARGS__; \
GPU_framebuffer_subpass_transition_array( \
_fb, actions, (sizeof(actions) / sizeof(GPUAttachmentState))); \
}

Definition at line 211 of file GPU_framebuffer.hh.

Referenced by blender::gpu::tests::test_framebuffer_subpass_input(), and blender::gpu::tests::test_framebuffer_subpass_input_clearops().

◆ NULL_ATTACHMENT_COLOR

#define NULL_ATTACHMENT_COLOR   {0.0, 0.0, 0.0, 0.0}

Definition at line 146 of file GPU_framebuffer.hh.

◆ NULL_LOAD_STORE

#define NULL_LOAD_STORE   {GPU_LOADACTION_DONT_CARE, GPU_STOREACTION_DONT_CARE, NULL_ATTACHMENT_COLOR}

Definition at line 147 of file GPU_framebuffer.hh.