Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DirectDraw Blt and AlphaBlt are really slow

89 views
Skip to first unread message

Matt

unread,
Dec 22, 2009, 12:32:01 PM12/22/09
to
So I'm writing an application that uses DirectDraw for simple graphics. I'm
using the AlphaBlt function to composite the displayed image. However, I've
discovered that it takes an outrageously long amount of time to call
AlphaBlt.

For example, a single call to AlphaBlt with a 100 x 200 source rectangle and
a 1280x1024 destination rectangle takes 29ms (using performance counters on
each side of the call). At first I thought that maybe it was the alpha
calculation that was slowing it down, so I changed to a standard Blt call.
When I did this, it got faster, but it still stakes 13 ms to complete the
blit. This is way too slow, for a single blit with a relatively small source.

Any thoughts on what's going on?
Here's my code:

//Creating the primary surface and back buffer
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP |
DDSCAPS_VIDEOMEMORY;
ddsd.dwBackBufferCount = 1;

hRet = directDraw_->CreateSurface(&ddsd, &primarySurface_, NULL);
//backSurface_ is found using EnumAttachedSurfaces

//Here's how the source surface is created
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_CAPS;

ddsd.dwHeight = image.height();
ddsd.dwWidth = image.width();
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;

DDPIXELFORMAT pixFormat;
memset(&pixFormat, 0, sizeof(DDPIXELFORMAT));
pixFormat.dwSize = sizeof(DDPIXELFORMAT);
pixFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS | DDPF_ALPHAPREMULT;
pixFormat.dwFourCC = 0;
pixFormat.dwRGBBitCount = 32;
pixFormat.dwRBitMask = 0x00FF0000;
pixFormat.dwGBitMask = 0x0000FF00;
pixFormat.dwBBitMask = 0x000000FF;
pixFormat.dwRGBAlphaBitMask = 0xFF000000;

ddsd.ddpfPixelFormat = pixFormat;

hRet = dDraw_->CreateSurface(&ddsd,&sourceSurf,NULL);


//and finally here's the blt. This takes almost 30 ms!
hRet = backSurface_->AlphaBlt(&destRect, sourceSurf, &srcRect, moreMagic,
&alphaFX);

My hardware is a VIA EPIA-M700 board, so it should support all kinds of fun
hardware acceleration

Luca Calligaris [eMVP]

unread,
Dec 23, 2009, 4:33:45 AM12/23/09
to
The display controller may support the acceleration but its driver may not:
if the device is using the standard VGA driver (ddi_flat.dll) all the
accelerationa are emulated in SW.
You can knowwhich driver you're using checking the
HKEY_LOCAL_MACHINE\System\GDI\Drivers\Display key

--
Luca Calligaris (MVP-Windows Embedded)
l.calliga...@eurotech.it.nospam
www.eurotech.it


"Matt" <matthew.gay@[ivy league school starting with the letter Y].edu> ha
scritto nel messaggio
news:58F515FC-33D4-42B6...@microsoft.com...

mattgay

unread,
Jan 12, 2010, 7:00:54 PM1/12/10
to

Sorry for the late response (I was on vacation over Christmas/NewYear).

I just checked the driver, and I am in fact using the driver provided by via (ddi_via.dll). I actually have an email in to Via to confirm that this driver really supports hardware acceleration (I wouldn't be totally shocked if it didn't...)

Luca Calligaris [eMVP] wrote:

The display controller may support the acceleration but its driver may not:if

23-Dec-09

The display controller may support the acceleration but its driver may not:
if the device is using the standard VGA driver (ddi_flat.dll) all the
accelerationa are emulated in SW.

You can knowwhich driver you are using checking the


HKEY_LOCAL_MACHINE\System\GDI\Drivers\Display key

--
Luca Calligaris (MVP-Windows Embedded)
l.calliga...@eurotech.it.nospam
www.eurotech.it


"Matt" <matthew.gay@[ivy league school starting with the letter Y].edu> ha
scritto nel messaggio

Previous Posts In This Thread:

On Tuesday, December 22, 2009 12:32 PM
Matt wrote:

