48 Depsgraph *depsgraph_;
67 GPUContext *gpu_context_ =
nullptr;
93 original_probes_(probes)
96 bake_result_.resize(probes.
size());
97 bake_result_.fill(
nullptr);
122 for (
auto i : bake_result_.index_range()) {
123 if (bake_result_[i] ==
nullptr) {
126 Object *orig_ob = original_probes_[i];
129 std::scoped_lock
lock(result_mutex_);
138 bake_result_[i] =
nullptr;
148 void run(
const bool *stop =
nullptr,
bool *do_update =
nullptr,
float *progress =
nullptr)
160 instance_->init_light_bake(depsgraph_, manager_);
163 for (
auto i : original_probes_.index_range()) {
166 instance_->light_bake_irradiance(
168 [
this]() { context_enable(); },
169 [
this]() { context_disable(); },
170 [&]() {
return (
G.is_break ==
true) || ((stop !=
nullptr) ? *stop :
false); },
173 std::scoped_lock
lock(result_mutex_);
175 if (bake_result_[i] !=
nullptr) {
178 bake_result_[i] = cache_frame;
186 *progress = (i + grid_progress) / original_probes_.size();
192 report_ = instance_->info_get();
195 if ((
G.is_break ==
true) || (stop !=
nullptr && *stop ==
true)) {
204 void context_enable(
bool render_begin =
true)
211 else if (gl_context_ ==
nullptr) {
218 if (gpu_context_ ==
nullptr) {
231 void context_disable()
239 else if (gl_context_ ==
nullptr) {
258 void delete_resources()
261 context_enable(
false);
273 else if (gl_context_ ==
nullptr) {
279 if (gpu_context_ !=
nullptr) {
296using namespace blender::eevee;
319 "Baking lighting...",
324 bmain, view_layer, scene, std::move(original_probes),
true, report, frame, delay_ms);
344 bmain, view_layer, scene, std::move(original_probes),
false, report, frame);
346 return reinterpret_cast<void *
>(
bake);
351 delete static_cast<LightBake *
>(job_data);
356 static_cast<LightBake *
>(job_data)->update();
General operations for probes.
Platform independent time functions.
constexpr int64_t size() const
constexpr StringRefNull()
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 DRW_gpu_context_enable()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void DRW_blender_gpu_render_context_enable(void *re_gpu_context)
void EEVEE_lightbake_update(void *job_data)
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
void WM_jobs_stop_type(wmWindowManager *wm, const void *owner, eWM_JobType job_type)
void DRW_system_gpu_render_context_disable(GHOST_IContext *re_system_gpu_context)
void DEG_graph_free(Depsgraph *graph)
GPUContext * GPU_context_create(GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context)
void BLI_time_sleep_ms(int ms)
void GPU_context_main_unlock()
bool GPU_use_main_context_workaround()
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
void DRW_system_gpu_render_context_enable(GHOST_IContext *re_system_gpu_context)
void DRW_blender_gpu_render_context_disable(void *re_gpu_context)
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))
GHOST_IContext * WM_system_gpu_context_create()
void wm_window_reset_drawable()
void DRW_gpu_context_disable()
void WM_system_gpu_context_dispose(GHOST_IContext *context)
void DEG_id_tag_update(ID *id, unsigned int flags)
bool WM_jobs_has_running(const wmWindowManager *window_manager, const void *owner, const eWM_JobType type, const eWM_JobFlag exclude_flags)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
wmJob * EEVEE_lightbake_job_create(wmWindowManager *wm, wmWindow *win, Main *bmain, ViewLayer *view_layer, Scene *scene, Vector< Object * > original_probes, std::string &report, int delay_ms, int frame)
void EEVEE_lightbake_job_data_free(void *job_data)
void BKE_lightprobe_grid_cache_frame_free(struct LightProbeGridCacheFrame *cache)
void * EEVEE_lightbake_job_data_alloc(Main *bmain, ViewLayer *view_layer, Scene *scene, Vector< Object * > original_probes, std::string &report, int frame)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, const eWM_JobFlag flag, const eWM_JobType job_type)
void DEG_graph_relations_update(Depsgraph *graph)
void DEG_evaluate_on_framechange(Depsgraph *graph, float frame, DepsgraphEvaluateSyncWriteback sync_writeback=DEG_EVALUATE_SYNC_WRITEBACK_NO)
void GPU_context_main_lock()
void EEVEE_lightbake_job(void *job_data, wmJobWorkerStatus *worker_status)
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote, void(*timer_step)(void *))
void GPU_context_discard(GPUContext *)
struct LightProbeGridCacheFrame * grid_static_cache
struct LightProbeObjectCache * lightprobe_cache