Re: thread texture loading
- From: "Nicolas Bernard" <nicolas.bernard@xxxxxxxxxxxxxx>
- Date: Mon, 19 Dec 2005 12:50:13 +0100
Hello,
first, tx for your advise, i try them,
it just seem to be the inverse for me, load file from disk to memory using
fread, and then using D3DXCreateTextureFromFileInMemoryEx(...) takes much
times than doing
a simple D3DXCreateTextureFromFileEx(...),
maybe i'm wrong in doing thing...
here are result I got
loading and creating from memory
texture51.dds : texTime = 01920128 ms, texRes = 0x00000000
texture51.bmp : texTime = 05760054 ms, texRes = 0x00000000
texture51.jpg : texTime = 00095753 ms, texRes = 0x00000000
create from file
texture51.dds : texTime = 00001313 ms, texRes = 00000000
texture51.bmp : texTime = 00000203 ms, texRes = 00000000
texture51.jpg : texTime = 00000281 ms, texRes = 00000000
all 3 texture are the same, 1600*1200 in 24bits.
dds is a dxt5 picture,
my loading/creating procedure :
localFileStart = GetTickCount();
// copie du fichier en mémoire
f = fopen( "texture51.bmp", "rb" );
// taille du fichier
res = fseek( f, 0, SEEK_END );
size = 0; res = fgetpos( f, &size );
res = fseek( f, 0, SEEK_SET );
// copy du fichier en mémoire
fileMemory = new char[ size ];
res = fread( fileMemory, size/512, 512, f );
pos = 0; res = fgetpos( f, &pos );
fclose(f);
// creation de la texture en memoire
hr = D3DXCreateTextureFromFileInMemoryEx( m_pd3dDevice9, fileMemory,
size,
D3DX_DEFAULT, D3DX_DEFAULT, 1,
0, D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_FILTER_NONE,
D3DX_DEFAULT, 0, NULL, NULL, &pTexture );
// cleaning, and saving time
delete[] fileMemory;
totalTime = (int)GetTickCount() - (int)localFileStart;
fprintf(g, "texture51.bmp : texTime = %.8i ms, texRes = 0x%.8i\n", size,
totalTime, hr );
if ( pTexture ) pTexture->Release();
And here the d3dxcreatetexturefromfile procedure :
// chargement texture
DWORD localTexStart = GetTickCount();
hr = D3DXCreateTextureFromFileEx( m_pd3dDevice9, "texture51.dds",
D3DX_DEFAULT,
D3DX_DEFAULT, 1,
0,
D3DFMT_UNKNOWN, D3DPOOL_DEFAULT, D3DX_FILTER_NONE,
D3DX_DEFAULT,
0, NULL, NULL, &pTexture );
// clearing and saving time
totalTime = (int)GetTickCount() - localTexStart;
fprintf(g, "\ntexture51.dds : texTime = %.8i ms, texRes = %.8x\n",
totalTime, hr );
if ( pTexture ) pTexture->Release();
some advise ?
tx,
"Wessam Bahnassi" <wbahnassi@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:%23oj0QIbAGHA.4004@xxxxxxxxxxxxxxxxxxxxxxx
>I suggest you save your files in DDS format (DXT compressed). In your
>loading thread, just read the whole file into memory using your favourite
>I/O API. When you want to realize them to HW textures, just call
>D3DXCreateTextureFromFileInMemory() and pass in the data you finished
>loading.
> This offers less HDD access (because the files are compressed), as well as
> minimal CPU processing when creating the D3D texture because the data is
> copied as a single blob without any additional processing per texel. If
> you use JPG files, you save HDD access, but D3DX would have to do a lot of
> work to decompress and format convert the data which is much likely to
> cause hickups during rendering...
>
> --
> Wessam Bahnassi
> Microsoft DirectX MVP,
> Lead Programmer
> In|Framez
> --
> In|Structurez Arabic Gamedev Community
> www.instructurez.com
>
>
> "Nicolas Bernard" <nicolas.bernard@xxxxxxxxxxxxxx> wrote in message
> news:%23Z%23ePzWAGHA.1296@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi,
>>
>> I would like to preload textures from files. I just want them to load in
>> system memory so that it does not need of direct3device.
>> But the D3DXCreateTextureFromFileEx use the device althought I specify to
>> use D3DPOOL_SYSTEMMEM.
>>
>> I wan't to load texture in a different thread and in system memory to
>> avoid those high cost file access, and then to have texture ready to be
>> propulsed in memory in case of, by using UpdateSurface.
>>
>> So, have you some advise, if my way of doing thing are wrong, or some
>> library than can do such thing ?
>>
>> Tx by advance,
>>
>> Nicolas,
>>
>
>
.
- Follow-Ups:
- Re: thread texture loading
- From: Robert Dunlop [MS MVP]
- Re: thread texture loading
- From: Wessam Bahnassi
- Re: thread texture loading
- References:
- thread texture loading
- From: Nicolas Bernard
- Re: thread texture loading
- From: Wessam Bahnassi
- thread texture loading
- Prev by Date: Software rendering / CreateOffscreenPlainSurface fails
- Next by Date: Re: thread texture loading
- Previous by thread: Re: thread texture loading
- Next by thread: Re: thread texture loading
- Index(es):
Relevant Pages
|