Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Not possible to AsyncReadback variable-length Append-Buffer using CommandBuffers?

Discussion in 'Shaders' started by Arycama, Jan 16, 2020.

  1. Arycama

    Arycama

    Joined:
    May 25, 2014
    Posts:
    183
    From what I can tell, there's no way to do this currently.

    I am using an AppendStrucutredBuffer to build a list of data on the GPU each frame. I then want to read back the number of elements in that buffer to the CPU, and then use that result to read back only the required number of elements from the GPU.

    This is possible using regular Graphics commands, but I want to use CommandBuffers and Async Compute. However CommandBuffer.RequestAsyncReadback does not have any overloads that would allow what I need. The only overload requires a hard-coded int value, which is not useful as the required quantity changes between frames.

    Does anyone have any alternative suggestions?
    If not, it would be great if this was somehow made possible in a future update.
    (Perhaps passing in a ComputeBuffer reference, in place of the count value when calling CommandBuffer.RequestAsyncReadback).