Re: Improving Application Performance by DISABLING hardware acceleration?



Thanks Severian for responding to this post.

As a background note, I have been using a Nvidia Go5200 and ATI 9600 as my
main test machines.

I found a similar issue when using Windows Media Encoder for screen capture
(Disabling Hardware Acceleration improving performance):
http://www.microsoft.com/windows/windowsmedia/9series/encoder/faq.aspx
Look over Section 3.2 -What can I do to improve the quality of my screen
captures?

Another issue that Disabling Hardware Acceleration seems to solve, is
DirectX overlays become accessable to my code below for a screen capture.

Currently by Disabling Hardware acceleration, I gain about 40-50MS of speed
per screen capture!

>From the look of your post, DIBs are worth investigating! It sounds like
there is a much better way to do this code, than what I have. I might need
a few pointers on where to start on using DIB's.

I will post the code I am using below:
----------------------------

Public oBackground As System.Drawing.Bitmap

Public Sub CaptureScreen()

Dim hSDC, hMDC, hMDC2 As Integer

Dim hBMP, hBMPOld As Integer

Dim CurInf As CursorInfo

Dim CurPos As PointAPI

Dim CursorIcon As New ICONINFO

Dim FW As Integer 'Width

Dim FH As Integer 'Height

Try

'Source DC

hSDC = CreateDC("DISPLAY", "", "", "")

'Destination DC with transpairent windows

hMDC = CreateCompatibleDC(hSDC)

'Screen Width

FW = GetDeviceCaps(hSDC, HORIZRES)

'Screen height

FH = GetDeviceCaps(hSDC, VERTRES)

hBMP = CreateCompatibleBitmap(hSDC, FW, FH)

hBMPOld = SelectObject(hMDC, hBMP)

Call BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, RasterOperations.SRCCOPY +
RasterOperations.CAPTUREBLT)

Call DeleteDC(hSDC)

'get cursor information

CurInf.cbSize = Len(CurInf)

Call GetCursorInfo(CurInf)



If (CurInf.flags And CURSOR_SHOWING) Then

'Get Hot Spot Info

GetIconInfo(CurInf.hCursor, CursorIcon)

Call DrawIconEx(hMDC, CurInf.ptScreenPos.X - CursorIcon.xHotspot, _

CurInf.ptScreenPos.Y - CursorIcon.yHotspot, _

CurInf.hCursor, 0, 0, 0, False, DI_NORMAL)

End If

Call SelectObject(hMDC, hBMPOld)

Call DeleteDC(hMDC)

oBackground = System.Drawing.Image.FromHbitmap(New IntPtr(hBMP))

DeleteObject(hBMP)

DeleteObject(hBMPOld)



Catch ex As Exception

Debug.WriteLine("CaptureScreen: General GDI ERROR: " & ex.Message.ToString)

End Try

End Sub

"Severian [MVP]" <severian@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ekjjf15om69ici5125n0jkth6d40ovi5lk@xxxxxxxxxx
> On Tue, 9 Aug 2005 11:36:35 -0700, "gregory_may" <None> wrote:
>
>>My understanding, is there are two paths to the graphics hardware. One is
>>Legacy GDI and the other is DirectX:
>>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/programmingguide/gettingstarted/architecture.asp
>>
>>It seems that disabling graphics hardware acceleration can dramatically
>>improve performance of GDI applications and system resource usage on
>>Windows
>>2000/XP.
>
> I would think this would only be the case with broken, or improperly
> optimized, display adapters/drivers.
>
> A specific difference I recall is that disabling hardware acceleration
> may force DDBs to be allocated in system (rather than video) memory;
> if you have a fast processor but a crappy display adapter, this may
> improve performance when operating on in-memory DDBs.
>
>>Anyone know of a programmatic way to disable hardware acceleration?
>
> Modern display adapters work differently than old ones. Using GDI, old
> ones would usually perform better with DDBs rather than DIBs, while
> the reverse seems to sometimes be the case today.
>
> If you're using memory DCs with DDBs (compatible bitmaps), you may
> want to try switching to DIBs; these are not as memory-limited as DDBs
> and may solve your problem without having to reconfigure the display.
>
> Otherwise, let us know what display device you're using now, and what
> kind of drawing operations you're doing (and whether you're doing them
> directly to the screen or using a memory DC).
>
> --
> Phillip Crews aka Severian
> Microsoft MVP, Windows SDK
> Posting email address is real, but please post replies on the newsgroup.


.



Relevant Pages

  • Re: Reading IE browser contents?
    ... The Document object represents the loaded page. ... "Microsoft Shell Controls and Automation" ... Dim ie2 As InternetExplorer ... windows AND IE windows. ...
    (microsoft.public.vb.general.discussion)
  • Re: function PlaySound does not work
    ... You need to use any of several methods to get the Windows directory. ... Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long ... Public Function GetWinDir() As String ... Dim sBuffer As String ...
    (microsoft.public.vb.winapi)
  • RE: GetOpen filename to open files(Workbooks)
    ... As I said previously you can't circumvent the windows security protection ... Set FileNameXls = Workbooks.Open(_ ... Dim FileNameXls As Variant ... Dim ShName As String, PathStr As String ...
    (microsoft.public.excel.misc)
  • Re: How do I update Word 2002 to create merged faxes?
    ... If you have Windows 2000 or Windows XP, the "official" way is to have the ... If you're going to try it, please read the notes, modify the macro to suit ... Dim bFaxServerAvailable As Boolean ... Dim oFaxPorts As FAXCOMLib.FaxPorts ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Activate the fax option for mail merge
    ... If you have Windows 2000 or Windows XP, the "official" way is to have the ... Dim bFaxServerAvailable As Boolean ... ' - ensure that at least one output port is available ... Set oFaxPorts = Nothing ...
    (microsoft.public.word.mailmerge.fields)