Blender V5.0
blender::gpu::Context Class Referenceabstract

#include <gpu_context_private.hh>

Inherited by blender::gpu::DummyContext, blender::gpu::GLContext, blender::gpu::MTLContext, and blender::gpu::VKContext.

Public Member Functions

 Context ()
virtual ~Context ()
virtual void activate ()=0
virtual void deactivate ()=0
virtual void begin_frame ()=0
virtual void end_frame ()=0
virtual void flush ()=0
virtual void finish ()=0
virtual void memory_statistics_get (int *r_total_mem, int *r_free_mem)=0
virtual void debug_group_begin (const char *, int)
virtual void debug_group_end ()
virtual bool debug_capture_begin (const char *title)=0
virtual void debug_capture_end ()=0
virtual void * debug_capture_scope_create (const char *name)=0
virtual bool debug_capture_scope_begin (void *scope)=0
virtual void debug_capture_scope_end (void *scope)=0
virtual void debug_unbind_all_ubo ()=0
virtual void debug_unbind_all_ssbo ()=0
bool is_active_on_thread ()
VertBufdummy_vbo_get ()
Batch * procedural_points_batch_get ()
Batch * procedural_lines_batch_get ()
Batch * procedural_triangles_batch_get ()
Batch * procedural_triangle_strips_batch_get ()
void assert_framebuffer_shader_compatibility (Shader *sh)

Static Public Member Functions

static Contextget ()

Public Attributes

Shadershader = nullptr
FrameBufferactive_fb = nullptr
GPUMatrixStatematrix_state = nullptr
StateManagerstate_manager = nullptr
Immediateimm = nullptr
FrameBufferback_left = nullptr
FrameBufferfront_left = nullptr
FrameBufferback_right = nullptr
FrameBufferfront_right = nullptr
DebugStack debug_stack
bool debug_is_capturing = false
int context_id = 0
Vector< StorageBuf * > printf_buf
VertBufdummy_vbo = nullptr
Batch * procedural_points_batch = nullptr
Batch * procedural_lines_batch = nullptr
Batch * procedural_triangles_batch = nullptr
Batch * procedural_triangle_strips_batch = nullptr
TexturePooltexture_pool = nullptr
int shader_builtin_srgb_transform = 0
bool shader_builtin_srgb_is_dirty = false

Static Public Attributes

static int context_counter = 0

Protected Member Functions

void free_resources ()

Protected Attributes

pthread_t thread_
bool is_active_
void * ghost_window_

Detailed Description

Definition at line 31 of file gpu_context_private.hh.

Constructor & Destructor Documentation

◆ Context()

blender::gpu::Context::Context ( )

Definition at line 70 of file gpu_context.cc.

References context_counter, context_id, GPU_matrix_state_create(), is_active_, matrix_state, texture_pool, and thread_.

Referenced by get().

◆ ~Context()

blender::gpu::Context::~Context ( )
virtual

IMPORTANT: Do not free resources (texture, batch, buffers) in this function. These objects are likely to reference the GL/VK/MTLContext which is already destroyed at this point.

Definition at line 81 of file gpu_context.cc.

References back_left, back_right, BLI_assert, front_left, front_right, GPU_matrix_state_discard(), imm, matrix_state, state_manager, and texture_pool.

Member Function Documentation

◆ activate()

virtual void blender::gpu::Context::activate ( )
pure virtual

◆ assert_framebuffer_shader_compatibility()

void blender::gpu::Context::assert_framebuffer_shader_compatibility ( Shader * sh)
inline

◆ begin_frame()

virtual void blender::gpu::Context::begin_frame ( )
pure virtual

◆ deactivate()

virtual void blender::gpu::Context::deactivate ( )
pure virtual

◆ debug_capture_begin()

virtual bool blender::gpu::Context::debug_capture_begin ( const char * title)
pure virtual

◆ debug_capture_end()

virtual void blender::gpu::Context::debug_capture_end ( )
pure virtual

◆ debug_capture_scope_begin()

virtual bool blender::gpu::Context::debug_capture_scope_begin ( void * scope)
pure virtual

◆ debug_capture_scope_create()

virtual void * blender::gpu::Context::debug_capture_scope_create ( const char * name)
pure virtual

◆ debug_capture_scope_end()

virtual void blender::gpu::Context::debug_capture_scope_end ( void * scope)
pure virtual

◆ debug_group_begin()

virtual void blender::gpu::Context::debug_group_begin ( const char * ,
int  )
inlinevirtual

