Encoding Indirect Thread Dispatch on GPU

Hello -

I was hopeful someone could help me with a few ideas for troubleshooting a test program I am writing to try out encoding compute dispatch commands on the gpu using an indirect command buffer. My simple set up is described below. Please advise if more information would be helpful. The problem I find myself with is that commands are not being encoded into the icb.

Kernel: A simple function that accepts three parameters:
  1. A buffer that holds the icb

  2. A buffer that holds the compute pipeline state for another kernel function

  3. A camera uniforms buffer that consists of a view and projection matrix

The thread_position_in_grid is used to index into the icb within the kernel. The body of the kernel is essentially:
  • compute_command cmd(bufferA->icb, thread_id);

  • cmd.set_compute_pipeline_state(bufferB->pipeline);

  • cmd.set_kernel_buffer(uniforms, 1);

  • cmd.concurrent_dispatch_threads(threads, threadsPerThreadGroup);

I am not getting any errors from the Metal API. The second kernel function is just a dummy function for testing purposes. It just takes the uniforms buffer and does nothing with it. This seems straight forward enough, but still, when I inspect the buffers, the GPU debugger says no commands have been encoded. Also, if I attempt to execute the commands in the icb from the render loop and take a frame capture, I get a bad access error.

I did confirm that I am calling useResource:options: on the icb in the render loop.

Thoughts on how I should trouble shoot?

Thanks,

Answered by Graphics and Games Engineer in 671513022
Hi lducot2,

Sorry you ran into this.

It would be helpful if you created a report with Feedback Assistant and provide whatever info you can (ideally a reproducer) so that the GPU tools team can look into this.
After further testing it seems the commands are being encoded. I can get expected results running simple calculations and reading them back on the cpu. The issue appears to be that the metal frame capture tool doesn’t play well with indirect command buffers leading me to believe the buffer was empty when in fact it was not.
Accepted Answer
Hi lducot2,

Sorry you ran into this.

It would be helpful if you created a report with Feedback Assistant and provide whatever info you can (ideally a reproducer) so that the GPU tools team can look into this.
Thanks for the suggestion. I will do so this weekend.
Encoding Indirect Thread Dispatch on GPU
 
 
Q