From 9dc4f63e40dd9536d9b04ea3071e239b07b42c4b Mon Sep 17 00:00:00 2001 From: Misaki Date: Thu, 23 Oct 2025 15:13:10 +0900 Subject: [PATCH] Update namespace --- .../{InternalRelease.cs => IReleasable.cs} | 0 Ghost.Core/TypeHandle.cs | 5 ++++ Ghost.Engine/Services/PlayerLoopService.cs | 2 +- Ghost.Graphics/D3D12/D3D12ResourceDatabase.cs | 4 ++-- Ghost.Graphics/Ghost.Graphics.csproj | 2 +- Ghost.Graphics/RHI/Common.cs | 2 +- Ghost.Graphics/RenderPasses/MeshRenderPass.cs | 2 +- Ghost.Shader.Test/Ghost.Shader.Test.csproj | 2 +- Ghost.Shader.Test/Program.cs | 2 +- Ghost.Shader/Compiler/Lexer.cs | 2 +- Ghost.Shader/Compiler/Parser/DefinesBlock.cs | 2 +- Ghost.Shader/Compiler/Parser/IBlockParser.cs | 2 +- Ghost.Shader/Compiler/Parser/IncludesBlock.cs | 2 +- Ghost.Shader/Compiler/Parser/KeywordsBlock.cs | 2 +- Ghost.Shader/Compiler/Parser/ParseUtility.cs | 2 +- Ghost.Shader/Compiler/Parser/PassBlock.cs | 2 +- Ghost.Shader/Compiler/Parser/PipelineBlock.cs | 2 +- .../Compiler/Parser/PropertiesBlock.cs | 2 +- Ghost.Shader/Compiler/Parser/ShaderBlock.cs | 12 +++++----- Ghost.Shader/Compiler/SDLCompiler.cs | 24 +++++++++---------- .../{ShaderSemantics.cs => SDLSemantics.cs} | 4 ++-- .../{ShaderSyntax.cs => SDLSyntax.cs} | 4 ++-- Ghost.Shader/Compiler/Token.cs | 2 +- Ghost.Shader/Compiler/TokenStream.cs | 2 +- .../Generator/ShaderStructGenerator.cs | 2 +- .../{Ghost.Shader.csproj => Ghost.SDL.csproj} | 0 GhostEngine.sln | 2 +- 27 files changed, 48 insertions(+), 43 deletions(-) rename Ghost.Core/Contracts/{InternalRelease.cs => IReleasable.cs} (100%) rename Ghost.Shader/Compiler/{ShaderSemantics.cs => SDLSemantics.cs} (94%) rename Ghost.Shader/Compiler/{ShaderSyntax.cs => SDLSyntax.cs} (94%) rename Ghost.Shader/{Ghost.Shader.csproj => Ghost.SDL.csproj} (100%) diff --git a/Ghost.Core/Contracts/InternalRelease.cs b/Ghost.Core/Contracts/IReleasable.cs similarity index 100% rename from Ghost.Core/Contracts/InternalRelease.cs rename to Ghost.Core/Contracts/IReleasable.cs diff --git a/Ghost.Core/TypeHandle.cs b/Ghost.Core/TypeHandle.cs index f1c660b..0d5020d 100644 --- a/Ghost.Core/TypeHandle.cs +++ b/Ghost.Core/TypeHandle.cs @@ -40,6 +40,11 @@ public readonly struct TypeHandle return Type.GetTypeFromHandle(RuntimeTypeHandle.FromIntPtr(Value)); } + public override int GetHashCode() + { + return Value.GetHashCode(); + } + public static implicit operator TypeHandle(IntPtr value) { return new TypeHandle(value); diff --git a/Ghost.Engine/Services/PlayerLoopService.cs b/Ghost.Engine/Services/PlayerLoopService.cs index 7d82c0b..f332807 100644 --- a/Ghost.Engine/Services/PlayerLoopService.cs +++ b/Ghost.Engine/Services/PlayerLoopService.cs @@ -48,7 +48,7 @@ internal static class PlayerLoopService var world = World.GetWorld(i); foreach (var script in world.QueryScript()) { - script.Update(); + script.OnDestroy(); } } diff --git a/Ghost.Graphics/D3D12/D3D12ResourceDatabase.cs b/Ghost.Graphics/D3D12/D3D12ResourceDatabase.cs index 7d75e83..b8774a6 100644 --- a/Ghost.Graphics/D3D12/D3D12ResourceDatabase.cs +++ b/Ghost.Graphics/D3D12/D3D12ResourceDatabase.cs @@ -369,7 +369,7 @@ internal class D3D12ResourceDatabase : IResourceDatabase, IDisposable var id = _shaders.Count; _shaders.Add(shader); - return new Identifier(id); + return new Identifier(id); } public bool HasShader(Identifier id) @@ -460,7 +460,7 @@ internal class D3D12ResourceDatabase : IResourceDatabase, IDisposable 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++) { ref var shader = ref _shaders[i]; diff --git a/Ghost.Graphics/Ghost.Graphics.csproj b/Ghost.Graphics/Ghost.Graphics.csproj index 80ad45a..37dc8be 100644 --- a/Ghost.Graphics/Ghost.Graphics.csproj +++ b/Ghost.Graphics/Ghost.Graphics.csproj @@ -23,7 +23,7 @@ - + diff --git a/Ghost.Graphics/RHI/Common.cs b/Ghost.Graphics/RHI/Common.cs index 1e18e8f..c16d36e 100644 --- a/Ghost.Graphics/RHI/Common.cs +++ b/Ghost.Graphics/RHI/Common.cs @@ -627,7 +627,7 @@ public enum IndexType UInt32 } -// Shader compiler +// SDL compiler internal ref struct CompilerConfig { diff --git a/Ghost.Graphics/RenderPasses/MeshRenderPass.cs b/Ghost.Graphics/RenderPasses/MeshRenderPass.cs index c4cad32..ac65412 100644 --- a/Ghost.Graphics/RenderPasses/MeshRenderPass.cs +++ b/Ghost.Graphics/RenderPasses/MeshRenderPass.cs @@ -3,7 +3,7 @@ using Ghost.Graphics.Contracts; using Ghost.Graphics.Data; using Ghost.Graphics.RHI; using Ghost.Graphics.Utilities; -using Ghost.Shader.Compiler; +using Ghost.SDL.Compiler; using Misaki.HighPerformance.Image; namespace Ghost.Graphics.RenderPasses; diff --git a/Ghost.Shader.Test/Ghost.Shader.Test.csproj b/Ghost.Shader.Test/Ghost.Shader.Test.csproj index 61f0db5..abf0647 100644 --- a/Ghost.Shader.Test/Ghost.Shader.Test.csproj +++ b/Ghost.Shader.Test/Ghost.Shader.Test.csproj @@ -9,7 +9,7 @@ - + diff --git a/Ghost.Shader.Test/Program.cs b/Ghost.Shader.Test/Program.cs index 1b4c7bd..182f5f5 100644 --- a/Ghost.Shader.Test/Program.cs +++ b/Ghost.Shader.Test/Program.cs @@ -1,4 +1,4 @@ -using Ghost.Shader.Compiler; +using Ghost.SDL.Compiler; using Misaki.HighPerformance.Mathematics; using System.Numerics; diff --git a/Ghost.Shader/Compiler/Lexer.cs b/Ghost.Shader/Compiler/Lexer.cs index bedfc27..299e454 100644 --- a/Ghost.Shader/Compiler/Lexer.cs +++ b/Ghost.Shader/Compiler/Lexer.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler; +namespace Ghost.SDL.Compiler; public class Lexer { diff --git a/Ghost.Shader/Compiler/Parser/DefinesBlock.cs b/Ghost.Shader/Compiler/Parser/DefinesBlock.cs index a46dba8..2c0be99 100644 --- a/Ghost.Shader/Compiler/Parser/DefinesBlock.cs +++ b/Ghost.Shader/Compiler/Parser/DefinesBlock.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; internal class DefinesBlock : IBlockParser, List> { diff --git a/Ghost.Shader/Compiler/Parser/IBlockParser.cs b/Ghost.Shader/Compiler/Parser/IBlockParser.cs index ed3c2a0..76a8c55 100644 --- a/Ghost.Shader/Compiler/Parser/IBlockParser.cs +++ b/Ghost.Shader/Compiler/Parser/IBlockParser.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; internal interface IBlockParser { diff --git a/Ghost.Shader/Compiler/Parser/IncludesBlock.cs b/Ghost.Shader/Compiler/Parser/IncludesBlock.cs index 7fc86b5..57f99b3 100644 --- a/Ghost.Shader/Compiler/Parser/IncludesBlock.cs +++ b/Ghost.Shader/Compiler/Parser/IncludesBlock.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; internal class IncludesBlock : IBlockParser, List> { diff --git a/Ghost.Shader/Compiler/Parser/KeywordsBlock.cs b/Ghost.Shader/Compiler/Parser/KeywordsBlock.cs index 761d268..f3edfbb 100644 --- a/Ghost.Shader/Compiler/Parser/KeywordsBlock.cs +++ b/Ghost.Shader/Compiler/Parser/KeywordsBlock.cs @@ -1,6 +1,6 @@ using Ghost.Core.Graphics; -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; internal class KeywordsBlock : IBlockParser, List> { diff --git a/Ghost.Shader/Compiler/Parser/ParseUtility.cs b/Ghost.Shader/Compiler/Parser/ParseUtility.cs index c27408a..1e130a1 100644 --- a/Ghost.Shader/Compiler/Parser/ParseUtility.cs +++ b/Ghost.Shader/Compiler/Parser/ParseUtility.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; internal static class ParseUtility { diff --git a/Ghost.Shader/Compiler/Parser/PassBlock.cs b/Ghost.Shader/Compiler/Parser/PassBlock.cs index bae5904..c890b91 100644 --- a/Ghost.Shader/Compiler/Parser/PassBlock.cs +++ b/Ghost.Shader/Compiler/Parser/PassBlock.cs @@ -1,6 +1,6 @@ using Ghost.Core.Graphics; -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; // TODO: Add pass template support. // Pass templates let user to inject their own custom code into the generated HLSL code. diff --git a/Ghost.Shader/Compiler/Parser/PipelineBlock.cs b/Ghost.Shader/Compiler/Parser/PipelineBlock.cs index d0e08e6..871d1a0 100644 --- a/Ghost.Shader/Compiler/Parser/PipelineBlock.cs +++ b/Ghost.Shader/Compiler/Parser/PipelineBlock.cs @@ -1,6 +1,6 @@ using Ghost.Core.Graphics; -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; internal class PipelineBlock : IBlockParser { diff --git a/Ghost.Shader/Compiler/Parser/PropertiesBlock.cs b/Ghost.Shader/Compiler/Parser/PropertiesBlock.cs index b83b37c..a089fa4 100644 --- a/Ghost.Shader/Compiler/Parser/PropertiesBlock.cs +++ b/Ghost.Shader/Compiler/Parser/PropertiesBlock.cs @@ -2,7 +2,7 @@ using Ghost.Core.Graphics; using Misaki.HighPerformance.Mathematics; using System.Globalization; -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; internal class PropertiesBlock : IBlockParser> { diff --git a/Ghost.Shader/Compiler/Parser/ShaderBlock.cs b/Ghost.Shader/Compiler/Parser/ShaderBlock.cs index 706ebe5..bae258f 100644 --- a/Ghost.Shader/Compiler/Parser/ShaderBlock.cs +++ b/Ghost.Shader/Compiler/Parser/ShaderBlock.cs @@ -1,15 +1,15 @@ -namespace Ghost.Shader.Compiler.Parser; +namespace Ghost.SDL.Compiler.Parser; -internal class ShaderBlock : IBlockParser +internal class ShaderBlock : IBlockParser { public static bool ShouldEnter(Token token) { 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); shader.name = stream.Expect(TokenType.StringLiteral); @@ -49,14 +49,14 @@ internal class ShaderBlock : IBlockParser return shader; } - public static ShaderSemantics? SemanticAnalysis(ShaderSyntax? syntax, List errors) + public static SDLSemantics? SemanticAnalysis(SDLSyntax? syntax, List errors) { if (syntax == null) { return null; } - var shaderModel = new ShaderSemantics + var shaderModel = new SDLSemantics { name = syntax.name.lexeme, properties = PropertiesBlock.SemanticAnalysis(syntax.properties, errors), diff --git a/Ghost.Shader/Compiler/SDLCompiler.cs b/Ghost.Shader/Compiler/SDLCompiler.cs index 7c7fa26..e2a2d1c 100644 --- a/Ghost.Shader/Compiler/SDLCompiler.cs +++ b/Ghost.Shader/Compiler/SDLCompiler.cs @@ -1,9 +1,9 @@ using Ghost.Core; using Ghost.Core.Graphics; -using Ghost.Shader.Compiler.Parser; +using Ghost.SDL.Compiler.Parser; using System.Text; -namespace Ghost.Shader.Compiler; +namespace Ghost.SDL.Compiler; public struct SDLError { @@ -24,13 +24,13 @@ internal static class SDLCompiler private struct ShaderInheritance { - public ShaderSemantics? parent; + public SDLSemantics? parent; public List? children; } - public static List ParseShaders(TokenStream stream) + public static List ParseShaders(TokenStream stream) { - var shaders = new List(); + var shaders = new List(); while (stream.TryPeek(out var nextToken)) { @@ -52,7 +52,7 @@ internal static class SDLCompiler return shaders; } - public static ShaderSemantics? SemanticAnalysis(ShaderSyntax syntax, out List errors) + public static SDLSemantics? SemanticAnalysis(SDLSyntax syntax, out List errors) { errors = new(); @@ -72,11 +72,11 @@ internal static class SDLCompiler return shaderModel; } - private static List? TopologicalSort(ReadOnlySpan semantics) + private static List? TopologicalSort(ReadOnlySpan semantics) { var inDegrees = new Dictionary(); var childrenMap = new Dictionary>(); - var semanticsMap = new Dictionary(); + var semanticsMap = new Dictionary(); foreach (var s in semantics) { @@ -94,7 +94,7 @@ internal static class SDLCompiler } } - var queue = new Queue(); + var queue = new Queue(); foreach (var s in semantics) { if (inDegrees[s.name] == 0) @@ -103,7 +103,7 @@ internal static class SDLCompiler } } - var sortedList = new List(); + var sortedList = new List(); while (queue.Count > 0) { var current = queue.Dequeue(); @@ -123,7 +123,7 @@ internal static class SDLCompiler 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 data) //{ @@ -192,7 +192,7 @@ internal static class SDLCompiler // TODO: Implement shader inheritance resolution, including property and pass merging. // Currently, we just ignore inheritance. - public static ShaderDescriptor ResolveShader(ShaderSemantics semantics) + public static ShaderDescriptor ResolveShader(SDLSemantics semantics) { var descriptor = new ShaderDescriptor { diff --git a/Ghost.Shader/Compiler/ShaderSemantics.cs b/Ghost.Shader/Compiler/SDLSemantics.cs similarity index 94% rename from Ghost.Shader/Compiler/ShaderSemantics.cs rename to Ghost.Shader/Compiler/SDLSemantics.cs index 98e4367..3191211 100644 --- a/Ghost.Shader/Compiler/ShaderSemantics.cs +++ b/Ghost.Shader/Compiler/SDLSemantics.cs @@ -1,6 +1,6 @@ using Ghost.Core.Graphics; -namespace Ghost.Shader.Compiler; +namespace Ghost.SDL.Compiler; public enum PropertyScope { @@ -38,7 +38,7 @@ internal class PassSemantic public PipelineSemantic? localPipeline; } -internal class ShaderSemantics +internal class SDLSemantics { public string name = string.Empty; public string fallback = string.Empty; diff --git a/Ghost.Shader/Compiler/ShaderSyntax.cs b/Ghost.Shader/Compiler/SDLSyntax.cs similarity index 94% rename from Ghost.Shader/Compiler/ShaderSyntax.cs rename to Ghost.Shader/Compiler/SDLSyntax.cs index 0e9b604..fc24d54 100644 --- a/Ghost.Shader/Compiler/ShaderSyntax.cs +++ b/Ghost.Shader/Compiler/SDLSyntax.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler; +namespace Ghost.SDL.Compiler; internal struct FunctionCallDeclaration { @@ -43,7 +43,7 @@ internal class PassSyntax public List? functionCalls; } -internal class ShaderSyntax +internal class SDLSyntax { public Token name; public PropertiesSyntax? properties; diff --git a/Ghost.Shader/Compiler/Token.cs b/Ghost.Shader/Compiler/Token.cs index 9c02b75..4a4cbfe 100644 --- a/Ghost.Shader/Compiler/Token.cs +++ b/Ghost.Shader/Compiler/Token.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler; +namespace Ghost.SDL.Compiler; [Flags] public enum TokenType diff --git a/Ghost.Shader/Compiler/TokenStream.cs b/Ghost.Shader/Compiler/TokenStream.cs index 1412263..3af5259 100644 --- a/Ghost.Shader/Compiler/TokenStream.cs +++ b/Ghost.Shader/Compiler/TokenStream.cs @@ -1,4 +1,4 @@ -namespace Ghost.Shader.Compiler; +namespace Ghost.SDL.Compiler; internal static class TokenStreamImple { diff --git a/Ghost.Shader/Generator/ShaderStructGenerator.cs b/Ghost.Shader/Generator/ShaderStructGenerator.cs index cc5fcc2..d7cbfde 100644 --- a/Ghost.Shader/Generator/ShaderStructGenerator.cs +++ b/Ghost.Shader/Generator/ShaderStructGenerator.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; -namespace Ghost.Shader.Generator; +namespace Ghost.SDL.Generator; public enum PackingRules { diff --git a/Ghost.Shader/Ghost.Shader.csproj b/Ghost.Shader/Ghost.SDL.csproj similarity index 100% rename from Ghost.Shader/Ghost.Shader.csproj rename to Ghost.Shader/Ghost.SDL.csproj diff --git a/GhostEngine.sln b/GhostEngine.sln index 0c945b8..57745f8 100644 --- a/GhostEngine.sln +++ b/GhostEngine.sln @@ -21,7 +21,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Editor.Core", "Ghost. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Graphics", "Ghost.Graphics\Ghost.Graphics.csproj", "{F55831B1-2ADE-4CEB-8023-F92C7ABF57FE}" 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 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Shader.Test", "Ghost.Shader.Test\Ghost.Shader.Test.csproj", "{C3AB43A4-88D8-49F8-B738-A738C8BCEE3F}" EndProject