#archived-dots

1 messages Β· Page 78 of 1

vagrant surge
#

in the blog

flat talon
dull copper
#

looking at the post, that's probably it, doesn't make sense to write that extensive post and then make same for blog πŸ˜ƒ

#

Project Tiny Preview 0.15.3 does not include Physics2D. We are in the process of bringing an improved DOTS 2D Physics module. You can still use HitBox2D for lightweight intersection and overlap checking module that does not require physics.

#

well, now they officially said they are working on 2D DOTS physics

minor sluice
#

nooo, I was hoping on that. Still great news though πŸ˜ƒ

#

Anyone knows if those hitbox and overlap modules internally already utilize broadphases, trees and all of that? for proper performance?

safe lintel
#

disappointed its not tooling for regular non tiny dots

#

will tiny ever not need to be "built" to play?

vagrant surge
#

@safe lintel it wont take too long

#

this is just because tiny is "too" focused on webgames

#

but given its DOTS, i dont expect them to take much to make it work inside the editor as usual

dull copper
#

do note that the Tiny has "DOTS Mode", it's not Tiny mode and the DOTS projects don't have any tiny related extensions

#

this is the same editor that we will eventually get for full DOTS

#

it just only has Tiny components set for it atm

#

but for example, you can put regular ECS components to it even today

#

but like mentioned before, there's like no 3D Camera on the DOTS Mode right now, so you won't get far πŸ˜„

#

I do hope we can get the play mode running on the editor soon tho

vagrant surge
#

nor fancy physics or Transform system

dull copper
#

as it's pretty serious limitations on Tiny now

#

I also don't even get why they have that limitation as they support mono too

#

so it feels like they probably just haven't had time to implement it yet

#

@vagrant surge Unity Physics (aka DOTS physics) components show up on DOTS Mode if you have the package installed

#

some, like that collider aren't configurable from this side tho πŸ˜„

safe lintel
#

hmm is there a physicsbody/shape components that get converted to a collider in tiny?

dull copper
#

I wouldn't expect Unity Physics to really work on Tiny right now

#

I think Joe mentioned few times that in the future you can just mix "Tiny" and full ECS components, based on what you need

safe lintel
#

yeah surprised that stuff is there if its not in a working state

vagrant surge
#

doing that in DOTS is very easy

dull copper
#

well, it's first C# version

vagrant surge
#

its one of the main points of ECS arch, you can literally swap systems very easily

dull copper
#

it's expected it's not fully done πŸ˜ƒ

#

altho most here probably expected DOTS editor a long time ago already :p

#

This preview is fully integrated with Unity’s Data-Oriented Tech Stack (DOTS) and sets up a foundation for bringing advanced features for both tiny and big use cases.

safe lintel
#

i think i expected a dots editor before tiny, not that i expected one to be out by now

dull copper
#
Not yet. We are working on this feature and we will provide updates.```
magic frigate
#

So will we end up with three separate editors between the the current, DOTS and Tiny editors?

dull copper
#

afaik the idea is that the DOTS Mode will cover all DOTS related

#

I say this again: the new editor doesn't have "tiny" wording anywhere, it's labeled as DOTS Mode, DOTS project etc

magic frigate
#

Ah, that's good to hear

dull copper
#

What we get today with c# tiny is prepared for tiny components tho. It will take a long time till we get full dots support on it

#

Long time estimate is just my personal guess based on iteration times Unity has had so far

urban rivet
#

The editor "modes" concept is still in flight AFAIK

#

but it'll be 1 editor

#

cos projects can mix

#

as far as I know the concept is you still work quite naturally as you do now but DOTS converts the wasteful and easy to understand prefabs to internal rep

low tangle
#

I really hope they don't go and hide away ecs stuff too much

#

I don't mind the conversion approach but I've just gotten used to having full control and using all components directly

dull copper
#

I'd just want a view toggle on the editor

#

that lets me view what's on gameobject side and what is on DOTS side

#

it feels like nobrainer to me, that it should be like that

#

but seems like Unity doesn't agree

split lily
#

Does anyone know how to add the Disabled component to an entity using CommandBuffer?
Currently I've got this
CommandBuffer.AddComponent(index, entity, typeof(Disabled));
And I'm getting this error
The type 'Type' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method

tawdry tree
#

Check the info for disabled - is it a class or struct?

split lily
#

It's a struct

#

Hmm.. I got it to work but I don't think its doing what I wanted it to be doing

#

All I actually want to do is disable/enable a RenderMesh on these entities - using Disabled seems to stop it being included in the system I'm using to add and remove that component in the first place

tawdry tree
#

Disabled disables the entire entity, yeah

mint iron
#

anyone seen an example of how to use UnsafeUtility.PinGCObjectAndGetAddress

safe lintel
#

@split lily maybe try new Disabled() instead of typeof(Disabled)

safe lintel
#

i dont suppose anyone has used the new InputSystem with ecs? not having any luck setting the input callbacks to work within a ComponentSystem(I dont want to use it with a Monobehaviour)

low tangle
#

yeah even tag components you just new Type() them

#

not a type pram

untold night
#

@safe lintel - I did get it to work, but there's still some MonoBehaviour hybrid glue. I suspect one of the first things they'll do after the 1.0 preview release is better ECS compatibility but I gave up and went the Hybrid route for the time being.

safe lintel
#

hmm probably wouldnt be hard to do that

#

i dont suppose you are getting a constant error message with the latest version? its kinda driving me nuts, occurs in a blank project too

untold night
#

I haven't checked much the last week, but I plan on getting back to it this week and update the latest.

What version are you on specifically? I'm staying on 2019.1 until 2019.2b6 since there's a UI assemblyreference issue. They pulled uGUI into it's own assembly and it caused a lot of issues with both Unity packages and external packages / asset store assets.

safe lintel
#

2019.1.4f1 with 0.2.10

#

yeah im not gonna try 2019.2 until b6 as well

#

although hes using the 2019.2 beta

untold night
#

I'd submit a bug report then. For errors bubbling up from native that'll get you a faster response than a github issue

#

are you on Windows, Mac, or Linux for workstation?

I haven't seen that error on Win64

#

but I also haven't used my mac in like 3 months

safe lintel
#

windows

#

man i dread bug reporting because its so slow to send, thats like an entirely different issue that I seem to have

twin raven
#

How Burst will achieve cross platform floating point determinism?

dull copper
#

it doesn't - yet

#

but basically they stick to some IEEE standard for floats, avoid operations that are known to throw the determinism off and come up with their own alternatives for them - which they can guarantee uses float math that is known to be deterministic

#

you also trade perf for this, hence it going to be optional for those who really need it

twin raven
#

Thanks. I figured they would have to trade in some performance. Hoping that with all the other benefits of burst the penalty won't be too bad for my project. I tried to read from unity forums and github about this and couldn't find anything related to it being optional tho.

inland relic
#

hey if anyone's around, my game runs fine when I run it in the unity editor
but when I build it I get

(Filename: C:\buildslave\unity\build\Runtime/Mono/ManagedMonoBehaviourRef.cpp Line: 333)```
any Idea how to figure out which script it's talking about?
golden heron
#

Not easily, i dont think, however you shouldnt be getting this at all - if the referenced monbehaviour on the object were missing truly, it would never have allowed you to build in the first place. How big is your game? @inland relic

#

It could be caused by an object script reference persisting beyond the life of the object, possibly, althought im not sure if that would give this particular error... This is something that usually comes up in the console as a red error during compilation, and if not solved will stop you from being able to progress. Also, if it says "GameObject 'null' " Its suggests that the associated object may well have been destroyed as well, because the name is missing. Is it possible somewhere in your code you have used Destroy(this) ? This directs to the components - this = current running script, NOT the associated gameobject, so Destroy(this) removes the component, whereas Destroy(this.gameObject) destroys the object initially, and then the components as a part of the object.

#

What are people meaning by "new input system"?

golden heron
#

New release?

dull copper
#

new input system

golden heron
#

thanks, i just looked, the forum post is from 2017, and talks about a pre release alpha, have they completedit now, or at least improved somewhat?

dull copper
#

those links would explain it, just look at the github readme

golden heron
#

ah, ok thanks :)

#

So would you say in your opinion its worth integrating now, or would you wait until its finished properly to upgrade a project intended fo release?

dull copper
#

it's pretty raw still, I'd suggest to try before fully using it

#

readme has some rough roadmap

golden heron
#

It says on the github something like 85% completed features, 60% stability, and 40% shine hehe

dull copper
#

github's estimates are way too optimistic tho

golden heron
#

Seems like its worth checking out for a bit of fun, and to see what to expect, but maybe not for a release project

#

I just delayed everything whilst i spent 2 months learning ecs hehe

#

Has anyone been working on anything to do with pathfinding in ecs?

#

Mostly gonna look for comments on the overall concept - but here is my idea for pathfinding, in my case. Firstly, the use case is as follows, the universe will comprise 1000+ systems, each procedurally generated to contain planets and asteroids and a sun, like a small solar system. The systems will be connected via wormhole-like starlanes, and the only things that stay fixed are the position of the sun and the relative position of the starlanes, everything else orbits the sun.

#

Also, this is for an mmo, and in the first case i am working on an ai pathfinding system, where the ai is assumed to have explored, in full, basically the entire universe.

#

So, my intention is to have the systems hold a kind of data set constructed by an ahead of time pathfinding algorithm to avoid the repetitive calculations involved in the pathfinding of an optimal path through the interconnected spiderweb of systems.

#

The data set will comprise for each system the ores it contains, the station commodities produced in that system, and then a list of every other system in the universe, which is a list of int values which show the number of jumps to the systems, and the index of the system is again an int used across everything preserving the same system id, so, in spite of using an array of cached data of every system on every system, it should be relatively small as its only the index and an int per entry. Then, the universe from each systems perspective can be broken down by exploring the immediately adjacent jumps to each system, and, as the systems are filling in data, they can reference other system's data to fill out parts of the data set faster.

#

When a ship needs a path, it then requests from the server, and the server returns a list of int values describing the system indexes in the order required to get where it wants to go, and the server creates the list by rferencing the desired object at the destination (stocks, or asteroids of a certain ore type, and later other things), then it picks a system, and if more than one option appears, it references this own system's distances list to pick the closest, then from the destination working back to the start it simply picks the closest system of those adjacent for each system and records the int ids.

#

In system navigation is simple in three dimensional space - my partitioning system should handle collision avoidance easily enough.

