Blender V5.0
draw_context.cc File Reference
#include <cstdio>
#include "CLG_log.h"
#include "BLI_function_ref.hh"
#include "BLI_listbase.h"
#include "BLI_map.hh"
#include "BLI_math_matrix.h"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_sys_types.h"
#include "BLI_task.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLF_api.hh"
#include "BLT_translation.hh"
#include "BKE_context.hh"
#include "BKE_curve.hh"
#include "BKE_curves.h"
#include "BKE_duplilist.hh"
#include "BKE_editmesh.hh"
#include "BKE_global.hh"
#include "BKE_grease_pencil.h"
#include "BKE_idprop.hh"
#include "BKE_lattice.hh"
#include "BKE_layer.hh"
#include "BKE_main.hh"
#include "BKE_mball.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"
#include "BKE_paint.hh"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_pointcloud.hh"
#include "BKE_scene.hh"
#include "BKE_screen.hh"
#include "BKE_subdiv_modifier.hh"
#include "BKE_volume.hh"
#include "DNA_camera_types.h"
#include "DNA_mesh_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
#include "ED_gpencil_legacy.hh"
#include "ED_screen.hh"
#include "ED_space_api.hh"
#include "ED_view3d.hh"
#include "GPU_capabilities.hh"
#include "GPU_framebuffer.hh"
#include "GPU_matrix.hh"
#include "GPU_platform.hh"
#include "GPU_shader_shared.hh"
#include "GPU_state.hh"
#include "GPU_uniform_buffer.hh"
#include "GPU_viewport.hh"
#include "UI_resources.hh"
#include "UI_view2d.hh"
#include "WM_api.hh"
#include "DRW_render.hh"
#include "draw_cache.hh"
#include "draw_color_management.hh"
#include "draw_common_c.hh"
#include "draw_context_private.hh"
#include "draw_handle.hh"
#include "draw_manager_text.hh"
#include "draw_shader.hh"
#include "draw_subdivision.hh"
#include "draw_view_c.hh"
#include "draw_view_data.hh"
#include "draw_cache_impl.hh"
#include "engines/compositor/compositor_engine.h"
#include "engines/eevee/eevee_engine.h"
#include "engines/external/external_engine.h"
#include "engines/gpencil/gpencil_engine.hh"
#include "engines/image/image_engine.h"
#include "engines/overlay/overlay_engine.h"
#include "engines/select/select_engine.hh"
#include "engines/workbench/workbench_engine.h"
#include "GPU_context.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "BLI_time.h"
#include "DRW_select_buffer.hh"

Go to the source code of this file.

Classes

struct  ExtractionGraph
struct  DupliCacheManager
struct  blender::draw::InstancesKey
struct  DRWSelectBuffer

Namespaces

namespace  blender
namespace  blender::draw

Enumerations

enum class  blender::draw::InstancesFlags : uint8_t { blender::draw::IsNegativeScale = 1 << 0 }

Functions

static bool draw_show_annotation ()
static bool blender::draw::supports_handle_ranges (DupliObject *dupli, Object *parent)
 blender::draw::ENUM_OPERATORS (InstancesFlags, InstancesFlags::IsNegativeScale)