◆ debug_group_end()

virtual void blender::gpu::Context::debug_group_end ( )
inlinevirtual

◆ debug_unbind_all_ssbo()

virtual void blender::gpu::Context::debug_unbind_all_ssbo ( )
pure virtual

◆ debug_unbind_all_ubo()

virtual void blender::gpu::Context::debug_unbind_all_ubo ( )
pure virtual

◆ dummy_vbo_get()

◆ end_frame()

virtual void blender::gpu::Context::end_frame ( )
pure virtual

◆ finish()

virtual void blender::gpu::Context::finish ( )
pure virtual

◆ flush()

virtual void blender::gpu::Context::flush ( )
pure virtual

◆ free_resources()

void blender::gpu::Context::free_resources ( )
protected

◆ get()

Context * blender::gpu::Context::get ( )
static

Definition at line 124 of file gpu_context.cc.

References active_ctx, and Context().

Referenced by blender::gpu::GLTexture::check_feedback_loop(), blender::gpu::ShaderCompiler::compile(), blender::gpu::debug_validate_binding_image_format(), blender::gpu::GLContext::get(), blender::gpu::MTLContext::get(), blender::gpu::VKContext::get(), GPU_apply_state(), GPU_backbuffer_bind(), GPU_batch_draw_advanced(), GPU_batch_draw_indirect(), GPU_batch_multi_draw_indirect(), GPU_batch_procedural_lines_get(), GPU_batch_procedural_points_get(), GPU_batch_procedural_triangle_strips_get(), GPU_batch_procedural_triangles_get(), GPU_blend_get(), GPU_clear_color(), GPU_clear_depth(), GPU_color_mask(), GPU_context_active_get(), GPU_debug_capture_begin(), GPU_debug_capture_end(), GPU_debug_capture_scope_begin(), GPU_debug_capture_scope_create(), GPU_debug_capture_scope_end(), GPU_debug_get_groups_names(), GPU_debug_group_begin(), GPU_debug_group_end(), GPU_debug_group_match(), GPU_depth_mask(), GPU_depth_mask_get(), GPU_depth_range(), GPU_depth_test_get(), GPU_face_culling_get(), GPU_finish(), GPU_flush(), GPU_framebuffer_active_get(), GPU_framebuffer_back_get(), GPU_framebuffer_blit(), GPU_framebuffer_restore(), GPU_frontbuffer_read_color(), GPU_line_smooth_get(), GPU_line_width_get(), GPU_matrix_dirty_get(), GPU_matrix_reset(), GPU_matrix_stack_level_get_model_view(), GPU_matrix_stack_level_get_projection(), gpu_matrix_state_active_set_dirty(), GPU_mem_stats_get(), GPU_memory_barrier(), GPU_offscreen_draw_to_screen(), gpu_offscreen_fb_get(), GPU_point_size(), GPU_program_point_size(), GPU_scissor(), GPU_scissor_get(), GPU_scissor_test(), GPU_shader_bind(), GPU_shader_get_bound(), GPU_shader_unbind(), GPU_state_set(), GPU_stencil_mask_get(), GPU_stencil_test_get(), GPU_stereo_quadbuffer_support(), GPU_storagebuf_debug_unbind_all(), GPU_texture_bind(), GPU_texture_bind_ex(), GPU_texture_image_bind(), GPU_texture_image_unbind(), GPU_texture_image_unbind_all(), GPU_texture_unbind(), GPU_texture_unbind_all(), GPU_uniformbuf_debug_unbind_all(), GPU_unpack_row_length_set(), GPU_viewport(), GPU_viewport_size_get_f(), GPU_viewport_size_get_i(), GPU_write_mask_get(), immActivate(), immEnd(), blender::gpu::Immediate::polyline_draw_workaround(), polyline_draw_workaround(), blender::gpu::Shader::set_framebuffer_srgb_target(), blender::gpu::MTLShaderCompiler::specialize_shader(), blender::gpu::GLFrameBuffer::~GLFrameBuffer(), and blender::gpu::Shader::~Shader().

◆ is_active_on_thread()

bool blender::gpu::Context::is_active_on_thread ( )

Definition at line 119 of file gpu_context.cc.

References active_ctx, and thread_.

Referenced by blender::gpu::MTLContext::deactivate().

◆ memory_statistics_get()

virtual void blender::gpu::Context::memory_statistics_get ( int * r_total_mem,
int * r_free_mem )
pure virtual

◆ procedural_lines_batch_get()

