Thread: Faster method than GetFrontBuffer()

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    1

    Faster method than GetFrontBuffer()

    I'm trying to sample portions of the screen several times a second while hooked into a DX9 app. I've read that GetFrontBuffer is extremely slow, the code I have now uses GetRenderTargetData and it also causes large slow downs. Is it possible to read out (portions of) the front buffer without taking a huge hit in performance? The sampling rate dosen't have to be very great, 2 to 4 frames a second, and I do expect to take some hit in performance, but I also know there is a better way than this.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    1. Lock the back buffer.
    2. Get a pointer to it.
    3. Use an assembly loop to copy dwords from back buffer or secondary surface to your buffer.

    You could use a FOR loop but you would want to make sure it is using REP MOVSD and not REP MOVSB with a value of (buffer_size*4) in ECX.

    I think most compilers should use REP MOVSD.

    It should be mentioned that the C standard library memory functions like memcpy, memmove, etc., DO NOT use anything but STOSB and MOVSB. They copy bytes at a time which will actually decrease performance by a factor of 4.
    Last edited by VirtualAce; 05-04-2005 at 06:44 AM.

  3. #3
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    [edit] silly comment, no need for it to be here, and cant find a way to remove the post.
    Last edited by skorman00; 05-04-2005 at 10:48 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX | Drawing text
    By gavra in forum Game Programming
    Replies: 4
    Last Post: 06-08-2009, 12:23 AM
  2. on method pointers and inheritance
    By BrownB in forum C++ Programming
    Replies: 2
    Last Post: 03-02-2009, 07:50 PM
  3. Overriding a method in C
    By DavidDobson in forum C Programming
    Replies: 1
    Last Post: 07-05-2008, 07:51 AM
  4. Any faster intersection method?
    By franziss in forum C++ Programming
    Replies: 6
    Last Post: 10-24-2005, 08:07 PM
  5. Merge and Heap..which is really faster
    By silicon in forum C++ Programming
    Replies: 2
    Last Post: 05-10-2005, 04:06 PM