MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / SwapIndices

Function SwapIndices

cmp_core/shaders/bc6_encode_kernel.cpp:2726–2762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2724#endif
2725
2726void SwapIndices(CGU_INT32 iEndPoints[MAX_SUBSETS][MAX_END_POINTS][MAX_DIMENSION_BIG],
2727 CGU_INT32 iIndices[3][MAX_SUBSET_SIZE],
2728 CGU_INT entryCount[MAX_SUBSETS],
2729 CGU_INT max_subsets,
2730 CGU_INT mode,
2731 CGU_INT shape_pattern)
2732{
2733 CGU_UINT32 uNumIndices = 1 << ModePartition[mode].IndexPrec;
2734 CGU_UINT32 uHighIndexBit = uNumIndices >> 1;
2735
2736 for (CGU_INT subset = 0; subset < max_subsets; ++subset)
2737 {
2738 // region 0 (subset = 0) The fix-up index for this subset is allways index 0
2739 // region 1 (subset = 1) The fix-up index for this subset varies based on the shape
2740 size_t i = subset ? g_Region2FixUp[shape_pattern] : 0;
2741
2742 if (iIndices[subset][i] & uHighIndexBit)
2743 {
2744#ifdef ASPM_GPU
2745 // high bit is set, swap the aEndPts and indices for this region
2746 swap(iEndPoints[subset][0][0], iEndPoints[subset][1][0]);
2747 swap(iEndPoints[subset][0][1], iEndPoints[subset][1][1]);
2748 swap(iEndPoints[subset][0][2], iEndPoints[subset][1][2]);
2749#else
2750 // high bit is set, swap the aEndPts and indices for this region
2751 std::swap(iEndPoints[subset][0][0], iEndPoints[subset][1][0]);
2752 std::swap(iEndPoints[subset][0][1], iEndPoints[subset][1][1]);
2753 std::swap(iEndPoints[subset][0][2], iEndPoints[subset][1][2]);
2754#endif
2755
2756 for (size_t j = 0; j < (size_t)entryCount[subset]; ++j)
2757 {
2758 iIndices[subset][j] = uNumIndices - 1 - iIndices[subset][j];
2759 }
2760 }
2761 }
2762}
2763
2764// helper function to check transform overflow
2765// todo: check overflow by checking against sign

Callers 2

EncodePatternFunction · 0.85
EncodePatternMethod · 0.85

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected