How to release CPU side vertex data and ensure mapping relationships, how to partially map and modify data? #1260
Replies: 1 comment
-
Might I suggest updating your Github profile so you aren't just referenced as a list of numbers. We're humans here not robots so prefer to communicate like we're humans rather than inanimate objects. As for your questions I can provide suggestions but I wider approach you are taking may be the an inefficient way of tackling the task so knowing how to do something that is help you head further down a wrong path isn't really helping you as much as you need. So I think the best to take a step back and explain what you are trying to achieve at a high level rather than explain how you are trying to achieve it. This will allow us to point you in the most efficient direction. |
Beta Was this translation helpful? Give feedback.
-
The VSG packaging is very good, but I need more flexibility, or rather, I need your help.
I use vsg:: Array to store vertex data, and I know it will be stored in GPU memory. Therefore, I hope that after the data is transferred to the GPU, the vertex data on the CPU side can be released while maintaining the mapping relationship, so that I can also modify the data in GPU memory.
Vulkan can use the following code to complete mapping operations, so how can I free up the CPU memory of vsg:: Array and reserve my right to modify GPU memory?
void* data; vkMapMemory(device, vertexBufferMemory, 0, bufferInfo.size, 0, &data); memcpy(data, vertices.data(), (size_t)bufferInfo.size); vkUnmapMemory(device, vertexBufferMemory);
In my development project, the number of vertices for each shape is very small, only a few, but the number of shapes can reach millions or even billions. In order to improve rendering efficiency, I merged them into one buffer, namely vsg:: Array, for storage. After freeing up CPU memory, users often modify and delete data from a certain graph. Therefore, my current approach is to call vsg:: Array:: dirty and re upload the entire data. You should have guessed my question: is there a way to modify only a part of vsg:: Array? I will provide the starting point, length, and data.
If you could provide a simple example, I would greatly appreciate it. All I need is:
Beta Was this translation helpful? Give feedback.
All reactions