Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/eevee_next/eevee_light.cc')
-rw-r--r--source/blender/draw/engines/eevee_next/eevee_light.cc125
1 files changed, 57 insertions, 68 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_light.cc b/source/blender/draw/engines/eevee_next/eevee_light.cc
index dbbf481f3f4..b60246fa3ab 100644
--- a/source/blender/draw/engines/eevee_next/eevee_light.cc
+++ b/source/blender/draw/engines/eevee_next/eevee_light.cc
@@ -333,11 +333,11 @@ void LightModule::end_sync()
/* This scene data buffer is then immutable after this point. */
light_buf_.push_update();
- for (auto key : deleted_keys) {
+ for (auto &key : deleted_keys) {
light_map_.remove(key);
}
- /* Update sampling on deletion or un-hidding (use_scene_lights). */
+ /* Update sampling on deletion or un-hiding (use_scene_lights). */
if (assign_if_different(light_map_size_, light_map_.size())) {
inst_.sampling.reset();
}
@@ -399,74 +399,70 @@ void LightModule::culling_pass_sync()
uint culling_tile_dispatch_size = divide_ceil_u(total_word_count_, CULLING_TILE_GROUP_SIZE);
/* NOTE: We reference the buffers that may be resized or updated later. */
+
+ culling_ps_.init();
{
- DRW_PASS_CREATE(culling_select_ps_, DRW_STATE_NO_DRAW);
- GPUShader *sh = inst_.shaders.static_shader_get(LIGHT_CULLING_SELECT);
- DRWShadingGroup *grp = DRW_shgroup_create(sh, culling_select_ps_);
- DRW_shgroup_storage_block_ref(grp, "light_cull_buf", &culling_data_buf_);
- DRW_shgroup_storage_block(grp, "in_light_buf", light_buf_);
- DRW_shgroup_storage_block(grp, "out_light_buf", culling_light_buf_);
- DRW_shgroup_storage_block(grp, "out_zdist_buf", culling_zdist_buf_);
- DRW_shgroup_storage_block(grp, "out_key_buf", culling_key_buf_);
- DRW_shgroup_call_compute(grp, culling_select_dispatch_size, 1, 1);
- DRW_shgroup_barrier(grp, GPU_BARRIER_SHADER_STORAGE);
+ auto &sub = culling_ps_.sub("Select");
+ sub.shader_set(inst_.shaders.static_shader_get(LIGHT_CULLING_SELECT));
+ sub.bind_ssbo("light_cull_buf", &culling_data_buf_);
+ sub.bind_ssbo("in_light_buf", light_buf_);
+ sub.bind_ssbo("out_light_buf", culling_light_buf_);
+ sub.bind_ssbo("out_zdist_buf", culling_zdist_buf_);
+ sub.bind_ssbo("out_key_buf", culling_key_buf_);
+ sub.dispatch(int3(culling_select_dispatch_size, 1, 1));
+ sub.barrier(GPU_BARRIER_SHADER_STORAGE);
}
{
- DRW_PASS_CREATE(culling_sort_ps_, DRW_STATE_NO_DRAW);
- GPUShader *sh = inst_.shaders.static_shader_get(LIGHT_CULLING_SORT);
- DRWShadingGroup *grp = DRW_shgroup_create(sh, culling_sort_ps_);
- DRW_shgroup_storage_block_ref(grp, "light_cull_buf", &culling_data_buf_);
- DRW_shgroup_storage_block(grp, "in_light_buf", light_buf_);
- DRW_shgroup_storage_block(grp, "out_light_buf", culling_light_buf_);
- DRW_shgroup_storage_block(grp, "in_zdist_buf", culling_zdist_buf_);
- DRW_shgroup_storage_block(grp, "in_key_buf", culling_key_buf_);
- DRW_shgroup_call_compute(grp, culling_sort_dispatch_size, 1, 1);
- DRW_shgroup_barrier(grp, GPU_BARRIER_SHADER_STORAGE);
+ auto &sub = culling_ps_.sub("Sort");
+ sub.shader_set(inst_.shaders.static_shader_get(LIGHT_CULLING_SORT));
+ sub.bind_ssbo("light_cull_buf", &culling_data_buf_);
+ sub.bind_ssbo("in_light_buf", light_buf_);
+ sub.bind_ssbo("out_light_buf", culling_light_buf_);
+ sub.bind_ssbo("in_zdist_buf", culling_zdist_buf_);
+ sub.bind_ssbo("in_key_buf", culling_key_buf_);
+ sub.dispatch(int3(culling_sort_dispatch_size, 1, 1));
+ sub.barrier(GPU_BARRIER_SHADER_STORAGE);
}
{
- DRW_PASS_CREATE(culling_zbin_ps_, DRW_STATE_NO_DRAW);
- GPUShader *sh = inst_.shaders.static_shader_get(LIGHT_CULLING_ZBIN);
- DRWShadingGroup *grp = DRW_shgroup_create(sh, culling_zbin_ps_);
- DRW_shgroup_storage_block_ref(grp, "light_cull_buf", &culling_data_buf_);
- DRW_shgroup_storage_block(grp, "light_buf", culling_light_buf_);
- DRW_shgroup_storage_block(grp, "out_zbin_buf", culling_zbin_buf_);
- DRW_shgroup_call_compute(grp, 1, 1, 1);
- DRW_shgroup_barrier(grp, GPU_BARRIER_SHADER_STORAGE);
+ auto &sub = culling_ps_.sub("Zbin");
+ sub.shader_set(inst_.shaders.static_shader_get(LIGHT_CULLING_ZBIN));
+ sub.bind_ssbo("light_cull_buf", &culling_data_buf_);
+ sub.bind_ssbo("light_buf", culling_light_buf_);
+ sub.bind_ssbo("out_zbin_buf", culling_zbin_buf_);
+ sub.dispatch(int3(1, 1, 1));
+ sub.barrier(GPU_BARRIER_SHADER_STORAGE);
}
{
- DRW_PASS_CREATE(culling_tile_ps_, DRW_STATE_NO_DRAW);
- GPUShader *sh = inst_.shaders.static_shader_get(LIGHT_CULLING_TILE);
- DRWShadingGroup *grp = DRW_shgroup_create(sh, culling_tile_ps_);
- DRW_shgroup_storage_block_ref(grp, "light_cull_buf", &culling_data_buf_);
- DRW_shgroup_storage_block(grp, "light_buf", culling_light_buf_);
- DRW_shgroup_storage_block(grp, "out_light_tile_buf", culling_tile_buf_);
- DRW_shgroup_call_compute(grp, culling_tile_dispatch_size, 1, 1);
- DRW_shgroup_barrier(grp, GPU_BARRIER_SHADER_STORAGE);
+ auto &sub = culling_ps_.sub("Tiles");
+ sub.shader_set(inst_.shaders.static_shader_get(LIGHT_CULLING_TILE));
+ sub.bind_ssbo("light_cull_buf", &culling_data_buf_);
+ sub.bind_ssbo("light_buf", culling_light_buf_);
+ sub.bind_ssbo("out_light_tile_buf", culling_tile_buf_);
+ sub.dispatch(int3(culling_tile_dispatch_size, 1, 1));
+ sub.barrier(GPU_BARRIER_SHADER_STORAGE);
}
}
void LightModule::debug_pass_sync()
{
- if (inst_.debug_mode != eDebugMode::DEBUG_LIGHT_CULLING) {
- debug_draw_ps_ = nullptr;
- return;
+ if (inst_.debug_mode == eDebugMode::DEBUG_LIGHT_CULLING) {
+ debug_draw_ps_.init();
+ debug_draw_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM);
+ debug_draw_ps_.shader_set(inst_.shaders.static_shader_get(LIGHT_CULLING_DEBUG));
+ inst_.hiz_buffer.bind_resources(&debug_draw_ps_);
+ debug_draw_ps_.bind_ssbo("light_buf", &culling_light_buf_);
+ debug_draw_ps_.bind_ssbo("light_cull_buf", &culling_data_buf_);
+ debug_draw_ps_.bind_ssbo("light_zbin_buf", &culling_zbin_buf_);
+ debug_draw_ps_.bind_ssbo("light_tile_buf", &culling_tile_buf_);
+ debug_draw_ps_.bind_texture("depth_tx", &inst_.render_buffers.depth_tx);
+ debug_draw_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3);
}
-
- debug_draw_ps_ = DRW_pass_create("LightCulling.Debug", DRW_STATE_WRITE_COLOR);
- GPUShader *sh = inst_.shaders.static_shader_get(LIGHT_CULLING_DEBUG);
- DRWShadingGroup *grp = DRW_shgroup_create(sh, debug_draw_ps_);
- DRW_shgroup_storage_block_ref(grp, "light_buf", &culling_light_buf_);
- DRW_shgroup_storage_block_ref(grp, "light_cull_buf", &culling_data_buf_);
- DRW_shgroup_storage_block_ref(grp, "light_zbin_buf", &culling_zbin_buf_);
- DRW_shgroup_storage_block_ref(grp, "light_tile_buf", &culling_tile_buf_);
- DRW_shgroup_uniform_texture_ref(grp, "depth_tx", &inst_.render_buffers.depth_tx);
- DRW_shgroup_call_procedural_triangles(grp, nullptr, 1);
}
-void LightModule::set_view(const DRWView *view, const int2 extent)
+void LightModule::set_view(View &view, const int2 extent)
{
- float far_z = DRW_view_far_distance_get(view);
- float near_z = DRW_view_near_distance_get(view);
+ float far_z = view.far_clip();
+ float near_z = view.near_clip();
culling_data_buf_.zbin_scale = -CULLING_ZBIN_COUNT / fabsf(far_z - near_z);
culling_data_buf_.zbin_bias = -near_z * culling_data_buf_.zbin_scale;
@@ -474,24 +470,17 @@ void LightModule::set_view(const DRWView *view, const int2 extent)
culling_data_buf_.visible_count = 0;
culling_data_buf_.push_update();
- DRW_stats_group_start("Light Culling");
-
- DRW_view_set_active(view);
- DRW_draw_pass(culling_select_ps_);
- DRW_draw_pass(culling_sort_ps_);
- DRW_draw_pass(culling_zbin_ps_);
- DRW_draw_pass(culling_tile_ps_);
-
- DRW_stats_group_end();
+ inst_.manager->submit(culling_ps_, view);
}
-void LightModule::debug_draw(GPUFrameBuffer *view_fb)
+void LightModule::debug_draw(View &view, GPUFrameBuffer *view_fb)
{
- if (debug_draw_ps_ == nullptr) {
- return;
+ if (inst_.debug_mode == eDebugMode::DEBUG_LIGHT_CULLING) {
+ inst_.info = "Debug Mode: Light Culling Validation";
+ inst_.hiz_buffer.update();
+ GPU_framebuffer_bind(view_fb);
+ inst_.manager->submit(debug_draw_ps_, view);
}
- GPU_framebuffer_bind(view_fb);
- DRW_draw_pass(debug_draw_ps_);
}
/** \} */