MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / createMippedFromFiles

Method createMippedFromFiles

Source/Falcor/Core/API/Texture.cpp:263–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263ref<Texture> Texture::createMippedFromFiles(
264 ref<Device> pDevice,
265 fstd::span<const std::filesystem::path> paths,
266 bool loadAsSrgb,
267 ResourceBindFlags bindFlags,
268 Bitmap::ImportFlags importFlags
269)
270{
271 std::vector<Bitmap::UniqueConstPtr> mips;
272 mips.reserve(paths.size());
273 size_t combinedSize = 0;
274 std::filesystem::path fullPathMip0;
275
276 for (const auto& path : paths)
277 {
278 Bitmap::UniqueConstPtr pBitmap;
279 if (hasExtension(path, "dds"))
280 {
281 pBitmap = ImageIO::loadBitmapFromDDS(path);
282 }
283 else
284 {
285 pBitmap = Bitmap::createFromFile(path, kTopDown, importFlags);
286 }
287 if (!pBitmap)
288 {
289 logWarning("Error loading mip {}. Loading failed for image file '{}'.", mips.size(), path);
290 break;
291 }
292
293 if (!mips.empty())
294 {
295 if (mips.back()->getFormat() != pBitmap->getFormat())
296 {
297 logWarning("Error loading mip {} from file {}. Texture format of all mip levels must match.", mips.size(), path);
298 break;
299 }
300 if (std::max(mips.back()->getWidth() / 2, 1u) != pBitmap->getWidth() ||
301 std::max(mips.back()->getHeight() / 2, 1u) != pBitmap->getHeight())
302 {
303 logWarning(
304 "Error loading mip {} from file {}. Image resolution must decrease by half. ({}, {}) != ({}, {})/2",
305 mips.size(),
306 path,
307 pBitmap->getWidth(),
308 pBitmap->getHeight(),
309 mips.back()->getWidth(),
310 mips.back()->getHeight()
311 );
312 break;
313 }
314 }
315 else
316 {
317 fullPathMip0 = path;
318 }
319 combinedSize += pBitmap->getSize();
320 mips.emplace_back(std::move(pBitmap));

Callers

nothing calls this directly

Calls 15

hasExtensionFunction · 0.85
linearToSrgbFormatFunction · 0.85
logDebugFunction · 0.85
getFormatMethod · 0.80
backMethod · 0.80
getWidthMethod · 0.80
getHeightMethod · 0.80
createTexture2DMethod · 0.80
to_stringFunction · 0.70
logWarningFunction · 0.50
maxFunction · 0.50
reserveMethod · 0.45

Tested by

no test coverage detected