#Why can't Burst read from static variables if we can give them as ref arguments ?

1 messages · Page 1 of 1 (latest)

dim matrix
#

Hello!
I'm wondering something. Why can't we do this (it does an error saying that Burst can't read from non-readonly static variables) :

[BurstCompile]
class Test{
  public static NativeArray<int> someArray;
  
  [BurstCompile]
  public static int Function(){
    return someArray[0];
  }

  public void CallFunction{
    Function();
  }
}

if we can do that :

[BurstCompile]
class Test{
  public static NativeArray<int> someArray;
  
  [BurstCompile]
  public static int Function(ref NativeArray<int> someArray){
    return someArray[0];
  }

  public void CallFunction{
    Function(ref someArray);
  }
}

?
It does the same right? But it's so annoying to have to pass everything with ref 😫

modest meteor
#

it's not the same

#

in second case you pass pointers to data in managed context

#

in first case you try to read managed context in burst

dim matrix
#

Hmm OK but the result is the same, we can access and modify the array 🤔

modest meteor
#

math.pow(value, 2) is also giving same result as value * value. but the way they do it is different