Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: pointer returned by glMapBuffer -> RAM or VRAM ?

  1. #1
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2

    pointer returned by glMapBuffer -> RAM or VRAM ?

    Hello everyone, and thanks for your valuable time

    I have a question about glMapBuffer. This function return a pointer, but I would like to know if this points to a RAM-copied-version of the buffer, or directly to the VRAM buffer ?

    Indeed, a pointer on RAM which points to a VRAM buffer sounds weird...(to me ^^).

    I actually think that the buffer is copied from VRAM to RAM, then the function return the pointer to that copied-buffer, so that we can use other functions such as memcpy etc...
    Am I right ?

    Thanks for any help

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    754
    The OpenGL implementation (graphics driver) could map GPU memory into the application address space. It can decide what to do based on buffer size or usage hint, or information it tracked about how this buffer was used over the last few frames. In essence, there is no way to know. Is knowing that you are allowed to use memcpy and friends with the returned pointer not sufficient for your needs?

  3. #3
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2
    Thanks for your help :-)

    Indeed, I can use it like that, but I like understand how things really work ^^
    I really don't understand the way a "conventional" pointer, which is on RAM, can point to VRAM's data (if this is the case, because we cannot know if data has been copied to RAM during the call).
    -> In memcpy, I give adresses...how can the system know that this adress is actually on VRAM ?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    754
    You'll have to ask a kernel/driver developer how exactly this is done, also on a quick glance it looks like Linux Device Drivers, Chapter 13 may be relevant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •