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

RWByteAddressBuffer usage

Discussion in 'General Graphics' started by jesta, Jul 23, 2015.

  1. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    I'm trying to use a RWByteAddressBuffer to build a histogram in a compute shader. I created the buffer with the following code:
    Code (CSharp):
    1. _histogramBuffer = new ComputeBuffer(256, 4, ComputeBufferType.Raw);
    I then set this buffer on my shader and dispatch. I'm reading the values in another compute shader and it seems to stay at 0.

    I tested the exact same compute shaders in sharpDX and it works fine, so they're not the problem. I can also write/read normal StructuredBuffers and Textures just fine.

    Is there a special step to make ByteAddressBuffers work?
     
  2. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Update: I can actually write to the RWByteAddressBuffer in one compute shader. The problem occurs when I set the same buffer as ByteAddressBuffer in another compute shader and try Loading the values. All I get is 0 even though GetData returns the correct values.
     
  3. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    293
    Update 2: Everything works if I change the shader to use a UAV instead of a SRV. This looks like a bug, so I'll send a report.