#

So, the entire system will avoid any costly calculations, instead relying on array iterations and int value comparisons. Data such as the distance between two starlane entrances inside the same system would very much be valuable for the pathfinding, but i do think it would result in too much stored data - im already gonna need to cache the data to disk, and read in a way which intentionally does not hold it all permanently in memory or the system will run out of ram.

#

It would also heavily complicate the comparisons and calculations required as i would then need to use floats to manage the distances, which also increases memory requirements.

#

Or, begin to compare the distances whilst calculating which again defeats the point of the system.

#

Ooh, another constraint in the universe is almost so obvious as to be assumed, which is that there definitely will exist a path from every system to every other system, there will never be a case where the appropriate response to the request is "no path available".

#

And, in the case of ai ships, i can stagger the path generation over a fairly long time in regards to frames, the ai ships are intended to be a little slow, if they respond too quickly then they will make a system which is too efficient, and players wont have a chance to capitalise on trade opportunities. Even a five minute wait for a path would be acceptable.

#

They will definitely include a random wait in there processes somewhere to... this sounds wierd ... but to "improve the inefficiency of the system" hehe

mint iron
#

That's quite ambitious.

So i'm not sure that you would need an elaborate system for navigation between systems. Standard A* or whatever, can work fast enough on large data sets, so even if you had 20,000+ solar systems in your galaxy i think it would be a relatively quick calculation. Your decisions around server placement /latency/networking might have more of an impact than the gains from a hyper sophisticated pathfinding approach. Id say make it as simple as you can, then optimize it when you can identify the bottlenecks.

mint iron
minor sapphire
#

I run a job that populates a NativeHashMap. I want my next job to iterate over it. How can I do so without calling complete() in between followed by GetKeyArray on the main thread??

tawdry tree
#

Err, you need to call complete to ensure the first job finishes. What are you trying to accomplish?

#

If it's the thing which deallocates after the job ([DisposeOnJobCompletion]?), just put the attribute in the final job that uses the nativecollection.

minor sapphire
#

Job b depends on job a. Job a populates a hashmap, job b wants to iterate over hash map. To accomplish i would call complete and then get keys array to pass to job b in between

#

But this creates a sync point. Wondering if it's possible to avoid the complete, and iterate over the hashmap some other way...

#

Job b already depends on a, just want to avoid coming back to main thread hmm. I could use IJob instead of IJobParallelFor... And get the keys before running my own loop... But really need the parallel here...

#

Wish there was an 'Initialise' before the 'Execute'...

#

Then could get keys there...

#

I could run an IJob and store keys in a dynamic buffer I suppose...

amber flicker
#

suspect there may be a better way to handle the keys depending on what you're doing but presumably the main point is that you need to guarantee the hashmap has been finished writing to before trying to read from it?

#

hence the complete

minor sapphire
#

Yes. The dependency should handle that anyway

#

The only reason I want keys is to iterate over the hashmap

#

In a IJobParallelFor

#

Is there another way to iterate a hashmap?

amber flicker
#

I'm a bit confused πŸ˜ƒ - are you getting an error? Surely if the hashmap has finished being written to, there's no problem? Would this be better as a NativeArray if you just need the keys for iteration?

minor sapphire
#

I haven't finished writing it yet, so no error heh

#
Job 1: 
Populate -> HashMap<key, value> map;

Job 2: (depends on job1)
i want to loop over all key/value pairs in the HashMap
amber flicker
#

so firstly, if relevant, I'd try and use e.g. an entity with component as a key or similar if you can, second, if you want to do it this way - in Job 2 you can just call GetKeyArray() no?

minor sapphire
#

To do this, my first thought is:

Job 1;
Populate HashMap

