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

Function ExecuteTextureLoadingTasks

libraries/ntc-utils/src/BufferLoading.cpp:523–714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521}
522
523bool ExecuteTextureLoadingTasks(
524 nvrhi::IDevice* device,
525 nvrhi::ICommandList* commandList,
526 ntc::IContext* context,
527 ntc::IStream* inputFile,
528 GDeflateFeatures* gdeflateFeatures,
529 std::vector<TextureSubresourceLoadingTask>& tasks,
530 size_t compressedBufferSize,
531 size_t decompressedBufferSize)
532{
533 nvrhi::BufferHandle compressedBuffer;
534 nvrhi::BufferHandle decompressedBuffer;
535
536 if (compressedBufferSize)
537 {
538 nvrhi::BufferDesc compressedBufferDesc = nvrhi::BufferDesc()
539 .setByteSize(compressedBufferSize)
540 .setDebugName("Compressed Latents Buffer")
541 .setCanHaveRawViews(true)
542 .enableAutomaticStateTracking(nvrhi::ResourceStates::CopyDest);
543 compressedBuffer = device->createBuffer(compressedBufferDesc);
544 if (!compressedBuffer)
545 return false;
546 }
547
548 if (decompressedBufferSize)
549 {
550 nvrhi::BufferDesc decompressedBufferDesc = nvrhi::BufferDesc()
551 .setByteSize(decompressedBufferSize)
552 .setDebugName("Decompressed Latents Buffer")
553 .setCanHaveRawViews(true)
554 .enableAutomaticStateTracking(nvrhi::ResourceStates::CopyDest);
555 decompressedBuffer = device->createBuffer(decompressedBufferDesc);
556 if (!decompressedBuffer)
557 return false;
558 }
559
560 bool anyDStorageTasks = false;
561 nvrhi::ITexture* lastTexture = nullptr;
562
563 commandList->open();
564 for (TextureSubresourceLoadingTask& task : tasks)
565 {
566 if (task.pipeline == BufferLoadingPipeline::None)
567 continue; // Nothing to do
568
569 assert(inputFile);
570 bool readSuccessful = inputFile->Seek(task.footprint.buffer.rangeInStream.offset);
571
572 // Read the data into one of the CPU buffers (task.compressedData or task.uncompressedBuffer)
573 uint64_t totalBytesRead = 0;
574 if (readSuccessful && task.readCompressedIntoCpuBuffer)
575 {
576 assert(!task.compressedData.empty());
577 readSuccessful = inputFile->Read(task.compressedData.data(), task.compressedData.size());
578 totalBytesRead += task.compressedData.size();
579 }
580 if (readSuccessful && task.readUncompressedIntoCpuBuffer)

Tested by

no test coverage detected