46 Depsgraph *depsgraph_;
63 void *gl_context_ =
nullptr;
65 GPUContext *gpu_context_ =
nullptr;
91 original_probes_(probes)
94 bake_result_.resize(probes.
size());
95 bake_result_.fill(
nullptr);
120 for (
auto i : bake_result_.index_range()) {
121 if (bake_result_[
i] ==
nullptr) {
124 Object *orig_ob = original_probes_[
i];
127 std::scoped_lock
lock(result_mutex_);
136 bake_result_[
i] =
nullptr;
146 void run(
const bool *stop =
nullptr,
bool *do_update =
nullptr,
float *progress =
nullptr)
158 instance_->init_light_bake(depsgraph_, manager_);
161 for (
auto i : original_probes_.index_range()) {
164 instance_->light_bake_irradiance(
166 [
this]() { context_enable(); },
167 [
this]() { context_disable(); },
168 [&]() {
return (
G.is_break ==
true) || ((stop !=
nullptr) ? *stop :
false); },
171 std::scoped_lock
lock(result_mutex_);
173 if (bake_result_[
i] !=
nullptr) {
176 bake_result_[
i] = cache_frame;
184 *progress = (
i + grid_progress) / original_probes_.size();
190 report_ = instance_->info_get();
193 if ((
G.is_break ==
true) || (stop !=
nullptr && *stop ==
true)) {
202 void context_enable(
bool render_begin =
true)
209 else if (gl_context_ ==
nullptr) {
216 if (gpu_context_ ==
nullptr) {
229 void context_disable()
237 else if (gl_context_ ==
nullptr) {
256 void delete_resources()
259 context_enable(
false);
271 else if (gl_context_ ==
nullptr) {
277 if (gpu_context_ !=
nullptr) {
317 "Baking lighting...",
322 bmain, view_layer, scene, std::move(original_probes),
true, report, frame, delay_ms);
342 bmain, view_layer, scene, std::move(original_probes),
false, report, frame);
344 return reinterpret_cast<void *
>(
bake);
349 delete static_cast<LightBake *
>(job_data);
General operations for probes.
void BKE_lightprobe_grid_cache_frame_free(struct LightProbeGridCacheFrame *cache)
int BLI_thread_is_main(void)
Platform independent time functions.
void BLI_time_sleep_ms(int ms)
void DEG_id_tag_update(ID *id, unsigned int flags)
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
void DEG_graph_free(Depsgraph *graph)
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame, DepsgraphEvaluateSyncWriteback sync_writeback=DEG_EVALUATE_SYNC_WRITEBACK_NO)
void DEG_graph_relations_update(Depsgraph *graph)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void DRW_blender_gpu_render_context_disable(void *re_gpu_context)
void DRW_gpu_context_disable()
void DRW_system_gpu_render_context_enable(void *re_system_gpu_context)
void DRW_gpu_context_enable()
void DRW_system_gpu_render_context_disable(void *re_system_gpu_context)
void DRW_blender_gpu_render_context_enable(void *re_gpu_context)
bool GPU_use_main_context_workaround()
GPUContext * GPU_context_create(void *ghost_window, void *ghost_context)
void GPU_context_main_lock()
void GPU_context_main_unlock()
void GPU_context_discard(GPUContext *)
constexpr int64_t size() const
A running instance of the engine.
void run(const bool *stop=nullptr, bool *do_update=nullptr, float *progress=nullptr)
LightBake(Main *bmain, ViewLayer *view_layer, Scene *scene, Span< Object * > probes, bool run_as_job, std::string &report, int frame, int delay_ms=0)
void * EEVEE_lightbake_job_data_alloc(Main *bmain, ViewLayer *view_layer, Scene *scene, blender::Vector< Object * > original_probes, std::string &report, int frame)
void EEVEE_lightbake_job(void *job_data, wmJobWorkerStatus *worker_status)
void EEVEE_lightbake_job_data_free(void *job_data)
wmJob * EEVEE_lightbake_job_create(wmWindowManager *wm, wmWindow *win, Main *bmain, ViewLayer *view_layer, Scene *scene, blender::Vector< Object * > original_probes, std::string &report, int delay_ms, int frame)
void EEVEE_lightbake_update(void *job_data)
static void update(bNodeTree *ntree)
struct LightProbeGridCacheFrame * grid_static_cache
struct LightProbeObjectCache * lightprobe_cache
void WM_jobs_stop_type(wmWindowManager *wm, const void *owner, eWM_JobType job_type)
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, const eWM_JobFlag flag, const eWM_JobType job_type)
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
bool WM_jobs_test(const wmWindowManager *wm, const void *owner, int job_type)
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))
void * WM_system_gpu_context_create()
void wm_window_reset_drawable()
void WM_system_gpu_context_dispose(void *context)