MCPcopy Create free account
hub / github.com/NVIDIA-RTX/RTXNTC / SaveGraphicsStagingTextures

Function SaveGraphicsStagingTextures

tools/cli/GraphicsPasses.cpp:353–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351
352 return true;
353}
354
355bool SaveGraphicsStagingTextures(
356 ntc::ITextureSetMetadata* metadata,
357 nvrhi::IDevice* device,
358 char const* savePath,
359 ImageContainer const userProvidedContainer,
360 bool saveMips,
361 GraphicsResourcesForTextureSet const& graphicsResources)
362{
363 fs::path const outputPath = fs::path(savePath);
364 bool mipsDirCreated = false;
365
366 std::mutex mutex;
367 bool anyErrors = false;
368
369 for (int index = 0; index < int(graphicsResources.perTexture.size()); ++index)
370 {
371 ntc::ITextureMetadata* textureMetadata = metadata->GetTexture(index);
372 ntc::BlockCompressedFormat bcFormat = textureMetadata->GetBlockCompressedFormat();
373
374 if (bcFormat != ntc::BlockCompressedFormat::None)
375 continue;
376
377 if (!mipsDirCreated && saveMips && metadata->GetDesc().mips > 1)
378 {
379 fs::path mipsPath = outputPath / "mips";
380 if (!fs::is_directory(mipsPath) && !fs::create_directories(mipsPath))
381 {
382 fprintf(stderr, "Failed to create directory '%s'.\n", mipsPath.generic_string().c_str());
383 return false;
384 }
385 mipsDirCreated = true;
386 }
387
388 GraphicsResourcesForTexture const& textureResources = graphicsResources.perTexture[index];
389 nvrhi::TextureDesc const& textureDesc = textureResources.stagingColor->getDesc();
390
391 ImageContainer container = userProvidedContainer;
392
393 // The textures have been created long before, we can only read them as they are at this point...
394 // Float32 data means we'll save as EXR.
395 // TODO: implement full conversion support.
396 if (textureDesc.format == nvrhi::Format::RGBA32_FLOAT)
397 {
398 if (container != ImageContainer::EXR && container != ImageContainer::Auto)
399 {
400 printf("Warning: Cannot save texture '%s' as %s in this mode, using EXR instead.\n",
401 textureResources.name.c_str(), GetContainerExtension(container));
402 }
403
404 container = ImageContainer::EXR;
405 }
406 else if (container == ImageContainer::EXR)
407 {
408 printf("Warning: Cannot save texture '%s' as EXR in this mode, using BMP instead.\n",
409 textureResources.name.c_str());
410

Callers 1

mainFunction · 0.85

Calls 5

GetContainerExtensionFunction · 0.85
StartAsyncTaskFunction · 0.85
SaveImageToContainerFunction · 0.85
WaitForAllTasksFunction · 0.85
GetTextureMethod · 0.80

Tested by

no test coverage detected