Blender V5.0
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.h"
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
26/* -------------------------------------------------------------------- */
29
31{
32 if (engine) {
34 }
35
37
38 /* Free GPU context after engine, which may need context for cleanup. */
39 display.reset();
40
43}
44
46{
47 display = std::make_shared<RenderDisplay>();
48}
49
51{
52 RE_compositor_free(*this);
53
54 BKE_curvemapping_free_data(&r.mblur_shutter_curve);
55
57}
58
59bool Render::prepare_viewlayer(ViewLayer *view_layer, Depsgraph *depsgraph)
60{
62 return true;
63 }
64
66}
67
69
70/* -------------------------------------------------------------------- */
73
75{
78 GPU_context_active_set(static_cast<GPUContext *>(blender_gpu_context));
79 GPU_context_discard(static_cast<GPUContext *>(blender_gpu_context));
80 blender_gpu_context = nullptr;
81 }
82
85 system_gpu_context = nullptr;
86
87 /* If in main thread, reset window context. */
88 if (BLI_thread_is_main()) {
90 }
91 }
92
93 display_update_cb = nullptr;
95 stats_draw_cb = nullptr;
96 progress_cb = nullptr;
97 draw_lock_cb = nullptr;
98 test_break_cb = nullptr;
99}
100
102{
104
105 if (system_gpu_context == nullptr) {
106 /* Needs to be created in the main thread. */
108 /* The context is activated during creation, so release it here since the function should not
109 * have context activation as a side effect. Then activate the drawable's context below. */
110 if (system_gpu_context) {
112 }
114 }
115}
116
125
127{
128 if (display_update_cb) {
129 display_update_cb(duh, render_result, rect);
130 }
131}
132
139
141{
142 if (stats_draw_cb) {
143 stats_draw_cb(sdh, render_stats);
144 }
145}
146
148{
149 if (progress_cb) {
151 }
152}
153
155{
156 if (draw_lock_cb) {
157 draw_lock_cb(dlh, true);
158 }
159}
161{
162 if (draw_lock_cb) {
163 draw_lock_cb(dlh, false);
164 }
165}
166
168{
169 if (!test_break_cb) {
170 return false;
171 }
172
173 return test_break_cb(tbh);
174}
175
void BKE_curvemapping_free_data(CurveMapping *cumap)
#define BLI_assert(a)
Definition BLI_assert.h:46
void BLI_rw_mutex_end(ThreadRWMutex *mutex)
Definition threads.cc:482
void BLI_mutex_end(ThreadMutex *mutex)
Definition threads.cc:360
int BLI_thread_is_main(void)
Definition threads.cc:179
GPUContext * GPU_context_create(void *ghost_window, void *ghost_context)
void GPU_context_discard(GPUContext *)
void GPU_context_active_set(GPUContext *)
BPy_StructRNA * depsgraph
void RE_engine_free(RenderEngine *engine)
void RE_compositor_free(Render &render)
void render_result_free(RenderResult *rr)
ThreadMutex engine_draw_mutex
virtual ~BaseRender()
struct RenderEngine * engine
ThreadRWMutex resultmutex
std::shared_ptr< RenderDisplay > display
RenderResult * result
void stats_draw(RenderStats *render_stats)
void progress(float progress)
void display_update(RenderResult *render_result, rcti *rect)
void(* current_scene_update_cb)(void *handle, struct Scene *scene)
void ensure_system_gpu_context()
void(* draw_lock_cb)(void *handle, bool lock)
void(* display_update_cb)(void *handle, RenderResult *rr, rcti *rect)
void(* stats_draw_cb)(void *handle, RenderStats *ri)
void * system_gpu_context
void current_scene_update(struct Scene *scene)
void * blender_gpu_context
void * ensure_blender_gpu_context()
void(* progress_cb)(void *handle, float i)
bool(* test_break_cb)(void *handle)
~Render() override
bool(* prepare_viewlayer_cb)(void *handle, struct ViewLayer *vl, struct Depsgraph *depsgraph)
RenderResult * pushedresult
RenderData r
bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) override
void * prepare_vl_handle
void * WM_system_gpu_context_create()
void wm_window_reset_drawable()
void WM_system_gpu_context_dispose(void *context)
void WM_system_gpu_context_activate(void *context)
void WM_system_gpu_context_release(void *context)