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

Callers 1

mainFunction · 0.85

Calls 5

WriteDescriptorMethod · 0.80
GetTextureMethod · 0.80
ExecuteComputePassMethod · 0.45

Tested by

no test coverage detected