Re: thread texture loading

Tech-Archive recommends: Fix windows errors by optimizing your registry



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,
>>
>
>


.



Relevant Pages

  • Re: Generating one table with a terabyte of data
    ... Take any simple string matching issues and run them as external C code on the files before loading. ... not match the job but can be adjusted for greater performance by changing memory type or adjusting IO layouts. ... them after a bulk load. ... Another thing is to split the updates across file sets. ...
    (microsoft.public.sqlserver.dts)
  • Re: Performance extreme deterioration
    ... programs from loading at startup. ... Pentium M 1.4 GHz processor and 512 MB of memory. ... If I click on my system tray, there are 24 icons of programs ... programs that automatically load into memory from doing so. ...
    (microsoft.public.windowsxp.general)
  • Re: thread texture loading
    ... > it just seem to be the inverse for me, load file from disk to memory using ... > // creation de la texture en memoire ... >>loading thread, just read the whole file into memory using your favourite ... >> Microsoft DirectX MVP, ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: losing resources to textures
    ... Say I write a loop to load 200 textures to my vertex buffer. ... another texture onto the same vertex buffer. ... I am not losing memory anywhere... ... GDI+) frees the memory, ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: losing resources to textures
    ... 64 MB of Video RAM is not a lot. ... did have a memory leak problem that has since been fixed. ... It might be better to load them one at a time, ... > another texture onto the same vertex buffer. ...
    (microsoft.public.win32.programmer.directx.managed)