#archived-dots

1 messages · Page 251 of 1

gusty comet
#

its because tiny was more a proof of concept then intended for production. they actually communicated as much

rustic rain
#

but overall my own code is extremely lightweight and takes less than 0.3 ms total

#

thing is

#

I didn't use TIny

#

only physics from it

#

I talk about general dots packages

gusty comet
#

yeah which was written explicitly for it. Its not production ready at all.

rustic rain
#

yeah, I guess

#

I'll have to rewrite my game for monos now

#

xD

gusty comet
#

At least you can actually do something. My unity is literally effing bricked at the moment.

rustic rain
#

at least if I'll need actual compute power, I know how to implement it

hollow sorrel
#

might be faster to use dots 3d physics and just treat it as 2d

rustic rain
#

I'm not certain how tbh

#

I probably will need joints on axis

#

which is same useless overhead I don't really need

candid epoch
#

tbf every dots packages is peview so they basically tell you to not use in production.

deft stump
#

the new input system is okay wdym?

rustic rain
#

new input system is not compatible with Unity remote kek

gusty comet
#

Its half baked half finished and terribly documented.

rustic rain
#

terribly documented is true, hard to find good info.
But overall I think it's fine to use

candid epoch
rustic rain
#

but I don't have too much experience in development yet

gusty comet
#

So many features they tried to establish and they came out half baked, broken with poor if any documentation.

#

I made 9 albeit smaller games in the last 3 years, and each time when it comes to pick establish the technology pipeline I want to use unity but every time something is not panning out because of something being half baked.

#

Meanwhile I was able to without many hitches release 6 games with game maker studio 2 and 3 with godot without much of an issue.

#

And that is despite me hating godots pythonness.

deft stump
robust scaffold
#

What's half baked about UIE? The only thing left I think they haven't implemented is element specific materials / shaders. And trust me when I say UIB has come a long way.

worn valley
#

I think the new input system is aimed at non programmers. It is very complex but you don't have to use much code for it. I don't like it but I am very fluent in code.

#

@gusty comet i rewrote some stuff for a simulator I was making with ECS and it became literally 1000s of times faster. DOTS is like writing stuff in low level code. It's hard to do well but the performance is incredible.

rustic rain
#

yeah, it's good when you need perfomance

#

but when you need basic stuff

#

it might turn things other way around sadly

#

I really hope Tiny won't be the only solution for dots

#

with 2D

worn valley
#

Oh yeah it takes way longer to do simple stuff. It takes me way more time to actually set up what data I actually need than do do the code to do stuff

#

I just love knowing the stuff I write will get faster and faster as more cores become e standard on computers

rustic rain
#

no I mean, just the implementation of ecs takes away perfomance, since it brings overhead

#

I am literally rewriting my game in OOP rn because of it

#

I didn't expect it to be that bad

worn valley
#

What is the major overhead?

rustic rain
#

well, simply empty project already is about 3 times slower than no dots

#

like, simple game objects without game logic

#

I have no idea why, maybe 2D physics package is just broken atm

#

but it's eating 1ms on it's own

robust scaffold
#

Are you using hybrid renderer?

rustic rain
#

meanwhile all my own systems combined barely take 0.3ms

#

yeah

#

v2

robust scaffold
#

HR currently is god awful

rustic rain
#

I know

#

I always despised it

robust scaffold
#

Roll your own graphics pipeline

rustic rain
#

I tried to make my own renderer several times, but I failed

gusty comet
#

I have used ECS systems frequently in the past I am keenly aware of the performance gains.That does not change that dots is an a sorry state.

rustic rain
#

I did it okeshing I think with drawing my custom spritesheet

robust scaffold
#

DOTS is perfectly usable currently. Stick with Entities and Burst only. Roll your own graphics solution

rustic rain
#

but since no SRP batching, or GPU instancing came along with it

#

I thought I'd rather go with HR

gusty comet
rustic rain
#

yeah, it's kinda uuugh

gusty comet
#

Literally every time I tried to use unity for a project it came down to unity being basically just used for rendering.

robust scaffold
gusty comet
worn valley
#

simple stuff will always be worst with DOTS. It's focused on when you need to scale something to a crazy amount down the pipeline. And ECS makes everything more maintainable due to the modularity of it, but that does come at a cost

rustic rain
#

yyep

worn valley
#

I also had to turn off all the safer systems before I got crazy performance for my simulation stuff.

robust scaffold
gusty comet
#

The thing is ECS is not just for performance. Its also a completely different way of structuring your codebase.

rustic rain
worn valley
#

Like with the safety system on it was 2.2ms on the main thread and then safety off it was maybe .25ms

robust scaffold
robust scaffold
rustic rain
#

everything has safety checks

#

jobs, native containers, any query

robust scaffold
worn valley
rustic rain
#

I hope those editor only, cause I didn't do anything when building game kek

robust scaffold
worn valley
#

Yeah they may not be

rustic rain
#

kinda afraid I was looking at perfomance with safety checks

robust scaffold
rustic rain
#

like I said, my own code is 0.3ms total

#

all systems I had were part of my own system groups

robust scaffold
rustic rain
#

but sir, why my game was 50 fps max lol

#

2D fancy implementation of flappy bird lol

worn valley
#

Well where it there of the 19.3 ms going?

robust scaffold
#

I think there might be a different problem. Have you been using profilers tags and not the profiler itself?

rustic rain
#

I won't redo profiler again

robust scaffold
#

Or just screenshot the profiler on a typical frame. What's going on?

rustic rain
#

but I remember

#

6ms on reder

#

weird huge lines on main thread with smth really unknown

#

and that was on Build, not in editor

safe lintel
#

@robust scaffold "HR currently is god awful" I disagree, but why do you actually hate it? cant remember if Ive asked you before

robust scaffold
rustic rain
#

even rn, when I just installed fresh dots project, I already had about 200 fps on stage of simply moving entities

In fully classic Unity, I get 500 with same thing

#

so basically on little projects, there's seem to be little to no gain from dots

robust scaffold
#

Theres no use to Burst if you only have 5 elements in an array

rustic rain
#

yyyyep

safe lintel
#

but is that in a build? its not a 1:1 comparison with all the safety checks going on in editor

rustic rain
#

that is exactly my case lol

#

my build showed 50 fps

#

max

#

on mobile

#

I'll see how much I'll get with classic unity

safe lintel
#

@robust scaffold I only have 0.4-0.5 ms of overhead for HR, what do/did you get with it?

pliant pike
#

I think there was some bugs with certain versions of the HR where you get worse performance

robust scaffold
robust scaffold
safe lintel
#

what kind of cpu/gpu and is this on desktop or mobile? I have the same overhead for hdrp and urp, though somewhat older hardware(8700k and 1070)

worn valley
#

The overhead should always be higher at the start but then doesn't increase as much with more stuff. It's like writing stuff in C# and then saying that it has more overhead than writing it all in assembly. If we wrote everything in assembly it would all be insanely fast with no overhead but be impossible to maintain

pliant pike
#

is there some trick I'm missing to enable burst because it seems completely random as to whether it Unity uses it or not 😕 even when I'm putting explicitly to use burst

worn valley
#

in ECS or just jobs?

#

also Burst takes a while to compile after you run the new code, it does it at runtime so wait till it settles before testing

#

you can also turn on compile before play which freezes your editor while it compiles everything @pliant pike

rustic rain
pliant pike
#

Yeah thanks, I think it's just the first time I run after compiling, that must be the problem

pliant pike
worn valley
#

Yup it runs all the code once to see the result and then compiles as you go. Usually took me a few seconds to settle down

#

it'll compile code randomly so it isn't always the same compile order

pliant pike
#

It probably doesn't help when you have tons of errors as well

worn valley
#

no, that doesn't help

rustic rain
#

as far as I know you need to tell BurstCompile on struct and on Execute method

#

both attributes exist, right?

pliant pike
rustic rain
#

ah

#

in this case it's bursted 100%

#

all you need is this then

pliant pike
#

I know, that's what I did, thanks

pliant pike
#

How are people using methods inside jobs?

worn valley
#

I use methods inside of jobs all the time. I usually make them static methods so that I know what is going in or out

#

Or you can make them private methods inside of jobs that can access the input or output native arrays. Either or works.

#

I wouldn't expose any methods from the inside of jobs since jobs should be their own thing. All you do is put in the info into the job and then execute it.

#

and then grab the outputs

pliant pike
#

ok cool public static seems to work, thanks

lofty sequoia
#

