-static size_t
-_calcDataSize(DXGI_FORMAT Format, UINT Width, UINT Height, INT RowPitch, UINT Depth = 1, INT DepthPitch = 0) {
- if (Width == 0 || Height == 0 || Depth == 0) {
- return 0;
- }
-
- if (RowPitch < 0) {
- os::log("apitrace: warning: %s: negative row pitch %i\n", __FUNCTION__, RowPitch);
- return 0;
- }
-
- if (DepthPitch < 0) {
- os::log("apitrace: warning: %s: negative slice pitch %i\n", __FUNCTION__, DepthPitch);
- 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, INT RowPitch, UINT Depth = 1, INT 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);
-}
-
-
-inline UINT
-_getNumMipLevels(UINT Width, UINT Height = 1, UINT Depth = 1) {
- UINT MipLevels = 0;
- do {
- ++MipLevels;
- Width >>= 1;
- Height >>= 1;
- Depth >>= 1;
- } while (Width || Height || Depth);
- return MipLevels;
-}