Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Which buffer was set in ComputeShader.SetBuffer()?

Discussion in 'General Graphics' started by coastalbytes, Jul 27, 2021.

  1. coastalbytes

    coastalbytes

    Joined:
    May 31, 2021
    Posts:
    1
    Is there a way to determine which buffer has been previously set with a SetBuffer()?

    A compute shader is being used to copy values from one of a number of source buffers to a target buffer. Depending on the scenario, ComputeShader.SetBuffer() is being called to set the source buffer to one of a number of possible buffers, then sometime later dispatch is called. For debug purposes, I'd like to be able to determine which buffer has been previously set at the time of dispatch.

    For example,

    Code (CSharp):
    1.  
    2.         public ComputeShader computeShader;
    3.  
    4.         ComputeBuffer bufferA = new ComputeBuffer(count, sizeof(uint));
    5.         ComputeBuffer bufferB = new ComputeBuffer(count, sizeof(uint));
    6.         ComputeBuffer bufferC = new ComputeBuffer(count, sizeof(uint));
    7.         .
    8.         .
    9.         .
    10.         computeShader.SetBuffer("SourceBuffer", one of the above buffers);
    11.         .
    12.         .
    13.         .
    14.         // Is there a way to tell which of buffers A, B, or C,
    15.         // that SourceBuffer has been set to?
    16.         computeShader.Dispatch(kernel, numberOfThreads);
     
unityunity