0

environment:
i5 750
DDR3 4G Win7 pro x64 sp1
DXSDK 9.0c June 2010
GeForce GT240(driver 275.33) 512MB
MSVC 2008 sp1

project:
a game project that uses character sprite images that is DXT5(A8R8G8B8) dds format.
A sprite is 512*512 size per each frame, and each frame is each other files.
(we uses rendered 3dsmax cartoon shader modeling animation. and 3dsmax render each frame onto each other files.)
and load that way :

HRESULT hr = D3DXCreateTextureFromFileEx( m_pd3dDevice //LPDIRECT3DDEVICE9 m_pd3dDevice
        ,filename_upper.c_str() //std::wstring filename_upper
        ,D3DX_DEFAULT_NONPOW2   
        ,D3DX_DEFAULT_NONPOW2   
        ,1
        ,0
        ,D3DFMT_A8R8G8B8
        ,D3DPOOL_MANAGED
        ,D3DX_FILTER_NONE 
        ,D3DX_FILTER_NONE
        ,NULL
        ,&info   // D3DXIMAGE_INFO info                
        ,NULL
        ,&rsTexture //LPDIRECT3DTEXTURE9 rsTexture
);

problem:
the hr is almost S_OK. when many files are loaded, sometimes it outs D3DXERR_INVALIDDATA.
i was googling and i found it is not means reached out of Memory. (out of memory is D3DERR_OUTOFVIDEOMEMORY or E_OUTOFMEMORY)
many answer says "file corrupted or abnormally format", but i don't think so because the error occurs in load random file. (the 'load failed file' is load successfully when next time, or the opposite case randomly).

what's the problem and what can i do?
i'm really in panic help me!

user1101221
  • 394
  • 6
  • 21
  • Have you tried reproducing this error using the same textures (in the same sequence) in a separate app? There might be a variety of reasons this happens, including memory corruption from somewhere else in your program. If this does not happen elsewhere - I'd start examining the rest of the code with a fine-tooth comb. – Ani Jun 11 '12 at 13:20

1 Answers1

2

Explaning your answer:

D3DFMT_A8R8G8B8 is not D3DFMT_DXT5. The format's name implies that it contains 4 components of 8 bits each hence the "R8" etc. So you were converting all your files to 32-bit which takes up 4 times the amount of storage space of DXT5.

As it happens using, simply, D3DFMT_FROM_FILE means it will use the DXT5 you specify in the file. You could also have specified D3DFMT_DXT5. This would have the advantage of automatically converting any R8G8B8A8 (or any other format) files you happen to load to the correct DXT5 compressed format.

Goz
  • 61,365
  • 24
  • 124
  • 204