DirectDraw Blt and AlphaBlt are really slow
So I am writing an application that uses DirectDraw for simple graphics. I am
using the AlphaBlt function to composite the displayed image. However, I have


discovered that it takes an outrageously long amount of time to call
AlphaBlt.

For example, a single call to AlphaBlt with a 100 x 200 source rectangle and
a 1280x1024 destination rectangle takes 29ms (using performance counters on
each side of the call). At first I thought that maybe it was the alpha
calculation that was slowing it down, so I changed to a standard Blt call.
When I did this, it got faster, but it still stakes 13 ms to complete the
blit. This is way too slow, for a single blit with a relatively small source.

Any thoughts on what is going on?
Here is my code:

//Creating the primary surface and back buffer
DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP |
DDSCAPS_VIDEOMEMORY;
ddsd.dwBackBufferCount = 1;

hRet = directDraw_->CreateSurface(&ddsd, &primarySurface_, NULL);
//backSurface_ is found using EnumAttachedSurfaces

//Here is how the source surface is created


DDSURFACEDESC ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_CAPS;

ddsd.dwHeight = image.height();
ddsd.dwWidth = image.width();
ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;

DDPIXELFORMAT pixFormat;
memset(&pixFormat, 0, sizeof(DDPIXELFORMAT));
pixFormat.dwSize = sizeof(DDPIXELFORMAT);
pixFormat.dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS | DDPF_ALPHAPREMULT;
pixFormat.dwFourCC = 0;
pixFormat.dwRGBBitCount = 32;
pixFormat.dwRBitMask = 0x00FF0000;
pixFormat.dwGBitMask = 0x0000FF00;
pixFormat.dwBBitMask = 0x000000FF;
pixFormat.dwRGBAlphaBitMask = 0xFF000000;

ddsd.ddpfPixelFormat = pixFormat;

hRet = dDraw_->CreateSurface(&ddsd,&sourceSurf,NULL);


//and finally here is the blt. This takes almost 30 ms!


hRet = backSurface_->AlphaBlt(&destRect, sourceSurf, &srcRect, moreMagic,
&alphaFX);

My hardware is a VIA EPIA-M700 board, so it should support all kinds of fun
hardware acceleration

On Wednesday, December 23, 2009 4:33 AM
Luca Calligaris [eMVP] wrote:

The display controller may support the acceleration but its driver may not:if
The display controller may support the acceleration but its driver may not:
if the device is using the standard VGA driver (ddi_flat.dll) all the
accelerationa are emulated in SW.

You can knowwhich driver you are using checking the


HKEY_LOCAL_MACHINE\System\GDI\Drivers\Display key

--
Luca Calligaris (MVP-Windows Embedded)
l.calliga...@eurotech.it.nospam
www.eurotech.it


"Matt" <matthew.gay@[ivy league school starting with the letter Y].edu> ha
scritto nel messaggio


Submitted via EggHeadCafe - Software Developer Portal of Choice
Implementing Continuous Scrolling UI Pattern in ASP.NET
http://www.eggheadcafe.com/tutorials/aspnet/b8381915-06d9-4538-b4bb-5ac2a8e73f34/implementing-continuous-s.aspx

mattgay

unread,
Jan 13, 2010, 9:38:45 AM1/13/10
to
I just wanted to add a quick update. I tried using color keying (instead of alpha blending) in hopes that it would be faster. The color keying was faster, but it's clearly not hardware accelerated.

Blitting the same 3 sprites (each approximately 100x200) takes 1.2 ms without color keying, and 47 ms with color keying.

I should also note that I am not changing the pixel formats in any way, so I don't think there's a slow-down due to the conversion process.

Matt Gay wrote:

I'm using the VIA driver...
12-Jan-10

Sorry for the late response (I was on vacation over Christmas/NewYear).

I just checked the driver, and I am in fact using the driver provided by via (ddi_via.dll). I actually have an email in to Via to confirm that this driver really supports hardware acceleration (I wouldn't be totally shocked if it didn't...)

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice

Word HTML Cleaner
http://www.eggheadcafe.com/tutorials/aspnet/32f02d6f-2118-4517-ba64-8d998c6afa42/word-html-cleaner.aspx

0 new messages