Add MESA_map_buffer_client_pointer.#678
Conversation
|
You can get the next free extension number with |
8787926 to
4abf4b8
Compare
|
It looks good to me. |
4abf4b8 to
d0655c9
Compare
Good to hear. I've asked Jacek, who's worked on the Wine side of this code for other solutions to take a look as well before this gets pushed. Additionally, there's a few decisions I made that might be review worthy:
|
| If a buffer is mapped with the MAP_CLIENT_POINTER_BIT_MESA flag, the | ||
| returned pointer will be in a range provided by the application through | ||
|
|
||
| void AddClientPointerRangeMESA( void *addr, sizeiptr size ); |
There was a problem hiding this comment.
global, the same range can fit multiple buffers, and stay around for new mappings after the buffer has been unmapped
There was a problem hiding this comment.
I don't know if it has to be stated somewhere in the spec that it's global, but stating it would perhaps be better than leaving it up to the reader to figure out.
There was a problem hiding this comment.
I've updated the wording to make the global state more clear
d0655c9 to
6d9e364
Compare
This extension's purpose is for Wine (https://winehq.org), which runs 32-bit Windows applications with 64-bit system libraries, to be able to implement glMapBuffer such that the returned pointer is in the 32-bit address range.
Currently, Wine will set up a CPU storage for the buffer from which it copies the contents on glUnmapBuffer. For persistent maps, it currently uses either Vulkan resource sharing with VK_EXT_map_memory_placed, or AMD_pinned_memory.
These approaches can't work for legacy maps with the same speed, since they move buffer upload management to the application side, which can't for example provide staging buffers to avoid unnecessary synchronization.
For more details on the problem space, see
https://gitlab.freedesktop.org/mesa/mesa/-/issues/14254
and
https://lists.freedesktop.org/archives/mesa-dev/2024-October/226323.html
This extension should address the problem going forward by allowing Wine to provide 32-bit address ranges to the driver, onto which BOs can be mapped.
In OOM situations, it is on the application (Wine) to get the unused address ranges back from the driver and free them, as firstly, a callback extensions seems to be undesireable, and more importantly, WINE has a better idea of what constitutes an OOM, namely when 32-bit address range runs out, which the 64-bit driver has no awareness of.
Proof-of-concept RadeonSI implementation: https://gitlab.freedesktop.org/Guy1524/mesa/-/commit/829c099c16c4fbea27812705c6527a0ab1d1ba98
Wine branch: https://gitlab.winehq.org/dlesho/wine/-/commits/map_buffer_client_pointer