I can't seem to get the DOTS physics package to work, I'm getting errors at Broadphase.cs:873, Is there a specific Unity version I should be using? I'm using the latest LTS

safe lintel
#

after f25 they broke the collection package

lofty sequoia
#

Awesome lol

#

Thanks, gonna install f25

safe lintel
#

@lofty sequoia wait sorry I think f25 its broken, im personally on f23

safe lintel
#

ah, must be another reason im avoiding f25 🥲

rustic rain
#

oh well

#

so I fully rewrote all my dots progress with OOP

#

and looks like end perfomance is not THAT different xD

#

allthough I need a bit more testing

#

so far profiling is about 3 times faster

#

10 fps vs 40

#

without profiler game caps at 57 on mobile, can't really check what is actual top fps

#

vs 50 fps with dots

#

welp
I guess mobile is not ready for dots at all

#

PC is barely ready

rotund token
#

kind of disagree

#

there are some AAA studios using DOTS on mobile

#

people just have to realize what DOTS provides

#

if you have a basic game, tiny simulation

#

and especially if you're using some hybrid workflow

#

then what benefit is it giving you?

#

like i'm not really sure what you're expecting 😅

#

it's also unfortunately really easy to write poor dots code, especially without a lot of experience

#

doesn't mean you can't do amazing things on it!

rustic rain
#

well yeah, by mobile I meant some casual non-sim games

#

obviously in some heavy projects profit will overcome overhead

#

but on low end devices it's just unviable

#

UNLESS threading profit overcomes all that overhead anyway

rotund token
#

if you're doing a low end mobile game

#

it's probably advisable to switch to simple scheduling mode

#

from what i've heard that is quite beneficial on mobile

rustic rain
#

wdym?

rotund token
#

ENABLE_SIMPLE_SYSTEM_DEPENDENCIES

#

i drew a graph of this ages ago

#

in simple dependency mode, it doesn't do a complex dependency check when you schedule jobs to determine what can run at what time

#

instead of just schedules them depending on the order you call them

rustic rain
#

huh

rotund token
#

System1 schedules Job1, System2 schedules job2

#

job2 will only depend on job1 in simple mode

rustic rain
#

I see

rotund token
#

regardless of what components etc are used

rustic rain
#

so that really simplifies setting up dependencies

rotund token
#

ENABLE_SIMPLE_SYSTEM_DEPENDENCIES define can now be used to replace the automatic dependency chaining with a much simplified strategy. With ENABLE_SIMPLE_SYSTEM_DEPENDENCIES it simply chains jobs in the order of the systems against previous jobs. Without ENABLE_SIMPLE_SYSTEM_DEPENDENCIES, dependencies are automatically chained based on read / write access of component data of each system. In cases when there game code is forced to very few cores or there are many systems, this can improve performance since it reduces overhead in calculating optimal dependencies.

#

from the patch notes [0.3.0] - 2019-12-03 way back when it was added

#

it's ideal for low end mobile devices

rustic rain
#

I'm guessing overhead is reduced from some to 0

#

gotta test that

#

kind of fun to test real application perfomance with this

rotund token
#

the big drawback is its bad to use systemgroups

#

because they are included in the chain

#

and basically cause sync points ^_^'

rustic rain
#

ugh

#

you mean every time system group ends it gets OnCOmplete?

rotund token
#

when it starts

rustic rain
#

I don't get it

#

when it starts it's not scheduled yet

rotund token
#

SystemGroup1 has SystemA,B,C in it
SystemGroup2 has SystemD,E,F in it

#

when systemgroup2 starts updating, it'll sync point SystemC

#

before SystemD runs

rustic rain
#

ah

#

that

#

Does it really matter tho?

#

whether you schedule everything in loop and then it gets oncomplete

rotund token
#

if systemC has a system that takes 5ms

rustic rain
#

or when it gets complete meanwhile scheduling

rotund token
#

then yes?

#

its waiting on main thread for 5ms

rustic rain
#

considering it's all linear with this define

#

oooh

#

it's running on main thread

rotund token
#

thats what a sync point is

#

it has to wait on main thread for job to finish

rustic rain
#

hold on, what causes jobs to run threaded properly then?

#

unity's sync points?

rotund token
#

what do you mean?

#

job are threaded when you call schedule[Parallel]

rustic rain
#

yeah, but what's the difference then

#

if SystemC Schedules job

#

and gets called by next system to finish?

rotund token
#

the next system doesn't finish it

#

EXCEPT in simple dependency mode by compnent system groups

#

because compnoentsystemgroups use the old componentsystem instead of systembae

#

which is basically a main thread only system

#

without simple dependency mode it checks what dependencies it needs to complete, which is none

#

but in simple dependency mode there is no check, as its a main thread system it just completes the handle pass to it i.e. systemC

rustic rain
#

Ok, so main thread will be the first to run job if it encounters sync point

#

meanwhile if sync point has a lot of jobs scheduled already

#

they all will spread

rotund token
#

a sync point just means the main thread has to wait for a worker thread to finish

#

the main thread will try to help by grabbing a job and completing it

#

but if it can't it literally just sleeping

rustic rain
#

yeah, it's a bit clear now

#

so basically no SystemGroups?

rotund token
#

yeah its just a annoyance in simple dependency mode

rustic rain
#

any alternative to make it clear at least during debugging tho?

rotund token
#

you can write your own system group that doesn't have this issue

rustic rain
#

so I make my own group

rotund token
#

you have to implement the whole systemgroup in a systembase

rustic rain
#

put it in front of simulation system

#

ah, that's how

rotund token
#

and just pass the dependency through

rustic rain
#

sad life

tepid gale
#

How does one deal with the immutability of structs within the scope of Dots? Ideally, I'd like the performance of Dots, but with being able to have constantly changing value of entity variables. Do I simply re-construct the struct containing the data? Is it best practice to keep the components separate and small, so that they don't cause overhead when re-constructing the components?

rustic rain
#

entity queries reference structs in component arrays

#

you basically write to referenced structs

#

that are passed with ref

#

same thing with in but it's restricting you from writing to it

#

yet still passed as reference

tepid gale
rustic rain
#

yeah

tepid gale
#

Is that good practice, or is there maybe another way of doing the same thing?

rustic rain
#

it's native c# practice

tepid gale
#

Thank you!

chilly crow
#

is it possible to get an enum name as a FixedString128 in a job?

#

eh I'll just chuck it into the component in the authoring step

worn valley
#

I think enums are just converted into an int at runtime.

#

What kind of game are you making @rustic rain?

rustic rain
#

kind of like flappy bird by gameplay nature

worn valley
#

Yeah not a huge gain to do it with DOTS. It really shines when you have to do a lot of parallel stuff and parallel physics is hard as heck.

rustic rain
#

I have a feeling I can still squiz enough perfomance to at least achieve capped 60 fps

#

since I didn't do simple scheduling

#

and I think I did a bit of fail with UI Toolkit event system kek

worn valley
#

I bet you are leaving performance on the table somewhere else. The UI system Unity ships with is very flexible but can be costly

devout prairie
rustic rain
#

everything

#

literally every single mechanic

#

full ECS

devout prairie
#

Is it mostly parallel jobs?

rustic rain
#

nah, I only used ForEach queries

#

my usual query is about 5 entities max

#

Parallel eats more than gives

devout prairie
#

Yeah i was wondering if that's where you were losing the benefit

rustic rain
#

My guess is that just running HR and all those Unity systems

devout prairie
#

Definitely interesting to find out if there's benefit it doing jobs stuff on small amounts of data, would love to know more on this myself

rustic rain
#

so far I added quite a lot to my OOP version and it's still about 2x more perfomant

#

on PC

#

in editor

devout prairie
# rustic rain My guess is that just running HR and all those Unity systems

Yeah i definitely felt that enabling Hybrid Renderer gave me an automatic fps penalty right off the bat but that was a year ago now so i can't remember if it was a clear comparison.. I kinda needed it though as i got the massive overall benefit of doing all this other stuff ( hundreds of skinned meshes and ragdolls etc )

devout prairie
#

I mean it may be that your data stuff is multiples faster, but Hybrid is eating up time - what does the profiler look like?

#

I do remember a couple of people saying for anything short of a few k gameobjects, they just render without HybridRenderer but i think that was more of an issue with HR v1

rustic rain
#

and like this on peaks

devout prairie
#

PhysicsWorldSystem / TransformSystemGroup / PresentationSystemGroup then roughly the culprits

#

in transform system is it the parenting system?

rustic rain
#

it's vanilla system

#

my is GameSystemGroup

#

and CollisionSystemGroup

#

everything else is built in