Main Thread;
Job1.Complete()
var keys = HashMap.GetKeysArray();
Job2.Schedule(keys.length, x, inputDeps0;

Job2 : IJobParallelFor
keys:
execute(int index)
var hashMapKey = keys[index];
#

I can indeed call GetKeyArray() in Job2 if it were an IJob

#

but i'm hoping to keep it parallel...

#

I don't really want to call GetKeysArray() for every iteration in an IJobParallelFor

#

I'm considering using an IJob to call GetKeysArray() and store as a dynamic buffer on some singleton entity

#

then access from the IJobParallelFor

#

this just all seems convoluted though lol

#

maybe I should just call Complete and pass it in lol

amber flicker
#

hmm... I don't think there's anything wrong with just using an IJob and storing the keys array as a temp native array

minor sapphire
#

can you get data back out of the ijob?

#

nah, I dont' know how to pass the result to the next job...

#

unless I store in a component

amber flicker
#

what's the result? fyi there's nothing wrong with doing GetExistingSystem<Blah>().myHashMap and passing that into a job

minor sapphire
#

yeah these jobs are in the same system anyway

amber flicker
#

cool

minor sapphire
#

the hashmap will be complete before the job runs on account of the dependency

#

I just have no way of parallel iterating it that I can see without an array of keys

#

and to get an array of keys and pass into the job means calling complete on the main thread thus creating the sync point

#

I might go with this whole dynamic buffers idea, using an IJob in the middle to get and store the keys for the next job to access

#

I just want IJobNativeHashMapForEach lol

#

wonder how hard it is to create a new job type...

coarse turtle
amber flicker
#

fyi @minor sapphire apologies - when I was saying IJob i meant IJobChunk - does anyone know if there are times when IJobParallelFor is more performant than IJobChunk?

minor sapphire
#

I need to iterate a collection, not a bunch of entities

#

not sure about performance question

#

found this

#

I will try it out

#

HashMapList, can be iterated like a list πŸ˜„

#

trade memory for functionality

#

we'll see...

#

actually...

tawdry tree
#

Did you clear it up? Had dinner but chaining jobs should absolutely minimise the impact of sync points

minor sapphire
#

I suppose I could simultanously populate my hashmap and a keys array myself

#

List has some features that lets you use its count in a parallelfor before you know it's count int he main thread

#

i can probably make use of these

#

Joachim has an interesting post about it here

minor sapphire
#

I think that post is too old cause I can't seem to pass a list into Schedule() as he has done....

minor sapphire
#

what is IJobParallelForFilter and why is it so hard to find info on it 😐

#

ffs now what is ENABLE_MORE_CONTAINER_SUPPORT lol

#

this API needs a lot of love lol

fathom trout
#

it is for appending indices to a list within jobs then filtering by those in more jobs

inland relic
#

@golden heron it's pretty big, we've got a few scenes and thousands of assets

#

I think this particular error has something to do with the wwise plugin

#

there are 3 game objects in the scene with the errors that act as singletons and I am guessing that the error is coming from each one of those singletons because there are 3 of those error messages that popup

golden heron
#

@inland relic ill send a dm, the singleton is likely the cause, it would be quicker if i saw code...

inland relic
#

Cool thanks!

fathom trout
#

@minor sapphire was on phone before, maybe you figured it out ,but you would call job.ScheduleAppend( indicesList, length, batches, dependency); then any index of the IJobParallelForFilter that gets returned true will pass the append, get added to the indices list. For subsequent jobs (dependencies of the append) you can call ScheduleFilter( indices, batches, dependency) and it will only iterate the indices in the list. For each index if it returns true, it stays in the indices, if it returns false it gets removed from the indices.

#

you can also further append to the indices in a chain of scheduled jobs, and the indices stick around after calling complete also if needed (be sure to clear the indices list before all the scheduling otherwise it will build up in size)

#

i guess it could be a tempJob allocation too

dull copper
#

so... if anyone has issues with entities and IL2CPP

#

make sure to grab the link.xml from DOTS samples repo πŸ˜„

#

turned out, it's the code stripping that was the reason I couldn't get anything rendered after things had been converted to ECS side on hybrid renderer

dull copper
#

it was a pretty silly mistake from my end as I've read in past that you need to manually link ECS stuff for IL2CPP, just forgot about it

#

and... it appears that Unity Physics crash on Master and Release build configurations is fixed by the same bloody code stripping fix πŸ˜ƒ

stiff urchin
#

Whats the current state of ECS? Is it more stable now? I used it a while ago and it awkward because of missing/wrong documentation.

dull copper
#

pretty much as stable as it's ever been πŸ˜„

#

each version changes API, new version, new issues

#

then add the compatibility issues between packages if everything isn't updated to support the latest one

#

so, in my opinion, it's still only for people who want an adventure πŸ˜„

#

and it's evolving and making progress alright, just it's never been really smooth experience to use as things keep changing

tawdry tree
#

You should use the current ECS if:
-You want to try it
-You want to help shape it by submitting feedback
-You want to learn ECS (The only thing you can really learn is the general mindset, given how much changes, but if you try out updates as they come you should have a pretty good feel on how it works.)

You should not use the current ECS if:
-You need the code to be reliable and stable.*1
-You need complex or low-level features and can't make them all from scratch
-You're not already familiar with programming

#

*1 In my experience it's pretty reliable/stable in that I haven't had any crashes and such, but the APIs change regularly, so the codebase itself is not. I've been doing pretty simple stuff, though.

#

That's more or less my take on it; I try to keep up with the changes and wrap my head around the general architecture and patterns, and I would actually say you can even use it in production... provided you're making a fairly simple thing (physics is especially nasty, AI sounds like it's currently a nightmare to implement, dunno bout netcode, etc), and you're ready to update and potentially have to rewrite a bunch of code on a weekly or semi-weekly basis.
Just about any flash game from the flash game portal era could probably be (re)made in ECS, possibly with some nuts performance (or OK perf but a shitton of stuff)

coarse turtle
#

Netcode can be painful due to the lack of documentation and things not exactly working with RCP in their example for the transport layer

#

but honestly it works quite well once you get through the initial hurdle of understanding things

urban rivet
#

Totally do try ECS as a new old way of thinking but never, ever do this if deadlines are even a scant thought as it will take a totally random amount of learning time to get.

#

In fact try to see the problem as being the same as learning how to code shaders but without docs.

#

Actually seen people have slower results becuse they didn't know what to do with ECS

#

Basically stalling the heck out of it

vagrant surge
#

the cool thing with what unity is doing is that they are doing exactly what they said, with the "democraticing data oriented design"

#

data oriented design is kind of hard, but the limited feature set Burst and ECS gives essentially 100% forces you to do data oriented stuff

urban rivet
#

Joachim's decision to make the compiler throw an error if something would be slow yet technically not crash is a very good one too

#

But people can still break this. every time they do, it's worth posting about on forums so they can eliminate that too

vagrant surge
#

ECS really is "training wheels" for data oriented design

#

they should plug the Fabian book more times, its extremelly relevant for everything Burst/Jobs related

#

my beef is just how bad the workflow is

#

Entitas is still so much better as at least it has editor support

safe lintel
#

besides editor support what else are your concerns?

vagrant surge
#

changing the API every 2 weeks

#

but biggest beef is 100% the editor support

#

if it had entitas-like support, hybrid mode would be kind of usable

#

would be useful for games right now

safe lintel
#

the api hasnt been in that much in flux lately

vagrant surge
#

but it doesnt. Entites cant be edited in editor, and you cant see entities in inspector either

#

the Convert workflow is honestly nothing but a hack, i really dislike that

coarse turtle
#

Eventually, they'll add support for editing entity data in the editor

safe lintel
#

yeah converting still doesnt feel good, better than the proxy stuff i guess

vagrant surge
#

doesnt seems so @coarse turtle

#

look at where they are going with Tiny and DOTS-only editor

#

it seems the path is for a "pure ECS" editor instead

coarse turtle
#

Ah - I must've missed out on that on the forums then

vagrant surge
#

im going to start tinkering with C# tiny

#

tho its current version is soooooooo early

#

with that whole "needs to build for play"

safe lintel
#

i wish they just gave more communication on the roadmap

dull copper
#

gdc's dots roadmap talk was a huge letdown

#

was really wishing for some real roadmap

#

got chart where they estimate they get engine systems ported by ~2022

#

but it doesn't really have much new in regards to DOTS

crystal zephyr
#

I guess my favorite version from the slides is 2019.3 πŸ˜‰

minor sapphire
#

In case anyone didn't see this post and is interesting in unity physics... This post was reaction to a teaser video on Havok physics.

Shinyclef said:
Please sir, tell people who decide not to make us cry in the pricing department. Don't forget us little solo indies! I'm both excited and scared for the Havok licencing/pricing announcement...
---------------
steveeHavok:
I know the good folk are working on that announcement very soon, so I won't spoil their thunder. 
I also know we have certainly not forgotten you little solo indies, and that you should not be scared at all ;-)
minor sapphire
#

oh whaaatt

#

audiooo

#

I want soouunnnddd

dull copper
#

well, no luck on 2019.3.0a5 at least

#

same errors on 2019.2.0b5

minor sapphire
#

def gonna need some kind of info to understand how this audio system works...

dull copper
#

and probably wait for next version of the package or editor πŸ˜ƒ

minor sapphire
#

ignoring presentation group for now...

coarse turtle
#

yea the simulation group is just waiting on all the semaphores πŸ‘

minor sapphire
#

what a lazy bum that main thread...

#

πŸ˜„

safe lintel
#

what exactly is a semaphore?

stiff urchin
#

semaphore is how you can detect if a GPU is done processing a command or group of commands.

#

at least in vulkan it is

low tangle
#

its a simple flag for saying if another thread as finished work

#

think of it as a atomic boolean

stiff urchin
#

yeah thats better

low tangle
#

`Consider a variable A and a boolean variable S. A is only accessed when S is marked true. Thus, S is a semaphore for A.

One can imagine a stoplight signal (S) just before a train station (A). In this case, if the signal is green, then one can enter the train station. If it is yellow or red (or any other color), the train station cannot be accessed.`

#

main thread runs jobs when it can as one of the worker threads

#

so unless you have a complete up there in a job system your main thread will work on jobs too

minor sapphire
#

does complete prevent the main thread from participating in the completion of the jobs?

safe lintel
low tangle
#

if I remember correctly yes @minor sapphire

#

you should use completes when you need to

#

but avoid them when you can

#

same goes for main thread component systems instead of job component systems

amber flicker
#

Does anyone know how to disable dynamic render batching with the hybrid renderer? At least I deselect it in the project settings but I still see UpdateDynamicRenderBatches in the profiler

minor sapphire
#

@low tangle does that apply to other sync points such as EntityManager.RemoveComponent?

#

I'm not sure what to do to allow my main thread to participate in jobs in stead of just sitting there waiting 😐

#

You have a sync point at least when you reach the command buffer right? so at some point it's going to be Complete()ing something...

low tangle
#

Yeah you want to use endsimcommandbuffer so your ecbs play out as late as possible

#

Then the jobs are not sync points and the main thread will go to the next job system. Once at the end it will work on jobs as well

minor sapphire
#

Imagine ideal code where the main thread only schedules jobs.

#

It will schedule everything super fast and end up at the command buffer system very soon

#

meanwhile, jobs have a lot of work to do, so they take a while

#

the main thread is just gotta sit there waiting for jobs to complete so it can process the command buffer??

#

My full simulation group looks like this. I think I did a decent job in jobifying and removing sync points, but I hate how idle the main thread is now lol.

mint iron
#

quick question, can you run a job from within a job

dull copper
#

you can chain jobs but they need to be scheduled from main thread

#

so you can't nest them / schedule a new job from existing job

#

@minor sapphire you got a response πŸ˜„

#

gotta love that guy, pointing the obvious

#

but to the actual issue, have you checked the core utilization some other way? also are you sure the things above are not using the main thread while the workers do something?

#

having job system using only 3 worker threads doesn't mean the rest of the engine couldn't do things with the remaining cpu capacity

tawdry tree
#

So either:

var handle = Job1.Schedule();
job.Schedule(handle); //Make it a dependency, this chains the jobs. Very little cost.

or

struct SomeJob : IJob{
  //Change some value
  //Some other system would read this value and start another job.
  //This is the standard way to have systems communicate (System1 makes an entity or changes the value of a component's entity, System2 check for that)
}

or

class SomeSystem : system{
  struct SomeJob : IJob{
    public NativeArray<bool> ShouldStartJob2;
    //execute sets ShouldStartJob2[0] = true
  }

  void OnUpdate(inputDeps){
    var shouldStartJob2 = new NativeArray(0, temp);
    //schedule and complete job
    //if should start new job, do so
    //Alternatively, always chain the new job, but send in the bool array and exit early if false
  }
}
#

Pseudocode obviously, but those seem to be the main ways for a job to communicate

minor sapphire
#

@dull copper good points

#

I have 60-75% CPU utilisation

#

across all 4 physical cores

#

the cores are likely sharing the task of processing the threads, unless there is core affinity going on

#

the presentation group is hopeless though so that's part of the problem

#

but for now I'm only looking at sim group

mint iron
#

@tawdry tree @dull copper thank you! ❀

minor sapphire
#

at some stage I'd love to get a job or two running on those workers during presentation group πŸ˜„

dull copper
#

I'd just want to use burst on separate thread that's not a job

minor sapphire
#

oh yeah me too, it's amazing what impact it has

dull copper
#

that way one could do longer running things that are not frame dependent

minor sapphire
#

burst on a worker thread with producer/consumer pattern 😐

#

yes please

mint iron
#

it seems that now you can debug step through a job marked with [BurstCompile] and with Burst Compliation enabled. Is that correct? when i tried a few months ago it would skip over anything that showed as properly burst compiled in the burst inspector (i'm using 2019.1).

mint iron
#

no somethings wrong here, i get the same timings with compilation turned on and off

solar ridge
#

Glancing over, @minor sapphire you WANT your main thread to idle really. Realistically you want everything to idle waiting for the next frame really

#

Consider a mobile. If you ran everything forever never waiting on say the time for 60fps for a frame standard, your phone would get rather hot which is bad for the device over time

#

Main thread specifically you want to idle, due to the volatile nature of the jobs you just scheduled.

#

Also note, you may not want to necessarily take ALL of the cpu πŸ˜‰ as the device MAY be using it for other things

#

Assassin's creed is an interesting example of that happening.

dull copper
#

huh

solar ridge
#

All the CPU is driven towards the game, which means my browser that handles chat dies at times

dull copper
#

this is not about CPU idling after it's done it's work

#

it's about possibly one core sitting idle while others do the work

solar ridge
#

The entire core?

dull copper
#

like mentioned before, I suspect the main thread may still do other things but I haven't benchmarked this myself

minor sapphire
#

main thread is sitting waiting for jobs to finish, even when don't hit 60fps

#

this is not about vsync

solar ridge
#

Realistically main thread should wait.

minor sapphire
#

what do you mean by 'realistically'?

dull copper
#

but why is the worker thread count limited to 3?

solar ridge
#

That one I don't know @dull copper

dull copper
#

I think it adjusts that per CPU

minor sapphire
#

that's the better point πŸ˜„

dull copper
#

@minor sapphire you have quad-core right?

minor sapphire
#

yes, quad core, no hyper threading

dull copper
#

I saw the comment that you don't have HT

#

I'm on same boat

solar ridge
#

The reason your main should wait is because you may not know when the other threads will finish

minor sapphire
#

but if it were 4 threads, the 4th physical core could do something

dull copper
#

and all I ever see is 3 workers

minor sapphire
#

*4 worker threads

solar ridge
#

If you start up going on some weird worker path... all of the other threads may finish and then be like... "Why are you not done?"

dull copper
#

this is not really about main thread waiting

#

of course it waits

minor sapphire
#

yes you're right it wasn't stated clearly

#

updated post :)

0lento with another good point. This is not really about the main thread waiting, that point is realistically fine. The point rather is, why limited to 3 workers here? If there was a 4th worker, the 4 cores could jump on the train to process while main thread waits.
#

perhaps the expectation is that the main thread is 'usually' the bottleneck?

vagrant surge
#

it is

dull copper
#

or to keep the thing responsive, I dunno

vagrant surge
#

the main thread is the one running the simulation loop itself, so of course it bottlenecks

dull copper
#

they must have a reason to do this tho, when you go for "performance by default", you don't just omit one core

vagrant surge
#

the others are kinda helper/job thread

minor sapphire
#

but in ECS territory, where you want to be able to scale up with more cores, you encourage or at least allow for well jobified code

#

without leaving an idle core

vagrant surge
#

the main core has to run around scheduling stuff

minor sapphire
#

did you see my screenshot?

#

I have 6ms waiting...

#

I spent effort to remove syncpoints and jobify

vagrant surge
#

how many cores you got there?

minor sapphire
#

4, no hyperthreading

#

3 worker threads keep very busy in simulation group

vagrant surge
#

weird

minor sapphire
#

main threads rushes through scheduling then waits at the finish line (end sim command buffer) sipping lemonaid waiting for workers to catch up

#

to optimise utilisation, I could theoretically 'de-jobify' some of the later systems

#

which seems silly hehe

vagrant surge
#

thats the kind of thing that should be classed as bug i think

minor sapphire
#

for code that isn't super well jobified you'd expect the main thread to lag behind and thus not have this kind of issue heh

#

but I just keep thinking surely I'm missing something

#

is there really no way to define number of workers? I'm gonna look into it

#

Joachim_Ante (May 8): We are adding API's to limit the worker thread count at runtime and via command line.

#

if I had hyperthreading the physical could would still be utilised I think cause it would have one thread that isn't the main thread assigned to it

dull copper
#

I feel this setup would work just fine with HT

minor sapphire
#

imo in their implementation of 'JobHandle.Complete()', the main thread should check "IsComplete" and if false, bite off a chunk of dependent work like the other workers, and then check again

dull copper
#

as you still get some work assigned to the core if the logic is worker thread count = hw threads -1

minor sapphire
#

yes

#

hyper threading is only on i7s though right?

dull copper
#

i9's nowadays I think

minor sapphire
#

what no i7 hyperthreading?

dull copper
#

I think they make i7's now without, yes

minor sapphire
#

wow

dull copper
#

it's just stupid renaming policy

#

people want to buy bigger numbers

minor sapphire
#

not many people have an i9

dull copper
vagrant surge
#

its retarded

minor sapphire
#

I suppose if they're going with more physical cores I can't complain πŸ˜„

vagrant surge
#

specially because hyperthreading is as close as "free perf" as you can get in cpus

minor sapphire
#

but it does mean if they have thread count = core count then highly-jobified code will have one physical core idle in current state

dull copper
#

I just think myself that new i7 is just i5

#

and new i9 is "i7"

vagrant surge
#

meanwhile AMD

minor sapphire
#

imagine main thread just calling 'schedule' a bunch of times and then waiting at commandbuffer

vagrant surge
#

12 strong cores for 500 dollas tho.im definitely getting one

minor sapphire
#

yeah I'm pretty happy to see more cores trend after what seems like eternity stuck in quad core world

vagrant surge
#

unity is being quite smart with the whole job system stuff

#

unreal is not doing anything about it

minor sapphire
#

8 physical cores + hyperthreading... I waannnntttt

vagrant surge
#

they are reserving the 16 core one

#

they 100% have those ready to ship

#

probably just in case intel tries to do anything

dull copper
#

oh, I didn't even notice Unity updated the beta forums to have "Data Oriented Technology Stack" now

#

has that been changed for a long time already?

vagrant surge
#

wasnt it you who told me that they changed name?

minor sapphire
#

yeah for a while now

dull copper
#

no I mean, the forum section went for the old name for ages

#

I have the old one on the pinned link too

#

I'll update it altho forum sw can redirect

minor sapphire
#

I'm gonna edit ecs source to add another worker... if I can

#

gotta find the code...

#

I'll compare and report back πŸ˜„

#

imo just change the implementation of "Complete" heh

#

these sync points

#

would this be in unity.jobs? unity.entities? unity.entities.hybrid? can't see anything obvious...

dull copper
#

would expect the job system to manage the worker amount

minor sapphire
#

wonder where the actual jobs system code is...

#

maybe it's in main engine..?

dull copper
#

oh, that's just job system extension package

#

actual job system ships with Unity

minor sapphire
#

ah damn so I can't go changing it

dull copper
#

probably not unless they expose some setting for that

minor sapphire
#

for a moment, the main thread is like, you know what, I'm gonna get off my a** and help

#

could it be that maybe there is a profiler bug?

#

or do I need to a deep profile? I'll try that

#

problem with deep profile is now the main thread is too busy dealing with the deep profiling lool

#

the worker threads are on holiday now haha

#

I dunno, perhaps I should give up for the moment

#

I'll just keep building the game until inevitably I fail at jobification and end up with a main thread bottleneck? πŸ˜‚

#

oh another thing I can look at is total job time vs the sum of instance time I can see

#

if it adds up to ~75% I guess the main thread is secretly helping behind the profiler's back πŸ˜„

#

It says 4 instances, but I summed the instance time of the 3 instances I could see, and got a total of 7.17ms.

#

which equals the total it shows, but it shows 4 instances!

#

added to forum post. possible bug I guess.

#

I'll more on from this now lol

minor sapphire
#

can't have a ref type even in a single threaded non-burst job...?

vagrant surge
#

@minor sapphire jobs are jobs, even if singlethread

minor sapphire
#

it is true jobs are jobs

vagrant surge
#

unity basically thinks jobs are "run anywhere", and does all of its safety mechanisms

tawdry tree
#

Isn't there an unsafe kinda attribute you can use? Not that I'd advise you to actually use that (dangerous!), but I think it exists. That said, if you run it singlethreaded anyway, just use a normal method.

minor sapphire
#

fairly old core i5 handles 10k ship battle @60fps
would love to see what more cores can do...

vagrant surge
#

lovely

tawdry tree
#

Oooh, looks even better than that that gif you shared a bit back

safe lintel
#

nice, my play results with 33k ships

magic frigate
mint iron
#

maybe someone has some insight into this performance quirk:

        _world.Update();
        var sw3 = Stopwatch.StartNew();
        _world.Update();
        sw3.Stop();
        Debug.Log($"TestSystem Took: {sw3.Elapsed.TotalMilliseconds:N4}");

_world.Update(); runs a burst job, and when i have it executed twice in a row like shown, it takes 0.0006 - 0.0015 ms. But when i comment out the first _world.Update(); it runs at 0.0040-0.0060 ms.

I'm aware that burst jobs take a perf hit on the first run due to the reflection etc but once its cached it runs fast. Except, this block of code is being executed in a MonoBehavior every Update call, so its spamming constantly. I hadn't expected a difference when run close together; could this be explained by cache hits or is there some other short term caching going on with burst jobs.

Seems very odd to me.

knotty radish
#

Maybe you could look at the performance tool package if you really want some benchmarks, it will handle not using first Updates and diff across multiple frames (and other nice features)

minor sapphire
#

Wow you guys got some sweet numbers on i7! I think I need a CPU upgrade!

#

Oo a hexacore too.

minor sapphire
#

My post in main thread utilisation is quite derailed lol.

dull copper
#

@minor sapphire small nitpicking on your post #10 on that thread, you are using 0.1.0 version of Unity Physics πŸ˜ƒ

#

just mentioning it in case someone thinks Unity Physics is actually reached 1.0.0

#

I'm going to get system upgrade too but I'll wait for the new Ryzen's to arrive to the market as they looked pretty sweet (only available late this summer)

minor sapphire
#

oh yes I have 1.0.0

#

I better update!

#

Oh wait I did say I'm running 2019.2.0b2, with physics 1.0 (latest)

#

I'll add .0 on the end to be sure haha

dull copper
#

@minor sapphire you got time machine then πŸ˜„

#

there's three versions so far, 0.0.1-preview, 0.0.2-preview and 0.1.0-preview

minor sapphire
#

oh lol right I have the latest I what I meant to say πŸ˜„

#

fixed lol

dull copper
#

it's no big deal, it's just if I've learned something is that people do gravedig old forum threads, so people may get confused if they find a post in the future that talks about things that may not be relevant for the final release

minor sapphire
#

yeah that's for noticing πŸ˜ƒ

tribal fog
#

f1.

minor sapphire
tribal fog
#

im running 5.0.0

minor sapphire
#

test project with one system and one IJobForEachWithEntity, and it registers itself to EndSimCmdBuffer

#

looks like ONLY one thread is working?

#

it is a heavy job with only 100 entities

#

this is many more entities (therefore I ore chunks) but the individual work load is much lighter

#

nothing has change regarding sync points

minor sapphire
#

what do you guys use the initialization system group for?

tawdry tree
#

I have yet to actually use the systemgroups, but is that as simple as an [Attribute] or making it a dependency? Seem to remember something like that from before.

dull copper
#

I wonder how long it'll take for Unity to fix the simulation group

#

it's still framerate dependent by deafult

#

(at least Unity Physics stepping that uses that group)

minor sapphire
#

oh yeah I was wondering that myself

#

Oh wait unity physics is locked at 50 hertz

#

That's what SteveeHavok mentioned a few days ago

#

but did say that is temporary

dull copper
#

really?

#

I don't think it is

#

it seems to be locked on the editor

#

but if you build standalone, it runs as fast it can unless you have vsync enabled on your build

minor sapphire
#

lemme see if I can dig up the post

#

hmm interesting

dull copper
#

50Hz would be the default physics timestep on Unity's settings (for Time.fixedDeltaTime)

#

the old hack PhilSA made for 0.0.1 also broke on recent version

#

(to run the simulation group manually at fixed timesteps)

#

I haven't really put any effort to investigate this myself as it's kinda pointless

#

any fix I make now may break on next version when they change their systems again

#

so, will just keep using vsync and see what they come up with first and then see if I want to change it

minor sapphire
#

here is the post

#

I'll keep a closer eye on whether I see physics 'every' frame 'once' in my tests

#

Main thread REALLY doesn't like to get involved LOL

dull copper
#

well, the post you linked linked into PhilSA's post about the hack I mentioned

#

ah, I know what's confusion is about now

#

Unity Physics steps at expected 50Hz rate

#

but it steps that on every time you run through the main loop

#

so the faster you run, faster your physics will appear to run

minor sapphire
#

oohhhh

dull copper
#

as Unity Physics internal simulation step is 0.02

minor sapphire
#

that makes some sense I guess heh

vagrant surge
#

wtf why 50 hz

minor sapphire
#

it also explains why some frames it seems to run faster than others

vagrant surge
#

why not 60

dull copper
#

it's because Unity has always defaulted to 50

vagrant surge
#

the common FPS is 30 or 60, by having the physics at 50, its not contiguous

dull copper
#

it has nothing to do with the framerate as it's decoupled in Unity anyway

#

in unreal, you always sync and run the physics to the Tick, but this causes variable physics simulation steps

#

in Unity, we've used to having fixed timesteps for physics

#

and then if you need to sync it to rendering perfectly, you use interpolation or extrapolation

#

there's also option to manually simulate physics steps in Unity and then you can do UE4 like setup if you want

vagrant surge
#

but precisely for that. A lot of games lock to either 30 or 60

#

so having the physics locked to that would be a much better number

dull copper
#

well, then you can do the manual stepping

#

but it's not been an option for more than 2 years now

#

so, the 50Hz option is quite legacy default

#

I think it goes like over decade back

#

of course, we don't really know what kind of final setup we will get for DOTS physics (Unity Physics package), that's just how it's been on regular physics sim in Unity

gusty comet
#

Hi I'm having a problem, I'm getting this error Loading a managed string literal is not supported by burst and this error The managed function UnityEngine.Debug.Log(object message)is not supported by burst on this

public void Execute(ref ECS c0) => Debug.Log(c0.test ? "It's working!" : "It isn't working...");

and these errors, Boxing a valuetype byte to a managed object is not supported by burst, The managed function object.Equals(object objA, object objB) is not supported by burst on this

public static implicit operator bool(Boolean value) => value.Value is 1;
minor sapphire
#

yeah that's cause you can't use managed objects in burst Visual

#

this includes strings

dull copper
#

there's NativeString thing that should work I think

minor sapphire
#

if you wanna debug test with logs, temporarily remove burst

dull copper
#

never used it

minor sapphire
#

I haven't used it either, when was that added??

#

do you have to call Dispose as usual?

dull copper
#

it's been a while

#

like, 3-4 versions ago I think

minor sapphire
#

at least we didn't have to have NativeBool πŸ˜‚

dull copper
#

it's not in the changelog

minor sapphire
#

my thread got interesting 0lento

#

I think main thread just bails out of helping long dependency chains after helping like once

dull copper
#

would be nice to get some staff response there

minor sapphire
#

I'm gonna increase entity count more and reduce job work load to ensure there are enough chunks to go around

minor sapphire
#

yep, definitely a main thread bail out. But I still have that nagging feeling like "idiot, you made a mistake and now your stupidity is immortalised on the forum" πŸ˜‚

#

all test results on post with screenshots and code so hopefully if no one points out a flaw then I'm not a total idiot πŸ˜„

minor sapphire
#

anyone got a near-latest version of unity?

#

I wanna know if upgrading is gonna solve this cpu utilisation problem lol

dull copper
#

I doubt it

#

it looks like that for me on latest 2019.3 alphas too

minor sapphire
#

in your own code?

dull copper
#

all ecs code I've ran

#

I can check how it looks using latest physics samples

minor sapphire
#

you usually have main thread waiting idle?

dull copper
#

main thread is still doing other things, mainly meant the 3 worker threads being there

#

now that I look at the profiler on a5, there are background jobs listed as well, but they don't have any jobs assigned to them

minor sapphire
#

a5?

dull copper
#

2019.3.0a5

minor sapphire
#

oh right right

minor sapphire
#

argh I've been so unproductive today. I blame the forum.

craggy orbit
#

i'm very new to using ECS and have a question about it. i know that with regular non-ECS stuff, it's good to pool stuff (sometimes). say i have exactly 1,000 identical (besides translation) entities. should i create them all on launch and keep them there hidden until needed, or should i create and remove as needed? im guessing i should probably keep them all but you never know 🀷 just thought i'd get some more input on it

minor sapphire
#

create and remove as needed

#

pooling is useful in old world because objects carry a lot of baggage

craggy orbit
#

oh for real? great to know! thanks very much!

minor sapphire
#

yeah for real πŸ˜„

#

feel free to ask questions cause I was new about a month and a bit ago

#

and yeah, lots of new things to get used to lol

craggy orbit
#

i've got some basic ECS stuff working, but i just feel like i could push it a tiny bit further. thank you for offering to help!

vagrant surge
#

@craggy orbit the way the ECS itself works, its basically doing pooling on EVERYTHING by default

cunning monolith
#

Can't figure out how to use jobified raycasts for bullets. I have BulletSystem of type IJobForEach, which moves all bullets according to speed. This system also must do raycast for each bullet. So, how to properly call raycast from inside burst job?
Manual says "If you are already in a Burst job, just call as normal...", but i am missing the point, normal call is totally not working, it must be properly jobified somehow.

vagrant surge
#

so yeah, absolutely zero need. And creating/destroying objects is cheap, so feel free to do so

#

instead of disabling an object, just delete it and leave a "mark" or someting to restore it later

minor sapphire
#

@cunning monolith are you using Unity.Physics or wanting to use PhysX?

#

or, your own implementation πŸ˜„

cunning monolith
#

@minor sapphire Unity Physics

minor sapphire
#

too long I'll DM

cunning monolith
#

fixed raycasts by adding [Readonly] to physics world passed inside job. Thanks to @minor sapphire

#

ECS stuff is hardcore, i am barely understanding what i am doing )

