[Bf-blender-cvs] [44e3d1b0d23] cycles-x: Cycles X: Generalize pass flags storage
Sergey Sharybin
noreply at git.blender.org
Thu Jun 10 10:51:22 CEST 2021
Commit: 44e3d1b0d230a501700efe83b68d40e2c35ffd55
Author: Sergey Sharybin
Date: Tue Jun 8 16:57:49 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB44e3d1b0d230a501700efe83b68d40e2c35ffd55
Cycles X: Generalize pass flags storage
Use bitfield instead of individual boolean flags.
No functional changes.
Differential Revision: https://developer.blender.org/D11552
===================================================================
M intern/cycles/integrator/pass_accessor.cpp
M intern/cycles/render/pass.cpp
M intern/cycles/render/pass.h
M intern/cycles/render/scene.cpp
===================================================================
diff --git a/intern/cycles/integrator/pass_accessor.cpp b/intern/cycles/integrator/pass_accessor.cpp
index 4c372a1e0bc..803792524f0 100644
--- a/intern/cycles/integrator/pass_accessor.cpp
+++ b/intern/cycles/integrator/pass_accessor.cpp
@@ -175,7 +175,7 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
}
}
else if (destination.num_components == 3) {
- if (pass_info.is_unaligned) {
+ if (pass_info.flags & PASS_FLAG_UNALIGNED) {
DCHECK_LE(pass_info.num_components, 3)
<< "Number of components mismatch for pass type " << pass_info.type;
}
diff --git a/intern/cycles/render/pass.cpp b/intern/cycles/render/pass.cpp
index 423886e1e2d..cb1e0060284 100644
--- a/intern/cycles/render/pass.cpp
+++ b/intern/cycles/render/pass.cpp
@@ -21,6 +21,20 @@
CCL_NAMESPACE_BEGIN
+/* Combine pass flags together. Used to merge newly requested flags into an existing pass. */
+static PassFlags pass_flags_combine(const PassFlags flags_a, const PassFlags flags_b)
+{
+ PassFlags result = flags_a | flags_b;
+
+ /* If pass was ever requested to be created explicitly never fall back to treating the pass as
+ * an automatically created. */
+ if ((flags_a & PASS_FLAG_AUTO) == 0 || (flags_b & PASS_FLAG_AUTO) == 0) {
+ result &= ~PASS_FLAG_AUTO;
+ }
+
+ return result;
+}
+
static bool compare_pass_order(const Pass &a, const Pass &b)
{
if (a.components == b.components)
@@ -94,7 +108,7 @@ PassInfo Pass::get_info(PassType type)
pass_info.use_filter = true;
pass_info.use_exposure = false;
pass_info.divide_type = PASS_NONE;
- pass_info.is_unaligned = false;
+ pass_info.flags = PASS_FLAG_NONE;
switch (type) {
case PASS_NONE:
@@ -186,15 +200,15 @@ PassInfo Pass::get_info(PassType type)
case PASS_DENOISING_COLOR:
pass_info.num_components = 3;
pass_info.use_exposure = true;
- pass_info.is_unaligned = true;
+ pass_info.flags |= PASS_FLAG_UNALIGNED;
break;
case PASS_DENOISING_NORMAL:
pass_info.num_components = 3;
- pass_info.is_unaligned = true;
+ pass_info.flags |= PASS_FLAG_UNALIGNED;
break;
case PASS_DENOISING_ALBEDO:
pass_info.num_components = 3;
- pass_info.is_unaligned = true;
+ pass_info.flags |= PASS_FLAG_UNALIGNED;
break;
case PASS_SHADOW_CATCHER:
@@ -240,7 +254,7 @@ PassInfo Pass::get_info(PassType type)
return pass_info;
}
-void Pass::add(PassType type, vector<Pass> &passes, const char *name, bool is_auto)
+void Pass::add(PassType type, vector<Pass> &passes, const char *name, PassFlags flags)
{
for (Pass &pass : passes) {
if (pass.type != type) {
@@ -259,21 +273,21 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name, bool is_au
/* If no name is specified, any pass of the correct type will match. */
if (name == NULL) {
- pass.is_auto &= is_auto;
+ pass.flags = pass_flags_combine(pass.flags, flags);
return;
}
/* If we already have a placeholder pass, rename that one. */
if (pass.name.empty()) {
pass.name = name;
- pass.is_auto &= is_auto;
+ pass.flags = pass_flags_combine(pass.flags, flags);
return;
}
/* If neither existing nor requested pass have placeholder name, they
* must match. */
if (name == pass.name) {
- pass.is_auto &= is_auto;
+ pass.flags = pass_flags_combine(pass.flags, flags);
return;
}
}
@@ -286,7 +300,7 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name, bool is_au
pass.filter = pass_info.use_filter;
pass.exposure = pass_info.use_exposure;
pass.divide_type = pass_info.divide_type;
- pass.is_auto = is_auto;
+ pass.flags = flags;
if (name) {
pass.name = name;
@@ -300,7 +314,7 @@ void Pass::add(PassType type, vector<Pass> &passes, const char *name, bool is_au
stable_sort(&passes[0], &passes[0] + passes.size(), compare_pass_order);
if (pass.divide_type != PASS_NONE) {
- Pass::add(pass.divide_type, passes, nullptr, is_auto);
+ Pass::add(pass.divide_type, passes, nullptr, flags);
}
}
@@ -323,7 +337,7 @@ static const int get_next_no_auto_pass_index(const vector<Pass> &passes, int ind
++index;
while (index < passes.size()) {
- if (!passes[index].is_auto) {
+ if ((passes[index].flags & PASS_FLAG_AUTO) == 0) {
return index;
}
}
@@ -384,7 +398,7 @@ void Pass::remove_auto(vector<Pass> &passes, PassType type)
return;
}
- if (!passes[i].is_auto) {
+ if ((passes[i].flags & PASS_FLAG_AUTO) == 0) {
/* Pass is not automatically created, can not remove. */
return;
}
@@ -397,7 +411,7 @@ void Pass::remove_all_auto(vector<Pass> &passes)
vector<Pass> new_passes;
for (const Pass &pass : passes) {
- if (!pass.is_auto) {
+ if ((pass.flags & PASS_FLAG_AUTO) == 0) {
new_passes.push_back(pass);
}
}
diff --git a/intern/cycles/render/pass.h b/intern/cycles/render/pass.h
index 16797805e01..4df90f91e68 100644
--- a/intern/cycles/render/pass.h
+++ b/intern/cycles/render/pass.h
@@ -25,17 +25,27 @@
CCL_NAMESPACE_BEGIN
+enum PassFlag {
+ PASS_FLAG_NONE = 0,
+
+ /* Is true when the actual storage of the pass is not aligned to any of boundary.
+ * For example, if the pass with 3 components is stored (and written by the kernel) as individual
+ * float components. */
+ PASS_FLAG_UNALIGNED = (1 << 0),
+
+ /* The has been created automatically as a requirement to various rendering functionality (such
+ * as adaptive sampling). */
+ PASS_FLAG_AUTO = (1 << 1),
+};
+using PassFlags = int;
+
struct PassInfo {
PassType type = PASS_NONE;
int num_components = -1;
bool use_filter = false;
bool use_exposure = false;
PassType divide_type = PASS_NONE;
-
- /* Is true when the actual storage of the pass is not aligned to any of boundary.
- * For example, if the pass with 3 components is stored (and written by the kernel) as individual
- * float components. */
- bool is_unaligned = false;
+ PassFlags flags;
};
class Pass : public Node {
@@ -50,10 +60,7 @@ class Pass : public Node {
bool exposure;
PassType divide_type;
ustring name;
-
- /* The has been created automatically as a requirement to various rendering functionality (such
- * as adaptive sampling). */
- bool is_auto;
+ PassFlags flags;
static const NodeEnum *get_type_enum();
@@ -62,7 +69,7 @@ class Pass : public Node {
static void add(PassType type,
vector<Pass> &passes,
const char *name = nullptr,
- bool is_auto = false);
+ PassFlags flags = PASS_FLAG_NONE);
/* Check whether two sets of passes are matching exactly. */
static bool equals_exact(const vector<Pass> &A, const vector<Pass> &B);
diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index 9323312e317..fac5d85524e 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -552,36 +552,36 @@ void Scene::update_passes()
/* Display pass for viewport. */
const PassType display_pass = film->get_display_pass();
- Pass::add(display_pass, passes, nullptr, true);
+ Pass::add(display_pass, passes, nullptr, PASS_FLAG_AUTO);
/* Create passes needed for adaptive sampling. */
const AdaptiveSampling adaptive_sampling = integrator->get_adaptive_sampling();
if (adaptive_sampling.use) {
- Pass::add(PASS_SAMPLE_COUNT, passes, nullptr, true);
- Pass::add(PASS_ADAPTIVE_AUX_BUFFER, passes, nullptr, true);
+ Pass::add(PASS_SAMPLE_COUNT, passes, nullptr, PASS_FLAG_AUTO);
+ Pass::add(PASS_ADAPTIVE_AUX_BUFFER, passes, nullptr, PASS_FLAG_AUTO);
}
/* Create passes needed for denoising. */
const bool denoise_store_passes = integrator->get_denoise_store_passes();
if (integrator->get_use_denoise() || denoise_store_passes) {
- Pass::add(PASS_DENOISING_COLOR, passes, nullptr, true);
+ Pass::add(PASS_DENOISING_COLOR, passes, nullptr, PASS_FLAG_AUTO);
/* NOTE: Enable all passes when storage is requested. This way it is possible to tweak denoiser
* parameters later on. */
if (denoise_store_passes || integrator->get_use_denoise_pass_normal()) {
- Pass::add(PASS_DENOISING_NORMAL, passes, nullptr, true);
+ Pass::add(PASS_DENOISING_NORMAL, passes, nullptr, PASS_FLAG_AUTO);
}
if (denoise_store_passes || integrator->get_use_denoise_pass_albedo()) {
- Pass::add(PASS_DENOISING_ALBEDO, passes, nullptr, true);
+ Pass::add(PASS_DENOISING_ALBEDO, passes, nullptr, PASS_FLAG_AUTO);
}
}
/* Create passes for shadow catcher. */
if (display_pass == PASS_SHADOW_CATCHER || has_shadow_catcher()) {
- Pass::add(PASS_SHADOW_CATCHER, passes, nullptr, true);
- Pass::add(PASS_SHADOW_CATCHER_MATTE, passes, nullptr, true);
+ Pass::add(PASS_SHADOW_CATCHER, passes, nullptr, PASS_FLAG_AUTO);
+ Pass::add(PASS_SHADOW_CATCHER_MATTE, passes, nullptr, PASS_FLAG_AUTO);
}
film->tag_modified();
More information about the Bf-blender-cvs
mailing list