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

Function DecompressTextureSetWithGraphicsAPI

tools/cli/GraphicsPasses.cpp:185–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185bool DecompressTextureSetWithGraphicsAPI(
186 nvrhi::IDevice* device,
187 nvrhi::ICommandList* commandList,
188 nvrhi::ITimerQuery* timerQuery,
189 GraphicsDecompressionPass& gdp,
190 GDeflateFeatures* gdeflateFeatures,
191 ntc::IContext* context,
192 ntc::ITextureSetMetadata* metadata,
193 ntc::IStream* inputFile,
194 int mipLevels,
195 bool enableDithering,
196 GraphicsResourcesForTextureSet const& graphicsResources)
197{
198 // In some cases, this function is called without a file - which means we reuse the previously uploaded data.
199 if (inputFile)
200 {
201 if (!gdp.SetLatentDataFromTextureSet(commandList, context, gdeflateFeatures, inputFile, metadata))
202 {
203 fprintf(stderr, "GraphicsDecompressionPass::SetInputData failed.\n");
204 return false;
205 }
206 }
207
208 int const numTextures = int(graphicsResources.perTexture.size());
209
210 // Write UAV descriptors for all necessary mip levels into the descriptor table
211 for (int mipLevel = 0; mipLevel < mipLevels; ++mipLevel)
212 {
213 for (int index = 0; index < numTextures; ++index)
214 {
215 const auto bindingSetItem = nvrhi::BindingSetItem::Texture_UAV(
216 mipLevel * numTextures + index,
217 graphicsResources.perTexture[index].color,
218 nvrhi::Format::UNKNOWN,
219 nvrhi::TextureSubresourceSet(mipLevel, 1, 0, 1));
220
221 gdp.WriteDescriptor(bindingSetItem);
222 }
223 }
224
225 ntc::InferenceWeightType weightType = metadata->GetBestSupportedWeightType();
226 if (weightType == ntc::InferenceWeightType::Unknown)
227 {
228 fprintf(stderr, "The texture set does not provide any weights compatible with the current device.\n");
229 return false;
230 }
231
232 commandList->open();
233
234 if (!gdp.SetWeightsFromTextureSet(commandList, metadata, weightType))
235 {
236 fprintf(stderr, "GraphicsDecompressionPass::SetWeightsFromTextureSet failed.\n");
237 commandList->close();
238 return false;
239 }
240
241 commandList->beginTimerQuery(timerQuery);
242

Callers 1

mainFunction · 0.85

Calls 5

WriteDescriptorMethod · 0.80
GetTextureMethod · 0.80
ExecuteComputePassMethod · 0.45

Tested by

no test coverage detected