devout prairie
#

yeah i know those are vanilla, that's why i'm asking is it the parenting system inside TransformSystemGroup that's hogging cycles there

rustic rain
#

ah

devout prairie
#

i've had issues with that on and off

rustic rain
#

eh, I closed it already

devout prairie
# rustic rain my is GameSystemGroup

i noticed ur GameSystemGroup is like 0.23ms so your code specifically is obviously negligable, it's really the vanilla stuff that's holding it back right

rustic rain
#

it's 5.8% anyway

#

yyep

#

I spent month and a half learning dots

#

I wouldn't forgive myself doing unperfomant code kek

devout prairie
#

would be interested to see whats inside presentation system group causing that 3ms under the peak times

#

no hassle tho if it's closed etc

#

also on the mono version of your project, i wonder what the difference is between say, your game logic mono times vs for example that 0.23ms GameSystemGroup.. but i understand it's probs not comparing apples with apples as there's probably overlaps in your monos with collision code and ui stuff etc etc

rustic rain
#

well, even though my own code is 0.23

#

doesn't mean it doesn't rely on code that is 50

#

kek

#

here I uploaded profiler data

#

if you're interested

#

I assume you can see it on your own end

devout prairie
#

weird, download button doesn't work for me in chrome but does in edge

#

ah i can't open it rn, will check later

#

one thing that removed a ton of overhead for me was just setting FixedRateManager to null.. i did basically get shit for this as it 'breaks determinism' etc but it made things a lot quicker, previously i was getting multiple instances of the PhysicsWorld systems per frame, and setting this to null gave me just one.. everything still worked

#

it may be that there's some other settings to adjust for what was happening with FixedRateManager in my case but tbh whatever those might be is beyond me

#

another couple of things is disable shadows where not required and there's a transparency define which speeds up rendering if not using mats with transparency

#

relating to hybrid renderer

pliant pike
#

Stupid question but does this code not work to declare a variable passed into a job as read only AttackATKQuery = GetEntityQuery(ComponentType.ReadOnly<ATKdata>(), ComponentType.ReadOnly<UniqueGUIDat>());

#

because I keep getting these errors ReadWriteBuffers are restricted to only read & write the element at the job index. You can use double buffering strategies to avoid race conditions due to reading & writing in parallel to the same elements from a job.

rustic rain
#

show more code?

pliant pike
rustic rain
#

it's warning you

#

cause you get access to whole array

#

from different threads

worn valley
#

you are probably trying to write to that array too you just don't realize it

pliant pike
#

I know but I'm only reading from it

worn valley
#

Oh I know what you are doing

#

you can't pull the data in twice

#

you are pulling in in UniqueGUIDat dudesGUID which conflicts with the entity stuff you pulled

calm edge
#

Is there a way to get high-accuracy timing (like Stopwatch) in burst compiled code?

rustic rain
#

burst is for fastest computation

#

not for timed actions

calm edge
#

Stopwatch is for timing fast computations 😉

rustic rain
#

just wrap your job with stopwatch

#

but you'll need to .Run() it

pliant pike
worn valley
#

You can't pull in the same type of component in both a native array and in the foreach

pliant pike
#

Like the job archetype is the GUID with the listofattackers component and that is different to the other archetypes

worn valley
#

It just doesn't like that, I can't remember why

pliant pike
#

Also it works if I set them to with read-only() in the job

worn valley
#

oh maybe I am wrong then 🤷‍♂️

pliant pike
#

And it also works with schedule() fine

rotund token
#

if you don't use WithReadOnly(array) then it errors basically there's a missmatch between the job readable state and the query readable state

pliant pike
rustic rain
#

it's probably errors for thread safety

#

as far as I noticed, they want us to have write access only either in single thread job

#

or only if you are limited per array index

rotund token
#

the readonly on the query changes how dependencies are scheduled

#

readonly on a job ensures thread safety and burst optimizations

#

and they don't have to match

#

you have a write query with 2 jobs

#

the first job is marked readonly, the second job can write

sleek wind
#

Hello everyone! I'm learning DOTS making an Asteroids game, i need to spawn a lot of bullets from the player when it shoots. should I make an "entity pool" ? or simply instantiate them at the spawn point? maybe i could spawn entities at the point but also use a gameobject pool for moving the bullets. what do you think?

rustic rain
#

there's no need for pools in ecs

#

everything is preallocated

pliant pike
worn valley
worn valley
#

Yes I am pretty sure.

#

It was someone giving a talk at a local conference I am pretty sure. I am sorry I can't find the link right now.

karmic basin
#

Talking about this one i assume https://www.youtube.com/watch?v=BNMrevfB6Q0

In this video, learn about what's involved in migrating existing game code to the new Data-Oriented Technology Stack (DOTS), which comprises the C# Job System, the Entity Component System (ECS), and the Burst Compiler. You'll also gain an understanding of the performance benefits you can expect from these systems. Finally, you'll learn when it m...

▶ Play video
#

Also there's an asteroïd sample (IIRC in the multiplayer samples), in case you'd like to yoïnk some ideas

worn valley
#

Nailed it

sleek wind
#

Thanks a lot!!

robust scaffold
#

Another week is over and Unity is radio silent on DOTS 0.50 release... Then again, talking to the community about DOTS is just bad.

#

Then again, I'm looking at these completed 0.50 sample projects and nothing has changed on the lambda side. Sadly no examples of struct based jobs. 0.50 might just be completely indistinguishable from 0.17 at this rate. The core Entities package at least.

rotund token
#

what changes do you actually want with jobs?

robust scaffold
#

Due to the fairly opaque access of Dependency between systems (passes through magical box of JobDebugger), I have to instead manually JobHandle.CombineDependency(static singleton, Dependency) at the very end of every single system.

#

If there was a way to instead just grab hold of the final Dependency from a single loop of world SystemBase Update, that would make my life a hell of a lot easier.

rotund token
#

this is not something I see them supporting

robust scaffold
#

I know what I want exists, it's somewhere in JobDebugger, but I have no clue where exactly the dependency ultimately ends up in.

#

Additionally, I wish ExclusiveEntityTransaction was a little less clunky in usage.

#

Yea, I know it's "purely for world initialization" but it opens up amazing possibilities for pure job thread world update.

#

I've managed to get it working but it kinda breaks everything else.

#

Definitely very eager to see how the blittable shared component data will come out, crossing my fingers to see if it ships with 0.50. Basically the #1 thing I wish right now.

#

ISystemBase could be completely deprecated and I'll be decently okay if only Blittable SCD comes along as well.

#

Also, Burst 1.7.2 could not come fast enough. Constantly having to restart my editor to reliably view changes in inspector if I forget to close the inspector before changing code is so incredibly annoying.

devout prairie
rustic rain
#

aren't they already fast?

pliant pike
#

do you guys think its a bad idea to put roughly 10,000 entities into a buffer

pliant pike
#

ok maybe its not much of a problem I can add 10,000 entities to 10 buffers in under 7 milliseconds leahWTF

safe lintel
safe lintel
#

would also require a new material

worn valley
#

@pliant pike What do you need it for though? There may be a better way to do what you are trying to do

pliant pike
#

I'm trying to have 10 entity's each attack 10,000 entity's

worn valley
#

haha, well in that case go nuts

#

I do love stressing the system

pliant pike
#

like imagine they are giant mechs in a war

worn valley
#

I did some stress test where I searched through 50k objects to figure out if they were close and it took no time at all due to burst

#

and I was like

#

darnit, I was gonna post the whoa image from the Matrix

pliant pike
#

yeah I'm surprised it works so well with this basic naive approach, its probably way more than I need anyway

worn valley
#

the nice thing about burst is that you just do it the inefficient way which is way easier to program and it just works super fast without futzing around

#

like looping through a list instead of doing fancy look up

pliant pike
#

yeah its crazy

pliant pike
#

I think I'm reaching the limits though having a search through a 10,000 size array and multiple searches through 10,000 entities in a loop is taking a while(roughly 1000 milliseconds)

worn valley
#

yeah that is searching through 100 billion things I think

pliant pike
#

not quite a 100 billion leahS

#

100 million

robust scaffold
#

I believe the max number of entities possible in a single world is somewhere around 200M entities. It's some power of 2 around that number.

worn valley
#

I think the max entities are the limit of a 32 bit int. Cause all an entity is a 32 bit int and a 32bit in for a version

robust scaffold
#

My guess was the same order of magnitude at least.

hot basin
#

how to get entity prefab created by IDeclareReferencedPrefabs?

rotund token
#

