Posts: 8
Threads: 3
Joined: Jan 2023
Reputation:
0
The documentation how to activate the burst solver is still stating rather old version numbers it seems. I try to get it running in 2023.1 but there Burst is quite advanced and the collections package does not contain needed types anymore so there will be many compile errors.
How can I get the Burst backend properly activated in the new Unity and Burst versions?
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
21-02-2023, 08:41 AM
(This post was last modified: 21-02-2023, 08:43 AM by josemendez.)
(20-02-2023, 09:33 PM)ImpossibleRob Wrote: The documentation how to activate the burst solver is still stating rather old version numbers it seems. I try to get it running in 2023.1 but there Burst is quite advanced and the collections package does not contain needed types anymore so there will be many compile errors.
How can I get the Burst backend properly activated in the new Unity and Burst versions? Hi there!
I'm aware of this, working on an update. Latest Collections package version has replaced UnsafeList with a generic version, and changed the type restriction for generic containers.
Open up NativeMultilevelGrid.cs in your project, and replace the Cell<K> struct with this one, which uses UnsafeList<T> instead of UnsafeList:
Code: public struct Cell<K> where K : unmanaged, IEquatable<K>
{
int4 coords;
UnsafeList<K> contents;
public Cell(int4 coords)
{
this.coords = coords;
contents = new UnsafeList<K>(4,Allocator.Persistent);
}
public int4 Coords
{
get { return coords; }
}
public int Length
{
get { return contents.Length; }
}
public void* ContentsPointer
{
get { return contents.Ptr; }
}
public K this[int index]
{
get
{
return contents.ElementAt(index);
}
}
public void Add(K entity)
{
contents.Add(entity);
}
public bool Remove(K entity)
{
int index = contents.IndexOf(entity);
if (index >= 0)
{
contents.RemoveAtSwapBack(index);
return true;
}
return false;
}
public void Dispose()
{
contents.Dispose();
}
}
In the same file, change the declaration of NativeMultilevelGrid to:
Quote:public unsafe struct NativeMultilevelGrid<T> : IDisposable where T : unmanaged, IEquatable<T>
Any other "the type <type> must be a non-nullable value type along with all fields at any level of nesting" errors that pop up are solved the same way: changing generic constraints from struct to unmanaged.
This should allow the Burst backend to work with the latest Collections package versions. Let me know if I can be of further help,
kind regards
Posts: 8
Threads: 3
Joined: Jan 2023
Reputation:
0
Thanks for the fast response! Highly appreciated. I did the changes but some errors still remain. I am now on 2023.1.b5, Collections 1.2.4, Burst 1.8.2 and Mathematics 1.2.6. The compile error I get is
Code: Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(87,16): error CS0246: The type or namespace name 'NativeParallelHashMap<,>' could not be found (are you missing a using directive or an assembly reference?)
What can I do about this one? Thanks a million!
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
28-02-2023, 11:38 AM
(This post was last modified: 28-02-2023, 11:39 AM by josemendez.)
(27-02-2023, 10:22 PM)ImpossibleRob Wrote: Thanks for the fast response! Highly appreciated. I did the changes but some errors still remain. I am now on 2023.1.b5, Collections 1.2.4, Burst 1.8.2 and Mathematics 1.2.6. The compile error I get is
Code: Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(87,16): error CS0246: The type or namespace name 'NativeParallelHashMap<,>' could not be found (are you missing a using directive or an assembly reference?)
What can I do about this one? Thanks a million!
Hi,
NativeParallelHashMap is not used in Obi at all.
Line 87 in NativeMultilevelGrid.cs (as downloaded from the asset store) declares a NativeHashMap, not a NativeParallelHashMap. Not sure how NativeParallelHashMap has ended up there, but replacing it with NativeHashMap should do the trick.
kind regards,
Posts: 8
Threads: 3
Joined: Jan 2023
Reputation:
0
This is strange indeed. It might be the Unity API Updater which changed the signatures but I have no comparison to the original package right now. I changed it and the error is gone. Now just two errors left:
Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(72,29): error CS1929: 'UnsafeList<K>' does not contain a definition for 'IndexOf' and the best extension method overload 'MemoryExtensions.IndexOf<K>(ReadOnlySpan<K>, ReadOnlySpan<K>)' requires a receiver of type 'ReadOnlySpan<K>'
Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(75,21): error CS1929: 'UnsafeList<K>' does not contain a definition for 'RemoveAtSwapBack' and the best extension method overload 'ListExtensions.RemoveAtSwapBack<K>(List<K>, int)' requires a receiver of type 'List<K>'
How should these be changed?
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
28-02-2023, 03:12 PM
(This post was last modified: 28-02-2023, 03:13 PM by josemendez.)
(28-02-2023, 02:51 PM)ImpossibleRob Wrote: This is strange indeed. It might be the Unity API Updater which changed the signatures but I have no comparison to the original package right now. I changed it and the error is gone. Now just two errors left:
Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(72,29): error CS1929: 'UnsafeList<K>' does not contain a definition for 'IndexOf' and the best extension method overload 'MemoryExtensions.IndexOf<K>(ReadOnlySpan<K>, ReadOnlySpan<K>)' requires a receiver of type 'ReadOnlySpan<K>'
Obi\Scripts\Common\Backends\Burst\DataStructures\NativeMultilevelGrid.cs(75,21): error CS1929: 'UnsafeList<K>' does not contain a definition for 'RemoveAtSwapBack' and the best extension method overload 'ListExtensions.RemoveAtSwapBack<K>(List<K>, int)' requires a receiver of type 'List<K>'
How should these be changed?
Note that beta Unity versions are not officially supported by Obi.
According to the documentation, UnsafeList<T> does have IndexOf and RemoveAtSwapBack methods in Collections 1.2.4:
https://docs.unity3d.com/Packages/com.un...___0____1_
https://docs.unity3d.com/Packages/com.un...ist-1.html
Not sure why these errors are popping up, I'd suggest raising a question in the Unity forums regarding the Collections package and UnsafeList<T> support.
Posts: 8
Threads: 3
Joined: Jan 2023
Reputation:
0
I have a suspicion what the reason is. I just installed Obi into a fresh 2022.2 project and that worked. Then I copied the critical file 1:1 into the 2023 project and voila, it works. It seem when installing Rope into a 2023 somewhere along the way the API is updated in the file and is done so in a way that breaks the package. Now I am all set! Thanks a lot.
Posts: 1
Threads: 0
Joined: Jul 2023
Reputation:
0
(28-02-2023, 03:12 PM)josemendez Wrote: Note that beta Unity versions are not officially supported by Obi.
According to the documentation, UnsafeList<T> does have IndexOf and RemoveAtSwapBack methods in Collections 1.2.4:
https://docs.unity3d.com/Packages/com.un...___0____1_
https://docs.unity3d.com/Packages/com.un...ist-1.html
Not sure why these errors are popping up, I'd suggest raising a question in the Unity forums regarding the Collections package and UnsafeList<T> support.
I'm getting this same error in Unity 2022.3.4, which is not beta...
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
13-07-2023, 06:33 AM
(This post was last modified: 13-07-2023, 06:54 AM by josemendez.)
(13-07-2023, 06:26 AM)Oliran Wrote: I'm getting this same error in Unity 2022.3.4, which is not beta...
The error has to do with the version of the Collections package, not Unity. I was just pointing out a different issue to OP since he was having problems with NativeParallelHashMap possibly related to Unity 2023 beta: that betas (regardless of version number) are not supposed to be used in production, hence not officially supported.
Open up NativeMultilevelGrid.cs in your project, and replace the Cell<K> struct with this one, which uses UnsafeList<T> instead of UnsafeList:
Code: public struct Cell<K> where K : unmanaged, IEquatable<K>
{
int4 coords;
UnsafeList<K> contents;
public Cell(int4 coords)
{
this.coords = coords;
contents = new UnsafeList<K>(4,Allocator.Persistent);
}
public int4 Coords
{
get { return coords; }
}
public int Length
{
get { return contents.Length; }
}
public void* ContentsPointer
{
get { return contents.Ptr; }
}
public K this[int index]
{
get
{
return contents.ElementAt(index);
}
}
public void Add(K entity)
{
contents.Add(entity);
}
public bool Remove(K entity)
{
int index = contents.IndexOf(entity);
if (index >= 0)
{
contents.RemoveAtSwapBack(index);
return true;
}
return false;
}
public void Dispose()
{
contents.Dispose();
}
}
let me know if that helps,
kind regards
|