Cleanup: EEVEE-Next: Remove use of deprecated DRWView API

This commit is contained in:
Clément Foucault
2023-11-22 18:08:46 +01:00
parent 14d4da7555
commit beee7db425
4 changed files with 37 additions and 60 deletions

View File

@@ -632,7 +632,7 @@ void Film::update_sample_table()
} }
} }
void Film::accumulate(const DRWView *view, GPUTexture *combined_final_tx) void Film::accumulate(View &view, GPUTexture *combined_final_tx)
{ {
if (inst_.is_viewport()) { if (inst_.is_viewport()) {
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
@@ -653,9 +653,7 @@ void Film::accumulate(const DRWView *view, GPUTexture *combined_final_tx)
data_.display_only = false; data_.display_only = false;
inst_.push_uniform_data(); inst_.push_uniform_data();
draw::View drw_view("MainView", view); inst_.manager->submit(accumulate_ps_, view);
inst_.manager->submit(accumulate_ps_, drw_view);
combined_tx_.swap(); combined_tx_.swap();
weight_tx_.swap(); weight_tx_.swap();

View File

@@ -90,7 +90,7 @@ class Film {
void end_sync(); void end_sync();
/** Accumulate the newly rendered sample contained in #RenderBuffers and blit to display. */ /** Accumulate the newly rendered sample contained in #RenderBuffers and blit to display. */
void accumulate(const DRWView *view, GPUTexture *combined_final_tx); void accumulate(View &view, GPUTexture *combined_final_tx);
/** Sort and normalize cryptomatte samples. */ /** Sort and normalize cryptomatte samples. */
void cryptomatte_sort(); void cryptomatte_sort();

View File

@@ -28,11 +28,7 @@ namespace blender::eevee {
/** \name ShadingView /** \name ShadingView
* \{ */ * \{ */
void ShadingView::init() void ShadingView::init() {}
{
// dof_.init();
// mb_.init();
}
void ShadingView::sync() void ShadingView::sync()
{ {
@@ -59,31 +55,21 @@ void ShadingView::sync()
const CameraData &cam = inst_.camera.data_get(); const CameraData &cam = inst_.camera.data_get();
float4x4 viewmat, winmat; float4x4 viewmat, winmat;
const float(*viewmat_p)[4] = viewmat.ptr(), (*winmat_p)[4] = winmat.ptr();
if (false /* inst_.camera.is_panoramic() */) { if (false /* inst_.camera.is_panoramic() */) {
/* TODO(@fclem) Over-scans. */ /* TODO(@fclem) Over-scans. */
/* For now a mandatory 5% over-scan for DoF. */ /* For now a mandatory 5% over-scan for DoF. */
float side = cam.clip_near * 1.05f; float side = cam.clip_near * 1.05f;
float near = cam.clip_near; float near = cam.clip_near;
float far = cam.clip_far; float far = cam.clip_far;
perspective_m4(winmat.ptr(), -side, side, -side, side, near, far); winmat = math::projection::perspective(-side, side, -side, side, near, far);
viewmat = face_matrix_ * cam.viewmat; viewmat = face_matrix_ * cam.viewmat;
} }
else { else {
viewmat_p = cam.viewmat.ptr(); viewmat = cam.viewmat;
winmat_p = cam.winmat.ptr(); winmat = cam.winmat;
} }
main_view_ = DRW_view_create(viewmat_p, winmat_p, nullptr, nullptr, nullptr); main_view_.sync(viewmat, winmat);
sub_view_ = DRW_view_create_sub(main_view_, viewmat_p, winmat_p);
render_view_ = DRW_view_create_sub(main_view_, viewmat_p, winmat_p);
// dof_.sync(winmat_p, extent_);
// rt_buffer_opaque_.sync(extent_);
// rt_buffer_refract_.sync(extent_);
// inst_.hiz_back.view_sync(extent_);
// inst_.hiz_front.view_sync(extent_);
// inst_.gbuffer.view_sync(extent_);
} }
void ShadingView::render() void ShadingView::render()
@@ -103,9 +89,8 @@ void ShadingView::render()
update_view(); update_view();
DRW_stats_group_start(name_); DRW_stats_group_start(name_);
DRW_view_set_active(render_view_);
inst_.planar_probes.set_view(render_view_new_, extent_); inst_.planar_probes.set_view(render_view_, extent_);
/* If camera has any motion, compute motion vector in the film pass. Otherwise, we avoid float /* If camera has any motion, compute motion vector in the film pass. Otherwise, we avoid float
* precision issue by setting the motion of all static geometry to 0. */ * precision issue by setting the motion of all static geometry to 0. */
@@ -121,44 +106,42 @@ void ShadingView::render()
inst_.hiz_buffer.set_source(&inst_.render_buffers.depth_tx); inst_.hiz_buffer.set_source(&inst_.render_buffers.depth_tx);
inst_.hiz_buffer.set_dirty(); inst_.hiz_buffer.set_dirty();
inst_.pipelines.background.render(render_view_new_); inst_.pipelines.background.render(render_view_);
/* TODO(fclem): Move it after the first prepass (and hiz update) once pipeline is stabilized. */ /* TODO(fclem): Move it after the first prepass (and hiz update) once pipeline is stabilized. */
inst_.lights.set_view(render_view_new_, extent_); inst_.lights.set_view(render_view_, extent_);
inst_.reflection_probes.set_view(render_view_new_); inst_.reflection_probes.set_view(render_view_);
inst_.volume.draw_prepass(render_view_new_); inst_.volume.draw_prepass(render_view_);
/* TODO: cleanup. */
View main_view_new("MainView", main_view_);
/* TODO(Miguel Pozo): Deferred and forward prepass should happen before the GBuffer pass. */ /* TODO(Miguel Pozo): Deferred and forward prepass should happen before the GBuffer pass. */
inst_.pipelines.deferred.render(main_view_new, inst_.pipelines.deferred.render(main_view_,
render_view_new_, render_view_,
prepass_fb_, prepass_fb_,
combined_fb_, combined_fb_,
extent_, extent_,
rt_buffer_opaque_, rt_buffer_opaque_,
rt_buffer_refract_); rt_buffer_refract_);
inst_.volume.draw_compute(render_view_new_); inst_.volume.draw_compute(render_view_);
// inst_.lookdev.render_overlay(view_fb_); // inst_.lookdev.render_overlay(view_fb_);
inst_.pipelines.forward.render(render_view_new_, prepass_fb_, combined_fb_); inst_.pipelines.forward.render(render_view_, prepass_fb_, combined_fb_);
render_transparent_pass(rbufs); render_transparent_pass(rbufs);
inst_.lights.debug_draw(render_view_new_, combined_fb_); inst_.lights.debug_draw(render_view_, combined_fb_);
inst_.hiz_buffer.debug_draw(render_view_new_, combined_fb_); inst_.hiz_buffer.debug_draw(render_view_, combined_fb_);
inst_.shadows.debug_draw(render_view_new_, combined_fb_); inst_.shadows.debug_draw(render_view_, combined_fb_);
inst_.irradiance_cache.viewport_draw(render_view_new_, combined_fb_); inst_.irradiance_cache.viewport_draw(render_view_, combined_fb_);
inst_.reflection_probes.viewport_draw(render_view_new_, combined_fb_); inst_.reflection_probes.viewport_draw(render_view_, combined_fb_);
inst_.planar_probes.viewport_draw(render_view_new_, combined_fb_); inst_.planar_probes.viewport_draw(render_view_, combined_fb_);
inst_.ambient_occlusion.render_pass(render_view_new_); inst_.ambient_occlusion.render_pass(render_view_);
GPUTexture *combined_final_tx = render_postfx(rbufs.combined_tx); GPUTexture *combined_final_tx = render_postfx(rbufs.combined_tx);
inst_.film.accumulate(sub_view_, combined_final_tx); inst_.film.accumulate(jitter_view_, combined_final_tx);
rbufs.release(); rbufs.release();
postfx_tx_.release(); postfx_tx_.release();
@@ -176,7 +159,7 @@ void ShadingView::render_transparent_pass(RenderBuffers &rbufs)
float4 clear_color = {0.0f, 0.0f, 0.0f, 1.0f}; float4 clear_color = {0.0f, 0.0f, 0.0f, 1.0f};
GPU_framebuffer_bind(transparent_fb_); GPU_framebuffer_bind(transparent_fb_);
GPU_framebuffer_clear_color(transparent_fb_, clear_color); GPU_framebuffer_clear_color(transparent_fb_, clear_color);
inst_.pipelines.forward.render(render_view_new_, prepass_fb_, transparent_fb_); inst_.pipelines.forward.render(render_view_, prepass_fb_, transparent_fb_);
} }
} }
@@ -190,17 +173,16 @@ GPUTexture *ShadingView::render_postfx(GPUTexture *input_tx)
GPUTexture *output_tx = postfx_tx_; GPUTexture *output_tx = postfx_tx_;
/* Swapping is done internally. Actual output is set to the next input. */ /* Swapping is done internally. Actual output is set to the next input. */
inst_.depth_of_field.render(render_view_new_, &input_tx, &output_tx, dof_buffer_); inst_.depth_of_field.render(render_view_, &input_tx, &output_tx, dof_buffer_);
inst_.motion_blur.render(render_view_new_, &input_tx, &output_tx); inst_.motion_blur.render(render_view_, &input_tx, &output_tx);
return input_tx; return input_tx;
} }
void ShadingView::update_view() void ShadingView::update_view()
{ {
float4x4 viewmat, winmat; float4x4 viewmat = main_view_.viewmat();
DRW_view_viewmat_get(main_view_, viewmat.ptr(), false); float4x4 winmat = main_view_.winmat();
DRW_view_winmat_get(main_view_, winmat.ptr(), false);
/* TODO(fclem): Mixed-resolution rendering: We need to make sure we render with exactly the same /* TODO(fclem): Mixed-resolution rendering: We need to make sure we render with exactly the same
* distances between pixels to line up render samples and target pixels. * distances between pixels to line up render samples and target pixels.
@@ -213,14 +195,12 @@ void ShadingView::update_view()
jitter *= 2.0f; jitter *= 2.0f;
window_translate_m4(winmat.ptr(), winmat.ptr(), UNPACK2(jitter)); window_translate_m4(winmat.ptr(), winmat.ptr(), UNPACK2(jitter));
DRW_view_update_sub(sub_view_, viewmat.ptr(), winmat.ptr()); jitter_view_.sync(winmat, winmat);
/* FIXME(fclem): The offset may be noticeably large and the culling might make object pop /* FIXME(fclem): The offset may be noticeably large and the culling might make object pop
* out of the blurring radius. To fix this, use custom enlarged culling matrix. */ * out of the blurring radius. To fix this, use custom enlarged culling matrix. */
inst_.depth_of_field.jitter_apply(winmat, viewmat); inst_.depth_of_field.jitter_apply(winmat, viewmat);
DRW_view_update_sub(render_view_, viewmat.ptr(), winmat.ptr()); render_view_.sync(viewmat, winmat);
render_view_new_.sync(viewmat, winmat);
} }
/** \} */ /** \} */

View File

@@ -52,13 +52,12 @@ class ShadingView {
TextureFromPool postfx_tx_; TextureFromPool postfx_tx_;
/** Main views is created from the camera (or is from the viewport). It is not jittered. */ /** Main views is created from the camera (or is from the viewport). It is not jittered. */
DRWView *main_view_ = nullptr; View main_view_ = {"main_view"};
/** Sub views is jittered versions or the main views. This allows jitter updates without trashing /** Sub views is jittered versions or the main views. This allows jitter updates without trashing
* the visibility culling cache. */ * the visibility culling cache. */
DRWView *sub_view_ = nullptr; View jitter_view_ = {"jitter_view"};
/** Same as sub_view_ but has Depth Of Field jitter applied. */ /** Same as jitter_view_ but has Depth Of Field jitter applied. */
DRWView *render_view_ = nullptr; View render_view_;
View render_view_new_;
/** Render size of the view. Can change between scene sample eval. */ /** Render size of the view. Can change between scene sample eval. */
int2 extent_ = {-1, -1}; int2 extent_ = {-1, -1};
@@ -67,7 +66,7 @@ class ShadingView {
public: public:
ShadingView(Instance &inst, const char *name, const float4x4 &face_matrix) ShadingView(Instance &inst, const char *name, const float4x4 &face_matrix)
: inst_(inst), name_(name), face_matrix_(face_matrix), render_view_new_(name){}; : inst_(inst), name_(name), face_matrix_(face_matrix), render_view_(name){};
~ShadingView(){}; ~ShadingView(){};