Archived

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

Mihail121

Gimme advice...

Recommended Posts

Mihail121    100
Ok guys here it goes.I''ve based my SoftRen on the DDraw7 interfaces and i have to following question.What is more safe and more efficient to do: Create a DIB section,write to it,blit to back buffer and flip or Lock back buffer,write to it,flip? Keep in mind that the back buffer will stay locked during the whole rendering proccess... "Tonight we strike,there is thunder in the sky,together we''ll fight,some of us will die,but they''ll always remember that we''ve made a stand and many will die by hand!" - ManOwaR

Share this post


Link to post
Share on other sites
DrunkenHyena    805
The DIB way will be slow. GDI is not fast, though it is very flexible.

Provided you do not need to READ from the surface as you write to it, your method of locking the backbuffer each frame is the way to go.

If you need to read, then allocate a DD surface in system memory, read/write to that and then blit it to the real back buffer.

Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Mihail121    100
Thanks pal.No need to read only to write so i''ll use the lock system.But i have another question.Shoud i restore the backbuffer after each unlock?

"Tonight we strike,there is thunder in the sky,together we''ll fight,some of us will die,but they''ll always remember that we''ve made a stand and many will die by hand!" - ManOwaR

Share this post


Link to post
Share on other sites
iaretony    127
Even faster would be to avoid locking. If you can build you''re image by compositing (blitting other surface''s on top of eachother), you can take advantage of HW acceleration.

An appropriate use of locking would be if you had built a custom GUI library that supported arbitrarily shaped windows with rounded corners. You could lock a surface (in sytem memory), render you''re rounded corner once, unlock, then blit it from then on (IE, whenever the window moves).

In fact, if you''re using 3D accelerated 2D, you''re compositing could even be using HW accelerated alpha blending and chroma blits.

tony

Share this post


Link to post
Share on other sites
Mihail121    100
U won''t believe it guys but look at the following results:

DRIVER:"Primary Display Driver"
MODE:1600x1200 16 bpp 60 freq

FPS with locking - 1
FPS with GDI DIB section - 11

anyone have any explanation?

"Tonight we strike,there is thunder in the sky,together we''ll fight,some of us will die,but they''ll always remember that we''ve made a stand and many will die by hand!" - ManOwaR

Share this post


Link to post
Share on other sites
Nik02    4348
I believe GDI implementation is inherently double- or triple-buffered.
For optimization, i suggest double-buffering for you too, instead of direct framebuffer locks.

Share this post


Link to post
Share on other sites
Mihail121    100
I''m using double buffered DDraw surface chain and here is what i do:i create a GDI DIB section and write to it.Then i blit it to the back buffer and flip it with the front.That''s almost 20 times faster that locking the backbuffer and writing directly to it...

"Tonight we strike,there is thunder in the sky,together we''ll fight,some of us will die,but they''ll always remember that we''ve made a stand and many will die by hand!" - ManOwaR

Share this post


Link to post
Share on other sites
RenderTarget    398
These days it''s much better to blt entire frames to video than make little writes one at a time. Actually, that''s been true for years.

It has to do with DMA and burst lengths over the AGP / PCI bus, among other things like driver call overhead and such. Much better to build in system memory and blt.

I like pie.

Share this post


Link to post
Share on other sites