Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TriceHelix/GenericBurstJobs
Support for Generic, Burst compiled Jobs through automatic code analysis and generation
https://github.com/TriceHelix/GenericBurstJobs
burst-compiler code-analysis unity unity-editor
Last synced: 3 months ago
JSON representation
Support for Generic, Burst compiled Jobs through automatic code analysis and generation
- Host: GitHub
- URL: https://github.com/TriceHelix/GenericBurstJobs
- Owner: TriceHelix
- License: bsd-3-clause
- Created: 2023-06-08T11:02:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-28T15:31:42.000Z (10 months ago)
- Last Synced: 2024-04-23T02:40:50.578Z (7 months ago)
- Topics: burst-compiler, code-analysis, unity, unity-editor
- Language: C#
- Homepage:
- Size: 38.1 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-unity-open-source-on-github - GenericBurstJobs - Automatically register generic job structs with Burst Compiler (Static Code Analysis)
README
# Generic Burst Jobs in Unity
### Support for generic, Burst compiled Jobs through automatic code analysis and generation
Requires Unity 2020.3 LTS or newer.---
#### Installation (via Package Manager)
* Select "Add package from git URL..."
* Enter `https://github.com/TriceHelix/GenericBurstJobs.git#upm` and click "Add"
* Done!Additional Unity dependencies (these will be automatically installed):
* Unity.Burst (1.8 +)
* Unity.Collections (1.5 +)
* Mono.Cecil (1.11 +)
* Newtonsoft.Json (3.2 +)---
#### Usage
The settings are located at `Project Settings > Generic Burst Jobs`. There you can manually run the source generator, change its output destination, and more. By default, the generator will run automatically when the Player application is built.
During code analysis, any job structs marked with `Unity.Jobs.BurstCompileAttribute` that contain generic parameters will be tracked. For each unique instance of these structs the source generator creates a corresponding `Unity.Jobs.RegisterGenericJobTypeAttribute` in the output script. It works even through several layers of generic parameters, where some may belong to a class and some to a method. As long as all generic arguments of the job structs can be inferred at compile time, they will be registered.
The code analyzer ignores all code that is not part of [Unity's default scripting assemblies](https://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html). To enable analysis of an external assembly, simply add this attribute to one of its scripts: `[assembly: TriceHelix.GenericBurstJobs.ContainsGenericBurstJobs]`
You can also exclude specific job structs or analysis of the default assemblies by utilizing `TriceHelix.GenericBurstJobs.DisableGenericJobRegistryAttribute`.
---
#### Limitations
* Your generic job structs, aswell as any types which the struct is nested in, must be marked as `public`. Generic arguments for these jobs naturally have the same requirement.
* Analysis is affected by code stripping. If the compiler omits sections of code that contain references to generic job structs, they will not be registered. This is because the tool analyzes the compiled IL instead of your source code, rendering them undetectable.
* This tool is far from perfect and may not always provide flawless results. However, well written code will usually not be affected by this. If you have suggestions on how to improve code analysis, encounter a bug, or have any questions, feel free to open an issue or pull request!