pointer returned by glMapBuffer -> RAM or VRAM ?

Hello everyone, and thanks for your valuable time :slight_smile:

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 :slight_smile:

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?

Thanks for your help :slight_smile:

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 ?

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.