diff --git a/MoonWorks.csproj b/MoonWorks.csproj index e09a901..baa210d 100644 --- a/MoonWorks.csproj +++ b/MoonWorks.csproj @@ -24,4 +24,13 @@ Never + + + + MoonWorks.Graphics.StockShaders.VideoFullscreen.vert.refresh + + + MoonWorks.Graphics.StockShaders.VideoYUV2RGBA.frag.refresh + + diff --git a/lib/dav1dfile b/lib/dav1dfile index 3dcd69f..5065e2c 160000 --- a/lib/dav1dfile +++ b/lib/dav1dfile @@ -1 +1 @@ -Subproject commit 3dcd69ff85db80eea51481edd323b42c05993e1a +Subproject commit 5065e2cd4662dbe023b77a45ef967f975170dfff diff --git a/src/Game.cs b/src/Game.cs index 1b7286f..0ba395f 100644 --- a/src/Game.cs +++ b/src/Game.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using SDL2; +using SDL2; using MoonWorks.Audio; using MoonWorks.Graphics; using MoonWorks.Input; diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index 9920b09..191dbde 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -45,39 +45,54 @@ namespace MoonWorks.Graphics string basePath = System.AppContext.BaseDirectory; string videoVertPath = Path.Combine(basePath, "video_fullscreen.vert.refresh"); string videoFragPath = Path.Combine(basePath, "video_yuv2rgba.frag.refresh"); + + ShaderModule videoVertShader; + ShaderModule videoFragShader; + 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( - videoVertShader, - "main", - 0 - ), - FragmentShaderInfo = GraphicsShaderInfo.Create( - videoFragShader, - "main", - 3 - ), - VertexInputState = VertexInputState.Empty, - RasterizerState = RasterizerState.CCW_CullNone, - PrimitiveType = PrimitiveType.TriangleList, - MultisampleState = MultisampleState.None - } - ); + videoVertShader = new ShaderModule(this, videoVertPath); + videoFragShader = new ShaderModule(this, videoFragPath); } + else + { + // use defaults + var assembly = typeof(GraphicsDevice).Assembly; + + using var vertStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.VideoFullscreen.vert.refresh"); + using var fragStream = assembly.GetManifestResourceStream("MoonWorks.Graphics.StockShaders.VideoYUV2RGBA.frag.refresh"); + + videoVertShader = new ShaderModule(this, vertStream); + videoFragShader = new ShaderModule(this, fragStream); + } + + 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 + } + ); FencePool = new FencePool(this); } diff --git a/src/Graphics/StockShaders/Binary/video_fullscreen.vert.refresh b/src/Graphics/StockShaders/Binary/video_fullscreen.vert.refresh new file mode 100644 index 0000000..131f3a6 Binary files /dev/null and b/src/Graphics/StockShaders/Binary/video_fullscreen.vert.refresh differ diff --git a/src/Graphics/StockShaders/Binary/video_yuv2rgba.frag.refresh b/src/Graphics/StockShaders/Binary/video_yuv2rgba.frag.refresh new file mode 100644 index 0000000..176e8b4 Binary files /dev/null and b/src/Graphics/StockShaders/Binary/video_yuv2rgba.frag.refresh differ diff --git a/src/Video/Shaders/video_fullscreen.vert b/src/Graphics/StockShaders/Source/video_fullscreen.vert similarity index 100% rename from src/Video/Shaders/video_fullscreen.vert rename to src/Graphics/StockShaders/Source/video_fullscreen.vert diff --git a/src/Video/Shaders/video_yuv2rgba.frag b/src/Graphics/StockShaders/Source/video_yuv2rgba.frag similarity index 100% rename from src/Video/Shaders/video_yuv2rgba.frag rename to src/Graphics/StockShaders/Source/video_yuv2rgba.frag