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

#SHADER_API_D3D11 doesnt work on 2018.1.0b2

Discussion in 'Shaders' started by vladstorm_, Jan 16, 2018.

  1. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    Hey guys,

    I have a shader which uses StructuredBuffer.
    Usually I wrote this to make it work
    Code (CSharp):
    1.          #ifdef SHADER_API_D3D11
    2.          StructuredBuffer<Vert> _verticesOutput;
    3.          #endif
    4.  
    5.          #ifdef SHADER_API_D3D11
    6.          RWStructuredBuffer<int> _ArcPartsEvent;
    7.          #endif
    i had to mentioned SHADER_API_D3D11 because there's no StructuredBuffer on DirectX9. I also excluded it from the project. But now when I loaded my project in Unity 2018.1.0b2. Its saying that _verticesOutput is undeclared which means SHADER_API_D3D11 is not defined. Please, tell me how to fix it.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    Support for DirectX 9 was dropped in 2017.3. That said the SHADER_API_D3D11 should still exist since it is still used by Unity's internal shader code.

    The "real" issue is why is the code that uses _verticesOutput not also wrapped in an #ifdef block?
     
  3. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    i use #ifdef SHADER_API_D3D11 because otherwise compiler cant find StructuredBuffer type . Same with RWStructuredBuffer. Do you know how to fix it other way?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    That's not what that error means. It means _verticesOutput is being accessed in code that isn't also inside an #ifdef SHADER_API_D3D11 block.
     
  5. vladstorm_

    vladstorm_

    Joined:
    Nov 26, 2013
    Posts:
    184
    but before it worked. maybe they changed sth.
    before i only had to wrap StructuredBuffer declaration in SHADER_API_D3D11
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    No idea why it would have worked before, because it shouldn't have.