Cleanup: minor changes to DebugFlags

Use C++11, remove unused running_inside_blender and move viewport_static_bvh
to BlenderSync.
This commit is contained in:
Brecht Van Lommel 2022-08-11 16:59:29 +02:00
parent 4cbd799373
commit 5cbfdaccd0
6 changed files with 27 additions and 37 deletions

View File

@ -59,8 +59,6 @@ static void debug_flags_sync_from_scene(BL::Scene b_scene)
{
DebugFlagsRef flags = DebugFlags();
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
/* Synchronize shared flags. */
flags.viewport_static_bvh = get_enum(cscene, "debug_bvh_type");
/* Synchronize CPU flags. */
flags.cpu.avx2 = get_boolean(cscene, "debug_use_cpu_avx2");
flags.cpu.avx = get_boolean(cscene, "debug_use_cpu_avx");
@ -140,8 +138,6 @@ static PyObject *init_func(PyObject * /*self*/, PyObject *args)
BlenderSession::headless = headless;
DebugFlags().running_inside_blender = true;
Py_RETURN_NONE;
}

View File

@ -110,7 +110,8 @@ void BlenderSession::create_session()
{
const SessionParams session_params = BlenderSync::get_session_params(
b_engine, b_userpref, b_scene, background);
const SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background);
const SceneParams scene_params = BlenderSync::get_scene_params(
b_scene, background, use_developer_ui);
const bool session_pause = BlenderSync::get_session_pause(b_scene, background);
/* reset status/progress */
@ -196,7 +197,8 @@ void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsg
const SessionParams session_params = BlenderSync::get_session_params(
b_engine, b_userpref, b_scene, background);
const SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background);
const SceneParams scene_params = BlenderSync::get_scene_params(
b_scene, background, use_developer_ui);
if (scene->params.modified(scene_params) || session->params.modified(session_params) ||
!this->b_render.use_persistent_data()) {
@ -724,7 +726,8 @@ void BlenderSession::synchronize(BL::Depsgraph &b_depsgraph_)
/* on session/scene parameter changes, we recreate session entirely */
const SessionParams session_params = BlenderSync::get_session_params(
b_engine, b_userpref, b_scene, background);
const SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background);
const SceneParams scene_params = BlenderSync::get_scene_params(
b_scene, background, use_developer_ui);
const bool session_pause = BlenderSync::get_session_pause(b_scene, background);
if (session->params.modified(session_params) || scene->params.modified(scene_params)) {

View File

@ -801,7 +801,9 @@ void BlenderSync::free_data_after_sync(BL::Depsgraph &b_depsgraph)
/* Scene Parameters */
SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background)
SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene,
const bool background,
const bool use_developer_ui)
{
SceneParams params;
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
@ -812,7 +814,7 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background)
else if (shadingsystem == 1)
params.shadingsystem = SHADINGSYSTEM_OSL;
if (background || DebugFlags().viewport_static_bvh)
if (background || (use_developer_ui && get_enum(cscene, "debug_bvh_type")))
params.bvh_type = BVH_TYPE_STATIC;
else
params.bvh_type = BVH_TYPE_DYNAMIC;

View File

@ -84,7 +84,9 @@ class BlenderSync {
}
/* get parameters */
static SceneParams get_scene_params(BL::Scene &b_scene, bool background);
static SceneParams get_scene_params(BL::Scene &b_scene,
const bool background,
const bool use_developer_ui);
static SessionParams get_session_params(BL::RenderEngine &b_engine,
BL::Preferences &b_userpref,
BL::Scene &b_scene,

View File

@ -13,7 +13,6 @@
CCL_NAMESPACE_BEGIN
DebugFlags::CPU::CPU()
: avx2(true), avx(true), sse41(true), sse3(true), sse2(true), bvh_layout(BVH_LAYOUT_AUTO)
{
reset();
}
@ -41,17 +40,17 @@ void DebugFlags::CPU::reset()
bvh_layout = BVH_LAYOUT_AUTO;
}
DebugFlags::CUDA::CUDA() : adaptive_compile(false)
DebugFlags::CUDA::CUDA()
{
reset();
}
DebugFlags::HIP::HIP() : adaptive_compile(false)
DebugFlags::HIP::HIP()
{
reset();
}
DebugFlags::Metal::Metal() : adaptive_compile(false)
DebugFlags::Metal::Metal()
{
reset();
}
@ -84,14 +83,13 @@ void DebugFlags::OptiX::reset()
use_debug = false;
}
DebugFlags::DebugFlags() : viewport_static_bvh(false), running_inside_blender(false)
DebugFlags::DebugFlags()
{
/* Nothing for now. */
}
void DebugFlags::reset()
{
viewport_static_bvh = false;
cpu.reset();
cuda.reset();
optix.reset();

View File

@ -17,11 +17,6 @@ CCL_NAMESPACE_BEGIN
*/
class DebugFlags {
public:
/* Use static BVH in viewport, to match final render exactly. */
bool viewport_static_bvh;
bool running_inside_blender;
/* Descriptor of CPU feature-set to be used. */
struct CPU {
CPU();
@ -30,11 +25,11 @@ class DebugFlags {
void reset();
/* Flags describing which instructions sets are allowed for use. */
bool avx2;
bool avx;
bool sse41;
bool sse3;
bool sse2;
bool avx2 = true;
bool avx = true;
bool sse41 = true;
bool sse3 = true;
bool sse2 = true;
/* Check functions to see whether instructions up to the given one
* are allowed for use.
@ -65,7 +60,7 @@ class DebugFlags {
* By default the fastest will be used. For debugging the BVH used by other
* CPUs and GPUs can be selected here instead.
*/
BVHLayout bvh_layout;
BVHLayout bvh_layout = BVH_LAYOUT_AUTO;
};
/* Descriptor of CUDA feature-set to be used. */
@ -77,7 +72,7 @@ class DebugFlags {
/* Whether adaptive feature based runtime compile is enabled or not.
* Requires the CUDA Toolkit and only works on Linux at the moment. */
bool adaptive_compile;
bool adaptive_compile = false;
};
/* Descriptor of HIP feature-set to be used. */
@ -88,7 +83,7 @@ class DebugFlags {
void reset();
/* Whether adaptive feature based runtime compile is enabled or not. */
bool adaptive_compile;
bool adaptive_compile = false;
};
/* Descriptor of OptiX feature-set to be used. */
@ -100,7 +95,7 @@ class DebugFlags {
/* Load OptiX module with debug capabilities. Will lower logging verbosity level, enable
* validations, and lower optimization level. */
bool use_debug;
bool use_debug = false;
};
/* Descriptor of Metal feature-set to be used. */
@ -111,7 +106,7 @@ class DebugFlags {
void reset();
/* Whether adaptive feature based runtime compile is enabled or not. */
bool adaptive_compile;
bool adaptive_compile = false;
};
/* Get instance of debug flags registry. */
@ -142,15 +137,9 @@ class DebugFlags {
private:
DebugFlags();
#if (__cplusplus > 199711L)
public:
explicit DebugFlags(DebugFlags const & /*other*/) = delete;
void operator=(DebugFlags const & /*other*/) = delete;
#else
private:
explicit DebugFlags(DebugFlags const & /*other*/);
void operator=(DebugFlags const & /*other*/);
#endif
};
typedef DebugFlags &DebugFlagsRef;