forked from Misaki/GhostEngine
Update namespace
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user