minor sapphire
#

ya in a few weeks it'll be fine haha

#

@dull copper you using unity physics with dynamic physics bodies?

dull copper
#

barely, I'd ultimately want all my physics systems work with Unity physics but my ECS port has been on hold for a quite good while, should get back to it soon

#

I've mainly followed what they change and where it's going for the time being

#

also tested the builds with these systems in places (you've probably seen my IL2CPP comments :D) as I can't even consider things that break the build

minor sapphire
#

right

dull copper
#

getting the IL2CPP to work properly last week was nice tho, I can try to push more on these things

minor sapphire
#

I'm considering now switching from super basic movement to velocity based movement, and figured, unity physics would probably do this better than I would...

dull copper
#

still have few other items on my list before it tho

minor sapphire
#

maybe I should give IL2CPP build a go and see what performance is like if it works

dull copper
#

make sure to grab the link.xml from dots physics samples if you do πŸ˜„

#

(in other words, don't make same mistake as I did)

#

I don't think IL2CPP will improve your perf much, could be +- 0 on that front

minor sapphire
#

hmm what do I put where? lol

dull copper
#

it can be anywhere in the assets folder I think

#

dots physics samples have it on Assets folder directly

minor sapphire
#

what I just copy a file and put it in assets folder?

dull copper
#

yeah

#

I dunno if it had something extra that you needed to remove

#

but you definitely need the dots package refs there, there might be some test related things you may not need but I dunno if they do any harm either

#

it's basically just a list that tells what assemblies you don't want to strip from the managed side before it gets fed to IL2CPP

#

it's too aggressive by default and strips things that you would have needed

minor sapphire
#

ah I'll just wait till they fix it before trying il2cpp then lol

dull copper
#

causing ConvertToEntity to not render anything and also caused unity physics to crash on certain build confs for me

#

well, that could take a long time

#

it does build now if you just have that link.xml there to guide the system

#

I think I still got some crash on direct editor build but I usually build from VS solution anyway

#

I wonder if the remaining issue is just the stripping tool ignoring stuff still in that case

minor sapphire
#

ok I commented out all the test links

#

I'll see what happens lol

cunning monolith
#

How to delete entity with all children? Destroying parent via command buffer leaves his children to continue exist parentless

minor sapphire
#

I'm not sure on this one

#

it's a similar sort of issue but not about destroying

#

looks like children have a parent component, but I'm not sure if parents have references to their children

#

perhaps inspect the parent in the entity debugger and see if they have any components like that

cunning monolith
#

@minor sapphire yeah, seen that links. Parent have Child component on it, which holds array of children. But this is not normal IComponentData, i don't know how to properly access it

#

so how to traverse all children of entity?

minor sapphire
#

I have no idea, I've not tried to do this yet

#

worst case scenario is you'd have to create a component yourself with reference to children or something, probably a dynamic buffer, and do it manually

#

maybe create a helper method or something

#

but first keep googling and let me know if you find the answer lol

cunning monolith
minor sapphire
#

looks like it's a dynamic buffer

cunning monolith
#

so that is how it called. This way allows entity to have multiple components of same type

minor sapphire
#

basically

#

you specify a size, and i THINK anything over that size gets allocated to heap instead of stack? maybe??

#

I'll dm a couple of code sample I have with dynamic buffers

#

@dull copper IL2CPP build worked first try πŸ˜›

#

and I swear it's performing better...

#

need to proper comparison lol

#

man the IL2CPP build is BIIIG

#

like 650MB while the mono build is 125MB

hushed perch
#

doesn't it basically put all of the .NET Framework in there?

minor sapphire
#

I dunno ^^

hushed perch
#

I looked at the generated c++ code once, looked like basically all of corlib etc

minor sapphire
#

well, I'm just glad my project can build to IL2CPP for the time being haha

#

maybe later I can learn more about code stripping and stuff

#

Oh btw, look at Joachim_Ante go with his GPU vertex shader based animation system!

#
AnimationClips are converted to three textures that are sampled per vertex. All animation curves are converted to world space. This approach is insanely fast, and does practically no work on the CPU, but it is also limited what you can do with it due to everything being on the GPU & in world space.

I took the core code from the animation system, cleaned it up a whole lot and made a good workflow compatible with latest entities for it.

lol pretty awesome

hushed perch
#

nice

wooden pivot
#

@minor sapphire remeber to remove "DontShipThisWithYOurGame" folder from your builds

minor sapphire
#

Oh yes good point I was hasty with my alt enter of the whole folder πŸ˜‚

wooden pivot
#

that's some useless crap in your build which doubles it in size

minor sapphire
#

whadayaknow, the il2cpp build is smaller at 94MB

minor sapphire
#

I guess it's time to turn my movement systems into unity physics velocity based systems...

ember moth
#

Is it somehow possible to exclude a system from the editor world?

tropic cove
#

hi

#

i have jobs and burst packages but

#

i cannot use computejoboptimization attr

vivid kernel
#

hey guys sorry if this is a noob question, but what does the AlwaysUpdateSystem attribute mean? seen it in some examples

tawdry tree
#

I would guess it makes the system always update (run), possibly by turning off whatever automatically disables/destroys systems when you destroy the last entity it targets
TL;DR: Prolly makes it always update πŸ˜›

vivid kernel
#

even when you have no entities?

tawdry tree
#

Yeah, isn't that what I said? At least, it should've bene implied

minor sapphire
#

tommy if you call GetEntityQuery (or whatever it is) from a component system, the query is registered with some ECS unity thing. If the query returns no entities for a frame, then the system it's registered to doesn't get an OnUpdate call

#

unless you use [AlwaysUpdateSystem], in which case it doesn't care, and will always call OnUpdate

vivid kernel
#

thank you guys

minor sapphire
#

every time you use an EntityQuery in a system consider this point πŸ˜„

tawdry tree
#

I had an issue where I used one system to both spawn and destroy entities, which worked to begin with, but if I had ever spawned at least one entity and destroyed the last one, the system would deactivate. I looked for a way to disabled that, which sounds to be exactly what that attribute is for, but ended up splitting it into two systems.

safe lintel
#

@tropic cove i think thats now just [BurstCompile]

golden heron
#

Sup guys, does anyone know of any quick and easy way to tie the positions of a gameobject for visuals to an entity for physics, this will be a single case, maybe occasionally two objects done this way at once, never more than two tho. They are kinda a key piece of scenery.

#

The physics is my own, i just need to tie the position of an entity and a gameo ject firmly together, prefereably with the entity in control.

#

I did already do it for the camera, but it seems quite skippy.

tawdry tree
#

Make the gameobject a hybrid gameobject-entity?

#

Unfortunately I don't know exactly how to do that right now, but hybrid without converting sounds like what you want to do, ie. use ECS on a gameobject. SHould be some search terms for you from that.

ember moth
#

@tawdry tree @golden heron
Yep GameObjectEntity should be the way to go as it has implemented this

public class GameObjectEntity : MonoBehaviour
....
        public Entity Entity
        {
            get
            {
                if (enabled && gameObject.activeInHierarchy)
                    ReInitializeEntityManagerAndEntityIfNecessary();
                return m_Entity;
            }
        }
        Entity m_Entity;
tawdry tree
#

That's how you do it?
No interface or anything?

ember moth
#

It is all inside that implementation. If you add the MB it will create an entity in World.Active and put a reference into the GO GameObjectEntity

golden heron
#

do you add that alongside a normal convert to entity?

ember moth
#

If you add both, you get two different entities, so it should be only one of them

safe lintel
#

you could use the conversion process? if the position seems skippy from the regular copytransformtogameobject its because the transform system happens in the simulation update group, and you might need to code yourself a copy transform system that works in the presentation update group

minor sapphire
#

hmm should I give alpha 5 a try...

#

maybe I'll stick with beta for the moment...

craggy orbit
#

don't try 2019.3 a5. i tried it when i was first starting out and builds don't work with ECS

minor sapphire
#

ah thanks for heads up πŸ˜„

craggy orbit
minor sapphire
#

I have voted!

#

democracy!

#

that issue is package .32

#

still happening on 33?

#

oh yes it states so

dull copper
#

@craggy orbit that is caused by the latest testing packages

#

If you actually use the versions set in the dependencies of entities package, builds work

#

I know because I had that issue as well

#

There is no reason to need the newest testing packages either :)

dull copper
#

if you have that happening without manually upgrading the testing packages, then I dunno but that's what I saw myself

#

the issue reports repro didn't mention these testing packages at all

minor sapphire
#

Do I need to start looking at AMD CPUs? they seem to have improved quite a lot

#

3rd gen ryzen is looking pretty sweet

#

better go look at some benchmarks

dull copper
#

I'm definitely waiting over summer for them (new gen not yet available)

minor sapphire
#

they mentioned July 7 launch

#

$500 12 core

#

105 watts

dull copper
#

yeah but you usually don't have much stock then

#

I'm especially looking to get the 12c one

#

been stuck with my 4c/4t one for 6 years now which is few years longer than I usually have between upgrade πŸ˜ƒ

minor sapphire
#

Yeah, I've been on this since... hmm witcher 3 and arkham city were being promoted with gtx 970 card sales... when the heck was that lol

#

probs 5 years or something

dull copper
minor sapphire
#

oo so technical

minor sapphire
#

aw I seem to have maxed out on components in my IJobForEach for the first time, I need a 7 component overload lol

#

unless I can get world rotation from LocalToWorld...?

#

whhiicch I can

#

πŸ˜„

golden heron
#

Anyone worked on an ecs floating origin system? Im gonna need to implement one.

#

Otherwise, im kinda looking for some hints as to what people might think is causing the jitter in my camera, ill post a couple of videos now.

minor sapphire
#

aaahhhh I got a reply from unity staffer on my thread utilisation question I'm excited to see the answer when he investigates further

safe lintel
#

@golden heron it could be due to being inside the simulation group if it uses copytransform____, instead of the presentation group

winter veldt
#

is there a way to find all the components in an entity yet? either by identifying the archetype, then getting the components in an archetype? or some other direct way?

safe lintel
#

all of them or a specific one?

winter veldt
#

the concept is specific entity saving, regaurdless of it's type... so you attach a "Save" tag to an entity, and the save system saves it's component data.

#

it would be very beneficial to figure out what entity is being saved at runtime.

#

or would i need to specifically create a system for every savable entity type?

safe lintel
#

oh

#

no idea then πŸ˜„

tawdry tree
#

Pretty sure the entitymanager has .Get(Shared)Components (note the plural) methods, though I might remember wrong

winter veldt
#

yes, but that requires you to supply a type, i was hoping for something like getting a list of all components tied to an entity

minor sapphire
#

Even if you get your managed list into a blob, won't the compiler still complain about working with managed types?

zenith wyvern
#
Game Torrahod

This is one of the most misunderstood feature of ECS. Usually results in question like "How could I get SCD data in a job? I can't? Useless!" when you don't know how it was designed. So let's get to know how it works throughly.

vivid kernel
#

What's the difference between addcomponentdata and setcomponentdata?

zenith wyvern
#

One lets you set the component values as you add it, the other just adds a component

vivid kernel
#

Ok I just wanted to make sure because I wasn't sure if you had to set all the values when calling setcomponentdata

manic laurel
#

I have been playing around with ECS recently and I came across a situation that I wasn't quite sure how to transfer well.
Imagine a grid of entities. Each entity has some form of connection to the entity next to it (though not all spaces have to be occupied).
Now, the simplest way to handle this would be to just have a component that stores some kind of index (x, y). But then this would require iterating all of those components every time I wanted to find the neighbouring entities.

One thought I had was to turn it into a graph based structure. That is, each entity would have a component that links to 4 other entities (potentially null if there is no connection). This would give a simple way to work on all the entities that are surrounding an entity but it also just doesn't seem like a very nice solution. It is a bit hacky and doesn't respect the cache. Aside from this solution I am not really sure of another way to approach this that works nicely and allows the kind of queries and manipulations that I am after.
So I am curious if anyone has any ideas or thoughts on the matter?

low tangle
#

thats pretty much how unity handles it

#

in transforms in a older version at least, they create DAGs for entity->child parents and easy looking up of information

#

sometimes you can't get around random access and thats okay, you will still have about the best performance you can get anyways

#

hashmaps and acceleration stuctures can be build quickly and fast with burst from the linear entity data so its okay to build those every frame even

#

but you can even make sure you only modify those when needed by checking for chunk changes, or entity changes before invalidating the structures

manic laurel
#

That is fair, I am not really worried about performance, it isn't a limiting factor but I do want a nice architecture to work with.

Your second point there does give me an idea though. I have read that it is possible to inject systems into other systems (is this still the case as it seems injections are deprecated?)
I could make a system that creates the mappings I would need and then inject that wherever I need it. This would actually be pretty decent because I could easily trigger that system to run and update only when required.

low tangle
#

you don't inject anymore, instead you directly grab the target system and keep a reference to them :)

#
internal class LogicSystem : ComponentSystem
    {
        EntityQuery downloadWorld;

        LocalPlayerSingletonSystem LocalBody;

        protected override void OnCreateManager()
        {
            downloadWorld = GetEntityQuery(
                typeof(ClientLogic),
                typeof(DownloadWorldMessage));

            LocalBody = World.GetOrCreateSystem<LocalPlayerSingletonSystem>();
        }
#

trimmed it a bit

#

pattern is basically get your querys and jobs all setup at the top of the component or job system in the create manager

#

keeping a local internal reference to the system

#

then just use public fields or methods on the system to get the info you need from it

#

make sure your update order is correct if you start assuming at certain times for it, it might update later in the frame so it will contain data from the last frame [UpdateBefore()], [UpdateGroup()] can help fix this

#

@manic laurel

manic laurel
#

Okay neat that seems reasonable to me. Seems like this could be a good solution to my problem, I will have to give it a go.
Thank you for all the help πŸ˜ƒ

dull copper
#

@low tangle is awesome here, no nonsense, always straight to the point πŸ˜ƒ

minor sapphire
#

is adding force in UnityPhysics a matter of updating the PhysicsVelocity values?

craggy orbit
tawdry tree
#

Hmm, might be that they're not actually doing much, can't tell since you cropped out what's below

#

Unless the bottom row there is the lowest one

minor sapphire
#

anyone seen a case where LocalToWorld.Up is not reliable in some frames? (it seems top point backwards occasionally...)

safe lintel
#

regarding the velocity i was doing that for a bit and it seemed to work as expected for forces but I dont know if its actually correct. I did later switch it to the applyimpulse in the physics extensions class

minor sapphire
#

oh I better check out that impulse thing

safe lintel
#

ComponentExtensions.cs has a bunch of nifty stuff

minor sapphire
#

when you apply impulse do you have to multiply by delta time or anything?

safe lintel
#

yeah I do

dull copper
#

if you need force like thing, then yes @minor sapphire

#

technically your deltatime is constant with fixed timestepped physics so if you just tune the impulse amount manually it doesn't really make any difference in the end (besides that you can use more physically correct values)

#

(I'd still do the multiplication for forces just for sake of clarity

#

also since mentioning this, make sure you use same deltatime as the physics sim does and not the one from your update loop (unless it's the same)

twin raven
#

I am trying out a simple system and get an error:
Entities.ForEach((ref PlayerTag tag, ref VelocityComponent velocity) =>

#

ArgumentException: ArchetypeChunk.GetNativeArray<PlayerTag> cannot be called on zero-sized IComponentData

#

I cannot find examples how to use that approach with tags

safe lintel
#

remove the tag from foreach

#

add it via the query and then plug the query into the foreach, like entities.with(mytagquery).foreach

twin raven
#

ah, thanks

safe lintel
#

same goes for using it in jobs, cant use it like a regular component but it can be added to a query or requirecomponenttag attribute

twin raven
#

Thanks, that will be handy.

worthy shard
golden heron
#

@worthy shard you mean the component datas?

#

The part you see in the inspector is a proxy, it holds like initialisation data, or methods to generate that data, and can display variables as it inherits from monobehaviour. Thats all assuming you are converting a gameobject to an entity.

#

Otherwise you can create an instance of the component data which then you set the values of, and apply it to an entity with the entity manager.

worthy shard
#

So the "components" are just monobehavior wrappers for the actual components that i would use if i create entities from script. Thats helpful, thanks!

safe lintel
#

thats a very old video fyi, that workflow of having a wrapper monobehaviour is now deprecated for the new conversion workflow(afaik there are no official videos on this)

worthy shard
#

Thats even easier, have to try that tomorrow

craggy orbit
#

wasn't quite sure where to ask this but since ECS uses Unity.Mathematics a lot i guess it can go here. i was having trouble correctly multiplying a quaternion (Mathematics) by a float3. i tried the non-Mathematics quaternion and it worked correctly. any explanation?

dull copper
#

@craggy orbit is other on degrees and other in radians?

#

(for eulers)

#

I think the new math lib favors rads

craggy orbit
#

ah. that could be it. i remember seeing somewhere that the new stuff prefers radians

#

oh beat me to it

#

thanks!

dull copper
#

np, do tell if it was that

craggy orbit
#

it kinda worked, but i had to press the rotate button about 60 times to get it to do a 90 degree turn (normally one press) so i have no clue

#

smh i was using the wrong quaternion

#

one sec

#

yeah it's radians for the Mathematics quaternion

outer verge
#

Should I .gitignore /Assets/EntityCache/*?

#

Seems that got created by using the new 2D anim package, which seems to use ECS under the hood

dull copper
#

you'd think since you can safely delete that and get new one back when you save the scene, it shouldn't do too much harm to ignore it

#

I dunno how this would affect if you do like Unity Cloud builds tho

#

as those might require the files to be there

outer verge
#

But I don't know whether that means that it should be ignored in general

safe lintel
#

yeah it can be ignored because those caches are generated from scene files(manually)

#

@craggy orbit did you use the new mathematics mul for multiplying?

craggy orbit
#

i did at first. then i switched to math.rotate (mathematics version). they seem to do the same thing in my case

safe lintel
#

ah

amber flicker
tawdry tree
#

Dang, nice! It's (as you say) always nice to have examples, especially when they're proper source repos such as that one.

#

Oooh, and they even made it a Unity Package so you can just package install it, too.

low tangle
#

I'm looking forward to when unity makes github loading though package manager easy and on the gui

dull copper
#

it's already on gui, kinda

#

bit it's pretty bare bones

blazing mural
#

Awesome! When installing that as a package however I cant seem to open the demo scene file as its read only? is this typical with custom packages right now?

blazing mural
#

nvm just copying it out lets me open it

mint iron
#

is anyone aware of plans to support static field access in burst? or maybe workaround.

mint iron
#

you can do readonly. but it seems to get loaded as a constant (perhaps in readonly memory) rather than being writable through any means after compilation by any means i can find

amber flicker
#

@gusty comet sorry don't have time to thoroughly answer all of those but I remember this forum post was pretty useful so would def recommend starting with it: https://forum.unity.com/threads/ecs-memory-layout.532028/
is having lots of component data on an entity slower than having less component data..? - yes, but if you need that data, whether it's better split across more entities depends very much on your particular requirements

#

No problem - I'm sure when other people are around they'll chirp in too πŸ˜ƒ

crystal zephyr
#

You can also adjust the chunk size for your use cases. But that's globally, so increasing it for an entity which needs lets say 30 kb to 32kb, then a single entity chunk has also its own 32kb.

dull copper
#

from recent blog post: ```md

  • Fall (Q3) this year: Preview DOTS-Netcode will be available sometime this fall providing a server-authoritative stack, including entity serialization, delta compression, forward prediction, and interpolation. Given the Preview state, developers should still expect breaking changes to the API surface until the stack achieves verified state.

  • Spring/Summer (Q2) next year: Production-quality DOTS-Netcode – we’re targeting a production-quality release next spring/summer with the DOTS-Netcode and UTP sufficiently stable and full-featured. By this time, developers should have a fairly stable API surface, tech stack, and better documentation.```

tawdry tree
#

Depends on how you add them, I would guess.
If you use commands, those should all happen at once, but I don't think that's guaranteed otherwise. That said, they make things really tricky if the archetype changes take effect immediately, so I reckon they take effect by the next simulation group, or what they're called. The cost might be immediate, however.
Disclaimer: These are just educated guesses

amber flicker
#

I’d actually like to know any definitive answer but I believe if you add components on the main thread, they are added then and there and cause corresponding layout change as you can access them immediately after

#

That’s why where possible you should use archetypes

tawdry tree
#

If you check the Entity type, it's actually just an Id, a version, and helpers. So when you know that as long as both of those are the same as what you got saved, it's the same entity. I don't know if archetype changes update the version, but I know it will update if you delete and another one takes it place.
Also, version 0 is a special case, and means it has just been added.

public struct Entity {
  public int Id;
  public int Version;
}
#

Basically, it's 0 as default, but given an actual ID.... at some point? It has to have the correct version by the time it has fully instantiated, or it would make all sorts of messed, so as long as you get the entity from or after entityManager.CreateEntity(); you should be fine.
Tl;DR: 0 is the default value for int, but it will be given a proper one as soon as the entity manger does its thing.

vagrant surge
#

@tawdry tree version is only changed when the entity is deleted

#

ID is an index used in plenty of arrays. Version is just for checking

#

and 32 bits of version is beyond overkill

#

but they are ok with it

crystal zephyr
#

An per entity versioning would be to expensive. The chunk level is the most detailed level you get. If a component in a chunk was changed or even there was only an attempt to change it will increase the version of the chunk and seen as changed.

#

The version in the entity is used for re-using entity ids, I guess.

#

If you create an entity and you get an entity (id) 1:1. The next one would be 2:1. But if you destroy entity 1:1 and you create a new one afterwards the id 1 will be used. To differentiate the the old and the new one the version is used. You new entity will have 1:2.

frosty siren
#

Hi all, i was not programming DOTS for a month and after updating to .33 performance got weird. My systems that updates nothing takes 0.10 ms, and i see WaitForJobGroupID->Semaphore.WaitForSignal. I read changelog but i see no info about this.

And i have spikes in profiler with UpdateDynamicRenderBatches->Sort Shared Renderers -> GC.Collect that takes 20.79 ms. But i have only 10k cubes in my scene

tawdry tree
#

They do use shared components with the render data, right?

safe lintel
#

i used to think my biggest hurdle was waiting on dots animation but i think rendering is it, given how current shared rendermeshes work with chunks I have no idea how they intend to tackle all the stuff we take for granted with the old way of doing things

#

yeah i hit a crossroads and im contemplating a major shift back to non dots stuff

tawdry tree
#

I don't know the details, but if it is the exact same rendermesh SharedComponentData, then it does the magic stuff. If it's not the same, then I don't know... It's a bit opaque right now, and I have questions myself I would like answered. 🀷

manic laurel
#

On the topic of RenderMesh is it possible to control per instance material properties? I can't think of a way but I also don't know much about how it all works. Not averse to making my own rendering setup for ECS that can but I would like to keep using the builtin if possible.

indigo orchid
#

When dealing with the jobs system in ECS how can I do a producer/consumer type model? I thought NativeQueues would work but they don't seem to.
Basically I have one job that iterates all entities with certain components. From there some of those entities will need to have new components added. Because I want to burst compile this job I can't use an entity command buffer. So I my plan was to make a second job whose sole purpose was to add the component to the entity. In the first job entities would be added to a queue such that the second job can take them off of the queue and do the command buffer stuff.
Hopefully that explanation of the problem is good enough otherwise I can write up a minimal example to post.

tawdry tree
#

Which part stops you? If you want one job to run after the other you need to chain them, something like (pseudocode)

var queue = new NativeQueue();
var burstJobHandle = new BurstJob(queue).Schedule();
var commandBufferJobHandle = new CommandBufferJob(queue).Schedule(burstJobHandle);

Exact signature depends on which kind of job you use, of course.

indigo orchid
#

In this case I want them to run in parallel though. There shouldn't have to be a dependency

tawdry tree
#

You can't have them run concurrently, though. Concurrnecy and collections is hell

indigo orchid
#

Doesn't seem like it should be an issue to me though? It is classic producer consumer. One thread will keep dumping the entities that need to have the component added and the other will take them off as they are produced in order to buffer it.

#

Of course I don't actually need this but I am just experimenting and this is definitely something I would like to know how to do.

vagrant surge
#

@indigo orchid adding components needs a memory swap and some data structure updates

#

essentialy it is IMPOSSIBLE to do it multithreaded

#

the command buffer stuff is actually executed in the main thread, and its a hard sync point

indigo orchid
#

That's fair. Considering it is a buffer anyway I don't expect performance gain from this anyway.
Is there a way to do a general producer consumer model in a system though? Just out of curiosity?

vagrant surge
#

i dont know

amber flicker
#

I think maybe it fits best if you think adding a component to an entity that then a system consumes. Obviously right now adding components isn’t that fast but still, I’d say that’s how it is supposed to fit that paradigm?

vagrant surge
#

hell no

amber flicker
#

?

vagrant surge
#

native queues

#

adding components is very expensive

#

for a producer/consumer, the best is to have a parallel-for or similar that pushes data into queue

#

and then

#

another job that consumes it

#

but not at the same tim

amber flicker
#

Sure, native queues can be faster but like all things, depends on your requirements

vagrant surge
#

they are faster

#

to not be, must be some extremelly weir dcase

indigo orchid
#

Queues was my guess but I don't see how you can have the two jobs working in parallel?

#

Because as far as I can tell you can't write and read from a queue in two separate jobs?

vagrant surge
#

you can, but not at the same time i think

amber flicker
#

You can read once it’s finished writing

indigo orchid
#

Yeah, which is good and probably all you'd ever need. I'm just curious if there is a way such that you don't have to have that requirement.
That is, one job pushes onto some kind of queue which another job takes off the queue and both jobs are running in parallel.

vagrant surge
#

you dont want that in a job system

indigo orchid
#

Why not?

vagrant surge
#

the consumer thread will have to block

#

to wait for more data from the producer

#

this will stall

#

in a job system, what you want is tasks that NEVER stall, so you can execute everything

#

thats why its better to not have producer/consumer at the same time

#

just produce all stuff at once from a couple jobs, and then another job consumes

indigo orchid
#

Doesn't necessarily have to be the case though and the producer can always signal that it is done sending items. I agree that it is a weird thing that you probably wouldn't want to do just for the headache alone though.

vagrant surge
#

would need a mutex or so

#

and mutex are essentially fully banned in job systems

#

btw, i have done producer/consumer myself, but what i did is to launch the consumer when the producer is 90% done

#

and thats.. dangerous

#

would be possible for the consumer to end up with no itema

#

(this in C++)

#

so thats more or less why unity doesnt want to do that. Better leave the specific sync point

indigo orchid
#

That's fair enough, thanks for the help!

tawdry tree
#

Seems to me the short version on how to producer/consumer in ECS is 'no, you don't use that pattern with the ECS pattern'. As discussed you can do something similar but not the same. I dunno, just seems like a square peg, round hole problem.

vagrant surge
#

@tawdry tree producer/consumer on ecs is quite common

#

but with separate steps

#

not producer/consumer at te same time, but some threads producing stuff, and then other threads consuming stuff

tawdry tree
#

Well, then it becomes a definition thing - Is it really producer/consumer if you do function X makes something and function Y then uses that? If so, basically any application working with data has some form of it. The Wikipedia page on "Producer–consumer problem" defines that as "a multi-process synchronization problem", which I would take as not including fully synchronous work, and this is just a step from that - two separate parallelized tasks, ran sequentially.

sonic oyster
#

Guys, what's faster? Using IJobParallelFor or calling

	//queue IJob here
} ```
vagrant surge
#

parallel for

sonic oyster
#

Ofc I'm waiting for the job to complete on lateupdate

#

Okay thx

#

I might need to change my code a little bit now

tawdry tree
#

IJobParallelFor is literally made for that, so if it was not faster....

sonic oyster
#

Yeah but I'm iterating through 3D array

#

To generate map

#

And index in IJobParallelFor is 1D

vagrant surge
#

you can calculated 3d coord from 1d coord

#

for that, a quite good use case is to use morton codes (if your 3d array is power-of-two)

#

but it kinda doesnt matter much

minor sapphire
#

anyone used a custom collector in unity physics? I'm trying to figure out what a couple of interface methods are meant to do 😐

#

the TransformNewHits methods...

twin raven
#

I'm making a simple 2d physics engine in ecs. How can I update it in fixed timestep (multiple times a 1/60 frame)

trail burrow
#

@twin raven implement a custom update group with an overriden update that timesteps

merry oasis
#

can't seem to get frozen/static rendering to work, i have just the Static component on but it still uses dynamic rendering and when i add FrozenRenderSceneTag nothing renders at all

#

nothing renders even tho the static rendering method is being correctly called, i mean

amber flicker
#

@merry oasis possibly a long-shot but have you tried a simple Frozen tag?

merry oasis
#

i don't think you're supposed to add Frozen yourself

#

transform system will take in Static component, do the LocalToWorld calculation one last time, and then add Frozen component

#

but actually looking at it, seems like Frozen component is not being added or I cannot see it in the entity inspector

#

ok so having Frozen has no rendering happening, all 3 component groups in the rendering system are 0

#

thats Frozen by itself, and if there are both Static and Frozen

#

ok i got it to work

#

FrozenRenderSceneTag.SectionIndex just needs to be non-zero

amber flicker
#

Nice. I had no idea about that tag - do you have a link to a forum post or anything about it?

merry oasis
#

and also no Frozen component necessary

#

ah nope, if i google FrozenRenderSceneTag a total of 6 results come up lol

#

but it has no specifics on how to get it working, he just says "add this component" lol

#

but yeah my stuff is down from 22 ms to 0.22 ms so pretty good lol

odd bay
#

What does tagging an entity with a frozen component do?

odd bay
#

So what's the difference between a static tag and a frozen tag

#

It says that the static tag adds the frozen tag and the frozen tag stops LocalToWorld from upsating

amber flicker
#

yes, so static is essentially added for one frame where it updates the matrix

odd bay
#

Oh ok

#

I didn't see that part

merry oasis
#

i think so, but from the entity debugger i can see that Static is still on my entities

amber flicker
#

sorry yes, was just about to say - the static doesn't actually get removed

merry oasis
#

its probably something like

All<Static>,
None<Frozen>

then it adds Frozen

#

so it only runs once

odd bay
#

Does it cost anything to keep the static tag on it after it adds the frozen tag?

merry oasis
#

well its a tagging component, has no data, but idk if tagging components have been optimized yet

#

it might still store the internal component id per entity

#

or it could be ArchetypeChunk based like SharedComponentData is

#

idk on the specifics

amber flicker
#

afaik essentially no, a tag makes very little practical difference to perf

merry oasis
#

yeah i would think so too tbh

odd bay
#

so why not remove the static tag after it adds the frozen tag?

merry oasis
#

lol

#

Frozen is not even being added

#

i think docs are outdated, idk what Frozen does tbh

odd bay
#

Also, does the convert to entity component automatically apply the static tag to a static gameobject?

merry oasis
#

yes i think it should

#

but im generating my entities at runtime

amber flicker
#

I think when you add a tag, it makes those entities a different archetype, so if half your entities had the static tag added, it would split them into two archetypes. So if they all fit in 1 chunk before, now they'd be split into two chunks. RE: removing the static tag - a) it's slow to remove a component & b) the entity is still 'static' - as it just defines which archetype it is, there's no reason to remove it unless it becomes dynamic I guess?

merry oasis
#

well if you remove it, it will become dynamic

#

its only static as long as the component is on there

#

else the transform system will be doing calculations needlessly cuz your entity isn't moving in the first place

amber flicker
#

right - but hypothetically, I think Trevor was asking if frozen stopped it updating the transforms, why should it still be there

#

like I guess in theory you could swap a static tag for a frozen tag.... feels like a consequence of a lot of things changing.. need proper docs

merry oasis
#

well the transform system is looking for stuff that doesn't have Frozen

#

if you remove Frozen then the transform system can find it again

#

but yeah idk what Frozen is actually doing , but from what i can see Static does keep the transform system from working on these entities

amber flicker
#

right... if an entity marked as static is updated by the transform system every frame, maybe that's a little odd? idk

merry oasis
#

no i said if an entity has the Static component, its updated one last time, then its not updated again unless the Static component is removed

#

idk if Frozen is actually involved with this tbh, i can't see if a Frozen component is being added, at least not via the Entity Inspector

amber flicker
#

if the transform system updates an entity marked as static, it will do so forever unless it's archetype changes and has something like frozen added I would assume?

merry oasis
#

arg idk where the implementations of Static and Frozen are

#

theres nothing in the Unity.Transforms source code

#

not a single mention of either component, besides ofc Frozen's declaration

#

and Static's declaration is in Unity.Entities

amber flicker
#

yea nm - I've likely had far too much gin to be making any sense so I'm likely just confusing things πŸ˜… - glad you got that tag working at any rate

merry oasis
#

lol

lyric gust
#

What's everyone doing in ECS?

indigo orchid
#

Out of curiosity how did you get static/frozen to work? I just did a quick test and when adding static my entities still move and no frozen is added (like you said)

trail burrow
#

I'm just building unsafe collections that are compatible with the ECS atm, i.e. stuff that can be put on entities themselves

#
struct MyComponent : IComponentData {
  public UnsafeDictionary RelatedEntities;
}

etc.

minor sapphire
#

Fholm is it simple to add new ones?

#

Any gotchas that would turn someone off?

trail burrow
#

@minor sapphire how do you mean simple?

#

@minor sapphire well the thing that would turn people off from using them is that they are unsafe, i.e. you need to manage memory by hand, and they will not 'tell' you that you leaked memory like unitys NativeArray<T> etc do

#

but the benefit being that they're... generally faster than the unity ones (dictionary is about 2x as fast as unitys), and they can be put inside of components

crystal zephyr
#

Sound very interesting.

minor sapphire
#

Impressive performance.

crystal zephyr
#

@trail burrow Do you share it already somewhere?

trail burrow
#

@crystal zephyr a few of them i have shared, not all

#

they are not done yet

#

i also need to do HashSet<T>, Stack<T>, Queue<T>

mint iron
#

are you sharing these anywhere @trail burrow ?

trail burrow
#

@mint iron not atm, i shared a few of the simpler ones (array, ringbuffer, etc.)

#

but not more than that

mint iron
#

ahh okay, im definiately interested if you do πŸ˜„

#

make a store asset and ill buy it πŸ˜„

trail burrow
#

ha

mint iron
trail burrow
#

@mint iron so i took a different approach to mine

#

where the types are not generic

#

and instead have static generic methods on them

#
    _queue_spsc = UnsafeConcurrentBoundedQueue_SPSC.Allocate<int>(BENCH_COUNT);

    for (var i = 0; i < BENCH_COUNT; ++i) {
      UnsafeConcurrentBoundedQueue_SPSC.Push(_queue_spsc, i);
    }
mint iron
#

hmmm i've started seeing that more, unitys unsafeList and UnsafePtrList do that too.

#

it will be nice when they starting using 8.0 and we can do a lot more with constructed unamanged type support

#

oh i see what you're doing

trail burrow
#

@mint iron 7.3 has unmanaged support

#

I use that

#

that is available from 2018.3 and up

#
    public bool TryDequeue<T>(out T value) where T : unmanaged {
      T vc;

      while (true) {
        IntPtr h  = _head;
        IntPtr t  = _tail;
        IntPtr tn = Next(h);

        if (h != _head)
          continue;

        if (h == t) {
          if (IntPtr.Zero == tn) {
            value = default;
            return false;
          }

          Interlocked.CompareExchange(ref _tail, tn, t);
          continue;
        }

        vc = Value<T>(tn);

        if (h == Interlocked.CompareExchange(ref _head, tn, h)) {
          AllocHelper.Free((void*)h);
          break;
        }
      }

      value = vc;
      return true;
    }
#

i.e.

#

public bool TryDequeue<T>(out T value) where T : unmanaged {

mint iron
#

pops up all the time on VS 2019, this feature is currently in preview bla blah

trail burrow
#

ah yeah that will be nice

mint iron
#

so like, Something<T>*

trail burrow
#

yeah, that'll be nice

#

that would let me clean up the collections a bit

mint iron
#

yeah its pretty awkward right now

#

ive started keeping a generic and non generic version of things, and just casting it back and forth

#

so that they can be stored as fields etc

#

but you have to then have the type information available from elsewhere, parent etc

#

i figured out how to make useful/writable statics for burst this week. its been super useful.

#
    {
        public static readonly UnsafeList* SomeGlobalData = StaticPointer.Create<UnsafeList>();
    }```