diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index 97fd954d..a2182db0 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -22,6 +22,10 @@ namespace MoonWorks.Graphics private readonly List> resources = new List>(); + private static bool usingCustomVideoShaders; + private static string customVideoVertexShaderFilepath; + private static string customVideoFragmentShaderFilepath; + public GraphicsDevice( Backend preferredBackend, bool debugMode @@ -38,8 +42,24 @@ namespace MoonWorks.Graphics Conversions.BoolToByte(debugMode) ); - VideoVertexShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.FullscreenVert.spv")); - VideoFragmentShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.YUV2RGBAFrag.spv")); + Stream videoVertexShaderStream; + Stream videoFragmentShaderStream; + if (!usingCustomVideoShaders) + { + videoVertexShaderStream = GetEmbeddedResource("MoonWorks.Shaders.FullscreenVert.spv"); + videoFragmentShaderStream = GetEmbeddedResource("MoonWorks.Shaders.YUV2RGBAFrag.spv"); + } + else + { + videoVertexShaderStream = File.Open(customVideoVertexShaderFilepath, FileMode.Open, FileAccess.Read); + videoFragmentShaderStream = File.Open(customVideoFragmentShaderFilepath, FileMode.Open, FileAccess.Read); + } + + VideoVertexShader = new ShaderModule(this, videoVertexShaderStream); + VideoFragmentShader = new ShaderModule(this, videoFragmentShaderStream); + + videoVertexShaderStream.Close(); + videoFragmentShaderStream.Close(); VideoPipeline = new GraphicsPipeline( this, @@ -148,6 +168,16 @@ namespace MoonWorks.Graphics return typeof(GraphicsDevice).Assembly.GetManifestResourceStream(name); } + /// + /// Use this ONLY for platforms with non-standard graphics APIs where the shader code can't be embedded into the assembly! + /// + public static void UseCustomVideoShaders(string vertexShaderFilePath, string fragmentShaderFilePath) + { + usingCustomVideoShaders = true; + customVideoVertexShaderFilepath = vertexShaderFilePath; + customVideoFragmentShaderFilepath = fragmentShaderFilePath; + } + protected virtual void Dispose(bool disposing) { if (!IsDisposed)