static void blender::draw::foreach_obref_in_scene (DRWContext &draw_ctx, FunctionRef< bool(Object &)> should_draw_object_cb, FunctionRef< void(ObjectRef &)> draw_object_cb)
Settings
bool DRW_object_is_renderable (const Object *ob)
bool DRW_object_is_in_edit_mode (const Object *ob)
int DRW_object_visibility_in_active_context (const Object *ob)
bool DRW_object_use_hide_faces (const Object *ob)
bool DRW_object_is_visible_psys_in_active_context (const Object *object, const ParticleSystem *psys)
const MeshDRW_object_get_editmesh_cage_for_drawing (const Object &object)
Viewport (DRW_viewport)
DRWDataDRW_viewport_data_create ()
void DRW_viewport_data_free (DRWData *drw_data)
static DRWDatadrw_viewport_data_ensure (GPUViewport *viewport)
blender::draw::TextureFromPoolDRW_viewport_pass_texture_get (const char *pass_name)
void DRW_viewport_request_redraw ()
Garbage Collection
void DRW_cache_free_old_batches (Main *bmain)
Rendering (DRW_engines)
static void drw_engines_cache_populate (blender::draw::ObjectRef &ref, DupliCacheManager &dupli_cache, ExtractionGraph &extraction)
void DRW_draw_region_engine_info (int xoffset, int *yoffset, int line_height)
static bool gpencil_object_is_excluded (View3D *v3d)
static bool gpencil_any_exists (Depsgraph *depsgraph)
bool DRW_gpencil_engine_needed_viewport (Depsgraph *depsgraph, View3D *v3d)
Callbacks
static void drw_callbacks_pre_scene (DRWContext &draw_ctx)
static void drw_callbacks_post_scene (DRWContext &draw_ctx)
static void drw_callbacks_pre_scene_2D (DRWContext &draw_ctx)
static void drw_callbacks_post_scene_2D (DRWContext &draw_ctx, View2D &v2d)
DRWTextStoreDRW_text_cache_ensure ()
Draw Manager State
const DRWContextDRW_context_get ()
DRW_engines
void DRW_engines_register ()
void DRW_engines_free ()
DRW_module
void DRW_module_init ()
void DRW_module_exit ()

Main Draw Loops (DRW_draw)

static struct DRWSelectBuffer g_select_buffer = {nullptr}
static void drw_draw_render_loop_3d (DRWContext &draw_ctx, RenderEngineType *engine_type)
static void drw_draw_render_loop_2d (DRWContext &draw_ctx)
void DRW_draw_view (const bContext *C)
void DRW_draw_render_loop_offscreen (Depsgraph *depsgraph, RenderEngineType *engine_type, ARegion *region, View3D *v3d, const bool is_image_render, const bool draw_background, const bool do_color_management, GPUOffScreen *ofs, GPUViewport *viewport)
bool DRW_render_check_grease_pencil (Depsgraph *depsgraph)
void DRW_render_gpencil (RenderEngine *engine, Depsgraph *depsgraph)
void DRW_render_to_image (RenderEngine *engine, Depsgraph *depsgraph, std::function< void(RenderEngine *, RenderLayer *, const rcti)> render_view_cb, std::function< void(RenderResult *)> store_metadata_cb)
void DRW_render_object_iter (RenderEngine *engine, Depsgraph *depsgraph, std::function< void(blender::draw::ObjectRef &, RenderEngine *, Depsgraph *)> callback)
void DRW_custom_pipeline_begin (DRWContext &draw_ctx, Depsgraph *)
void DRW_custom_pipeline_end (DRWContext &draw_ctx)
void DRW_cache_restart ()
void DRW_render_set_time (RenderEngine *engine, Depsgraph *depsgraph, int frame, float subframe)
static void draw_select_framebuffer_depth_only_setup (const int size[2])
void DRW_draw_select_loop (Depsgraph *depsgraph, ARegion *region, View3D *v3d, bool use_obedit_skip, bool draw_surface, bool, const bool do_material_sub_selection, const rcti *rect, DRW_SelectPassFn select_pass_fn, void *select_pass_user_data, DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data)
void DRW_draw_depth_loop (Depsgraph *depsgraph, ARegion *region, View3D *v3d, GPUViewport *viewport, const bool use_gpencil, const bool use_only_selected, const bool use_only_active_object)
void DRW_draw_select_id (Depsgraph *depsgraph, ARegion *region, View3D *v3d)
bool DRW_draw_in_progress ()

Function Documentation

◆ draw_select_framebuffer_depth_only_setup()

◆ draw_show_annotation()

◆ DRW_cache_free_old_batches()

◆ DRW_cache_restart()

void DRW_cache_restart ( )

Used when the render engine want to redo another cache populate inside the same render frame. Assumes it is called between DRW_custom_pipeline_begin/end().

Definition at line 1808 of file draw_context.cc.

References DRWContext::acquire_data(), DRWContext::data, drw_get(), DRWData::modules_begin_sync(), and DRWData::modules_exit().

Referenced by workbench_render_to_image().

◆ drw_callbacks_post_scene()

◆ drw_callbacks_post_scene_2D()

◆ drw_callbacks_pre_scene()

◆ drw_callbacks_pre_scene_2D()

◆ DRW_context_get()

