Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/render/render_opengl.c
| Show All 12 Lines | |||||
| * along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| * | * | ||||
| * The Original Code is Copyright (C) 2008 Blender Foundation. | * The Original Code is Copyright (C) 2008 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup edrend | * \ingroup render | ||||
| */ | */ | ||||
| #include <math.h> | #include <math.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <stddef.h> | #include <stddef.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
| #include "GPU_framebuffer.h" | #include "GPU_framebuffer.h" | ||||
| #include "GPU_glew.h" | #include "GPU_glew.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "render_intern.h" | #include "render_intern.h" | ||||
| /* Define this to get timing information. */ | /* Define this to get timing information. */ | ||||
| // #undef DEBUG_TIME | // #define DEBUG_TIME | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| # include "PIL_time.h" | # include "PIL_time.h" | ||||
| #endif | #endif | ||||
| // TODO(sergey): Find better approximation of the scheduled frames. | // TODO(sergey): Find better approximation of the scheduled frames. | ||||
| // For really highres renders it might fail still. | // For really highres renders it might fail still. | ||||
| #define MAX_SCHEDULED_FRAMES 8 | #define MAX_SCHEDULED_FRAMES 8 | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | typedef struct OGLRender { | ||||
| wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/ | wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/ | ||||
| void **movie_ctx_arr; | void **movie_ctx_arr; | ||||
| TaskScheduler *task_scheduler; | TaskScheduler *task_scheduler; | ||||
| TaskPool *task_pool; | TaskPool *task_pool; | ||||
| bool pool_ok; | bool pool_ok; | ||||
| bool is_animation; | bool is_animation; | ||||
| eImageFormatDepth color_depth; | |||||
| SpinLock reports_lock; | SpinLock reports_lock; | ||||
| unsigned int num_scheduled_frames; | unsigned int num_scheduled_frames; | ||||
| ThreadMutex task_mutex; | ThreadMutex task_mutex; | ||||
| ThreadCondition task_condition; | ThreadCondition task_condition; | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| double time_start; | double time_start; | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | if (gpd) { | ||||
| MEM_freeN(gp_rect); | MEM_freeN(gp_rect); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* shouldnt suddenly give errors mid-render but possible */ | /* shouldnt suddenly give errors mid-render but possible */ | ||||
| char err_out[256] = "unknown"; | char err_out[256] = "unknown"; | ||||
| ImBuf *ibuf_view; | ImBuf *ibuf_view; | ||||
| const int alpha_mode = (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL; | const int alpha_mode = (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL; | ||||
| int output_flags = oglrender->color_depth <= R_IMF_CHAN_DEPTH_8 ? IB_rect : IB_rectfloat; | |||||
| if (view_context) { | if (view_context) { | ||||
| ibuf_view = ED_view3d_draw_offscreen_imbuf(depsgraph, | ibuf_view = ED_view3d_draw_offscreen_imbuf(depsgraph, | ||||
| scene, | scene, | ||||
| v3d->shading.type, | v3d->shading.type, | ||||
| v3d, | v3d, | ||||
| ar, | ar, | ||||
| sizex, | sizex, | ||||
| sizey, | sizey, | ||||
| IB_rectfloat, | output_flags, | ||||
| alpha_mode, | alpha_mode, | ||||
| oglrender->ofs_samples, | oglrender->ofs_samples, | ||||
| viewname, | viewname, | ||||
| oglrender->ofs, | oglrender->ofs, | ||||
| err_out); | err_out); | ||||
| /* for stamp only */ | /* for stamp only */ | ||||
| if (rv3d->persp == RV3D_CAMOB && v3d->camera) { | if (rv3d->persp == RV3D_CAMOB && v3d->camera) { | ||||
| camera = BKE_camera_multiview_render(oglrender->scene, v3d->camera, viewname); | camera = BKE_camera_multiview_render(oglrender->scene, v3d->camera, viewname); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(depsgraph, | ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(depsgraph, | ||||
| scene, | scene, | ||||
| NULL, | NULL, | ||||
| OB_SOLID, | OB_SOLID, | ||||
| scene->camera, | scene->camera, | ||||
| oglrender->sizex, | oglrender->sizex, | ||||
| oglrender->sizey, | oglrender->sizey, | ||||
| IB_rectfloat, | output_flags, | ||||
| V3D_OFSDRAW_SHOW_ANNOTATION, | V3D_OFSDRAW_SHOW_ANNOTATION, | ||||
| alpha_mode, | alpha_mode, | ||||
| oglrender->ofs_samples, | oglrender->ofs_samples, | ||||
| viewname, | viewname, | ||||
| oglrender->ofs, | oglrender->ofs, | ||||
| err_out); | err_out); | ||||
| camera = scene->camera; | camera = scene->camera; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | static bool screen_opengl_render_init(bContext *C, wmOperator *op) | ||||
| ARegion *prevar = CTX_wm_region(C); | ARegion *prevar = CTX_wm_region(C); | ||||
| GPUOffScreen *ofs; | GPUOffScreen *ofs; | ||||
| OGLRender *oglrender; | OGLRender *oglrender; | ||||
| int sizex, sizey; | int sizex, sizey; | ||||
| bool is_view_context = RNA_boolean_get(op->ptr, "view_context"); | bool is_view_context = RNA_boolean_get(op->ptr, "view_context"); | ||||
| const bool is_animation = RNA_boolean_get(op->ptr, "animation"); | const bool is_animation = RNA_boolean_get(op->ptr, "animation"); | ||||
| const bool is_sequencer = RNA_boolean_get(op->ptr, "sequencer"); | const bool is_sequencer = RNA_boolean_get(op->ptr, "sequencer"); | ||||
| const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); | const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); | ||||
| const eImageFormatDepth color_depth = (is_animation) ? scene->r.im_format.depth : | |||||
| R_IMF_CHAN_DEPTH_32; | |||||
| const int samples = U.ogl_multisamples; | const int samples = U.ogl_multisamples; | ||||
| char err_out[256] = "unknown"; | char err_out[256] = "unknown"; | ||||
| if (G.background) { | if (G.background) { | ||||
| BKE_report( | BKE_report( | ||||
| op->reports, RPT_ERROR, "Cannot use OpenGL render in background mode (no opengl context)"); | op->reports, RPT_ERROR, "Cannot use OpenGL render in background mode (no opengl context)"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | static bool screen_opengl_render_init(bContext *C, wmOperator *op) | ||||
| /* NOTE: The depsgraph is not only used to update scene for a new frames, but also to initialize | /* NOTE: The depsgraph is not only used to update scene for a new frames, but also to initialize | ||||
| * output video handles, which does need evaluated scene. */ | * output video handles, which does need evaluated scene. */ | ||||
| oglrender->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | oglrender->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| oglrender->cfrao = scene->r.cfra; | oglrender->cfrao = scene->r.cfra; | ||||
| oglrender->ofs_samples = samples; | oglrender->ofs_samples = samples; | ||||
| oglrender->write_still = is_write_still && !is_animation; | oglrender->write_still = is_write_still && !is_animation; | ||||
| oglrender->is_animation = is_animation; | oglrender->is_animation = is_animation; | ||||
| oglrender->color_depth = color_depth; | |||||
| oglrender->views_len = BKE_scene_multiview_num_views_get(&scene->r); | oglrender->views_len = BKE_scene_multiview_num_views_get(&scene->r); | ||||
| oglrender->is_sequencer = is_sequencer; | oglrender->is_sequencer = is_sequencer; | ||||
| if (is_sequencer) { | if (is_sequencer) { | ||||
| oglrender->sseq = CTX_wm_space_seq(C); | oglrender->sseq = CTX_wm_space_seq(C); | ||||
| ImBuf **ibufs_arr = MEM_callocN(sizeof(*ibufs_arr) * oglrender->views_len, __func__); | ImBuf **ibufs_arr = MEM_callocN(sizeof(*ibufs_arr) * oglrender->views_len, __func__); | ||||
| oglrender->seq_data.ibufs_arr = ibufs_arr; | oglrender->seq_data.ibufs_arr = ibufs_arr; | ||||
| ▲ Show 20 Lines • Show All 552 Lines • Show Last 20 Lines | |||||