MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / FinalizeTexture

Method FinalizeTexture

src/engine/TextureCache.cpp:337–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337void TextureCache::FinalizeTexture(
338 std::shared_ptr<TextureData> texture,
339 CommonRenderPasses* passes,
340 nvrhi::ICommandList* commandList)
341{
342 assert(texture->data);
343 assert(commandList);
344
345 uint originalWidth = texture->width;
346 uint originalHeight = texture->height;
347
348 bool isBlockCompressed =
349 (texture->format == nvrhi::Format::BC1_UNORM) ||
350 (texture->format == nvrhi::Format::BC1_UNORM_SRGB) ||
351 (texture->format == nvrhi::Format::BC2_UNORM) ||
352 (texture->format == nvrhi::Format::BC2_UNORM_SRGB) ||
353 (texture->format == nvrhi::Format::BC3_UNORM) ||
354 (texture->format == nvrhi::Format::BC3_UNORM_SRGB) ||
355 (texture->format == nvrhi::Format::BC4_SNORM) ||
356 (texture->format == nvrhi::Format::BC4_UNORM) ||
357 (texture->format == nvrhi::Format::BC5_SNORM) ||
358 (texture->format == nvrhi::Format::BC5_UNORM) ||
359 (texture->format == nvrhi::Format::BC6H_SFLOAT) ||
360 (texture->format == nvrhi::Format::BC6H_UFLOAT) ||
361 (texture->format == nvrhi::Format::BC7_UNORM) ||
362 (texture->format == nvrhi::Format::BC7_UNORM_SRGB);
363
364 if (isBlockCompressed)
365 {
366 originalWidth = (originalWidth + 3) & ~3;
367 originalHeight = (originalHeight + 3) & ~3;
368 }
369
370 uint scaledWidth = originalWidth;
371 uint scaledHeight = originalHeight;
372
373 if (m_MaxTextureSize > 0 && int(std::max(originalWidth, originalHeight)) > m_MaxTextureSize &&
374 texture->isRenderTarget && texture->dimension == nvrhi::TextureDimension::Texture2D)
375 {
376 if (originalWidth >= originalHeight)
377 {
378 scaledHeight = originalHeight * m_MaxTextureSize / originalWidth;
379 scaledWidth = m_MaxTextureSize;
380 }
381 else
382 {
383 scaledWidth = originalWidth * m_MaxTextureSize / originalHeight;
384 scaledHeight = m_MaxTextureSize;
385 }
386 }
387
388 const char* dataPointer = static_cast<const char*>(texture->data->data());
389
390 nvrhi::TextureDesc textureDesc;
391 textureDesc.format = texture->format;
392 textureDesc.width = scaledWidth;
393 textureDesc.height = scaledHeight;
394 textureDesc.depth = texture->depth;

Callers

nothing calls this directly

Calls 6

GetMipLevelsNumFunction · 0.85
BlitTextureMethod · 0.80
resetMethod · 0.80
maxFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected