Sequencer: Scene Strip Performance

- Merged SEQ_OFSDRAW with V3D_OFSDRAW and define in the
       DNA_view3d_types: Due to this FSAA always kicked in making the
       rendering slow.
     - Removed `Texture Solid` and `DOF`.
     - Now when chosing Solid rendering the settings
       of the original scene is used.
     - Added a global override to use scene specific shading. In the
       Future we will need to enhanced this so user can change the
       settings.
     - Added support for LookDev. LookDev crashed as it needed the
       `evil_C` what was not set
     - LookDev mode will always show the scene + world lights.

Reviewed By: brecht, fclem

Maniphest Tasks: T62517

Differential Revision: https://developer.blender.org/D4738
This commit is contained in:
Jeroen Bakker 2019-04-25 16:24:06 +02:00
parent 3e780507bd
commit d1f6ea2793
11 changed files with 49 additions and 61 deletions

View File

@ -1291,7 +1291,7 @@ class SEQUENCER_PT_strip_cache(SequencerButtonsPanel, Panel):
class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
bl_label = "Scene Preview & Render"
bl_label = "Scene Shading"
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
bl_category = "Strip"
@ -1304,11 +1304,8 @@ class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel):
col = layout.column()
col.prop(render, "sequencer_gl_preview", text="")
row = col.row()
row.active = render.sequencer_gl_preview == 'SOLID'
row.prop(render, "use_sequencer_gl_textured_solid")
col.prop(render, "use_sequencer_gl_dof")
if render.sequencer_gl_preview in ['SOLID', 'WIREFRAME']:
col.prop(render, "use_sequencer_override_scene_strip")
class SEQUENCER_PT_view(SequencerButtonsPanel_Output, Panel):

View File

@ -100,7 +100,6 @@ typedef struct SeqRenderData {
/* special case for OpenGL render */
struct GPUOffScreen *gpu_offscreen;
struct GPUFX *gpu_fx;
int gpu_samples;
bool gpu_full_samples;
} SeqRenderData;
@ -487,19 +486,9 @@ struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C,
ListBase *seqbasep,
struct SeqLoadInfo *seq_load);
/* view3d draw callback, run when not in background view */
/* NOTE: Keep in sync with V3D_OFSDRAW_* flags. */
enum {
SEQ_OFSDRAW_NONE = (0),
SEQ_OFSDRAW_USE_BACKGROUND = (1 << 0),
SEQ_OFSDRAW_USE_FULL_SAMPLE = (1 << 1),
SEQ_OFSDRAW_USE_GPENCIL = (1 << 2),
SEQ_OFSDRAW_USE_SOLID_TEX = (1 << 2),
SEQ_OFSDRAW_USE_CAMERA_DOF = (1 << 3),
};
typedef struct ImBuf *(*SequencerDrawView)(struct Depsgraph *depsgraph,
struct Scene *scene,
struct View3DShading *shading_override,
int drawtype,
struct Object *camera,
int width,

View File

@ -3454,9 +3454,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
const bool is_rendering = G.is_rendering;
const bool is_background = G.background;
const bool do_seq_gl = is_rendering ? 0 /* (context->scene->r.seq_flag & R_SEQ_GL_REND) */ :
(context->scene->r.seq_prev_type) != OB_RENDER;
// bool have_seq = false; /* UNUSED */
const bool do_seq_gl = is_rendering ? 0 : (context->scene->r.seq_prev_type) != OB_RENDER;
bool have_comp = false;
bool use_gpencil = true;
/* do we need to re-evaluate the frame after rendering? */
@ -3521,15 +3519,14 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
char err_out[256] = "unknown";
const int width = (scene->r.xsch * scene->r.size) / 100;
const int height = (scene->r.ysch * scene->r.size) / 100;
const bool use_background = (scene->r.alphamode == R_ADDSKY);
const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id);
unsigned int draw_flags = SEQ_OFSDRAW_NONE;
draw_flags |= (use_gpencil) ? SEQ_OFSDRAW_USE_GPENCIL : 0;
draw_flags |= (use_background) ? SEQ_OFSDRAW_USE_BACKGROUND : 0;
draw_flags |= (context->gpu_full_samples) ? SEQ_OFSDRAW_USE_FULL_SAMPLE : 0;
draw_flags |= (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) ? SEQ_OFSDRAW_USE_SOLID_TEX : 0;
draw_flags |= (context->scene->r.seq_flag & R_SEQ_CAMERA_DOF) ? SEQ_OFSDRAW_USE_CAMERA_DOF : 0;
unsigned int draw_flags = V3D_OFSDRAW_NONE;
draw_flags |= (use_gpencil) ? V3D_OFSDRAW_SHOW_ANNOTATION : 0;
draw_flags |= (context->gpu_full_samples) ? V3D_OFSDRAW_USE_FULL_SAMPLE : 0;
draw_flags |= (context->scene->r.seq_flag & R_SEQ_OVERRIDE_SCENE_SETTINGS) ?
V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS :
0;
/* for old scene this can be uninitialized,
* should probably be added to do_versions at some point if the functionality stays */
@ -3544,6 +3541,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
/* set for OpenGL render (NULL when scrubbing) */
depsgraph,
scene,
&context->scene->display.shading,
context->scene->r.seq_prev_type,
camera,
width,

View File

@ -161,8 +161,10 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
static void drw_deferred_shader_add(GPUMaterial *mat, bool deferred)
{
/* Do not deferre the compilation if we are rendering for image. */
if (DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION || !deferred) {
/* Do not deferre the compilation if we are rendering for image.
* deferred rendering is only possible when `evil_C` is available */
if (DST.draw_ctx.evil_C == NULL || DRW_state_is_image_render() || !USE_DEFERRED_COMPILATION ||
!deferred) {
/* Double checking that this GPUMaterial is not going to be
* compiled by another thread. */
DRW_deferred_shader_remove(mat);

View File

@ -54,6 +54,7 @@ struct RenderEngineType;
struct Scene;
struct ScrArea;
struct View3D;
struct View3DShading;
struct ViewContext;
struct ViewLayer;
struct WorkSpace;
@ -584,16 +585,6 @@ void ED_view3d_draw_setup_view(struct wmWindow *win,
float winmat[4][4],
const struct rcti *rect);
enum {
V3D_OFSDRAW_NONE = (0),
V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0),
/* Only works with ED_view3d_draw_offscreen_imbuf_simple(). */
V3D_OFSDRAW_USE_GPENCIL = (1 << 1),
V3D_OFSDRAW_USE_CAMERA_DOF = (1 << 2),
};
struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph,
struct Scene *scene,
int drawtype,
@ -610,6 +601,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph,
char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph,
struct Scene *scene,
struct View3DShading *shading_override,
int drawtype,
struct Object *camera,
int width,

View File

@ -381,9 +381,10 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
}
}
else {
draw_flags |= V3D_OFSDRAW_USE_GPENCIL;
draw_flags |= V3D_OFSDRAW_SHOW_ANNOTATION;
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
NULL,
OB_SOLID,
scene->camera,
oglrender->sizex,

View File

@ -1824,6 +1824,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
*/
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
Scene *scene,
View3DShading *shading_override,
int drawtype,
Object *camera,
int width,
@ -1846,22 +1847,25 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
ar.regiontype = RGN_TYPE_WINDOW;
v3d.camera = camera;
View3DShading *source_shading_settings = &scene->display.shading;
if (draw_flags & V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS && shading_override != NULL) {
source_shading_settings = shading_override;
}
memcpy(&v3d.shading, source_shading_settings, sizeof(View3DShading));
v3d.shading.type = drawtype;
if (drawtype == OB_MATERIAL) {
v3d.shading.flag = V3D_SHADING_SCENE_WORLD | V3D_SHADING_SCENE_LIGHTS;
}
v3d.flag2 = V3D_HIDE_OVERLAYS;
if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) {
if (draw_flags & V3D_OFSDRAW_SHOW_ANNOTATION) {
v3d.flag2 |= V3D_SHOW_ANNOTATION;
}
v3d.shading.background_type = V3D_SHADING_BACKGROUND_WORLD;
if (draw_flags & V3D_OFSDRAW_USE_CAMERA_DOF) {
if (camera->type == OB_CAMERA) {
v3d.fx_settings.dof = &((Camera *)camera->data)->gpu_dof;
v3d.fx_settings.fx_flag |= GPU_FX_FLAG_DOF;
}
}
rv3d.persp = RV3D_CAMOB;
copy_m4_m4(rv3d.viewinv, v3d.camera->obmat);

View File

@ -1816,8 +1816,9 @@ enum {
R_SEQ_UNUSED_0 = (1 << 0), /* cleared */
R_SEQ_UNUSED_1 = (1 << 1), /* cleared */
R_SEQ_UNUSED_2 = (1 << 2), /* cleared */
R_SEQ_SOLID_TEX = (1 << 3),
R_SEQ_CAMERA_DOF = (1 << 4),
R_SEQ_UNUSED_3 = (1 << 3), /* cleared */
R_SEQ_UNUSED_4 = (1 << 4), /* cleared */
R_SEQ_OVERRIDE_SCENE_SETTINGS = (1 << 5),
};
/* RenderData.displaymode */

View File

@ -581,6 +581,14 @@ enum {
V3D_GIZMO_SHOW_CAMERA_DOF_DIST = (1 << 2),
};
/** Settings for offscreen rendering */
enum {
V3D_OFSDRAW_NONE = (0),
V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 0),
V3D_OFSDRAW_SHOW_ANNOTATION = (1 << 1),
V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS = (1 << 2),
};
#define RV3D_CAMZOOM_MIN -30
#define RV3D_CAMZOOM_MAX 600

View File

@ -6154,17 +6154,12 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop, "Sequencer Preview Shading", "Method to draw in the sequencer view");
# endif
prop = RNA_def_property(srna, "use_sequencer_gl_textured_solid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_SOLID_TEX);
RNA_def_property_ui_text(
prop, "Textured Solid", "Display face-assigned textures in solid draw method");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
prop = RNA_def_property(srna, "use_sequencer_gl_dof", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_CAMERA_DOF);
prop = RNA_def_property(srna, "use_sequencer_override_scene_strip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_OVERRIDE_SCENE_SETTINGS);
RNA_def_property_ui_text(prop,
"Depth of Field",
"Use depth of field using the values from scene strip active camera");
"Override Scene Settings",
"Use workbench render settings from the sequencer scene, instead of "
"each individual scene used in the strip");
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update");
prop = RNA_def_property(srna, "use_single_layer", PROP_BOOLEAN, PROP_NONE);

View File

@ -1223,6 +1223,7 @@ static ImBuf *blend_file_thumb(const bContext *C,
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
NULL,
OB_SOLID,
scene->camera,
BLEN_THUMB_SIZE * 2,