How often, the answer is "It depends." In some situations, glMapBuffer really allocates memory through malloc, copies the data there for your use, and glUnmapBuffer releases it.
However, a common way to implement glMapBuffer is to map memory. If you do not know what it is, take a look at the documentation for mmap system calls (* nix systems such as Linux, MacOS X) or CreateFileMap. What happens is interesting: modern operating systems manage the address space of running processes in virtual memory. Each time there is access to some kind of "memory", OS memory management uses the available address as an index in the translation table, redirecting operations to system RAM, swap space, etc. (Of course, the details are largely involved, memory management is one of the most difficult things in the kernel to understand). The driver can install its own access handler. Thus, the process can mmap something controlled by the driver into its address space, and each time it accesses it, the mmap driver handler is called. This allows the driver to map some GPU memory (via DMA) to the process address space and perform the necessary bookkeeping. In this situation, glMapBuffer will create such a memory mapping, and the pointer you receive will point to some address space of your process that was mapped into the DMA memory reserved for the GPU.
datenwolf
source share