Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question StructuredBuffer in DirectX 12

Discussion in 'Shaders' started by Micz84, Aug 9, 2023.

  1. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    436
    Hi I have an issue with StructuredBuffers in Dx12
    I am porting out shaders from Dx11 to 12 and I get this error:
    Code (csharp):
    1. Unexpected identifier "StructuredBuffer". Expected one of: typedef const void inline uniform nointerpolation extern shared static volatile row_major column_major struct or a user-defined type
    Do I have to change it to something else?
     
  2. INedelcu

    INedelcu

    Unity Technologies

    Joined:
    Jul 14, 2015
    Posts:
    158
    They should work without issues.

    Declaration examples:
    StructuredBuffer<float4> SomeBuffer;
    StructuredBuffer<SomeStructure> AnotherBuffer;

    How did you declare your structured buffer?
     
  3. Micz84

    Micz84

    Joined:
    Jul 21, 2012
    Posts:
    436
    Hi, exactly like that:
    StructuredBuffer<float> _sourceMesh;
    Today I do not see this error. Strangely, it was working correctly and an issue I had ware not related to this error.
    One more question StructuredBuffers are recommended to be declared inside #ifdef with SHADER_API_D3D11 but then they are not present in Dx12. Is there a keyword for Dx12?
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,835
    Hi!
    There is no SHADER_API_D3D12. Both DX11 and DX12 use SHADER_API_D3D11.