Skip to content

Commit cc5d289

Browse files
committed
Fixed Example 43.SumAndCDFFilters + added extra validation for filter
+ Added axesToSum + Example 43 to use new IApplicationFramework predefined paths
1 parent e51f077 commit cc5d289

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

examples_tests/43.SumAndCDFFilters/main.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class SumAndCDFFilterSampleApp : public NonGraphicalApplicationBase
207207
state.inMipLevel = MIPMAP_IMAGE;
208208
state.outMipLevel = MIPMAP_IMAGE;
209209
#endif // IMAGE_VIEW
210+
state.axesToSum = (1 << 2) | (1 << 1) | (1 << 0); // ZYX
210211

211212
if (!sumFilter.execute(core::execution::par_unseq,&state))
212213
logger->log("Something went wrong while performing sum operation!", nbl::system::ILogger::ELL_WARNING);
@@ -215,17 +216,19 @@ class SumAndCDFFilterSampleApp : public NonGraphicalApplicationBase
215216
}
216217
return newSumImage;
217218
};
218-
219-
IAssetLoader::SAssetLoadParams lp(0ull, nullptr, IAssetLoader::ECF_DONT_CACHE_REFERENCES);
220-
219+
220+
asset::IAssetLoader::SAssetLoadParams loadParams;
221+
loadParams.logger = logger.get();
222+
221223
#ifdef IMAGE_VIEW
222-
auto bundle = assetManager->getAsset("../../media/GLI/earth-cubemap3.dds", lp);
223-
auto cpuImageViewFetched = core::smart_refctd_ptr_static_cast<asset::ICPUImageView>(bundle.getContents().begin()[0]);
224-
224+
auto imgPath = sharedInputCWD / "GLI/earth-cubemap3.dds";
225+
auto bundle = assetManager->getAsset(imgPath.string(), loadParams);
226+
auto cpuImageViewFetched = core::smart_refctd_ptr_static_cast<asset::ICPUImageView>(bundle.getContents()[0]);
225227
auto cpuImage = getSummedImage(cpuImageViewFetched->getCreationParameters().image);
226228
#else
227-
auto bundle = assetManager->getAsset("../../media/colorexr.exr", lp);
228-
auto cpuImage = getSummedImage(core::smart_refctd_ptr_static_cast<asset::ICPUImage>(bundle.getContents().begin()[0]));
229+
auto imgPath = sharedInputCWD / "colorexr.exr";
230+
auto bundle = assetManager->getAsset(imgPath.string(), loadParams);
231+
auto cpuImage = getSummedImage(core::smart_refctd_ptr_static_cast<asset::ICPUImage>(bundle.getContents()[0]));
229232
#endif // IMAGE_VIEW
230233

231234
ICPUImageView::SCreationParams viewParams;
@@ -262,16 +265,20 @@ class SumAndCDFFilterSampleApp : public NonGraphicalApplicationBase
262265
();
263266

264267
asset::IAssetWriter::SAssetWriteParams wparams(cpuImageView.get());
268+
wparams.logger = logger.get();
269+
265270
#ifdef IMAGE_VIEW
266-
assetManager->writeAsset(outputFileName = std::string(MODE.data()) + "IMG_VIEW.dds", wparams);
271+
outputFileName = std::string(MODE.data()) + "IMG_VIEW.dds";
267272
#else
268273
#ifdef OVERLAPPING_REGIONS
269-
assetManager->writeAsset(outputFileName = std::string(MODE.data()) + "IMG_OVERLAPPING_REGIONS.exr", wparams);
274+
outputFileName = std::string(MODE.data()) + "IMG_OVERLAPPING_REGIONS.exr";
270275
#else
271-
assetManager->writeAsset(outputFileName = std::string(MODE.data()) + "IMG.exr", wparams);
276+
outputFileName = std::string(MODE.data()) + "IMG.exr";
272277
#endif // OVERLAPPING_REGIONS
273278
#endif // IMAGE_VIEW
274-
279+
280+
auto outputFilePath = localOutputCWD / outputFileName;
281+
assetManager->writeAsset(outputFilePath.string(), wparams);
275282
return outputFileName;
276283
};
277284

@@ -320,8 +327,9 @@ class SumAndCDFFilterSampleApp : public NonGraphicalApplicationBase
320327
{
321328
const std::string satFileName = writeSATandGetItsOutputName();
322329
const std::string convolutedSatFileName = "CONVOLUTED_" + satFileName;
330+
const auto convolutedSatFilePath = localOutputCWD / convolutedSatFileName;
323331

324-
auto bundle = assetManager->getAsset(satFileName, lp);
332+
auto bundle = assetManager->getAsset(satFileName, loadParams);
325333
#ifdef IMAGE_VIEW
326334
auto cpuImageViewFetched = core::smart_refctd_ptr_static_cast<asset::ICPUImageView>(bundle.getContents().begin()[0]);
327335
auto cpuImage = getDisConvolutedImage(cpuImageViewFetched->getCreationParameters().image);
@@ -337,7 +345,7 @@ class SumAndCDFFilterSampleApp : public NonGraphicalApplicationBase
337345
assert(cpuImageView.get(), "The imageView didn't pass creation validation!");
338346

339347
asset::IAssetWriter::SAssetWriteParams wparams(cpuImageView.get());
340-
assetManager->writeAsset(convolutedSatFileName, wparams);
348+
assetManager->writeAsset(convolutedSatFilePath.string(), wparams);
341349
}
342350
}
343351

include/nbl/asset/filters/CSummedAreaTableImageFilter.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CSummedAreaTableImageFilterBase
3030
uint8_t* scratchMemory = nullptr; //!< memory covering all regions used for temporary filling within computation of sum values
3131
size_t scratchMemoryByteSize = {}; //!< required byte size for entire scratch memory
3232
bool normalizeImageByTotalSATValues = false; //!< after sum performation division will be performed for the entire image by the max sum values in (maxX, 0, z) depending on input image - needed for UNORM and SNORM
33-
uint8_t axesToSum = 0u; //!< which axes you want to sum; X: bit0, Y: bit1, Z: bit2
33+
uint8_t axesToSum = 0u; //!< which axes you want to sum; X: bit0, Y: bit1, Z: bit2 // TODO: make ALL_AXES the default and make sure examples using it work as expected.
3434

3535
static inline size_t getRequiredScratchByteSize(const ICPUImage* inputImage, asset::VkExtent3D extent)
3636
{
@@ -96,13 +96,16 @@ class CSummedAreaTableImageFilter : public CMatchedSizeInOutImageFilterCommon, p
9696

9797
if (state->scratchMemoryByteSize < state_type::getRequiredScratchByteSize(state->inImage, state->extent))
9898
return false;
99+
100+
if (state->axesToSum == 0u)
101+
return false;
99102

100103
if (asset::getFormatChannelCount(outFormat) != asset::getFormatChannelCount(inFormat))
101104
return false;
102105

103106
if (asset::getFormatClass(inFormat) > asset::getFormatClass(outFormat)) // TODO in future! Change to a function checking a bit-depth for an each single channel
104107
return false;
105-
108+
106109
return true;
107110
}
108111

0 commit comments

Comments
 (0)