Blender  V3.3
eevee_renderbuffers.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation.
3  */
4 
15 #include "BLI_rect.h"
16 
17 #include "GPU_framebuffer.h"
18 #include "GPU_texture.h"
19 
20 #include "DRW_render.h"
21 
22 #include "eevee_film.hh"
23 #include "eevee_instance.hh"
24 
25 namespace blender::eevee {
26 
28 {
29  depth_tx.sync();
30  combined_tx.sync();
31 
32  normal_tx.sync();
33  vector_tx.sync();
34  diffuse_light_tx.sync();
35  diffuse_color_tx.sync();
36  specular_light_tx.sync();
37  specular_color_tx.sync();
38  volume_light_tx.sync();
39  emission_tx.sync();
40  environment_tx.sync();
41  shadow_tx.sync();
42  ambient_occlusion_tx.sync();
43 }
44 
45 void RenderBuffers::acquire(int2 extent, void *owner)
46 {
47  auto pass_extent = [&](eViewLayerEEVEEPassType pass_bit) -> int2 {
48  /* Use dummy texture for disabled passes. Allows correct bindings. */
49  return (inst_.film.enabled_passes_get() & pass_bit) ? extent : int2(1);
50  };
51 
52  eGPUTextureFormat color_format = GPU_RGBA16F;
53  eGPUTextureFormat float_format = GPU_R16F;
54 
55  /* Depth and combined are always needed. */
56  depth_tx.acquire(extent, GPU_DEPTH24_STENCIL8, owner);
57  combined_tx.acquire(extent, color_format, owner);
58 
59  bool do_vector_render_pass = inst_.film.enabled_passes_get() & EEVEE_RENDER_PASS_VECTOR;
60  /* Only RG16F when only doing only reprojection or motion blur. */
61  eGPUTextureFormat vector_format = do_vector_render_pass ? GPU_RGBA16F : GPU_RG16F;
62  /* TODO(fclem): Make vector pass allocation optional if no TAA or motion blur is needed. */
63  vector_tx.acquire(extent, vector_format, owner);
64 
65  normal_tx.acquire(pass_extent(EEVEE_RENDER_PASS_NORMAL), color_format, owner);
66  diffuse_light_tx.acquire(pass_extent(EEVEE_RENDER_PASS_DIFFUSE_LIGHT), color_format, owner);
67  diffuse_color_tx.acquire(pass_extent(EEVEE_RENDER_PASS_DIFFUSE_COLOR), color_format, owner);
68  specular_light_tx.acquire(pass_extent(EEVEE_RENDER_PASS_SPECULAR_LIGHT), color_format, owner);
69  specular_color_tx.acquire(pass_extent(EEVEE_RENDER_PASS_SPECULAR_COLOR), color_format, owner);
70  volume_light_tx.acquire(pass_extent(EEVEE_RENDER_PASS_VOLUME_LIGHT), color_format, owner);
71  emission_tx.acquire(pass_extent(EEVEE_RENDER_PASS_EMIT), color_format, owner);
72  environment_tx.acquire(pass_extent(EEVEE_RENDER_PASS_ENVIRONMENT), color_format, owner);
73  shadow_tx.acquire(pass_extent(EEVEE_RENDER_PASS_SHADOW), float_format, owner);
74  ambient_occlusion_tx.acquire(pass_extent(EEVEE_RENDER_PASS_AO), float_format, owner);
75 
76  const AOVsInfoData &aovs = inst_.film.aovs_info;
77  aov_color_tx.ensure_2d_array(
78  color_format, (aovs.color_len > 0) ? extent : int2(1), max_ii(1, aovs.color_len));
79  aov_value_tx.ensure_2d_array(
80  float_format, (aovs.value_len > 0) ? extent : int2(1), max_ii(1, aovs.value_len));
81 }
82 
84 {
85  depth_tx.release();
86  combined_tx.release();
87 
88  normal_tx.release();
89  vector_tx.release();
90  diffuse_light_tx.release();
91  diffuse_color_tx.release();
92  specular_light_tx.release();
93  specular_color_tx.release();
94  volume_light_tx.release();
95  emission_tx.release();
96  environment_tx.release();
97  shadow_tx.release();
98  ambient_occlusion_tx.release();
99 }
100 
101 } // namespace blender::eevee
MINLINE int max_ii(int a, int b)
eViewLayerEEVEEPassType
@ EEVEE_RENDER_PASS_AO
@ EEVEE_RENDER_PASS_NORMAL
@ EEVEE_RENDER_PASS_DIFFUSE_LIGHT
@ EEVEE_RENDER_PASS_VOLUME_LIGHT
@ EEVEE_RENDER_PASS_DIFFUSE_COLOR
@ 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_SHADOW
eGPUTextureFormat
Definition: GPU_texture.h:83
@ GPU_RG16F
Definition: GPU_texture.h:103
@ GPU_DEPTH24_STENCIL8
Definition: GPU_texture.h:120
@ GPU_R16F
Definition: GPU_texture.h:113
AOVsInfoDataBuf aovs_info
Definition: eevee_film.hh:36
eViewLayerEEVEEPassType enabled_passes_get() const
Definition: eevee_film.cc:459
void acquire(int2 extent, void *owner)
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
aov_color_img AOVsInfoData
vec_base< int32_t, 2 > int2