Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Burst for standalone players

Discussion in 'Entity Component System and C# Job system' started by xoofx, Jul 10, 2018.

  1. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    54
    Hello,

    As part of the 2018.2 release of Unity, we are pleased to release an official preview of the burst package with support for standalone players (i.e AOT mode of burst) which is only working with 2018.2+

    This version `0.2.4-preview.20` is now accessible from the package manager:

    upload_2018-7-10_15-55-0.png

    User Documentation

    There is a documentation available through the burst package. This is an early preview. We expect to give more insights on how to better use burst to improve the performance of your games.

    Support for standalone players

    When building a player, burst will compile a single dynamic library for all the burst jobs in your game. Depending on the platform, the dynamic library will be output to a different folder (on Windows, it is in the path `Data/Plugins/lib_burst_generated.dll`)

    This library will be loaded by the Job system runtime on the first job compiled by burst.
    The settings to enable the compilation are controlled by the Jobs/burst menu, the same way than for the editor.
    In a future iteration, these settings will be moved to proper settings per platform/player.

    Supported platforms

    This release is supporting the following platforms for standalone players:

    - Windows
    - MacOS
    - Linux
    - Xbox One
    - PS4
    - Android (ARM v7 and v8+)
    - iOS (ARM v7 and v8+)

    Note that most platforms using Intel x64 processors should be working quite flawlessly. For the mobile platforms, this is something really new and you might encounter bugs for these platforms. Please let us know by reporting them via the Help menu and select Report a bug.

    Known issues

    We still have a few known issues with this release for standalone players support:

    - Accuracy/Precision are currently not supported
    - The target CPU is currently hardcoded per platform (e.g SSE4 for Windows 64 bits)

    These issues will be resolved in a future release of burst.

    Please note also that the latest release of ECS `0.0.12-preview.8` is not using this version of burst. A new version of ECS will be published in the coming days with the latest burst.
     
    Last edited: Jul 10, 2018
    rizu likes this.
  2. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    591
    FIRST! :p can it be used outside the job system? if so I will test it asap
     
  3. LordDarkon76

    LordDarkon76

    Joined:
    Apr 1, 2015
    Posts:
    21
    Can it be used with the Incremental Compiler? Or does it has any issue ?
     
  4. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    54
    Not for this version unfortunately. There are a few issues that prevented to release this feature in this release. Can't tell exactly when these will be resolved.
     
    sebas77 likes this.
  5. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    54
    Afaik, it should work with it. Burst doesn't work at C# compiler stage but by later post processing compiled .NET assemblies.
     
  6. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    591
    Apparantently I will be the last one to try it :D
     
  7. BernsteinA

    BernsteinA

    Joined:
    Jun 26, 2013
    Posts:
    12
    Is there an ETA on Burst for Nintendo Switch?
     
  8. Loofou

    Loofou

    Joined:
    Aug 22, 2012
    Posts:
    9
    Does it work with jobs outside of the ECS? I successfully used the job system for procedural Generation and now I want to experiment with the burst compiler as well. I added the package and put the [BurstCompile] attribute over a job struct, but it can't compile as it can't find the attribute. The only attribute found is BurstDiscard.

    I'm on 2018.2 and use the incremental compiler and assembly definition files.
     
  9. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    4,084
    Burst can be used without ECS. You need to include the Burst package in the package manager.
    (ECS package automatically includes a dependency on Burst)
     
  10. Loofou

    Loofou

    Joined:
    Aug 22, 2012
    Posts:
    9
    Thanks for the answer, but like I said, I have the package already installed from the package manager. The file is even there in the project browser, but even with including "Unity.Burst" the compiler can't seem to find the attribute. The Editor Tools coming with the Burst package seem to run fine though. I can open the Burst Job Inspector and so on. I simply can't compile any jobs, as the BurstCompile attribute is not recognized for some weird reason. I have the suspicion it might be related to assembly definition files, but I am not sure.

    BC_Issue_01.png BC_Issue_02.png BC_Issue_03.png
     
  11. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    4,084
    If your code is in a assembly definition file then you need to create a dependency / assembly reference to "Unity.Burst"
     
  12. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    3,238
    Any ETA on when the assemblies from packages will be available in the selection menu for references? Right now, in order to add a dependency to Unity.Burst, you have to open the asmdef file in a text editor.
     
    Prodigga likes this.
  13. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    216
    you can drag it from the project folder if you have 2018.2 (under "Packages")
     
  14. Loofou

    Loofou

    Joined:
    Aug 22, 2012
    Posts:
    9
    Ah that makes sense, thank you. I already thought about doing that, but as it didn't show up in the drop down menu, I thought it might not be the case. Thank you very much!
     
  15. bgrz

    bgrz

    Joined:
    Mar 22, 2015
    Posts:
    36
    Maybe add to the documentation that Windows SDK and VC++ toolset has to be installed in order for burst to work in builds.
     
    FlightCrazed likes this.
  16. FlightCrazed

    FlightCrazed

    Joined:
    Aug 1, 2014
    Posts:
    35
    Thanks, and good idea! However, even after installing the sdk and vc++ I still get this error.I am on windows 10, VS2017, Unity 2018.2.2f1 and on Burst 0.2.4-preview.23


    Exception: C:\Users\GreatAce\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.burst@0.2.4-preview.23\.Runtime\bcl.exe did not run properly!
    UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:130)
    UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:73)
    Unity.Burst.Editor.BurstAotCompiler.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) (at C:/Users/GreatAce/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.burst@0.2.4-preview.23/Editor/BurstAotCompiler.cs:215)
    UnityEditor.Build.BuildPipelineInterfaces.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:452)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()





    System.NotSupportedException: Burst compilation for standalone, is only supported with a suitable compiler tool chain. (C++ code builder is unable to build C++ code. In order to build C++ code for Windows Desktop, you must have one of these installed:
    Visual Studio 2010 with C++ compilers and Windows 7 SDK (it cannot build C++ code because it is not installed)
    Visual Studio 2010 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\10.0_Config\InstallDir" in the registry
    Windows 7 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v7.0A\InstallationFolder" in the registry

    Visual Studio 2013 with C++ compilers and Windows 8.1 SDK (it cannot build C++ code because it is not installed)
    Visual Studio 2013 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\12.0_Config\InstallDir" in the registry
    Windows 8.1 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1\InstallationFolder" in the registry

    Visual Studio 2015 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
    Visual Studio 2015 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry
    Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry

    Visual Studio 2017 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed)
    Visual Studio 2017 installation is found using Microsoft.VisualStudio.Setup.Configuration COM APIs
    Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry

    ).
    at Burst.Compiler.IL.Aot.AotLinker.Link(IEnumerable`1 objFiles, String outPath)
    at Burst.Compiler.IL.Aot.AotCompiler.Link(Module module, AotCompilerOptions compilerOptions)
    at Burst.Bcl.Program.Main(String[] args)
     
    Last edited: Aug 4, 2018
  17. uani

    uani

    Joined:
    Sep 6, 2013
    Posts:
    54
    These are the components I installed to remedy above error some months ago:

    upload_2018-8-5_20-41-35.png

    I don't remember the defaults, but perhaps the CLI (command line interface) is also necessary?

    Did you add the IL2CPP Windows build target inside Unitys installer?

    Other than that, try a restart of Windows :|


    @Unity: does posting "internal errors" reported in the console when using Burst help you? Such as :) :( :

    Code (CSharp):
    1. C:\buildslave\unity\build\Runtime\Jobs\Managed\IJobParallelForTransform.cs(32,13): error: Internal compiler error while processing function `System.Void UnityEngine.Jobs.IJobParallelForTransformExtensions/TransformParallelForLoopStruct`1::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)`
    2.  
    3. While compiling job: System.Void UnityEngine.Jobs.IJobParallelForTransformExtensions/TransformParallelForLoopStruct`1<treePartWobbling>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
    4.  
    5. Compiler exception: Burst.Compiler.IL.Syntax.BuilderException: Internal compiler error while processing function `System.Void UnityEngine.Jobs.IJobParallelForTransformExtensions/TransformParallelForLoopStruct`1::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)` ---> System.InvalidOperationException: Unable to find interface method `System.Void UnityEngine.Jobs.IJobParallelForTransform::Execute(System.Int32,UnityEngine.Jobs.TransformAccess)` from type `treePartWobbling`
    6.   at Burst.Compiler.IL.Syntax.ILBuilder.DevirtualizeMethod (Mono.Cecil.TypeReference thisType, Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Syntax.GenericContext& thisContext) [0x00147] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    7.   at Burst.Compiler.IL.Syntax.ILBuilder.Call (Mono.Cecil.Cil.Instruction inst, Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Syntax.ILExpression thisArgument) [0x000c6] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    8.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstruction (Mono.Cecil.Cil.Instruction inst) [0x003d6] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    9.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstructions () [0x00074] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    10.    --- End of inner exception stack trace ---
    11.   at Burst.Compiler.IL.Syntax.ILBuilder.ThrowInternalError (System.Exception ex) [0x0002d] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    12.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessInstructions () [0x001de] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    13.   at Burst.Compiler.IL.Syntax.ILBuilder.ProcessFunctionBody () [0x000b7] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    14.   at Burst.Compiler.IL.Syntax.ILBuilder.Visit (Burst.Compiler.IL.Syntax.MethodBinding binding) [0x00099] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    15.   at Burst.Compiler.IL.ILVisitor.PrepareFunctionInternal (Burst.Compiler.IL.Syntax.MethodBinding methodBinding) [0x00065] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    16.   at Burst.Compiler.IL.ILVisitor.PrepareFunction (Burst.Compiler.IL.Syntax.MethodBinding methodBinding) [0x00000] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    17.   at Burst.Compiler.IL.ILVerifier.PrepareFunction (Burst.Compiler.IL.Syntax.MethodBinding methodBinding) [0x00000] in <a2ed9824c1aa48fdb9ed369837529c5f>:0
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Jobs;
    3. using Unity.Collections;
    4. using Unity.Burst;
    5.  
    6. [BurstCompile]
    7. public struct treePartWobbling : IJobParallelForTransform {
    8.  
    9.     [ReadOnly]
    10.     public Vector3 rotationAxis;
    11.  
    12.     [ReadOnly]
    13.     public float elongation;
    14.  
    15.     void IJobParallelForTransform.Execute(int index, TransformAccess transform)
    16.     {
    17.         transform.rotation *= Quaternion.AngleAxis(elongation, rotationAxis);
    18.     }
    19. }
    edit: every version up to date as of now
     
    FlightCrazed likes this.
  18. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    54
    Hopefully yes :)

    Could you change your method interface implementation to public instead of explicit? (Might not work with the later)
     
  19. uani

    uani

    Joined:
    Sep 6, 2013
    Posts:
    54
    Hi, nice, thank you. Do you mean
    public void I....Execute(…)
    ? This yields error "CS0106: The modifier `public' is not valid for this item"
     
  20. pavelkouril

    pavelkouril

    Joined:
    Jul 22, 2016
    Posts:
    81
    Actually,
    public void Execute(int index, TransformAccess transform)
    , without specifying the interface explicitly.
     
  21. uani

    uani

    Joined:
    Sep 6, 2013
    Posts:
    54
    Thank you, this "did the job": the error is gone.
     
  22. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    355
    I'm getting a lot of errors referring to UnityEngine.Mathf, even after removing all references to Mathf, why is that?