#archived-dots
1 messages ยท Page 10 of 1
example
type: "Asteroid"
name: "Default"
and then I assign blob reference to that entity
aaaand after I load subscene
I have prefab with blob asset reference that points to that "Asteroid" or name "Default"
so if I instantiate it, I always know what prefab it was instantiated from
now if I want to add that prefab to some database
I CreateAdditionalEntity()
and assign Entity reference to it
reference to that main prefab
and then my runtime system loops over those additional entities and adds them to dynamic database
well what i'm doing is fairly simple, but it's just giving me problems at every turn
no blobs needed
i could find a way to not use blobs but there's really nothing wrong with that approach, and when i'm not using subscenes, it works perfectly
in fact the problem isn't even related to the blobs themselves..
there's problem with blob database
it's static
you can't make it bigger
or smaller
GetPrimaryEntity for the prefab is returning the wrong Entity
did you reference your prefab?
i'm not making it bigger or smaller i'm building a blob, as i say that's not even the issue
at conversion stage?
because that's normal sadly
what i mean it's different to the runtime entity
yeah it references and creates the prefab, it just doesn't return the correct primary entity for this particular prefab, whereas for the other prefab it does return the correct entity
Entities are remapped only if you assign them to Components
so if you assign them to blob
they won't be remapped
because if you convert in runtime
you create entities in actual World
subscene conversion is done inside it's own conversion worlds
at least that's what I assume
could be wrong
i wish i could demonstrate without flooding the chat will all of the code
post the file :)
i mostly create blobs at runtime start.
pretty easy and you just have to put them in your own blobassetstore which needs to be disposed
well i could but that then introduces problems with the order because the subscene is loaded after systems OnCreate
so i'd need to create a system which looks for subscene to be loaded, and then builds the blob in OnUpdate
and then tell my other systems to wait until this is done
why OnUpdate
or, manually create/add my systems only once subscene data is loaded
OnStartRunning works too
hmm
i'll ask something else. why blobs?
but I feel like you overcomplicate things xD
is that guarenteed to be after the subscene is loaded though?
kinda going in circles tbh
i think i'll just not use subscene, and avoid all of these problems
๐
i'm going to give it one more shot
but i'm not happy about it ๐
so, GetPrimaryEntity is clearly not working as expected inside my subscene
the thing is, the exact same code works perfectly outside of subscene, this is the annoying part
i literally take my authoring object, out of the subscene, and my blob is built perfectly and as expected
sir, it's because you wrap it in a type
that doesn't get remapped
it's as if you grabbed index and version from Entity
and expected them to change after conversion
Entity references are remapped once subscene is loaded
shouldnt be storing entities inside of blobs
why not?
i get what you're saying here, and it makes sense, but it does work outside of the subscene, during conversion
i'm literally just storing a struct containing an Entity field inside a blob
welp
you are literally just storing int2
in a blob
and you expect it to be valid entity reference xD
exactly
no the point is that it works fine, during conversion, when not in a subscene
because during conversion
you create blob
in actual world
so the entity reference you put in there
is valid for this world
but subscene world only exists during conversion
that's why entities must be remapped
and it's done on components
there's no issue with storing the GetPrimaryEntity to the blob struct during conversion and then it failing to remap correctly, if it's not in a subscene
you can just store all your entity references in component
that creates blob in runtime
because this way
this component will be remapped with valid references
as issue said entities can be remapped but when stored inside of blobs they wont be
yeah i get the concept, i just don't get why it does work okay when not in a subscene
i'm guessing it could be what you're hinting at above
yeah that
that makes some kind of sense
think of them as relative and absolute references
subscene references are relative to subscene
runtime conversion references are absolute
the prefabs once converted do still exist within the subscene
so when you load subscene and read references as absolute you are certainly getting an invalid result
so i guess by my logic, that relative reference inside the subscene's Convert would resolve in exactly the same way as when it's not in a subscene
if you serialize it
but i guess in the case where, a subscene creates it's own conversion world it possibly makes some kind of sense
tbh, i'd still expect it to work as is
conversion that is not in a subscene still uses it's own conversion world, this is why i don't get there's a difference
can you actually check?
read dstWorld
in your runtime conversion
and compare
to your actual game world
is it same reference?
right so i'm guessing it isn't
is, sorry
but in subscene, dstWorld is not the same
yep
thus references are invalid
when you wrap them
in blob
store them in component instead
and they will be valid
because they will be remapped during subscene loading
man, I just realised
still infuriating though
that Unity has entity remapper
and they didn't expose it
sadkek
would make creation of save/load so much easier
why the desire to store in blobs anyway? I sort of get it when I want to do something one way and it doesnt work, its sometimes hard to let go
I don't get it either
in fact
you could probably just use chunks as your database
and use temporary queries
to get all lists of prefabs
well why not use blobs?
hehe
they are specifically for static data
well the whole no remapping thing ๐
and your prefabs aren't
yeah but entities themselves arent necessarily static
well the idea is, once the prefabs are created by conversion, they are static at least until they are destroyed
so all i'm doing is storing my unit data ( health etc etc ) along with the prefab entity
query.GetNativeArray()
if it's static
you will have persistent array
of any valid component you want
health, entity, etc
I wouldn't agree
say i have 10 types of unit right..
each one is basically similar, but have different health, etc etc
i could create an entity/component setup just to store all of those templates yeah
or, i could just store it in a blob
i don't get the problem
it's literally just a struct of all of the unit data, that i can dip into when i'm spawning a unit
well, the obvious problem is that you create blob at the wrong time xD
spawn system says 'ok i need to spawn x unit', it then dips into the blob and pulls the data for x unit, gets the prefab entity, gets the health, etc, and spawns it
there's not a separate prefab for each unit
there's lets say a base model prefab, which applies to all units
Btw does anyone here knows any good quadtree library ?
All i find are pretty outdated and not "high performance"... Wanted to use one in tie with dots basically
and then there's different attributes for each unit type
ah
I plan to have spawn pipeline for this kind of thing
where I could have simple
Spawn method
with prefab name
and settings struct
in which I define my desires hehe
it's really not difficult, complicated or unusual
it's an analogue of using ScriptableObjects in mono
but as you said, i'm basically creating the blob at the wrong time, in the case of subscenes, which was my whole frustration
subscenes seem to be buggy, they don't update until you've coaxed them in multiple ways to do so, they seem determined to cause problems, and now the blob problem comes along ๐
i don't often get annoyed, but when i do ๐
well
the blob thing was of course my problem, not a problem with subscenes themselves
but after several attempts and constantly being tripped up by subscenes, i was a tiny bit annoyed
runtime conversion is slow
it is
i mean i get it, i understand the benefits of using subscenes etc
that's literally why i decided ok i have everything working, i'm going to convert it to a subscene
the way i did this previously was probably more in line with what you're suggesting, and i did use a subscene for the prefabs
so i had an authoring component inside the subscene, which had a list of all of my GameObject prefabs
i then created a single prefab holder entity, and added a dynamic buffer, with data on my prefabs etc
i'm pretty certain the buffer also contained references to the prefab entities
buffers get remapped
so i think the problem in this case is exactly as you're saying, inside the blob they're not getting remapped
whereas inside a component or buffer yeah they do
ComponentType has a field HasEntityReference
pretty sure for this exact reason, hehe
i'll ask again. why blobs! what do you gain?
i think for simplicity, i'll just switch back to that, but inside the buffer i'll hold a reference to the prefab entity alongside a blobassetreference which will hold the actual data for each unit type
Trying to install the Jobs package by itself but get this error immediately.
I'm using unity 2020.3.12f1
i just figured it's what they're for.. basically to convert my scriptable objects ( which can be created/edited in the editor ) to a storage that i can dip into from my spawner system
unit data makes total sense, i just don't get the need for an entity in there
and I'm pretty certain you could split that
simply just to hold the prefab entity that the spawner will spawn
again, it's just when i'm creating the blob, because the entity isn't remapping
What version do I need?
the idea of storing the entity in a blob in itself i think is fine
alongside the rest of the unit data
i don't agree with that.
a spawner can consist of a prefab + blobAssetReference
it doesn't have to be all in the blob
of course it doesn't have to be
anyone?
but why split that up
because a blob is not designed for entity remapping ๐
or any kind of dynamic data
Error happens upon trying to install any of these previous versions too
well exactly, i was building at runtime, which was fine, it worked perfectly
i'm confused, i thought you had the problems at conversion stage?
yes basically, it worked perfectly when building at runtime
but once in a subscene, not
guess not.
because the subscene wasn't remapping to the runtime entities i guess
i think this:
#archived-dots message
@narrow field can you paste the contents of your package manifest json somewhere?
use 2020.3.30+
Either upgrade your unity version or use 0.11 Jobs.
On the topic of blogs, I haven't found a reason to use any personally. If I could encode textures, maybe, but currently I just have all may data in components.
It helps that in 2d, all the meshs are very simple
Got it installed now, however it seems I cannot use Unity.Mathematics? It's appears in the package manager as installed however I cannot use it in any of my scripts
https://docs.unity3d.com/Packages/com.unity.mathematics@1.2/manual/index.html trying to follow the documentation that has an example that has "using static Unity.Mathematics.math;" but that STILL doesn't work.
using static is for later versions of unity I believe
Doesn't change anything
I'm literally just following what the official documentation on my current version is doing
do you have Assembly Def?
If you have one of these defined, you need to add Unity.Mathematics to the Reference list.
I've gotta say, this is one of the most beautiful burst outputs I have ever seen.
how does it look in c#?
It's the one line at the start of that loop.
In an ECS for each loop, how would I go about getting entities WITHOUT a certain tag? Thanks.
.WithNone<Tag>()
Thanks Korn!
Ive gotta hand it to the 3 guys working on dots physics over at unity, combining 4 AABBs into a single node is ingenious.
The issue is that from what I can tell, everyone working on DOTS physics were either reassigned or fired. The last response from a DOTS physics programmer on the forums was during the 0.17 days and 0.50 brought no new changes to the API.
I don't think you're correct
I'm just saying, during the ~1 year between 0.17 and 0.50, nothing was changed in physics beyond the bare minimum to continue functioning.
I think it got "deprioritized" like DOTS animation and audio.
a shame, physics could need some love. but due to the big code changes further extensive development was halted
dots physics is one of their best releases without much patching needed
Trying to fix a bottleneck in my system. I'm trying to set a bunch of points in a nativearray and then setdata on a computebuffer using the nativearray. Issue is that I'm using 1 million points and currently most of the CPU frame time is going to SetData on the compute buffer
If each point is a float3, that's 12 MB of data being transferred to the GPU. I dont think you're gonna get any faster unless you reinvent electronic engineering.
I'm using half3s
Then that's 6 MB, not much better.
You need to get really creative in packing bits or space it out over multiple frames. 1M points is a lot of data being transferred.
Modern video games have thousands of MB of textures in the GPU because they only transfer the data once at loading, or stream it in over multiple frames. If you're trying to transfer 1M points every frame as update, that's physically impossible.
I recommend transferring in the source data at startup to the GPU and computing whatever you need in a compute buffer. Dont try computing things in a Job and then transferring it over.
You can try using some time in the cpu end to tightly pack the data and send it to the gpu, and then also take some time on that end to unpack them. You'd be transfering less bits, but I don't know if you'd manage to compress it that much, and then, compression also adds some overhead. But you can check some articles about demo scenes, those guys really know how to compress things. For example, check Inigo Quillez's website.
the guy with the username something 'havok', was he one of the unity devs? i was never quite sure when reading his replies if he was a havok guy helping them with that or an actual unity dev
Havoc is an intel physics system. That dev was loaned from Intel to integrate the havoc API into dots but has since disappeared from the face of the forums since the release of 0.17.
yeah that was what i kindof assumed
Also, I'm not updating the entire nativearray per frame, but I'm having trouble figuring out how to only set a certain amount of data in the computebuffer
I tried using BeginWrite/EndWrite but it ended up not working and I wasn't sure why (yes I had it set to ComputeBufferMode.SubUpdates)
Subupdate, in my experience, seems very unreliable.
Otherwise, set data seems pretty self explanatory
@viral sonnet How does one go and find where a component is being changed for debugging change filters?
wdym?
I have a change filter on a job (the chunk.HasChanged(Comp, Version)) and it's being activated despite nothing moving. I need to find out why.
is smth acessing component data of this chunk?
Apparently yes. And I need to find out what is.
just search for
GetComponentTypeHandle();
with type of what you think is the reason
oh boy, only a good IDE will help here. comb the code for access with writes
oh fun
what also helps, some job that will debug.log when the comp has been changed and then disabling systems one by one. when the line stops outputting you're nearly there
Well, I dont think I need this change filter anyways. There's gonna be one BVH for the entire world so if anything moves, it gets rebuilt.
riggt, the unity one. yeah no change filter needed
It's not that expensive, only 1.5ms for 10,000 entities. Scales linearly though so it's pretty bad at 50,000 since I use a better splitting algo than unity. If I were to use the same split as Unity's I get similar 0.75ms performance for 10,000.
Yea, there's refitting and incremental reconstruction of the BVH tree but.... is it really needed?
do you need that much or just optimizing for optimizations sake
Stress testing. I dont know if I'm gonna make every bullet a circle body or just a raycast line segment.
bullets shoukd be raycasts
They might be slow bullets though
i think even in that case raycasts are more performant
Probably, hrm. Now with a BVH, I can get back to actually programming physics.
Yea. Raycasts is probably the way forward. I dont want bullets to be colliding with themselves and I havent implemented a collision filter yet.
oh yeah saw this the other day relating to 2022.2
There are also some exciting changes to support newer Burst versions, e.g. the groundwork to switch Burst off dynamically when you set breakpoints with a managed debugger
Imagine using a debugger. Debug.Log is enough for the honest down to earth coder.
At least assert works in burst.
I think burst is in a great position right now. I cant think of anything that it can improve on atm. I dont have that many methods so I havent hit the iteration speed wall let.
my only request is always compiled burst jobs but break points switching to mono my remove my need for that
A stretch goal maybe would be a hover over tooltip on the inspector over all the commands. A small blurb when hovering over an operation that says what it does, what the throughput is. The stuff that can be found on the Intel Intrinsics database so I dont need to keep going back and forth to see if any improvements actually improved anything.
oh inspector could have a bunch of improvements
yeah burst inspector is pretty bare bones
And trimming out all the unity code as well
amd uprof made it right. it shows the c# lines on top and in the bottom window the assembly. when you click on a c# line it highlights the corresponding assembly lines
exactly, there's soooo much bloat
great to be able to see changes between compiles
so i can stop copy/pasting it into notepad++
then i need a simple ctrl+f
Yea, I saw those screenshots but I think short of coding their own IDE, the inline yellow comments in the inspector is the current best they can do.
oh yeah! change highlights between compiles. mmhhh ๐
I got a dead discord that I post my before and after screenshots for comparison.
you what mate? ๐ do you run on a terminal or smth? ๐
And maybe hints about why this loop couldnt be unrolled or vectorized. What's blocking the magical purple VP from occurring.
I'm sure they've got their own. There's little they can actually improve with the compiler IMO.
Like the method hierarchy is currently just a flat list. There needs to be some foldering and ordering by file.
it's at a really good place already
And maybe a burst option that allows a method to be hidden in the burst inspector list (with an additional toggle in the inspector to show the hidden methods). That way unity can hide all of their shipped methods and the inspector can focus on the user's code.
i maybe have a dumb question about float precision. if i have a high number, like 1.0e52 and add +1 to it e52 times. is the result 2.0e52?
i have test it with e10 but the loops is too big lol
Not possible:
but yeah you are way past max float
oh sorry, ignore the limit. take e31 or smth in range
This question is possible with double.
point is, is something that high even precise enough to pick up such a small number
at 16.7million (16e6) your precision is 1
anything above that and you're precision is worse than 1
so adding 1 does not guarantee changing the value
so at one point if the numbers are big enough i'd need to store 2 values to even catch an increment of 1.
one variable just for precise accumulation
one to store the big number
anything above 16,777,216 you need doubles for accuracy for 1 increments
but if you're goal is int accuracy, why not just use an int ^_^'
because it doesn't go that high ๐
incremental games struggle with data types ๐
Use a decimal then.
just because float can go that high, i don't consider it useful for anything above about 100k if you care about accuracy
simple example. you have a metric, you get +1 every 0.1 second (or something very small). you want to accumulate this. now the game is played for a year 24/7. it shouldn't stop working at some point is what i'm thinking about.
I'm pretty sure decimal max value, or the value in which precision starts being an issue, is longer than the current age of the universe.
incremental games often go over the double limit and need custom implementations
ah
that's unlikely
just reduce the incremental factor then
Pull a zimbabwe and chop off a few of the digits on the increments and then restart the count.
if you increment +10/second
it will take
5.696113e+299
years
to exceed double max value
it will stop working long before that. the above screenshot shows a double precsion of 1 with e15 or smth that I counted
yeah so
the max value of 9007199254740992 for 1 precision
is 285,580,191 years if incrementing +1/second
but yeah, at some point the increment has to get higher otherwise it's unrealistic to take any meaningful effect
haha, yeah if you put it like that ๐
as I said in the opening. maybe a dumb question ๐ anyway, the precision table helped to wrap my mind around it where it starts breaking down
i have that table saved
it's super useful
especially when deciding if i want to use half
though its missing a few steps not hard to do the maths yourself
yep, saved it too now. i remember you posting this some time ago
i want to add more stat data types now. i already have half and float. need double too and bring it all together
double for health and damage amount is super useful
at least as option
and i need to find out how good burst is with jump tables. could get somewhat annoying to first get the data type and then the corresponding array of values
ah right i remember. yeah pretty cool. so you had an extension or how did you determine which stat is which data type?
this is for modifiers
add is always short (+5 int)
increased/more is always half (30% increased damage etc)
the actual final stat is stored in an int always
i don't think it'd be healthy for a game to have a single stat modifier 8000% increased
๐
nearly always going to be <1
depends on the type of game
i was struggling to find any example
those korean grinders i played went nuts with numbers
8000% is still only a value of 80
which still has 0.5 precision
and at those crazy scales you don't need fine precision anyway
also personally i hate games with stupid numbers so i dont need to worry about that ๐
eh, most shit the bed with bad number formating ๐
WoW did a huge stat squish because numbers were in the million range.
and they were sooo happy when numbers were again in the 1k range
i just thought. why not show 1234k? readable. good enough
but there are other reasons and those are all solid
it just went on for a very long time like this
and it always ended in the same way every expansion so everytime they needed a stat squish which also means numbers are totally relative and don't mean anything over the course
which makes me sad
Dynamic buffer accessor is so big. Adds nearly 400 bytes to the thread's stack. I can't fit my own stackalloc in there.
that's why i always saw such a performance decrease. what are those 400 bytes?
i only see 20 bytes + 41 from safety
and how did you see how much it puts on the stack?
With and without
300 bytes, not 400. Still, big.
Unity stackalloc 256 + 512 in their AABB overlap test. I just move mine to a native array. Not like I'm doing any vectorization on the actual nodes.
For comparison, this is 456 bytes.
haha my biggest job has 936 in its execute
so methods that are inlined don't need an additonal stack alloc, right?
If they're inlined, they get added to the method's stack. Most of the time, that's what you want but if you have a really big but short lived manual stackalloc, you want to have it NoInlining so it gets cleared at the method's return.
i see thanks
There's one stack alloc per method (not inlined) and all of them summed up equals the thread's stack alloc. Which is finite so dont use too many variables.
Too many as in stackalloc int[512] like what unity is doing...
ok i see, i haven't accounted for that the memory is just moved to the parent method. what about variables that are calculated in the main method and then used as parameter for a sub-method. does this occupy 2 times the memory or will the method just read from the register of the main method?
multiplied by 4 because of int
Probably depends on the comp running it as well. My shittop dies at 256 max for that screenshot bove.
wait, is my math off. what cache size did you take? i get 6,25% for l1 with 32.768
ah ok
1mb = 1024x1024=1,048,576 bytes
he's allocating 512x4 bytes
2048/1,048,576 = 0.001953125 or 0.1953125%
hopefully my math checks out ^_^'
(I originally missed the x4)
so uhm, how does the stack size differ from L1/2/3 cache?
stack is just a section of main memory that employs a well understood convention of growing down and automatic cleanup
oh man, why did i assume stackalloc puts data on l1 ... ๐
stack is stored in ram but it has a high probability of matching in cache
And if you shift the pointer off stack, you get the dreaded stack overflow!
i was a master of stack overflows when i learned programming in c++. those damn recursive learning tasks ๐
They called you the great flooder
I used to effect magical memory optimizations back in the day by editing the default link script to shrink the stack size from 1mb to 64k
those were the times when you had to restart your pc on some stack overflows or wrong pointers. and don't get me started on the dos IDEs. Borland C++ was it called
what exactly is burst doing to make my code run faster?
because I get very little performance gains using it. Infact im seeing an overall loss in performance just having dots installed before adding any user code
my editor stays at 90 fps vs the 600ish i would see before
Using hybrid renderer?
Thats why. It has quite a bit of overhead rendering nothing. That's why I dont use it.
How do you render then?
is unity working on a better renderer?
Yes. In 2022.2, it's looks to be completely overhauling HR to be far better.
short answer, yes
Awesome
hybrid renderer will be in version 3 (soon)
It is in version 3 right now, just DOTS will use it (soon)
As for Entities, the other half of DOTS, it's a storage medium. It shouldn't impact your FPS any more than using List<>s or Dictionary<>s
What burst does is translate the C# code into direct machine intrinsic operations. Making it faster and better.
Well, C# IL code.
so its basically an il to native jit compiler
AOT in build. JIT in editor. But yes.
not needed. turn off safety checks and leak detection. there's little difference then to builds
at least when it comes to burst jobs
Then thats not the issue I already did this
maybe dots not optimized for cpus that make use of efficiency cores?
I got one of the new i7s with 8p+4e cores
Dots without HR is basically a pile of arrays that's a bit flexible about typing. It doesnt care what the processor architecture it's running on.
oh i figured it was doing more than that behind the scenes
when you mention performance issues. best to just post a screenshot of the profiler here with the timeline
All the fancy things are mimicking dynamic typing of the arrays. You can roll your own Entities entirely without any packages. NativeArray is a core struct.
Im just talking about how if you go from a blank unity project with no code in it then install dots and press play your fps is significantly lower than before.
Is native array just a wrapper around T**?
dots is quite a few things. as we already mentioned, HR is not that great
but you also don't need HR really to do something with burst, jobs and entities
entities jobs and burst installed alone reduces fps in the editor in a blank project by 50 fps for me
thats with safety checks and leak detection turned off
thats with a urp project
there's something else going on. burst and entities itself don't do anything
The default systems i guess?
The checks though are just boolean
they aren't taking that much time
they shouldn't run really with no entities present
anyway, 50 fps don't mean anything when the framerate is 300 or 350. what counts is the milliseconds spent in cpu
fps is a reciprocal number and therefore relative
anyone knows of a compression repo that uses burst/jobs?
unity just uses l4z
via CodecService
works in burst but it's just a native call - not burst optimized or anything
Latios has some compression stuff that might be interesting
https://github.com/Dreaming381/Latios-Framework/blob/8e67573423d51e115a121e6cf4fb2ed5fd04e6f0/Kinemation/ACL_Unity/AclUnityCompression.cs#L243
3ms just to find overlapping AABBs for 10,000 entities simultaneously. Not good.
ouch
I press multithread and it halves the time (cant multithread BVH building) but I dont know if it's valid.
is this simdified
Yea. Compares 4 AABBs at once.
I think the main issue is the adding of the entity that it overlaps with to the dynamic buffer. That isnt vectorized.
Im allergic to dynamic buffers
It's a great automatically managed NMHM.
I havent found a use case where I needed something dynamic yet I guess
An alternative option would be a fixed buffer struct and it'll allow for vectorized writes of the target entity, but that decimates chunk capacity.
fixed buffers only good if you can control the size
but they are my bread and butter
it's just so much empty space though. Dynamic buffers is great in that it's dynamic. Memory isnt wasted on empty slots.
I have 10,000 entities, each with a fixed Entity[16]. I want to be able to record every possible overlap but only in rare cases where all 16 would be used. Rest of the time, it's just sitting there empty
my use case lets me fill them up pretty good
can every entity overlap with every other entity?
Yea. I havent implemented collision flags yet so they can overlap with any other entity with a physics component
what are you doing with the results of the job?
have you considered writing to a temp array and then use AddRange? the temp array could be a list that you allocate once in job per thread
I'm doing that right now in fact. (Also trying to figure out why unity is crashing).
It's the broadphase of a physics collision detection algo
Do you have dynamic buffers in your project ATM?
yes, i use them for stats. inlined in chunk at fixed size
I dont know why but setting internal buffer capacity for a buffer component to 0 results in unity hard crashing on launch.
o_O
are you doing something weird with it? setting to 0 means data is allocated outside of chunk. not sure if you want to do this in that kind of algo?
I dont think this is because I'm abusing pointers everywhere. I dont even run anything until play.
Outside the chunk is fine, it's only storing an Entity for the opposing entity that it overlaps with.
writes will be slow though if you do it single
That's the stack trace when I set the capacity to 0 and launch unity.
how do you get the ptr?
I dont, not for a dynamic buffer
hm, that's very unusual then
Top of the SS is the access. Bottom is the write.
I havent had a chance to dig into physics much but there are some options for passing the data into your narrow phase
never ever had a crash because of it
where's the free occurring in entities
we have over 100 buffers or something stupid at work all 0 size
Top of the SS is the componenttypes containing the buffer (Overlaps). Bottom is the add components. It works, if I set the IBC to anything above 0.
and the struct of the buffer only has Entity in it?
Target?
Oh, the components?
yeah i had this bug a long time ago
it's because typeof(X) => ComponentType.ReadWrite<X>() which requires using TypeManager
return FromTypeIndex(TypeManager.GetTypeIndex<T>());
And it crashed...
and typemanager doesn't get setup in time
oh you doing this in burst?
yeah that won't work
The incremental builder is in burst, but the conversion works even with these managed arrays
i'm pretty sure what's happening is outside of burst, your component has 0 size and exists outside the chunk
inside it has the default size
so thinks its putting it into the chunk
But if I make it 4, no crashes
yeah because that still exists in the chunk
Oh fuck, the conversion system really does not like any dynamic buffers of size other than 4
Well then, I guess I'll be using a fixed buffer. Thanks unity for making the choice for me
huh, i use 33
you can't use ComponentType
before TypeManager has been initialized
a static field can cause this to happen
Hrm, alright. Im gonna try this
And then convert that to componenttype[] inside the foreach
yeah that's what i was suggesting because that's instantiated on use
hrm
that didnt fix it
It's creating the component types inside the Entities.ForEach()
So this has to be after TypeManager been initialized.
Huh, same issue with my other dynamic array also created at conversion.
Seems that dynamic buffers can not have a size other than default (4) during conversion. After startup, it's fine.
i have no idea why you have these errors, only thing i can say is that i can set all kinds of internal caps in and out of conversion
all my buffers are setup during conversion
a wide variety of sizes
[InternalBufferCapacity(6)]
public struct ClusterConnection : IBufferElementData
{
public Entity Value;
}```
``` void IConvertGameObjectToEntity.Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
dstManager.AddComponent<Cluster>(entity);
dstManager.AddComponent<ClusterDirty>(entity);
dstManager.AddComponent<ClusterConnection>(entity);```
that's a 6
public struct BuildPreviewData : IBufferElementData
{
public Entity Value;
}
protected override void CustomConvert(EntityManager dstManager, Entity entity, GameObjectConversionSystem conversionSystem)
{
var previewData = dstManager.AddBuffer<BuildPreviewData>(entity);```
giant 128
I'm making mine in a GOCS, not a IGCOTE
Im gonna see if it changes anything if I try a IGCOTE
i have a bunch in conversion systems
public struct SavableLinks : IBufferElementData
{
public Entity Entity;
public ulong Value;
}```
```#if UNITY_PHYSICS
[UpdateAfter(typeof(EndColliderConversionSystem))]
[UpdateAfter(typeof(PhysicsBodyConversionSystem))]
#endif
[ConverterVersion("tim", 1)]
public class SavableConversionSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
// ...
var savableLinks = this.DstEntityManager.AddBuffer<SavableLinks>(entity);
hrm
None of my scripts touch conversion though, what did I break?
Alright, i tried a IGCOTE and it didnt crash... huh
What I have, which might be the issue, is a duplication script.
I think I might be overflowing whatever internal system they have for clearing memory during conversion
Yea, it's the duplication. I'll need to do that on awake instead of during conversion it seems like
hrmmm, actually. I think it's DOTS Hierarchy in the editor (before pressing play) that is crashing unity
Alright, nevermind. Just changing the IBC crashes unity. To fix, reopen unity, clear entity cache, and hope
what are you using this for?
Broadphase tests. For physics.
doesn't unity handle this internally?
Unity has their own physics package is if that's what you mean internally. I choose to make my own.
Doing this cuts runtime by about 0.2ms, out of 1ms total. Not bad.
nice, pretty good
sooo apparently this system queries for SettingsMenuState in order to run (I assume because of the GetSingletonEntity call), but I want it to run regardless.
should I be going about this a different way? I'm basically just using the component in another system with RequireSingleton and OnStart/StopRunning to control my UI state
public partial class ToggleSettingsMenuStateSystem : SystemBase
{
protected override void OnUpdate()
{
if (HEVS.Input.GetKeyDown(KeyCode.Escape))
{
Debug.Log("derping");
if (HasSingleton<SettingsMenuState>())
EntityManager.DestroyEntity(GetSingletonEntity<SettingsMenuState>());
else
EntityManager.CreateEntity(typeof(SettingsMenuState));
}
}
}
Add
[AlwaysUpdateSystem]
pog thank you
I think this works. It should hopefully without exploding.
Yep. It does. Nice. Love it when code works first try.
what's going on here? not seeing the use of this
might have to do that i have no context what compIdx, compDat is
CompX is the "compressed" arrays of entities.
Compression is basically is vectorized select that also shuffles the true components to the left.
hm, i don't think you need to pin them btw
I'm using Span<> instead of direct pointers for safety.
These are random hardcoded array sizes and if any of them overflow, span will throw an error whereas a pointer will do random things until it hard crashes unity (learned that the hard way).
and that works with pinning the ptr to it?
wouldn't that require using the actual span struct?
Yea. Span is built into C# and has neat properties. It's basically a wrapper around a pointer.
And you use fixed to get the original pointer out of Span.
i know, but you are using pointers then and not the span. how can that be safe?
hrm, true. I dont actually index the span.
Used to before I wrote that memcpy stride section
but then I rewrote it, and now I dont use the span...
Well, guess I dont need the span.
yep, for that kind of safety. hardcode a const somewhere convenient
and use an assert
I was originally using it alongside this span as well (which is being indexed here)
oh wow, math.compress is left packing. i actually have a simd left packing in my code that's not working because i have no idea how to actually write such a thing and the lookup table
great name ... who calls something like that compress
Yea. Math has some really neat functions. I'm using this because that's what Unity physics does.
Yea, no clue.
oh i know, leftpacking was too verbose ... oh wait
Sooo, span is like reference to stack memory structure?
it's a convenient (safe) struct for a stackalloc
so yes. no idea if it can resize. never used it really
And apparently the other "hidden" neat math functions are countbits and tz/lzcnt for bitwise ops.
Cant resize.
Span can also be used to fix regular arrays but that will never come up in burst as you can not make managed arrays.
So stackalloc just let's you allocate any amount of data and span let's you to cast this allocated data to your chosen type?
you can do it with pointers or reinterpret too. also unsafeutility.As
Stackalloc allows you to allocate any type of data and returns that data as a pointer to the first value. Span is just a neat wrapper that contains the length of the stackalloc as well for safety when indexing into it.
Since I'm not indexing into the span (and using it's safety), i changed the stackalloc back to int pointers.
Just a fixed sized pointer to allocated memory?
No, it's like a NativeArray. It contains the length of the final array, not the number of elements.
dat leftpacking must be nice for early outs on something. that at least was the use case i wanted to tey but failed
Oh, so it is size of arraycount multiplied by type size?
why are you making this complicated. it's like a nativearray but allocated in stack
The array count in the stackalloc is like a regular array, not in byte size. In that SS, i can fit 64 ints into compIdx or 256 bytes.
It's a NA(Allocator.Temp) that disposes automatically at method return, instead of whenever unity feels like it.
I just don't really understand it ๐
it's really fast and on par with preallocated mem. should be used instead of temp nativearray in jobs
And yea, leftpacking is purpose built it seems like for tree testing. BVH, Octree, Quad, any type of tree.
i have tested it comparing stackalloc with a pre-allocated nativelist and there was no real improvement
Any examples how it looks like from allocation to disposal?
no dispose needed, when the method returns it's gone
Hmm
float* arr = stackalloc float[16]; for example
Is there a limit to amount of data?
i wanted leftpacking for these kind of tests
1 MB per thread generally.
yeah ๐ the stack size
Left packing results in 3 vectorized operations. No loops. Very clean.
So, 1 mb is size of stack?
Ok
Now it finally makes sense
Just temp native array but faster hehe
Combined with span
I've posted above how I'm using to compare 4 (or less, it's a bool check) entities against 1. So if you can guarantee a multiple of 4 entities you're comparing, left packing will work.
ok, i can do this with 2 loops then. i don't always have multiples of 4
thanks, i need to go to bed ๐ o/
You can create a guaranteed next multiple of 4 array then memcopy in. Then do all these checks.
yea, just dont use too much because this is how you get those infamous stack overflows.
I feel like I'm learning cpp at this point xD
Yep. Burst is C++ brought to the world of C#.
At least you dont need to write header files.
But span is indeed a nice learn
Along with stackalloc
Microoptimizations for performance critical applications
This aint just micro. This is how you can conduct physics on thousands of individual objects simultaneously in real time.
Might be micro for each entity but summed up over 10,000 or 50,000, it's a lot.
I assume this means crash?
Security
The use of stackalloc automatically enables buffer overrun detection features in the common language runtime (CLR). If a buffer overrun is detected, the process is terminated as quickly as possible to minimize the chance that malicious code is executed.
Yep. That's the downside. Writing C++ means losing the nice soft crash and informative error messages when things overflow.
And you hard crash unity as well. I spent 7 hours yesterday figuring out that I mistyped j instead of k inside a for loop indexing a raw pointer. It kept crashing unity with no error messages outside of Null reference exception (buffer overrun). And slowly walking back to where the issue is.
Yep.
You can tell because adding additional capacity to a NA doesnt change the stack allocation quantity inside burst.
Span's not just limited to stackalloc. I've wrapped NativeArrays around these to get a pointer like access with the buffer overrun safety of a NA.
Is there away to set an entity as a navmeshmodifier?
The GO nav mesh? No built in way. There is a DOTS nav mesh though, open source and free.
I was under the impression navmesh was compatible with dots
im using the expirimental ai package if that makes a diff
is it good?
Never used either nav systems myself. I use flowfields for my pathfinding.
I plan for a few thousand entities and flow fields scale better.
I just need something simple for pathfinding tbh. My game is a top down 3d game and the ground is 100% flat
Cant go wrong with A* with a few dozen at most pathfinders. Beyond that, nav meshes are faster up to about a thousand. Then flowfields win out.
Id have about 250 units pathfinding at most
thing about a* is I can't understand how I go about marking area of my world as unwalkable
make your world a grid. Larger grid sizes mean faster A* performance but worse quality of path.
Unity's nav mesh query, i think the thing you're looking at, seems to be a burst accelerated GO system, not a DOTS system.
If you want to use the nav package, you'll need to go hybrid and dip into GO land to update the nav mesh using monobehaviors
yeah I dont want to mess with game objects so that isnt an option
Pretty sure there's a navmesh in dots
Since tertle discussed it with someone else
@rotund token could you clarify?
dots nav was someone in the dots community, it's fully featured and very robust but not Unity's package
Unity's default navmesh works from dots
Yeah you can use this API if you want to use inside job. https://docs.unity3d.com/ScriptReference/Experimental.AI.NavMeshQuery.html
^
But can you generate a navmesh at runtime on an entity?
yes
how do I add them to the navmesh modifier list?
cause right now I got this and it works fine for a gameobject but once things got put into subscenes it stopped generating the navmesh
i told someone how to do this hte other day
private IEnumerator RebuildNavMeshAsync()
{
Bounds navMeshBounds = new Bounds(new Vector3(observer.transform.position.x, 0, observer.transform.position.z), new Vector3(boundsSize, 20, boundsSize));
modifiers = NavMeshModifier.activeModifiers;
for (int i = 0; i < modifiers.Count; i++)
{
markups.Add(new NavMeshBuildMarkup()
{
root = modifiers[i].transform,
overrideArea = modifiers[i].overrideArea,
area = modifiers[i].area,
ignoreFromBuild = modifiers[i].ignoreFromBuild
});
}
NavMeshBuilder.CollectSources(navMeshBounds, surface.Value.layerMask,
surface.Value.useGeometry, surface.Value.defaultArea, markups, sources);
var navMeshUpdateOperation = NavMeshBuilder.UpdateNavMeshDataAsync(
navmeshData, surface.Value.GetBuildSettings(), sources, navMeshBounds);
yield return navMeshUpdateOperation;
}
and it was you >_>
no you didn't tell me how to add entities to the navmesh modifier list
you just have to add your rendermesh
to the list of meshes
you can't use CollectSources
you have to collect them yourself
Ok thank you
just build a list of NavMeshBuildSource
from your entities
sourceObject is the mesh from RenderMesh
transform is LocalToWorld
think that's all you need from memory
Area I guess
I am sorry if you did mention this when you helped me build the code before I may have overlooked it cause I wasn't using unities ecs at that time. Decided to switch a few days ago after seeing how much better the api got
for bounds, you can either use a known area
or you can calculate it from combining all your WorldBounds
apart from that, it just takes the same navmeshdata and buildsettings
so the navmeshmodifiers aren't needed when using entities then?
i don't think they're require for game objects either
they just let you override the area with a different type if you want
if you don't use them it'll just use the default area
we use fmod
any general tip how is it structured in project?
yeah, but it has string field in Editor
which kind of makes it a bit harder
for type EventReference
so it comes to resolving guids manually
cant you just marshal the string to a ptr?
you dont pass fmod the string though
(i dont think, could be wrong on that)
but the wrapper is literally just
native calls with a ptr and values
i have no utils for fmod
this is work
i dont use fmod in my own project
this is just the default fmod sdk
yeah, interesting
I still wonder about how you structure it in entities
if you even do
ah
all the fmod string convert to guid
and you can pass those direct to fmod to get eventids etc
i'm no expert
audio guy asks me to hook up some data
i do
that's about the extent i've used it
apart from setting up the audio device switcher i think
I see
i just know it's pretty much a native library
which has the nice benefit of being callable from burst
and the c# wrapper they provide is really tiny
so should not be that hard to add your own little burstable wrapper instead
I cannot really find any actual examples of being called from burst
All I found are managed solutions
just go into fmod_studio.cs
and look at the external calls
and call them directly yourself
and even some dud who made a guide of how to use it with entities also used Managed systems
external calls can be made from burst?
burst can call native libraries
huh
so you can make a cpp method and call it from burst?
that's really interesting to know
yes
I'd assume as long as parameters are unmanaged and burst compatible
and so is return type
thats a limitation of the native call
but Transform
?
it's managed and it's external call
this is not a DllImport
You can pass pointers to structs from c# to c++ as parameters to pinvoke calls
oh nvm
^
hmm, can't actually find it
even github is 404
kek
oh found it
I think
hmmm
So the key to native calls
is System class
with only field of IntPtr
I am guessing this is similiar to EntityManager
as I can get reference to it in OnCreate
and then call it in bursted code
looks like true
private void Update() { Debug.Log(_system.isValid()); }
not a single false
very interesting
[StructLayout(LayoutKind.Sequential)]
public struct PARAMETER_DESCRIPTION
{
public StringWrapper name;
public PARAMETER_ID id;
public float minimum;
public float maximum;
public float defaultvalue;
public PARAMETER_TYPE type;
public PARAMETER_FLAGS flags;
public GUID guid;
}
They even have their own string wrappers kek
UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP_RUNTIME_WORLD
Where do I need to define it so it works?
it still compiles with automatic bootstrap
oh
maybe # is wrong one
Does World get's disposed on SceneChange?
Can I keep it?
System.ArgumentException: Unknown Type:`{0}` All ComponentType must be known at compile time & be successfully registered. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
Anyone know how to fix this issue? In my code, I'm attempted to add a custom dynamic buffer to an entity: ecb.AddBuffer<BlockBuff>(entityInQueryIndex, ent); //Add new block data array. but the error then occurs. From what I've seen online, I have to add an AssemblyInfo.cs in the same directory as the script to define it prior to compile time: ```using Chunks;
using Unity.Entities;
//Used to define component types prior to runtime.
[assembly: RegisterGenericComponentType(typeof(BlockBuff))]
[assembly: RegisterGenericComponentType(typeof(DynamicBuffer<BlockBuff>))]```
I would appreciate some help on the matter if anyone knows any solutions! Thanks.
can you show implementation of your buffer element data?
declaration
public bool isExist; //Does this block exist within the chunk?
public int colorIndex; //Index position of color map
public int textureIndex; //Index position of texture map
public int faceCount; //Index position of texture map
}```
Sure thing. Thanks.
ahem
looks fully legit
Remove RegisterGenericComponent...
that shouldn't do any good
hmmm
are you certain that this exact buffer is causing error?
I'd also recommend clearing cache and restart editor
To my knowledge, yes. The error doesn't show where the issue is being caused at but commenting out those lines removes the error.
entities, especially subscenes are really buggy lately
Hi. Does dots have any instruments(api) to detect in systems removing or adding new components? I've used State Components and custom tag components to detect this actions but it is clunky solution.
no
might want to figure out better solution
structural changes like these are very expensive
when there's a lot of entities
that require such reaction
look into ChangeFilters
in job structs, chunk.DidOrderChange detects structural changes
WithChangeFilters in systems foreach? I guess this feature detects only component changes not adding/removing.
i think it also detects structural changes in chunks. but if you only need to look for add/remove look at enzis suggestion.
thanks for advice!
but it detects all structural changes
not of certain component
very true. a built-in feature to run systems when certain components are added/removed would be quite nice.
Sure you could do that initialisation when you add a component right at that point where you add it but youd not be able to split up systems in a clean way. like if an entity gets a health component id not want to initialize the HP bar right away where i spawn the entity. id want an extra system for UI decoupled from the gamesystems.
what i currently do is adding one "Initialized" component to entities that need to do some stuff in the first frame on spawn. likewise i have tags that request initialisation of certain components (which was @agile cradle clunky solution). havent found anything better :/
potentially
I see a way it can be done
if you quite literally write your own ECB
which detects it and stores in some container
as events
Unbelievable
FMOD is burstable
holy
btw, physics stutters doesn't exist in build
I have no idea, what is causing this nonsense in editor
You mean the sliding across surface stuttering?
no, I mean stuttering due to changing translation value in update
Is the camera following the moving entity?
yes
Oh, that's just camera update issues.
Like the update of the position of the camera should be located in late simulation group so it pulls the correct position from the target entity
Uh, no clue then
it's some kind of weird physics doing
I gave up on cinemachine due to camera stutter issues. Switched to a custom monobehavior for the camera controller running in late update and it works fine now
you can select where to update cinemachine though
you can even manually update it
but once again, those stutters are from physics
not from camera
Its been a while but I remember messing with all of those settings and couldn't get rid of the stutter completely. Didn't try manually updating though so maybe that would have worked.
I'm not trying to say that the problem is from cinemachine necessarily. Never figured out the root cause. But switching to a custom camera controller fixed the stutter issue for me.
Finally, after hours of digging through the Entity source, I have converted my tilemap:
All you need is some asmref to pull out unity's neat function that extends supported companion object types:
And conversion from there is straight forward and works.
That works for general objects that dont also need to run their monobehavior update loops. Or it's already on the white list.
Yea. I do not want to roll my own tilemap and Unity's tilemap depends on the existance of a grid and tilemap component. So companion GO is the only way for it to work.
I think I finally understand the conversion system, after all these years
Finally converted my tilemap. Took.... weeks.
Burst 1.8.0 Pre-2 is out. Key changes I've noticed:
- Setting a breakpoint in an attached managed debugger (Rider/VS Unity Debugger...) on a method that is burst compiled, will switch off the burst code path for that method, allowing it to be debugged as normal.
- Added toggle to filter Unity tests on and off.
- Assembly is now searchable either through CTRL + f or the contex menu associated with the inspector view. Search options include case sensitivity, whole word match, and regex.
- Added focus on current job in the burst inspector.
@viral sonnet @rotund token
I think they ported the burst compiler not detecting changes from 1.7.2 to 1.8.0pre2 as well. Gonna upgrade now and see this new inspector
Holy shit, it's so clean. No more unity tests clogging everything
A bit more looking around, havent noticed anything else immediately
oh it's per method
not per job
that's even better
good thing i have an ultrawide o_O
search is new right
can actually find the code i'm looking for like instantly so nice
well
oooh
hm
nope, didn't work
oh yeah they don't always properly generate the line stuff
Switch between full debug and then back to minimal debug (default) to refresh the yellow line comments
had a corruption within 30min
=S
Already logged
oof, guess the improvements to the hashing system didnt really improve much
interesting it was in my 1 entities.foreach in the entire library
coincidence? probably not
but maybe
maybe it was just entities codegen corrupted
i didnt actually test if restarting without nuking cache would fix it
you guys made me excited to update. guess i'll wait ๐
nice to find a ctrl+f feature!
Did you know, a rectangle has 4 points? That's 4 floats for X, and 4 floats for Y. 4 means vectorization.

@viral sonnet Needed the ptr CDFE. Hope ya dont mind me taking a copy of ya repo. What's the improvement for BufferTypeHandleFast?
you're welcome ๐ i should update the repo again. it's nothing big tbh, uses a lookup cache.
The type names get longer and longer and longer
haha, yeah I think it would be worth it to just rename it to CDFEX ๐
yeah, good one
I dont remember, is this mixing of CDFE and CDH possible?
yes, but you need to disable safety
you will get alias errors if you are writing
on the cdfe
All of these are readonlys
it's obviously not safe if you're reading from cdh and writing cdfe to same entities ever
The massive disable safety tags.
Im pretty sure Unity made the tags so ungodly long to discourage people from using it.
or at least the peasants without ultrawide monitors
in times of auto completion i have not much issue with them. all start with Native
Just a suggestion under the chunk extensions:
public static bool Has<T>(this ArchetypeChunk chunk, ref BufferTypeHandleFast<T> bufferComponentTypeHandle)
where T : struct, IBufferElementData
{
var typeIndexInArchetype = ChunkDataUtility.GetIndexInTypeArray(chunk.m_Chunk->Archetype, bufferComponentTypeHandle.m_TypeIndex);
return (typeIndexInArchetype != -1);
}```
unsafeCDFE makes the tower of properties slightly better
it does
forum post suggested they will add the cache to the buffer but it's not in 0.51. just checked
Cache?
the lookupCache
Oh, maybe in 1.0 then. BufferAccessor should just be an array of pointers though.
the Update() on CDFE/BFE will be nice to have as well
i have added my collections now to the repo
parallel list and array hashmaps
the array hashmap work on either one array with a key offset or 2 arrays. fastest hashmap i could make ๐ parallel list is basically a multi threaded list writer with 128 nativelists to write to
usage is like a nativestream, just that it expects chunkIndex and don't foget to set the chunkCount before the job is scheduled
the index can be abused for whatever ๐
i should probably make the name more generic. BeginForEachChunk doesn't suggest that any kind of index can be used
curiously what's the advantage of your array hashmap
over just writing to the key/value arrays directly in a regular hashmap
is it just api convenience?
pretty much, yeah. easier to setup and the biggest difference is the 1 array option that only uses value but no key array
the parallelList can also be indexed with ParallelListHashMap. not using that though in my project
Another suggestion:
public bool TryGetComponentRefRO<TUser>(Entity entity, out TUser* ptr) where TUser : unmanaged
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
AtomicSafetyHandle.CheckReadAndThrow(m_Safety);
#endif
CheckComponentIsZeroSized();
var ecs = m_Access->EntityComponentStore;
var hasComponent = ecs->HasComponent(entity, m_TypeIndex, ref m_Cache);
if (hasComponent)
{
ptr = (TUser*)ecs->GetComponentDataWithTypeRO(entity, m_TypeIndex, ref m_Cache);
}
else
{
ptr = null;
return false;
}
return true;
}``` Allow for the the pointer returns to be cast designated as whatever the user wants. For easy inline reinterpretation but no safety checks.
ah, yeah. makes sense
Here's my use case. CircleReal is just a IComponentData wrapper around a single float. I can now inline the reinterpret without having to use another var.
no need to explain. good idea. ๐ i have added it