#Burst error

1 messages · Page 1 of 1 (latest)

sweet hare
#

Edit: was a bug that was fixed with restarting Unity.

I'm trying to pass an enum from a struct into a method and it's yeilding a burst hash error:
Burst internal compiler error: System.Exception: Error while generating hash for method references: System.Exception: Error while hashing 0x06000041
I decided to replace the argument with a constant, and I get this error instead:
System.cs(131,13): Burst error BC0101: ... Value cannot be null.

Here is the code causing issues:

ECB.SetComponent(partEntity, new PhysicsCollider { 
    Value = SelectCollider(ColliderType.Sphere, partInfo.Scale, float3.zero, partInfo.Rotation ) 
    });
public BlobAssetReference<Collider> SelectCollider(ColliderType ColliderType, float3 Scale, float3 Offset, float3 Orientation)
{
    switch (ColliderType)
    {
        case ColliderType.Sphere: return stuff
        case ColliderType.Box: return stuff
        case ColliderType.Cylinder: return stuff
    }        
    return stuff
}

(The ECB line of code is the one causing the error according to my second burst error)

In Burst documentation it is shown that I am unable to use enum methods in burst. However, I'm not using any enum methods. Even if a switch case with enums counts as a method, how come that's not where the error is coming from (as far as I can tell).

What am I missing?

past estuary
#

the ecb line of code is the entire method though

sweet hare
#

The ecb code works fine without the selectcollider method

golden nacelle
#

are you burst compiling this method?

#

with direct attribute I mean

sweet hare
#

Yes

golden nacelle
#

then you need to pass struct with args

#

by ref

sweet hare
golden nacelle
#

Allthough

#

I think you are just missusing it

#

and all you need is to just burst compile job struct itself

sweet hare
#

Tried messing around with burst discard but didn't change anything

#

Ill give more detaild tmr, gn

frosty jolt
#

I use enums extensively and have no problem with Burst.

sweet hare
#

Good morning (or afternoon), here is most of the job struct. I've tried to reduce clutter the script as best I could. What am I doing wrong that's screwing up burst? Keep in mind everything here besides the select collider method and the ecb set component line has worked flawlessly before doing this stuff on colliders.

[BurstCompile] 
public partial struct TowerPlaceJob : IJobEntity
{
    [WriteOnly] public NativeArray<sbyte> CurrencyChange;
    [WriteOnly] public NativeArray<byte> Completed;

    [ReadOnly] public NativeArray<TowerPartData> Parts;
    [ReadOnly] public NativeList<TowerPartInfo> TowerParts;
    [ReadOnly] public NativeList<FlatIndex> TowerIndexes;

    [ReadOnly] public long CurrentCurrency;
    [ReadOnly] public Entity TowerEntity;

    public EntityCommandBuffer ECB;

    private void Execute(
        ref TowerPlacementSystemData towerPlacementData, 
        in PlayerUIInputData uiData, 
        in PlayerMouseInputData inputData, 
        in PlayerModificationInputData modifyInputData)
    {
        //shit tonne of if statements
        Place(inputData.MousePositionToWorld, 0);
    }

    private void Place(float3 position, int selectedTowerIndex)
    {        
        FlatIndex towerI = TowerIndexes[selectedTowerIndex];
        NativeArray<Entity> partEntities = new(
            towerI.IndexLength, 
            Allocator.Temp, 
            NativeArrayOptions.UninitializedMemory);
        ECB.Instantiate(TowerEntity, partEntities);

        for (int i = towerI.StartIndex; i < towerI.StartIndex + towerI.IndexLength; i++)
        {
            int TowerPartIndex = i - towerI.StartIndex;
            Entity partEntity = partEntities[TowerPartIndex];
            TowerPartData partData = Parts[TowerParts[i].TowerPartDataIndex];
            TowerPartInfo partInfo = TowerParts[i];

            //Add basic components

            ECB.SetComponent(partEntity, new PhysicsCollider { 
                Value = SelectCollider(ColliderType.Sphere, 
                                        partInfo.Scale, 
                                        float3.zero, 
                                        partInfo.Rotation ) 
            });
           
            if (partData.PartType == TowerPartType.Bearing)
            {
                //Add components
            }
            else if (partData.PartType == TowerPartType.Gun)
            {
                //Add components
            }
        }

        Completed[0] = 1;
    }
    
    public BlobAssetReference<Collider> SelectCollider(
        ColliderType ColliderType, 
        float3 Scale, 
        float3 Offset, 
        float3 Orientation)
    {
        switch (ColliderType)
        {
            case ColliderType.Sphere: return SphereCollider.Create(new SphereGeometry { 
                Radius = Scale.x, 
                Center = Offset });
            case ColliderType.Box: return BoxCollider.Create(new BoxGeometry { 
                Size = Scale, 
                Center = Offset, 
                Orientation = quaternion.Euler(Orientation) });
            case ColliderType.Cylinder: return CylinderCollider.Create(new CylinderGeometry { 
                Radius = Scale.y, 
                Height = Scale.y, 
                Center = Offset, 
                Orientation = quaternion.Euler(Orientation) });
        }

        UnityEngine.Debug.LogError($"Suitable collider not found in enum.");
        return SphereCollider.Create(new SphereGeometry { Radius = 1 });
    }
#

My theory is that I can't use create blob asset references in burst,

#

Burst error

golden nacelle
#

I do that

sweet hare
#

So what's screwing up then?

#

ooh wait, does adding an enum to a struct make it non-blittable?

#

nvm I'm using enums in another struct in literally the same job

golden nacelle
#

Any code inside of job does not matter as long as it's unmanagged

#

All blittable restrictions only apply to function pointer entry point

#

Which is not at your control for jobs

sweet hare
#

So what is causing the error with burst?

#

Can't find anything helpful in the burst error stack

#

besides which job it is coming from

#

just reopened unity and burst error is gone...