-
-static size_t
-_calcDataSize(DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) {
- if (Width == 0 || Height == 0 || Depth == 0) {
- return 0;
- }
-
- switch (Format) {
- case DXGI_FORMAT_BC1_TYPELESS:
- case DXGI_FORMAT_BC1_UNORM:
- case DXGI_FORMAT_BC1_UNORM_SRGB:
- case DXGI_FORMAT_BC2_TYPELESS:
- case DXGI_FORMAT_BC2_UNORM:
- case DXGI_FORMAT_BC2_UNORM_SRGB:
- case DXGI_FORMAT_BC3_TYPELESS:
- case DXGI_FORMAT_BC3_UNORM:
- case DXGI_FORMAT_BC3_UNORM_SRGB:
- case DXGI_FORMAT_BC4_TYPELESS:
- case DXGI_FORMAT_BC4_UNORM:
- case DXGI_FORMAT_BC4_SNORM:
- case DXGI_FORMAT_BC5_TYPELESS:
- case DXGI_FORMAT_BC5_UNORM:
- case DXGI_FORMAT_BC5_SNORM:
- Width = (Width + 3) / 4;
- Height = (Height + 3) / 4;
- break;
-
- case DXGI_FORMAT_R8G8_B8G8_UNORM:
- case DXGI_FORMAT_G8R8_G8B8_UNORM:
- Width = (Width + 1) / 2;
- break;
-
- case DXGI_FORMAT_UNKNOWN:
- return 0;
-
- default:
- break;
- }
-
- /* FIXME */
- (void)Width;
-
- size_t size = Height * RowPitch;
-
- if (Depth > 1) {
- size += (Depth - 1) * DepthPitch;
- }
-
- return size;
-}
-
-static size_t
-_calcMipDataSize(UINT MipLevel, DXGI_FORMAT Format, UINT Width, UINT Height, UINT RowPitch, UINT Depth = 1, UINT DepthPitch = 0) {
- if (Width == 0 || Height == 0 || Depth == 0) {
- return 0;
- }
-
- Width = std::max(Width >> MipLevel, UINT(1));
- Height = std::max(Height >> MipLevel, UINT(1));
- Depth = std::max(Depth >> MipLevel, UINT(1));
-
- return _calcDataSize(Format, Width, Height, RowPitch, Depth, DepthPitch);
-}