Jump to content
  • Advertisement
Sign in to follow this  
mattropo1is

Mapping a DXT1 compressed texture

This topic is 2041 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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/

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
For simplicity use D3DXLoadSurfaceFromSurface() to convert a texture to a different format.

Share this post


Link to post
Share on other sites

For simplicity use D3DXLoadSurfaceFromSurface() to convert a texture to a different format.


Depends on whether the OP is using D3D 9 or 10/11.

Share this post


Link to post
Share on other sites

[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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!