diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-08-30 21:25:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-08-30 21:25:48 +0300 |
commit | 57ea8616924aeae3875414500471ab50b80e750c (patch) | |
tree | 269425f20f47d212dfc0f680c297f004ae4a5759 /source | |
parent | 884bb4a4a5ea04521c76b38a033cbc797be35e9f (diff) |
EEVEE-Next: Light Culling: Use new DRW API
Diffstat (limited to 'source')
5 files changed, 24 insertions, 31 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc index 56788ab64fc..d93a69c859f 100644 --- a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc +++ b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.cc @@ -81,7 +81,7 @@ void HiZBuffer::update() } } -void HiZBuffer::debug_draw(GPUFrameBuffer *view_fb) +void HiZBuffer::debug_draw(View &view, GPUFrameBuffer *view_fb) { if (inst_.debug_mode == eDebugMode::DEBUG_HIZ_VALIDATION) { inst_.info = @@ -89,9 +89,8 @@ void HiZBuffer::debug_draw(GPUFrameBuffer *view_fb) " - Red: pixel in front of HiZ tile value.\n" " - Blue: No error."; inst_.hiz_buffer.update(); - GPU_framebuffer_bind(view_fb); - inst_.manager->submit(debug_draw_ps_); + inst_.manager->submit(debug_draw_ps_, view); } } diff --git a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh index cb3569e801e..8ea44236b35 100644 --- a/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh +++ b/source/blender/draw/engines/eevee_next/eevee_hizbuffer.hh @@ -67,7 +67,7 @@ class HiZBuffer { */ void update(); - void debug_draw(GPUFrameBuffer *view_fb); + void debug_draw(View &view, GPUFrameBuffer *view_fb); void bind_resources(DRWShadingGroup *grp) { diff --git a/source/blender/draw/engines/eevee_next/eevee_light.cc b/source/blender/draw/engines/eevee_next/eevee_light.cc index cf9949c6c23..a52fa93d949 100644 --- a/source/blender/draw/engines/eevee_next/eevee_light.cc +++ b/source/blender/draw/engines/eevee_next/eevee_light.cc @@ -445,22 +445,18 @@ void LightModule::culling_pass_sync() 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("light_buf", &culling_light_buf_); + debug_draw_ps_.bind("light_cull_buf", &culling_data_buf_); + debug_draw_ps_.bind("light_zbin_buf", &culling_zbin_buf_); + debug_draw_ps_.bind("light_tile_buf", &culling_tile_buf_); + debug_draw_ps_.bind("depth_tx", &inst_.render_buffers.depth_tx); + debug_draw_ps_.draw_procedural(GPU_PRIM_TRIS, 1, 3); } - - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_CUSTOM; - debug_draw_ps_ = DRW_pass_create("Debug.LightCulling", state); - GPUShader *sh = inst_.shaders.static_shader_get(LIGHT_CULLING_DEBUG); - DRWShadingGroup *grp = DRW_shgroup_create(sh, debug_draw_ps_); - inst_.hiz_buffer.bind_resources(grp); - 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(View &view, const int2 extent) @@ -477,15 +473,14 @@ void LightModule::set_view(View &view, const int2 extent) 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); } - inst_.info = "Debug Mode: Light Culling Validation"; - inst_.hiz_buffer.update(); - GPU_framebuffer_bind(view_fb); - DRW_draw_pass(debug_draw_ps_); } /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_light.hh b/source/blender/draw/engines/eevee_next/eevee_light.hh index bc13073d765..c4f88044533 100644 --- a/source/blender/draw/engines/eevee_next/eevee_light.hh +++ b/source/blender/draw/engines/eevee_next/eevee_light.hh @@ -121,8 +121,7 @@ class LightModule { uint total_word_count_ = 0; /** Debug Culling visualization. */ - DRWPass *debug_draw_ps_ = nullptr; - /* GPUTexture *input_depth_tx_ = nullptr; */ + PassSimple debug_draw_ps_ = {"LightCulling.Debug"}; public: LightModule(Instance &inst) : inst_(inst){}; @@ -137,7 +136,7 @@ class LightModule { */ void set_view(View &view, const int2 extent); - void debug_draw(GPUFrameBuffer *view_fb); + void debug_draw(View &view, GPUFrameBuffer *view_fb); void bind_resources(DRWShadingGroup *grp) { diff --git a/source/blender/draw/engines/eevee_next/eevee_view.cc b/source/blender/draw/engines/eevee_next/eevee_view.cc index 9ef47411818..48951c2bae7 100644 --- a/source/blender/draw/engines/eevee_next/eevee_view.cc +++ b/source/blender/draw/engines/eevee_next/eevee_view.cc @@ -132,8 +132,8 @@ void ShadingView::render() inst_.pipelines.forward.render(render_view_new_, prepass_fb_, combined_fb_, rbufs.combined_tx); - inst_.lights.debug_draw(combined_fb_); - inst_.hiz_buffer.debug_draw(combined_fb_); + inst_.lights.debug_draw(render_view_new_, combined_fb_); + inst_.hiz_buffer.debug_draw(render_view_new_, combined_fb_); GPUTexture *combined_final_tx = render_postfx(rbufs.combined_tx); |