Update namespace

This commit is contained in:
2025-10-23 15:13:10 +09:00
parent 28c386b0bb
commit 9dc4f63e40
27 changed files with 48 additions and 43 deletions

View File

@@ -40,6 +40,11 @@ public readonly struct TypeHandle
return Type.GetTypeFromHandle(RuntimeTypeHandle.FromIntPtr(Value)); return Type.GetTypeFromHandle(RuntimeTypeHandle.FromIntPtr(Value));
} }
public override int GetHashCode()
{
return Value.GetHashCode();
}
public static implicit operator TypeHandle(IntPtr value) public static implicit operator TypeHandle(IntPtr value)
{ {
return new TypeHandle(value); return new TypeHandle(value);

View File

@@ -48,7 +48,7 @@ internal static class PlayerLoopService
var world = World.GetWorld(i); var world = World.GetWorld(i);
foreach (var script in world.QueryScript()) foreach (var script in world.QueryScript())
{ {
script.Update(); script.OnDestroy();
} }
} }

View File

@@ -369,7 +369,7 @@ internal class D3D12ResourceDatabase : IResourceDatabase, IDisposable
var id = _shaders.Count; var id = _shaders.Count;
_shaders.Add(shader); _shaders.Add(shader);
return new Identifier<Shader>(id); return new Identifier<SDL>(id);
} }
public bool HasShader(Identifier<Shader> id) public bool HasShader(Identifier<Shader> id)
@@ -460,7 +460,7 @@ internal class D3D12ResourceDatabase : IResourceDatabase, IDisposable
ThrowMemoryLeakException("materials", _materials.Count); ThrowMemoryLeakException("materials", _materials.Count);
} }
// Shader are reference type, it will be managed by GC, so we don't throw exception here. // SDL are reference type, it will be managed by GC, so we don't throw exception here.
for (var i = 0; i < _shaders.Count; i++) for (var i = 0; i < _shaders.Count; i++)
{ {
ref var shader = ref _shaders[i]; ref var shader = ref _shaders[i];

View File

@@ -23,7 +23,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ghost.Core\Ghost.Core.csproj" /> <ProjectReference Include="..\Ghost.Core\Ghost.Core.csproj" />
<ProjectReference Include="..\Ghost.Shader\Ghost.Shader.csproj" /> <ProjectReference Include="..\Ghost.Shader\Ghost.SDL.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -627,7 +627,7 @@ public enum IndexType
UInt32 UInt32
} }
// Shader compiler // SDL compiler
internal ref struct CompilerConfig internal ref struct CompilerConfig
{ {

View File

@@ -3,7 +3,7 @@ using Ghost.Graphics.Contracts;
using Ghost.Graphics.Data; using Ghost.Graphics.Data;
using Ghost.Graphics.RHI; using Ghost.Graphics.RHI;
using Ghost.Graphics.Utilities; using Ghost.Graphics.Utilities;
using Ghost.Shader.Compiler; using Ghost.SDL.Compiler;
using Misaki.HighPerformance.Image; using Misaki.HighPerformance.Image;
namespace Ghost.Graphics.RenderPasses; namespace Ghost.Graphics.RenderPasses;

View File

@@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ghost.Shader\Ghost.Shader.csproj" /> <ProjectReference Include="..\Ghost.Shader\Ghost.SDL.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,4 +1,4 @@
using Ghost.Shader.Compiler; using Ghost.SDL.Compiler;
using Misaki.HighPerformance.Mathematics; using Misaki.HighPerformance.Mathematics;
using System.Numerics; using System.Numerics;

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler; namespace Ghost.SDL.Compiler;
public class Lexer public class Lexer
{ {

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal class DefinesBlock : IBlockParser<List<Token>, List<string>> internal class DefinesBlock : IBlockParser<List<Token>, List<string>>
{ {

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal interface IBlockParser<T, U> internal interface IBlockParser<T, U>
{ {

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal class IncludesBlock : IBlockParser<List<Token>, List<string>> internal class IncludesBlock : IBlockParser<List<Token>, List<string>>
{ {

View File

@@ -1,6 +1,6 @@
using Ghost.Core.Graphics; using Ghost.Core.Graphics;
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal class KeywordsBlock : IBlockParser<List<FunctionCallDeclaration>, List<KeywordsGroup>> internal class KeywordsBlock : IBlockParser<List<FunctionCallDeclaration>, List<KeywordsGroup>>
{ {

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal static class ParseUtility internal static class ParseUtility
{ {

View File

@@ -1,6 +1,6 @@
using Ghost.Core.Graphics; using Ghost.Core.Graphics;
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
// TODO: Add pass template support. // TODO: Add pass template support.
// Pass templates let user to inject their own custom code into the generated HLSL code. // Pass templates let user to inject their own custom code into the generated HLSL code.

View File

@@ -1,6 +1,6 @@
using Ghost.Core.Graphics; using Ghost.Core.Graphics;
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal class PipelineBlock : IBlockParser<PipelineSyntax, PipelineSemantic> internal class PipelineBlock : IBlockParser<PipelineSyntax, PipelineSemantic>
{ {

View File

@@ -2,7 +2,7 @@ using Ghost.Core.Graphics;
using Misaki.HighPerformance.Mathematics; using Misaki.HighPerformance.Mathematics;
using System.Globalization; using System.Globalization;
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal class PropertiesBlock : IBlockParser<PropertiesSyntax, List<PropertySemantic>> internal class PropertiesBlock : IBlockParser<PropertiesSyntax, List<PropertySemantic>>
{ {

View File

@@ -1,15 +1,15 @@
namespace Ghost.Shader.Compiler.Parser; namespace Ghost.SDL.Compiler.Parser;
internal class ShaderBlock : IBlockParser<ShaderSyntax, ShaderSemantics> internal class ShaderBlock : IBlockParser<SDLSyntax, SDLSemantics>
{ {
public static bool ShouldEnter(Token token) public static bool ShouldEnter(Token token)
{ {
return token.Match(TokenType.Keyword, TokenLexicon.KnownKeywords.SHADER); return token.Match(TokenType.Keyword, TokenLexicon.KnownKeywords.SHADER);
} }
public static ShaderSyntax Parse(TokenStreamSlice stream) public static SDLSyntax Parse(TokenStreamSlice stream)
{ {
var shader = new ShaderSyntax(); var shader = new SDLSyntax();
stream.Expect(TokenType.Keyword); stream.Expect(TokenType.Keyword);
shader.name = stream.Expect(TokenType.StringLiteral); shader.name = stream.Expect(TokenType.StringLiteral);
@@ -49,14 +49,14 @@ internal class ShaderBlock : IBlockParser<ShaderSyntax, ShaderSemantics>
return shader; return shader;
} }
public static ShaderSemantics? SemanticAnalysis(ShaderSyntax? syntax, List<SDLError> errors) public static SDLSemantics? SemanticAnalysis(SDLSyntax? syntax, List<SDLError> errors)
{ {
if (syntax == null) if (syntax == null)
{ {
return null; return null;
} }
var shaderModel = new ShaderSemantics var shaderModel = new SDLSemantics
{ {
name = syntax.name.lexeme, name = syntax.name.lexeme,
properties = PropertiesBlock.SemanticAnalysis(syntax.properties, errors), properties = PropertiesBlock.SemanticAnalysis(syntax.properties, errors),

View File

@@ -1,9 +1,9 @@
using Ghost.Core; using Ghost.Core;
using Ghost.Core.Graphics; using Ghost.Core.Graphics;
using Ghost.Shader.Compiler.Parser; using Ghost.SDL.Compiler.Parser;
using System.Text; using System.Text;
namespace Ghost.Shader.Compiler; namespace Ghost.SDL.Compiler;
public struct SDLError public struct SDLError
{ {
@@ -24,13 +24,13 @@ internal static class SDLCompiler
private struct ShaderInheritance private struct ShaderInheritance
{ {
public ShaderSemantics? parent; public SDLSemantics? parent;
public List<ShaderInheritance>? children; public List<ShaderInheritance>? children;
} }
public static List<ShaderSyntax> ParseShaders(TokenStream stream) public static List<SDLSyntax> ParseShaders(TokenStream stream)
{ {
var shaders = new List<ShaderSyntax>(); var shaders = new List<SDLSyntax>();
while (stream.TryPeek(out var nextToken)) while (stream.TryPeek(out var nextToken))
{ {
@@ -52,7 +52,7 @@ internal static class SDLCompiler
return shaders; return shaders;
} }
public static ShaderSemantics? SemanticAnalysis(ShaderSyntax syntax, out List<SDLError> errors) public static SDLSemantics? SemanticAnalysis(SDLSyntax syntax, out List<SDLError> errors)
{ {
errors = new(); errors = new();
@@ -72,11 +72,11 @@ internal static class SDLCompiler
return shaderModel; return shaderModel;
} }
private static List<ShaderSemantics>? TopologicalSort(ReadOnlySpan<ShaderSemantics> semantics) private static List<SDLSemantics>? TopologicalSort(ReadOnlySpan<SDLSemantics> semantics)
{ {
var inDegrees = new Dictionary<string, int>(); var inDegrees = new Dictionary<string, int>();
var childrenMap = new Dictionary<string, List<string>>(); var childrenMap = new Dictionary<string, List<string>>();
var semanticsMap = new Dictionary<string, ShaderSemantics>(); var semanticsMap = new Dictionary<string, SDLSemantics>();
foreach (var s in semantics) foreach (var s in semantics)
{ {
@@ -94,7 +94,7 @@ internal static class SDLCompiler
} }
} }
var queue = new Queue<ShaderSemantics>(); var queue = new Queue<SDLSemantics>();
foreach (var s in semantics) foreach (var s in semantics)
{ {
if (inDegrees[s.name] == 0) if (inDegrees[s.name] == 0)
@@ -103,7 +103,7 @@ internal static class SDLCompiler
} }
} }
var sortedList = new List<ShaderSemantics>(); var sortedList = new List<SDLSemantics>();
while (queue.Count > 0) while (queue.Count > 0)
{ {
var current = queue.Dequeue(); var current = queue.Dequeue();
@@ -123,7 +123,7 @@ internal static class SDLCompiler
return sortedList.Count == semantics.Length ? sortedList : null; return sortedList.Count == semantics.Length ? sortedList : null;
} }
private static string GetPassUniqueId(ShaderSemantics shader, PassSemantic pass) private static string GetPassUniqueId(SDLSemantics shader, PassSemantic pass)
{ {
//static ulong Fnv1a64(ReadOnlySpan<char> data) //static ulong Fnv1a64(ReadOnlySpan<char> data)
//{ //{
@@ -192,7 +192,7 @@ internal static class SDLCompiler
// TODO: Implement shader inheritance resolution, including property and pass merging. // TODO: Implement shader inheritance resolution, including property and pass merging.
// Currently, we just ignore inheritance. // Currently, we just ignore inheritance.
public static ShaderDescriptor ResolveShader(ShaderSemantics semantics) public static ShaderDescriptor ResolveShader(SDLSemantics semantics)
{ {
var descriptor = new ShaderDescriptor var descriptor = new ShaderDescriptor
{ {

View File

@@ -1,6 +1,6 @@
using Ghost.Core.Graphics; using Ghost.Core.Graphics;
namespace Ghost.Shader.Compiler; namespace Ghost.SDL.Compiler;
public enum PropertyScope public enum PropertyScope
{ {
@@ -38,7 +38,7 @@ internal class PassSemantic
public PipelineSemantic? localPipeline; public PipelineSemantic? localPipeline;
} }
internal class ShaderSemantics internal class SDLSemantics
{ {
public string name = string.Empty; public string name = string.Empty;
public string fallback = string.Empty; public string fallback = string.Empty;

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler; namespace Ghost.SDL.Compiler;
internal struct FunctionCallDeclaration internal struct FunctionCallDeclaration
{ {
@@ -43,7 +43,7 @@ internal class PassSyntax
public List<FunctionCallDeclaration>? functionCalls; public List<FunctionCallDeclaration>? functionCalls;
} }
internal class ShaderSyntax internal class SDLSyntax
{ {
public Token name; public Token name;
public PropertiesSyntax? properties; public PropertiesSyntax? properties;

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler; namespace Ghost.SDL.Compiler;
[Flags] [Flags]
public enum TokenType public enum TokenType

View File

@@ -1,4 +1,4 @@
namespace Ghost.Shader.Compiler; namespace Ghost.SDL.Compiler;
internal static class TokenStreamImple internal static class TokenStreamImple
{ {

View File

@@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Ghost.Shader.Generator; namespace Ghost.SDL.Generator;
public enum PackingRules public enum PackingRules
{ {

View File

@@ -21,7 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Editor.Core", "Ghost.
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Graphics", "Ghost.Graphics\Ghost.Graphics.csproj", "{F55831B1-2ADE-4CEB-8023-F92C7ABF57FE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Graphics", "Ghost.Graphics\Ghost.Graphics.csproj", "{F55831B1-2ADE-4CEB-8023-F92C7ABF57FE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Shader", "Ghost.Shader\Ghost.Shader.csproj", "{145C2867-C0FD-4FB0-B60D-467E52081E14}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.SDL", "Ghost.Shader\Ghost.SDL.csproj", "{145C2867-C0FD-4FB0-B60D-467E52081E14}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Shader.Test", "Ghost.Shader.Test\Ghost.Shader.Test.csproj", "{C3AB43A4-88D8-49F8-B738-A738C8BCEE3F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Shader.Test", "Ghost.Shader.Test\Ghost.Shader.Test.csproj", "{C3AB43A4-88D8-49F8-B738-A738C8BCEE3F}"
EndProject EndProject