Refactor: variant-aware shader/material pipeline overhaul
Major architectural update to graphics/material/shader system: - Introduced strongly-typed key structs (Key64/Key128) for passes, variants, and pipelines; removed legacy key types. - Implemented robust hashing and key generation utilities for efficient variant and pipeline lookup/caching. - Shader compiler now compiles/caches all keyword variants using new key system; includes handled as lists. - Switched to push constant root signature for per-draw data; updated HLSL and C# codegen accordingly. - Refactored Material, Shader, and Pass data structures for cache efficiency and variant support. - Pipeline library and PSO management now use 128-bit keys and variant-specific caching. - Replaced WorldNode with SceneNode in editor/scene graph; introduced ComponentManager for archetype/query management. - Migrated math utilities to Misaki.HighPerformance.Mathematics; updated editor controls. - Updated all HLSL and codegen for new buffer/push constant layouts and macros. - Misc: project reference cleanup, D3D12 Work Graph support, doc updates, and code modernization.
This commit is contained in:
44
Ghost.Core/Utilities/Hash.cs
Normal file
44
Ghost.Core/Utilities/Hash.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ghost.Core.Utilities;
|
||||
|
||||
public static class Hash
|
||||
{
|
||||
private const ulong _PRIME1 = 0xfa517d6985796b7bul;
|
||||
private const ulong _PRIME2 = 0x589578278297b985ul;
|
||||
private const ulong _PRIME3 = 0x221147a447814b73ul;
|
||||
private const ulong _PRIME4 = 0x9e3779b97f4a7c15ul; // Golden Ratio
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong Hash64(ulong a, ulong b)
|
||||
{
|
||||
return a ^ (b * _PRIME4 + (a << 6) + (a >> 2));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong Hash64(ulong a, ulong b, ulong c)
|
||||
{
|
||||
ulong h1 = a * _PRIME1;
|
||||
ulong h2 = b * _PRIME2;
|
||||
ulong h3 = c * _PRIME3;
|
||||
|
||||
ulong h = h1 ^ h2 ^ h3;
|
||||
|
||||
h = (h ^ (h >> 33)) * _PRIME4;
|
||||
return h ^ (h >> 29);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong Hash64(ulong a, ulong b, ulong c, ulong d)
|
||||
{
|
||||
ulong h1 = a * _PRIME1;
|
||||
ulong h2 = b * _PRIME2;
|
||||
ulong h3 = c * _PRIME3;
|
||||
ulong h4 = d * _PRIME4;
|
||||
|
||||
ulong h = h1 ^ h2 ^ h3 ^ h4;
|
||||
|
||||
h = (h ^ (h >> 33)) * _PRIME1;
|
||||
return h ^ (h >> 29);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user