Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_engine.c
| Show All 21 Lines | |||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "BLI_rand.h" | #include "BLI_rand.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_global.h" /* for G.debug_value */ | #include "BKE_global.h" /* for G.debug_value */ | ||||
| #include "DEG_depsgraph_query.h" | |||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "eevee_private.h" | #include "eevee_private.h" | ||||
| #include "eevee_engine.h" /* own include */ | #include "eevee_engine.h" /* own include */ | ||||
| #define EEVEE_ENGINE "BLENDER_EEVEE" | #define EEVEE_ENGINE "BLENDER_EEVEE" | ||||
| Show All 38 Lines | static void eevee_engine_init(void *ved) | ||||
| GPU_framebuffer_ensure_config(&fbl->main_color_fb, | GPU_framebuffer_ensure_config(&fbl->main_color_fb, | ||||
| {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->color)}); | {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(txl->color)}); | ||||
| if (sldata->common_ubo == NULL) { | if (sldata->common_ubo == NULL) { | ||||
| sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data), | sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data), | ||||
| &sldata->common_data); | &sldata->common_data); | ||||
| } | } | ||||
| /* EEVEE_effects_init needs to go first for TAA */ | /* `EEVEE_renderpasses_init` will set the active render passes used by `EEVEE_effects_init`. | ||||
| * `EEVEE_effects_init` needs to go second for TAA. */ | |||||
| EEVEE_renderpasses_init(vedata); | |||||
| EEVEE_effects_init(sldata, vedata, camera, false); | EEVEE_effects_init(sldata, vedata, camera, false); | ||||
| EEVEE_materials_init(sldata, stl, fbl); | EEVEE_materials_init(sldata, stl, fbl); | ||||
| EEVEE_shadows_init(sldata); | EEVEE_shadows_init(sldata); | ||||
| EEVEE_lightprobes_init(sldata, vedata); | EEVEE_lightprobes_init(sldata, vedata); | ||||
| } | } | ||||
| static void eevee_cache_init(void *vedata) | static void eevee_cache_init(void *vedata) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | if (cast_shadow) { | ||||
| EEVEE_shadows_caster_register(sldata, ob); | EEVEE_shadows_caster_register(sldata, ob); | ||||
| } | } | ||||
| } | } | ||||
| static void eevee_cache_finish(void *vedata) | static void eevee_cache_finish(void *vedata) | ||||
| { | { | ||||
| EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); | EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); | ||||
| EEVEE_PrivateData *g_data = ((EEVEE_Data *)vedata)->stl->g_data; | EEVEE_PrivateData *g_data = ((EEVEE_Data *)vedata)->stl->g_data; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | |||||
| const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); | |||||
| EEVEE_volumes_cache_finish(sldata, vedata); | EEVEE_volumes_cache_finish(sldata, vedata); | ||||
| EEVEE_materials_cache_finish(sldata, vedata); | EEVEE_materials_cache_finish(sldata, vedata); | ||||
| EEVEE_lights_cache_finish(sldata, vedata); | EEVEE_lights_cache_finish(sldata, vedata); | ||||
| EEVEE_lightprobes_cache_finish(sldata, vedata); | EEVEE_lightprobes_cache_finish(sldata, vedata); | ||||
| EEVEE_effects_draw_init(sldata, vedata); | EEVEE_effects_draw_init(sldata, vedata); | ||||
| EEVEE_volumes_draw_init(sldata, vedata); | EEVEE_volumes_draw_init(sldata, vedata); | ||||
| uint tot_samples = scene_eval->eevee.taa_render_samples; | |||||
| if (tot_samples == 0) { | |||||
| /* use a high number of samples so the outputs accum buffers | |||||
| * will have the highest possible precision */ | |||||
| tot_samples = 1024; | |||||
| } | |||||
| EEVEE_renderpasses_output_init(sldata, vedata, tot_samples); | |||||
| /* Restart taa if a shader has finish compiling. */ | /* Restart taa if a shader has finish compiling. */ | ||||
| /* HACK We should use notification of some sort from the compilation job instead. */ | /* HACK We should use notification of some sort from the compilation job instead. */ | ||||
| if (g_data->queued_shaders_count != g_data->queued_shaders_count_prev) { | if (g_data->queued_shaders_count != g_data->queued_shaders_count_prev) { | ||||
| g_data->queued_shaders_count_prev = g_data->queued_shaders_count; | g_data->queued_shaders_count_prev = g_data->queued_shaders_count; | ||||
| EEVEE_temporal_sampling_reset(vedata); | EEVEE_temporal_sampling_reset(vedata); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | while (loop_len--) { | ||||
| GPU_framebuffer_bind(fbl->main_fb); | GPU_framebuffer_bind(fbl->main_fb); | ||||
| GPU_framebuffer_texture_detach(fbl->main_color_fb, dtxl->depth); | GPU_framebuffer_texture_detach(fbl->main_color_fb, dtxl->depth); | ||||
| /* Post Process */ | /* Post Process */ | ||||
| DRW_stats_group_start("Post FX"); | DRW_stats_group_start("Post FX"); | ||||
| EEVEE_draw_effects(sldata, vedata); | EEVEE_draw_effects(sldata, vedata); | ||||
| DRW_stats_group_end(); | DRW_stats_group_end(); | ||||
| EEVEE_renderpasses_output_accumulate(sldata, vedata); | |||||
| DRW_view_set_active(NULL); | DRW_view_set_active(NULL); | ||||
| if (DRW_state_is_image_render() && (stl->effects->enabled_effects & EFFECT_SSR) && | if (DRW_state_is_image_render() && (stl->effects->enabled_effects & EFFECT_SSR) && | ||||
| !stl->effects->ssr_was_valid_double_buffer) { | !stl->effects->ssr_was_valid_double_buffer) { | ||||
| /* SSR needs one iteration to start properly. */ | /* SSR needs one iteration to start properly. */ | ||||
| loop_len++; | loop_len++; | ||||
| /* Reset sampling (and accumulation) after the first sample to avoid | /* Reset sampling (and accumulation) after the first sample to avoid | ||||
| * washed out first bounce for SSR. */ | * washed out first bounce for SSR. */ | ||||
| EEVEE_temporal_sampling_reset(vedata); | EEVEE_temporal_sampling_reset(vedata); | ||||
| stl->effects->ssr_was_valid_double_buffer = stl->g_data->valid_double_buffer; | stl->effects->ssr_was_valid_double_buffer = stl->g_data->valid_double_buffer; | ||||
| } | } | ||||
| } | } | ||||
| if ((stl->g_data->render_passes & SCE_PASS_COMBINED) > 0) { | |||||
| /* Tonemapping and transfer result to default framebuffer. */ | /* Tonemapping and transfer result to default framebuffer. */ | ||||
| bool use_render_settings = stl->g_data->use_color_render_settings; | bool use_render_settings = stl->g_data->use_color_render_settings; | ||||
| GPU_framebuffer_bind(dfbl->default_fb); | GPU_framebuffer_bind(dfbl->default_fb); | ||||
| DRW_transform_to_display(stl->effects->final_tx, true, use_render_settings); | DRW_transform_to_display(stl->effects->final_tx, true, use_render_settings); | ||||
| /* Draw checkerboard with alpha under. */ | /* Draw checkerboard with alpha under. */ | ||||
| EEVEE_draw_alpha_checker(vedata); | EEVEE_draw_alpha_checker(vedata); | ||||
| } | |||||
| else { | |||||
| EEVEE_renderpasses_draw(sldata, vedata); | |||||
| } | |||||
| /* Debug : Output buffer to view. */ | /* Debug : Output buffer to view. */ | ||||
| switch (G.debug_value) { | switch (G.debug_value) { | ||||
| case 1: | case 1: | ||||
| if (txl->maxzbuffer) { | if (txl->maxzbuffer) { | ||||
| DRW_transform_to_display(txl->maxzbuffer, false, false); | DRW_transform_to_display(txl->maxzbuffer, false, false); | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines | |||||