Open john012343210 opened 1 week ago
That would be a callback function:
FnameOfTheShader9Interface::Dispatch(Params, [](int OutputVal) {
// Do something
});
The callback is run when the results are back from the gpu
@AskingQuestions
May I have your kind help for some guidance?
https://unreal.shadeup.dev/docs/compute/base I'm following this example, which just sum up the two numbers.
May I know in order to get the result Should I use the callback function?
May I know in order to get the result Should I use the callback function?
Correct, that callback function will be called with the resulting data in the buffer from the GPU.
// Dispatches this shader. Can be called from any thread static void Dispatch( FnameOfTheShader9DispatchParams Params, TFunction<void(int OutputVal)> AsyncCallback ) { if (IsInRenderingThread()) { DispatchRenderThread(GetImmediateCommandList_ForRenderCommand(), Params, AsyncCallback); }else{ DispatchGameThread(Params, AsyncCallback); } }
// Params struct used to pass args to our compute shader FnameOfTheShader9DispatchParams Params(1, 1, 1);
It seems that dispatch need to take two arguments. May I know What should I write in the 2nd argument?