In my code I have a case when I’d like to update only some portion of a persistent buffer (the buffer is mapped to CPU visible memory with
GL_MAP_UNSYNCHRONIZED_BIT) - e.x. I have some array of structures and on the CPU I update only a few of these structs.
I know that I should synchronize writes and reads in these cases and that’s what I do for my per-frame buffers - I have a buffer x3 the size and just cycle between it’s ranges, making sure the range isn’t used with a fence.
But these buffers have new data every frame, and here only small portion on the data CAN change.
If I wanted to synchronize the access in a similar fashion as with the per-frame buffers, I’d have to send write all the data every frame, which kind of sucks tbh.
If there is a solution for that then I’d appreciate an answer, but what bothers me more is what happens if I don’t synchronize the write? By that I mean what I just
memcpymy data to the pinned memory and the drivers issues a DMA during a rendering call uses the buffer that I’m updating?
Is this even a defined behaviour or there is no simple answer and thus it’s better not to do it, a it might cause crashes and etc.