Speeding up pinvoke

S

Sean Cross

Any idea how I could speed up the following p/invoke operation. It is
being called 6000 times a second so any speed up would be welcome.


c# Method:
public void BltFast(int dwX, int dwY, GapiSurface srcSurface,
ref GDRect srcRect, BltFastOptions dwFlags, ref GDBLTFASTFX fastFx)
{
GdNet.CGapiSurface_BltFast(unmanagedGapiObject, dwX, dwY,
srcSurface.GapiObject, ref srcRect, (int)dwFlags, ref fastFx);
}

P/Invoke:
[DllImport("gd300.dll")]
public static extern UInt32 CGapiSurface_BltFast(IntPtr pSurface, int
dwX, int dwY, IntPtr pSrcSurface, ref GDRect pSrcRect, int dwFlags, ref
GDBLTFASTFX pGDBltFastFx);

C++ Declaration:
GAPIDRAW_API HRESULT __stdcall CGapiSurface_BltFast(CGapiSurface*
pSurface, LONG destX, LONG destY, CGapiSurface* pSrcSurface, RECT*
pSrcRect, DWORD dwFlags, GDBLTFASTFX* pGDBltFastFx);

Sean
---------------------------------------
Sean Cross
mailto:[email protected]

Pics Print - The photo printing solution for Windows.
http://www.picsprint.com

http://www.Intuitex.com - Multimedia software for Windows,
Gapidraw.net and hekkus.net libraries for the compact framework
 
A

Alex Feinman [MVP]

I cannot imagine an application that would need frame rate of 6000 fps, so
most likely you are updating multiple small screen objects at a more
reasonable frame rate. The tradeoff is between blting larger image fragment
less often (saving on P/Invoke but losing on larger than needed data
transfers) and blting multiple smaller images. I suppose you should try
achieving the happy medium by consolidating smaller updates that have common
bounding rectangle no larger than certain value to which you will arrive as
a result of experiments.

Unfortunately P/Invoke is inherently slow. I'm not aware of any way to
drastically increase its speed
 
S

Sean Cross

There are about 200 independant objects at 30fps. This is the mfc
sample app in my gapidraw wrapper (www.intuitex.com).

There isn't much data being trasferred as all the image loading is
handled by the c++ library.

I have a few ideas to try out, but none are very pretty :-( What would
happen if I created a struct that contained all the parameters and the
just pinvoked on the struct? Any ideas or should I just suck it and see?

Ta

Sean
I cannot imagine an application that would need frame rate of 6000 fps, so
most likely you are updating multiple small screen objects at a more
reasonable frame rate. The tradeoff is between blting larger image fragment
less often (saving on P/Invoke but losing on larger than needed data
transfers) and blting multiple smaller images. I suppose you should try
achieving the happy medium by consolidating smaller updates that have common
bounding rectangle no larger than certain value to which you will arrive as
a result of experiments.

Unfortunately P/Invoke is inherently slow. I'm not aware of any way to
drastically increase its speed

Any idea how I could speed up the following p/invoke operation. It is
being called 6000 times a second so any speed up would be welcome.


c# Method:
public void BltFast(int dwX, int dwY, GapiSurface srcSurface,
ref GDRect srcRect, BltFastOptions dwFlags, ref GDBLTFASTFX fastFx)
{
GdNet.CGapiSurface_BltFast(unmanagedGapiObject, dwX, dwY,
srcSurface.GapiObject, ref srcRect, (int)dwFlags, ref fastFx);
}

P/Invoke:
[DllImport("gd300.dll")]
public static extern UInt32 CGapiSurface_BltFast(IntPtr pSurface, int
dwX, int dwY, IntPtr pSrcSurface, ref GDRect pSrcRect, int dwFlags, ref
GDBLTFASTFX pGDBltFastFx);

C++ Declaration:
GAPIDRAW_API HRESULT __stdcall CGapiSurface_BltFast(CGapiSurface*
pSurface, LONG destX, LONG destY, CGapiSurface* pSrcSurface, RECT*
pSrcRect, DWORD dwFlags, GDBLTFASTFX* pGDBltFastFx);

Sean
---------------------------------------
Sean Cross
mailto:[email protected]

Pics Print - The photo printing solution for Windows.
http://www.picsprint.com

http://www.Intuitex.com - Multimedia software for Windows,
Gapidraw.net and hekkus.net libraries for the compact framework
 
Top