I'll give you full code when I get out of bed and go to pc

hot basin
#

but for this I need conversionSystem, to be specific I need that prefab in MB

karmic basin
#

It's just a GameObject before conversion

hot basin
#

it is, and I need Entity of that prefab after conversion

karmic basin
#

Then yeah like tertle said, getPrimaryEntity

#

like you would for any other entity

#

it's just that you declared it through the declare interface to help the system discover it

hot basin
#

getPrimaryEntity is from GameObjectConversionSystem which I don't have

karmic basin
#

How do you convert ?

hot basin
#

I have a prefab with authoring MB with: IConvertGameObjectToEntity, IDeclareReferencedPrefabs somewhere on the scene

#

and I want another MB to have it's Entity prefab

hot basin
safe lintel
#

conversionSystem.GetPrimaryEntity(youGameObject)

#

its part of the interface

karmic basin
hot basin
#

how can I check if i'm after conversion process? Still from a MB

safe lintel
#

is it part of the same hierarchy?

#

wait a second, same gameobject/hierarchy just different monobehaviours?

hot basin
#

nope, it's two seperate gameobjects

#

ok there is no way, or at least the easy way

safe lintel
#

of the same hierarchy or different?

#

as if its different then afaik not really any easy way to get them to reference each other

hot basin
#

I'll make another script with conversionSystem

safe lintel
#

[unless its a prefab?]

karmic basin
#

I mean I'm not sure I understand why you want it in a MB, but you could still query back the entity from MB with an entityquery for example

rotund token
#

(ok out of bed)
are you trying to access outside of conversion?

#

just in runtime

hot basin
#

yeah, I could just assign reference from prefab but I have no reference for "main GO"

#

prefab is in the scene but I can spawn it after so prefab from project files is also acceptable

rotund token
#

hmm, not the answer you're looking for but my strong advice when working in a hybrid solution is to never access entity world from monobehaviours

#

this is talking from experience, you will just constantly burn yourself through your entire project from issue after issue

hot basin
#

I need it only for spawning

#

as I'm rewriting parts of existing MB based project and I don't want to touch too much of a project

#

just convert prefab to entity and rest will be cared by ECS systems

rotund token
#

cant you just store the entity on the MB when you convert?

hot basin
#

I could Find it I suppose

rotund token
#

why can't 1 MB just reference the other?

#

you said they're both in the same scene

hot basin
#

It can, but it's this specific case, I wanted to have more universal solution

#

ok so how tf convert any prefab from asset folder?

#

without any restrictions from above

#

just plain DOTS conversion workflow

rotund token
#

IDeclareReferencedPrefabs will allow you to add a prefab referenced for conversion

hot basin
#

and then I need additional System to convert it?

rotund token
#

no, it'll just be converted based off components it has

hot basin
#

so an authoring component with IConvertGameObjectToEntity will work yes?

rotund token
#

yep it just passes any dependencies through the conversion systems

#

so any conversion systems will run on it including the one that handles IConvertGameObjectToEntity

hot basin
#

but the problem is I don't see any prefab in entity window

rotund token
#

filter by Prefab component

hot basin
#

did it, even checked old entity debugger

#

do I need any defines?

#

nvm found it

rotund token
#

all good?

#

because i just tested and yeah worked fine

hot basin
#

yeah, declaration should be also be called from converted object to entity

#

and I just waited for prefab query to not be null

sleek wind
#

Random question: there is a DOTS-standard way of dealing with audio?

hot basin
#

it's best solution for now

hot basin
rustic rain
#

maybe you should implement quadrants or smth?

rustic rain
pliant pike
robust scaffold
#

I'm half asleep but I just thought of something wild. What if, I create my own Entities system? Instead of using the package, I just have one giant static class with static arrays of native array fields. With manual chunk fracturing and direct pointers to native array backing buffers? What could possibly go wrong?

#

With computer memory so large, who cares about a little leak here or there. Imagine the possibilities!

#

Meta 'entities'. Actual parallel scheduling (because ScheduleParallel crashes my entire computer). Structural changes on job thread without breaking everything else.

#

Static class based 'Entities' has all the benefits of Burst and none of the current requirement to stick with 2020.3.

#

I'm gonna see how this works. Pointers to buffers of pointers to buffers of pointers. What could possibly go wrong?

#

Roll my own ECS. None of the syntactic sugar nor support. All of the wild possibilities.

haughty rampart
#

sounds terrible

worn valley
rustic rain
#

2021.2.7f works

#

above requires collections fix

#

which still makes it work

#

and assuming no one tried

#

it might even work on 2022

haughty rampart
rustic rain
#

oh well

#

sad times

haughty rampart
#

2021.2 support will come later

rustic rain
#

life is pain I guess

#

even waiting for 0.50 is not justified

#

xD

#

gotta wait for 0.50 AND 21.2 support

gilded glacier
#

anyone having some experience with custom entity command buffers ?

rustic rain
#

well, most of the time all you want is just inherit from base ecb without any overrides or additions

#

if that counts as some experience kek

gilded glacier
#

I just thought it cannot be that simple, as there is recommendation to use the existing buffers instead in the docs

rustic rain
#

well yeah, why would you create another one

#

I remember double buffer was mentioned once as some sort of justification for it, but I can't really remember for what purpose

gilded glacier
#

want to process stuff within a single frame, but with chained structural changes

#

I know double buffer was some ancient thing for rendering in a window (probably not the same thing)

rustic rain
#

well anyway

#

if you want new buffer

#

just inherit from it

#

and add updateafter/before attributes to position it properly

gilded glacier
#

okay, thanks

fickle smelt
#

I'm trying to loop through a large NativeArray, but its get_length() & getter are both very slow, even with burst safety's off. I can get the performance back calling ToArray() on the NativeArray, however this method generates 7MB of garbage, excluding the additional heap allocations for the new managed array space. Is there any way around this I'm missing? Or another way to approach the problem? I'm looking to have neither the slowness of looping NativeArray nor the garbage generation of ToArray

rustic rain
#

how often do you have to call it?

fickle smelt
#

It's used in a terrain generator, so multiple times a frame for a limited duration and then never.

rustic rain
#

can't you cache it?

#

or predict it?

#

I'd treat it as Count in lists

#

which is kinda expensive as well

fickle smelt
#

I can both cache & predict it (and have tried doing just so), but it's the ToArray method itself that generates the garbage

rustic rain
#

why do you need to copy array if you solve the problem of getting leght?

#

ToArray() will quite literally copy whole array as far as I know

fickle smelt
#

Yes, but looping over the NativeArry is extrodinarily slow

rustic rain
#

looping through any native container is slow

fickle smelt
#

Both in getting its length every loop cycle (70ms profiled), and accessing the value inside the loop (350ms profiled)

rustic rain
#

they are made for thread safety

#

and for burst

fickle smelt
#

Sure, so that's my question. How do I do this without the slowness of NativeArray and without the garbage generation of ToArray (which removes the performance bottleneck in favour of garbage)

#

I'm not actually looping the array in a job, I'm looping it after it's been processed by a job

rustic rain
#

is it possible not to have NativeArray in the first place? just create data in normal array from the beginning?

fickle smelt
#

I'm calculating a 2d float array and it's values. I can't pass that through to the jobs system or burst directly. So I've put the values in a NativeArray<"struct">

#

As far as I understand it, I've no way to do that without using Native stuff

rustic rain
#

yeah, burst only works with native containers

main echo
#

Are there any guides on how to make your own deterministic physics?

fickle smelt
#

Hmm....the performance hit from the garbage is far less than the performance cost of not using Burst. So I think I might just have to suck this one up and hope Unity find a way to de-garbage that method!

rustic rain
#

that'd be great ngl

fickle smelt
#

Ha ha, indeed. Thanks for taking a look

vague yew
#

Hi i was wondering how stable dots is for creating a mmo-like android game?

rustic rain
#

pre alpha for anything

#

no matter what you are going to do - you're gonna have to implement your own stuff one way or another

vague yew
#

does it have any issues with building to android?

rustic rain
#

I didn't have any

vague yew
#

using 0.17?

rustic rain
#

yeah

#

but mind one thing - for my project dots was extremely slow solution
It takes some overhead price to implement threading and etc

#

which wasn't justified for my small project at all

vague yew
#

thanks for the info

worn valley
rustic rain
#

I'm fairly certain he is using jobs only

#

not ECS

pliant pike
#

yeah 70ms to get the length, something seems wrong there 😕

worn valley
#

