forked from MoonsideGames/MoonWorks
Add support for custom Video shaders
parent
66c6ceec04
commit
4f89325d29
|
@ -22,6 +22,10 @@ namespace MoonWorks.Graphics
|
|||
|
||||
private readonly List<WeakReference<GraphicsResource>> resources = new List<WeakReference<GraphicsResource>>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this ONLY for platforms with non-standard graphics APIs where the shader code can't be embedded into the assembly!
|
||||
/// </summary>
|
||||
public static void UseCustomVideoShaders(string vertexShaderFilePath, string fragmentShaderFilePath)
|
||||
{
|
||||
usingCustomVideoShaders = true;
|
||||
customVideoVertexShaderFilepath = vertexShaderFilePath;
|
||||
customVideoFragmentShaderFilepath = fragmentShaderFilePath;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!IsDisposed)
|
||||
|
|
Loading…
Reference in New Issue