Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Trying to add LBS Node support breaks GraphicsBuffer bindings

Discussion in 'Graphics for ECS' started by DreamingImLatios, Apr 5, 2023.

  1. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,295
    This is a weird one.

    Context: Windows 10, DX11, running 2022.2.12 and Graphics Pre.65.

    I have a custom skinning solution that uses custom shader graph nodes like this:
    upload_2023-4-5_11-15-8.png
    And if I build my skinning solution to only target these nodes, everything works perfectly! However, when trying to add compatibility for Unity's built-in nodes for compatibility with other assets, I start to run into problems.

    For vertex skinning, I use structured buffers to store the skin matrices. The LBS node on the other hand uses ByteAddressBuffer. No worries, I can just use
    GraphicsBuffer.Target.Structured | GraphicsBuffer.Target.Raw
    when creating my persistent GraphicsBuffer. Except, the moment I do this, my shader stops working. If I remove the Raw flag, it works again.

    Looking at RenderDoc, I can see that the compute shader that sets everything up does the right thing, but the draw call drawing the mesh doesn't seem to have the correct data bound to the buffer slot.

    Any thoughts on what the issue might be and how I can best proceed?
     
  2. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    210
    D3D11 documentation says that: "You can't combine the D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS flag with D3D11_RESOURCE_MISC_BUFFER_STRUCTURED."

    This limitation is also applied to the constant buffers. In other words it is forbidden by API to make a buffer that is raw and structured in the same time. You can try to check this by enabling debug D3D11 layer via dxcpl.exe.
     
  3. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,295
    Great spot!

    Unity should log a warning in the graphics buffer constructor rather than fail silently.