How to tell when a compute shader is done?

Godot Version

4.4.1

Question

I’m designing a compute shader to generate a map for a world terrain. Right now I’m starting the computation by creating a compute list, like in the raindrop example shader:

	var compute_list := rd.compute_list_begin()
	rd.compute_list_bind_compute_pipeline(compute_list, pipeline)
	rd.compute_list_bind_uniform_set(compute_list, current_set, 0)
	rd.compute_list_set_push_constant(compute_list, push_constant, push_constant.size())
	rd.compute_list_dispatch(compute_list, x_groups, y_groups, 1)
	rd.compute_list_end()

I’m not calling rd.submit() or rd.sync() because the example code does not do this and it does not seem to be necessary.

Anyhow, I was wondering if there’s any way to check if the compute shader is currently running or if it has finished? This is so that once it finishes, I’d like to check if any parameters have changed on my Godot object, and if to so run the shader again with the new parameter values.

Submit is required to start the compute, sync() is necessary to know when your gpu has completed the compute. But this can take some time so you can just wait an arbitrary amount of time, and it will block until its done.

The memory you setup will be where things have changed so the memory will be modified in place. Unless you setup an out buffer along side your in buffer.

Since sync will block you could throw it into a separate thread.