Update namespace
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -48,7 +48,7 @@ internal static class PlayerLoopService
|
||||
var world = World.GetWorld(i);
|
||||
foreach (var script in world.QueryScript())
|
||||
{
|
||||
script.Update();
|
||||
script.OnDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ internal class D3D12ResourceDatabase : IResourceDatabase, IDisposable
|
||||
|
||||
var id = _shaders.Count;
|
||||
_shaders.Add(shader);
|
||||
return new Identifier<Shader>(id);
|
||||
return new Identifier<SDL>(id);
|
||||
}
|
||||
|
||||
public bool HasShader(Identifier<Shader> 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];
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ghost.Core\Ghost.Core.csproj" />
|
||||
<ProjectReference Include="..\Ghost.Shader\Ghost.Shader.csproj" />
|
||||
<ProjectReference Include="..\Ghost.Shader\Ghost.SDL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -627,7 +627,7 @@ public enum IndexType
|
||||
UInt32
|
||||
}
|
||||
|
||||
// Shader compiler
|
||||
// SDL compiler
|
||||
|
||||
internal ref struct CompilerConfig
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Ghost.Shader\Ghost.Shader.csproj" />
|
||||
<ProjectReference Include="..\Ghost.Shader\Ghost.SDL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ghost.Shader.Compiler;
|
||||
using Ghost.SDL.Compiler;
|
||||
using Misaki.HighPerformance.Mathematics;
|
||||
using System.Numerics;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler;
|
||||
namespace Ghost.SDL.Compiler;
|
||||
|
||||
public class Lexer
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler.Parser;
|
||||
namespace Ghost.SDL.Compiler.Parser;
|
||||
|
||||
internal class DefinesBlock : IBlockParser<List<Token>, List<string>>
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler.Parser;
|
||||
namespace Ghost.SDL.Compiler.Parser;
|
||||
|
||||
internal interface IBlockParser<T, U>
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler.Parser;
|
||||
namespace Ghost.SDL.Compiler.Parser;
|
||||
|
||||
internal class IncludesBlock : IBlockParser<List<Token>, List<string>>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Ghost.Core.Graphics;
|
||||
|
||||
namespace Ghost.Shader.Compiler.Parser;
|
||||
namespace Ghost.SDL.Compiler.Parser;
|
||||
|
||||
internal class KeywordsBlock : IBlockParser<List<FunctionCallDeclaration>, List<KeywordsGroup>>
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler.Parser;
|
||||
namespace Ghost.SDL.Compiler.Parser;
|
||||
|
||||
internal static class ParseUtility
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Ghost.Core.Graphics;
|
||||
|
||||
namespace Ghost.Shader.Compiler.Parser;
|
||||
namespace Ghost.SDL.Compiler.Parser;
|
||||
|
||||
internal class PipelineBlock : IBlockParser<PipelineSyntax, PipelineSemantic>
|
||||
{
|
||||
|
||||
@@ -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<PropertiesSyntax, List<PropertySemantic>>
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
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<ShaderSyntax, ShaderSemantics>
|
||||
return shader;
|
||||
}
|
||||
|
||||
public static ShaderSemantics? SemanticAnalysis(ShaderSyntax? syntax, List<SDLError> errors)
|
||||
public static SDLSemantics? SemanticAnalysis(SDLSyntax? syntax, List<SDLError> errors)
|
||||
{
|
||||
if (syntax == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var shaderModel = new ShaderSemantics
|
||||
var shaderModel = new SDLSemantics
|
||||
{
|
||||
name = syntax.name.lexeme,
|
||||
properties = PropertiesBlock.SemanticAnalysis(syntax.properties, errors),
|
||||
|
||||
@@ -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<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))
|
||||
{
|
||||
@@ -52,7 +52,7 @@ internal static class SDLCompiler
|
||||
return shaders;
|
||||
}
|
||||
|
||||
public static ShaderSemantics? SemanticAnalysis(ShaderSyntax syntax, out List<SDLError> errors)
|
||||
public static SDLSemantics? SemanticAnalysis(SDLSyntax syntax, out List<SDLError> errors)
|
||||
{
|
||||
errors = new();
|
||||
|
||||
@@ -72,11 +72,11 @@ internal static class SDLCompiler
|
||||
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 childrenMap = new Dictionary<string, List<string>>();
|
||||
var semanticsMap = new Dictionary<string, ShaderSemantics>();
|
||||
var semanticsMap = new Dictionary<string, SDLSemantics>();
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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<char> 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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler;
|
||||
namespace Ghost.SDL.Compiler;
|
||||
|
||||
internal struct FunctionCallDeclaration
|
||||
{
|
||||
@@ -43,7 +43,7 @@ internal class PassSyntax
|
||||
public List<FunctionCallDeclaration>? functionCalls;
|
||||
}
|
||||
|
||||
internal class ShaderSyntax
|
||||
internal class SDLSyntax
|
||||
{
|
||||
public Token name;
|
||||
public PropertiesSyntax? properties;
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler;
|
||||
namespace Ghost.SDL.Compiler;
|
||||
|
||||
[Flags]
|
||||
public enum TokenType
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Ghost.Shader.Compiler;
|
||||
namespace Ghost.SDL.Compiler;
|
||||
|
||||
internal static class TokenStreamImple
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user