How to create cudaTextureObject with texture raw data in Block Compressed (BC) format?

Be careful about block compressed mipmaps though. The CUDA implementation of block compressed textures is not handling any texture levels with extents which are not a multiple of 4.
That’s due to the order in which the mipmaps are allocated and then re-interpreted with a resource view as a block compressed format. Since the mipmaps are not allocated with the necessary rounding (up) to 4x4 blocks but using the actual rounded (down) texels, the texture level extents are not matching the required block compressed extends for those.

Means non-mipmapped textures with extents being a multiple of 4 will work. Other textures would need to be scaled.
Mipmaps would need to be limited to the smallest level which still has multiple of 4 extents both when downloading and sampling (set the texture description max mipmap level clamp.)

That block compressed resource view method is insufficient and requires a different API with native block compressed formats instead to determine the correct mipmap sizes in blocks. This is a long standing CUDA bug I filed after analyzing this problem:
https://forums.developer.nvidia.com/t/mip-map-with-block-compressed-texture/72170

2 Likes