Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-03-03 23:16:54 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-03-03 23:16:54 +0300
commit58e2ec18ae58918017170c915e7587759f322779 (patch)
tree8f646ae8a0d73d7cec6840e888d9095e3df3d576 /source/blender/draw/engines/eevee/eevee_renderpasses.hh
parentfbf4d8f8b5c60313a6ec15c7bd23e12f34b98878 (diff)
EEVEE: Deferred: Large refactor
This changes drastically the implementation to leverage arbitrary writes in order to reduce complexity, memory usage and increase speed. Since we are no longer dependent on the framebuffer requirement, we can allocate bigger size texture that fits all views and avoid the extra. Transparency, holdout and emissions are no longer deferred and are now composited using dual source blending. The indirect lighting and raytracing is still not functional but will also gets a large refactor on its own
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_renderpasses.hh')
-rw-r--r--source/blender/draw/engines/eevee/eevee_renderpasses.hh74
1 files changed, 74 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_renderpasses.hh b/source/blender/draw/engines/eevee/eevee_renderpasses.hh
index e25f7cf79d1..7da77ac90f0 100644
--- a/source/blender/draw/engines/eevee/eevee_renderpasses.hh
+++ b/source/blender/draw/engines/eevee/eevee_renderpasses.hh
@@ -29,6 +29,10 @@ enum eRenderPassBit {
RENDERPASS_DEPTH = (1 << 1),
RENDERPASS_NORMAL = (1 << 2),
RENDERPASS_VECTOR = (1 << 3),
+ RENDERPASS_EMISSION = (1 << 4),
+ RENDERPASS_DIFFUSE_COLOR = (1 << 5),
+ RENDERPASS_SPECULAR_COLOR = (1 << 6),
+ RENDERPASS_VOLUME_LIGHT = (1 << 7),
/** Used for iterator. */
RENDERPASS_MAX,
RENDERPASS_ALL = ((RENDERPASS_MAX - 1) << 1) - 1,
@@ -43,6 +47,10 @@ static inline eRenderPassBit to_render_passes_bits(int i_rpasses)
SET_FLAG_FROM_TEST(rpasses, i_rpasses & SCE_PASS_Z, RENDERPASS_DEPTH);
SET_FLAG_FROM_TEST(rpasses, i_rpasses & SCE_PASS_NORMAL, RENDERPASS_NORMAL);
SET_FLAG_FROM_TEST(rpasses, i_rpasses & SCE_PASS_VECTOR, RENDERPASS_VECTOR);
+ SET_FLAG_FROM_TEST(rpasses, i_rpasses & SCE_PASS_EMIT, RENDERPASS_EMISSION);
+ SET_FLAG_FROM_TEST(rpasses, i_rpasses & SCE_PASS_DIFFUSE_COLOR, RENDERPASS_DIFFUSE_COLOR);
+ SET_FLAG_FROM_TEST(rpasses, i_rpasses & SCE_PASS_GLOSSY_COLOR, RENDERPASS_SPECULAR_COLOR);
+ /* RENDERPASS_VOLUME_LIGHT? */
return rpasses;
}
@@ -57,6 +65,14 @@ static inline const char *to_render_passes_name(eRenderPassBit rpass)
return RE_PASSNAME_NORMAL;
case RENDERPASS_VECTOR:
return RE_PASSNAME_VECTOR;
+ case RENDERPASS_EMISSION:
+ return RE_PASSNAME_EMIT;
+ case RENDERPASS_DIFFUSE_COLOR:
+ return RE_PASSNAME_DIFFUSE_COLOR;
+ case RENDERPASS_SPECULAR_COLOR:
+ return RE_PASSNAME_GLOSSY_COLOR;
+ case RENDERPASS_VOLUME_LIGHT:
+ return RE_PASSNAME_VOLUME_LIGHT;
default:
BLI_assert(0);
return "";
@@ -67,6 +83,10 @@ static inline eFilmDataType to_render_passes_data_type(eRenderPassBit rpass,
const bool use_log_encoding)
{
switch (rpass) {
+ case RENDERPASS_EMISSION:
+ case RENDERPASS_DIFFUSE_COLOR:
+ case RENDERPASS_SPECULAR_COLOR:
+ case RENDERPASS_VOLUME_LIGHT:
case RENDERPASS_COMBINED:
return (use_log_encoding) ? FILM_DATA_COLOR_LOG : FILM_DATA_COLOR;
case RENDERPASS_DEPTH:
@@ -97,12 +117,26 @@ class RenderPasses {
Film *depth = nullptr;
Film *normal = nullptr;
Film *vector = nullptr;
+ Film *emission = nullptr;
+ Film *diffuse_color = nullptr;
+ Film *diffuse_light = nullptr;
+ Film *specular_color = nullptr;
+ Film *specular_light = nullptr;
+ Film *volume_light = nullptr;
Vector<Film *> aovs;
+ /** View texture to render to. */
+ TextureFromPool emission_tx = {"PassEmission"};
+ TextureFromPool diffuse_color_tx = {"PassDiffuseColor"};
+ TextureFromPool specular_color_tx = {"PassSpecularColor"};
+ TextureFromPool volume_light_tx = {"PassVolumeLight"};
private:
Instance &inst_;
eRenderPassBit enabled_passes_ = RENDERPASS_NONE;
+ /* Maximum texture size. Since we use imageLoad/Store instead of framebuffer, we only need to
+ * allocate the biggest texture. */
+ int2 tmp_extent_ = int2(-1);
public:
RenderPasses(Instance &inst) : inst_(inst){};
@@ -113,6 +147,9 @@ class RenderPasses {
delete depth;
delete normal;
delete vector;
+ for (Film *&film : aovs) {
+ delete film;
+ }
}
void init(const int extent[2], const rcti *output_rect);
@@ -122,6 +159,16 @@ class RenderPasses {
for (RenderPassItem rpi : *this) {
rpi.film->sync();
}
+ emission_tx.sync();
+ diffuse_color_tx.sync();
+ specular_color_tx.sync();
+ volume_light_tx.sync();
+ tmp_extent_ = int2(-1);
+ }
+
+ void view_sync(int2 view_extent)
+ {
+ tmp_extent_ = math::max(tmp_extent_, view_extent);
}
void end_sync(void)
@@ -131,6 +178,25 @@ class RenderPasses {
}
}
+ void acquire()
+ {
+ auto acquire_tmp_pass_buffer = [&](TextureFromPool &texture, bool enabled_pass) {
+ texture.acquire(enabled_pass ? tmp_extent_ : int2(1), GPU_RGBA16F, (void *)&inst_);
+ };
+ acquire_tmp_pass_buffer(emission_tx, enabled_passes_ & RENDERPASS_EMISSION);
+ acquire_tmp_pass_buffer(diffuse_color_tx, enabled_passes_ & RENDERPASS_DIFFUSE_COLOR);
+ acquire_tmp_pass_buffer(specular_color_tx, enabled_passes_ & RENDERPASS_SPECULAR_COLOR);
+ acquire_tmp_pass_buffer(volume_light_tx, enabled_passes_ & RENDERPASS_VOLUME_LIGHT);
+ }
+
+ void release()
+ {
+ emission_tx.release();
+ diffuse_color_tx.release();
+ specular_color_tx.release();
+ volume_light_tx.release();
+ }
+
void resolve_viewport(DefaultFramebufferList *dfbl)
{
for (RenderPassItem rpi : *this) {
@@ -168,6 +234,14 @@ class RenderPasses {
return normal;
case RENDERPASS_VECTOR:
return vector;
+ case RENDERPASS_EMISSION:
+ return emission;
+ case RENDERPASS_DIFFUSE_COLOR:
+ return vector;
+ case RENDERPASS_SPECULAR_COLOR:
+ return vector;
+ case RENDERPASS_VOLUME_LIGHT:
+ return vector;
default:
BLI_assert(0);
return combined;