diff --git a/MoonWorks.csproj b/MoonWorks.csproj
index ccbd6509..2b68c6d7 100644
--- a/MoonWorks.csproj
+++ b/MoonWorks.csproj
@@ -24,13 +24,4 @@
PreserveNewest
-
-
-
- MoonWorks.Shaders.FullscreenVert.spv
-
-
- MoonWorks.Shaders.YUV2RGBAFrag.spv
-
-
diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs
index 0508e7fe..5e56e1e6 100644
--- a/src/Graphics/GraphicsDevice.cs
+++ b/src/Graphics/GraphicsDevice.cs
@@ -14,8 +14,6 @@ namespace MoonWorks.Graphics
public SDL2.SDL.SDL_WindowFlags WindowFlags => (SDL2.SDL.SDL_WindowFlags) windowFlags;
// Built-in video pipeline
- private ShaderModule VideoVertexShader { get; }
- private ShaderModule VideoFragmentShader { get; }
internal GraphicsPipeline VideoPipeline { get; }
public bool IsDisposed { get; private set; }
@@ -25,8 +23,7 @@ namespace MoonWorks.Graphics
public GraphicsDevice(
Backend preferredBackend,
bool debugMode
- )
- {
+ ) {
Backend = (Backend) Refresh.Refresh_SelectBackend((Refresh.Backend) preferredBackend, out windowFlags);
if (Backend == Backend.Invalid)
@@ -38,25 +35,43 @@ namespace MoonWorks.Graphics
Conversions.BoolToByte(debugMode)
);
- VideoVertexShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.FullscreenVert.spv"));
- VideoFragmentShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.YUV2RGBAFrag.spv"));
+ // Check for optional video shaders
+ string basePath = SDL2.SDL.SDL_GetBasePath();
+ string videoVertPath = Path.Combine(basePath, "video_fullscreen.refresh");
+ string videoFragPath = Path.Combine(basePath, "video_yuv2rgba.refresh");
+ if (File.Exists(videoVertPath) && File.Exists(videoFragPath))
+ {
+ ShaderModule videoVertShader = new ShaderModule(this, videoVertPath);
+ ShaderModule videoFragShader = new ShaderModule(this, videoFragPath);
- VideoPipeline = new GraphicsPipeline(
- this,
- new GraphicsPipelineCreateInfo
- {
- AttachmentInfo = new GraphicsPipelineAttachmentInfo(
- new ColorAttachmentDescription(TextureFormat.R8G8B8A8, ColorAttachmentBlendState.None)
- ),
- DepthStencilState = DepthStencilState.Disable,
- VertexShaderInfo = GraphicsShaderInfo.Create(VideoVertexShader, "main", 0),
- FragmentShaderInfo = GraphicsShaderInfo.Create(VideoFragmentShader, "main", 3),
- VertexInputState = VertexInputState.Empty,
- RasterizerState = RasterizerState.CCW_CullNone,
- PrimitiveType = PrimitiveType.TriangleList,
- MultisampleState = MultisampleState.None
- }
- );
+ VideoPipeline = new GraphicsPipeline(
+ this,
+ new GraphicsPipelineCreateInfo
+ {
+ AttachmentInfo = new GraphicsPipelineAttachmentInfo(
+ new ColorAttachmentDescription(
+ TextureFormat.R8G8B8A8,
+ ColorAttachmentBlendState.None
+ )
+ ),
+ DepthStencilState = DepthStencilState.Disable,
+ VertexShaderInfo = GraphicsShaderInfo.Create(
+ videoVertShader,
+ "main",
+ 0
+ ),
+ FragmentShaderInfo = GraphicsShaderInfo.Create(
+ videoFragShader,
+ "main",
+ 3
+ ),
+ VertexInputState = VertexInputState.Empty,
+ RasterizerState = RasterizerState.CCW_CullNone,
+ PrimitiveType = PrimitiveType.TriangleList,
+ MultisampleState = MultisampleState.None
+ }
+ );
+ }
}
public bool ClaimWindow(Window window, PresentMode presentMode)
@@ -214,11 +229,6 @@ namespace MoonWorks.Graphics
}
}
- private static Stream GetEmbeddedResource(string name)
- {
- return typeof(GraphicsDevice).Assembly.GetManifestResourceStream(name);
- }
-
protected virtual void Dispose(bool disposing)
{
if (!IsDisposed)
diff --git a/src/Graphics/Resources/ShaderModule.cs b/src/Graphics/Resources/ShaderModule.cs
index f2c88d43..01b86220 100644
--- a/src/Graphics/Resources/ShaderModule.cs
+++ b/src/Graphics/Resources/ShaderModule.cs
@@ -5,7 +5,7 @@ using System.IO;
namespace MoonWorks.Graphics
{
///
- /// Shader modules expect input in SPIR-V bytecode format.
+ /// Shader modules expect input in Refresh bytecode format.
///
public class ShaderModule : GraphicsResource
{
diff --git a/src/Video/Shaders/Compiled/FullscreenVert.spv b/src/Video/Shaders/Compiled/FullscreenVert.spv
deleted file mode 100644
index ffc57de4..00000000
Binary files a/src/Video/Shaders/Compiled/FullscreenVert.spv and /dev/null differ
diff --git a/src/Video/Shaders/Compiled/YUV2RGBAFrag.spv b/src/Video/Shaders/Compiled/YUV2RGBAFrag.spv
deleted file mode 100644
index c9fbf324..00000000
Binary files a/src/Video/Shaders/Compiled/YUV2RGBAFrag.spv and /dev/null differ
diff --git a/src/Video/Shaders/Source/Fullscreen.vert b/src/Video/Shaders/video_fullscreen.vert
similarity index 100%
rename from src/Video/Shaders/Source/Fullscreen.vert
rename to src/Video/Shaders/video_fullscreen.vert
diff --git a/src/Video/Shaders/Source/YUV2RGBA.frag b/src/Video/Shaders/video_yuv2rgba.frag
similarity index 100%
rename from src/Video/Shaders/Source/YUV2RGBA.frag
rename to src/Video/Shaders/video_yuv2rgba.frag
diff --git a/src/Video/VideoPlayer.cs b/src/Video/VideoPlayer.cs
index 5622b6db..b0405428 100644
--- a/src/Video/VideoPlayer.cs
+++ b/src/Video/VideoPlayer.cs
@@ -50,6 +50,11 @@ namespace MoonWorks.Video
public VideoPlayer(GraphicsDevice graphicsDevice, AudioDevice audioDevice)
{
GraphicsDevice = graphicsDevice;
+ if (GraphicsDevice.VideoPipeline == null)
+ {
+ throw new InvalidOperationException("Missing video shaders!");
+ }
+
AudioDevice = audioDevice;
LinearSampler = new Sampler(graphicsDevice, SamplerCreateInfo.LinearClamp);