| 110 | } |
| 111 | |
| 112 | void DecompressBc2( uint32_t width, uint32_t height, uint32_t depth, const Tr2SubresourceData& src, uint8_t* decompressed ) |
| 113 | { |
| 114 | uint32_t pitch = width * 4; |
| 115 | uint32_t slice = pitch * height; |
| 116 | for( uint32_t k = 0; k < depth; ++k ) |
| 117 | { |
| 118 | const uint8_t* source = static_cast<const uint8_t*>( src.m_sysMem ) + src.m_sysMemSlicePitch * k; |
| 119 | for( uint32_t j = 0; j < height; j += 4 ) |
| 120 | { |
| 121 | for( uint32_t i = 0; i < width; i += 4 ) |
| 122 | { |
| 123 | uint32_t color0 = ConvertBGR565A8ToBGRA8( *reinterpret_cast<const uint16_t*>( source + 8 ), 0 ); |
| 124 | uint32_t color1 = ConvertBGR565A8ToBGRA8( *reinterpret_cast<const uint16_t*>( source + 8 + 2 ), 0 ); |
| 125 | uint32_t color2 = InterpolatedColor( color0, 2, color1, 1, 1, 3 ); |
| 126 | uint32_t color3 = InterpolatedColor( color0, 1, color1, 2, 1, 3 ); |
| 127 | uint32_t bits = *reinterpret_cast<const uint32_t*>( source + 8 + 4 ); |
| 128 | for( uint32_t y = 0; y < 4; ++y ) |
| 129 | { |
| 130 | for( uint32_t x = 0; x < 4; ++x ) |
| 131 | { |
| 132 | uint32_t destY = j + y; |
| 133 | uint32_t* destPixel = reinterpret_cast<uint32_t*>( decompressed + k * slice + destY * pitch + ( x + i ) * sizeof( uint32_t ) ); |
| 134 | unsigned alphaValue = ( *( reinterpret_cast<const uint16_t*>( source ) + y ) >> x * 4 ) & 15; |
| 135 | alphaValue = alphaValue * 255 / 15; |
| 136 | alphaValue <<= 24; |
| 137 | switch( ( bits >> 2 * ( 4 * y + x ) ) & 3 ) |
| 138 | { |
| 139 | case 0: |
| 140 | *destPixel = color0 | alphaValue; |
| 141 | break; |
| 142 | case 1: |
| 143 | *destPixel = color1 | alphaValue; |
| 144 | break; |
| 145 | case 2: |
| 146 | *destPixel = color2 | alphaValue; |
| 147 | break; |
| 148 | case 3: |
| 149 | *destPixel = color3 | alphaValue; |
| 150 | break; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | source += 16; |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | void DecompressBc3( uint32_t width, uint32_t height, uint32_t depth, const Tr2SubresourceData& src, uint8_t* decompressed ) |
| 161 | { |
no test coverage detected