Blender V5.0
eevee_hizbuffer.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13#pragma once
14
15#include "DRW_render.hh"
16
18
19namespace blender::eevee {
20
21class Instance;
22
23/* -------------------------------------------------------------------- */
26
27class HiZBuffer {
28 private:
29 Instance &inst_;
30
34 std::array<gpu::Texture *, HIZ_MIP_COUNT> hiz_mip_ref_;
35
40 draw::StorageBuffer<uint4, true> atomic_tile_counter_ = {"atomic_tile_counter"};
42 PassSimple hiz_update_ps_ = {"HizUpdate"};
44 PassSimple hiz_update_layer_ps_ = {"HizUpdate.Layer"};
45 int layer_id_ = -1;
47 PassSimple debug_draw_ps_ = {"HizUpdate.Debug"};
49 bool is_dirty_ = true;
51 gpu::Texture *src_tx_ = nullptr;
52 gpu::Texture **src_tx_ptr_ = nullptr;
53
54 HiZData &data_;
55
56 public:
57 HiZBuffer(Instance &inst, HiZData &data) : inst_(inst), data_(data)
58 {
59 atomic_tile_counter_.clear_to_zero();
60 };
61
62 void sync();
63
69 void set_source(gpu::Texture **texture, int layer = -1)
70 {
71 src_tx_ptr_ = texture;
72 layer_id_ = layer;
73 swap_layer();
74 }
75
83 {
84 hiz_tx_.swap();
85 back.ref_tx_ = hiz_tx_.previous();
86 front.ref_tx_ = hiz_tx_.current();
87 set_dirty();
88 }
89
93 void set_dirty()
94 {
95 is_dirty_ = true;
96 }
97
103 void update();
104
105 void debug_draw(View &view, gpu::FrameBuffer *view_fb);
106
107 /* Back is Previous layer depth (ex: For refraction). Front for current layer depth. */
108 struct {
111
112 template<typename PassType> void bind_resources(PassType &pass)
113 {
114 pass.bind_texture(HIZ_TEX_SLOT, &ref_tx_);
115 }
117};
118
120
121} // namespace blender::eevee
static AppView * view
BMesh const char void * data
void debug_draw(View &view, gpu::FrameBuffer *view_fb)
HiZBuffer(Instance &inst, HiZData &data)
void set_source(gpu::Texture **texture, int layer=-1)
struct blender::eevee::HiZBuffer::@312272073133116306117315271010160007344264367302 back
struct blender::eevee::HiZBuffer::@312272073133116306117315271010160007344264367302 front
A running instance of the engine.
#define HIZ_TEX_SLOT
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
PassType
detail::Pass< command::DrawCommandBuf > PassSimple