I am not doing any ECS, just jobs and getting a length is trivial. The only time it takes forever is when you loop through an mesh array and get the length like this Mesh.vertices. It generates a new array every time you call it. So you need to assign it to an array first.

drowsy pagoda
#

If I nest UnsafeList inside NativeArray, will Disposeing the array implicitly Dispose the UnsafeLists? Or do I need to loop through array to explicitly dispose of the lists?

coarse turtle
drowsy pagoda
#

Also, am I understanding this correctly? If I add an entity with a dynamic buffer, changing the length should NOT move that entity to a different archetype right? Only the presence of the dynamic buffer determines this, not its length or contents. Am I correct to make this assumption?

tepid abyss
#

Hey, I am trying to create an a skill system where each skill can spawn different prefab/entity, and has their own "skill level" modification for each level (level 1: damage+5, level2: projectile+1, etc..).

The problem I am having is storing the prefab for each skill, I can't seem to use ScriptableObject to get Entity like in MonoBehaviour (in the inspector that is).
Is there a way to do it and be able to modify that value in the editor?

drowsy pagoda
#

Without using ForEach pattern, how can I efficiently access a DynamicBuffer via EntityQuery, much like components via query.ToComponentDataArrayAsync. Can someone post a quick example? I can’t find docs that show this.

#

Or am I looking at using type handles for this?

pliant pike
#

you can't do it with an entityquery have to use GetBuffer

#

I've asked that before and its annoying

drowsy pagoda
#

Doesn’t that create a sync point when GetBuffer is called? Or at least if you write to it.

pliant pike
#

not quite I think its just out of order memory access so its slower

#

the only way I figured to access lots of buffers efficiently was to get them in a job and then pack them into a nativearray

drowsy pagoda
pliant pike
#

