Sign in to follow this  

trouble in using d3d DXT file

This topic is 3485 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, everybody, I have some trouble in using d3d DXT file, recently I change my texture format to d3d compress texture(DXT5),but I found the loading speed become slow, the code is simply like this: HRESULT hr = D3DXCreateTextureFromFileInMemoryEx( pDevice, // device pSrcData, // data SrcDataSize, // data size 0, // width 0, // height 1, // mipmap level 0, // usage D3DFMT_DXT5, // format D3DPOOL_DEFAULT, // d3dpool D3DX_FILTER_NONE, // filter D3DX_FILTER_NONE, // mipfilter colorkey, // colorkey NULL, // D3DXIMAGE_INFO NULL, // PALETTEENTRY ppTexture); I know DXT format file is complex, when decode it need much time,but my question is DXT is used direct by hardware, so I assume from the D3DXCreateTextureFromFileInMemoryEx call to video memory, the DXT file isn't be decoded, if my assume is wrong,tell me in what situation can cause DXT file being decoded, if I'm right, what others can cause loading DXT file speed is slow down. (I set miplevels = 1 because I know generate mipmaps need decode DXT file,calculate mipmap pixel,and encode, but even set miplevels = 1,the loading speed is still slow) looking for you help, thanks.

Share this post


Link to post
Share on other sites
As you said, creating mips requires a slow decode, encode process, which can be bypassed by pre-generating the mips (dds files support that option).

Resizing would also require decoding. If your textures are not power of 2 sizes, they'll get stretched, or placed on a larger canvas. You have no filter, so you won't get stretching, but it will likely decode when moving the image to a pow2 sized canvas if your texture isn't appropriately sized to begin with.

Colorkeying also requires decoding and re-encoding. If your color key is not 0, that could be a cause.

Format conversion requires decoding. I'm not sure if D3DX is smart enough to ignore the DXT5 to DXT5 conversion. DXT4 and 5 are the same format, merely interpreted differently, so it is perhaps thinking it's converting from DXT4 to 5. Specify D3DFMT_UNKNOWN to load without format conversion.

Share this post


Link to post
Share on other sites
thanks a lot Namethatnobodyelsetook, It's clearly, I used colorkey, when disable colorkey, the loading speed increase significantly.

now the conclusion is: if you don't want DXT file being decode and encode when loading, you must make texture size is power of 2, pre-generating the mips,
don't set colorkey, when every condition is ok, the loading speed will as quickly as load a normal format texture file like bmp file.
is that right ?

Share this post


Link to post
Share on other sites
I can't think of any other condition that should slow it down, though there is a chance I forgot about something. It should load even faster than a BMP, as the BMP still needs to create mips. It will certainly render faster than a BMP, as you will have significantly reduced the amount of bandwidth used for texture lookups... this doesn't translate to a huge gain in FPS in most cases, but it is a nice bonus.

Share this post


Link to post
Share on other sites
ok, when someone said "hi, this version is very slow....", I think we all have the same feeling, the sky become dark,the earth is shaking....
first guess, then open vtune,PerfHUD whatever tools we can use to find what happen, so I suggest D3D debug runtime should give some warning when we do some "wrong" operate cause DXT file have to being decode and encode, I think it will helpful for developers.

Share this post


Link to post
Share on other sites

This topic is 3485 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this