Results 1 to 3 of 3

Thread: Writing to AGP Memory using VAR

  1. #1
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001

    Writing to AGP Memory using VAR

    Simple question - probably been asked before, but can't find a positive answer.
    I upload my vertex array to agp memory. Every frame, I want to change *just* the 'y' value for every vertex.
    Is it best for me to keep my own copy of the vertex array in system memory, change the 'y' values in that array, then (after my fence has finished) do a 'memcpy' to copy the entire system memory vertex array onto the agp memory vertex array? Or should I stick to my loop (below):-

    float* v=agp_varray + YOFFSET;
    float* h=height_array;
    for (i=0; i<numverts; i++)
    *v = *h++;

    Thanks for listening, and sorry if you've heard this one before.

    [This message has been edited by knackered (edited 01-15-2002).]

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Aug 2000
    Portsmouth, Hampshire, England

    Re: Writing to AGP Memory using VAR


    Technically you should update you system memory shadow, and then blit it across doing sequential writes to take account of write combining.

    However, I tried doing a particle test in AGP RAM, and found it was much quicker to just loop through the AGP memory, modifying vertices as I went. Hardly optimal, but turned out faster for some reason.

    As a side note, dont use memcpy for copying arrays to AGP, as it isn't very efficient. A simple few lines of assembler using rep movsd would probably be better. Or even a loop in C, with a int pointer, copying Dwords at a time.


    P.S. If you want the fastest solution. Do every method you can think of, and time them. IT's the only true way to know which is the best.

    [This message has been edited by Nutty (edited 01-15-2002).]

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001

    Re: Writing to AGP Memory using VAR

    The memcpy() that comes with MSVC version 6 uses rep movsd internally, so it's about as efficient as the assembly that you're talking about. If you want sufficiently better speed, you'd have to code a more advanced loop that pre-reads large chunks into the L1 cache (to keep the DRAM page open) and then copy from there into the AGP buffer using aligned uncached writes (typically using movntps, or possibly movntq for more AMD CPU compatibility).

    And modifying your system memory buffer and blitting to AGP is definitely the right thing to do; especially if you modify the system RAM by doing buffer pre-read before modifying (again, because of the cache).

    If you're not going this extra distance, chances are either way you write it, it's going to come out a wash.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Similar Threads

  1. Memory barrier problems for writing and reading an image
    By jacob6 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-24-2018, 08:30 AM
  2. Replies: 0
    Last Post: 01-05-2014, 09:10 PM
  3. About writing to Global Memory
    By lava in forum OpenCL
    Replies: 5
    Last Post: 07-22-2010, 01:58 AM
  4. Writing to shared global memory
    By louiswu in forum OpenCL
    Replies: 3
    Last Post: 11-29-2009, 02:00 PM
  5. writing to buffer WITHOUT writing to screen
    By mrshirts in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 10-01-2000, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean