Cycles integration with Draw Manager
We can now use object and other modes on top of Cycles. Since we are now always on "render_to_view" (old Rendered mode), the pause button is always visible.
This commit is contained in:
@@ -1651,10 +1651,11 @@ def draw_pause(self, context):
|
||||
if scene.render.engine == "CYCLES":
|
||||
view = context.space_data
|
||||
|
||||
cscene = scene.cycles
|
||||
layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
|
||||
|
||||
if view.viewport_shade == 'RENDERED':
|
||||
cscene = scene.cycles
|
||||
layername = scene.render.layers.active.name
|
||||
layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
|
||||
layout.prop(cscene, "preview_active_layer", icon="RENDERLAYERS", text=layername)
|
||||
|
||||
|
||||
|
||||
@@ -1418,13 +1418,19 @@ static bool check_rendered_viewport_visible(Main *bmain)
|
||||
wmWindow *window;
|
||||
for (window = wm->windows.first; window != NULL; window = window->next) {
|
||||
bScreen *screen = window->screen;
|
||||
Scene *scene = screen->scene;
|
||||
ScrArea *area;
|
||||
RenderEngineType *type = RE_engines_find(scene->r.engine);
|
||||
if ((type->draw_engine != NULL) || (type->render_to_view == NULL)) {
|
||||
continue;
|
||||
}
|
||||
const bool use_legacy = (type->flag & RE_USE_LEGACY_PIPELINE) != 0;
|
||||
for (area = screen->areabase.first; area != NULL; area = area->next) {
|
||||
View3D *v3d = area->spacedata.first;
|
||||
if (area->spacetype != SPACE_VIEW3D) {
|
||||
continue;
|
||||
}
|
||||
if (v3d->drawtype == OB_RENDER) {
|
||||
if (v3d->drawtype == OB_RENDER || !use_legacy) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ set(SRC
|
||||
engines/eevee/eevee_engine.c
|
||||
engines/eevee/eevee_lights.c
|
||||
engines/eevee/eevee_probes.c
|
||||
engines/external/external_engine.c
|
||||
|
||||
DRW_engine.h
|
||||
intern/DRW_render.h
|
||||
@@ -95,6 +96,7 @@ set(SRC
|
||||
engines/clay/clay_engine.h
|
||||
engines/eevee/eevee_engine.h
|
||||
engines/eevee/eevee_private.h
|
||||
engines/external/external_engine.h
|
||||
)
|
||||
|
||||
if(WITH_CLAY_ENGINE)
|
||||
|
||||
@@ -247,7 +247,7 @@ DrawEngineType draw_engine_basic_type = {
|
||||
|
||||
RenderEngineType DRW_engine_viewport_basic_type = {
|
||||
NULL, NULL,
|
||||
BASIC_ENGINE, N_("Basic"), RE_INTERNAL | RE_USE_OGL_PIPELINE,
|
||||
BASIC_ENGINE, N_("Basic"), RE_INTERNAL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
&draw_engine_basic_type,
|
||||
{NULL, NULL, NULL}
|
||||
|
||||
@@ -657,7 +657,7 @@ DrawEngineType draw_engine_clay_type = {
|
||||
|
||||
RenderEngineType DRW_engine_viewport_clay_type = {
|
||||
NULL, NULL,
|
||||
CLAY_ENGINE, N_("Clay"), RE_INTERNAL | RE_USE_OGL_PIPELINE,
|
||||
CLAY_ENGINE, N_("Clay"), RE_INTERNAL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, &CLAY_collection_settings_create,
|
||||
&draw_engine_clay_type,
|
||||
{NULL, NULL, NULL}
|
||||
|
||||
@@ -696,7 +696,7 @@ DrawEngineType draw_engine_eevee_type = {
|
||||
|
||||
RenderEngineType DRW_engine_viewport_eevee_type = {
|
||||
NULL, NULL,
|
||||
EEVEE_ENGINE, N_("Eevee"), RE_INTERNAL | RE_USE_OGL_PIPELINE | RE_USE_SHADING_NODES,
|
||||
EEVEE_ENGINE, N_("Eevee"), RE_INTERNAL | RE_USE_SHADING_NODES,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, &EEVEE_collection_settings_create,
|
||||
&draw_engine_eevee_type,
|
||||
{NULL, NULL, NULL}
|
||||
|
||||
240
source/blender/draw/engines/external/external_engine.c
vendored
Normal file
240
source/blender/draw/engines/external/external_engine.c
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright 2017, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributor(s): Blender Institute
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file external_engine.h
|
||||
* \ingroup draw_engine
|
||||
*
|
||||
* Base engine for external render engines.
|
||||
* We use it for depth and non-mesh objects.
|
||||
*/
|
||||
|
||||
#include "DRW_render.h"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_view3d_types.h"
|
||||
|
||||
#include "BKE_icons.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "ED_view3d.h"
|
||||
#include "ED_screen.h"
|
||||
|
||||
#include "GPU_glew.h"
|
||||
#include "GPU_matrix.h"
|
||||
#include "GPU_shader.h"
|
||||
#include "GPU_viewport.h"
|
||||
|
||||
#include "external_engine.h"
|
||||
/* Shaders */
|
||||
|
||||
#define EXTERNAL_ENGINE "BLENDER_EXTERNAL"
|
||||
|
||||
/* *********** LISTS *********** */
|
||||
|
||||
/* GPUViewport.storage
|
||||
* Is freed everytime the viewport engine changes */
|
||||
typedef struct EXTERNAL_Storage {
|
||||
int dummy;
|
||||
} EXTERNAL_Storage;
|
||||
|
||||
typedef struct EXTERNAL_StorageList {
|
||||
struct EXTERNAL_Storage *storage;
|
||||
struct EXTERNAL_PrivateData *g_data;
|
||||
} EXTERNAL_StorageList;
|
||||
|
||||
typedef struct EXTERNAL_FramebufferList {
|
||||
struct GPUFrameBuffer *default_fb;
|
||||
} EXTERNAL_FramebufferList;
|
||||
|
||||
typedef struct EXTERNAL_TextureList {
|
||||
/* default */
|
||||
struct GPUTexture *depth;
|
||||
} EXTERNAL_TextureList;
|
||||
|
||||
typedef struct EXTERNAL_PassList {
|
||||
struct DRWPass *depth_pass;
|
||||
} EXTERNAL_PassList;
|
||||
|
||||
typedef struct EXTERNAL_Data {
|
||||
void *engine_type;
|
||||
EXTERNAL_FramebufferList *fbl;
|
||||
EXTERNAL_TextureList *txl;
|
||||
EXTERNAL_PassList *psl;
|
||||
EXTERNAL_StorageList *stl;
|
||||
} EXTERNAL_Data;
|
||||
|
||||
/* *********** STATIC *********** */
|
||||
|
||||
static struct {
|
||||
/* Depth Pre Pass */
|
||||
struct GPUShader *depth_sh;
|
||||
} e_data = {NULL}; /* Engine data */
|
||||
|
||||
typedef struct EXTERNAL_PrivateData {
|
||||
DRWShadingGroup *depth_shgrp;
|
||||
} EXTERNAL_PrivateData; /* Transient data */
|
||||
|
||||
/* Functions */
|
||||
|
||||
static void EXTERNAL_engine_init(void *UNUSED(vedata))
|
||||
{
|
||||
/* Depth prepass */
|
||||
if (!e_data.depth_sh) {
|
||||
e_data.depth_sh = DRW_shader_create_3D_depth_only();
|
||||
}
|
||||
}
|
||||
|
||||
static void EXTERNAL_cache_init(void *vedata)
|
||||
{
|
||||
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
|
||||
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
|
||||
|
||||
if (!stl->g_data) {
|
||||
/* Alloc transient pointers */
|
||||
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
|
||||
}
|
||||
|
||||
/* Depth Pass */
|
||||
{
|
||||
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
}
|
||||
}
|
||||
|
||||
static void EXTERNAL_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
|
||||
|
||||
if (!DRW_is_object_renderable(ob))
|
||||
return;
|
||||
|
||||
struct Batch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
/* Depth Prepass */
|
||||
DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
|
||||
}
|
||||
}
|
||||
|
||||
static void EXTERNAL_cache_finish(void *UNUSED(vedata))
|
||||
{
|
||||
}
|
||||
|
||||
static void external_draw_scene(void *UNUSED(vedata))
|
||||
{
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
Scene *scene = draw_ctx->scene;
|
||||
View3D *v3d = draw_ctx->v3d;
|
||||
RegionView3D *rv3d = draw_ctx->rv3d;
|
||||
ARegion *ar = draw_ctx->ar;
|
||||
|
||||
RenderEngineType *type;
|
||||
GLint scissor[4];
|
||||
|
||||
rcti border_rect;
|
||||
bool render_border;
|
||||
bool clip_border;
|
||||
|
||||
render_border = ED_view3d_calc_render_border(scene, v3d, ar, &border_rect);
|
||||
clip_border = render_border && !BLI_rcti_compare(&ar->drawrct, &border_rect);
|
||||
|
||||
/* Create render engine. */
|
||||
if (!rv3d->render_engine) {
|
||||
RenderEngine *engine;
|
||||
type = RE_engines_find(scene->r.engine);
|
||||
|
||||
if (!(type->view_update && type->render_to_view)) {
|
||||
return;
|
||||
}
|
||||
|
||||
engine = RE_engine_create_ex(type, true);
|
||||
engine->tile_x = scene->r.tilex;
|
||||
engine->tile_y = scene->r.tiley;
|
||||
type->view_update(engine, draw_ctx->evil_C);
|
||||
rv3d->render_engine = engine;
|
||||
}
|
||||
|
||||
/* Rendered draw. */
|
||||
gpuPushProjectionMatrix();
|
||||
ED_region_pixelspace(ar);
|
||||
|
||||
if (clip_border) {
|
||||
/* For border draw, we only need to clear a subset of the 3d view. */
|
||||
if (border_rect.xmax > border_rect.xmin && border_rect.ymax > border_rect.ymin) {
|
||||
glGetIntegerv(GL_SCISSOR_BOX, scissor);
|
||||
glScissor(border_rect.xmin, border_rect.ymin,
|
||||
BLI_rcti_size_x(&border_rect), BLI_rcti_size_y(&border_rect));
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Render result draw. */
|
||||
type = rv3d->render_engine->type;
|
||||
type->render_to_view(rv3d->render_engine, draw_ctx->evil_C);
|
||||
|
||||
if (clip_border) {
|
||||
/* Restore scissor as it was before. */
|
||||
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
||||
}
|
||||
|
||||
gpuPopProjectionMatrix();
|
||||
}
|
||||
|
||||
static void EXTERNAL_draw_scene(void *vedata)
|
||||
{
|
||||
EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl;
|
||||
external_draw_scene(vedata);
|
||||
DRW_draw_pass(psl->depth_pass);
|
||||
}
|
||||
|
||||
static void EXTERNAL_engine_free(void)
|
||||
{
|
||||
/* All shaders are builtin. */
|
||||
}
|
||||
|
||||
static const DrawEngineDataSize EXTERNAL_data_size = DRW_VIEWPORT_DATA_SIZE(EXTERNAL_Data);
|
||||
|
||||
DrawEngineType draw_engine_external_type = {
|
||||
NULL, NULL,
|
||||
N_("External"),
|
||||
&EXTERNAL_data_size,
|
||||
&EXTERNAL_engine_init,
|
||||
&EXTERNAL_engine_free,
|
||||
&EXTERNAL_cache_init,
|
||||
&EXTERNAL_cache_populate,
|
||||
&EXTERNAL_cache_finish,
|
||||
NULL,
|
||||
&EXTERNAL_draw_scene
|
||||
};
|
||||
|
||||
/* Note: currently unused, we should not register unless we want to see this when debugging the view. */
|
||||
|
||||
RenderEngineType DRW_engine_viewport_external_type = {
|
||||
NULL, NULL,
|
||||
EXTERNAL_ENGINE, N_("External"), RE_INTERNAL,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
&draw_engine_external_type,
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
#undef EXTERNAL_ENGINE
|
||||
31
source/blender/draw/engines/external/external_engine.h
vendored
Normal file
31
source/blender/draw/engines/external/external_engine.h
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2017, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Contributor(s): Blender Institute
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file external_engine.h
|
||||
* \ingroup draw_engine
|
||||
*/
|
||||
|
||||
#ifndef __EXTERNAL_ENGINE_H__
|
||||
#define __EXTERNAL_ENGINE_H__
|
||||
|
||||
extern RenderEngineType DRW_engine_viewport_external_type;
|
||||
|
||||
#endif /* __EXTERNAL_ENGINE_H__ */
|
||||
@@ -76,6 +76,7 @@
|
||||
#include "engines/clay/clay_engine.h"
|
||||
#include "engines/eevee/eevee_engine.h"
|
||||
#include "engines/basic/basic_engine.h"
|
||||
#include "engines/external/external_engine.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
@@ -96,6 +97,9 @@ extern char datatoc_gpu_shader_2D_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_3D_vert_glsl[];
|
||||
extern char datatoc_gpu_shader_fullscreen_vert_glsl[];
|
||||
|
||||
/* Prototypes. */
|
||||
static void DRW_engines_enable_external(void);
|
||||
|
||||
/* Structures */
|
||||
typedef enum {
|
||||
DRW_UNIFORM_BOOL,
|
||||
@@ -1919,7 +1923,13 @@ static void DRW_engines_enable_from_engine(const Scene *scene)
|
||||
{
|
||||
/* TODO layers */
|
||||
RenderEngineType *type = RE_engines_find(scene->r.engine);
|
||||
use_drw_engine(type->draw_engine);
|
||||
if (type->draw_engine != NULL) {
|
||||
use_drw_engine(type->draw_engine);
|
||||
}
|
||||
|
||||
if ((type->flag & RE_INTERNAL) == 0) {
|
||||
DRW_engines_enable_external();
|
||||
}
|
||||
}
|
||||
|
||||
static void DRW_engines_enable_from_object_mode(void)
|
||||
@@ -1985,6 +1995,14 @@ static void DRW_engines_enable_basic(void)
|
||||
use_drw_engine(DRW_engine_viewport_basic_type.draw_engine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use for external render engines.
|
||||
*/
|
||||
static void DRW_engines_enable_external(void)
|
||||
{
|
||||
use_drw_engine(DRW_engine_viewport_external_type.draw_engine);
|
||||
}
|
||||
|
||||
static void DRW_engines_enable(const bContext *C)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
@@ -2413,7 +2413,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
|
||||
/* TODO layers - In the future we should get RE from Layers */
|
||||
RenderEngineType *type = RE_engines_find(scene->r.engine);
|
||||
|
||||
if (IS_VIEWPORT_LEGACY(v3d) && ((type->flag & RE_USE_OGL_PIPELINE) == 0)) {
|
||||
if (IS_VIEWPORT_LEGACY(v3d) && ((type->flag & RE_USE_LEGACY_PIPELINE) != 0)) {
|
||||
view3d_main_region_draw_legacy(C, ar);
|
||||
return;
|
||||
}
|
||||
@@ -2429,10 +2429,12 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
GPU_viewport_bind(rv3d->viewport, &ar->winrct);
|
||||
|
||||
if (type->flag & RE_USE_OGL_PIPELINE)
|
||||
if ((type->flag & RE_USE_LEGACY_PIPELINE) == 0) {
|
||||
view3d_draw_view_new(C, ar, &draw_data);
|
||||
else
|
||||
}
|
||||
else {
|
||||
view3d_draw_view(C, ar, &draw_data);
|
||||
}
|
||||
|
||||
GPU_viewport_unbind(rv3d->viewport);
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ struct BakePixel;
|
||||
#define RE_USE_TEXTURE_PREVIEW 128
|
||||
#define RE_USE_SHADING_NODES_CUSTOM 256
|
||||
#define RE_USE_SPHERICAL_STEREO 512
|
||||
#define RE_USE_OGL_PIPELINE 1024
|
||||
#define RE_USE_LEGACY_PIPELINE 1024 /* XXX Temporary flag, to be removed once draw manager is finished. */
|
||||
|
||||
/* RenderEngine.flag */
|
||||
#define RE_ENGINE_ANIMATION 1
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
static RenderEngineType internal_render_type = {
|
||||
NULL, NULL,
|
||||
"BLENDER_RENDER", N_("Blender Render"), RE_INTERNAL,
|
||||
"BLENDER_RENDER", N_("Blender Render"), RE_INTERNAL | RE_USE_LEGACY_PIPELINE,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
@@ -81,7 +81,7 @@ static RenderEngineType internal_render_type = {
|
||||
|
||||
static RenderEngineType internal_game_type = {
|
||||
NULL, NULL,
|
||||
"BLENDER_GAME", N_("Blender Game"), RE_INTERNAL | RE_GAME,
|
||||
"BLENDER_GAME", N_("Blender Game"), RE_INTERNAL | RE_GAME | RE_USE_LEGACY_PIPELINE,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user