Computer shaders: execution during post-draw

Godot Version

4.7

Question

Hi, i have a compute shader that should generate collision mesh data and would like to run it occasionally but I dont want to impact render performance … is there a function/signal or callback in gdscript that is called during the event when the backbuffer is copied to the display?

There is no GDScript callback for the exact moment the backbuffer is presented.

The closest signal is RenderingServer.frame_post_draw, but it only means that all Viewports have been updated — not that the GPU is idle. Your compute shader may therefore still affect rendering performance.

For occasional work, use a local RenderingDevice, avoid calling sync() immediately, and retrieve the result asynchronously or a few frames later.

Yeah thats the sort of function I was thinking about.

I can probably get away with occasional FPS drops because the compute shader isnt a large workload and the FPS is highly variable anyway.

Glad that helps! In that case, frame_post_draw should be a reasonable place to trigger it.