Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Bug ComputeShader doesn't work correctly in AssetBundle

Discussion in 'Asset Bundles' started by HuangJianXiaoNiu, Jul 26, 2021.

  1. HuangJianXiaoNiu

    HuangJianXiaoNiu

    Joined:
    Jan 6, 2021
    Posts:
    1
    the project I've tested it works in Editor or Mobile Devices when the ComputeShader doesn't in AssetBundle.
    Attach a script using this ComputeShader in a scene or loading by Resources.Load is perfectly worked. but when I build AssetBundle. it doesn't work anymore.

    I've tested in these situations in unity 2019.4.16f1 and unity 2020.3.11f1

    Situation 1: Assetbundle file with a scene and this ComputeShader.
    Situation 2: Assetbundle file with a scene and another assetbundle file with this ComputeShader.

    both situation doesn't work correctly.
    when I call ComputeShader.FindKernel, it always throws ArgumentException: Kernel 'CSMain' not found.

    code below:
    Code (CSharp):
    1. string csf = Path.Combine(Application.streamingAssetsPath, "computeshader.ab");
    2. AssetBundle ab = AssetBundle.LoadFromFile(csf);
    3. ComputeShader _ComputeShader = ab.LoadAsset<ComputeShader>("computeshader.compute");
    4. ComputeShader _Instance_ComputeShader = Instantiate(_ComputeShader);
    5. int Kernel = _Instance_ComputeShader.FindKernel("CSMain");    //throws the exception in this line.
     
    orjansolli likes this.
  2. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    318
    Can you file a bug report for this issue?
     
unityunity