Skip to content

Commit f397c61

Browse files
author
devsh
committed
test destructors running at proper times
1 parent b1a61af commit f397c61

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

13_MaterialCompilerTest/main.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,35 @@ class MaterialCompilerTest final : public application_templates::MonoDeviceAppli
5656
layer->btdf = forest->_new<CFrontendIR::CDeltaTransmission>();
5757
ASSERT_VALUE(forest->addMaterial(layerH,logger),true,"Add Material");
5858
}
59+
60+
// creating a node and changing our mind
61+
{
62+
auto image = ICPUImage::create({
63+
.type = IImage::E_TYPE::ET_2D,
64+
.samples = IImage::E_SAMPLE_COUNT_FLAGS::ESCF_1_BIT,
65+
.format = EF_R16_SFLOAT,
66+
.extent = {32,32,1},
67+
.mipLevels = 1,
68+
.arrayLayers = 1
69+
});
70+
auto view = ICPUImageView::create({.image=image,.viewType=ICPUImageView::ET_2D,.format=EF_R16_SFLOAT});
71+
72+
using spectral_var_t = CFrontendIR::CSpectralVariable;
73+
spectral_var_t::SCreationParams<1> params = {};
74+
params.knots.uvSlot() = 0;
75+
params.knots.params[0].scale = 4.5f;
76+
params.knots.params[0].view = view;
77+
78+
ASSERT_VALUE(view->getReferenceCount(),2,"initial reference count");
79+
80+
auto handle = forest->_new<spectral_var_t>(std::move(params));
81+
ASSERT_VALUE(view->getReferenceCount(),2,"transferred reference count");
82+
83+
// cleaning it up right away should run the destructor immediately and drop the image view refcount
84+
forest->_delete(handle);
85+
ASSERT_VALUE(view->getReferenceCount(),1,"after deletion reference count");
86+
}
87+
5988
// delta reflection
6089
// cook torrance GGX
6190
// cook torrance GGX with Fresnel

0 commit comments

Comments
 (0)