Browse Source

UPM package version 3.2.6

tags/3.2.6
GitHub 2 years ago
parent
commit
abe7d55edf
3 changed files with 27 additions and 74 deletions
  1. +8
    -69
      DataStructures/Unmanaged/UnsafeBlob.cs
  2. +6
    -2
      README.md
  3. +13
    -3
      package.json

+ 8
- 69
DataStructures/Unmanaged/UnsafeBlob.cs View File

@@ -12,10 +12,9 @@ namespace Svelto.ECS.DataStructures

/// <summary>
/// Note: this must work inside burst, so it must follow burst restrictions
/// Note: All the svelto native structures
/// It's a typeless native queue based on a ring-buffer model. This means that the writing head and the
/// reading head always advance independently. IF there is enough space left by dequeued elements,
/// the writing head will wrap around. The writing head cannot ever surpass the reading head.
/// reading head always advance independently. If there is enough space left by dequeued elements,
/// the writing head will wrap around if it reaches the end of the array. The writing head cannot ever surpass the reading head.
///
/// </summary>
struct UnsafeBlob : IDisposable
@@ -55,7 +54,6 @@ namespace Svelto.ECS.DataStructures
var structSize = (uint) MemoryUtilities.SizeOf<T>();
var writeHead = _writeIndex % capacity;

//the idea is, considering the wrap, a read pointer must always be behind a writer pointer
#if DEBUG && !PROFILE_SVELTO
var size = _writeIndex - _readIndex;
var spaceAvailable = capacity - size;
@@ -69,7 +67,7 @@ namespace Svelto.ECS.DataStructures
{
Unsafe.Write(ptr + writeHead, item);
}
else //copy with wrap, will start to copy and wrap for the reminder
else //copy with wrap, will start to copy and wrap for the remainder
{
var byteCountToEnd = capacity - writeHead;

@@ -179,75 +177,16 @@ namespace Svelto.ECS.DataStructures
}
}

// /// <summary>
// /// Note when a realloc happens it doesn't just unwrap the data, but also reset the readIndex to 0 so
// /// if readIndex is greater than 0 the index of elements of an unwrapped queue will be shifted back
// /// </summary>
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// internal void ReallocOld(uint newCapacity)
// {
// unsafe
// {
// //be sure it's multiple of 4. Assuming that what we write is aligned to 4, then we will always have aligned wrapped heads
// //the reading and writing head always increment in multiple of 4
// newCapacity += MemoryUtilities.Pad4(newCapacity);
//
// byte* newPointer = null;
// #if DEBUG && !PROFILE_SVELTO
// if (newCapacity <= capacity)
// throw new Exception("new capacity must be bigger than current");
// #endif
// newPointer = (byte*) MemoryUtilities.Alloc(newCapacity, allocator);
//
// //copy wrapped content if there is any
// var currentSize = _writeIndex - _readIndex;
// if (currentSize > 0)
// {
// var readerHead = _readIndex % capacity;
// var writerHead = _writeIndex % capacity;
//
// //there was no wrapping
// if (readerHead < writerHead)
// {
// //copy to the new pointer, starting from the first byte still to be read, so that readIndex
// //position can be reset
// Unsafe.CopyBlock(newPointer, ptr + readerHead, (uint) currentSize);
// }
// //the goal of the following code is to unwrap the queue into a linear array.
// //the assumption is that if the wrapped writeHead is smaller than the wrapped readHead
// //the writerHead wrapped and restart from the being of the array.
// //so I have to copy the data from readerHead to the end of the array and then
// //from the start of the array to writerHead (which is the same position of readerHead)
// else
// {
// var byteCountToEnd = capacity - readerHead;
//
// Unsafe.CopyBlock(newPointer, ptr + readerHead, byteCountToEnd);
// Unsafe.CopyBlock(newPointer + byteCountToEnd, ptr, (uint) writerHead);
// }
// }
//
// if (ptr != null)
// MemoryUtilities.Free((IntPtr) ptr, allocator);
//
// ptr = newPointer;
// capacity = newCapacity;
//
// _readIndex = 0;
// _writeIndex = currentSize;
// }
// }
/// <summary>
/// This version of Realloc unwrap a queue, but doesn't change the unwrapped index of existing elements.
/// In this way the previously index will remain valid
/// This version of Realloc unwraps a queue, but doesn't change the unwrapped index of existing elements.
/// In this way the previously indices will remain valid
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void Realloc(uint newCapacity)
{
unsafe
{
//be sure it's multiple of 4. Assuming that what we write is aligned to 4, then we will always have aligned wrapped heads
//be sure it's multiple of 4. Assuming that what we write is aligned to 4, then we will always have aligned wrapped heads.
//the reading and writing head always increment in multiple of 4
newCapacity += MemoryUtilities.Pad4(newCapacity);

@@ -292,7 +231,7 @@ namespace Svelto.ECS.DataStructures
ptr = newPointer;
capacity = newCapacity;

//_readIndex = 0;
//_readIndex = 0; readIndex won't change to keep the previous reserved indices valid
_writeIndex = _readIndex + currentSize;
}
}
@@ -321,4 +260,4 @@ namespace Svelto.ECS.DataStructures
uint _writeIndex;
uint _readIndex;
}
}
}

+ 6
- 2
README.md View File

@@ -4,15 +4,19 @@
Real ECS framework for c\#. Enables to write encapsulated, decoupled, maintainable, highly efficient, data oriented, cache friendly, code without pain. Although the framework is platform agnostic \(compatible with c\# 7 and .net standard 2.0\), it comes with several Unity extensions.

## Why using Svelto.ECS with Unity?
Svelto.ECS wasn't born just from the needs of a large team, but also as a result of years of reasoning behind software engineering applied to game development. Svelto.ECS hasn't been written just to develop faster code, it has been designed to help develop better code. Performance gains is just one of the benefits in using Svelto.ECS, as ECS is a great way to write cache-friendly code. Svelto.ECS has been developed with the idea of ECS being a paradigm and not just a pattern, letting the user shift completely away from Object Oriented Programming with consequent improvements of the code design and code maintainability. Svelto.ECS is the result of years of iteration of the ECS paradigm applied to real game development with the intent to be as foolproof as possible. Svelto.ECS has been designed to be used by a medium-size/large team working on long term projects where the cost of maintainability is relevant. Svelto.ECS can be educative for all kind of developers, but small teams must take in consideration the learning curve/cost of ECS in general and Svelto.ECS in particular.
Svelto.ECS wasn't born just from the needs of a large team, but also as a result of years of reasoning behind software engineering applied to game development. Svelto.ECS hasn't been written just to develop faster code, it has been designed to help develop better code. Performance gains is just one of the benefits in using Svelto.ECS, as ECS is a great way to write cache-friendly code. Svelto.ECS has been developed with the idea of ECS being a paradigm and not just a pattern, letting the user shift completely away from Object Oriented Programming with consequent improvements of the code design and code maintainability. Svelto.ECS is the result of years of iteration of the ECS paradigm applied to real game development with the intent to be as foolproof as possible. Svelto.ECS has been designed to be used by a medium-size/large team working on long term projects where the cost of maintainability is relevant.

**Svelto.ECS is also fully compatible with DOTS and Svelto.ECS code can be fully burstied and jobified.**
**Svelto.ECS is the only c# framework other than DOTS ECS to be fully compatible with Burst and Jobs.**

Svelto.ECS is compatible with Unity 2019.3.x cycle as long as it's not used with DOTS ECS. If DOTS ECS integration is necessary, Svelto.ECS will always target the last stable unity version using DOTS.

## Why using Svelto.ECS without Unity?
The question is just for fun! There are so many c# game engines out there (Stride, Monogame, FlatRedBall, WaveEngine, UnrealCLR, UniEngine just to mention some) and Svelto.ECS is compatible with all of them!

## If you decide to use Svelto.ECS

Svelto.ECS is an Open Source Project provided as it is, no support is guaranteed other than the help given on the Svelto Discord channel. Issues will be fixed when possible. If you decide to adopt Svelto.ECS, it's assumed you are willing to partecipate to the development of the product if necessary.

## How to clone the repository:
The folders Svelto.ECS and Svelto.Common, where present, are submodules pointing to the relative repositories. If you find them empty, you need to update them through the submodule command. Check some instructions here: https://github.com/sebas77/Svelto.ECS.Vanilla.Example/wiki



+ 13
- 3
package.json View File

@@ -2,14 +2,24 @@
"displayName": "Svelto ECS",
"category": "Svelto",
"description": "Svelto ECS C# Lightweight Data Oriented Entity Component System Framework",
"author": {
"name": "Sebastiano Mandala",
"url": "https://www.sebaslab.com/"
},
"repository": {
"type": "git",
"url": "https://github.com/sebas77/Svelto.ECS.git"
},
"dependencies": {
"com.sebaslab.svelto.common": "3.2.3"
"com.sebaslab.svelto.common": "3.2.4"
},
"keywords": [
"svelto"
"svelto",
"ecs",
"svelto.ecs"
],
"name": "com.sebaslab.svelto.ecs",
"version": "3.2.5",
"version": "3.2.6",
"type": "library",
"unity": "2019.3"
}

Loading…
Cancel
Save