diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-08-25 14:51:39 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-08-25 14:51:39 +0300 |
commit | 9886150a6d886b434f0058a2a15b67f700983842 (patch) | |
tree | 7add7afa83a6bcc8ca854c1133f565c359428383 | |
parent | 3a6696c0e746e1a788605c9b490d77a72e9f4ac5 (diff) |
Fix eevee test case
-rw-r--r-- | source/blender/draw/engines/eevee_next/eevee_film.cc | 22 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_command.cc | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.cc | 19 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.hh | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_view.hh | 11 | ||||
-rw-r--r-- | source/blender/draw/intern/shaders/draw_command_generate_comp.glsl | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.cc | 1 |
7 files changed, 43 insertions, 16 deletions
diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index 6c507972c53..ea0afdb16d3 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -401,13 +401,13 @@ void Film::sync() /* NOTE(@fclem): 16 is the max number of sampled texture in many implementations. * If we need more, we need to pack more of the similar passes in the same textures as arrays or * use image binding instead. */ - accumulate_ps_.bind("in_weight_img", &weight_tx_.current()); - accumulate_ps_.bind("out_weight_img", &weight_tx_.next()); + accumulate_ps_.bind("in_weight_img", draw::as_image(&weight_tx_.current())); + accumulate_ps_.bind("out_weight_img", draw::as_image(&weight_tx_.next())); accumulate_ps_.bind("in_combined_tx", &combined_tx_.current(), filter); - accumulate_ps_.bind("out_combined_img", &combined_tx_.next()); - accumulate_ps_.bind("depth_img", &depth_tx_); - accumulate_ps_.bind("color_accum_img", &color_accum_tx_); - accumulate_ps_.bind("value_accum_img", &value_accum_tx_); + accumulate_ps_.bind("out_combined_img", draw::as_image(&combined_tx_.next())); + accumulate_ps_.bind("depth_img", draw::as_image(&depth_tx_)); + accumulate_ps_.bind("color_accum_img", draw::as_image(&color_accum_tx_)); + accumulate_ps_.bind("value_accum_img", draw::as_image(&value_accum_tx_)); /* Sync with rendering passes. */ accumulate_ps_.barrier(GPU_BARRIER_TEXTURE_FETCH | GPU_BARRIER_SHADER_IMAGE_ACCESS); if (use_compute) { @@ -561,8 +561,9 @@ void Film::accumulate(const DRWView *view, GPUTexture *combined_final_tx) data_.display_only = false; data_.push_update(); - DRW_view_set_active(view); - DRW_manager_get()->submit(accumulate_ps_); + draw::View drw_view("MainView", view); + + DRW_manager_get()->submit(accumulate_ps_, drw_view); combined_tx_.swap(); weight_tx_.swap(); @@ -589,8 +590,9 @@ void Film::display() data_.display_only = true; data_.push_update(); - DRW_view_set_active(nullptr); - DRW_manager_get()->submit(accumulate_ps_); + draw::View drw_view("MainView", DRW_view_default_get()); + + DRW_manager_get()->submit(accumulate_ps_, drw_view); inst_.render_buffers.release(); diff --git a/source/blender/draw/intern/draw_command.cc b/source/blender/draw/intern/draw_command.cc index 41eb20e4057..8923e0d7d05 100644 --- a/source/blender/draw/intern/draw_command.cc +++ b/source/blender/draw/intern/draw_command.cc @@ -225,7 +225,7 @@ std::string ResourceBind::serialize() const case Type::Sampler: return std::string(".bind_texture") + (is_reference ? "_ref" : "") + "(" + std::to_string(slot) + - (sampler != GPU_SAMPLER_MAX ? std::string(", sampler=" + sampler) : "") + ")"; + (sampler != GPU_SAMPLER_MAX ? ", sampler=" + std::to_string(sampler) : "") + ")"; case Type::Image: return std::string(".bind_image") + (is_reference ? "_ref" : "") + "(" + std::to_string(slot) + ")"; diff --git a/source/blender/draw/intern/draw_manager.cc b/source/blender/draw/intern/draw_manager.cc index d0d863af8ea..20b3544cab7 100644 --- a/source/blender/draw/intern/draw_manager.cc +++ b/source/blender/draw/intern/draw_manager.cc @@ -5,6 +5,7 @@ * \ingroup draw */ +#include "BKE_global.h" #include "GPU_compute.h" #include "draw_manager.h" @@ -49,9 +50,18 @@ void Manager::end_sync() GPU_memory_barrier(GPU_BARRIER_SHADER_STORAGE); } -void Manager::submit(PassSimple &pass) +void Manager::submit(PassSimple &pass, View &view) { + view.bind(); + command::RecordingState state; + + pass.draw_commands_buf_.bind(state, pass.headers_, pass.commands_, view.visibility_buf_); + + GPU_storagebuf_bind(matrix_buf, DRW_OBJ_MAT_SLOT); + GPU_storagebuf_bind(infos_buf, DRW_OBJ_INFOS_SLOT); + // GPU_storagebuf_bind(attribute_buf, DRW_OBJ_ATTR_SLOT); /* TODO */ + pass.submit(state); } @@ -70,6 +80,13 @@ void Manager::submit(PassMain &pass, View &view) // GPU_storagebuf_bind(attribute_buf, DRW_OBJ_ATTR_SLOT); /* TODO */ pass.submit(state); + + if (G.debug & G_DEBUG_GPU) { + GPU_storagebuf_unbind_all(); + GPU_texture_image_unbind_all(); + GPU_texture_unbind_all(); + GPU_uniformbuf_unbind_all(); + } } } // namespace blender::draw diff --git a/source/blender/draw/intern/draw_manager.hh b/source/blender/draw/intern/draw_manager.hh index 1f67e620614..49e244c069a 100644 --- a/source/blender/draw/intern/draw_manager.hh +++ b/source/blender/draw/intern/draw_manager.hh @@ -61,7 +61,7 @@ class Manager { * Submit a pass for drawing. All resource reference will be dereferenced and commands will be * sent to GPU. */ - void submit(PassSimple &pass); + void submit(PassSimple &pass, View &view); void submit(PassMain &pass, View &view); private: diff --git a/source/blender/draw/intern/draw_view.hh b/source/blender/draw/intern/draw_view.hh index bbfce2f203f..594fbe79ca4 100644 --- a/source/blender/draw/intern/draw_view.hh +++ b/source/blender/draw/intern/draw_view.hh @@ -8,6 +8,7 @@ */ #include "DRW_gpu_wrapper.hh" +#include "DRW_render.h" #include "draw_shader_shared.h" @@ -26,7 +27,7 @@ class View { private: UniformBuffer<ViewInfos> data_; /** Result of the visibility computation. 1 bit per resource ID. */ - VisibilityBuf visibility_buf_ = {"VisibilityBuf"}; + VisibilityBuf visibility_buf_; const char *debug_name_; @@ -35,6 +36,14 @@ class View { public: View(const char *name) : visibility_buf_(name), debug_name_(name){}; + /* For compatibility with old system. Will be removed at some point. */ + View(const char *name, const DRWView *view) : visibility_buf_(name), debug_name_(name) + { + float4x4 view_mat, win_mat; + DRW_view_viewmat_get(view, view_mat.ptr(), false); + DRW_view_winmat_get(view, win_mat.ptr(), false); + this->sync(view_mat, win_mat); + } void set_clip_planes(Span<float4> planes); diff --git a/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl b/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl index 2c736996d60..031a35e4864 100644 --- a/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl +++ b/source/blender/draw/intern/shaders/draw_command_generate_comp.glsl @@ -51,7 +51,7 @@ void main() DrawGroup group = group_buf[group_id]; - if (!is_visible || proto.instance_len == 0) { + if (!is_visible) { /* Skip the draw but still count towards the completion. */ if (atomicAddAndGet(group_buf[group_id].total_counter, proto.instance_len) == group.len) { write_draw_call(group, group_id); diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc index 10482398a50..138e617fc0e 100644 --- a/source/blender/gpu/intern/gpu_batch.cc +++ b/source/blender/gpu/intern/gpu_batch.cc @@ -222,7 +222,6 @@ void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader) void GPU_batch_draw_parameter_get(GPUBatch *gpu_batch, int *r_v_count, int *r_i_count) { - BLI_assert(Context::get()->shader != nullptr); Batch *batch = static_cast<Batch *>(gpu_batch); if (batch->elem) { |