Added a new `Ref<T>` struct for reference semantics. Added the `RenderGraph` system for managing rendering passes. Added the `RenderTexture` class for encapsulating GPU resources. Added `GraphicsBuffer` class for effective GPU resource management. Changed `CommandList` methods from public to internal for visibility control. Changed `IRenderPass` interface from internal to public for accessibility. Changed `GetData<T>()` in `ComponentObject.cs` to return `CompRef<T>`. Changed `GetComponent<T>()` in `EntityManager.cs` to return `CompRef<T>`. Changed `GetSingleton<T>()` in `World.cs` to use `CompRef<T>`. Changed `IQueryTypeParameter` to use `CompRef<T>` for consistency. Changed `QueryItem<T0>` and related structs to use `CompRef<T>`. Changed `Material` class to support bindless textures. Changed `Shader` class to support bindless rendering. Changed `Mesh` class to support bindless vertex and index buffer access. Updated documentation to reflect the new bindless rendering architecture.
62 lines
2.0 KiB
Plaintext
62 lines
2.0 KiB
Plaintext
<#@ template language="C#" debug="false" hostspecific="true" #>
|
|
<#@ assembly name="System.Core" #>
|
|
<#@ import namespace="System.Linq" #>
|
|
<#@ include file="Helpers.ttinclude" #>
|
|
<#@ output extension=".cs" #>
|
|
|
|
using Ghost.Entities.Components;
|
|
using Ghost.Entities.Query;
|
|
|
|
namespace Ghost.Entities;
|
|
|
|
<# for (int arity = 1; arity <= Amount; arity++)
|
|
{
|
|
var generics = AppendGenerics(arity);
|
|
var restrictions = AppendGenericRestrictions(arity, "unmanaged, IComponentData");
|
|
var constructorParams = Enumerable.Range(0, arity)
|
|
.Select(i => $"ComponentPool<T{i}> pool{i}")
|
|
.Aggregate((a, b) => a + ", " + b);
|
|
var deconstructParams = Enumerable.Range(0, arity)
|
|
.Select(i => {
|
|
var name = $"c{i}";
|
|
return arity == 1
|
|
? $"out CompRef<T0> {name}"
|
|
: $"out CompRef<T{i}> {name}";
|
|
})
|
|
.Aggregate((a, b) => a + ", " + b);
|
|
#>
|
|
public readonly struct QueryItem<<#= generics #>>
|
|
<#= restrictions #>
|
|
{
|
|
private readonly Entity _entity;
|
|
<# for (int i = 0; i < arity; i++){ #>
|
|
private readonly ComponentPool<T<#= i #>> _pool<#= i #>;
|
|
<# } #>
|
|
|
|
internal QueryItem(Entity entity, <#= constructorParams #>)
|
|
{
|
|
_entity = entity;
|
|
<# for (int i = 0; i < arity; i++){ #>
|
|
_pool<#= i #> = pool<#= i #>;
|
|
<# } #>
|
|
}
|
|
|
|
public Entity Entity => _entity;
|
|
|
|
<# for (int i = 0; i < arity; i++){ #>
|
|
public ref T<#= i #> Component<#= i #> => ref _pool<#= i #>.GetRef(_entity);
|
|
<# } #>
|
|
|
|
// Deconstruct into tuple-like values
|
|
public void Deconstruct(out Entity entity, <#= deconstructParams #>)
|
|
{
|
|
entity = _entity;
|
|
|
|
<# for (int i = 0; i < arity; i++){ #>
|
|
c<#= i #> = new (ref _pool<#= i #>.GetRef(_entity));
|
|
<# } #>
|
|
}
|
|
}
|
|
|
|
<# } #>
|