2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2005 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup editors
|
2011-02-21 07:25:24 +00:00
|
|
|
*/
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#pragma once
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2021-12-27 17:26:09 +01:00
|
|
|
#include "DNA_ID_enums.h"
|
2023-08-08 17:36:06 +02:00
|
|
|
#include "DNA_material_types.h"
|
2008-12-13 19:00:54 +00:00
|
|
|
#include "DNA_vec_types.h"
|
|
|
|
|
|
2017-11-28 13:04:21 +01:00
|
|
|
struct DEGEditorUpdateContext;
|
2021-01-28 13:36:23 +01:00
|
|
|
struct Depsgraph;
|
2.5
Added WM Jobs manager
- WM can manage threaded jobs for you; just provide a couple
of components to get it work:
- customdata, free callback for it
- timer step, notifier code
- start callback, update callback
- Once started, each job runs an own timer, and will for
every time step check necessary updates, or close the
job when ready.
- No drawing happens in jobs, that's for notifiers!
- Every job stores an owner pointer, and based on this owner
it will prevent multiple jobs to enter the stack.
Instead it will re-use a running job, signal it to stop
and allow caller to re-initialize it even.
- Check new wm_jobs.c for more explanation. Jobs API is still
under construction.
Fun: BLI_addtail(&wm->jobs, steve); :)
Put Node shader previews back using wmJobs
- Preview calculating is now fully threaded (1 thread still)
- Thanks to new event system + notifiers, you can see
previews update even while dragging sliders!
- Currently it only starts when you change a node setting.
Warning: the thread render shares Node data, so don't delete
nodes while it renders! This topic is on the todo to make safe.
Also:
- bug in region initialize (do_versions) showed channel list in
node editor wrong.
- flagged the channel list 'hidden' now, it was really in the
way! This is for later to work on anyway.
- recoded Render API callbacks so it gets handlers passed on,
no globals to use anymore, remember?
- previewrender code gets now so much nicer! Will remove a lot
of stuff from code soon.
2009-01-22 14:59:49 +00:00
|
|
|
struct ID;
|
2021-01-28 13:36:23 +01:00
|
|
|
struct MTex;
|
2021-02-18 14:14:17 +11:00
|
|
|
struct Main;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
struct Render;
|
2011-11-28 14:55:35 +00:00
|
|
|
struct Scene;
|
2012-04-26 12:30:37 +00:00
|
|
|
struct ScrArea;
|
2021-02-18 14:14:17 +11:00
|
|
|
struct bContext;
|
|
|
|
|
struct bScreen;
|
2022-02-18 18:11:16 +01:00
|
|
|
struct PreviewImage;
|
2023-08-08 17:36:06 +02:00
|
|
|
struct ViewLayer;
|
|
|
|
|
struct World;
|
2021-01-28 13:36:23 +01:00
|
|
|
struct wmWindow;
|
2014-11-18 15:51:31 +01:00
|
|
|
struct wmWindowManager;
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `render_ops.cc` */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_operatortypes_render();
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2023-07-31 11:50:54 +10:00
|
|
|
/* `render_update.cc` */
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_render_engine_changed(Main *bmain, bool update_scene_data);
|
|
|
|
|
void ED_render_engine_area_exit(Main *bmain, ScrArea *area);
|
|
|
|
|
void ED_render_view_layer_changed(Main *bmain, bScreen *screen);
|
2017-11-28 13:04:21 +01:00
|
|
|
|
|
|
|
|
/* Callbacks handling data update events coming from depsgraph. */
|
|
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_render_id_flush_update(const DEGEditorUpdateContext *update_ctx, ID *id);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Update all 3D viewport render and draw engines on changes to the scene.
|
|
|
|
|
* This is called by the dependency graph when it detects changes.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, bool updated);
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Update 3D viewport render or draw engine on changes to the scene or view settings.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_render_view3d_update(Depsgraph *depsgraph, wmWindow *window, ScrArea *area, bool updated);
|
Sorry, three commits in one, became difficult to untangle..
Editors Modules
* render/ module added in editors, moved the preview render code there and
also shading related operators.
* physics/ module made more consistent with other modules. renaming files,
making a single physics_ops.c for operators and keymaps. Also move all
particle related operators here now.
* space_buttons/ now should have only operators relevant to the buttons
specificially.
Updates & Notifiers
* Material/Texture/World/Lamp can now be passed to DAG_id_flush_update,
which will go back to a callback in editors. Eventually these should
be in the depsgraph itself, but for now this gives a unified call for
doing updates.
* GLSL materials are now refreshed on changes. There's still various
cases missing,
* Preview icons now hook into this system, solving various update cases
that were missed before.
* Also fixes issue in my last commit, where some preview would not render,
problem is avoided in the new system.
Icon Rendering
* On systems with support for non-power of two textures, an OpenGL texture
is now used instead of glDrawPixels. This avoids problems with icons get
clipped on region borders. On my Linux desktop, this gives an 1.1x speedup,
and on my Mac laptop a 2.3x speedup overall in redrawing the full window,
with the default setup. The glDrawPixels implementation on Mac seems to
have a lot of overhread.
* Preview icons are now drawn using proper premul alpha, and never faded so
you can see them clearly.
* Also tried to fix issue with texture node preview rendering, globals can't
be used with threads reliably.
2009-09-29 19:12:12 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
Scene *ED_render_job_get_scene(const bContext *C);
|
|
|
|
|
Scene *ED_render_job_get_current_scene(const bContext *C);
|
2013-07-08 22:26:10 +00:00
|
|
|
|
2024-03-26 17:54:30 +11:00
|
|
|
/**
|
|
|
|
|
* Render the preview method.
|
2012-03-03 16:31:46 +00:00
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
enum ePreviewRenderMethod {
|
2024-03-26 17:54:30 +11:00
|
|
|
/** Preview is rendered for buttons window. */
|
2015-05-11 16:29:12 +02:00
|
|
|
PR_BUTS_RENDER = 0,
|
2024-03-26 17:54:30 +11:00
|
|
|
/** Preview is rendered for icons. hopefully fast enough for at least 32x32. */
|
2015-05-11 16:29:12 +02:00
|
|
|
PR_ICON_RENDER = 1,
|
2024-03-26 17:54:30 +11:00
|
|
|
/** No render, we just ensure deferred icon data gets generated. */
|
2021-12-15 14:27:38 -06:00
|
|
|
PR_ICON_DEFERRED = 2,
|
2023-08-04 22:15:25 -04:00
|
|
|
};
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2023-08-08 17:36:06 +02:00
|
|
|
bool ED_check_engine_supports_preview(const Scene *scene);
|
|
|
|
|
const char *ED_preview_collection_name(ePreviewType pr_type);
|
|
|
|
|
|
|
|
|
|
void ED_preview_ensure_dbase(bool with_gpencil);
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_preview_free_dbase();
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2021-12-09 00:55:11 +11:00
|
|
|
/**
|
|
|
|
|
* Check if \a id is supported by the automatic preview render.
|
|
|
|
|
*/
|
2023-08-04 22:15:25 -04:00
|
|
|
bool ED_preview_id_is_supported(const ID *id);
|
2021-11-22 20:00:47 +01:00
|
|
|
|
2023-08-08 17:36:06 +02:00
|
|
|
void ED_preview_set_visibility(Main *pr_main,
|
|
|
|
|
Scene *scene,
|
|
|
|
|
ViewLayer *view_layer,
|
|
|
|
|
ePreviewType pr_type,
|
|
|
|
|
ePreviewRenderMethod pr_method);
|
2024-01-30 14:53:41 -05:00
|
|
|
World *ED_preview_prepare_world(Main *pr_main,
|
|
|
|
|
const Scene *scene,
|
|
|
|
|
const World *world,
|
|
|
|
|
ID_Type id_type,
|
|
|
|
|
ePreviewRenderMethod pr_method);
|
2023-08-08 17:36:06 +02:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_preview_shader_job(const bContext *C,
|
2009-10-07 14:48:29 +00:00
|
|
|
void *owner,
|
2023-08-04 22:15:25 -04:00
|
|
|
ID *id,
|
|
|
|
|
ID *parent,
|
|
|
|
|
MTex *slot,
|
2009-10-07 14:48:29 +00:00
|
|
|
int sizex,
|
|
|
|
|
int sizey,
|
2021-12-27 17:26:09 +01:00
|
|
|
ePreviewRenderMethod method);
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_preview_icon_render(
|
|
|
|
|
const bContext *C, Scene *scene, PreviewImage *prv_img, ID *id, enum eIconSizes icon_size);
|
|
|
|
|
void ED_preview_icon_job(
|
|
|
|
|
const bContext *C, PreviewImage *prv_img, ID *id, enum eIconSizes icon_size, bool delay);
|
2021-11-24 11:20:35 +01:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_preview_restart_queue_free();
|
|
|
|
|
void ED_preview_restart_queue_add(ID *id, enum eIconSizes size);
|
|
|
|
|
void ED_preview_restart_queue_work(const bContext *C);
|
2021-11-24 11:20:35 +01:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_preview_kill_jobs(wmWindowManager *wm, Main *bmain);
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slot, rcti *rect);
|
2008-12-13 19:00:54 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_render_clear_mtex_copybuf();
|
2010-03-29 05:37:34 +00:00
|
|
|
|
2023-08-04 22:15:25 -04:00
|
|
|
void ED_render_internal_init();
|