Batch * blender::gpu::Context::procedural_lines_batch_get ( )

◆ procedural_points_batch_get()

Batch * blender::gpu::Context::procedural_points_batch_get ( )

◆ procedural_triangle_strips_batch_get()

Batch * blender::gpu::Context::procedural_triangle_strips_batch_get ( )

◆ procedural_triangles_batch_get()

Batch * blender::gpu::Context::procedural_triangles_batch_get ( )

Member Data Documentation

◆ active_fb

◆ back_left

FrameBuffer* blender::gpu::Context::back_left = nullptr

All 4 window frame-buffers. None of them are valid in an off-screen context. Right frame-buffers are only available if using stereo rendering. Front frame-buffers contains (in principle, but not always) the last frame color. Default frame-buffer is back_left.

Definition at line 47 of file gpu_context_private.hh.

Referenced by blender::gpu::GLContext::activate(), blender::gpu::DummyContext::DummyContext(), blender::gpu::MTLContext::framebuffer_restore(), free_resources(), blender::gpu::MTLContext::get_default_framebuffer(), blender::gpu::GLContext::GLContext(), GPU_backbuffer_bind(), GPU_framebuffer_back_get(), GPU_framebuffer_restore(), blender::gpu::MTLContext::MTLContext(), blender::gpu::VKContext::sync_backbuffer(), blender::gpu::VKContext::VKContext(), ~Context(), and blender::gpu::VKContext::~VKContext().

◆ back_right

◆ context_counter

int blender::gpu::Context::context_counter = 0
static

Definition at line 60 of file gpu_context_private.hh.

Referenced by Context().

◆ context_id

int blender::gpu::Context::context_id = 0

Definition at line 61 of file gpu_context_private.hh.

Referenced by Context().

◆ debug_is_capturing

bool blender::gpu::Context::debug_is_capturing = false

◆ debug_stack

◆ dummy_vbo

VertBuf* blender::gpu::Context::dummy_vbo = nullptr

Dummy VBO to feed the procedural batches.

Definition at line 67 of file gpu_context_private.hh.

Referenced by dummy_vbo_get(), and free_resources().

◆ front_left

◆ front_right

◆ ghost_window_

void* blender::gpu::Context::ghost_window_
protected

◆ imm

◆ is_active_

◆ matrix_state

◆ printf_buf

Vector<StorageBuf *> blender::gpu::Context::printf_buf

◆ procedural_lines_batch

Batch* blender::gpu::Context::procedural_lines_batch = nullptr

Definition at line 70 of file gpu_context_private.hh.

Referenced by free_resources(), and procedural_lines_batch_get().

◆ procedural_points_batch

Batch* blender::gpu::Context::procedural_points_batch = nullptr

Dummy batches for procedural geometry rendering.

Definition at line 69 of file gpu_context_private.hh.

Referenced by free_resources(), and procedural_points_batch_get().

◆ procedural_triangle_strips_batch

Batch* blender::gpu::Context::procedural_triangle_strips_batch = nullptr

Definition at line 72 of file gpu_context_private.hh.

Referenced by free_resources(), and procedural_triangle_strips_batch_get().

◆ procedural_triangles_batch

Batch* blender::gpu::Context::procedural_triangles_batch = nullptr

Definition at line 71 of file gpu_context_private.hh.

Referenced by free_resources(), and procedural_triangles_batch_get().

◆ shader

◆ shader_builtin_srgb_is_dirty

bool blender::gpu::Context::shader_builtin_srgb_is_dirty = false

◆ shader_builtin_srgb_transform

int blender::gpu::Context::shader_builtin_srgb_transform = 0

Global state to avoid setting the srgb builtin uniform for every shader bind.

Definition at line 78 of file gpu_context_private.hh.

Referenced by blender::gpu::Shader::set_framebuffer_srgb_target(), and blender::gpu::Shader::set_srgb_uniform().

◆ state_manager

◆ texture_pool

TexturePool* blender::gpu::Context::texture_pool = nullptr

Texture pool used to recycle temporary texture (or render target) memory.

Definition at line 75 of file gpu_context_private.hh.

Referenced by Context(), free_resources(), blender::gpu::TexturePool::get(), and ~Context().

◆ thread_

pthread_t blender::gpu::Context::thread_
protected

Thread on which this context is active.

Definition at line 83 of file gpu_context_private.hh.

Referenced by blender::gpu::GLContext::activate(), blender::gpu::MTLContext::activate(), Context(), and is_active_on_thread().


The documentation for this class was generated from the following files: