47 Depsgraph *depsgraph_;
64 void *gl_context_ =
nullptr;
77 std::mutex result_mutex_;
92 original_probes_(probes)
96 bake_result_.
fill(
nullptr);
122 if (bake_result_[i] ==
nullptr) {
125 Object *orig_ob = original_probes_[i];
128 std::scoped_lock
lock(result_mutex_);
137 bake_result_[i] =
nullptr;
147 void run(
bool *stop =
nullptr,
bool *do_update =
nullptr,
float *progress =
nullptr)
167 [
this]() { context_enable(); },
168 [
this]() { context_disable(); },
169 [&]() {
return (
G.is_break ==
true) || ((stop !=
nullptr) ? *stop :
false); },
172 std::scoped_lock
lock(result_mutex_);
174 if (bake_result_[i] !=
nullptr) {
177 bake_result_[i] = cache_frame;
185 *progress = (i + grid_progress) / original_probes_.
size();
194 if ((
G.is_break ==
true) || (stop !=
nullptr && *stop ==
true)) {
203 void context_enable(
bool render_begin =
true)
210 else if (gl_context_ ==
nullptr) {
217 if (gpu_context_ ==
nullptr) {
230 void context_disable()
238 else if (gl_context_ ==
nullptr) {
257 void delete_resources()
260 context_enable(
false);
272 else if (gl_context_ ==
nullptr) {
278 if (gpu_context_ !=
nullptr) {
323 bmain, view_layer, scene, std::move(original_probes),
true, report, frame, delay_ms);
346 bmain, view_layer, scene, std::move(original_probes),
false, report, frame);
348 return reinterpret_cast<void *
>(
bake);
353 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)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
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 *)
struct GPUContext GPUContext
constexpr int64_t size() const
IndexRange index_range() const
void resize(const int64_t new_size)
void fill(const T &value) const
A running instance of the engine.
void light_bake_irradiance(Object &probe, FunctionRef< void()> context_enable, FunctionRef< void()> context_disable, FunctionRef< bool()> stop, FunctionRef< void(LightProbeGridCacheFrame *, float progress)> result_update)
void init_light_bake(Depsgraph *depsgraph, draw::Manager *manager)
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 run(bool *stop=nullptr, bool *do_update=nullptr, float *progress=nullptr)
void EEVEE_NEXT_lightbake_job(void *job_data, wmJobWorkerStatus *worker_status)
void EEVEE_NEXT_lightbake_update(void *job_data)
void EEVEE_NEXT_lightbake_job_data_free(void *job_data)
wmJob * EEVEE_NEXT_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_NEXT_lightbake_job_data_alloc(Main *bmain, ViewLayer *view_layer, Scene *scene, blender::Vector< Object * > original_probes, std::string &report, int frame)
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)