Compute shader : RenderingDevice.TextureGetDataAsync() don't seems to work

Godot Version

Godot 4.4 mono

Question

Hello,

I’m working on some terrain generation using a compute shader and c#. I’m trying to optimize it, and reduce the freeze caused by the TextureGetData() function.
I looked to the documentation, and I learned there is TextureGetDataAsync() function made for this type of issue. The issue is that the function don’t seems to work and the callback parameter is never called and no error is throwed.
I feel like i’m missing something. Does anyone already did something similar ?

Here is the version with TextureGetData(), it works but it cause a freeze. (I’m using a callable, only to compare with the async version)

_localDevice = RenderingServer.CreateLocalRenderingDevice();
...
_localDevice.Submit();
_localDevice.Sync();

Callable callable = new Callable(this, MethodName.UpdateData);
var bytes = _localDevice.TextureGetData(_heightmapRid, 0);
callable.Call(bytes);

Here the async version which doesn’t work, callable is never called, no error throwed and the return value of the function is “Ok” :

_localDevice = RenderingServer.CreateLocalRenderingDevice();
...
_localDevice.Submit();
_localDevice.Sync();

Callable callable = new Callable(this, MethodName.UpdateData);
Error error = _localDevice.TextureGetDataAsync(_heightmapRid, 0, callable);

Thanks in advance,

You probably need to set the callback before syncing the RenderingDevice. Try moving it before calling sync()

1 Like