MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / findViewCommon

Function findViewCommon

Source/Falcor/Core/API/Texture.cpp:444–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442
443template<typename ViewClass, typename ViewMapType>
444ref<ViewClass> findViewCommon(
445 Texture* pTexture,
446 uint32_t mostDetailedMip,
447 uint32_t mipCount,
448 uint32_t firstArraySlice,
449 uint32_t arraySize,
450 ViewMapType& viewMap,
451 CreateFuncType<ViewClass> createFunc
452)
453{
454 uint32_t resMipCount = 1;
455 uint32_t resArraySize = 1;
456
457 resArraySize = pTexture->getArraySize();
458 resMipCount = pTexture->getMipCount();
459
460 if (firstArraySlice >= resArraySize)
461 {
462 logWarning("First array slice is OOB when creating resource view. Clamping");
463 firstArraySlice = resArraySize - 1;
464 }
465
466 if (mostDetailedMip >= resMipCount)
467 {
468 logWarning("Most detailed mip is OOB when creating resource view. Clamping");
469 mostDetailedMip = resMipCount - 1;
470 }
471
472 if (mipCount == Resource::kMaxPossible)
473 {
474 mipCount = resMipCount - mostDetailedMip;
475 }
476 else if (mipCount + mostDetailedMip > resMipCount)
477 {
478 logWarning("Mip count is OOB when creating resource view. Clamping");
479 mipCount = resMipCount - mostDetailedMip;
480 }
481
482 if (arraySize == Resource::kMaxPossible)
483 {
484 arraySize = resArraySize - firstArraySlice;
485 }
486 else if (arraySize + firstArraySlice > resArraySize)
487 {
488 logWarning("Array size is OOB when creating resource view. Clamping");
489 arraySize = resArraySize - firstArraySlice;
490 }
491
492 ResourceViewInfo view = ResourceViewInfo(mostDetailedMip, mipCount, firstArraySlice, arraySize);
493
494 if (viewMap.find(view) == viewMap.end())
495 {
496 viewMap[view] = createFunc(pTexture, mostDetailedMip, mipCount, firstArraySlice, arraySize);
497 }
498
499 return viewMap[view];
500}
501

Callers

nothing calls this directly

Calls 3

ResourceViewInfoClass · 0.70
logWarningFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected