Blender V4.3
eevee_renderbuffers.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
15#include "BLI_rect.h"
16
17#include "GPU_framebuffer.hh"
18#include "GPU_texture.hh"
19
20#include "DRW_render.hh"
21
22#include "eevee_film.hh"
23#include "eevee_instance.hh"
24
25namespace blender::eevee {
26
28{
30
31 data.color_len = 0;
32 data.value_len = 0;
33
34 auto pass_index_get = [&](eViewLayerEEVEEPassType pass_type, int dependent_passes = 0) {
35 if (enabled_passes & (pass_type | dependent_passes)) {
36 return pass_storage_type(pass_type) == PASS_STORAGE_COLOR ? data.color_len++ :
37 data.value_len++;
38 }
39 return -1;
40 };
41
42 data.normal_id = pass_index_get(EEVEE_RENDER_PASS_NORMAL, EEVEE_RENDER_PASS_AO);
43 data.position_id = pass_index_get(EEVEE_RENDER_PASS_POSITION);
44 data.diffuse_light_id = pass_index_get(EEVEE_RENDER_PASS_DIFFUSE_LIGHT);
45 data.diffuse_color_id = pass_index_get(EEVEE_RENDER_PASS_DIFFUSE_COLOR);
46 data.specular_light_id = pass_index_get(EEVEE_RENDER_PASS_SPECULAR_LIGHT);
47 data.specular_color_id = pass_index_get(EEVEE_RENDER_PASS_SPECULAR_COLOR);
48 data.volume_light_id = pass_index_get(EEVEE_RENDER_PASS_VOLUME_LIGHT);
49 data.emission_id = pass_index_get(EEVEE_RENDER_PASS_EMIT);
50 data.environment_id = pass_index_get(EEVEE_RENDER_PASS_ENVIRONMENT);
51 data.shadow_id = pass_index_get(EEVEE_RENDER_PASS_SHADOW);
52 data.ambient_occlusion_id = pass_index_get(EEVEE_RENDER_PASS_AO);
53 data.transparent_id = pass_index_get(EEVEE_RENDER_PASS_TRANSPARENT);
54
55 data.aovs = inst_.film.aovs_info;
56}
57
59{
61
62 extent_ = extent;
63
64 auto pass_extent = [&](eViewLayerEEVEEPassType pass_bit) -> int2 {
65 /* Use dummy texture for disabled passes. Allows correct bindings. */
66 return (enabled_passes & pass_bit) ? extent : int2(1);
67 };
68
70
71 /* Depth and combined are always needed. */
73 /* TODO(fclem): depth_tx should ideally be a texture from pool but we need stencil_view
74 * which is currently unsupported by pool textures. */
75 // depth_tx.acquire(extent, GPU_DEPTH24_STENCIL8);
77
78 eGPUTextureUsage usage_attachment_read_write = GPU_TEXTURE_USAGE_ATTACHMENT |
81
82 /* TODO(fclem): Make vector pass allocation optional if no TAA or motion blur is needed. */
83 vector_tx.acquire(extent, vector_tx_format(), usage_attachment_read_write);
84
85 int color_len = data.color_len + data.aovs.color_len;
86 int value_len = data.value_len + data.aovs.value_len;
87
89 (color_len > 0) ? extent : int2(1),
90 math::max(1, color_len),
91 usage_attachment_read_write);
93 (value_len > 0) ? extent : int2(1),
94 math::max(1, value_len),
95 usage_attachment_read_write);
96
97 eGPUTextureFormat cryptomatte_format = GPU_R32F;
98 const int cryptomatte_layer_len = inst_.film.cryptomatte_layer_max_get();
99 if (cryptomatte_layer_len == 2) {
100 cryptomatte_format = GPU_RG32F;
101 }
102 else if (cryptomatte_layer_len == 3) {
103 cryptomatte_format = GPU_RGBA32F;
104 }
109 cryptomatte_format,
111}
112
114{
115 /* TODO(fclem): depth_tx should ideally be a texture from pool but we need stencil_view
116 * which is currently unsupported by pool textures. */
117 // depth_tx.release();
119
122}
123
125{
127 bool do_vector_render_pass = (enabled_passes & EEVEE_RENDER_PASS_VECTOR) ||
128 (inst_.motion_blur.postfx_enabled() && !inst_.is_viewport());
129
130 /* Only RG16F when only doing only reprojection or motion blur. */
131 return do_vector_render_pass ? GPU_RGBA16F : GPU_RG16F;
132}
133
134} // namespace blender::eevee
eViewLayerEEVEEPassType
@ EEVEE_RENDER_PASS_CRYPTOMATTE_MATERIAL
@ EEVEE_RENDER_PASS_AO
@ EEVEE_RENDER_PASS_NORMAL
@ EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT
@ EEVEE_RENDER_PASS_DIFFUSE_LIGHT
@ EEVEE_RENDER_PASS_VOLUME_LIGHT
@ EEVEE_RENDER_PASS_DIFFUSE_COLOR
@ EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET
@ EEVEE_RENDER_PASS_ENVIRONMENT
@ EEVEE_RENDER_PASS_SPECULAR_LIGHT
@ EEVEE_RENDER_PASS_VECTOR
@ EEVEE_RENDER_PASS_SPECULAR_COLOR
@ EEVEE_RENDER_PASS_EMIT
@ EEVEE_RENDER_PASS_TRANSPARENT
@ EEVEE_RENDER_PASS_SHADOW
@ EEVEE_RENDER_PASS_POSITION
eGPUTextureUsage
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_ATTACHMENT
eGPUTextureFormat
@ GPU_DEPTH24_STENCIL8
@ GPU_RG32F
void acquire(int2 extent, eGPUTextureFormat format, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL)
bool ensure_2d_array(eGPUTextureFormat format, int2 extent, int layers, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
bool ensure_2d(eGPUTextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
int cryptomatte_layer_max_get() const
AOVsInfoDataBuf aovs_info
Definition eevee_film.hh:53
eViewLayerEEVEEPassType enabled_passes_get() const
MotionBlurModule motion_blur
static ePassStorageType pass_storage_type(eViewLayerEEVEEPassType pass_type)
static constexpr eGPUTextureFormat color_format
static constexpr eGPUTextureFormat float_format
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
static eViewLayerEEVEEPassType enabled_passes(const ViewLayer *view_layer)
T max(const T &a, const T &b)
VecBase< int32_t, 2 > int2