| 5134 | } |
| 5135 | |
| 5136 | void imageDecodeToRgba32f(bx::AllocatorI* _allocator, void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint32_t _depth, uint32_t _dstPitch, TextureFormat::Enum _srcFormat) |
| 5137 | { |
| 5138 | const uint8_t* src = (const uint8_t*)_src; |
| 5139 | uint8_t* dst = (uint8_t*)_dst; |
| 5140 | |
| 5141 | const uint32_t srcBpp = s_imageBlockInfo[_srcFormat].bitsPerPixel; |
| 5142 | const uint32_t srcPitch = _width*srcBpp/8; |
| 5143 | |
| 5144 | for (uint32_t zz = 0; zz < _depth; ++zz, src += _height*srcPitch, dst += _height*_dstPitch) |
| 5145 | { |
| 5146 | switch (_srcFormat) |
| 5147 | { |
| 5148 | case TextureFormat::BC5: |
| 5149 | { |
| 5150 | uint32_t width = _width/4; |
| 5151 | uint32_t height = _height/4; |
| 5152 | |
| 5153 | const uint8_t* srcData = src; |
| 5154 | |
| 5155 | for (uint32_t yy = 0; yy < height; ++yy) |
| 5156 | { |
| 5157 | for (uint32_t xx = 0; xx < width; ++xx) |
| 5158 | { |
| 5159 | uint8_t temp[16*4]; |
| 5160 | |
| 5161 | decodeBlockDxt45A(temp+2, srcData); |
| 5162 | srcData += 8; |
| 5163 | decodeBlockDxt45A(temp+1, srcData); |
| 5164 | srcData += 8; |
| 5165 | |
| 5166 | for (uint32_t ii = 0; ii < 16; ++ii) |
| 5167 | { |
| 5168 | float nx = temp[ii*4+2]*2.0f/255.0f - 1.0f; |
| 5169 | float ny = temp[ii*4+1]*2.0f/255.0f - 1.0f; |
| 5170 | float nz = bx::sqrt(1.0f - nx*nx - ny*ny); |
| 5171 | |
| 5172 | const uint32_t offset = (yy*4 + ii/4)*_width*16 + (xx*4 + ii%4)*16; |
| 5173 | float* block = (float*)&dst[offset]; |
| 5174 | block[0] = nx; |
| 5175 | block[1] = ny; |
| 5176 | block[2] = nz; |
| 5177 | block[3] = 0.0f; |
| 5178 | } |
| 5179 | } |
| 5180 | } |
| 5181 | } |
| 5182 | break; |
| 5183 | |
| 5184 | case TextureFormat::BC6H: |
| 5185 | { |
| 5186 | uint32_t width = _width/4; |
| 5187 | uint32_t height = _height/4; |
| 5188 | |
| 5189 | const uint8_t* srcData = src; |
| 5190 | |
| 5191 | for (uint32_t yy = 0; yy < height; ++yy) |
| 5192 | { |
| 5193 | for (uint32_t xx = 0; xx < width; ++xx) |
no test coverage detected