Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_engine.c
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (!stl->g_data) { | ||||
| stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__); | stl->g_data = MEM_callocN(sizeof(*stl->g_data), __func__); | ||||
| } | } | ||||
| stl->g_data->use_color_render_settings = USE_SCENE_LIGHT(v3d) || | stl->g_data->use_color_render_settings = USE_SCENE_LIGHT(v3d) || | ||||
| !LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d); | !LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d); | ||||
| stl->g_data->background_alpha = DRW_state_draw_background() ? 1.0f : 0.0f; | stl->g_data->background_alpha = DRW_state_draw_background() ? 1.0f : 0.0f; | ||||
| stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL); | stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL); | ||||
| stl->g_data->valid_taa_history = (txl->taa_history != NULL); | stl->g_data->valid_taa_history = (txl->taa_history != NULL); | ||||
| const float *viewport_size = DRW_viewport_render_size_get(); | |||||
| int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]}; | |||||
| /* Invalidate the TAA history if the render size was changed */ | |||||
| if (txl->color) { | |||||
| int size[2]; | |||||
| GPU_texture_get_mipmap_size(txl->color, 0, size); | |||||
| if (size[0] != size_fs[0] || size[1] != size_fs[1]) { | |||||
| stl->g_data->view_updated = true; | |||||
| stl->g_data->valid_double_buffer = false; | |||||
| stl->g_data->valid_taa_history = false; | |||||
| } | |||||
| } | |||||
| /* Main Buffer */ | /* Main Buffer */ | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->color, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP); | DRW_texture_ensure_render_fullscreen_2d( | ||||
| &txl->color, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP); | |||||
| { | |||||
| int size[2]; | |||||
| GPU_texture_get_mipmap_size(dtxl->depth, 0, size); | |||||
| /* Use dtxl->depth if the render size matches the viewport size. | |||||
| * Otherwise, create a new depth buffer. */ | |||||
| if (size[0] != size_fs[0] || size[1] != size_fs[1]) { | |||||
| DRW_texture_ensure_render_fullscreen_2d(&txl->depth, GPU_DEPTH24_STENCIL8, 0); | |||||
| } | |||||
| else { | |||||
| DRW_TEXTURE_FREE_SAFE(txl->depth); | |||||
| } | |||||
| } | |||||
| GPU_framebuffer_ensure_config(&fbl->main_fb, | GPU_framebuffer_ensure_config(&fbl->main_fb, | ||||
| {GPU_ATTACHMENT_TEXTURE(dtxl->depth), | {GPU_ATTACHMENT_TEXTURE(txl->depth ? txl->depth : dtxl->depth), | ||||
| GPU_ATTACHMENT_TEXTURE(txl->color), | GPU_ATTACHMENT_TEXTURE(txl->color), | ||||
| GPU_ATTACHMENT_LEAVE, | GPU_ATTACHMENT_LEAVE, | ||||
| GPU_ATTACHMENT_LEAVE, | GPU_ATTACHMENT_LEAVE, | ||||
| GPU_ATTACHMENT_LEAVE, | GPU_ATTACHMENT_LEAVE, | ||||
| GPU_ATTACHMENT_LEAVE}); | GPU_ATTACHMENT_LEAVE}); | ||||
| 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)}); | ||||
| GPU_framebuffer_ensure_config( | |||||
| &fbl->main_depth_fb, | |||||
| {GPU_ATTACHMENT_TEXTURE(txl->depth ? txl->depth : dtxl->depth), GPU_ATTACHMENT_NONE}); | |||||
| 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); | ||||
| } | } | ||||
| if (sldata->clip_ubo == NULL) { | if (sldata->clip_ubo == NULL) { | ||||
| sldata->clip_ubo = DRW_uniformbuffer_create(sizeof(sldata->clip_data), &sldata->clip_data); | sldata->clip_ubo = DRW_uniformbuffer_create(sizeof(sldata->clip_data), &sldata->clip_data); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | while (loop_len--) { | ||||
| /* Depth prepass */ | /* Depth prepass */ | ||||
| DRW_stats_group_start("Prepass"); | DRW_stats_group_start("Prepass"); | ||||
| DRW_draw_pass(psl->depth_pass); | DRW_draw_pass(psl->depth_pass); | ||||
| DRW_draw_pass(psl->depth_pass_cull); | DRW_draw_pass(psl->depth_pass_cull); | ||||
| DRW_stats_group_end(); | DRW_stats_group_end(); | ||||
| /* Create minmax texture */ | /* Create minmax texture */ | ||||
| DRW_stats_group_start("Main MinMax buffer"); | DRW_stats_group_start("Main MinMax buffer"); | ||||
| EEVEE_create_minmax_buffer(vedata, dtxl->depth, -1); | EEVEE_create_minmax_buffer(vedata, txl->depth ? txl->depth : dtxl->depth, -1); | ||||
| DRW_stats_group_end(); | DRW_stats_group_end(); | ||||
| EEVEE_occlusion_compute(sldata, vedata, dtxl->depth, -1); | EEVEE_occlusion_compute(sldata, vedata, txl->depth ? txl->depth : dtxl->depth, -1); | ||||
| EEVEE_volumes_compute(sldata, vedata); | EEVEE_volumes_compute(sldata, vedata); | ||||
| /* Shading pass */ | /* Shading pass */ | ||||
| DRW_stats_group_start("Shading"); | DRW_stats_group_start("Shading"); | ||||
| if (DRW_state_draw_background()) { | if (DRW_state_draw_background()) { | ||||
| DRW_draw_pass(psl->background_pass); | DRW_draw_pass(psl->background_pass); | ||||
| } | } | ||||
| EEVEE_draw_default_passes(psl); | EEVEE_draw_default_passes(psl); | ||||
| Show All 29 Lines | while (loop_len--) { | ||||
| EEVEE_draw_effects(sldata, vedata); | EEVEE_draw_effects(sldata, vedata); | ||||
| DRW_stats_group_end(); | DRW_stats_group_end(); | ||||
| if ((stl->effects->taa_current_sample > 1) && !DRW_state_is_image_render()) { | if ((stl->effects->taa_current_sample > 1) && !DRW_state_is_image_render()) { | ||||
| DRW_viewport_matrix_override_unset_all(); | DRW_viewport_matrix_override_unset_all(); | ||||
| } | } | ||||
| } | } | ||||
| if (txl->depth) { | |||||
| /* Render the depth in full-resolution so that overlay rendering | |||||
| * does not cause Z-fighting */ | |||||
| GPU_framebuffer_bind(dfbl->depth_only_fb); | |||||
| GPU_framebuffer_clear_depth(dfbl->depth_only_fb, 1.0f); | |||||
| DRW_stats_group_start("Full-res Depth Pass"); | |||||
| DRW_draw_pass(psl->depth_pass); | |||||
| DRW_draw_pass(psl->depth_pass_cull); | |||||
| DRW_stats_group_end(); | |||||
| } | |||||
| /* LookDev */ | /* LookDev */ | ||||
| EEVEE_lookdev_draw_background(vedata); | EEVEE_lookdev_draw_background(vedata); | ||||
| /* END */ | /* END */ | ||||
| /* 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); | ||||
| ▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines | |||||