MCPcopy Create free account
hub / github.com/defold/defold / unpack_bc7_mode6

Function unpack_bc7_mode6

engine/dlib/src/basis/encoder/basisu_gpu_texture.cpp:661–712  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659 };
660
661 bool unpack_bc7_mode6(const void *pBlock_bits, color_rgba *pPixels)
662 {
663 static_assert(sizeof(bc7_mode_6) == 16, "sizeof(bc7_mode_6) == 16");
664
665 const bc7_mode_6 &block = *static_cast<const bc7_mode_6 *>(pBlock_bits);
666
667 if (block.m_lo.m_mode != (1 << 6))
668 return false;
669
670 const uint32_t r0 = (uint32_t)((block.m_lo.m_r0 << 1) | block.m_lo.m_p0);
671 const uint32_t g0 = (uint32_t)((block.m_lo.m_g0 << 1) | block.m_lo.m_p0);
672 const uint32_t b0 = (uint32_t)((block.m_lo.m_b0 << 1) | block.m_lo.m_p0);
673 const uint32_t a0 = (uint32_t)((block.m_lo.m_a0 << 1) | block.m_lo.m_p0);
674 const uint32_t r1 = (uint32_t)((block.m_lo.m_r1 << 1) | block.m_hi.m_p1);
675 const uint32_t g1 = (uint32_t)((block.m_lo.m_g1 << 1) | block.m_hi.m_p1);
676 const uint32_t b1 = (uint32_t)((block.m_lo.m_b1 << 1) | block.m_hi.m_p1);
677 const uint32_t a1 = (uint32_t)((block.m_lo.m_a1 << 1) | block.m_hi.m_p1);
678
679 color_rgba vals[16];
680 for (uint32_t i = 0; i < 16; i++)
681 {
682 const uint32_t w = basist::g_bc7_weights4[i];
683 const uint32_t iw = 64 - w;
684 vals[i].set_noclamp_rgba(
685 (r0 * iw + r1 * w + 32) >> 6,
686 (g0 * iw + g1 * w + 32) >> 6,
687 (b0 * iw + b1 * w + 32) >> 6,
688 (a0 * iw + a1 * w + 32) >> 6);
689 }
690
691 pPixels[0] = vals[block.m_hi.m_s00];
692 pPixels[1] = vals[block.m_hi.m_s10];
693 pPixels[2] = vals[block.m_hi.m_s20];
694 pPixels[3] = vals[block.m_hi.m_s30];
695
696 pPixels[4] = vals[block.m_hi.m_s01];
697 pPixels[5] = vals[block.m_hi.m_s11];
698 pPixels[6] = vals[block.m_hi.m_s21];
699 pPixels[7] = vals[block.m_hi.m_s31];
700
701 pPixels[8] = vals[block.m_hi.m_s02];
702 pPixels[9] = vals[block.m_hi.m_s12];
703 pPixels[10] = vals[block.m_hi.m_s22];
704 pPixels[11] = vals[block.m_hi.m_s32];
705
706 pPixels[12] = vals[block.m_hi.m_s03];
707 pPixels[13] = vals[block.m_hi.m_s13];
708 pPixels[14] = vals[block.m_hi.m_s23];
709 pPixels[15] = vals[block.m_hi.m_s33];
710
711 return true;
712 }
713
714 bool unpack_bc7(const void *pBlock, color_rgba *pPixels)
715 {

Callers 1

unpack_bc7Function · 0.85

Calls 1

set_noclamp_rgbaMethod · 0.80

Tested by

no test coverage detected