Blender V5.3
render_types.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "render_types.h"
10
11#include <memory>
12
13#include "BKE_colortools.hh"
14
15#include "BLI_assert.hh"
16#include "RE_compositor.hh"
17#include "RE_engine.h"
18
19#include "render_result.h"
20
21#include "GPU_context.hh"
22
23#include "WM_api.hh"
24#include "wm_window.hh"
25
26namespace blender {
27
28/* -------------------------------------------------------------------- */
31
33{
34 if (engine) {
36 }
37
39
40 /* Free GPU context after engine, which may need context for cleanup. */
41 display.reset();
42
45}
46
48{
49 display = std::make_shared<RenderDisplay>();
50}
51
60
61bool Render::prepare_viewlayer(ViewLayer *view_layer, Depsgraph *depsgraph)
62{
64 return true;
65 }
66
67 return prepare_viewlayer_cb(prepare_vl_handle, view_layer, depsgraph);
68}
69
71
72/* -------------------------------------------------------------------- */
75
77{
79
80 display_update_cb = nullptr;
82 stats_draw_cb = nullptr;
83 progress_cb = nullptr;
84 draw_lock_cb = nullptr;
85 test_break_cb = nullptr;
86}
87
89{
92 GPU_context_active_set(static_cast<GPUContext *>(blender_gpu_context));
93 GPU_context_discard(static_cast<GPUContext *>(blender_gpu_context));
94 blender_gpu_context = nullptr;
95 }
96
99 system_gpu_context = nullptr;
100
101 /* If in main thread, reset window context. */
102 if (BLI_thread_is_main()) {
104 }
105 }
106}
107
109{
111
112 if (system_gpu_context == nullptr) {
113 /* Needs to be created in the main thread. */
115 /* The context is activated during creation, so release it here since the function should not
116 * have context activation as a side effect. Then activate the drawable's context below. */
117 if (system_gpu_context) {
119 }
121 }
122}
123
132
134{
135 if (display_update_cb) {
136 display_update_cb(duh, render_result);
137 }
138}
139
146
148{
149 if (stats_draw_cb) {
150 stats_draw_cb(sdh, render_stats);
151 }
152}
153
155{
156 if (progress_cb) {
158 }
159}
160
162{
163 if (draw_lock_cb) {
164 draw_lock_cb(dlh, true);
165 }
166}
168{
169 if (draw_lock_cb) {
170 draw_lock_cb(dlh, false);
171 }
172}
173
175{
176 if (!test_break_cb) {
177 return false;
178 }
179
180 return test_break_cb(tbh);
181}
182
184
185} // namespace blender
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RE_compositor_free(Render &render)
GPUContext * GPU_context_create(GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context)
void WM_system_gpu_context_release(GHOST_IContext *context)
void GPU_context_active_set(GPUContext *)
GHOST_IContext * WM_system_gpu_context_create()
void wm_window_reset_drawable()
void RE_engine_free(RenderEngine *engine)
void WM_system_gpu_context_dispose(GHOST_IContext *context)
void render_result_free(RenderResult *rr)
int BLI_thread_is_main()
Definition threads.cc:184
void WM_system_gpu_context_activate(GHOST_IContext *context)
void BLI_mutex_end(ThreadMutex *mutex)
Definition threads.cc:363
void BLI_rw_mutex_end(ThreadRWMutex *mutex)
Definition threads.cc:485
void BKE_curvemapping_free_data(CurveMapping *cumap)
void GPU_context_discard(GPUContext *)
std::shared_ptr< RenderDisplay > display
ThreadMutex engine_draw_mutex
ThreadRWMutex resultmutex
RenderResult * result
struct RenderEngine * engine
struct CurveMapping mblur_shutter_curve
void(*) stats_draw_cb(void *handle, RenderStats *ri)
void * ensure_blender_gpu_context()
void display_update(RenderResult *render_result)
void(*) progress_cb(void *handle, float i)
void(*) display_update_cb(void *handle, RenderResult *rr)
void stats_draw(RenderStats *render_stats)
void(*) current_scene_update_cb(void *handle, struct Scene *scene)
void current_scene_update(struct Scene *scene)
void(*) draw_lock_cb(void *handle, bool lock)
void progress(float progress)
GHOST_IContext * system_gpu_context
bool(*) test_break_cb(void *handle)
void * prepare_vl_handle
bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) override
RenderResult * pushedresult
~Render() override
bool(*) prepare_viewlayer_cb(void *handle, struct ViewLayer *vl, struct Depsgraph *depsgraph)