Skip to content

Commit 8cdf0ca

Browse files
author
devsh
committed
annotate expected errors in log
1 parent f0093f8 commit 8cdf0ca

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

13_MaterialCompilerTest/main.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
7272
}
7373

7474
// TODO: use std::source_info
75-
#define ASSERT_VALUE(WHAT,VALUE,MSG) if (WHAT!=VALUE) return logFail("%s:%d test doesn't match expected value. %s",__FILE__,__LINE__,MSG)
75+
#define ASSERT_VALUE(WHAT,VALUE,MSG) if (WHAT!=VALUE) \
76+
return logFail("%s:%d test doesn't match expected value. %s",__FILE__,__LINE__,MSG); \
77+
else if (!VALUE) \
78+
if constexpr (std::is_same_v<decltype(VALUE),bool>) \
79+
m_logger->log("Disregard the error above, its expected.",system::ILogger::ELL_INFO)
80+
7681

7782
using spectral_var_t = CFrontendIR::CSpectralVariable;
7883
// simple white furnace testing materials
@@ -120,6 +125,11 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
120125
layer->brdfTop = ctH;
121126
}
122127

128+
// test layer cycle detection
129+
layer->coated = layerH;
130+
ASSERT_VALUE(forest->addMaterial(layerH,logger),false,"Layer Cycle Detection");
131+
layer->coated = {};
132+
123133
ASSERT_VALUE(forest->addMaterial(layerH,logger),true,"Add Material");
124134
}
125135

@@ -147,13 +157,22 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
147157
// to be transferred to the BTDF or absorbed by the BRDF itself.
148158
// Hence the BTDF expression must contain the BRDF coating term (how much energy is "taken" by the BRDF).
149159
const auto mulH = forest->_new<CFrontendIR::CMul>();
160+
layer->brdfTop = mulH;
161+
layer->btdf = mulH;
162+
layer->brdfBottom = mulH;
163+
150164
auto* mul = forest->deref(mulH);
151165
// regular BRDF will normalize to 100% over a hemisphere, if we allow a BTDF term we must split it half/half
152166
{
153167
spectral_var_t::SCreationParams<1> params = {};
154168
params.knots.params[0].scale = 0.5f;
155169
mul->rhs = forest->_new<spectral_var_t>(std::move(params));
156170
}
171+
172+
// test expression cycle detection
173+
mul->lhs = mulH;
174+
ASSERT_VALUE(forest->addMaterial(layerH,logger),false,"Expression Cycle Detection");
175+
157176
// create the BxDF as we'd do for a single BRDF or BTDF
158177
{
159178
const auto orenNayarH = forest->_new<CFrontendIR::COrenNayar>();
@@ -164,9 +183,6 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
164183
mul->lhs = orenNayarH;
165184
}
166185
// TODO: add a derivative map for testing the printing and compilation
167-
layer->brdfTop = mulH;
168-
layer->btdf = mulH;
169-
layer->brdfBottom = mulH;
170186
ASSERT_VALUE(forest->addMaterial(layerH,logger),true,"Add Material");
171187
}
172188
}
@@ -481,7 +497,7 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
481497
}
482498
topLayer->coated = diffuseH;
483499

484-
ASSERT_VALUE(forest->addMaterial(rootH,logger),true,"Twosided Rough Plastic");
500+
ASSERT_VALUE(forest->addMaterial(rootH,logger),false,"Twosided Rough Plastic");
485501
}
486502

487503
// coated diffuse transmitter

0 commit comments

Comments
 (0)