Search Unity

CommandBuffer.RequestAsyncReadback is stalling

Discussion in 'General Graphics' started by whitexroft, Dec 29, 2020.

  1. whitexroft

    whitexroft

    Joined:
    Oct 22, 2012
    Posts:
    48
    While AsyncGPUReadback's "RequestToNativeArray" function can omit it's callback function and have it as null, the command buffer version can't. It throws an InvalidOperation exception because it does not take null as an argument.

    By adding a callback that reads some data back from compute into CPU, the render thread is stalling.
    On PC it is barely noticable, but the 0.04ms converts to 10ms on a low end device

    If I could omit the callback, I could read data manually from the native array, even though it might be dirty, but without stalling

    upload_2020-12-29_11-51-24.png
     
  2. whitexroft

    whitexroft

    Joined:
    Oct 22, 2012
    Posts:
    48
    Actually, it seems that it is the dispatch is taking this long, and the readback command is waiting for it.
    But the suggestion with "null" parameter still stands. The callback may not be necessary if RequestToNativeArray is used.