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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Compute Shaders don't compile

Discussion in 'Shaders' started by Rexx_Norilsk, Feb 23, 2022.

  1. Rexx_Norilsk

    Rexx_Norilsk

    Joined:
    May 22, 2018
    Posts:
    9
    Hello,
    I write compute shader with parallel calculation, but it doesn't compile:
    Compiled--..shader:
    Code (CSharp):
    1. **** Platform Direct3D 11:
    2.   no variants for this platform (no compute support, or no kernels)
    I'm tried to replace Graphics API on OpenGL, Vulcan and Directx 12. But also it doesn't work.

    Shader code:
    Code (CSharp):
    1. #pragma kernel Nbody
    2.  
    3. #define d1 6.0f
    4. #define d2 4.0f
    5. #define p1 3.0f
    6. #define p2 2.0f
    7.  
    8. #define deltaT 0.1f
    9. #define maxZone 512f
    10.  
    11. //Вспомогательная структура
    12. struct physData
    13. {
    14.     float x; // Х координата
    15.     float y; // У координата
    16.     float vx; // Х скорость
    17.     float vy; // У скорость
    18.     float m; // Масса
    19. };
    20.  
    21. //Входные данные
    22. RWStructuredBuffer<physData> nodes;
    23.  
    24.  
    25. [numthreads(256,1,1)]
    26. void Nbody(uint3 id : SV_DispatchThreadID)
    27. {
    28.     //float vx = 0.0f, vy = 0.0f, posx, posy;
    29.     //for (int j = 0; j < 256; j++)
    30.     //{
    31.     //    if (id.x != j)
    32.     //    {
    33.     //        vx += nodes[j].m * (d1 * (nodes[j].x - nodes[id.x].x)) / pow(sqrt(pow(nodes[j].x - nodes[id.x].x, 2.0f) + pow(nodes[j].y - nodes[id.x].y, 2.0f)), p1) -
    34.     //            (d2 * (nodes[j].x - nodes[id.x].x)) / pow(sqrt(pow(nodes[j].x - nodes[id.x].x, 2.0f) + pow(nodes[j].y - nodes[id.x].y, 2.0f)), p2);
    35.     //        vy += nodes[j].m * (d1 * (nodes[j].y - nodes[id.x].y)) / pow(sqrt(pow(nodes[j].x - nodes[id.x].x, 2.0f) + pow(nodes[j].y - nodes[id.x].y, 2.0f)), p1) -
    36.     //            (d2 * (nodes[j].y - nodes[id.x].y)) / pow(sqrt(pow(nodes[j].x - nodes[id.x].x, 2.0f) + pow(nodes[j].y - nodes[id.x].y, 2.0f)), p2);
    37.     //    }
    38.     //}
    39.     //nodes[id.x].vx = nodes[id.x].vx + deltaT * vx;
    40.     //nodes[id.x].vy = nodes[id.x].vy + deltaT * vy;
    41.  
    42.     //posx = nodes[id.x].x + deltaT * nodes[i].vx;
    43.     //if (posx <= -maxZone || posx >= maxZone) nodes[id.x].vx = -nodes[id.x].vx;
    44.     //posy = nodes[id.x].y + deltaT * nodes[id.x].vy;
    45.     //if (posy <= -maxZone || posy >= maxZone) nodes[id.x].vy = -nodes[id.x].vy;
    46.  
    47.     //nodes[id.x].x = posx;
    48.     //nodes[id.x].y = posy;
    49.     nodes[id.x].x = 0f;
    50.     nodes[id.x].y = 0f;
    51.  
    52. }
    53.  


    Video card: AMD RX 6600 XT
     
    Last edited: Feb 23, 2022
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,623
    Please try to use the correct forums, the above is not scripting. The shader forum is here.

    I'll move your post for you.
     
  3. Rexx_Norilsk

    Rexx_Norilsk

    Joined:
    May 22, 2018
    Posts:
    9
    Thx
     
  4. Rexx_Norilsk

    Rexx_Norilsk

    Joined:
    May 22, 2018
    Posts:
    9
    The problem was solved, I guarded the shader in unicode without a signature (1200). Changed to unicode with signature (65001)
     
  5. zicrus

    zicrus

    Joined:
    Jun 14, 2020
    Posts:
    3
    What does it mean to guard a shader in unicode, and how do I do it? I have the same problem.