2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2017 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup draw_engine
|
2017-05-01 14:55:59 +02:00
|
|
|
*
|
|
|
|
|
* Base engine for external render engines.
|
|
|
|
|
* We use it for depth and non-mesh objects.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-10-03 16:01:33 +02:00
|
|
|
#include "DRW_engine.h"
|
2017-05-01 14:55:59 +02:00
|
|
|
#include "DRW_render.h"
|
|
|
|
|
|
2020-05-14 12:42:52 +02:00
|
|
|
#include "DNA_modifier_types.h"
|
2017-05-01 14:55:59 +02:00
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
|
|
2023-10-09 23:41:53 +02:00
|
|
|
#include "BKE_object.hh"
|
2020-05-14 12:42:52 +02:00
|
|
|
#include "BKE_particle.h"
|
2019-09-19 17:31:07 +02:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_image.hh"
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2017-05-01 14:55:59 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
#include "GPU_batch.h"
|
|
|
|
|
#include "GPU_debug.h"
|
2017-05-01 14:55:59 +02:00
|
|
|
#include "GPU_matrix.h"
|
|
|
|
|
#include "GPU_shader.h"
|
2020-10-22 01:19:10 +02:00
|
|
|
#include "GPU_state.h"
|
2017-05-01 14:55:59 +02:00
|
|
|
#include "GPU_viewport.h"
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
#include "RE_engine.h"
|
|
|
|
|
#include "RE_pipeline.h"
|
|
|
|
|
|
2019-02-23 18:31:45 +11:00
|
|
|
#include "external_engine.h" /* own include */
|
|
|
|
|
|
2017-05-01 14:55:59 +02:00
|
|
|
/* Shaders */
|
|
|
|
|
|
|
|
|
|
#define EXTERNAL_ENGINE "BLENDER_EXTERNAL"
|
|
|
|
|
|
2023-07-27 14:16:58 +02:00
|
|
|
extern "C" char datatoc_basic_depth_frag_glsl[];
|
|
|
|
|
extern "C" char datatoc_basic_depth_vert_glsl[];
|
2020-06-03 10:29:32 +02:00
|
|
|
|
2023-07-27 14:16:58 +02:00
|
|
|
extern "C" char datatoc_common_view_lib_glsl[];
|
2020-06-03 10:29:32 +02:00
|
|
|
|
2017-05-01 14:55:59 +02:00
|
|
|
/* *********** LISTS *********** */
|
|
|
|
|
|
|
|
|
|
/* GPUViewport.storage
|
2020-09-10 09:45:25 +10:00
|
|
|
* Is freed every time the viewport engine changes. */
|
2023-07-24 10:10:47 +10:00
|
|
|
struct EXTERNAL_Storage {
|
2017-05-01 14:55:59 +02:00
|
|
|
int dummy;
|
2023-07-24 10:10:47 +10:00
|
|
|
};
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2023-07-24 10:10:47 +10:00
|
|
|
struct EXTERNAL_StorageList {
|
2023-06-03 08:36:28 +10:00
|
|
|
EXTERNAL_Storage *storage;
|
2017-05-01 14:55:59 +02:00
|
|
|
struct EXTERNAL_PrivateData *g_data;
|
2023-07-24 10:10:47 +10:00
|
|
|
};
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2023-07-24 10:10:47 +10:00
|
|
|
struct EXTERNAL_FramebufferList {
|
2023-06-03 08:36:28 +10:00
|
|
|
GPUFrameBuffer *depth_buffer_fb;
|
2023-07-24 10:10:47 +10:00
|
|
|
};
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2023-07-24 10:10:47 +10:00
|
|
|
struct EXTERNAL_TextureList {
|
2017-05-01 14:55:59 +02:00
|
|
|
/* default */
|
2023-06-03 08:36:28 +10:00
|
|
|
GPUTexture *depth_buffer_tx;
|
2023-07-24 10:10:47 +10:00
|
|
|
};
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2023-07-24 10:10:47 +10:00
|
|
|
struct EXTERNAL_PassList {
|
2023-06-03 08:36:28 +10:00
|
|
|
DRWPass *depth_pass;
|
2023-07-24 10:10:47 +10:00
|
|
|
};
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2023-07-24 10:10:47 +10:00
|
|
|
struct EXTERNAL_Data {
|
2017-05-01 14:55:59 +02:00
|
|
|
void *engine_type;
|
|
|
|
|
EXTERNAL_FramebufferList *fbl;
|
|
|
|
|
EXTERNAL_TextureList *txl;
|
|
|
|
|
EXTERNAL_PassList *psl;
|
|
|
|
|
EXTERNAL_StorageList *stl;
|
2021-12-07 11:30:50 +01:00
|
|
|
void *instance_data;
|
|
|
|
|
|
2017-05-04 15:46:09 +02:00
|
|
|
char info[GPU_INFO_SIZE];
|
2023-07-24 10:10:47 +10:00
|
|
|
};
|
2017-05-01 14:55:59 +02:00
|
|
|
|
|
|
|
|
/* *********** STATIC *********** */
|
|
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
|
/* Depth Pre Pass */
|
2023-06-03 08:36:28 +10:00
|
|
|
GPUShader *depth_sh;
|
2023-07-13 14:39:32 +02:00
|
|
|
} e_data = {nullptr}; /* Engine data */
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2023-07-24 10:10:47 +10:00
|
|
|
struct EXTERNAL_PrivateData {
|
2017-05-01 14:55:59 +02:00
|
|
|
DRWShadingGroup *depth_shgrp;
|
2019-05-01 12:31:59 +02:00
|
|
|
|
|
|
|
|
/* Do we need to update the depth or can we reuse the last calculated texture. */
|
2020-01-23 21:38:06 +01:00
|
|
|
bool need_depth;
|
2019-05-01 12:31:59 +02:00
|
|
|
bool update_depth;
|
2023-07-24 10:10:47 +10:00
|
|
|
}; /* Transient data */
|
2017-05-01 14:55:59 +02:00
|
|
|
|
|
|
|
|
/* Functions */
|
|
|
|
|
|
2019-05-01 12:31:59 +02:00
|
|
|
static void external_engine_init(void *vedata)
|
2017-05-01 14:55:59 +02:00
|
|
|
{
|
2019-05-01 12:31:59 +02:00
|
|
|
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = draw_ctx->region;
|
2019-05-01 12:31:59 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Depth pre-pass. */
|
2017-05-01 14:55:59 +02:00
|
|
|
if (!e_data.depth_sh) {
|
2022-05-01 19:35:31 +02:00
|
|
|
/* NOTE: Reuse Basic engine depth only shader. */
|
|
|
|
|
e_data.depth_sh = GPU_shader_create_from_info_name("basic_depth_mesh");
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
2019-05-01 12:31:59 +02:00
|
|
|
|
|
|
|
|
if (!stl->g_data) {
|
|
|
|
|
/* Alloc transient pointers */
|
2023-07-13 14:39:32 +02:00
|
|
|
stl->g_data = MEM_cnew<EXTERNAL_PrivateData>(__func__);
|
2020-01-23 21:38:06 +01:00
|
|
|
stl->g_data->need_depth = true;
|
2019-05-01 12:31:59 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-23 21:38:06 +01:00
|
|
|
stl->g_data->update_depth = true;
|
|
|
|
|
|
2019-06-02 02:14:56 +02:00
|
|
|
/* Progressive render samples are tagged with no rebuild, in that case we
|
|
|
|
|
* can skip updating the depth buffer */
|
2020-03-06 16:56:42 +01:00
|
|
|
if (region && (region->do_draw & RGN_DRAW_NO_REBUILD)) {
|
2020-01-23 21:38:06 +01:00
|
|
|
stl->g_data->update_depth = false;
|
2019-05-01 12:31:59 +02:00
|
|
|
}
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* Add shading group call which will take care of writing to the depth buffer, so that the
|
|
|
|
|
* alpha-under overlay will happen for the render buffer. */
|
|
|
|
|
static void external_cache_image_add(DRWShadingGroup *grp)
|
|
|
|
|
{
|
|
|
|
|
float obmat[4][4];
|
|
|
|
|
unit_m4(obmat);
|
|
|
|
|
scale_m4_fl(obmat, 0.5f);
|
|
|
|
|
|
|
|
|
|
/* NOTE: Use the same Z-depth value as in the regular image drawing engine. */
|
|
|
|
|
translate_m4(obmat, 1.0f, 1.0f, 0.75f);
|
|
|
|
|
|
|
|
|
|
GPUBatch *geom = DRW_cache_quad_get();
|
|
|
|
|
|
|
|
|
|
DRW_shgroup_call_obmat(grp, geom, obmat);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 12:30:55 +01:00
|
|
|
static void external_cache_init(void *vedata)
|
2017-05-01 14:55:59 +02:00
|
|
|
{
|
|
|
|
|
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
|
|
|
|
|
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
|
2019-05-01 12:31:59 +02:00
|
|
|
EXTERNAL_TextureList *txl = ((EXTERNAL_Data *)vedata)->txl;
|
|
|
|
|
EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl;
|
2020-01-23 21:38:06 +01:00
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
const View3D *v3d = draw_ctx->v3d;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-01 12:31:59 +02:00
|
|
|
{
|
2023-07-13 14:39:32 +02:00
|
|
|
DRW_texture_ensure_fullscreen_2d(
|
|
|
|
|
&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, DRWTextureFlag(0));
|
2019-05-01 12:31:59 +02:00
|
|
|
|
|
|
|
|
GPU_framebuffer_ensure_config(&fbl->depth_buffer_fb,
|
|
|
|
|
{
|
|
|
|
|
GPU_ATTACHMENT_TEXTURE(txl->depth_buffer_tx),
|
|
|
|
|
});
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-01 14:55:59 +02:00
|
|
|
/* Depth Pass */
|
|
|
|
|
{
|
2018-05-20 19:05:13 +02:00
|
|
|
psl->depth_pass = DRW_pass_create("Depth Pass",
|
|
|
|
|
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL);
|
2017-05-01 14:55:59 +02:00
|
|
|
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
|
|
|
|
}
|
2019-05-01 12:31:59 +02:00
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
if (v3d != nullptr) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* Do not draw depth pass when overlays are turned off. */
|
|
|
|
|
stl->g_data->need_depth = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
|
|
|
|
|
}
|
2023-07-13 14:39:32 +02:00
|
|
|
else if (draw_ctx->space_data != nullptr) {
|
|
|
|
|
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (space_type == SPACE_IMAGE) {
|
|
|
|
|
external_cache_image_add(stl->g_data->depth_shgrp);
|
|
|
|
|
|
|
|
|
|
stl->g_data->need_depth = true;
|
|
|
|
|
stl->g_data->update_depth = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-29 12:30:55 +01:00
|
|
|
static void external_cache_populate(void *vedata, Object *ob)
|
2017-05-01 14:55:59 +02:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
2017-05-01 14:55:59 +02:00
|
|
|
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
if (draw_ctx->space_data != nullptr) {
|
|
|
|
|
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (space_type == SPACE_IMAGE) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-19 17:31:07 +02:00
|
|
|
if (!(DRW_object_is_renderable(ob) &&
|
|
|
|
|
DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF))
|
|
|
|
|
{
|
2017-05-01 14:55:59 +02:00
|
|
|
return;
|
2019-01-25 07:10:13 +11:00
|
|
|
}
|
2017-05-01 14:55:59 +02:00
|
|
|
|
2023-03-08 12:35:58 +01:00
|
|
|
if (ob->type == OB_GPENCIL_LEGACY) {
|
2020-01-23 21:38:06 +01:00
|
|
|
/* Grease Pencil objects need correct depth to do the blending. */
|
|
|
|
|
stl->g_data->need_depth = true;
|
2019-05-01 12:31:59 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
if (ob->type == OB_MESH && ob->modifiers.first != nullptr) {
|
2020-05-14 12:42:52 +02:00
|
|
|
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
|
|
|
|
|
if (md->type != eModifierType_ParticleSystem) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
|
|
|
|
|
if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ParticleSettings *part = psys->part;
|
|
|
|
|
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
|
|
|
|
|
|
|
|
|
if (draw_as == PART_DRAW_PATH) {
|
2023-07-13 14:39:32 +02:00
|
|
|
GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, nullptr);
|
|
|
|
|
DRW_shgroup_call(stl->g_data->depth_shgrp, hairs, nullptr);
|
2020-05-14 12:42:52 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-03 08:36:28 +10:00
|
|
|
GPUBatch *geom = DRW_cache_object_surface_get(ob);
|
2020-01-23 21:38:06 +01:00
|
|
|
if (geom) {
|
2023-03-17 16:43:56 +11:00
|
|
|
/* Depth Pre-pass. */
|
2020-01-23 21:38:06 +01:00
|
|
|
DRW_shgroup_call(stl->g_data->depth_shgrp, geom, ob);
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
static void external_cache_finish(void * /*vedata*/) {}
|
2017-05-01 14:55:59 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
static void external_draw_scene_do_v3d(void *vedata)
|
2017-05-01 14:55:59 +02:00
|
|
|
{
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
RegionView3D *rv3d = draw_ctx->rv3d;
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = draw_ctx->region;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-09-05 11:48:06 -03:00
|
|
|
DRW_state_reset_ex(DRW_STATE_WRITE_COLOR);
|
|
|
|
|
|
|
|
|
|
/* The external engine can use the OpenGL rendering API directly, so make sure the state is
|
|
|
|
|
* already applied. */
|
|
|
|
|
GPU_apply_state();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-01 14:55:59 +02:00
|
|
|
/* Create render engine. */
|
2023-07-18 17:17:48 +02:00
|
|
|
RenderEngine *render_engine = nullptr;
|
|
|
|
|
if (!rv3d->view_render) {
|
2017-11-28 15:06:32 +01:00
|
|
|
RenderEngineType *engine_type = draw_ctx->engine_type;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-30 14:32:47 +02:00
|
|
|
if (!(engine_type->view_update && engine_type->view_draw)) {
|
2017-05-01 14:55:59 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-18 17:17:48 +02:00
|
|
|
rv3d->view_render = RE_NewViewRender(engine_type);
|
|
|
|
|
render_engine = RE_view_engine_get(rv3d->view_render);
|
|
|
|
|
engine_type->view_update(render_engine, draw_ctx->evil_C, draw_ctx->depsgraph);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
render_engine = RE_view_engine_get(rv3d->view_render);
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-01 14:55:59 +02:00
|
|
|
/* Rendered draw. */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push_projection();
|
2019-05-27 16:33:38 +02:00
|
|
|
GPU_matrix_push();
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_pixelspace(region);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-01 14:55:59 +02:00
|
|
|
/* Render result draw. */
|
2023-07-18 17:17:48 +02:00
|
|
|
const RenderEngineType *type = render_engine->type;
|
|
|
|
|
type->view_draw(render_engine, draw_ctx->evil_C, draw_ctx->depsgraph);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-22 01:19:10 +02:00
|
|
|
GPU_bgl_end();
|
|
|
|
|
|
2019-05-27 16:33:38 +02:00
|
|
|
GPU_matrix_pop();
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop_projection();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-04 15:46:09 +02:00
|
|
|
/* Set render info. */
|
2023-07-13 14:39:32 +02:00
|
|
|
EXTERNAL_Data *data = static_cast<EXTERNAL_Data *>(vedata);
|
2023-07-18 17:17:48 +02:00
|
|
|
if (render_engine->text[0] != '\0') {
|
|
|
|
|
STRNCPY(data->info, render_engine->text);
|
2017-05-04 15:46:09 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
data->info[0] = '\0';
|
|
|
|
|
}
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* Configure current matrix stack so that the external engine can use the same drawing code for
|
|
|
|
|
* both viewport and image editor drawing.
|
|
|
|
|
*
|
|
|
|
|
* The engine draws result in the pixel space, and is applying render offset. For image editor we
|
|
|
|
|
* need to switch from normalized space to pixel space, and "un-apply" offset. */
|
|
|
|
|
static void external_image_space_matrix_set(const RenderEngine *engine)
|
|
|
|
|
{
|
2023-07-13 14:39:32 +02:00
|
|
|
BLI_assert(engine != nullptr);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
const DRWView *view = DRW_view_get_active();
|
2023-06-03 08:36:28 +10:00
|
|
|
SpaceImage *space_image = (SpaceImage *)draw_ctx->space_data;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
/* Apply current view as transformation matrix.
|
|
|
|
|
* This will configure drawing for normalized space with current zoom and pan applied. */
|
|
|
|
|
|
|
|
|
|
float view_matrix[4][4];
|
|
|
|
|
DRW_view_viewmat_get(view, view_matrix, false);
|
|
|
|
|
|
|
|
|
|
float projection_matrix[4][4];
|
|
|
|
|
DRW_view_winmat_get(view, projection_matrix, false);
|
|
|
|
|
|
|
|
|
|
GPU_matrix_projection_set(projection_matrix);
|
|
|
|
|
GPU_matrix_set(view_matrix);
|
|
|
|
|
|
|
|
|
|
/* Switch from normalized space to pixel space. */
|
|
|
|
|
{
|
|
|
|
|
int width, height;
|
|
|
|
|
ED_space_image_get_size(space_image, &width, &height);
|
|
|
|
|
|
|
|
|
|
const float width_inv = width ? 1.0f / width : 0.0f;
|
|
|
|
|
const float height_inv = height ? 1.0f / height : 0.0f;
|
|
|
|
|
GPU_matrix_scale_2f(width_inv, height_inv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Un-apply render offset. */
|
|
|
|
|
{
|
|
|
|
|
Render *render = engine->re;
|
|
|
|
|
rctf view_rect;
|
|
|
|
|
rcti render_rect;
|
|
|
|
|
RE_GetViewPlane(render, &view_rect, &render_rect);
|
|
|
|
|
|
|
|
|
|
GPU_matrix_translate_2f(-render_rect.xmin, -render_rect.ymin);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
static void external_draw_scene_do_image(void * /*vedata*/)
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
Scene *scene = draw_ctx->scene;
|
|
|
|
|
Render *re = RE_GetSceneRender(scene);
|
|
|
|
|
RenderEngine *engine = RE_engine_get(re);
|
|
|
|
|
|
|
|
|
|
/* Is tested before enabling the drawing engine. */
|
2023-07-13 14:39:32 +02:00
|
|
|
BLI_assert(re != nullptr);
|
|
|
|
|
BLI_assert(engine != nullptr);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2022-09-05 11:48:06 -03:00
|
|
|
DRW_state_reset_ex(DRW_STATE_WRITE_COLOR);
|
|
|
|
|
|
|
|
|
|
/* The external engine can use the OpenGL rendering API directly, so make sure the state is
|
|
|
|
|
* already applied. */
|
|
|
|
|
GPU_apply_state();
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
|
|
|
|
|
|
|
|
|
/* Clear the depth buffer to the value used by the background overlay so that the overlay is not
|
|
|
|
|
* happening outside of the drawn image.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: The external engine only draws color. The depth is taken care of using the depth pass
|
|
|
|
|
* which initialized the depth to the values expected by the background overlay. */
|
|
|
|
|
GPU_framebuffer_clear_depth(dfbl->default_fb, 1.0f);
|
|
|
|
|
|
|
|
|
|
GPU_matrix_push_projection();
|
|
|
|
|
GPU_matrix_push();
|
|
|
|
|
|
|
|
|
|
external_image_space_matrix_set(engine);
|
|
|
|
|
|
|
|
|
|
GPU_debug_group_begin("External Engine");
|
|
|
|
|
|
|
|
|
|
const RenderEngineType *engine_type = engine->type;
|
2023-07-13 14:39:32 +02:00
|
|
|
BLI_assert(engine_type != nullptr);
|
|
|
|
|
BLI_assert(engine_type->draw != nullptr);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
engine_type->draw(engine, draw_ctx->evil_C, draw_ctx->depsgraph);
|
|
|
|
|
|
|
|
|
|
GPU_debug_group_end();
|
|
|
|
|
|
|
|
|
|
GPU_matrix_pop();
|
|
|
|
|
GPU_matrix_pop_projection();
|
|
|
|
|
|
|
|
|
|
DRW_state_reset();
|
|
|
|
|
GPU_bgl_end();
|
|
|
|
|
|
|
|
|
|
RE_engine_draw_release(re);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void external_draw_scene_do(void *vedata)
|
|
|
|
|
{
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
if (draw_ctx->v3d != nullptr) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
external_draw_scene_do_v3d(vedata);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
if (draw_ctx->space_data == nullptr) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (space_type == SPACE_IMAGE) {
|
|
|
|
|
external_draw_scene_do_image(vedata);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-29 12:30:55 +01:00
|
|
|
static void external_draw_scene(void *vedata)
|
2017-05-01 14:55:59 +02:00
|
|
|
{
|
2017-05-03 04:59:15 +10:00
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
2019-05-01 12:31:59 +02:00
|
|
|
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
|
2017-05-01 14:55:59 +02:00
|
|
|
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
|
2019-05-01 12:31:59 +02:00
|
|
|
EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl;
|
|
|
|
|
const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
/* Will be nullptr during OpenGL render.
|
2017-05-03 04:59:15 +10:00
|
|
|
* OpenGL render is used for quick preview (thumbnails or sequencer preview)
|
|
|
|
|
* where using the rendering engine to preview doesn't make so much sense. */
|
|
|
|
|
if (draw_ctx->evil_C) {
|
2020-08-07 22:36:11 +10:00
|
|
|
const float clear_col[4] = {0, 0, 0, 0};
|
2020-02-11 15:18:55 +01:00
|
|
|
/* This is to keep compatibility with external engine. */
|
2020-09-19 14:32:41 +10:00
|
|
|
/* TODO(fclem): remove it eventually. */
|
2020-02-11 15:18:55 +01:00
|
|
|
GPU_framebuffer_bind(dfbl->default_fb);
|
|
|
|
|
GPU_framebuffer_clear_color(dfbl->default_fb, clear_col);
|
|
|
|
|
|
2017-11-29 12:30:55 +01:00
|
|
|
external_draw_scene_do(vedata);
|
2017-05-03 04:59:15 +10:00
|
|
|
}
|
2019-05-01 12:31:59 +02:00
|
|
|
|
2020-01-23 21:38:06 +01:00
|
|
|
if (stl->g_data->update_depth && stl->g_data->need_depth) {
|
2019-05-01 12:31:59 +02:00
|
|
|
DRW_draw_pass(psl->depth_pass);
|
2020-01-23 21:38:06 +01:00
|
|
|
/* Copy main depth buffer to cached framebuffer. */
|
2019-05-01 12:31:59 +02:00
|
|
|
GPU_framebuffer_blit(dfbl->depth_only_fb, 0, fbl->depth_buffer_fb, 0, GPU_DEPTH_BIT);
|
|
|
|
|
}
|
2020-01-23 21:38:06 +01:00
|
|
|
|
|
|
|
|
/* Copy cached depth buffer to main framebuffer. */
|
|
|
|
|
GPU_framebuffer_blit(fbl->depth_buffer_fb, 0, dfbl->depth_only_fb, 0, GPU_DEPTH_BIT);
|
2019-05-01 12:31:59 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
static void external_engine_free()
|
2017-05-01 14:55:59 +02:00
|
|
|
{
|
2020-06-03 10:29:32 +02:00
|
|
|
DRW_SHADER_FREE_SAFE(e_data.depth_sh);
|
2017-05-01 14:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-29 12:30:55 +01:00
|
|
|
static const DrawEngineDataSize external_data_size = DRW_VIEWPORT_DATA_SIZE(EXTERNAL_Data);
|
2017-05-01 14:55:59 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
DrawEngineType draw_engine_external_type = {
|
2023-07-18 14:18:10 +10:00
|
|
|
/*next*/ nullptr,
|
|
|
|
|
/*prev*/ nullptr,
|
|
|
|
|
/*idname*/ N_("External"),
|
|
|
|
|
/*vedata_size*/ &external_data_size,
|
|
|
|
|
/*engine_init*/ &external_engine_init,
|
|
|
|
|
/*engine_free*/ &external_engine_free,
|
2023-07-13 14:39:32 +02:00
|
|
|
/*instance_free*/ nullptr,
|
2023-07-18 14:18:10 +10:00
|
|
|
/*cache_init*/ &external_cache_init,
|
|
|
|
|
/*cache_populate*/ &external_cache_populate,
|
|
|
|
|
/*cache_finish*/ &external_cache_finish,
|
|
|
|
|
/*draw_scene*/ &external_draw_scene,
|
|
|
|
|
/*view_update*/ nullptr,
|
|
|
|
|
/*id_update*/ nullptr,
|
|
|
|
|
/*render_to_image*/ nullptr,
|
|
|
|
|
/*store_metadata*/ nullptr,
|
2017-05-01 14:55:59 +02:00
|
|
|
};
|
|
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* NOTE: currently unused,
|
2019-05-01 10:35:46 +10:00
|
|
|
* we should not register unless we want to see this when debugging the view. */
|
2017-05-01 14:55:59 +02:00
|
|
|
|
|
|
|
|
RenderEngineType DRW_engine_viewport_external_type = {
|
2023-07-18 14:18:10 +10:00
|
|
|
/*next*/ nullptr,
|
|
|
|
|
/*prev*/ nullptr,
|
|
|
|
|
/*idname*/ EXTERNAL_ENGINE,
|
|
|
|
|
/*name*/ N_("External"),
|
|
|
|
|
/*flag*/ RE_INTERNAL | RE_USE_STEREO_VIEWPORT,
|
|
|
|
|
/*update*/ nullptr,
|
|
|
|
|
/*render*/ nullptr,
|
|
|
|
|
/*render_frame_finish*/ nullptr,
|
|
|
|
|
/*draw*/ nullptr,
|
|
|
|
|
/*bake*/ nullptr,
|
|
|
|
|
/*view_update*/ nullptr,
|
|
|
|
|
/*view_draw*/ nullptr,
|
|
|
|
|
/*update_script_node*/ nullptr,
|
|
|
|
|
/*update_render_passes*/ nullptr,
|
|
|
|
|
/*draw_engine*/ &draw_engine_external_type,
|
|
|
|
|
/*rna_ext*/
|
|
|
|
|
{
|
|
|
|
|
/*data*/ nullptr,
|
|
|
|
|
/*srna*/ nullptr,
|
|
|
|
|
/*call*/ nullptr,
|
|
|
|
|
},
|
2017-05-01 14:55:59 +02:00
|
|
|
};
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
bool DRW_engine_external_acquire_for_image_editor()
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{
|
|
|
|
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
|
|
|
|
const SpaceLink *space_data = draw_ctx->space_data;
|
|
|
|
|
Scene *scene = draw_ctx->scene;
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
if (space_data == nullptr) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (space_type != SPACE_IMAGE) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-03 08:36:28 +10:00
|
|
|
SpaceImage *space_image = (SpaceImage *)space_data;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
const Image *image = ED_space_image(space_image);
|
2023-07-13 14:39:32 +02:00
|
|
|
if (image == nullptr || image->type != IMA_TYPE_R_RESULT) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (image->render_slot != image->last_render_slot) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Render is allocated on main thread, so it is safe to access it from here. */
|
|
|
|
|
Render *re = RE_GetSceneRender(scene);
|
|
|
|
|
|
2023-07-13 14:39:32 +02:00
|
|
|
if (re == nullptr) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return RE_engine_draw_acquire(re);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-03 16:01:33 +02:00
|
|
|
void DRW_engine_external_free(RegionView3D *rv3d)
|
|
|
|
|
{
|
|
|
|
|
if (rv3d->view_render) {
|
|
|
|
|
/* Free engine with DRW context enabled, as this may clean up per-context
|
|
|
|
|
* resources like VAOs. */
|
|
|
|
|
DRW_gpu_context_enable_ex(true);
|
|
|
|
|
RE_FreeViewRender(rv3d->view_render);
|
|
|
|
|
rv3d->view_render = nullptr;
|
|
|
|
|
DRW_gpu_context_disable_ex(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 14:55:59 +02:00
|
|
|
#undef EXTERNAL_ENGINE
|