Hi guys,
I have some textures that when created, were created as DXT1 compressed. I'd like to map them, and get the data back out. To that end, I created a staging buffer, do a copy of the original resource to the staging buffer, then map the staging buffer. This works just fine for non-DXT compressed textures; and the data all looks correct with the test textures I used.
questions:
1. When I map a DXT1 compressed texture - am I seeing compressed bits?
2. If they are not the compressed bits, what format are they in (RGB8)?
3. If they ARE compressed bits,
3a. Can I specify the staging buffer they are mapping to have a different format such as RGB8 to get the non-compressed bits (i.e use it as a decompressor)?
3b. If I cannot do 3A, then are there software decompressors around in a library that I might use to get the raw bits back out?
Thanks in advance
Mapping a DXT1 compressed texture
1. They are compressed.
3b. You need to create additional uncompressed texture and copy DXT1 compressed one to this new one. Then you can do mapping/reading back data from uncompressed as usual. Or you can do uncompression on CPU side, for example with this: http://code.google.com/p/libsquish/
3b. You need to create additional uncompressed texture and copy DXT1 compressed one to this new one. Then you can do mapping/reading back data from uncompressed as usual. Or you can do uncompression on CPU side, for example with this: http://code.google.com/p/libsquish/
Instead of decompressing in software, you can just write a super-simple compute shader that reads each texel and writes it to an output texture with a R32G32B32A32_FLOAT format. Then you can copy that to a staging buffer, and read the un-compressed data.
For simplicity use D3DXLoadSurfaceFromSurface() to convert a texture to a different format.
Depends on whether the OP is using D3D 9 or 10/11.
[quote name='Tispe' timestamp='1354866823' post='5008024']
For simplicity use D3DXLoadSurfaceFromSurface() to convert a texture to a different format.
Depends on whether the OP is using D3D 9 or 10/11.
[/quote]
It also depends on whether the OP wants to depend on D3DX, which is currently on its way out.
Thanks guys.
Yes, I can confirm if you just lock DXT compressed textures, the data you get back is compressed.
As for D3DXLoadSurfaceFromSurface(), you might also find (as I did) that D3DX11LoadTextureFromTexture() actually works better/easier. Yes, it is deprecated for Win8, but it was ok for our purposes. However, there is a new MS DirectXTex library for doing these operations that is compatible with Win8.
Thanks for the help!
Yes, I can confirm if you just lock DXT compressed textures, the data you get back is compressed.
As for D3DXLoadSurfaceFromSurface(), you might also find (as I did) that D3DX11LoadTextureFromTexture() actually works better/easier. Yes, it is deprecated for Win8, but it was ok for our purposes. However, there is a new MS DirectXTex library for doing these operations that is compatible with Win8.
Thanks for the help!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement