Giter VIP home page Giter VIP logo

Comments (3)

andreakarasho avatar andreakarasho commented on May 12, 2024 1

Just ported the Sample to FNA which is more NativeAOT friendly and it runs fine with some tweaks [removed the managed Texture2D field from the Sprite struct

from arch.

genaray avatar genaray commented on May 12, 2024
  • the compiler cannot predict the bytes size in memory, this is done during the runtime. So we could have a waste of resources here

Using the generic overloads actually registers components during "compile time" ( or atleast the first time they are being invoked ). Thats why i added API like: world.Create<Position, Velocity,...>(...);. This is already as efficient as it can get, since the compile time static Component<T> is being used :)

Using the type based approach however will determine during runtime, but theres no way around it... since types are used.

  • accessing to a component might be slower when using the Unsafe.As API for the reason above (things get done runtime side)

It depends, receiving an array from a Chunk is actually a O(1) operation. A internal lookup array is being used (chunk.ComponentIdToArrayIndex) to get the index of the component array which is the most efficient way... Only a direct field acess is faster.

  • the app cannot use the nativeaot optimizations (disable reflection) if the users wants (need to try out tbh)
    As far as i know, Array.CreateInstance is not being stripped out. So it should actually work, i think i also already ran it once in nativeaot. However we should probably retry this to see if it still works.

I was wondering if it's worth to replace the managed Array.CreateInstance with an opaque unmanaged pointers pool.

The problem with umanaged memory is that its way more restrictive. With unmanaged memory, we could not use managed structs as components anymore public struct Texture{ Texture2D... } and therefore its usage with monogame, godot or unity would be a very very bad experience. I actually had a branch where i used a combination of unmanaged memory and managed arrays to simulate this. However according to benchmarks it was not faster, it performed the same.

from arch.

genaray avatar genaray commented on May 12, 2024

Just ported the Sample to FNA which is more NativeAOT friendly and it runs fine with some tweaks [removed the managed Texture2D field from the Sprite struct

Thats great to hear :D

from arch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.