no use something like Entities.foreach((Dynamicbuffer<buffertype> mebuffer )) = >{ nativearra.add(mebuffer[i]}

drowsy pagoda
pliant pike
#

yeah you can get them directly in the entities.foreach or in jobstructs

#

I think you just have to be careful to get the syntax and order correct

drowsy pagoda
#

I see. Cool, thanks for the tip, this helps a lot.

#

This is definitely something that absolutely needs to be mentioned in their docs.

pliant pike
#

yeah they aren't really up to date, but I think it should say in the changelog

drowsy pagoda
#

Indeed.

#

Ok, I figured out how to access it without ForEach (in case I need to do more fine-tuned systems). If I have access to ArchetypeChunk either inside IJobEntityBatch or myQuery.CreateArchetypeChunkArray(Allocator.TempJob) which will spit out NativeArray<ArchetypeChunk>.

hot basin
#
InvalidOperationException: The ComponentDataFromEntity<Health> ApplyAttacks.healths must be marked [ReadOnly] in the job AttackSystem:ApplyAttacks, because the container itself is marked read only.
var healths = GetComponentDataFromEntity<Health>(true);
        [BurstCompile]
        private struct ApplyAttacks : IJob
        {
            [ReadOnly] public NativeHashMap<Entity, int> map;
            [ReadOnly] public ComponentDataFromEntity<Health> healths;

Can someone explain to me what's going on?

robust scaffold
#

and where is that job scheduled?

#

Make sure that the right [ReadOnly] if you used autocomplete. There's another [ReadOnly] tag originating from C# System class.

hot basin
#
jobHandle = new ApplyAttacks
            {
                map = map,
                healths = healths,
                ecb = ecb,
            }.Schedule(jobHandle);
#

which [ReadOnly] is the good one?

#

ok that was it

#

strange that unity/rider doesn't show that there is conflict with attributes

#

Unity.Collections.ReadOnly is the right one

robust scaffold
robust scaffold
#

healths = GetComponentDataFromEntity<Health>(true), ... (rest of new ApplyAttacks code)

#

I dont have any examples since I just deleted all my entities code so... hrm.

hot basin
#

why? is there a difference?

#

AFAIK compiler should do it regardless

robust scaffold
rotund token
#

there's actually a pretty bad cost of doing GetComponentDataFromEntity

#

one of the optimizations we had to make was to burst compile all these calls in large systems

#

it halved our system main thread time

#

it's also a very dumb cost by unity

robust scaffold
pliant pike
#

GetComponent is basically out of order memory access I'm not sure there's much Unity can do about that

rotund token
#

bursting the GetComponentDataFromEntity

robust scaffold
#

I recall several hours of testing in this very discord that showed about 20% speedup when using the pointer using ComponentDataFromEntityExposed and skipping the memcopy that unity enforces to prevent RW on a RO GCDFE.

robust scaffold
rotund token
#
Dependency = job.ScheduleParallel(_query, 1, Dependency);```
#
original implementation, lots of little systems - 6ms
merging to single system, lots of little jobs - 2.5ms
1 single system, merging into 1 large job (reusing Gets) - 0.75ms
1 single system, 1 large job, burst compiling Gets - 0.35ms```
#

quoting myself from a discussion i had when helping another studio a few weeks ago

robust scaffold
#

huh, that's wild

rotund token
#

we previously had a optimization that the first call to GetComponentDataFromEntity did it on the system, but any subsequent directly called EntityManager instead

#

but yeah, just burst compiling it even better

robust scaffold
#

bursting the job population is not something I would've thought possible. Wow. I'll need to get back to you on how you manually populated that job.

rotund token
#

of course it is! this is basically what ISystemBase can do

robust scaffold
#

Right now I'm doing graphics touchups so my mind is completely off gear from DOTS. Still, 6ms? That is extremely long.

rotund token
#

but yeah the problem with these GetComponentDataFromEntity calls is if you step through it's the AddReaderWriter method leading to CalculateReaderWriterDependency.Add

#

which is done, every time. this becomes very costly in systems with a lot of dependencies.

robust scaffold
#

My job scheduling is practically non-existent compared to the size of jobs themselves.

#

In the order of 1ms to fractions of 1... Wait, is this one giant job?

rotund token
#

it is now

#

look at my bottom quote

robust scaffold
#

Like you merged all the systems into 1 job. Wow

rotund token
#

at the over time optimization

#

we dont only have 1 system

#

this was just 1 part of the AI

robust scaffold
#

I thought it would be better for cache if there's many systems with many small targeted jobs

rotund token
#

i think this benchmark was for the ActionExecution part

robust scaffold
#

So you're saying that if I cram everything into a single job, practically shove in the entire entity storage, it's better for performance?

rotund token
#

well it removes a lot of main thread overhead

robust scaffold
#

If my entire game logic was one job with only dropping out to update UI every frame, that's better?

rotund token
#

the main advantage of large jobs is it removes a lot of main thread overhead, but it also utilizes threads a lot better

#

if you ever profiled a lot of small jobs you'll see a lot of wasted time between these jobs

robust scaffold
#

Yea, but I've seen them to be minuscule. Orders of 0.1ms between jobs

rotund token
#

0.1ms 100 times

#

adds up

robust scaffold
#

true... hrm

rotund token
#

im not advocating single job for entire project, thats dumb

#

and a lot of the optimizations i've been doing i would only advocate on low end mobile or previous gen console

#

because code maintainability is important

#

but we have organized this in a way its pretty maintainable

robust scaffold
#

My jobs run on orders of magnitude of 10ms to 100ms. Currently with 5 jobs running one after another. I guess subtracting 0.1ms * 5 between all 5 jobs really isnt anything.

rotund token
#

yeah that's nothing

robust scaffold
#

and of course the mega-singlethread structural change job that runs on the order of magnitude of 5 to 8 seconds (really need to revisit it... or my entire entity structure)

rotund token
#

but if you build say a utility system that is scoring everything

#

and the job is simply

                    consideration.RawInput = setIsEntityDead.TrueValue;
                }
                else {
                    consideration.RawInput = setIsEntityDead.FalseValue;
                }```
#

and you have 200 of these tiny scorers

#

when they're split in 200 systems/jobs

robust scaffold
#

huh, yea. Definitely need to merge that

rotund token
#

well you get the above

#

(i didn't write our AI, just fixed the performance issues with it)

robust scaffold
#

very interesting. Bursting job creation is not a priority for me but seeing how it's done is very useful.

rotund token
#

my personal AI system is entirely 1 job but it's actually built using a graph

#

and can be edited at runtime which i think is sweet

robust scaffold
#

AI is in the very distant future for me. I'm trying to just settle on one conclusive entity structure.

drowsy pagoda
#

It seems I cannot find a way to perform physics casts on worker threads. Keeps throwing error that I am trying to read from CollisionWorld during physics build/step blah blah blah. Is this true then? Any physics related calls need to be handled on main thread? Or at least job.Complete before next fixed step iteration?

haughty rampart
drowsy pagoda
rotund token
#

you need to add dependency handles

#

imo its a horrible requirement (so i wrote my automatic dependency handle system for physics to not have to do it)

chilly crow
#

so I have this simple system here and I'm getting the error error DC0002: Entities.ForEach Lambda expression invokes 'Format' on a PerformActionsElementRequirementSystem which is a reference type. This is only allowed with .WithoutBurst() and .Run().

        Entities.ForEach((ref PerformActions performer, in DynamicBuffer<ElementRequirement> requirements) =>
        {
            var elementBuffer = GetBufferFromEntity<Element>(true)[performer.Dealer];
            foreach (var requirement in requirements)
            {
                var element = elementBuffer[(int)requirement.Type];
                if (element.Count < requirement.Amount)
                {
                    performer.Status = IPerformActions.StatusType.Failed;
                    performer.Message = $"Not Enough {element.Name}";
                    return;
                }
            }
        }).Schedule();

I can do this:

performer.Message = "Not Enough ";

and this:

performer.Message = element.Name;

but not this:

performer.Message = $"Not Enough {element.Name}";

Why is this?

rotund token
#

performer.Message = $"Not Enough {element.Name}";
this is allocating a new string (managed object)

#

which is not allowed

chilly crow
#

👀 why is it trying to create a managed string?

#

if I hover it it's a fixedstring

rotund token
#

it's creating the string

#

then converting it to a fixedstring

chilly crow
#

performer.Message = "Not Enough ";
wouldn't this have the same issue then?

rotund token
#

no because burst has added support for this

#

it can use static strings

#

by simply writing them as a resource in the burst file

#

if you ever inspect a dll it'll literally just have any static strings hardcoded in the header

#

it doesn't need to create them, it's smart enough to make sure they already exist

chilly crow
#

oh I see

#

why do the docs say this is allowed then?

rotund token
#

because it's allowed in debug.log

chilly crow
rotund token
#

i suspect your actual issue might be the conversion of fixedstring to string

#

though maybe not because of your error

#

yeah if you even look

#
        public override String ToString()
        {
            return this.ConvertToString();
        }```
#

FixedString128

#

even specifically states it's not compatible

chilly crow
#

yikes so I'm ool then

#

TY for explaning

rotund token
#

rule of thumb is don't make your model manipulate strings, leave that for your presentation layer

chilly crow
#

yeah makes sense, I guess I could just provide the requirement.Name and a separate index into an array of possible strings to prepend ("Not Enough", "Too Many", etc.)

#

then the presentation layer can join them

drowsy pagoda
robust scaffold
rotund token
#

we run a lot of our jobs simultaneously with the render pipeline

#

and nothing stops them continuing into next frame

#

a real world example of a job running well into the render pipeline without blocking it (super slow because of old consoles though I've also fixed this job since)

rustic rain
#

huh

#

it appears that Unity integrating Native collections support

#

into different parts

worn valley
#

I can imagine they want to do it everywhere. Being able to use native arrays with meshes has made so much simpler.

rustic rain
#

man, I like the future

worn valley
#

I love NativeArrays to replace regular arrays. Disposal is a little more annoying but its great being able to create and destroy an array super quickly

rustic rain
#

they are faster to allocate?

#

huh Didn't know that

worn valley
#

Oh I mean without having to worry about garbage generation

#

If I need to use an array[] I'll make it in the class instead of a local variable

rustic rain
#

what's the difference between your own disposal and GC disposal tho?

worn valley
#

You never ever want to generate garbage in a game.

#

Because at some point, the GC will run and dispose of all that memory which can cause frame drops

rustic rain
#

well yeah

#

and then you also dispose

#

which cause frame drops

worn valley
#

Disposing a native array doesn't cause a frame drop

#

NativeArrays are especially useful if you need a new variable sized array every frame. Instead of keeping a list in active memory and clearing it every frame with .Clear() you can just create and destroy a native array every frame.

#

May or may not be faster, but it solves GC problems

rustic rain
#

hm

#

but isn't iteration speed over it's elements defeating the purpose?

#

I heard it's like 10 times worse

#

than iterating over linq List

worn valley
#

I don't know what a linq list is

#

All a list is is a wrapper of an array

rustic rain
#

I mean normal List<T>

worn valley
#

Yeah, so all that does is wrap an array of []

#

And then hold a length

rustic rain
#

well, that doesn't affect what I mentioned

verbal pewter
#

I'm trying to create an entity and then add it as part of a DynamicBuffer IBufferElement, but when I do that I get the following error: All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -2). Can someone shed some light on what's going on?

worn valley
#

so you could have just 1 value, the count is 1 and then 7 other unitialized memory

rustic rain
#

I guess gotta test it through

worn valley
#

The entity command buffer needs to be executed before you can do stuff to the entities created @verbal pewter

worn valley
rustic rain
#

doing for loop over native arrays

#

was mentioned several times to be about 10 times slower

#

than over normal array

worn valley
#

oh I would love to see where that was mentioned

#

I haven't seen anything about that

rustic rain
#

last time about yesterday

worn valley
#

oh about that huge array

verbal pewter
#

@worn valley So after creating an entity with the EntityCommandBuffer we can't do anything with it and have to wait until the next frame?

worn valley
#

something funky is going on with that person's code. It shouldn't take 7ms to get a length.

#

@verbal pewter You can, you just need to figure out the sync point where the EntityCommandBuffer can be executed

#

I seem to recall (It's been a while) that you can assign components to newly created entities with the entity command buffer, but you just need to make sure it executes itself first

#

ECS is all about the sync points. In some code I wrote a year ago I had about 5 sync points throughout a frame to make sure everything was working well

#

You may have to create a custom execute group

rustic rain
#

that's not the only mentioned
eh
Let's just wait till some test results come up

#

so we can actually see if it's faster or not

worn valley
#

Someone mentioning problems on here with their code (That you can't see) is no way to determine if there is a difference between a native array and a regular array. We have no way to know either way.

verbal pewter
#

@worn valley I'm trying to create a flexible system for managing agent behaviors/actions. Each agent has a DynamicBuffer that holds "memories." One of the agent actions is creating a new memory, represented by an Entity. I would really need to be able to create it and immediately assign it to the agent's memory DynamicBuffer. It sounds like this isn't possible? Are there any common work arounds for doing something like this? It seems like pretty basic functionality.

#

Or can we force the ECB to execute?

worn valley
#

Unfortunately this is beyond my knowledge. Dynamic buffers are pretty complex since the memory size can fluctuate. So yeah I am not sure.

#

You could also use fixedarrays if you know the memories aren't going to be huge. I think those can be assigned like that.

#

But I do recall being able to add components at the same time as creating entities. BUT I could be remembering wrong. I used a much older ECS version than .17

verbal pewter
#

Yeah, I'm able to add a component to the newly created entity. There just seems to be an issue with adding a reference of that entity to a DynamicBuffer.

worn valley
#

Oh I see, the dynamic buffer holds an entity reference? Yeah until the ECB is run, the created entity doesn't have a proper ID for you to reference

#

I don't know how you'll do that. That is a pain in the butt. Sorry!

verbal pewter
#

I just came across EntityCommandBuffer.AppendToBuffer, which evidently can remap. Will give it a try.

#

This is just such a basic thing that I can't imagine Unity doesn't provide some kind of solution.

#

It works! Wohoo 🙂

worn valley
#

oh heck yeah

#

I haven't heard of appendtobuffer

#

ECS is super powerful but there is a ton of stuff that is WAY harder

robust scaffold
#

TIL, compute shaders RWTexture2D are clamped wrapped and there's no way to change that

#

I know this is dots but I hope y'all can learn from my 9 hours of debugging

steel steppe
#

has anyone ever tried ecs but for grass?

worn valley
#

I used ECS for a rope system and it was great. But if you just need grass that doesn't interact a GPU shader will work great

rustic rain
#

I assume GPU shader grass is only for non-interactive kind of thing?

hot basin
#

you can always send interaction data to GPU and calculate whatever

rustic rain
#

no I mean if you use geometery shader

#

that would mean your grass only exists on GPU

#

thus no cpu interaction

hot basin
#

but you can send data to the GPU by buffers

#

that means you can interact but yes not on the CPU 😄

rotund token
#

What type of interactions would you be wanting to do on the CPU

rustic rain
#

well, that is another question I don't have answer for

#

kek

hot basin
#

as for example, it would be fairly easy to send simple collider data to calculate bending of the grass

rustic rain
#

someone posted full tutorial how to do that

#

in geometery shader

#

recently

#

interesting stuff

hot basin
#

nice, have you link to this tutorial?

rustic rain
hot basin
#

yeah, exacly what I had in mind

#

some time ago I made animation instancing on the gpu

#

and lately I was wondering if I should add IK to it

rustic rain
#

do you happen to know

#

whether gpu instancing is possible with SRP?

hot basin
#

isn't that just a check in the material in SPR?

rustic rain
#

no I mean

#

through graphics API

#

pretty sure that check won't work either tho

hot basin
#

yeah, check ComputeBuffers

rustic rain
#

it only works in built in for me

#

I'v worked with indirect instancing before

#

but now that I'm actually working in unity with URP

#

it just won't work for some reason

rotund token
#

What does frame debugger say?

rustic rain
#

eh, it was some time ago I tried it

#

I didn't check

rotund token
#

It will tell you why a draw call couldn't be batched with the previous

rustic rain
#

no, it's not about batching

#

it's about drawing through graphics api

#

Graphics.DrawMeshInstanced

#

batching is supposed to be disabled completely here

#

but I swear, I couldn't find a single mention of people successfuly using gpu instancing and using SRP

#

depressing stuff

hot basin
#

im currently using URP with my GPU instanced animation renderer

#

using Graphics.DrawMeshInstancedProcedural

#

and I didn't had any issues

#

besides my own incompetence XD

#

the main problem I have with it is that I need at least 2021.1 and hybrid renderer don't work for me with this version

#

so I need to render everything manually

waxen quail
#

not sure if this related to DOT channel or more suited in #↕️┃editor-extensions channel but I got shader compiler and build errors please check out the thread if you have any idea

rustic rain
#

Of how you set up MPB and shader

rotund token
rustic rain
#

ah, well

#

in my case

#

it wasn't drawn at all

rotund token
#

what is your shader?

rustic rain
#

only individual Draw calls worked

rotund token
#

are you trying to write it yourself or was it through shader graph

rustic rain
#

I tried shader graph with custom function that grabs instanced data

#

and amplify

#

amplify shaders won't even compile if I add any instanced property

rotund token
#

are you using SRP batcher?

rustic rain
#

I disabled them before my attempts

rotund token
#

hmm not sure then

#

all i know is gpu instancing doesn't work with srp batcher

#

but yeah this is definitely not my area

rustic rain
#

I'll give it a try some time later, but I really could use help of someone who worked with it

#

area is so shady atm

#

makes me want to switch to built in

rotund token
#

shader-y

#

heh i'll see myself out

pliant pike
#

Its great when you optimise a job, managed to get one down from 6000ms down to 3ms

rotund token
#

that's a bit of an insane difference

pliant pike
#

I know the first approach was really naive and just using lots of getcomponents though

sleek wind
#

Someone knows some good way to deal with animations in DOTS? a good article or video will help! I need to control a simple ship in a Asteroids clone, and want to use some values in the components to modify the animations, or trigger another. i.e. when I pick up a shield, I add the Shield component to my player entity, and I want that to trigger the sprite of the shield on.

hot basin
#

how do you make a communikation between UI and ECS?

pliant pike
gusty comet
#

……

#

Dots

karmic basin
#

👏

hot basin
#

can I use jobs and threads in one project?

worn valley
#

I think so, except the jobs system expands to always use the number of virtual cores in your CPU. So it may cause issues if your threads are interrupting you jobs. Why do you want to use both?

robust scaffold
#

Unity doesnt instantly halt all other programs running on ya computer when you press play. Those external programs run on separate threads.

hot basin
#

so I don't know if I need to "all in" on this or it's safe to mix

worn valley
#

Oh yeah you'll be fine. And yes about the other threads @robust scaffold. I just saw somewhere that the jobs system will just use all your cores. You can also limit the number of cores you are using in ECS / Jobs too if you want to 100% sure ensure that other threaded programs are able to run

#

I doubt it'll make a big difference unless you have some crazy code going on

robust scaffold
hot basin
#

thanks

worn valley
#

@robust scaffold I am always terrified of touching something that seems to work but is pages of code that I understood once but no longer 😛

robust scaffold
#

If I were to go back and recode it from scratch, ignoring the dangers, i could make it run 20x faster. Guaranteed now that I know how to code. But why break what already works. i only run it maybe once a month if I change the base input files.

worn valley
#

😰

robust scaffold
#

Newest C# comes with default struct constructor override capacity. Every day structs become closer to classes...

rotund token
#

yeah i like it but i'm a bit concerned it's going to cause some errors

#

var struct1 = default(MyStruct);
var struct2 = new MyStruct();

#

will no longer be the same thing

#

be very risky to override default constructor in existing projects imo

#

but there are many cases this will be great in new projects

robust scaffold
half jay
#

Hello there, i have problem with this system

#

my profiler show me this

#

soo for me its very simple code and im not really sure what it can take so long? Any advice what can i additionally check?

haughty rampart
#

1 - remove WithBurst()

half jay
haughty rampart
#

2 - use the generic versions to add components

haughty rampart
half jay
#

how does it affect performance? And i will be glad to read about advanced parameters and WithBurst() more, any links or something?

haughty rampart
#

still bad practice to include redundant logic

half jay
#

thank you I will fix this

haughty rampart
# half jay thank you I will fix this

other than that, your semaphore.waitforsignal means that your job is waiting to receive the signal that your needed resources are not currently used by anything else

half jay
#

what does it exactly mean ? Another job executing and this RemoveObjectOutBoundBoxSystem waiting while execution of another job end?

haughty rampart
#

maybe. probably

winged bane
# half jay Hello there, i have problem with this system

You can try a couple things to figure out whats happening. Im not familiar with your ObjectStorage system. Is this something you created? It would be worth profiling. The other thing to try is to profile the system in more detail, like looking at the job timings in the profiler and how they are split amongst workers, or disabling burst for the ForEach so you can really drill down into the details.

#

Also hello DOTS channel.

half jay
winged bane
#

You'll know better what to do when you can see the timings for each line of your job

#

Im going to guess your trouble are related to the hash map

haughty rampart
robust scaffold
robust scaffold
#

On a side note, I will reiterate what I said following the first time unity posted that December 2021 update: Unity communicating with the forum public was a mistake.

haughty rampart
#

disagree

safe lintel
#

@half jay if you use the timeline view for the profiler you can find exactly what the job is waiting on

half jay
haughty rampart
#

parallel writes to the same output is always really slow in comparison. that's common knowledge

#

because it always has to make sure that only 1 writes at any given time and completes. otherwise you'll get back invalid data

pliant pike
rustic rain
#

yes

worn valley
half jay
#

I thought that using WithNativeDisableParallelForRestriction places the responsibility on the programmer that the data will not overlap and therefore there is no such restriction as you wrote above

haughty rampart
#

it does not. it just makes it possible to do these operations at all

#

it places the responsibility on the programmer to make sure that the in data does not alias

pliant pike
#

they must have changed it in an update because I know I've accidently changed a single variable in multithreaded job and came out with the expected wrong result

haughty rampart
worn valley
#

I like to play fast and loose with the RemoveNativeRestriction and boy do you get some crazy results sometimes

haughty rampart
#

i solved 95% of all my problems without removenativerestriction and the solutions i came up with are even more optimized than the dirty solutions with removenativerestriction would've been

pliant pike
#

well I mean the result was wrong because I had 12 threads all adding to a value and I expected it be 12 in my naivety but instead the result was 1 or 2 because each were getting the original value

#

but I did not understand that at the time

robust scaffold
#

I just use the raw pointers to do operations with and go wild with type conversions. Safety checks isnt a problem if the code never encounters them.

haughty rampart
robust scaffold
#

praise be the interlocked

haughty rampart
#

no

robust scaffold
#

yes

pliant pike
#

you can actually do that leahWTF

robust scaffold
#

interlocked solves all problems with threading. trust me

haughty rampart
#

nah.

#

dirty solution

pliant pike
#

got it 👍

robust scaffold
#

but you admit it is a solution

haughty rampart
#

not a good one

#

and interlocked is not even CLS-compliant

robust scaffold
haughty rampart
#

Well partial...

#

Anyway, who else would love for c# to add postfixes for all number formats?

robust scaffold
haughty rampart
#

I mean. 123456789L. Exists. I want 244b. As well for example

robust scaffold
#

Wait, for constant value declaration?

haughty rampart
#

Yes

robust scaffold
#

Oh yea, that would be nice. But b is already used for Binary.

#

0b111011 and so on

haughty rampart
#

Well, similar things at least.

#

People suggested s which would be fine

robust scaffold
#

s for short?

haughty rampart
#

s. Signed byte

#

I don't remember the other proposals right now unfortunately. Anyway my point is, I want postfixes asap. Why is it not in c# yet.

robust scaffold
#

Alright, i think it's time to take the plunge. Im gonna rewrite my file loading system to output blittable structs.

#

Now that I can do parallel "structural" changes

#

It's roughly 20 files with over 200 lines each, written 3 years ago. Pain.

tepid abyss
#

Hey, I have a GameObject with this script:

public struct EnemyPrefabArray
    {
        public BlobArray<Entity> prefabs;
    }

    public struct EnemeyPrefabsDatabase : IComponentData
    {
        public BlobAssetReference<EnemyPrefabArray> Value;
    }
    
    
    [UpdateInGroup(typeof(GameObjectDeclareReferencedObjectsGroup))]
    public class EnemyDataHolderBehaviour : MonoBehaviour, IDeclareReferencedPrefabs, IConvertGameObjectToEntity
    {
        [SerializeField] public GameObject[] enemies;
        public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
        {
            foreach(var go in enemies)
                referencedPrefabs.Add(go);
        }

        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            var prefabs = new NativeArray<Entity>(enemies.Length, Allocator.Temp);
            for (var i = 0; i < enemies.Length; i++)
            {
                prefabs[i] = conversionSystem.GetPrimaryEntity(enemies[i]);
            }

            using (BlobBuilder builder = new BlobBuilder(Allocator.Temp))
            {
                ref var enemyBlob = ref builder.ConstructRoot<EnemyPrefabArray>();
                var blobArray = builder.Allocate(ref enemyBlob.prefabs, enemies.Length);
                for(int i = 0; i < enemies.Length; i++)
                {
                    blobArray[i] = conversionSystem.GetPrimaryEntity(enemies[i]);
                }

                var blobAsset = builder.CreateBlobAssetReference<EnemyPrefabArray>(Allocator.Persistent);
                dstManager.AddComponentData(entity, new EnemeyPrefabsDatabase{Value = blobAsset});
            }
        }
    }```

And I have a really strange bug when accessing this data, when I try to instantiate from those referenced prefabs (using their stored PrimaryEntity), I get completely another entity that is not related.
#

Am I doing something wrong when using AssetBlobs?

#

It seems that if I change the assign GameObject in this script, the entity I get from Instantiate is different

#

So I assume somehow the system is reading the wrong data (or writing the wrong data?)

#
enemyDatabaseQuery = GetEntityQuery(ComponentType.ReadOnly<EnemeyPrefabsDatabase>());

// In OnUpdate
var enemyDatabaseEntity = enemyDatabaseQuery.GetSingletonEntity();
ref var prefabsDB = ref EntityManager.GetComponentData<EnemeyPrefabsDatabase>(enemyDatabaseEntity).Value.Value;

// Later in Entities.ForEach()
ecb.Instantiate(prefabsDB.prefabs[0]); // Spawn the wrong entity
safe lintel
#

shouldnt be using blobs to store entities

tepid abyss
#

So how can I store the prefabs entities?

safe lintel
#

dynamic buffer or just a field

tepid abyss
#

Okay thank you 🙂

safe lintel
#

could use fixedlists as well

#

just not blobs 🙂

robust scaffold
# safe lintel could use fixedlists as well

I actually prefer fixed fields:

public unsafe struct IntB16
{
    public const int Length = 16;
    
    private fixed int _elements[Length];
    public ref int this[int index] => ref _elements[index];
}```
#

the ushort used for length and count variable in fixed list fucks with vectorization

#

I could probably create a "count" of this buffer by -infinity terminating the list.

pliant pike
#

so are you saying fixedlists are slower in jobs?

robust scaffold
#
[NoAlias] public NativeArray<String32> Names, Capitals; // Equality vectorized.

[NoAlias] public NativeArray<int> Owners, Controllers;
[NoAlias] public NativeArray<IntB16> Cores; // Check for any equality vectorized.
[NoAlias] public NativeArray<Flags> Flags; // Check V, Enable V, Disabled V. Check is most expensive.

I'm primarily using these lists as giant flags. Check if element exists and enable and disable (add and remove) are vectorized using these fixed fields. Fixed list would not due to the ushort length and count variables at the start.

pliant pike
#

Ok cool, as long as they aren't that slow the above is a level of complexity that is beyond me 😕

robust scaffold
drowsy pagoda
#

I can’t get OnSceneGui to draw Handles.Label while DOTS live link is in Play State view instead of legacy mode. Is there a way to make this work, or is this a limitation of current 0.17 entities package?

hard wagon
#

Is this the place where I would ask about Unity's Job system? I have question about NativeContainer and how I can work this out. If not, can someone help point me to the right direction where I can ask question about this topic?

drowsy pagoda
#

Yes. This is the right channel.

#

A lot ask about Native Containers, I recommend you do a search on this channel for your keywords before you ask. Your question most likely was answered many times over in the past 😉

hard wagon
#

So I'm trying to create a nativeArray collection of bytes, receiving from Texture2D.GetRawTextureData(). However, I have an finite image I need to append to a job system. How would I go about creating an List of array of bytes?

drowsy pagoda
#

As you probably are aware you can't nest NativeArrays...

#

however, you may use something like NativeArray<UnsafeList<YourStructHere>> instead.

#

Are you familiar with Unity.Collections.LowLevel.Unsafe caveats?

hard wagon
#

Nope.

#

I'm still trying to grasp how powerful the job system, but still not familiar with IJobParallelFor yet.

#

I got a basic IJob system setup, and that works really well.

drowsy pagoda
#

There is NativeList and UnsafeList basically, the Native containers have error checking and leak checks and things of that nature, but Unsafe containers do NOT, you have to manually keep track of that and make sure allocate and deallocate them proper. Otherwise you can have leaks and not know about them, other than that they work pretty much like Native container.

#

NativeContainers are wrappers for UnsafeContainers.

hard wagon
#

The other thing is that I can't have reference to a game object, but could I create a pointer to an object I need access to? I'm trying to combine Textures together.

#

And I've noticed that the more images I need to combine, the more time it takes to call GetRawTextureData per each image I need to combine.

#

Thought I could get around by passing in a pointer to Texture2D object and then call GetRawTextureData within the job system.

drowsy pagoda
#

Have you considered using a compute shader for this? I image it would be much more up the alley of a GPU operation rather than CPU/Workers no?

#

At least have the compute shader process image data before trying to apply the mutated data back to managed member(s)

hard wagon
#

strictly speaking, the GPU is very limited on the hardware I'm working with.

drowsy pagoda
#

That would most likely squash your "the more images I need to combine" issue.

#

Ah I see.

#

Well I'm afraid I can't be much more help than this, wait for someone more qualified than I to answer your question

hard wagon
#

I'll take a look into UnsafeList! Thanks!

rustic rain
#

Does it have to be container in container specifically?
Isn't separating it into array of jobs possible?

rustic rain
hard wagon
#

No because I needed to combine a source image with multiple overlapping images in the same job. @rustic rain

#

Currently, I have a job that runs through two images to combine, but that means I have to keep re-running the same job for additional images I need to append.

#

Would like to try reading the texture raw data, combine textures, encode to png, and save it to disk all inside the job system if possible.

rustic rain
#

No managed types in job

hard wagon
#

Otherwise, I might just have to use the Threading task system to do this.

rustic rain
#

Jobs are for super quick math

#

Kinda like compute shader basically

#

Just in c#

hard wagon
#

guess the only use for the job is to combine texture.... other than that, I'll have to use the threading to do other operation async

rustic rain
#

About nesting containers btw

#

I still don't get the reason why it has to be in one job.

hard wagon
#

I'm calling multiple jobs per source images I need to combine, but they all need respective images to combine to the source.

rustic rain
#

If it's about just passing read only data

hard wagon
#

source isn't readonly, but the images I need to append is readonly.

rustic rain
#

I think you can use struct pointers for this

hard wagon
#

Can I get some examples for this?

rustic rain
#

So you can access same data from different jobs

#

Eeeeh. I'm really uncertain, but potentially ComponentTyprHandlr

#

In ecs

#

I never looked inside of it

#

But I think it's just struct that holds pointers to all component data

#

Kind of a wrapper for developers to avoid using 'unsafe' themselves

hard wagon
#

Still need to find a way to get a list of NativeArray<byte>...

#

otherwise, I'm just iterating inside a loop for each images I need to combine.