Changeset View
Standalone View
source/blender/draw/engines/external/external_engine.c
| Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | static void external_cache_init(void *vedata) | |||||||||
| } | } | |||||||||
| /* Do not draw depth pass when overlays are turned off. */ | /* Do not draw depth pass when overlays are turned off. */ | |||||||||
| stl->g_data->need_depth = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0; | stl->g_data->need_depth = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0; | |||||||||
| } | } | |||||||||
| static void external_cache_populate(void *vedata, Object *ob) | static void external_cache_populate(void *vedata, Object *ob) | |||||||||
| { | { | |||||||||
| EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; | EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; | |||||||||
jbakker: Additional speedup can be get when modify-ing `DRW_draw_render_loop_2d_ex#do_populate_loop`.
I… | ||||||||||
Done Inline ActionsSeems that the optimization you're mentioning can be performed in the master branch by checking the image type. There is even a TODO there ;) sergey: Seems that the optimization you're mentioning can be performed in the master branch by checking… | ||||||||||
| if (!(DRW_object_is_renderable(ob) && | if (!(DRW_object_is_renderable(ob) && | |||||||||
| DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) { | DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) { | |||||||||
| return; | return; | |||||||||
| } | } | |||||||||
| if (ob->type == OB_GPENCIL) { | if (ob->type == OB_GPENCIL) { | |||||||||
| /* Grease Pencil objects need correct depth to do the blending. */ | /* Grease Pencil objects need correct depth to do the blending. */ | |||||||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | static void external_draw_scene_do(void *vedata) | |||||||||
| } | } | |||||||||
| } | } | |||||||||
| static void external_draw_scene(void *vedata) | static void external_draw_scene(void *vedata) | |||||||||
| { | { | |||||||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | |||||||||
| EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; | EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl; | |||||||||
| EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl; | EXTERNAL_PassList *psl = ((EXTERNAL_Data *)vedata)->psl; | |||||||||
| EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl; | EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl; | |||||||||
Not Done Inline ActionsHmm... current structure would still allocate shader passes and shader groups. We could not register the external engine when the prerequisites have not met (draw_manager.c) or invoke this method in the populate_init and don't construct the passes/groups in this case. The second option is mostly how we solve this. Note: DRW_engine_external_use_for_image_editor could also be a good location to block the external engine registration. jbakker: Hmm...
current structure would still allocate shader passes and shader groups. We could not… | ||||||||||
Done Inline ActionsCan you please rephrase the comment? DRW_engine_external_use_for_image_editor will actually enforce use of image_engine if either scene's Render or render's engine is missing. sergey: Can you please rephrase the comment?
`DRW_engine_external_use_for_image_editor` will actually… | ||||||||||
| const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | |||||||||
| /* Will be NULL during OpenGL render. | /* Will be NULL during OpenGL render. | |||||||||
| * OpenGL render is used for quick preview (thumbnails or sequencer preview) | * OpenGL render is used for quick preview (thumbnails or sequencer preview) | |||||||||
| * where using the rendering engine to preview doesn't make so much sense. */ | * where using the rendering engine to preview doesn't make so much sense. */ | |||||||||
| if (draw_ctx->evil_C) { | if (draw_ctx->evil_C) { | |||||||||
| const float clear_col[4] = {0, 0, 0, 0}; | const float clear_col[4] = {0, 0, 0, 0}; | |||||||||
| /* This is to keep compatibility with external engine. */ | /* This is to keep compatibility with external engine. */ | |||||||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | RenderEngineType DRW_engine_viewport_external_type = { | |||||||||
| RE_INTERNAL | RE_USE_STEREO_VIEWPORT, | RE_INTERNAL | RE_USE_STEREO_VIEWPORT, | |||||||||
| NULL, | NULL, | |||||||||
| NULL, | NULL, | |||||||||
| NULL, | NULL, | |||||||||
| NULL, | NULL, | |||||||||
| NULL, | NULL, | |||||||||
| NULL, | NULL, | |||||||||
| NULL, | NULL, | |||||||||
| NULL, | ||||||||||
| &draw_engine_external_type, | &draw_engine_external_type, | |||||||||
| {NULL, NULL, NULL}, | {NULL, NULL, NULL}, | |||||||||
Not Done Inline Actions
fclem: | ||||||||||
| }; | }; | |||||||||
| #undef EXTERNAL_ENGINE | #undef EXTERNAL_ENGINE | |||||||||
Not Done Inline Actionsexternal engines could alter the state of the GPU. Internal flags could be different than we expect. We might need a DRW_state_reset to make sure we can trust the internal and GPU state. In the viewport we added fixes when using BGL render engines, but I don't see the same when render engines call GL directly. Would add the GPU_bgl_end() here also, for case users want to use BGL to do similar tricks. jbakker: external engines could alter the state of the GPU. Internal flags could be different than we… | ||||||||||
Done Inline ActionsAm i understanding it correctly that I simply need to add DRW_state_reset(); and GPU_bgl_end(); at the end of this function? sergey: Am i understanding it correctly that I simply need to add `DRW_state_reset();` and `GPU_bgl_end… | ||||||||||
Not Done Inline ActionsGPU_bgl_end: yes, jbakker: GPU_bgl_end: yes,
DRW_state_reset: not sure, need feedback from Clement. | ||||||||||
Not Done Inline ActionsThrow a DRW_state_reset in there for good measure. But this is being a little bit paranoid. fclem: Throw a `DRW_state_reset` in there for good measure. But this is being a little bit paranoid. | ||||||||||
Not Done Inline ActionsI would suggest renaming the function to external_image_space_matrix_set to make it clear it sets the matrices and to not confuse it with external_cache_init (was my first thought). fclem: I would suggest renaming the function to `external_image_space_matrix_set` to make it clear it… | ||||||||||
Additional speedup can be get when modify-ing DRW_draw_render_loop_2d_ex#do_populate_loop.
I don't see this part of this patch, but would improve performance in heavier scenes.