Jump to content

  • Log In with Google      Sign In   
  • Create Account

Mapping a DXT1 compressed texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 mattropo1is   Members   -  Reputation: 142

Like
0Likes
Like

Posted 06 December 2012 - 08:06 PM

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

Sponsor:

#2 Martins Mozeiko   Crossbones+   -  Reputation: 1422

Like
0Likes
Like

Posted 06 December 2012 - 09:09 PM

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/

#3 MJP   Moderators   -  Reputation: 11343

Like
2Likes
Like

Posted 06 December 2012 - 10:05 PM

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.

#4 Tispe   Members   -  Reputation: 1033

Like
0Likes
Like

Posted 07 December 2012 - 01:53 AM

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

#5 mhagain   Crossbones+   -  Reputation: 7970

Like
0Likes
Like

Posted 07 December 2012 - 04:23 AM

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


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

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#6 MJP   Moderators   -  Reputation: 11343

Like
0Likes
Like

Posted 07 December 2012 - 04:45 PM


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


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


It also depends on whether the OP wants to depend on D3DX, which is currently on its way out.

#7 mattropo1is   Members   -  Reputation: 142

Like
0Likes
Like

Posted 19 December 2012 - 03:14 PM

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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS