Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Compute Shader not found

Discussion in 'Unity 5 Pre-order Beta' started by Todd-Wasson, Nov 19, 2014.

  1. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    This code works fine in Unity 4, but not Unity 5:

    (C#)
    Code (csharp):
    1.  
    2. string shaderName = "CSEulerWasson";
    3.  
    4.         kernalcomputeShaderGas = computeShaderGas.FindKernel(shaderName);
    5.         if (kernalcomputeShaderGas < 0)
    6.             print("ERROR:  " + shaderName + " not found");
    7.         else
    8.             print("computeShaderGas kernal = " + kernalcomputeShaderGas);
    9.  
    10.  
    I get the "not found" error here for some reason in Unity 5 and can't figure it out. It's as though .FindKernal is not working anymore. Do I need to change something here? Has the method changed perhaps in 5? Is this a known problem?

    The compute shader is included in the correct place in the inspector, it's the same as I have it in 4 from what I can see. I duplicated my project folder so I could work in 4 or 5 to test this out. This code is the same in both and seems to be the only problem area I'm having at the moment with 5. The rest of my project seems to work normally, only faster and better looking. :)
     
  2. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Anyone? Has anything changed on the compute shader side of things with Unity 5?
     
  3. Juho_Oravainen

    Juho_Oravainen

    Unity Technologies

    Joined:
    Jun 5, 2014
    Posts:
    42
    There should not be any difference on the FindKernel() func between Unity 4 and 5.

    Are you running in editor or a standalone build? As starters check that Direct3D11 mode is enabled on player settings and that your build target is set to PC standalone.

    Have you tried running the compute shader by using manually a numerical kernel index? Just to verify if the ComputeShader object you have is working at all. E.g. in your case just set kernalcomputeShaderGas = 0; If the .compute file has only one kernel in it, you're guaranteed to hit the correct one by using index 0.

    Btw, do you see any related console warnings or errors? And have you tried reimporting the compute shader (just in case)?
     
    Last edited: Nov 21, 2014
  4. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Sorry for the late reply. Been rebuilding my system and taking some time off.

    This has all been in the editor. I'm installing beta 14 now so will check the rest as you suggested. Thanks for the help. :)
     
  5. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Ok, I'm back up and running. Have checked your things:
    I'm running in the editor. There are no warnings or errors, only the self printed message generated by the loading code in the original post saying my shader kernal is not found. There is only this one compute shader with a single kernal which is index 0 as you said. In player settings -> other settings, Graphics API is set to D3D11 mode. This all was the same as it was in Unity 4 because I just ran Unity 5 on the same folder structure after making a backup for Unity 4 in case 5 wasn't quite up to snuff for my project yet.

    As far as I can see, my compute shader and compute shader script are attached to an "engine sound object" correctly. I've verified that both files are still in the same folder as before, but no luck.

    There's nothing to reimport, this is a shader I wrote that still works fine on Unity 4. It's a real time car engine simulation, gas dynamic driven procedural audio generator:



    I'm using this system in another project where I'm having the problem only on Unity 5 (have tested around beta 9 or 10 through 14 and it's the same). I haven't tried running the program in the video above in Unity 5 though. Maybe I should try that and see if I get the same problem?
     
    Last edited: Nov 26, 2014
  6. Juho_Oravainen

    Juho_Oravainen

    Unity Technologies

    Joined:
    Jun 5, 2014
    Posts:
    42
    By reimporting the shader I meant that in the editor's project tab you'll search for the compute shader file, right click it and select reimport. I'm speculating that perhaps some things have changed under the hood but for some reason it is not automatically reimporting the shader as you open the project the first time in Unity 5.
    If it doesn't help, then I guess you should report a bug with a minimal repro project and let me know the case number so I can take a closer look what's happening there.
     
  7. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Ahha, now that I did the reimport as you said, I get an error:

    Shader error in 'ComputeShaderGasDynamics5_ToddApproach_24MultipleCylinderExhaust.compute': Compute shader compilation had a problem, your compute shader was not compiled correctly

    Perhaps it's something I'm doing in the compute shader itself that's a problem in 5, but not 4? Are you aware of anything that might have changed in that area?
     
  8. Juho_Oravainen

    Juho_Oravainen

    Unity Technologies

    Joined:
    Jun 5, 2014
    Posts:
    42
    Definitely it seems that the compute shader itself contains something that Unity 5 does not like. You can double-check this by creating an empty project in 5 and copying this shader there (should get the same error).

    I can't tell from the top of my head what the exact problem there might be. I'll have to ask around a bit about things changed around the HLSL compiler in general between 4 and 5. In the mean time I suggest you try the double-check as suggested above and report a bug including that minimal project ('Help->Report a Bug' in the editor). Then post the case number here and I'll check what actually happens there.
     
  9. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Thanks for the help again. It may be some time before I get to this, but it looks like I'll have to.

    It's unfortunate that Microsoft buggered up UnityVS in Visual Studio immediately after they bought it. Hopefully they'll get color context back into it and add error reporting so I can go back to fixing things myself again. :rolleyes:
     
  10. Juho_Oravainen

    Juho_Oravainen

    Unity Technologies

    Joined:
    Jun 5, 2014
    Posts:
    42
    Couldn't find any obvious related changes around the shader compiler. It's kinda difficult to find the root cause without a repro ;) So I'll need your problem shader to be able to go forward. When you can, please file a bug with at minimum the shader attached (a small repro project is preferred, but I guess this sort of issue goes with the plain .compute file as well).
    You could of course paste the shader code here as well, but if you wish to keep the code undisclosed, then you should use our bug reporting system...
     
  11. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Thanks. I understand that's the only way. When I get a chance I'll try to do a small repro through the reporting system as you said, then come back here with a case number or whatever it gives you. There's no way I'd post that shader code in the forum. :D