diff --git a/src/DirectX12GameEngine.Shaders/ShaderBase.cs b/src/DirectX12GameEngine.Shaders/ShaderBase.cs deleted file mode 100644 index 05c6cf60..00000000 --- a/src/DirectX12GameEngine.Shaders/ShaderBase.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Numerics; - -namespace DirectX12GameEngine.Shaders -{ - public abstract class ShaderBase - { - [ShaderMethod] - [Shader("vertex")] - public virtual VSOutput VSMain(VSInput input) - { - return default; - } - - [ShaderMethod] - [Shader("pixel")] - public virtual PSOutput PSMain(PSInput input) - { - return default; - } - } - - public struct VSInput - { - [ShaderResource] [PositionSemantic] public Vector3 Position; - [ShaderResource] [NormalSemantic] public Vector3 Normal; - [ShaderResource] [TangentSemantic] public Vector4 Tangent; - [ShaderResource] [TextureCoordinateSemantic] public Vector2 TexCoord; - - [ShaderResource] [SystemInstanceIdSemantic] public uint InstanceId; - } - - public struct VSOutput - { - [ShaderResource] [PositionSemantic] public Vector4 PositionWS; - [ShaderResource] [NormalSemantic(0)] public Vector3 Normal; - [ShaderResource] [NormalSemantic(1)] public Vector3 NormalWS; - [ShaderResource] [TangentSemantic] public Vector4 Tangent; - [ShaderResource] [TextureCoordinateSemantic] public Vector2 TexCoord; - - [ShaderResource] [SystemPositionSemantic] public Vector4 ShadingPosition; - [ShaderResource] [SystemInstanceIdSemantic] public uint InstanceId; - [ShaderResource] [SystemRenderTargetArrayIndexSemantic] public uint TargetId; - } - - public struct PSInput - { - [ShaderResource] [PositionSemantic] public Vector4 PositionWS; - [ShaderResource] [NormalSemantic(0)] public Vector3 Normal; - [ShaderResource] [NormalSemantic(1)] public Vector3 NormalWS; - [ShaderResource] [TangentSemantic] public Vector4 Tangent; - [ShaderResource] [TextureCoordinateSemantic] public Vector2 TexCoord; - - [ShaderResource] [SystemPositionSemantic] public Vector4 ShadingPosition; - [ShaderResource] [SystemInstanceIdSemantic] public uint InstanceId; - [ShaderResource] [SystemRenderTargetArrayIndexSemantic] public uint TargetId; - - [ShaderResource] [SystemIsFrontFaceSemantic] public bool IsFrontFace; - } - - public struct PSOutput - { - [ShaderResource] [SystemTargetSemantic] public Vector4 ColorTarget; - } -} diff --git a/src/DirectX12GameEngine.Shaders/ShaderCompiler.cs b/src/DirectX12GameEngine.Shaders/ShaderCompiler.cs index c5a4dedb..ffe9aba0 100644 --- a/src/DirectX12GameEngine.Shaders/ShaderCompiler.cs +++ b/src/DirectX12GameEngine.Shaders/ShaderCompiler.cs @@ -26,7 +26,7 @@ namespace DirectX12GameEngine.Shaders const uint CP_UTF16 = 1200; IDxcBlobEncoding sourceBlob = library.CreateBlobWithEncodingOnHeapCopy(shaderSource, (uint)(shaderSource.Length * 2), CP_UTF16); - IDxcOperationResult result = compiler.Compile(sourceBlob, filePath, entryPoint ?? GetDefaultEntryPoint(version), $"{GetShaderProfile(version)}_6_1", new[] { "-Zpr" }, 1, null, 0, library.CreateIncludeHandler()); + IDxcOperationResult result = compiler.Compile(sourceBlob, filePath, entryPoint ?? "CSMain", "cs_6_1", new[] { "-Zpr" }, 1, null, 0, library.CreateIncludeHandler()); if (result.GetStatus() == 0) { @@ -64,27 +64,5 @@ namespace DirectX12GameEngine.Shaders blob = library.GetBlobAstUf16(blob); return new string(blob.GetBufferPointer(), 0, (int)(blob.GetBufferSize() / 2)); } - - private static string GetDefaultEntryPoint(ShaderVersion? version) => version switch - { - ShaderVersion.ComputeShader => "CSMain", - ShaderVersion.VertexShader => "VSMain", - ShaderVersion.PixelShader => "PSMain", - ShaderVersion.HullShader => "HSMain", - ShaderVersion.DomainShader => "DSMain", - ShaderVersion.GeometryShader => "GSMain", - _ => "" - }; - - private static string GetShaderProfile(ShaderVersion? version) => version switch - { - ShaderVersion.ComputeShader => "cs", - ShaderVersion.VertexShader => "vs", - ShaderVersion.PixelShader => "ps", - ShaderVersion.HullShader => "hs", - ShaderVersion.DomainShader => "ds", - ShaderVersion.GeometryShader => "gs", - _ => "lib" - }; } }