EEVEE-Next: Fix render not working

The swaps during accumulation were ignored because of the way the
`SwapChain<>` implementation works.

Using external references and updating them fixes the issue.
This commit is contained in:
Clément Foucault
2022-07-22 20:32:17 +02:00
parent 35843ddcd8
commit 676a2f690c
2 changed files with 22 additions and 4 deletions

View File

@@ -393,10 +393,10 @@ 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. */
DRW_shgroup_uniform_image_ref(grp, "in_weight_img", &weight_tx_.current());
DRW_shgroup_uniform_image_ref(grp, "out_weight_img", &weight_tx_.next());
DRW_shgroup_uniform_texture_ref_ex(grp, "in_combined_tx", &combined_tx_.current(), filter);
DRW_shgroup_uniform_image_ref(grp, "out_combined_img", &combined_tx_.next());
DRW_shgroup_uniform_image_ref(grp, "in_weight_img", &weight_src_tx_);
DRW_shgroup_uniform_image_ref(grp, "out_weight_img", &weight_dst_tx_);
DRW_shgroup_uniform_texture_ref_ex(grp, "in_combined_tx", &combined_src_tx_, filter);
DRW_shgroup_uniform_image_ref(grp, "out_combined_img", &combined_dst_tx_);
DRW_shgroup_uniform_image_ref(grp, "depth_img", &depth_tx_);
DRW_shgroup_uniform_image_ref(grp, "color_accum_img", &color_accum_tx_);
DRW_shgroup_uniform_image_ref(grp, "value_accum_img", &value_accum_tx_);
@@ -541,6 +541,12 @@ void Film::accumulate(const DRWView *view)
update_sample_table();
/* Need to update the static references as there could have change from a previous swap. */
weight_src_tx_ = weight_tx_.current();
weight_dst_tx_ = weight_tx_.next();
combined_src_tx_ = combined_tx_.current();
combined_dst_tx_ = combined_tx_.next();
data_.display_only = false;
data_.push_update();
@@ -567,6 +573,12 @@ void Film::display()
GPU_framebuffer_bind(dfbl->default_fb);
GPU_framebuffer_viewport_set(dfbl->default_fb, UNPACK2(data_.offset), UNPACK2(data_.extent));
/* Need to update the static references as there could have change from a previous swap. */
weight_src_tx_ = weight_tx_.current();
weight_dst_tx_ = weight_tx_.next();
combined_src_tx_ = combined_tx_.current();
combined_dst_tx_ = combined_tx_.next();
data_.display_only = true;
data_.push_update();

View File

@@ -45,8 +45,14 @@ class Film {
Texture depth_tx_;
/** Combined "Color" buffer. Double buffered to allow re-projection. */
SwapChain<Texture, 2> combined_tx_;
/** Static reference as SwapChain does not actually move the objects when swapping. */
GPUTexture *combined_src_tx_ = nullptr;
GPUTexture *combined_dst_tx_ = nullptr;
/** Weight buffers. Double buffered to allow updating it during accumulation. */
SwapChain<Texture, 2> weight_tx_;
/** Static reference as SwapChain does not actually move the objects when swapping. */
GPUTexture *weight_src_tx_ = nullptr;
GPUTexture *weight_dst_tx_ = nullptr;
/** Extent used by the render buffers when rendering the main views. */
int2 render_extent_ = int2(-1);
/** User setting to disable reprojection. Useful for debugging or have a more precise render. */