Extend RenderingDevice.buffer_get_data()
to allow reading data back from the GPU into PackedByteArrays that already exist
#8862
Labels
Describe the project you are working on
I am working on a voxel terrain editing plugin which will comprehensively use compute shaders to generate noise.
Describe the problem or limitation you are having in your project
Using RenderingDevice.BufferGetData() to readback from a compute shader forces a new PackedByteArray to be created instead of optionally allowing an existing PackedByteArray to be passed in to copy the data to. This forces an unnecessary heap allocation every time a compute buffer is read from.
Compute shaders are mainly good for processing large amount of data at once. The way godot is currently set up limits the uses of compute shaders, because a large amount of performance is lost by forcing a memcpy to a newly allocated PackedByteArray.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
This feature would add another method to the RenderingDevice class to optionally allow an existing PackedByteArray to be utilized for reading data back from a buffer.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Something along the lines of the following would be added to the RenderingDevice class:
Instead of creating a new Vector<uint8_t>, resizing, and then copying the data to that; one should be able to pass in an existing PackedByteArray.
If this enhancement will not be used often, can it be worked around with a few lines of script?
I believe this enhancement will be used extensively by anyone who uses compute shaders in godot.
Is there a reason why this should be core and not an add-on in the asset library?
Yes, this is a feature that other engines provide. Unity has a similar method, albeit it has bugs.
AsyncGPUReadback.RequestIntoNativeArray
The text was updated successfully, but these errors were encountered: