diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_engine.c | 3 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lightcache.c | 3 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_private.h | 1 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_volumes.c | 14 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_extra.c | 19 | ||||
-rw-r--r-- | source/blender/draw/engines/overlay/overlay_private.h | 1 | ||||
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_data.c | 1 | ||||
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_engine.c | 4 | ||||
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_private.h | 5 | ||||
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_volume.c | 19 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.h | 5 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_fluid.c | 97 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 18 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.h | 2 |
14 files changed, 54 insertions, 138 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 81edee17c76..47e8f234a01 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -353,8 +353,6 @@ static void eevee_draw_scene(void *vedata) EEVEE_renderpasses_draw_debug(vedata); - EEVEE_volumes_free_smoke_textures(); - stl->g_data->view_updated = false; DRW_view_set_active(NULL); @@ -574,7 +572,6 @@ static void eevee_render_to_image(void *vedata, } } - EEVEE_volumes_free_smoke_textures(); EEVEE_motion_blur_data_free(&ved->stl->effects->motion_blur); if (RE_engine_test_break(engine)) { diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index 2e1b92de068..f18e4db876b 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -1463,9 +1463,6 @@ void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float } eevee_lightbake_delete_resources(lbake); - - /* Free GPU smoke textures and the smoke domain list correctly: See also T73921. */ - EEVEE_volumes_free_smoke_textures(); } void EEVEE_lightbake_update_world_quick(EEVEE_ViewLayerData *sldata, diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 9f97dacf9fe..ee336326166 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -1558,7 +1558,6 @@ void EEVEE_volumes_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_volumes_resolve(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); void EEVEE_volumes_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, uint tot_samples); void EEVEE_volumes_output_accumulate(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata); -void EEVEE_volumes_free_smoke_textures(void); void EEVEE_volumes_free(void); /* eevee_effects.c */ diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 6a0c9fb36df..0ac6c6ad97c 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -43,9 +43,6 @@ static struct { GPUTexture *dummy_scatter; GPUTexture *dummy_transmit; - - /* List of all fluid simulation / smoke domains rendered within this frame. */ - ListBase smoke_domains; } e_data = {NULL}; /* Engine data */ static void eevee_create_textures_volumes(void) @@ -426,7 +423,6 @@ static bool eevee_volume_object_mesh_init(Scene *scene, if (fds->fluid && (fds->type == FLUID_DOMAIN_TYPE_GAS) /* && show_smoke */) { DRW_smoke_ensure(fmd, fds->flags & FLUID_DOMAIN_USE_NOISE); - BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(fmd)); } LISTBASE_FOREACH (GPUMaterialVolumeGrid *, gpu_grid, gpu_grids) { @@ -753,16 +749,6 @@ void EEVEE_volumes_resolve(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda } } -void EEVEE_volumes_free_smoke_textures(void) -{ - /* Free Smoke Textures after rendering */ - LISTBASE_FOREACH (LinkData *, link, &e_data.smoke_domains) { - FluidModifierData *fmd = (FluidModifierData *)link->data; - DRW_smoke_free(fmd); - } - BLI_freelistN(&e_data.smoke_domains); -} - void EEVEE_volumes_free(void) { DRW_TEXTURE_FREE_SAFE(e_data.dummy_scatter); diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index abcca5525c7..5d8ba06e181 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -1474,23 +1474,6 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, } if (draw_velocity || show_gridlines) { - BLI_addtail(&data->stl->pd->smoke_domains, BLI_genericNodeN(fmd)); - } -} - -static void OVERLAY_volume_free_smoke_textures(OVERLAY_Data *data) -{ - /* Free Smoke Textures after rendering */ - /* XXX This is a waste of processing and GPU bandwidth if nothing - * is updated. But the problem is since Textures are stored in the - * modifier we don't want them to take precious VRAM if the - * modifier is not used for display. We should share them for - * all viewport in a redraw at least. */ - LinkData *link; - while ((link = BLI_pophead(&data->stl->pd->smoke_domains))) { - FluidModifierData *fmd = (FluidModifierData *)link->data; - DRW_smoke_free_velocity(fmd); - MEM_freeN(link); } } @@ -1624,8 +1607,6 @@ void OVERLAY_extra_draw(OVERLAY_Data *vedata) void OVERLAY_extra_in_front_draw(OVERLAY_Data *vedata) { DRW_draw_pass(vedata->psl->extra_ps[1]); - - OVERLAY_volume_free_smoke_textures(vedata); } void OVERLAY_extra_centers_draw(OVERLAY_Data *vedata) diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.h index 71b6c9424e6..4c933e08a57 100644 --- a/source/blender/draw/engines/overlay/overlay_private.h +++ b/source/blender/draw/engines/overlay/overlay_private.h @@ -304,7 +304,6 @@ typedef struct OVERLAY_PrivateData { DRWView *view_edit_curves_points; /** TODO: get rid of this. */ - ListBase smoke_domains; ListBase bg_movie_clips; /** Two instances for in_front option and without. */ diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index f4e042933d1..f7f156e5297 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -163,7 +163,6 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->taa_sample_len = workbench_antialiasing_sample_count_get(wpd); wpd->volumes_do = false; - BLI_listbase_clear(&wpd->smoke_domains); /* FIXME: This reproduce old behavior when workbench was separated in 2 engines. * But this is a workaround for a missing update tagging. */ diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 566fd30096d..ccd693bc4c2 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -613,10 +613,8 @@ static void workbench_draw_scene(void *ved) workbench_draw_finish(vedata); } -void workbench_draw_finish(void *ved) +void workbench_draw_finish(void *UNUSED(ved)) { - WORKBENCH_Data *vedata = ved; - workbench_volume_draw_finish(vedata); /* Reset default view. */ DRW_view_set_active(NULL); } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 727b771ee08..492bce1e571 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -324,10 +324,6 @@ typedef struct WORKBENCH_PrivateData { /** Index of current material inside the material chunk. Only for material coloring mode. */ int material_index; - /* Volumes */ - /** List of smoke domain textures to free after drawing. */ - ListBase smoke_domains; - /* Depth of Field */ /** Depth of field temp buffers. */ struct GPUTexture *dof_blur_tx; @@ -533,7 +529,6 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata, struct ModifierData *md, eV3DShadingColorType color_type); void workbench_volume_draw_pass(WORKBENCH_Data *vedata); -void workbench_volume_draw_finish(WORKBENCH_Data *vedata); /* workbench_engine.c */ diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index c6f40c5d6bb..2c902e9b627 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -178,8 +178,6 @@ static void workbench_volume_modifier_cache_populate(WORKBENCH_Data *vedata, else { DRW_shgroup_call(grp, DRW_cache_cube_get(), ob); } - - BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(fmd)); } static void workbench_volume_material_color(WORKBENCH_PrivateData *wpd, @@ -334,20 +332,3 @@ void workbench_volume_draw_pass(WORKBENCH_Data *vedata) DRW_draw_pass(psl->volume_ps); } } - -void workbench_volume_draw_finish(WORKBENCH_Data *vedata) -{ - WORKBENCH_PrivateData *wpd = vedata->stl->wpd; - - /* Free Smoke Textures after rendering */ - /* XXX This is a waste of processing and GPU bandwidth if nothing - * is updated. But the problem is since Textures are stored in the - * modifier we don't want them to take precious VRAM if the - * modifier is not used for display. We should share them for - * all viewport in a redraw at least. */ - LISTBASE_FOREACH (LinkData *, link, &wpd->smoke_domains) { - FluidModifierData *fmd = (FluidModifierData *)link->data; - DRW_smoke_free(fmd); - } - BLI_freelistN(&wpd->smoke_domains); -} diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index d302140d9ac..566e68a5c84 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -21,6 +21,7 @@ struct Object; struct ParticleSystem; struct RegionView3D; struct ViewLayer; +struct DRWData; /* Keep in sync with globalsBlock in shaders */ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16) @@ -83,7 +84,9 @@ void DRW_fluid_ensure_flags(struct FluidModifierData *fmd); void DRW_fluid_ensure_range_field(struct FluidModifierData *fmd); void DRW_smoke_free(struct FluidModifierData *fmd); -void DRW_smoke_free_velocity(struct FluidModifierData *fmd); + +void DRW_smoke_init(struct DRWData *drw_data); +void DRW_smoke_exit(struct DRWData *drw_data); /* draw_common.c */ diff --git a/source/blender/draw/intern/draw_fluid.c b/source/blender/draw/intern/draw_fluid.c index 667bd24dddb..d3d4bbf505e 100644 --- a/source/blender/draw/intern/draw_fluid.c +++ b/source/blender/draw/intern/draw_fluid.c @@ -9,6 +9,7 @@ #include <string.h> +#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_utildefines.h" @@ -21,6 +22,8 @@ #include "GPU_texture.h" +#include "draw_manager.h" + #include "draw_common.h" /* Own include. */ #ifdef WITH_FLUID @@ -419,46 +422,6 @@ static bool get_smoke_velocity_field(FluidDomainSettings *fds, /** \name Public API * \{ */ -void DRW_smoke_free(FluidModifierData *fmd) -{ - if (fmd->type & MOD_FLUID_TYPE_DOMAIN && fmd->domain) { - if (fmd->domain->tex_density) { - GPU_texture_free(fmd->domain->tex_density); - fmd->domain->tex_density = NULL; - } - - if (fmd->domain->tex_color) { - GPU_texture_free(fmd->domain->tex_color); - fmd->domain->tex_color = NULL; - } - - if (fmd->domain->tex_shadow) { - GPU_texture_free(fmd->domain->tex_shadow); - fmd->domain->tex_shadow = NULL; - } - - if (fmd->domain->tex_flame) { - GPU_texture_free(fmd->domain->tex_flame); - fmd->domain->tex_flame = NULL; - } - - if (fmd->domain->tex_flame_coba) { - GPU_texture_free(fmd->domain->tex_flame_coba); - fmd->domain->tex_flame_coba = NULL; - } - - if (fmd->domain->tex_coba) { - GPU_texture_free(fmd->domain->tex_coba); - fmd->domain->tex_coba = NULL; - } - - if (fmd->domain->tex_field) { - GPU_texture_free(fmd->domain->tex_field); - fmd->domain->tex_field = NULL; - } - } -} - void DRW_smoke_ensure_coba_field(FluidModifierData *fmd) { #ifndef WITH_FLUID @@ -469,6 +432,7 @@ void DRW_smoke_ensure_coba_field(FluidModifierData *fmd) if (!fds->tex_field) { fds->tex_field = create_field_texture(fds, false); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_field)); } if (!fds->tex_coba && !ELEM(fds->coba_field, FLUID_DOMAIN_FIELD_PHI, @@ -478,6 +442,7 @@ void DRW_smoke_ensure_coba_field(FluidModifierData *fmd) FLUID_DOMAIN_FIELD_FLAGS, FLUID_DOMAIN_FIELD_PRESSURE)) { fds->tex_coba = create_transfer_function(TFUNC_COLOR_RAMP, fds->coba); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_coba)); } } #endif @@ -493,19 +458,24 @@ void DRW_smoke_ensure(FluidModifierData *fmd, int highres) if (!fds->tex_density) { fds->tex_density = create_density_texture(fds, highres); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_density)); } if (!fds->tex_color) { fds->tex_color = create_color_texture(fds, highres); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_color)); } if (!fds->tex_flame) { fds->tex_flame = create_flame_texture(fds, highres); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_flame)); } if (!fds->tex_flame_coba && fds->tex_flame) { fds->tex_flame_coba = create_transfer_function(TFUNC_FLAME_SPECTRUM, NULL); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_flame_coba)); } if (!fds->tex_shadow) { fds->tex_shadow = create_volume_texture( fds->res, GPU_R8, GPU_DATA_FLOAT, manta_smoke_get_shadow(fds->fluid)); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_shadow)); } } #endif /* WITH_FLUID */ @@ -536,6 +506,9 @@ void DRW_smoke_ensure_velocity(FluidModifierData *fmd) "vely", UNPACK3(fds->res), 1, GPU_R16F, GPU_DATA_FLOAT, vel_y); fds->tex_velocity_z = GPU_texture_create_3d( "velz", UNPACK3(fds->res), 1, GPU_R16F, GPU_DATA_FLOAT, vel_z); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_x)); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_y)); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_velocity_z)); } } #endif /* WITH_FLUID */ @@ -551,6 +524,7 @@ void DRW_fluid_ensure_flags(FluidModifierData *fmd) if (!fds->tex_flags) { fds->tex_flags = create_volume_texture( fds->res, GPU_R8UI, GPU_DATA_INT, manta_smoke_get_flags(fds->fluid)); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_flags)); swizzle_texture_channel_single(fds->tex_flags); } @@ -568,42 +542,29 @@ void DRW_fluid_ensure_range_field(FluidModifierData *fmd) if (!fds->tex_range_field) { fds->tex_range_field = create_field_texture(fds, true); + BLI_addtail(&DST.vmempool->smoke_textures, BLI_genericNodeN(&fds->tex_range_field)); } } #endif /* WITH_FLUID */ } -void DRW_smoke_free_velocity(FluidModifierData *fmd) +void DRW_smoke_init(DRWData *drw_data) { - /* TODO: Unify with the other #GPU_free_smoke. */ - - if (fmd->type & MOD_FLUID_TYPE_DOMAIN && fmd->domain) { - if (fmd->domain->tex_velocity_x) { - GPU_texture_free(fmd->domain->tex_velocity_x); - } - - if (fmd->domain->tex_velocity_y) { - GPU_texture_free(fmd->domain->tex_velocity_y); - } - - if (fmd->domain->tex_velocity_z) { - GPU_texture_free(fmd->domain->tex_velocity_z); - } - - if (fmd->domain->tex_flags) { - GPU_texture_free(fmd->domain->tex_flags); - } - - if (fmd->domain->tex_range_field) { - GPU_texture_free(fmd->domain->tex_range_field); - } + BLI_listbase_clear(&drw_data->smoke_textures); +} - fmd->domain->tex_velocity_x = NULL; - fmd->domain->tex_velocity_y = NULL; - fmd->domain->tex_velocity_z = NULL; - fmd->domain->tex_flags = NULL; - fmd->domain->tex_range_field = NULL; +void DRW_smoke_exit(DRWData *drw_data) +{ + /* Free Smoke Textures after rendering */ + /* XXX This is a waste of processing and GPU bandwidth if nothing + * is updated. But the problem is since Textures are stored in the + * modifier we don't want them to take precious VRAM if the + * modifier is not used for display. We should share them for + * all viewport in a redraw at least. */ + LISTBASE_FOREACH (LinkData *, link, &drw_data->smoke_textures) { + GPU_TEXTURE_FREE_SAFE(*(GPUTexture **)link->data); } + BLI_freelistN(&drw_data->smoke_textures); } /** \} */ diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 88d05fcd928..441628f2490 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1650,6 +1650,7 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, drw_debug_init(); DRW_hair_init(); + DRW_smoke_init(DST.vmempool); /* No frame-buffer allowed before drawing. */ BLI_assert(GPU_framebuffer_active_get() == GPU_framebuffer_back_get()); @@ -1715,6 +1716,8 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, GPU_flush(); } + DRW_smoke_exit(DST.vmempool); + DRW_stats_reset(); DRW_draw_callbacks_post_scene(); @@ -1999,6 +2002,8 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph) GPU_framebuffer_restore(); + DRW_smoke_exit(DST.vmempool); + drw_manager_exit(&DST); /* Reset state after drawing */ @@ -2016,6 +2021,7 @@ void DRW_render_object_iter( { const DRWContextState *draw_ctx = DRW_context_state_get(); DRW_hair_init(); + DRW_smoke_init(DST.vmempool); drw_task_graph_init(); const int object_type_exclude_viewport = draw_ctx->v3d ? @@ -2071,6 +2077,7 @@ void DRW_custom_pipeline(DrawEngineType *draw_engine_type, drw_manager_init(&DST, NULL, NULL); DRW_hair_init(); + DRW_smoke_init(DST.vmempool); ViewportEngineData *data = DRW_view_data_engine_data_get_ensure(DST.view_data_active, draw_engine_type); @@ -2079,6 +2086,8 @@ void DRW_custom_pipeline(DrawEngineType *draw_engine_type, callback(data, user_data); DST.buffer_finish_called = false; + DRW_smoke_exit(DST.vmempool); + GPU_framebuffer_restore(); /* The use of custom pipeline in other thread using the same @@ -2095,11 +2104,14 @@ void DRW_custom_pipeline(DrawEngineType *draw_engine_type, void DRW_cache_restart(void) { + DRW_smoke_exit(DST.vmempool); + drw_manager_init(&DST, DST.viewport, (int[2]){UNPACK2(DST.size)}); DST.buffer_finish_called = false; DRW_hair_init(); + DRW_smoke_init(DST.vmempool); } void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph, @@ -2417,6 +2429,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph, /* Init engines */ drw_engines_init(); DRW_hair_init(); + DRW_smoke_init(DST.vmempool); { drw_engines_cache_init(); @@ -2511,6 +2524,8 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph, } } + DRW_smoke_exit(DST.vmempool); + DRW_state_reset(); drw_engines_disable(); @@ -2587,6 +2602,7 @@ static void drw_draw_depth_loop_impl(struct Depsgraph *depsgraph, /* Init engines */ drw_engines_init(); DRW_hair_init(); + DRW_smoke_init(DST.vmempool); { drw_engines_cache_init(); @@ -2623,6 +2639,8 @@ static void drw_draw_depth_loop_impl(struct Depsgraph *depsgraph, drw_engines_draw_scene(); + DRW_smoke_exit(DST.vmempool); + DRW_state_reset(); /* TODO: Reading depth for operators should be done here. */ diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 832897b7040..e861d91d47e 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -527,6 +527,8 @@ typedef struct DRWData { struct GPUUniformBuf **obinfos_ubo; struct GHash *obattrs_ubo_pool; uint ubo_len; + /** List of smoke textures to free after drawing. */ + ListBase smoke_textures; /** Texture pool to reuse temp texture across engines. */ /* TODO(@fclem): The pool could be shared even between view-ports. */ struct DRWTexturePool *texture_pool; |