Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

browny

Why is it soo slowww :( ?

This topic is 6163 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 Recently i made a little FIRE demonstration using DirectX. I used the Direct Surface writing technique but unfortunately that turned out to be very slow . I made such similar FIRE demostrations in DOS earlier but they were quite fast !!!! Well.... the following code gives an outline of how i drew my fire in DirectX DDSURFACEDESC ddsd; BYTE *pSurface; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); pDDFireSurface->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL); pSurface = (BYTE*)ddsd.lpSurface; // I drew the bottom line of the fire here for( top TO bottom ){ // the main rendering of the fire goes here // by the way, the whole screen is not // rendered, it''s only the section where // the fire may appear is rendered } pDDFrontBuffer->Unlock(NULL); // Blt the pDDFireSurface to the BackBuffer. // Then i flip the BackBuffer to FrontBuffer. AM I DOING ANYTHING WRONG ?? or is there any way i could speed up my FIRE ?? Mentionably I''m just an amateur programmer . Any help from the big guys will be highly appreciated . Garrett

Share this post


Link to post
Share on other sites
Advertisement
First you lock the surface pointed by pDDFireSurface :
pDDFireSurface->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
and after all process, you unlock the surface pDDFrontBuffer :
pDDFrontBuffer->Unlock(NULL);

¿¿ Maybe this is your bug ?? or maybe it''s in the code inside the for ¿It is assembler, C++, which resolution are you using, etc ... ?





"If you''''re gonna die, die with your boots on"

Share this post


Link to post
Share on other sites
There are two instances when the fire code will be slow:
1) If the screen mode is above 8BIT color depth
2) If the surface you are modifying is in Video Memory.

DOS Fire was fast because the screen mode was only 320x240 and used 8Bit color, if u create your surface in SysMem it should speed things up.

  Downloads:  ZeroOne Realm

Share this post


Link to post
Share on other sites
As SikCiv said, putting the surface in system memory will speed things up. The _reason_ for this is that surfaces that are placed in the video memory are only accessible through the AGP bus, and both the AGP bus and the video memory is made for fast writes, not reads. In other words, if you want to draw directly video memory, you should do so with functions that only do writes.

For example:

*surface_memory_pointer = color; // ok
*surface_memory_pointer = (*surface_memory_pointer) + color; // not ok, requires reading

Share this post


Link to post
Share on other sites
Thanx khaile,
Thanx SikCiv n Thanks to Fantasy Guy too

Though i haven't tested out the system memory technique yet, but i've definitely learned a whole new stuff here. I really didn't know that Video Memory could ever be slower !! hehehe ..... thanx fellows

browny

Edited by - browny on September 5, 2001 4:48:54 AM

Share this post


Link to post
Share on other sites
Hey, it worked !!!
I changed my pDDFireSurface to system memory n BANG !!!
Cooool........ but i would like see my fire a lil more faster than that. Is there any other tricks that i could apply ??

Share this post


Link to post
Share on other sites
I don''t know how you''re drawing your fire, but I think the only way left is to use some optimization techniques. If you know Assembly, you can also use MMX to drive it faster.

Share this post


Link to post
Share on other sites
quote:
Original post by browny
Thanx khaile,
Thanx SikCiv n Thanks to Fantasy Guy too

Though i haven''t tested out the system memory technique yet, but i''ve definitely learned a whole new stuff here. I really didn''t know that Video Memory could ever be slower !! hehehe ..... thanx fellows

browny

Edited by - browny on September 5, 2001 4:48:54 AM


I''m gona'' second that. I''ll have to watch for that. Not sure I
fully understand it but I think get the idea.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!