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

Function SwizzleMipSet

applications/_plugins/common/textureio.cpp:558–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558void SwizzleMipSet(MipSet* pMipSet)
559{
560 if (pMipSet->m_ChannelFormat == CF_Compressed)
561 return;
562
563 for (int nMipLevel = 0; nMipLevel < pMipSet->m_nMipLevels; nMipLevel++)
564 {
565 for (int nFaceOrSlice = 0; nFaceOrSlice < CMP_MaxFacesOrSlices(pMipSet, nMipLevel); nFaceOrSlice++)
566 {
567 //=====================
568 // Uncompressed source
569 //======================
570 MipLevel* pInMipLevel = g_CMIPS->GetMipLevel(pMipSet, nMipLevel, nFaceOrSlice);
571
572 CMP_DWORD width = pInMipLevel->m_nWidth;
573 CMP_DWORD height = pInMipLevel->m_nHeight;
574 CMP_BYTE* data = pInMipLevel->m_pbData;
575
576 CMP_DWORD numChannels = 4;
577
578 if (pMipSet->m_TextureDataType == TDT_XRGB || pMipSet->m_TextureDataType == TDT_RGB)
579 numChannels = 3;
580
581 CMP_DWORD bytesPerChannel = GetChannelFormatBitSize(pMipSet->m_format) / 8;
582
583 CMP_BYTE* redChannel = data;
584 CMP_BYTE* blueChannel = data + 2 * bytesPerChannel;
585
586 for (uint32_t y = 0; y < height; ++y)
587 {
588 for (uint32_t x = 0; x < width; ++x)
589 {
590 for (uint32_t i = 0; i < bytesPerChannel; ++i)
591 {
592 CMP_BYTE temp = redChannel[i];
593 redChannel[i] = blueChannel[i];
594 blueChannel[i] = temp;
595 }
596
597 redChannel += bytesPerChannel * numChannels;
598 blueChannel += bytesPerChannel * numChannels;
599 }
600 }
601 }
602 }
603}
604
605// Determine if RGB channel to BGA can be done or skipped
606// for special cases of compressed formats.

Callers 3

cleanupFunction · 0.85
ProcessCMDLineFunction · 0.85

Calls 3

CMP_MaxFacesOrSlicesFunction · 0.85
GetChannelFormatBitSizeFunction · 0.85
GetMipLevelMethod · 0.80

Tested by

no test coverage detected