diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-11-11 13:56:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-11-11 15:07:07 +0300 |
commit | 145298e2d3b2edfc3ddb6d8ccfb3f393232dafb9 (patch) | |
tree | 5462388dd58af828c135c6056267f59b5812bdbf | |
parent | 497c35aa7804edc8f16eeff9e82bb3985275a5bd (diff) |
Cleanup: GL Render (simplify internal logic)
Reduce code-paths so improvements to 3D view render apply to sequencer too.
-rw-r--r-- | source/blender/blenkernel/BKE_sequencer.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 4 | ||||
-rw-r--r-- | source/blender/editors/render/render_opengl.c | 74 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 44 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 4 |
7 files changed, 59 insertions, 75 deletions
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 418179ceab7..350edde407b 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -36,6 +36,7 @@ struct StripColorBalance; struct Editing; struct GSet; struct GPUOffScreen; +struct GPUFX; struct ImBuf; struct Main; struct Mask; @@ -105,6 +106,7 @@ typedef struct SeqRenderData { /* special case for OpenGL render */ struct GPUOffScreen *gpu_offscreen; + struct GPUFX *gpu_fx; int gpu_samples; } SeqRenderData; @@ -417,7 +419,7 @@ typedef struct ImBuf *(*SequencerDrawView)( struct Scene *, struct Object *, int, int, unsigned int, int, bool, bool, bool, int, int, const char *, - struct GPUOffScreen *, char[256]); + struct GPUFX *, struct GPUOffScreen *, char[256]); extern SequencerDrawView sequencer_view3d_cb; /* copy/paste */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 45d33e51e18..6d583651e0f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3222,7 +3222,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) != 0, use_gpencil, true, scene->r.alphamode, context->gpu_samples, viewname, - context->gpu_offscreen, err_out); + context->gpu_fx, context->gpu_offscreen, err_out); if (ibuf == NULL) { fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out); } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 9da12211daa..e5fe163ce40 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -334,12 +334,12 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf( struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, bool draw_background, int alpha_mode, int samples, const char *viewname, - struct GPUOffScreen *ofs, char err_out[256]); + struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]); struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple( struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, int samples, const char *viewname, - struct GPUOffScreen *ofs, char err_out[256]); + struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]); struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 263abe752c2..2a48d30dfd1 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -253,7 +253,6 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr) RegionView3D *rv3d = oglrender->rv3d; Object *camera = NULL; ImBuf *ibuf; - float winmat[4][4]; float *rectf = RE_RenderViewGetById(rr, oglrender->view_id)->rectf; int sizex = oglrender->sizex; int sizey = oglrender->sizey; @@ -276,6 +275,7 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr) context.view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname); context.gpu_offscreen = oglrender->ofs; + context.gpu_fx = oglrender->fx; context.gpu_samples = oglrender->ofs_samples; ibuf = BKE_sequencer_give_ibuf(&context, CFRA, chanshown); @@ -337,62 +337,32 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr) MEM_freeN(gp_rect); } } - else if (view_context) { - bool is_persp; - /* full copy */ - GPUFXSettings fx_settings = v3d->fx_settings; - - ED_view3d_draw_offscreen_init(scene, v3d); - - GPU_offscreen_bind(oglrender->ofs, true); /* bind */ - - /* render 3d view */ - if (rv3d->persp == RV3D_CAMOB && v3d->camera) { -#if 0 - const bool is_ortho = (scene->r.mode & R_ORTHO) != 0; -#endif - camera = BKE_camera_multiview_render(oglrender->scene, v3d->camera, viewname); - RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat); - if (camera->type == OB_CAMERA) { - Camera *cam = camera->data; - is_persp = cam->type == CAM_PERSP; + else { + /* shouldnt suddenly give errors mid-render but possible */ + char err_out[256] = "unknown"; + ImBuf *ibuf_view; + + if (view_context) { + ibuf_view = ED_view3d_draw_offscreen_imbuf( + scene, v3d, ar, sizex, sizey, + IB_rect, draw_bgpic, + (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL, oglrender->ofs_samples, viewname, + oglrender->fx, oglrender->ofs, err_out); + + /* for stamp only */ + if (rv3d->persp == RV3D_CAMOB && v3d->camera) { + camera = BKE_camera_multiview_render(oglrender->scene, v3d->camera, viewname); } - else - is_persp = true; - BKE_camera_to_gpu_dof(camera, &fx_settings); } else { - rctf viewplane; - float clipsta, clipend; - - bool is_ortho = ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend, NULL); - if (is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend); - else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); - - is_persp = !is_ortho; + ibuf_view = ED_view3d_draw_offscreen_imbuf_simple( + scene, scene->camera, oglrender->sizex, oglrender->sizey, + IB_rect, OB_SOLID, false, true, true, + (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL, oglrender->ofs_samples, viewname, + oglrender->fx, oglrender->ofs, err_out); + camera = scene->camera; } - rect = MEM_mallocN(sizex * sizey * sizeof(unsigned char) * 4, "offscreen rect"); - - ED_view3d_draw_offscreen( - scene, v3d, ar, sizex, sizey, NULL, winmat, - draw_bgpic, draw_sky, is_persp, viewname, - oglrender->fx, &fx_settings, - oglrender->ofs); - GPU_offscreen_read_pixels(oglrender->ofs, GL_UNSIGNED_BYTE, rect); - - GPU_offscreen_unbind(oglrender->ofs, true); /* unbind */ - } - else { - /* shouldnt suddenly give errors mid-render but possible */ - char err_out[256] = "unknown"; - ImBuf *ibuf_view = ED_view3d_draw_offscreen_imbuf_simple( - scene, scene->camera, oglrender->sizex, oglrender->sizey, - IB_rect, OB_SOLID, false, true, true, - (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL, oglrender->ofs_samples, viewname, - oglrender->ofs, err_out); - camera = scene->camera; - if (ibuf_view) { /* steal rect reference from ibuf */ rect = (unsigned char *)ibuf_view->rect; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 565f8a51610..3b6f88f0538 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5402,7 +5402,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) ibuf = ED_view3d_draw_offscreen_imbuf( scene, CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, false, R_ALPHAPREMUL, 0, NULL, - NULL, err_out); + NULL, NULL, err_out); if (!ibuf) { /* Mostly happens when OpenGL offscreen buffer was failed to create, */ /* but could be other reasons. Should be handled in the future. nazgul */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 40cd91a6e2f..14861734bfa 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -3296,13 +3296,18 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( unsigned int flag, bool draw_background, int alpha_mode, int samples, const char *viewname, /* output vars */ - GPUOffScreen *ofs, char err_out[256]) + GPUFX *fx, GPUOffScreen *ofs, char err_out[256]) { RegionView3D *rv3d = ar->regiondata; ImBuf *ibuf; const bool draw_sky = (alpha_mode == R_ADDSKY) && v3d && (v3d->flag3 & V3D_SHOW_WORLD); const bool own_ofs = (ofs == NULL); + /* view state */ + GPUFXSettings fx_settings = {NULL}; + float winmat[4][4]; + bool is_ortho; + if (UNLIKELY(v3d == NULL)) return NULL; @@ -3325,7 +3330,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( /* render 3d view */ if (rv3d->persp == RV3D_CAMOB && v3d->camera) { CameraParams params; - GPUFXSettings fx_settings = {NULL}; Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname); BKE_camera_params_init(¶ms); @@ -3339,19 +3343,29 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( BKE_camera_to_gpu_dof(camera, &fx_settings); - ED_view3d_draw_offscreen( - scene, v3d, ar, sizex, sizey, NULL, params.winmat, - draw_background, draw_sky, !params.is_ortho, viewname, - NULL, &fx_settings, - ofs); + is_ortho = params.is_ortho; + copy_m4_m4(winmat, params.winmat); } else { - ED_view3d_draw_offscreen( - scene, v3d, ar, sizex, sizey, NULL, NULL, - draw_background, draw_sky, true, viewname, - NULL, NULL, ofs); + rctf viewplane; + float clipsta, clipend; + + fx_settings = v3d->fx_settings; + + is_ortho = ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend, NULL); + if (is_ortho) { + orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend); + } + else { + perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); + } } + ED_view3d_draw_offscreen( + scene, v3d, ar, sizex, sizey, NULL, winmat, + draw_background, draw_sky, !is_ortho, viewname, + fx, &fx_settings, ofs); + /* read in pixels & stamp */ ibuf = IMB_allocImBuf(sizex, sizey, 32, flag); @@ -3368,7 +3382,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( glPopAttrib(); } - + if (ibuf->rect_float && ibuf->rect) IMB_rect_from_float(ibuf); @@ -3387,7 +3401,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( Scene *scene, Object *camera, int width, int height, unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background, int alpha_mode, int samples, const char *viewname, - GPUOffScreen *ofs, char err_out[256]) + GPUFX *fx, GPUOffScreen *ofs, char err_out[256]) { View3D v3d = {NULL}; ARegion ar = {NULL}; @@ -3437,9 +3451,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( return ED_view3d_draw_offscreen_imbuf( scene, &v3d, &ar, width, height, flag, draw_background, alpha_mode, samples, viewname, - ofs, err_out); - - // seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty); + fx, ofs, err_out); } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 37fb4e5d89e..87f8c17ca1f 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -936,14 +936,14 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, BlendThumbnail **t scene, scene->camera, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, IB_rect, OB_SOLID, false, false, false, R_ALPHAPREMUL, 0, NULL, - NULL, err_out); + NULL, NULL, err_out); } else { ibuf = ED_view3d_draw_offscreen_imbuf( scene, v3d, ar, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, IB_rect, false, R_ALPHAPREMUL, 0, NULL, - NULL, err_out); + NULL, NULL, err_out); } if (ibuf) { |