I think sync() must be called at some point otherwise things may break and subsequent compute lists won’t run. It may work for you because you re-create the whole rendering device each time you run the compute list. Shader re-compilation causes a stutter there but that’s only a small part of the total lag time.
Try to put code in shader’s main() inside a loop that runs 50 times or so. Does it still run smoothly without sync()?
I think your best bet is to split the shader work; process only a bit of data each frame so there’s enough gpu resources left for rendering.
Thats not what im saying, im saying it only lags when sync is called. The compute shader runs when i call submit() and this works fine, so my assumption is that my shader is not taking too much work. The lag only comes through the synchronization
If you don’t call sync() how do you know when the shader is done?
You can use a counter variable and increase it in the shader for every thread that is done
Try to test what happens if there is much more work. Just stress test it to determine if the lag is caused by work itself or merely by calling sync(). My gpu stutters regardless of sync() being called.
My gpu stutters regardless of sync() being called.
are you using threads or not?
I’m using your worker thread pool setup. Also if I don’t call sync() at all but just wait it out, the engine complains at the next call to the rendering device that tries to retrieve the buffer data:
E 0:00:10:574 chunk_computer.gd:109 @ _compute_mesh(): Close failed with error 0x80004005.
<C++ Error> Condition "!((HRESULT)(res) >= 0)" is true.
<C++ Source> drivers/d3d12/rendering_device_driver_d3d12.cpp:2668 @ command_buffer_end()
<Stack Trace> chunk_computer.gd:109 @ _compute_mesh()
chunk_computer.gd:44 @ compute()
main.gd:53 @ create_single_mesh()
main.gd:35 @ load_chunk()
If you want to get to the bottom of this I’d recommend writing a truly minimal example from scratch (single script file, single buffer/uniform, minimal shader…). That way it’d also be easier to talk about it with the devs.