I'm trying to get Viewport texture data from the GPU to CPU side using RenderingDevice.TextureGetDataAsync() in order to avoid stalls with the following setup:
Texture2D _tex = samplerView.GetTexture();
Rid _rid = _tex.GetRid();
RenderingDevice _rd = RenderingServer.GetRenderingDevice();
Error _error = _rd.TextureGetDataAsync( _rid, 0, _callback );
GD.Print( "RD: " + _rd );
GD.Print( "Error: " + _error.ToString() );
GD.Print( "Callback: " + _callback );
GD.Print( "RID: " + _rid );```
The function gets called in _Process, I am not creating any other rendering devices elsewhere (AFAIK). So as far as I understand, I should be able to get the data from the texture asynchronously...? "SamplerView" is a subviewport. However, it keeps throwing errors telling the texture parameter is NULL:
Output is
```RD: <RenderingDevice#3892314318>
Error: InvalidParameter
Callback: Godot.Callable
RID: RID(25507810771124)```
Error I am getting is
```E 0:00:07:569 NativeCalls.cs:9194 @ int Godot.NativeCalls.godot_icall_3_1015(nint, nint, Godot.Rid, uint, Godot.Callable&): Parameter "tex" is null.
<C++ Source> servers/rendering/rendering_device.cpp:2089 @ texture_get_data_async()
<Stack Trace> NativeCalls.cs:9194 @ int Godot.NativeCalls.godot_icall_3_1015(nint, nint, Godot.Rid, uint, Godot.Callable&)
RenderingDevice.cs:2411 @ Godot.Error Godot.RenderingDevice.TextureGetDataAsync(Godot.Rid, uint, Godot.Callable)
WaterController.cs:167 @ void WaterController.QueryWaterDataAsyncUpdate()
WaterController.cs:97 @ void WaterController._Process(double)```