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

Function FillBufferLoadingTasksForBC

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

Source from the content-addressed store, hash-verified

33}
34
35void FillBufferLoadingTasksForBC(
36 ntc::TextureSetDesc const& textureSetDesc,
37 ntc::ITextureMetadata* textureMetadata,
38 std::vector<BufferLoadingTask>& tasks,
39 bool gpuDecompressionSupported,
40 nvrhi::GraphicsAPI graphicsAPI,
41 size_t& stagingBufferSize,
42 size_t& tempBufferSize,
43 size_t& finalBufferSize)
44{
45 tasks.clear();
46 tasks.resize(textureSetDesc.mips);
47
48 stagingBufferSize = 0;
49 tempBufferSize = 0;
50 finalBufferSize = 0;
51
52 bool const enableVkDecompression = gpuDecompressionSupported && graphicsAPI == nvrhi::GraphicsAPI::VULKAN;
53 bool const enableDStorage = gpuDecompressionSupported && graphicsAPI == nvrhi::GraphicsAPI::D3D12;
54
55 for (int mipLevel = 0; mipLevel < textureSetDesc.mips; ++mipLevel)
56 {
57 BufferLoadingTask& task = tasks[mipLevel];
58
59 textureMetadata->GetBC7ModeBuffer(mipLevel, &task.directCopySource, &task.directCopySize);
60 if (task.directCopySize)
61 {
62 task.pipeline = BufferLoadingPipeline::DirectCopy;
63 AppendBufferRange(task.stagingBufferRange, stagingBufferSize, task.directCopySize);
64 AppendBufferRange(task.finalBufferRange, finalBufferSize, task.directCopySize);
65 continue;
66 }
67
68 task.footprint = textureMetadata->GetBC7ModeBufferFootprint(mipLevel);
69 if (task.footprint.uncompressedSize == 0)
70 continue;
71
72 if (task.footprint.compressionType == ntc::CompressionType::None)
73 {
74 task.pipeline = BufferLoadingPipeline::ReadUncompressed;
75 AppendBufferRange(task.stagingBufferRange, stagingBufferSize, task.footprint.rangeInStream.size);
76 task.readIntoStagingBuffer = true;
77 }
78 else if (task.footprint.compressionType == ntc::CompressionType::GDeflate)
79 {
80 if (enableVkDecompression)
81 {
82 task.pipeline = BufferLoadingPipeline::DecompressWithVk;
83
84 // GDeflate header is read into a CPU buffer
85 size_t const headerSize = ntc::GetGDeflateHeaderSize(task.footprint.uncompressedSize);
86 task.compressedData.resize(headerSize);
87 task.readIntoCpuBuffer = true;
88
89 // Actual compressed data is read directly into the staging buffer
90 assert(task.footprint.rangeInStream.size > headerSize);
91 size_t const uploadSize = task.footprint.rangeInStream.size - headerSize;
92 AppendBufferRange(task.stagingBufferRange, stagingBufferSize, uploadSize);

Calls 1

AppendBufferRangeFunction · 0.85

Tested by

no test coverage detected