#archived-dots
1 messages Β· Page 132 of 1
You should really simplify your problem, break it down to a couple of different entities with RenderMeshes and you will see how it works.
If you want to have any kind of instanced rendering you need to either add a new material/mesh or use the SRP material properties
Which are barely documented right now unfortunately, but they do work with SRP9 and Hybrid Renderer v2 when you set everything up properly, from my testing
I'd love to test that but the SRP9 package has gone AWOL in the last day or two.
What does that mean
you can find them in package manager
Absent Without Leave. It's missing from GitHub
You can get it directly through UPM if you're using a Unity version at or above 2020.1b3
Oh, cool! I'll go grab that then. It may not be documented, but it at least gives me something more than spinning my wheels
You just click the "all versions" thing in the package list and URP 9 shows up
Awesome. Going to back up my project, and get it converted over tonight then. Might sleep before playing with it.
I've been like a hamster in a wheel on this thing, and that hasn't happened in some years. It kept waking me up last night
Just keep in mind it's like brand new (for us), lighting doesn't work at all in URP, and there's almost no documenation
SRP9 works in HDRP though, right?
I haven't tried it but yeah as far as I know it works and is more fleshed out than URP right now
WRT to Hybrid Renderer that is
I saw that mentioned on the forums, and that's when I switched over, earlier today
What would be the best way to store the previous values of entities? I'm toying around with a 2D game and was thinking of using the previous velocity and this frame's velocity to see if I should start a walking animation. Currently I was thinking of just creating a "previous velocity" component, and have a system running at the end of the frame that updates it.
(Also open to other ways of simple detection on whether or not movement has started to play animations)
Suggestion: Put previous velocity, current velocity, and future velocity all in an acceleration component. Update future velocity using an acceleration rate multiplied by time since the user began the triggering input. Reach a max velocity that syncs with your animation, and then set the acceleration to mask when it isn't synced (sleight of hand, to make it look good). Have the previous velocity field solely to detect deceleration outside the system that set it. This way, your animation can do the same thing in reverse when the player lets off the button.
Then you can adapt both velocity and animation to other triggers and events as well, automatically, just by manipulating the three tenses of velocity.
Example: user runs a character into a wall, velocity is set to zero, and that abrupt stop triggers the collide animation. User hits a patch of waist high water, slows down, and the animation automatically slows to match. etc
I think i get it, though I didn't really understand what you meant with the: "and then set the acceleration to mask when it isn't synced"
And, I guess in that example, it's future velocity that's set to zero?
semi-dots/Netcode related, but anyone know if there's a way to call the new BuildConfiguration assets from command line?
How do i update a icomponentdata set ?
Can i simply do something like "myComponent.myvariable = 10" ?
Build configuration API has Build(), so I'll probably have to hook into a command line call in some custom way and forward it
I spawn only one entity archetype... but the entity debugger shows me two times the same entity... any idea why this may happen ?
show us the code π
Defining the archetype im spawning in
Spawning the entity... clone(0) simply calls the "createCharacter" method
and the customizer on the created entity
rider? π
whats going on exactly there? rider can alter syntax ?
createCharacter should create only 1 entityπ€
it is just visual thing , not real syntaxπ€
why though ? is there advantage to reading/writing code like this? is this mimicking some other language?
interesting.
@stone osprey are you sure createCharacter is called only one time, cause Clone does not sound like you are creating something new, it sounds like you are copying something, that already existsπ
@naive parrot @warped trail Yep rider... i like it more than vs and it has a great integration with Jetbrains toolbox, especially if you use other jetbrains IDE's... furthermore it comes along with many cool features, auto generation of unity event functions, showing asset usages or asset overrides etc... Back to the code, yep im debugging that since half an hour... its only getting called once, its called clone because it depends on the "prototyper" pattern, but it basically does not clone, it simply calls the referenced "createCharacters" method π
Were you able to find out the reason π
I know that when you convert a prefab and instantiate you will have 2 entities, 1 for prefab, 1 for 'clonse' of that prefab, i never did archetype stuff however so i cant know
still, doesnt sound like a big issue π
So as I understand it, there isn't really an "official" way to implement NavMesh agents with ECS, is there? I only really need a few handfuls of agents running around, so I was thinking I could just implement them in monobehaviour with gameobjects and then interface those with entities in the background, but I've also been having trouble actually interacting with gameobjects in a system
well no only using them as regular gameobjects and then just interfacing with them as you would any other monobehaviour
there are a few github repos of user solutions, if you search in the dots forum, but then you're at the mercy of the author if the official packages become out of date, personally im just biting the bullet and using the old unity engine stuff as I also still rely on skinned meshes and dont care to use 3rd party stuff while ecs is in preview(which might as well be forever)
Yeah, I saw a repo of some guy basically building navmesh from scratch in ECS, but that seems like overkill for my use case and also not futureproof as you say
Oh, I guess I've been doing it the wrong way around and I should try to work with entities in a monobehaviour script rather than with gameobjects in a system
I think there was an experimental API for multithreading navmeshes at some point in time
i think someone here(im butchering the name, xjvs?) posted a snippet on the forums using it, it worked well but its just for finding the path multithreaded and doesnt really cover any part of the movement agent side of things
ah
i havent played with it - but i can imagine you can copy the position back to the LTW matrix right?
funnily enough i chose that name specifically because its hard to remember
i felt bad π€ so much, given that you post so much here and I couldnt remember 4 letters!
Belated thanks, I'll have to look at that stuff
I might just try to make my horrible monobehaviour frankenstein work somehow first since I probably don't need to multithread my pathfinding too much when I expect to be handling at most like two dozen agents, but who knows
I think there was a forum topic about it
and also i think Astar pro project is using jobs/burst in their beta version if you have bought it
Hi! I'm trying to integrate HDRP decals into my project, is there any dots way to handle decals or is managing gameobjects the way to go?
Recently posted about the compute shader pipeline that we use instead of the UECS rendering pipeline: http://www.sebaslab.com/the-1millioncubes-challenge-how-i-managed-to-animate-a-freakload-of-cubes-on-windows-using-unity/
@scarlet inlet very nice
looks like that sub-updates is a persistently mapped cpu buffer
yeah I wouldn't use it in production though, very subjective to the driver implementation I think. However we use GPUInstancer as it is and the number of objects we can render doesn't stop to amaze me
you can make it safe if you do the triple-buffering yourself
but im not fully sure how unity does it
1 million instanced cubes is no joke
Look at this video, it's already a couple of releases old. Everything you see it's continuously processed, physic, logic, graphic. There is no zone culling or portal. There is only the rendering culling based on the frustum that GPUInstancer does https://www.youtube.com/watch?v=IrqMPyD6G-Q
Sequel to long gone but not forgotten Raid 51 level also built in GameCraft, some time ago, while it was still called RobocraftX and the scale of basic block was roughly 3 times as big. The game itself has come a long, long way since then and it's currently being developed mor...
lots of bushes there
hehe yes π
When I open the build of my game it crashes immediately during loading.. How can I find the problem if no error appears?
I use math.normalize
If you feed very small vector3 to these functions they will return NaN, and if you are doing any other operation depending on these values behaviour will be undefinied and can crash
But it was working before (there was already math.normalize)
I am using normalizesafe sorry, not math.normalize
ah okay, well i suggest you should do DisableAutoCreation attribute to your recently updated systems, thats how i find out
There is a problem.. how can I dispose a native array in a struct when it's destroyed?
You cant put native array into Component, but if you are talking about plain struct then i guess you simply dispose of it when you know the entity that has that struct is going to die
i never tried tho
this thread's interesting - https://forum.unity.com/threads/why-does-entity-inspection-not-let-us-edit-entities.866491/#post-5707438
π€ that's a pretty interesting find about the entity debugger
Yeah it's pretty interesting why it's not enabled by default π€
14th - faux gdc, entities 1.0??? π
Any one knows whether Convert of IConvertGameObjectToEntity called first or Awake called first?
convert first iirc
Tho it does sound like there is a better way to do what you are trying to do
Would Gamobject's position change after I set entity's translation if I select convert and inject game object in Convert To Entity
There is a problem. I want to spawn a entity and set its initial position. First I Instantiate a gameobject prefab with Convert To Entity script, then set Translate data in Convert function of IConvertGameObjectToEntity. But the this gameobject still spawned at position(0,0,0).
Is there a reason you're not using SubScenes?
There are 2 components to sync entity/gameobject transform, CopyTransformToGameObject and CopyTransformFromGameObject, they both live under Unity.Transforms namespace, if you are thinking about changing your entity's transform thru ECS then put CopyTransformToGameObject and entity's gameobject will sync, if you want to change your gameobject's transfrom thru MB then put CopyTransformFromGameObject and entity's transform will sync
afaik you cant put inject mode in SubScenes
thx, I will try it
What exactly is inject mode? Can't find anything in the docs
It basically needed for the gameobjects that you want to still exist after its converted to entity, its generally used for the functionality in MB that has no equilevant of it in ECS, such as camera
Will there be any link between the MB and the Entity?
so Unity puts a "CompanionLink" component in your entity and puts your gameobject to there
Well there you go
So I can query for CompanionLink to get the MB from there?
Because right now I'm doing it in a pretty janky way
Like for my UI (very temporary) I have a Canvas that has a UIManager MB. This MB is in charge of setting the UI in MB world.
To get the data from ECS I have another GO that get's converted. This has a converted hybrid component that references the UIManager.
Would it then instead be possible to have all this on the same object with inject instead?
quite possible, tho i suppose its better to do just have GameObject in your query
What do you mean?
All the stuff in your MB will be 'added' to your entity, for example if i have a camera in my entity, this camera component will be added to that entity, so in order to get all the entities that has a camera component in ForEach i can do
ForEach((Camera camera)=>).WithoutBurst().Run()
so GameObject itself will be also added to that entity so you can just do ForEach((GameObject gameObject)=>).WithoutBurst().Run()
But I can also get any MBs right?
Yes
Okay, then I guess in that case it would be better to use the UIManager, no?
For my example at least
(And note I'm not talking about the specifics of doing UI in ECS, more about interacting with MBs)
You can just put a dummy script in your gameobject and do inject, and inspect the entity debugger to see what unity has done
yes, if you put UIManager script in your gameobject and do inject
then simply do ForEach((UIManager uiManager)=>).WithoutBurst().Run()
Alright, that's good to know. But then I guess it will also get the canvas MB on there, which I don't think is quite optimal
Yeah, it makes sense. But it's just not something I'd really want access to in ECS world I guess
Or I could just get the UI stuff in the system and do it all there? π€
if your UIManager is a singleton i would just get the components i need from entity manager in OnUpdate method and set the necessary values, its a dirty way of doing it π
Can entities have a layer value? Like with GameObjects
Or do I have to implement it myself?
you'd have to implement it yourself
unless you're talking about the physics authoring π€
@wide fiber or you can wait for v2, there is rendering layer componentπ
@vagrant surge there's not much for DOTS announced yet. on 22 April there's "Meet the Team Behind DOTS Sample" which doesn't really tell much what it's about, doesn't sound very technical session either
28 April has "Using Burst Compiler to Optimize for Android" but if you are not into mobiles, I doubt that'll be that interesting either
"Description:Join this session to learn how our partnership with ARM helps bring the power of the Burst Compiler to Android, enhancing multicore processor performance and power management. Youβll learn how Burst grants ahead-of-time compilation of critical C# code to native code and the features it enables (e.g., Advanced SIMD)."
I think streaming is still a bit off
@bright sentinel ?
Advanced SIMD π
its quite nice for me as i was going to release my first game to mobile π
i'm still waiting for Mike's gdc talkπ
is that actually going to happen ?
π€·ββοΈ
Is this the place for tiny?
welcome @last jasper π - yea for what little there is, probably here
@dull copper I meant that streaming is probably not going to be landing for a while
I have a Cube prefab with physics shape an physics body which I convert to a entity: Then instantiate a bunch of this entity prefab and set its nonuniformscale component to random size. But this only changes the renderd mesh and the physics body stays the original size. is there a way to adjust this ?
@vivid copper https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/UnityPhysicsSamples/Assets/Demos/5. Modify/Scripts/ChangeSphereColliderRadiusBehaviour.cs
https://forum.unity.com/threads/resizing-a-capsule-collider-at-runtime.858748/
i don't think this will help himπ€
if he instantiating this objects from one prefab, then he basically get copies of BlobAssetReferense<Collider> which are pointing to same blobasset
just create new collider for every instantiated object which you want to modifyπ€
well you could create an array of sizes and make a collider for each one and then select one at random for a pseudo random effect, but theres not really an alternative and perhaps given how theyve responded to such things there may never be a true alternative π
i think i saw a checkbox in the physicsShape to force a unique collider
it is unique, when you create entity via authoring component π
but i may be wrong, and they figured something out for instantiating caseπ€
thanks for the input. I try it, might be that I come back to this ^^
Is there a dots api for animations ?
Is there an easy way to get the component in a child in a child? Or do I have to use queries to get the right child, than another query to get the component?
You can do GetBufferFromEntity<Child> in OnUpdate and access entity's child buffer using indexer access like buffer[entity]
i think there is a dots animation package but its in very early state so not sure if its usable right now
Is there a dots api for animations ?
@stone osprey
https://github.com/Unity-Technologies/Unity.Animation.Samples
HDRP only apparently
@wide fiber not really, no - though you can use ComponentDataFromEntity if you have the entity of the child to get the component data
Thanks @zenith wyvern ! So its very experimental right now... i guess im gonna stick with monos for the first :9
Another question... Is there a way to store "Action<>" or "Func" inside a component ?
Would love to have a health component which is able to call events on death/on alive
There's Burst FunctionPointer which can be stored in a component
Burst FunctionPointer... thats interessting π Is it able to return/accept params ?
I think events should probably be built around the idea of using Event Components or an actual event system though, building events into your actual components themselves is kinda an OOP way of doing things I think
It can accept and return params, yeah
just to add if you're thinking actions / callbacks to mb land, it'll all need to main thread - you could also use an ICD class potentially
I thought about event components... but i cant really decide between them and the integrated callbacks... both have advantages... @amber flicker So you mean the FunctionPointer<> calls are getting executed on the main thread ?
no, sorry if I confused things
Just to clarify a bit, the reason you might want to avoid callbacks inside your component - any time you need to call that callback, you need to pass in any state it requires. That means that state needs to be passed all down the line of your ECS system to get to your component callback, and it quickly becomes a whole thing
Ideally the components themselves will represent the events/state and your systems will respond to them. That tends to fit better in ECS imo at least
if you want to e.g. associate an action like () => gameObject.SetActive() with an entity, i.e. you're working in mb/managed land, you could use an ICD class instead. Or just a dictionary (entity, action) etc. Might not be what you're doing at all.
Ahhh alright... so you mean the bridge π Thats right... im currently going with a hybrid approach... ecs for the data structure and gameobjects for the visual part, so i guess theres no real multithreaded approach for this scenario right now...
Is there a documentation of "FunctionPointer" ? The Burst-Package does not know that struct
Oh wait
it selected the wrong version again
Ok thanks
Not sure where to ask, if I create a static function it is loaded inside the memory for as long as the programm runs. I assume it's loaded inside RAM. When I use that function it is loaded inside the cache, correct?
with this ecs, everyone became obsessed with cacheπ
Tell me all about Cache π
How can I query the components of a disabled entity?
I think it's very helpful to know this in the future, any Idea if there is a documentation on this? Prolly inside C# docs somewhere π§
@wide fiber .WithEntityQueryOptions(EntityQueryOptions.IncludeDisabled)
Ah ok thanks
If I want to only include disabled ones? Should I also put the .WithAll<Disabled>()?
yeah
:)
I have 2 platforms on the same level and they do not have a gap between but when my ball rolls fast enough over the "joint" it starts hoping. Is there something I can do?
this is something that unity physics does(i am not a fan π ), you either need to modify the simulation and weld the points(samples repo might have an example of this) or use havok which does this automatically
you have to specify which layers are weldedπ
can I weld at runtime? because these platforms are generated at runtime
There's going to be a livestream from the dots sample team right, anyone know when that is?
where was the official mention of that?
i also saw mentioned a while ago meet the dots team but i only ever saw that on discord
I don't know, I remember seeing it...somewhere. Now I can't find where
artengine π€
@vivid copper If they're generated at runtime, can't you just "weld" them together before spawning them?
well instantiated is the correct term, as soon as I figure out how to weld i'll try but i do not even find a guide for this
@vivid copper It's essentially making one big mesh instead of two small ones, and combining vertices close together
You can make a pretty simple algorithm for that yourself
kinda wish this stuff was just taken care of for me
I mean stuff like this isn't even in old physics
You'd have to do that yourself as well
I can imagine it might come at some point
I dont recall this behaviour in physx though?
I've had the behavior happen
but the mesh and the physic collider are not the same so modifing mesh would not relsult in a other behaviour does it?
honestly that whole marble sample project wouldnt really work if the bouncing was near the same magnitude you get in dots physics
It shouldn't
artengine π€
@safe lintel you saw the blog post about this right?
yeah, im just surprised because its not really available for the public at hand
roadmap stream gave impression that they are working on exposing it to regular customers
hm my impression from that was the unity implementation was going to be available, but its current state it would stay as is(but id like to be wrong)
at given the glacial timeframe things move at, im skeptical of what the talk will feature
it'll probably just talk about the underlying tech
at best they could give some roadmap where they are going with it
Btw, any Idea why the Values of our struct components are written with a capital letter? Only because inside structs you usually write with capital letters? Or is there another reason?
most likely just the MSDN C# conventions where public fields start with a capital letter
@safe lintel @warped trail
Havok and welding did it many thanks to you!
wow ml-agents is coming ? its pretty hard to work with but seems rewarding
i thought only public properties was starting with capital letter and fields were camelCase π€
oh @opaque ledge probably haha
I actually dont really know myself - as long as you keep it consistent
^^
Yeah i think its Unity thingie, thats what they do, such as naming their private variables with "m_"
anyone know why you would want to check the fraction for a raycast hit?
iirc, fraction gives a value 0-1. useful for interpolation maybe? maybe proximity checking too
from docsπ€ Lower level ray cast routines against primitives have a slightly different input. They do not compute the surface intersection point explicitly for efficiency reasons. Instead, given a ray of origin - O and displacement (combining direction & distance) - D, they return a hit fraction - f, which can be used later to compute the hit position if needed using O + (D * f)
thanks, can you link the page?
and this from Raycast.cs ```Note that the primitives are considered solid.
Any ray originating from within the primitive will return a hit,
however the hit fraction will be zero, and the hit normal
will be the negation of the ray displacement vector.
using Tertle's event system. Hasn't been converted to SystemBase AFAIK, so feeling my way through it. I'm getting a 1-frame lag with this code. Any ideas why?: https://hastebin.com/latajuvafu.cs
@fallow mason haven't read the rest but are your systems updating out of order? can check their order in entity debugger
might have to add an [UpdateAfter(typeof(EventProducer))] on your EventConsumer
heh yep consumer is before producer. silly mistake.
hmm still getting lag
nvm I think it had something to do with me creating a reader in the EventProducer. I thought I needed to provide a foreachcount for my writes. got rid of the reader stuff and the lag disappeared.
now I have to test multiple event producers and readers to make sure everyone is getting the events they need
oh yes, that is working nicely
A script inside an assembly definition file out to be able to see a script sitting in /Assets right? I shouldn't need to add any reference to the asmdef?
ought*
This seem like a pretty common thing to do, but for the life of me, I cannot figure this out. I have 1 entity that is the player that is moving around and a bunch of other entities that are spawning and moving towards a point. How do i best get a reference from the player entity to the following entities (without using collision) ?
Had a dream last night that I'd started work on the audio for my game and had to have a factory pattern providing minimal audio source gameobjects to an AudioSystem in ECS. Anyone know if/when audio will be integrated in Dots?
lol
There is DSPGraph
its pretty low level
Hello, anyone know where is the source code of EndSimulationEntityCommandBufferSystem
are you trying to create your own command buffer system ?
yes, want to create a similar one but different timing
create a class that inherits from EntityCommandBuffer
Thxπ
How can I cast a ColliderCast with UnityPhysics? There is no example in the documentation
what do you mean?
Is there a function called Physics.SphereCast in Unity?
Or do I have to copy/paste the code of the example
you get or create collider and then physicsWorld.CastCollider with itπ
So there is no function called for example SphereCast, I have to make the collider and cast it manually.. ok
new tiny packageπ₯³
@dark egret you can use SharedStatic https://docs.unity3d.com/Packages/com.unity.burst@1.3/manual/index.html#shared-static
How can I get the world and use it in a Job with Burst?
It gives me an error that says I can't use references, it's only allowed without burst
why do you need world in a job? π€
Hm, no changelog for Entities 0.9.1...
0.9.1 released ? π
you should look for it in packages folder, changelog in manual wont update immediately
why do you need world in a job? π€
@warped trail I don't need it anymore, I have found another solution
I make a grid (at runtime, every 2 seconds for example) for my map (AI pathfinding), to check what nodes are walkable I use a SphereCast for each Node and based on what I hit I can say if it's walkable. The problem is that I have 900 nodes, it spends 1 second to make all the casts (in the editor)
Better solution to find which nodes are walkable? (In future I may add penalty costs also)
@silver dragon * Fixed NullReferenceException issue with Singleton access methods in SystemBase. is the only change I think
Ah, right, there is a changelog in the packages folder π
Yep, it's the only change
Hybrid Renderer's update is simply updated dependincies
Anyone knows how to declare ReadOnly for temp variable of NativeMultiHashMap?
Which is used in parallel foreach of entities
@wide fiber check out this project https://github.com/jeffvella/UnityAStarNavigation its does node flagging for area weights for OBBs.
Ok
Anyone knows how to access ComponentDataFromEntity<T> in parallel Entities.ForEach?
always log error "xxx is not declared [ReadOnly] in a IJobParallelFor job"
you have to do .WithDisableParallelRestriction(yourVariable)
If I want to create a lot of entities with the same archetype and I want to change the values of some variables in the components what can I do?
Do I have to make a for and create the entities 1 by 1?
most likely, otherwise batch create and iterate over the returned native array
Ok thanks
maybe try WithReadOnly? π€
@warped trail ok now I need a world in the job. How can I sphere cast inside a Job? I need the world to make the sphere cast (it's the first line of the function)
The new Entities package was purely a hotfix
maybe try WithReadOnly? π€
@warped trail Yes, it is working π
@wide fiber : https://forum.unity.com/threads/invalidoperationexception-the-previously-scheduled-job.682744/#post-5491623
i use something like this https://pastebin.com/6rY2Wvmk
work around with struct is ugly π
I tried this with NetCode in the ghost prediction group, but no dice. Any way to get that to work?
no luck with what?π€
Physics queries
just do queries before or after physicsπ€
unless you really want to change something in simulation
Right, but it's not working with the ghost prediction group
NetCode is doing some things with physics that make it not work
have you looked at how they do raycasts in LagCompensation sample?
No π€ Is that in the multiplayer repo?
yes
I'll have a look
@silver dragon it doesn't work, I am using SystemBase, maybe there are some differences.. I will send the code in a few minutes
@wide fiber look at code i linkedπ€
Ah yes, need to be changed a bit for Systembase
@warped trail Hmm, that looks promising. It was pretty close to what I was doing, but not exactly. I'll try it out next week when I have time, thanks
@warped trail ok
@warped trail basically I need to add those lines of code (the variables, the OnCreate function and the dependencies inside OnUpdate) to every system that needs to access physics?
yeah, you have to deal with those FinalJobHandle things, when you work with physics because physics use native containers alotπ
:(
Ok thanks
Are your prefabs invisible too when you use dots ?
Just tried to open a prefab and its invisible, just the scene shows up
This is dots related... would be great if someone could check if they have similar problems
do you have hybrid renderer package?
Yep... but im not using it... does this cause it ?
if you're using entity prefabs, instanitating them in dots, then it uses hybrid renderer; ive started new proejcts before and forgot to add the package and they were all invisible π¦
I mean the prefab mode/view is invisible... not the prefab itself ^^
So if you double click on a prefab, its inivisble and shows the scene... if i spawn it in, it renders fine
oh yeah... its invisible for me too, i have no idea why, it makes me angry.
@warped trail It gives me an error (all the systems don't work, their functions aren't called):
Invalid [UpdateAfter] Unity.Entities.EndSimulationEntityCommandBufferSystem ... because it's already restricted to be the last
I have deleted the UpdateAfter but now it gives me dependencies error, I will send the code and the errors in a few seconds if you want
@mint iron Yep... its impossible to work with... my whole UI is prefab based and i cant edit anything... i found one single forum post... they said they gonna fix it and its dots related... but i really wanna find a short solution for this
you can't order a system outside unitys ECB systems within default a group, don't know why they enforce that, its super annoying.
@wide fiber oh, i made a mistake there, you need EndFramePhysicsSystemπ
[UpdateAfter(typeof(EndFramePhysicsSystem))]
prefab mode/view works fine in my project, or i don't understand somethingπ€
@warped trail What unity version ? ^^ And could you probably post your dots related packages here ?
Thats the only post i found about this issue
i use 2020
Ok it works, 900 sphere casts in 0.75 milliseconds, Burst compiler and jobs are awesome
very nice
you can try point distance query instead of sphere casts π€
Hey, whats the difference internally between creating a local var of components or using component.Value over and over again inside ForEach Lambda functions?
probably doesnt matter, but i generally do var
well one is making a new variable without basing it on something that exists
I think he is asking because he wants to optimize his caches π
hey guys, really trying hard on this one, is anyone able to help?
I'm trying to Instantiate an hybrid object (a gameobject, with its linked entity), from a system. I can't figure out the proper way to do it. Best solution i found so far is to do a simple GameObject.Instantiate(prefab), and let the ConvertToEntity to its stuff, but in that case, there is no way for me to find the linked Entity after my instantiate call... any idea?
ideally i'd like to do something like : InstantiateHybridGameObjectFromEntityPrefab(Entity prefab) : Entity
or if there is no way to do that, I'll use a hashmap to map my gameobject prefabs to my entity prefabs, and use something like : InstantiateHybridGameObjectFromEntityPrefab(GameObject prefab) : Entity
do you know how to convert a prefab to an entity in code ? or rather in authoring component ?
yes, creating an entity prefab isn't a problem
you want to do that and stash that returned entity to shared static or to a component, then simply instantiate that entity
but that wouldn't instantiate a gameobject, is it?
No, you have to stash the entity that was returned from that convert function
If you're using HybridComponent it should instantiate the GameObject with it
i am in bed and dinner is soon, so i cant show you a code π
@eager jungle You should read this article https://gametorrahod.com/game-object-conversion-and-subscene/
hmm ill have a look at that thanks
HybridComponent, what is it exactly?
i mean what are you refering to?
The article explains it in detail, basically it "attaches" a gameobject of your prefab to your entity
So the prefab instance lives and dies with your entity, and gets instantiated alongside it.
if you convert a gameobject prefab to an entity you wont need to do that afaik, it will automatically done for you
so you mean, if i then instantiate an entity prefab, the gameobject will be instantiated along with it ? i though i tried it earlier and it wasn't working..
Were you using conversionSystem.AddHybridComponent?
no
let me show you quickly,
im using IDeclareReferencedPrefabs
and then conversionSystem.GetPrimaryEntity to save my entity prefab to a component
yes, check from entity debugger if your entity prefab has "Companion Link" component, that is the responsible for instantiating gameobject and attach it to your entity
or at least thats what i heard π
Yeah I think that should basically do what HybridComponent does internally, like Curly said
That's the idea at least
doing the way i mentionned earlier using GetPrimaryEntity, my prefab entity does not have a companion Link component
im not sure if using hybrid components is the way forward, given what topher alluded to
what do you mean?
He said something like, hybrid component was never meant to use directly, it was an internal thing
you can try point distance query instead of sphere casts π€
@warped trail mmh..
hmm @opaque ledge @zenith wyvern @safe lintel really trying my best, but i can't figure this out...
My code is extremely simple... my GameObject prefab is referenced like this : referencedPrefabs.AddRange(goPrefab);
In the Convert method of my IConvertGameObjectToEntity, i use conversionSystem.GetPrimaryEntity(goPrefab) to store the prefab onto a Component
The prefab gameObject itself has a ConvertToEntity : Convert and Inject
I really can't find a way to instantiate a linked gameobject+entity pair from a system...
Using EntityManager.Instantiate(prefab); does not create a GameObject
Using GameObject.Instantiate(goPrefab); creates both but I cannot get the Entity back (and its created later anyway, bc of the ConvertToEntity script)
Does the entity prefab you convert has "CompanionLink" component on it ?
@eager jungle
Entity debugger
i mean, i checked in the entity debugger, and the prefab entity does not have that component
your entity has to have CompanionLink component on it, Unity should have put one
does your gameobject have any disabled scripts or components ?
no, its a simple cube, ConvertToEntity enabled, with conversion mode = ConvertAndInjectGameObject
- a simple component
Can you add a dummy script and see if your entity has a CompanionLink on it ?
i can't even compile with that. Is is possible that i have set UNITY_DISABLE_MANAGED_COMPONENTS without knowing it (or its by default)?
its definitely not added by default
but perhaps check your project settings if its set ?
pretty sure its not
it should be in Project Settings->Player
well, not being able to compile shows there is something else going on
ill double check with a sample code as well, give me a sec
there are not disabled, for sure
what does compile error show π
testing now
EntityManager.GetComponentData<CompanionLink>(prefab)
error CS0122: 'CompanionLink' is inaccessible due to its protection level
oh no no no, you dont want to add CompanionLink your own, Unity will add it automatically when you convert your gameobject
im not adding it myself
you asked me to check from code if it was added, that's what i was trying to do
and its not showing in entity debugger
also i believe that i understand the problem, one time i heard that convert and inject mode doesnt work if you are converting it at runtime(meaning thru a authoring component).
I actually encountered this problem when i was trying to do the same for my world UI, but couldnt make it work
what you can do is manually adding your gameobject to your entity thru systems.
For example, you could have "AddSomething" component in your entity, then you simply query(on main thread) for it, do your processing and add managed component through entitymanager.AddComponentObject(entity) and then remove "AddSomething" component
just want to add something: having an instance of the prefab directly in the scene, the converted entity does not have a CompanionLink either
well that does sound weird π¦ That happened to me once because some scripts in my gameobject were disabled, but once i enabled them, CompanionLink was added again
how what you're mentionning above would help spawning a gameobject with a entity prefab btw?
someone must know about this lol i can't believe no one had this problem before
i havent used HybridComponents, but apparently you can call AddHybridComponent in the conversion script to get it to generate an entity with the CompanionLink. According to this: https://forum.unity.com/threads/convert-and-inject-game-object-in-prefabs.806382/#post-5456226
I'd say very few people if any are using HybridComponents, i dont even know if they intend to support it going forward or if it was something they were just experimenting with. So if its hard to get info, that's probably why.
@mint iron nice you mentionned it, i just tried that a minute ago, and indeed the companion link is added, but that doesn't make the gameobject spawn along with the entity anyway ^^
I'd say very few people if any are using HybridComponents, i dont even know if they intend to support it going forward or if it was something they were just experimenting with. So if its hard to get info, that's probably why.
How are you guys dealing with animations and unsupported features? or physics if you want anything production ready???
my conversation with topher a while ago kinda gave me the impression that hybrid components were really meant for their own use with subscenes like lights and cameras(ie longterm outlook for them is unknown), of course things may change but the samples mentions it shouldnt really be used outside of experimenting. that said I could totally be misinterpreting things but id just caution against doing anything significant with them
i mean, my problem seems very simple.... im pretty sure anyone that wants to use some kind of hybrid will have to deal with this
for animation im just going with using monobehaviours via AddComponentObject and managing their lifetime my self. mostly not destroying or creating any unityengine thing outside of start/awake
but for that you need to Inject Gameobject right?
also some other things like particles. yeah need to use that with inject
how would you spawn such an object from a system ??? bc basically thats what im trying to do
I pool my gameobjects into a list that I need to "spawn" at the start of the game, and then just get them from the list as needed from a system
i mean, what if you want to spawn one at a random time?
i think you can technically instantiate a gameobject that has IConvertGameObjectToEntity(god I hate typing that out) and the conversion is called while playing but it might cause your game to hitch because conversion should technically take place at the start and conversion systems are not necessarily jobified or bursted in any way
that does work for sure, but in my case i need to retrieve the linked entity for later use in my system
that's my problem actually
conversion should just give you an entity along when you use it via the interface
I mean you could just make your gameobject via Instantiate and then use EntityManager.Create to make an entity and then manually link them from a system
unless you are talking specifically about LinkedEntityGroup ?
i don't think so, there no hierarchy
i just need the gameobject to be instantiated at the same time as the entity... and get the entity right away, not next frame => reason why GameObject.Instantiate is impractical
Even though Im very surprised there is no simple answer to that (like a utility function), I could do with any manual workaround if you have one.
I'm really really surprised no one needs that. It seems like any networked game for example , instantiating hybrid gameobjects at runtime would need that. Or i really missed something important.
there used to be a utility function but they changed how the conversion pipeline works
on the surface it does the same behaviour you'd see as prior - but iirc they removed a few static utility functions which converted gameObjects
ok so i see what you mean by a frame lag of regular instantiate
im having that in a system for a networked game, i want to spawn something and save the linked entity into a hashmap along with its networked id. But i can't find a way to find the Entity from the GameObject itself either (in case im using GameObject.Instantiate and let the gameobject self register later for example)
well a weird work around is to have a "free list" of entities and gameobjects and when you need one instantiated you simply link the two together - but if you a massive volume of objects - you'd be pushing the load up front and try to predict how much you would need later down the line
you mean like a pool
yea pretty much
that's a good idea, but still, super weird we can't do that... the basic way
which entity version is this?
I might have a workaround - i haven't checked my testing suite with the latest entity version tho
0.8.0
People keep asking how to reference an individual entity from systems, and the only answer ever provided is, "Don't." Even though numerous API calls require an individual entity reference from a system. So, I'll answer the question.
Create a progenitor entity from which others are cloned. When your system starts, it's the. only. one. That's important, because you can filter for it and know you only get one.
Cache that progenitor.
Then every time you clone it, rename the clone with its hash.
Can I hide some entities in the EntityDebugger? I spawn 900 nodes, I can't find other entities easily
Look for the script you want on the left pane, and then you'll find a list of component combinations using it on the far right pane. Find the combo that represents the chunk you want, and only it will show in the middle pane when you select it.
I could make a world where there are only the nodes, but yeah
there is a filter, press on it white ones will show the entities that has that component, red ones will show the entities without that component
Ok thanks
i do red "PreviousParent" component, that disables every child
Your nodes are all in the same chunk, right?
How can I check the chunks?
Is there a way to get a ref to the EntityManager singleton from some MonoBehaviour?
They have all the same components, but I don't know if they are too big
1 sec koward. It's DefaultWorldSomethingOrAnother. I'm spoiled by my IDE's autocomplete
there is no entity manager singleton, every world has an entity manager, you can do DefaultInitializitonWorld.EntityManager
Your nodes are all in the same chunk, right?
@gusty comet yes
You should be able to select that chunk to only see those entities
I am using filters, it works well (I want to hide only the nodes, I can't do that with chunks)
"EntityManager singleton" each world has only one EntityManager, so they're all by definition a singleton
Within their world anyway
EntityManager eMan = World.DefaultGameObjectInjectionWorld.EntityManager;
Alright, thanks. I might need to read about the concept of worlds to ensure I'm not doing something weird here.
Are systems registered somewhere, or placed in a scene perhaps? How does the engine know they exist? Reflection on subclasses of SystemBase?
I think it gathers all the systems that inherits from ComponentSystemBase, maybe through reflection, but not sure. They're then stored with the world, so all worlds doesn't automatically all systems
Yes reflection
You can disable auto creating by using DisableAutoCreation, you can also disable creation of defaul world as well
If I put the 'in' (read-only) modifier to some parameters in a function will I get a performance improvement? (Called from a job)
yes, Unity will know you are reading it so it will know your job will not create any race condition for that component
Not by itself, but will allow the job system to parallelize more stuff - so the more complex your project is, the more it will utilize multiple cores
Is SystemGroup (Update, Initialization) set by reflection on what methods you override in your system?
Ok thanks
Unity uses reflection to find your systems and generates code from your code in OnUpdate
Do I have to put base.OnCreate() in a SystemBase override OnCreate?
i didnt see any change, so i simply dont
Ok
yep the base is an empty method.
Do you have to start from a converted gameobject at the moment to create an entity for the player's components? If not when&where should that entity be created?
You don't have to, but it's probably the best solution right now, so you can edit variables directly in the editor
it's seems like when I instantiate entities one at a time from a prefab in a ComponentSystem using PostUpdateCommands, they're all put in their own chunks instead of being combined. But when I manually create the things and attach a ConvertToEntity script to them, they're properly put into the same chunks. Is there some gotcha I'm unaware of with chunks, or is that a bug?
looks like if I instantiate them in groups of 10 each frame instead of 1, each group of ten is in its own chunk...
if they have exactly the same components they should be being packed into the same archetypes' chunks. Except if the chunks are locked, or if you use a SharedComponentData, then chunks must share the same value of SCD components.
how can you tell if a chunk is locked or not?
i think right now only a user can lock them by calling EntityManager.LockChunk()
I'll try systembase, though I don't see how that would change how chunks are handled
yeah, it might just be the way it works right now....
i usually use the NativeArray overload which will make full chunks properly.
looks like PostUpdateCommands is not available in SystemBase, do I have to get a command buffer manually?
yea I've used nativearrays in the past and never had issues
i think so yeah
thanks, I'll give it a shot
for create at least, they have fancy new methods for Get/Set/Has Component.
is SystemBase supposed to replace ComponentSystem?
yes
it will replace ComponentSystem and JobComponentSystem
one system to rule them allπ
well interestingly switching from ComponentSystem to SystemBase and using the different command buffer made it go from one entity per chunk to two, in addition to making the chunk archetypes thing in the entity debugger go wild, will post if I make more progress on identifying the issue
it looks like instantiating them through the SystemBase somehow adds a LinkedEntityGroup component, could that be the cause?
I found the issue. I had a sytem that would go through and remove components after instantiation, and it looks like after the removal of the components it would not put the entity into a like-chunk
seems like a bug, but it's using old API stuff. I'll submit a report if after making it use the newer stuff it still happens
Huh
As many of you rightfully mentioned, you like to work with systems and queries, and we understand. ECS queries will be an essential part of the Unity Editor experience in the future. We've come to assess that they go far beyond the needs of Visual Scripting alone. Once we have finalized an approach that will enable both artists and developers to harness the power of queries throughout the editor at a Unity-wide level, they will be re-introduced to Visual Scripting. β
From the Visual Scripting thread. What could it mean
Not sure how the conversion system fits with that description
like this? π
The ECS workflow is more and more based on authoring gameobjects, not writing jobs by hand and relying on under the hood magic. We're going the same way..
Like serializable queries you could set from an inspector maybe
oh man that thread is a dumpster fire
i dont understand that at all?
happen to have a link to the revelant thread?
oh lawd
Ehh don't be too hard on them, based on that last post there's obviously some big changes to the editor itself going on behind the scenes that they can't talk about yet
from tens of thousands of objects to switch that is opening a door π
Say, is there an example somewhere of how to use EntityCommandBuffer to instantiate clones of an existing entity? Or must that always be done on the main thread?
when would be a good time to set the max # of threads for the job system? I imagine when the scene loads or at a world creation standpoint, anyone have any thoughts? π€
Frustration is mounting. A week and a half with DOTS in Unity, and so far exactly nothing has been intuitive.
All structural change have to happen on the main, thread, unless you use https://docs.unity3d.com/Packages/com.unity.entities@0.9/manual/exclusive_entity_transaction.html?q=ExclusiveEntityTran @gusty comet
Much appreciated, Sark
Say, is there an example somewhere of how to use EntityCommandBuffer to instantiate clones of an existing entity? Or must that always be done on the main thread?
@gusty comet
And just to be clear EntityCommandBuffers are played back on the main thread, but you can definitely queue CommandBuffer.Instantiate commands inside a job
when would be a good time to set the max # of threads for the job system? is this new? i thought it was hardcoded at 128?
There's a JobUility.JobWorkerCount property
if thats an entity should be tested against Entity.Null, and ECB entities returned from create/instantiate will be invalid until playback.
I just saw the mistake, so cleared my noise.
public const int MaxJobThreadCount = 128; π
ah - wondering what this does
huh...
well that property certainly works - you can limit it down to 1 worker thread π€
well you learn something every day don't you.
yeah, I've used that for a while for quick testing
the downside of that setter is that it doesn't actually remove extra workers from profiler
for that to happen you have to launch the editor with extra command line parameter that limits the worker amount
o - good to know
I also don't think you set the worker amount to bigger than your own computers hw threadcount -1
so with say 8 hw threads, you can get max 7 workers
I can test this quickly but I think it was mentioned somewhere that it's capped by your hw
so I can confirm, tried to set 30 workers from commandline and Worker 22 was last one listed on profiler (so 23 workers total since they start from 0) on 24 hw thread machine
@mint iron ^
128 is just the max capacity
basically the computer you run it on will determine the actual worker amount unless you force it to something lesser
doesn't work the other way around
also, apparently 64 hw threads is actual capacity today
at least I do remember someone reporting issues with this stuff with 64core threadripper
had to turn off SMT for things to work
in my case i needed the max when making a fixed threaded container so each thread possible could have a place to write data; but i only knew about the const not the other one.
if it's only for your own use, then sure
hello guy .. Iβ―have something that looks like a bug but β―Iβ―am not sure .. Iβ―found a workaround but it does not feels right
{
Dictionary<ResourceType, int> resourceCounts = new Dictionary<ResourceType, int>();
entities.WithNone<RecipeElementComponent>().ForEach((ref ResourceComponent resourceComponent, ref QuantityComponent quantityComponent) =>
{
if (!resourceCounts.ContainsKey(resourceComponent._resourceType))
{
resourceCounts.Add(resourceComponent._resourceType, 0);
}
resourceCounts[resourceComponent._resourceType] += quantityComponent._resourceCount;
});
entities.WithNone</*RecipeElementComponent, */QuantityComponent>().ForEach((ref ResourceComponent resourceComponent) =>
{
if (!resourceCounts.ContainsKey(resourceComponent._resourceType))
{
resourceCounts.Add(resourceComponent._resourceType, 0);
}
resourceCounts[resourceComponent._resourceType] += 1;
});
return resourceCounts;
}```
Why if Iβ―uncomment RecipeElementComponent it says Iβ―have a duplicate filter in my query ? any mean to reset the QueryBuilder? is it intended?
I donβt really like making a query taking what the previous did in account :/
Just wondering.. if ebcs are now fully bursted, is there a point at which they become faster to use than e.g. a bunch of SetComponent or AddComponent calls?
My understanding is that after every structural change there's work done re chunks & layout. Does it make better sense to do this work after you've finished modifying the structure of a bunch of entities? Wondering if ebc playback allows for/takes advantage of that?
How do I apply multiple adjustments in one iteration of EntityCommandBuffer? Told to use entityInQueryIndex as jobIndex, but if I want to do multiple changes in one iteration of Entities.ForEach (thus using the same entityInQueryIndex) it fails. Do I have to create multiple buffers?
why would it fail ?
what do you mean by 'fail' exactly ? does it give you any error @cosmic sentinel
I must be going insane. I got errors in the log (before I did a workaround). Tried to go back to my old code but now I can't make it fail again.
Code pretty much does:
if (health.Value <= 0.0f)
{
ecb.RemoveComponent<Target>(entityInQueryIndex, entity);
}
ecb.SetComponent<Health>(entityInQueryIndex, target.Entity, health);
obviously affecting two different entities. but the target.Entity's health wouldn't update
but for some reason it works now. very confusing
my workaround was just to use target.Entity.Index instead of entityInQueryIndex
Try posting full code, and errors : )
I'll try to reproduce the error
whole reason to use entityInQueryIndex is being able to use parallel command buffer commands playback in deterministic way, so what you are doing is correct π
the visual studio drop8 thread is pretty fun to watch. Very heated
I just cringe any time I get to another manifesto. There are good points being made poorly.
Anyone know of any decent UI solutions for DOTS being worked on? I saw one on the forum, but I'm not sure if it's maintained anymore.
Quick question... is there a way to call "GetComponent" within a Entities.Foreach() ?
with SystemBase you can just call GetComponent<T>(Entity), i believe if its bursted the codegen swaps it out with GetComponentDataFromEntity
@fallow mason go hybrid π
hah trying to avoid that
targetting webgl and eventually I plan on moving development to tiny, so keeping it pure will give me the best chance of porting without issue
eventually we'll probably see something with UIElements, that'll be nice. I've been meaning to look into if they've exposed any of the native goodies so we could control it from dots. But its on my neverending list of awesome things to do.
yeah, I was thinking of getting familiar with that workflow since I've heard that will be the DOTS UI system of choice
in a year or two π
in a year or two we might have a nice shiny new UI system to look forward to π
i really liked all the stuff they showed in Copenhagen last year for UIElements, the editor, the perf demos, i have high hopes.
UIElements my comfort zone as an (also) web dev. But honestly, I don't hate UGUI like some. I'm just glad I rarely have to write IMGUI anymore.
UI Toolkit's really good but it's the opposite of dod right now.. hard to see it morphing into something but I guess it will eventually
Ok, another question... Entities.ForEach(AnimationComponent ac => { ac.Animator = getAnimator(); }); AnimationComponent is shared... getAnimator delivers a Object which is not null... in a ForEach loop after this one here ac.Animator is still null... any idea why ?
I have a system that crashes editor(it gives invalid IL code a few times before crash) even when burst is disabled and yet it works on standalone build
now i have to spend days to figure this out π
PostUpdateCommands is still a thing ?
no
What to use instead ?
private BeginSimulationEntityCommandBufferSystem endSim;
protected override void OnCreate()
{
endSim = World.DefaultGameObjectInjectionWorld.GetExistingSystem<BeginSimulationEntityCommandBufferSystem>();
}
and in OnUpdate
var commandBuffer = endSim.CreateCommandBuffer().ToConcurrent();
then you can use that commandBuffer for your structral changes
if you only do Schedule only do endSim.CreateCommandBuffer(), if you do ScheduleParallel you do endSim.CreateCommandBuffer().ToConcurrent(); and in your ForEach you have to do "int entityInQueryIndex" for job index parameter of your command buffer
in OnUpdate after your ForEach, you have to do endSim.AddJobHandleForProducer(Dependency);
Sooo and how do i do structural changes on entities ? That new buffer looks complicated
@stone osprey ```cs
using Unity.Entities;
public class YourSystem : SystemBase
{
protected override void OnUpdate()
{
var PostUpdateCommands = new EntityCommandBuffer(Allocator.TempJob);
Entities.ForEach((Entity e, in YourComponent data) =>
{
//PostUpdateCommands.SetComponent();
}).Run();
PostUpdateCommands.Playback(EntityManager);
PostUpdateCommands.Dispose();
}
}```
but this will create sync pointπ
uuh please dont do that π
also fyi DOTS Editor update came out yesterday - nothing new but makes it compatible with entities 0.9
If I have a query and I execute it multiple times will I get always the components in the same order?
In the native array
I believe so - unless there are any structural changes between the two. Otherwise it wouldn't be derministic I think. That said, if you're multi-threaded I wouldn't expect it guarantees that the chunks operated on by each worker are the same. (Also happy to be corrected if I'm wrong about any of this)
Ok
Is .setSharedComponentData(entity, struct) valid for updating shared components ?
The first job is used to play a "run" animation... it simply sets that data set... the second job plays the animation... the problem here :
The first job does not update the struct correctly...
A new value is never getting set
How can I have a rotation speed? I want an object to rotate toward a point but not instantly
This is my code:
https://pastebin.com/PDMV4iXQ
Ok ty
In an Entities.Foreach() how can I put an "optional" component? If the entity has that component I want to read it, if not I want to do a thing
I could use inside the Foreach an entityManager.getComponentData but it won't allow me to use burst (IIRC)
You cant
Ok
Well i fixed this issue... looks like only one single "SetSharedComponentData" is allowed in each SystemBase... i splitted my AnimatorComponent into two... one for the data set ( i component ) one for the unity reference...
Oh... is there an inbuild support for component dependency ? What should we do if one component requires another ?
yes you can, use ComponentDataFromEntity @wide fiber
might even be able to use HasComponent, havent really experimented with that much and if its burst compatible
yup if using SystemBase just HasComponent<>, GetComponent<> & SetComponent<> automatically do CDFE behind the scenes
@safe lintel I don't think it's allowed by the burst compiler
it IS burst compatiable, you have to use SystemBase to be able to use it
What Timboc said basically
Ok
thought of the day: This SystemBase method should have been replaced by codegen
@opaque ledge Some days ago I tested GetBufferFromEntity and it wasn't burst compatible, the other functions are compatible? (Now I don't have a pc)
GetBufferFromEntity is burst compatible
you have to do GetBufferFromEntity and GetComponentDataFromEntity inside OnUpdate, and not inside of ForEach
@wide fiber
Ah ok, I need it in the Foreach (sorry for the "bad explanation")
you have to do that in for each, that will return an 'array', you can use that array to access any entity's components, simply access it by indexing, like bufferFromEntity[myEntity]
@wide fiber
@opaque ledge this is an example (it gives me an error that says I can't use burst and jobs), how should I get the layer component from the entity? Burst and jobs are crucial for performance here:
https://pastebin.com/yZJzJzUh
what does the error say
Entities.Foreach Lambda expression invokes 'GetComponentDataFromEntity' on a ComponentSystemBase which is a reference type. This is only allowed with .WithoutBurst() and .Run()
(I am inheriting SystemBase)
you have to do GetComponentDataFromEntity OUTSIDE of ForEach and inside of OnUpdate
var layerDatas = GetComponentDataFromEntity<LayerData>(true);
Entities.ForEach((ref PathNodeData pathNodeData) =>
{
var layer = layerDatas [entity];
})
.WithReadOnly(layerDatas)
.ScheduleParallel();
Ok thanks
Or since you are doing it inside SystemBase you can also do
Entities.ForEach((ref PathNodeData pathNodeData) =>
{
var layer = GetComponent<LayerData>(entity);
}).ScheduleParallel();
π π
Gl^^
ah nice one of the latest packages shows what monobehaviours are attached to your entity
@safe lintel which package? Entities?
i dont know, I just updated entities, and dots editor within the last day or two and one of those things has the slightly improved entity debugger, guessing entities
Ok
Is there an example anywhere of how to use EntityCommandBuffer.Concurrent to generate parallel processing, now that practically everything in the documentation is marked obsolete?
I can't find an example anywhere using just IJobChunk or Entities.ForEach
Thank you, and sorry. The official Github examples aren't clearly enough labelled. That's a LOT of code altogether to read and try to find what's actually needed. By the time I find it, I wouldn't remember what I was looking for.
What we really need is a community wiki, so we can maintain documentation together.
default documentation is pretty goodπ€·ββοΈ
there is View latest versionπ
I suck
I may be getting too old for this. Almost 40, and the people in my life wouldn't let me focus until now
Guess they got tired of borderline poverty after a decade and a half of telling them I could do better if they'd let me
Thank you, drUiD. Unity has the best developer community I've ever witnessed, and it's immensely appreciated.
Still going nuts though. 15FPS with enormous spikes in GPU wait with only 10k vertices (2501 quads) in the scene, 2500 of them with the same rendermesh data, instanced materials using the color property with no texture, and those same 2500 rotated out of view of the camera. Lower the resolution, and FPS picks up, but I don't see how this should even be happening in the first place. People render millions of entities with no problem!
I thought maybe it was the way I instantiated them, so that's why I went over that. But with that eliminated, I'm totally out of guesses.
if you're seeing this in the editor, it may not accurately reflect the real performance; check if it improves with burst on, safety off, job debugger off, leak detection off. Even then, there's a lot of debugging code that still runs in the editor, like live-link stuff for syncing sub-scenes that take a couple of ms even when doing nothing.
Also, not sure if you're aware but async compliation of burst means that it may take a while for it to hot-swap out the slow-ass c# functions to the burst ptrs. So you may think its in burst when its actually not. Only way around that is to enable syncronous compliation and then wait for ages when you hit play.
Player loop is reading 2.3 ms, so that's about 43fps, with Burst Compile on, all safety stuff turned off, and jobs turned on. Editor loop is shadowing the rendering spikes on the performance graph, so that may be it. Going to go read up to verify synchronous compilation. "Loading, please wait..." is always better than "Damn lag!"
That 43 is weird still though. With all but one quad behind the camera, they should be culled completely. And on a 1080ti, it should take way more than that.
im not versed on it but ive seen comments in this channel before about culling that would make me believe hybridrenderer v1 is not culling at all.
I'm using V2. But in HDRP, so that may be the issue.
Thing is, even without culling, this isn't right. It's like it isn't batching
I'm not sure how to confirm that it is, aside from going over all the instructions
Trying to get URP to render now (copied scripts to a new project), to test if it's HDRP
are you on the latest unity beta as well?
it only works on whatever that is
Editor loop is shadowing the rendering spikes on the performance graph,
ah you mean on those frame spikes the editor loop is the excessively large part?
Yeah, but 2.3ms on player loop still comes out to about 43fps on that loop alone
I'm using 2020.1.05b
On UDP, seeing the same performance loss, without it even rendering the quads visibly
Just found the culprit!
if
(
camRot != Camera.main.transform.rotation ||
camPos != Camera.main.transform.position
)
{
FaceCam();
camRot = Camera.main.transform.rotation;
camPos = Camera.main.transform.position;
}
Without the camera moving. So, it's calls to check camera position (to keep quads pointed at the camera)
Comment that out, and it's back to normal
oh very nice!
always make sure you scan over the entity debugger and profiler to check your job times
make sure you didn't spinwait the main for a long ass time and what not
I was comparing float3 to Vector3, so the test was always false. Turns out moving 2501 entities every frame isn't performant
Or I'm moving them wrong
just show the code π
I haven't looked over this since I learned a little more about parallel jobs earlier
[BurstCompile]
public struct FaceCamera : IJobChunk
{
[NativeDisableParallelForRestriction]
public ArchetypeChunkComponentType<Translation> translations;
[NativeDisableParallelForRestriction]
public ArchetypeChunkComponentType<Rotation> rotations;
public ArchetypeChunkComponentType<QuadSprite> qSprites;
public Vector3 camPos;
public Vector3 camFor;
public Vector3 camUp;
public Quaternion camRot;
public void Execute(ArchetypeChunk chunk, int chunkIndex, int entityIndex)
{
NativeArray<Translation> translation
= chunk.GetNativeArray<Translation>(translations);
NativeArray<Rotation> rotation
= chunk.GetNativeArray<Rotation>(rotations);
NativeArray<QuadSprite> flags
= chunk.GetNativeArray<QuadSprite>(qSprites);
for(int i = 0; i < translation.Length; i++)
{
rotation[i] = new Rotation()
{
Value = (flags[i].reversed)
? (camRot * Quaternion.AngleAxis(180.0f,camUp))
: (camRot)
};
translation[i] = new Translation()
{
Value = new Unity.Mathematics.float3
(
camPos.x + camFor.x,
camPos.y + camFor.y,
camPos.z + camFor.z
)
};
}
}
}
But that's where the transforms are changed.
you can use ForEach for thisπ
Yep. Setting that up now
and use mathematics instead of Vector and Quaternionπ€
Why are you calculating the same rotation and translation, every time, for every entity in the chunk?
Or am I missing something here?
Each entity has its own translation and rotation, and they're all being positioned relative to the camera.
These will be UI rectangles at some point in the future.
And they won't all be in the same chunk. Eventually, they'll have different textures and tags to match, for different UI elements.
@stiff skiff Saw what you meant right after I said that, but anyway
Just went ahead and fixed it
aye guys, how stable is the implementation of ECS atm?
I've had 1 crash when playing around with large numbers of entities but I'm just curious if I can depend on it when I actually bring it into my game
its still in preview not close to stable
@halcyon bay
I wouldnt touch it with a 10ft pole myself... the API changes as you're doing stuff does not help dev
your code today might not work in the next version
well obviously, but is it not worth using at all
:\
Well does anyone know how close they are to a stable build?
well obviously, but is it not worth using at all
@halcyon bay
core is pretty stable in terms of crashes/bugs, but wouldn't trust any of the side packages yet such as networking etc
so biggest downside is that you need to reinvent the wheel for a lot of things
ok fair enough
I'm trying to make a factory game similar to factorio so I figured I'd use it for the items that go on belts and what not
but I came up with a system that won't be too intensive for the belts themselves and machines
Is there a way to make a query that excludes components (similar to Entites.WithNone, but for queries)?
@cosmic sentinel You can make a new EntityQueryDesc which supports None
Even though it's old, it should still work
It's pretty much the same in the new version https://docs.unity3d.com/Packages/com.unity.entities@0.9/manual/manual_iteration.html
@bright sentinel thanks
the core ecs has been stable pretty much since it came out, its just the conversion and high level packages that have been in major flux. theres two networking packages, unity transport and unity networking. transport is just a simple udp library that works inside of jobs / ecs but layered on top of that is networking, which is the high level ghost / replication - fps world state type of server system
and that is in active development
I shipped my vr networked sandbox game on full ecs and unity transport a few months back and have no issues with the core stuff being stable. other than some lost performance and stuff from job scheduling bugs etc. but that stuff has been fixed over time. it never really was a problem for a real game anyways because of the sync points and mono land shit you have to deal with anyways
been working on something you guys might be interested in, but not quite ready to make it public.
@vagrant surge
been working on a ECS framework for a ultra constrained system, that has almost no ram at all. basically benchmarking the framework/pattern
did it mainly to write my own ecs framework, but then I had some interesting ideas to apply it to a memory and cpu constrained system to see how well it can speed up a single core machine where I have direct control over the cpu 'cache'
Is there a way to convert a query's component to a entity-component NativeHashMap?
Currently I got stuff like:
NativeArray<Translation> positions = query.ToComponentDataArray<Translation>(Allocator.Temp);
But then in the Entities.ForEach I have to do a linear search for every entity:
Entities.ForEach((Entity entity, int entityInQueryIndex, in Target target, in Translation translation) =>
{
for (int i = 0; i < entities.Length; ++i)
{
if (entities[i] == target.Entity)
{
// positions[i]...
Do I have to construct my own hash map?
theres NativeHashMap<V,K>
yeah, I know that. but can I get one pre-made or do I have to generate my own?
and you usually will avoid ToComponentDataArray
you have to generate your own, but thats like 3 lines of lambda
let me grab a example
Thanks
this is the older style ForEach syntax in a deprecated ComponentSystem
I'll see if I can find a systembase one
yeah, I use systembase, but I think it will be fairly close π
bit easier to write
constructed at the top, very bottom most line is being used
this is a single thread usage, but native hash maps contain a parallel writer
better one
NativeHashMap<int, Entity> PlayerLookup = new NativeHashMap<int, Entity>(playerQuery.CalculateEntityCount(), Allocator.TempJob);
var writer = PlayerLookup.AsParallelWriter();
Entities
.WithStoreEntityQueryInField(ref playerQuery)
.WithAll<PlayerEntity, ServerOnly>()
.ForEach((Entity ent, ref PlayerID id) =>
{
writer.TryAdd(id.Value, ent);
}).Schedule(inputDeps).Complete();
var allPlayers = PlayerLookup.GetValueArray(Allocator.TempJob);
I use this pattern a lot, and have been thinking about building a way of auto doing it using a bit of reflection to say which field I want to use as the key in the map, and what query
something like a filter method
CreateHashmapFromQuery(query, (e, id)->(return (id.Value, ent);));```
roughly
is there any point doing a parallel writer if you're not doing parallel scheduling?
seems like you'll just introduce locks
it does internally yeah
it did speed up one of my hashes on a system that was actually full jobs
I do it out of habit, so that if theres a chance it speeds it up, it will
if not its nbd
writing it single is the same thing, but you just dont create that writer inbetween
same syntax
.Run() instead of schedule
yeah that's what I mean. in your example you write in the main thread but use locks
its not main thread, its just waiting till complete
that system is being ported to a full job usage
still single threaded job
but the foreach that runs right after has to run on main thread at the moment
it isn't a single threaded job if the number of entities is high enough
Working on the next issue, I find something weird. With 2500 entities (quads), frame debugger shows two SRP batcher calls: one with 4 vertices and 6 indices (the first quad), and one with 8 vertices and 12 indices (after the first is instantiated 2500 times). That's expected. But then, if I increase the number of instances, around 5000 this shoots up to 20 vertices and 30 indices. At 7000 instances, the game (and editor) crash because Windows resets the GPU. At 6500 instances, it's 24 vertices and 36 indices. There doesn't seem to be an intuitive relationship between the number of instances and the growth of vertices, except that they grow.
I can't find where anyone else has seen this growing vertices issue.
Should I submit a bug report for this?
@low tangle neat
atm im continuing my experiments with that boids simulation i had
after moving the entire simulation to be a threaded taskgraph, im reaching 20 ms for 400.000 entities for sim+render
Posting screencaps to show what I mean.
https://gyazo.com/bd6b2ceb2e8682cf593da7193d673cb8
First 2500 instances cost 4 vertices and 6 indices (the others are the original quad, which is in a different chunk)
https://gyazo.com/cc1aa95b0c0ea079dfacca61c9944646
Second 2500 cost 16 vertices and 24 indices
https://gyazo.com/027f902770ce296fd6d71166c8a66f16
The next 1000 cost another 4 vertices and 6 indices.
That's nowhere near a constant cost per instance (consider the first 2500). And at 7000 instances, the GPU is killed.
@vagrant surge hell yeah, keep us updated on that stuff.
did you do any more unreal engine stuff?
not atm
but here you can run the latest vesion of my thingy
includes Tracy profiler to check how it runs
last thing i did is implement a culling system very similar to what mike acton explains in Megacity
where i cull per-chunk, and build a list of visible chunks + bitmasks
i understand now why mike acton built it like that. It definitely its a great way to do it, very strong
@gusty comet are you instantiating from a gameobject prefab ? or create your entities from code ? Also GPU instancing on your materials has to be enabled for RenderMesh/Hybrid Renderer v2 to work
GPU instancing is enabled (they're being SRP batched), and they're procedurally generated quads.
Problem isn't getting them to batch. It's that the batcher is instancing a non-constant number of them, and then crashing the GPU.
First 2500 cost one quad (so it's instanced). But then the number of quads goes up
Can you try to instantiate from prefab ? i remember an Unity staff said creating your entities from conversation is much better in DOTS envoirement than generation one on your own especailly when it comes to the entities that has render components
i think it was in Hybrid Renderer forum topic
I guess I could try in a roundabout way, maybe? I need procedurally generated geometry, so I'd have to generate the mesh, attach it to a gameobject, convert it, and then instantiate it.
Cool, he covers it there. Thank you. This must be related to something HDRP specific. That explains why I didn't see it on the built in renderer before migrating.
Can I already export to html5 with unity tiny?
When you do HasComponent in Entities.ForEach of SystemBase will it do a GetComponentFromEntity? Follow code it does EntityManager, but I guess there is some magic involved, so does it matter if I use Schedule() or Run()?
If you're doing structural changes, use WithoutBurst().Run(). Otherwise, you should be able to use Schedule().
When you query for components, it just traverses the archetype's component list.
Sorry, WithStructuralChanges().WithoutBurst().Run(). I think.
@mystic mountain yes, HasComponent/Get/Set essentially do GetComponentFromEntity, with less code
Run makes the job run on main thread, schedule makes the job run on worker thread
You want to do Schedule most of the time
Right so can I avoid needing to add WithReadOnly etc with this?
yep exactly
unless you are parallely writing tho
you cant do SetComponent with ScheduleParallel
Right, then I still would need to do the disableParalell thingy
you have to explicitly do GetComponentFromEntity and put WithDisableParallel
So is there any threshold on when you should do run vs schedule vs paralell, or is this just something you'll have to test?
yeah its something you should test
always test
only rule of thumb you can work with is entity count, and how packed you think the chunks are
if you think the jobs gonna be running over 2 chunks with 50 entities each then yeah, main thread run
if your systems gonna run over every single position+delta+dietimer and there might be who knows how many at any time
probably a good idea to write it full parallel
but always just setup a test case and profile
For all like 100s of systems? x)
I guess only optimize when you have to but ok yeah.
thats why they made lambdas the one way to rule them all
there much easier to switch between
I actually just posted on the forums related to this.. in my case, numbers of entities that systems run over can vary hugely. Run/Schedule massively better for low numbers, ScheduleParallel significantly better for large numbers (obviously). At the moment it's looking like I'm going to have to do this manually/dynamically but with the lambda syntax, this is a bunch of horrible copy/paste, even once I've extracted the bulk into a struct. Would really love some auto parallel -> run switch when below a certain number of chunks.
@amber flicker I remember Joachim post in the topic that was about IForEach being depraceted, i believe it was about creating a static method that you pass your query's component in it and that static method would do the process
Something like this i think
static void Execute(ref componentA, in componentB){
//Process
}
void OnUpdate(){
if(lotsOfEntities){
Entities.ForEach((ref componentA, in componentB)=> Execute(ref componentA, in componentB)).ScheduleParallel();
}
else{
Entities.ForEach((ref componentA, in componentB)=> Execute(ref componentA, in componentB)).Run();
}
}
but i think he did it thru a struct instead of static method, i dont remember
tho i guess this wont see captured variables π€
thanks @opaque ledge yea that's what I meant by extracting the bulk into a struct (you do basically that but new myStruct().Execute) similar to the old ijobforeach. The issue is, in my case I also have a bunch of chaining of jobhandles so even doing this creates a tonne of code. It's looking like the most viable option right now but this feels like it should be an api level feature tbh.
ah okay
i dont think there is a workaround for this that lets you not do copy/paste π¦
https://forum.unity.com/threads/job-overhead-auto-parallel.869386/#post-5722282 - in practice it's fairly significant too... just 5 systems chained and I go from 0.04ms to 0.25ms..
I don't think it's unreasonable that scheduling a parallel job on a cpu with many cores takes considerably longer.. I guess I gotta hope over time other people will start experiencing this pain too π
the main frustrating part of this is that I could store ForEachLambdaJobDescription that foreach returns then later call Schedule or ScheduleParallel.. but doing that throws an error that ForEach needs to end in either a Run, Schedule or ScheduleParallel invocation π¬
copy generated code and use it directly π
It's all code-gen anyway - just longer compile times and more to maintain (not to mention all the refactoring to structs)
Unity Phsysics new package π
I'm curious what Entities 1.0 will bring usπ€
Or entities 0.10?
π
π
It's going to be a long while for it to be anywhere production ready, I feel π
missed minor Entities update earlier:
## [Entities 0.9.1] - 2020-04-15
### Fixed
* Fixed NullReferenceException issue with Singleton access methods in SystemBase.
Hybrid Renderer got update but it's only for dependencies according to changelog
if we are getting new subscene functionality in next release , will we finally get some subscene documentation?π€
## [Unity Physics 0.3.2-preview] - 2020-04-16
### Upgrade guide
* All `PhysicsShapeAuthoring` components that were newly added after version 0.3.0 were incorrectly initialized to have a bevel radius of 0. It is recommended that you audit recently authored content to assign reasonable non-zero values.
### Changes
* Dependencies
* Updated Collections from `0.5.2-preview.8` to `0.7.1-preview.3`
* Updated Entities from `0.6.0-preview.24` to `0.9.0-preview.6`
* Updated Jobs from `0.2.5-preview.20` to `0.2.8-preview.3`
* Run-Time Behavior
* In order to test gameplay end to end determinism users should:
* Navigate to UnityPhysicsEndToEndDeterminismTest.cs (and HavokPhysicsEndToEndDeterminsmTest.cs if using HavokPhysics)
* Remove #if !UNITY_EDITOR guards around [TestFixture] and [UnityTest] attributes (alternatively, users can run the tests
in standalone mode without the need to remove #ifs)
* Add scene that needs to be tested (File -> Build Settings -> Add Open Scenes)
* Make sure that synchronous burst is enabled
* Run the test in Test Runner
* Authoring/Conversion Behavior
* Compound conversion system is now deterministic between runs.
### Fixes
* Volume of dynamic meshes is now being approximated with the volume of the mesh AABB, as opposed to previously being set to 0.
* Fixed regression causing newly added `PhysicsShapeAuthoring` components to initialize with a bevel radius of 0.```
## [Havok Physics 0.2.2-preview] - 2020-04-16
### Changed
- `HavokSimulation.StepImmediate()` is now provided and can be wrapped in a single Burst compiled job for lightweight stepping logic; however, it doesn't support callbacks; if callbacks are needed, one should implement the physics step using a set of function calls that represent different phases of the physics engine and add customization logic in between these calls; this should all be wrapped in a Burst compiled job; check `HavokSimulation.StepImmediate()` for the full list of functions that need to be called
### Fixed
- Fixed a crash that would occur when adding a static body, while the AABB of an existing dynamic body contains world origin (0, 0, 0).
or will it be like we added this, this and this, good luck figure out how to use it in changelog? π
wonder if they've finally documented StepImmediate now that it's on both physics pacakges :p
check `HavokSimulation.StepImmediate()` for the full list of functions that need to be called
does sound like that's a negative though π
there's also a minor bump to Platforms 0.2.2p10 but since it doesn't have changelog update, it must be some dependency update
They have added TriggerEvents and CollisionEvents in previous update, so you could do ForEach on them (i think) but i still couldnt figure out how to use it
from forum π
cs var events = ((HavokSimulation) stepPhysicsWorld.Simulation).TriggerEvents; foreach (var i in events) { }
Anyone have any advice on setting up global game databases for use with DOTs? I've never had to implement one but I'm looing at seeing a few different ways, scriptable objects, static classes, external xml files etc. But all the info I can find is old so if there were any issues with ECS they wouldn;t be covering it anyway.
how do you get the JobHandle for dependency management thats gets generated/used by ForEach?
nvm , Dependency property contains this.
@loud matrix ill throw in some thoughts;
the easiest option is basic data converted into Singletons, you could do that by having a prefab in a subscene with authoring components, input your data in the GO and it will show up in ECS world, as long as you only have one such object it can be accessed via the EntityManager Singleton methods.
One downside there is that since subscenes compile to a blob of data, it has to be defined at compile time and if its something you need to load dynamically like converted from a web request then its not going to work. Maybe you could get around that by streaming in a complete SubScene or BlobAsset remotely either manually or with addressables, but i haven't seen some good examples.
Sadly runtime conversion doesn't seem like its going to be supported which complicates things.
You might want to look at this repo by @untold night https://github.com/periodyctom/Hydrogen.Entities/tree/master/Samples~/SimpleDatabaseExample which has a sample for a database from ScriptableObjects
@mint iron Thanks for the reply. It's mostly just game data, items, weapons, ship types etc. The one thing that interested me with scriptable objects was being able to easily grab meshes for use in ECS rendering without having to reference file names or the like.
so I am going to push some updates to that repo sometime in the near(ish) future, but I'll let you know that you can now put regular object IComponentData if you just need to read pre-existing data on the main thread. Use blobs if you need to access everything on jobs.
so you could have a component that's just a wrapper for a reference to a scriptableObject or mesh asset as an intermediate solution
Hey anyone know if having your enums inherit from byte is worth doing for ICDs? I imagine it would allow more in cache, but might be slower processing because modern architecture is optimized for 32 bit word length, right?
Probably would be more beneficial for netcode.
better to have them smaller
modern architecture basically treats all ints as 64 bit
i think
Yeah I can see OOP it not being worth the tradeoff, but got to get that tight DOD packing.
did some quick tests a while ago with 1mil array of int2 vs 1mil array of byte2 and doing a simple a + b = sum
in regular C# the result was the same, C# always casts to int when doing math on bytes so i guess that makes sense but was surprised to not see a result from being packed tighter in memory
in burst however the byte2 version was 2x faster when sum is int
3x faster when casting result to byte and sum is int (so sum += (byte)(a + b))
5x faster when casting to byte and sum is byte
i'm guessing burst actually treats byte math as bytes instead of casting to ints
Oh nice! Guess it's confirmed.
so ya even at worst using bytes has no negative impact which was the main reason i did the test, kept reading stuff about "just use ints because cpus are more optimized for it" and the idea that casting is expensive
Right, that was what I was reading. Makes sense that there would be benefit to using smaller datatypes with ECS. Glad to see it's true.
ECS tends to be so stupid fast that is bottlenecked by raw memory bandwdith
Pleasantly surprised to hear processing benefit too.
as a general rule of thumb, smaller = faster
yea
and just for reference the actual results with editor attaching disabled and all using NativeArray:
1mil a + b = sum in regular C# = 1.60ms
burst int2 = 0.60ms
burst byte2 = 0.30ms
burst byte2 with casts = 0.20ms
burst byte2 with casts and sum is byte = 0.10ms
burst int2 and sum is byte = 0.50ms
so best case scenario iterating and summing 1mil byte2's is only 0.10ms on my machine which sounds bonkers to me
even overhead will prob be more than 0.10ms when using proper systems and whatnot
burst is crazy fast
Wow. Yeah. Thanks for running those tests. Very cool.
oh sorry regular C# version was using regular C# arrays cuz nativearray in regular C# was more costly
but yea still
https://hatebin.com/rgbsbusgcb if anyone wants to verify, didn't make seperate tests for the casting differences since was just changing as i went
ill give it a whirl
looks like i forgot to put a [BurstCompile] above the int2job when i uploaded but it is in my tests
so ya just add it manually
and looks like i didn't add the byte2 struct either which is just
public struct byte2
{
public byte x;
public byte y;
}
since unity.math doesn't have a byte2
and remove the using Phased.Tilemap3D oh man
basically i just use one class that i use as a notepad for benchmarking stuff when i need to that's why it's so sloppy when i wanted to copypaste only this part
@hollow sorrel I'm wondering, only the bottom one was burstcompiled, wouldn't that make a huge difference?
Oh duh
That's the job
π€¦ββοΈ
Oh wait no, the int2 job isn't bursted π€
yea i think i copypasted wrong but it should be there on the TestInt2Job as well
no, i just have a laptop from 2008
my notebook probably runs slower than a modern phone haha
makes for the perfect testing machine then
if it runs on there you know it'll run for most ppl
runs marginally faster in WithCode, could also be due to overheads in the performance testing package though.
strangely it looks like the int2 is not being vectorized and the byte definately is
here's the rig https://hatebin.com/cownizohwu
that's weird because int2 is a unity.math type and byte2 isn't so i was expecting the opposite
yeah, compare the two https://gist.github.com/jeffvella/26db28e5c0adf6e612e1a66d8c2bf806
byte has all the fancy things, xmmword the dead giveaway cause its 128 wide.
ahh
i've been meaning to post burst inspector results on forum because burst guy asked but i can't even tell what part is relevant and what isn't so i never did
what would cause the int2 to not be vectorized?
accessing individual values π€
i'm just learning it at the moment, becuse i've been trying to improve an octree for the last few days, and making an Aabb4x2 for 256 wide goodness π
what a speedy person
damn i didn't think faster was possible
my laptop from 2012 π
i thought the point of using int2 int4 etc was that it would automatically do these fancy things
what did you change to make it faster?
i guess these fancy things will be with float4+float4
not when you play with individual values
oh that was with what drUiD just posted?
yeah
you'd have to go back through the output array i guess and sum it to get the same result
thats weird, how is adding to a single result different than adding to an array with one item π
hah wth. Burst like vectorization that much?
brb converting all my scalar operations
mmm no doesnt seem to make a difference, these two both perform the same. https://hatebin.com/kshowarjkd
but do you get vectorization?π€
yep
i reduced the input to 250k becuse its doing 4 at a time.
wait maybe i messed that up.
yeah i only had the first and second indices adding
thats a bit faster:
1 simd operation is slower then 1 regular operation ? π€
the byte operation is simd also
i mean int+int is faster than int4+int4 ?
no the int + int is 4x slower
int+int = 1ms and int4+int4 = 1ms ?
Test3.TestInt is the int+int, the other two are both int4, just diff output method
int+int is 1.94ms and int4+int4 is .53-.54ms no?
i don't know how to explain properly my question π
int+int is one operation right?
int4+in4 is one operation too, but it is doing 4x work
ah I see what you're asking
1 scalar operation is slower then 1 simd operation?
simd quite a bit faster, right? doing 4x the work in 1/4 the time?
yeah, although there is some additional setup it seems there are many more instructions for the simd version but its faster.
but you are not doing 4x the work in 1/4 the timeπ
you are doing 4x work in 1x time
haha, true, true - or the same work in 1/4 the time
how so? isn't the int4 version adding 4 ints in same op, while int version does one? and int4 version does it in about 1/4 the time?
i dont think hes talking about my test results, just in general
you are doing more work in same amount of time
ah ok
but is it really same amount of timeπ
simd operation can't be faster then scalar operation
it has to be. I just spent the last half hour converting everything π
too bad my English is bad π
I think your English is great. I'm just kidding. I did no such conversion, because I don't believe simd faster than scalar either
i dunno, it could be faster, not all instructions are created equal.
but setup time as well, int4 and bool4 masks might be faster, but you have to be storing them in that state all the way through, otherwise you've got added construction time.
my question is related to this i reduced the input to 250k becuse its doing 4 at a time.
like 1 mill simd ADD should be executed in same amount of time as 1 mill scalar ADD ?
yes but then simd verison would be adding 4x as much stuff in the same time
but whole point of simd is 4x work for same amount of time, isn't it?
or same work in 1/4 the time?
lol
but you can't do operation for half HZ