How to compute a texture(using compute shader) and then render it on main screen.

Godot Version

4.4.1-stable

Question

I’m trying to implement a GPU-computed cellular automata using Godot’s compute shader.

Initially, I referenced this open-source project to structure my rendering pipeline:

The implementation approach in this project is:

Submit compute lists via the main RenderingDevice for computation

Results are updated directly to a texture

This texture is passed as a Texture2DRD to the main render device’s shader parameter
This allows rendering without data readback (no need for rd.submit() and rd.get_texture_data()), as the compute list results are directly used for rendering.

After replicating this architecture, I noticed the rendered results aren’t updated on the texture in real-time. There’s about a 4-6 frame delay between dispatching render commands and seeing the results on screen, which doesn’t meet my design requirements for the cellular automata.

Now I’m considering creating a separate thread with its own local RenderingDevice for computation. However, the problem I’m facing is that I can’t seem to share rendering results between the local render device and main render device - I’m forced to:

Use rd.get_texture_data() to read data back to CPU

Then set it to the main render device’s shader parameter

I’d like to know if there’s any way to avoid this GPU→CPU→GPU data copy to further optimize my rendering performance.

Edit at 2025.06.11

I found that the “4-6 frame delay” mentioned above may be not true: it may caused by my screen recording software, i am trying to figure it out…

You can check this answer Draw Compute Shader As Texture - #3 by mrcdk to see how to share a texture between the main rendering device and a local one.

1 Like

Thanks a lot!