const DRWContext * DRW_context_get ( )

Definition at line 2156 of file draw_context.cc.

References drw_get().

Referenced by blender::image_engine::ScreenSpaceDrawingMode::begin_sync(), blender::draw::compositor_engine::Instance::draw(), blender::draw::overlay::Instance::draw(), blender::draw::overlay::Armatures::draw_armature_pose(), blender::draw::drw_batch_cache_generate_requested(), blender::draw::drw_batch_cache_generate_requested_evaluated_mesh_or_curve(), drw_callbacks_post_scene(), drw_callbacks_post_scene_2D(), DRW_draw_select_loop(), DRW_object_is_visible_psys_in_active_context(), DRW_object_visibility_in_active_context(), blender::draw::drw_particle_get_hair_source(), blender::draw::drw_particle_update_ptcache(), blender::draw::drw_particle_update_ptcache_edit(), blender::draw::DRW_volume_batch_cache_get_wireframes_face(), blender::draw::overlay::Instance::end_sync(), blender::draw::compositor_engine::Context::get_compositing_region(), blender::draw::compositor_engine::Context::get_output(), blender::draw::compositor_engine::Context::get_pass(), blender::draw::compositor_engine::Context::get_view_name(), blender::draw::compositor_engine::Context::get_viewer_output(), blender::image_engine::ScreenTileTextures< Divisions >::gpu_texture_size(), blender::image_engine::Instance::image_sync(), blender::draw::edit_select::Instance::init(), blender::draw::gpencil::Instance::init(), blender::draw::overlay::Instance::init(), blender::eevee::Instance::init(), blender::eevee::Instance::init(), blender::image_engine::Instance::init(), blender::workbench::Instance::init(), blender::workbench::Instance::init(), blender::draw::particle_batch_cache_ensure_pos(), blender::draw::gpencil::Engine::render_to_image(), blender::draw::sculpt_batches_get_ex(), blender::eevee::store_node_tree_errors(), and workbench_render_to_image().

◆ DRW_custom_pipeline_begin()

void DRW_custom_pipeline_begin ( DRWContext & draw_ctx,
Depsgraph * depsgraph )

Assume a valid GL context is bound (and that the gl_context_mutex has been acquired). This function only setup DST and execute the given function.

Warning
similar to DRW_render_to_image you cannot use default lists (dfbl & dtxl).

Definition at line 1785 of file draw_context.cc.

References DRWContext::acquire_data(), DRWContext::data, and DRWData::modules_begin_sync().

Referenced by blender::eevee::Instance::light_bake_irradiance().

◆ DRW_custom_pipeline_end()

◆ DRW_draw_depth_loop()

◆ DRW_draw_in_progress()

bool DRW_draw_in_progress ( )

Query that drawing is in progress (use to prevent nested draw calls).

Definition at line 2145 of file draw_context.cc.

References DRWContext::is_active().

Referenced by ED_view3d_draw_offscreen_check_nested().

◆ DRW_draw_region_engine_info()

void DRW_draw_region_engine_info ( int xoffset,
int * yoffset,
int line_height )

◆ drw_draw_render_loop_2d()

◆ drw_draw_render_loop_3d()

◆ DRW_draw_render_loop_offscreen()

◆ DRW_draw_select_id()

◆ DRW_draw_select_loop()

void DRW_draw_select_loop ( Depsgraph * depsgraph,
ARegion * region,
View3D * v3d,
bool use_obedit_skip,
bool draw_surface,
bool use_nearest,
bool do_material_sub_selection,
const rcti * rect,
DRW_SelectPassFn select_pass_fn,
void * select_pass_user_data,
DRW_ObjectFilterFn object_filter_fn,
void * object_filter_user_data )

Object mode select-loop.

Definition at line 1862 of file draw_context.cc.

References DRWContext::acquire_data(), BASE_ENABLED_AND_VISIBLE_IN_DEFAULT_VIEWPORT, BASE_FROM_DUPLI, BASE_SELECTABLE, BKE_modifiers_is_deformed_by_armature(), BKE_object_is_visible_in_viewport(), BKE_view_layer_active_object_get(), BLI_assert, BLI_rcti_size_x(), BLI_rcti_size_y(), DEG_get_evaluated_scene(), DEG_get_evaluated_view_layer(), DEG_get_original(), depsgraph, DefaultTextureList::depth, draw_select_framebuffer_depth_only_setup(), drw_callbacks_pre_scene(), DRW_context_get(), drw_engines_cache_populate(), DRW_gpencil_engine_needed_viewport(), DRW_SELECT_PASS_POST, DRW_SELECT_PASS_PRE, DRWContext::enable_engines(), DRWContext::engines_data_validate(), DRWContext::engines_draw_scene(), DRWContext::engines_init_and_sync(), View3DOverlay::flag, View3D::flag2, FOREACH_OBJECT_IN_MODE_BEGIN, FOREACH_OBJECT_IN_MODE_END, blender::draw::foreach_obref_in_scene(), g_select_buffer, GPU_framebuffer_bind(), GPU_framebuffer_clear_depth(), GPU_framebuffer_restore(), Object::mode, nullptr, OB_ARMATURE, OB_MBALL, OB_MODE_POSE, OBEDIT_FROM_OBACT, ToolSettings::object_flag, DRWContext::object_pose, View3D::object_type_exclude_select, OBPOSE_FROM_OBACT, OBWEIGHTPAINT_FROM_OBACT, View3D::overlay, DRWContext::release_data(), SCE_OBJECT_MODE_LOCK, DRWContext::SELECT_OBJECT, DRWContext::SELECT_OBJECT_MATERIAL, Scene::toolsettings, Object::type, V3D_HIDE_OVERLAYS, V3D_OVERLAY_BONE_SELECT, and DRWContext::viewport_texture_list_get().

Referenced by view3d_gpu_select_ex().

◆ DRW_draw_view()

◆ drw_engines_cache_populate()

◆ DRW_engines_free()

◆ DRW_engines_register()

void DRW_engines_register ( )

◆ DRW_gpencil_engine_needed_viewport()

bool DRW_gpencil_engine_needed_viewport ( Depsgraph * depsgraph,
View3D * v3d )

This function only does following things to make quick checks for whether Grease Pencil drawing is needed:

  • Whether Grease Pencil objects are excluded in the viewport.
  • If any Grease Pencil typed ID exists inside the depsgraph. Note: it does not to full check for cases where Grease Pencil strokes are generated within a non-grease-pencil object, to do complete check, use DRW_render_check_grease_pencil.

Definition at line 1173 of file draw_context.cc.

References depsgraph, gpencil_any_exists(), and gpencil_object_is_excluded().

Referenced by drw_draw_render_loop_3d(), and DRW_draw_select_loop().

◆ DRW_module_exit()

void DRW_module_exit ( )

◆ DRW_module_init()

void DRW_module_init ( )

Definition at line 2247 of file draw_context.cc.

References BKE_curve_batch_cache_dirty_tag_cb, BKE_curve_batch_cache_free_cb, BKE_curves_batch_cache_dirty_tag_cb, BKE_curves_batch_cache_free_cb, BKE_grease_pencil_batch_cache_dirty_tag_cb, BKE_grease_pencil_batch_cache_free_cb, BKE_lattice_batch_cache_dirty_tag_cb, BKE_lattice_batch_cache_free_cb, BKE_mesh_batch_cache_dirty_tag_cb, BKE_mesh_batch_cache_free_cb, BKE_particle_batch_cache_dirty_tag_cb, BKE_particle_batch_cache_free_cb, BKE_pointcloud_batch_cache_dirty_tag_cb, BKE_pointcloud_batch_cache_free_cb, BKE_subsurf_modifier_free_gpu_cache_cb, BKE_volume_batch_cache_dirty_tag_cb, BKE_volume_batch_cache_free_cb, blender::draw::DRW_curve_batch_cache_dirty_tag(), blender::draw::DRW_curve_batch_cache_free(), blender::draw::DRW_curves_batch_cache_dirty_tag(), blender::draw::DRW_curves_batch_cache_free(), blender::draw::DRW_grease_pencil_batch_cache_dirty_tag(), blender::draw::DRW_grease_pencil_batch_cache_free(), blender::draw::DRW_lattice_batch_cache_dirty_tag(), blender::draw::DRW_lattice_batch_cache_free(), blender::draw::DRW_mesh_batch_cache_dirty_tag(), blender::draw::DRW_mesh_batch_cache_free(), blender::draw::DRW_particle_batch_cache_dirty_tag(), blender::draw::DRW_particle_batch_cache_free(), blender::draw::DRW_pointcloud_batch_cache_dirty_tag(), blender::draw::DRW_pointcloud_batch_cache_free(), blender::draw::DRW_subdiv_cache_free(), blender::draw::DRW_volume_batch_cache_dirty_tag(), and blender::draw::DRW_volume_batch_cache_free().

Referenced by RE_engines_init().

◆ DRW_object_get_editmesh_cage_for_drawing()

const Mesh * DRW_object_get_editmesh_cage_for_drawing ( const Object & object)

Same as DRW_object_get_data_for_drawing, but for the editmesh cage, if it exists.

Definition at line 374 of file draw_context.cc.

References BKE_mesh_wrapper_ensure_subdivision(), BKE_object_get_editmesh_eval_cage(), BKE_subsurf_modifier_has_gpu_subdiv(), BLI_assert, and OB_MESH.

Referenced by blender::draw::DRW_mesh_batch_cache_create_requested(), and blender::draw::mesh_render_data_create().

◆ DRW_object_is_in_edit_mode()

bool DRW_object_is_in_edit_mode ( const Object * ob)

Does ob needs to be rendered in edit mode.

When using duplicate linked meshes, objects that are not in edit-mode will be drawn as it is in edit mode, when another object with the same mesh is in edit mode. This will not be the case when one of the objects are influenced by modifiers.

Definition at line 308 of file draw_context.cc.

References BKE_object_is_in_editmode(), ELEM, Object::mode, OB_CURVES, OB_MESH, OB_MODE_EDIT, and Object::type.

Referenced by DRW_draw_select_id(), blender::draw::overlay::MeshUVs::edit_object_sync(), blender::draw::ObjectRef::parent_is_in_edit_paint_mode(), blender::draw::Manager::resource_handle(), blender::draw::Manager::resource_handle(), and blender::draw::Manager::resource_handle_for_psys().

◆ DRW_object_is_renderable()

◆ DRW_object_is_visible_psys_in_active_context()

◆ DRW_object_use_hide_faces()

◆ DRW_object_visibility_in_active_context()

◆ DRW_render_check_grease_pencil()

◆ DRW_render_gpencil()

◆ DRW_render_object_iter()

◆ DRW_render_set_time()

void DRW_render_set_time ( RenderEngine * engine,
Depsgraph * depsgraph,
int frame,
float subframe )

◆ DRW_render_to_image()

◆ DRW_text_cache_ensure()

DRWTextStore * DRW_text_cache_ensure ( )

◆ DRW_viewport_data_create()

DRWData * DRW_viewport_data_create ( )

◆ drw_viewport_data_ensure()

DRWData * drw_viewport_data_ensure ( GPUViewport * viewport)
static

Definition at line 439 of file draw_context.cc.

References data, DRW_viewport_data_create(), and GPU_viewport_data_get().

Referenced by DRWContext::acquire_data().

◆ DRW_viewport_data_free()

◆ DRW_viewport_pass_texture_get()

blender::draw::TextureFromPool & DRW_viewport_pass_texture_get ( const char * pass_name)

Returns a TextureFromPool stored in the given view data for the pass identified by the given pass name. Engines should call this function for each of the passes needed by the viewport compositor in every redraw, then it should allocate the texture and write the pass data to it. The texture should cover the entire viewport.

Definition at line 528 of file draw_context.cc.

References drw_get(), Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_or_add_cb(), DRWContext::view_data_active, and DRWViewData::viewport_compositor_passes.

Referenced by blender::draw::gpencil::Instance::acquire_resources(), blender::draw::compositor_engine::Context::get_pass(), and blender::eevee::Film::write_viewport_compositor_passes().

◆ DRW_viewport_request_redraw()

◆ gpencil_any_exists()

bool gpencil_any_exists ( Depsgraph * depsgraph)
static

◆ gpencil_object_is_excluded()

bool gpencil_object_is_excluded ( View3D * v3d)
static

Variable Documentation

◆ g_select_buffer