Blender V4.3
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
13#pragma once
14
15#include "DRW_render.hh"
16
18
19namespace blender::eevee {
20
21class Instance;
22
23/* -------------------------------------------------------------------- */
27class HiZBuffer {
28 private:
29 Instance &inst_;
30
34 std::array<GPUTexture *, 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 GPUTexture *src_tx_ = nullptr;
52 GPUTexture **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(GPUTexture **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, GPUFrameBuffer *view_fb);
106
107 /* Back is Previous layer depth (ex: For refraction). Front for current layer depth. */
108 struct {
110 GPUTexture *ref_tx_ = nullptr;
111
112 template<typename PassType> void bind_resources(PassType &pass)
113 {
114 pass.bind_texture(HIZ_TEX_SLOT, &ref_tx_);
115 }
117};
118
121} // namespace blender::eevee
void debug_draw(View &view, GPUFrameBuffer *view_fb)
HiZBuffer(Instance &inst, HiZData &data)
struct blender::eevee::HiZBuffer::@195 front
struct blender::eevee::HiZBuffer::@195 back
void set_source(GPUTexture **texture, int layer=-1)
A running instance of the engine.
local_group_size(16, 16) .push_constant(Type texture
#define HIZ_TEX_SLOT
PassType