forked from MoonsideGames/MoonWorks
				
			Compare commits
	
		
			2 Commits 
		
	
	
		
			b1d30a9e6c
			...
			3348449a2e
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 3348449a2e | |
|  | 05de9a4066 | 
|  | @ -24,13 +24,4 @@ | ||||||
| 			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | 			<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||||
| 		</None> | 		</None> | ||||||
| 	</ItemGroup> | 	</ItemGroup> | ||||||
| 
 |  | ||||||
| 	<ItemGroup> |  | ||||||
| 		<EmbeddedResource Include="src\Video\Shaders\Compiled\FullscreenVert.spv"> |  | ||||||
| 			<LogicalName>MoonWorks.Shaders.FullscreenVert.spv</LogicalName> |  | ||||||
| 		</EmbeddedResource> |  | ||||||
| 		<EmbeddedResource Include="src\Video\Shaders\Compiled\YUV2RGBAFrag.spv"> |  | ||||||
| 			<LogicalName>MoonWorks.Shaders.YUV2RGBAFrag.spv</LogicalName> |  | ||||||
| 		</EmbeddedResource> |  | ||||||
| 	</ItemGroup> |  | ||||||
| </Project> | </Project> | ||||||
|  |  | ||||||
|  | @ -1489,7 +1489,6 @@ namespace MoonWorks.Graphics | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Draws using instanced rendering. | 		/// Draws using instanced rendering. | ||||||
| 		/// It is an error to call this method unless two vertex buffers have been bound. |  | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="baseVertex">The starting index offset for the vertex buffer.</param> | 		/// <param name="baseVertex">The starting index offset for the vertex buffer.</param> | ||||||
| 		/// <param name="startIndex">The starting index offset for the index buffer.</param> | 		/// <param name="startIndex">The starting index offset for the index buffer.</param> | ||||||
|  |  | ||||||
|  | @ -14,8 +14,6 @@ namespace MoonWorks.Graphics | ||||||
| 		public SDL2.SDL.SDL_WindowFlags WindowFlags => (SDL2.SDL.SDL_WindowFlags) windowFlags; | 		public SDL2.SDL.SDL_WindowFlags WindowFlags => (SDL2.SDL.SDL_WindowFlags) windowFlags; | ||||||
| 
 | 
 | ||||||
| 		// Built-in video pipeline | 		// Built-in video pipeline | ||||||
| 		private ShaderModule VideoVertexShader { get; } |  | ||||||
| 		private ShaderModule VideoFragmentShader { get; } |  | ||||||
| 		internal GraphicsPipeline VideoPipeline { get; } | 		internal GraphicsPipeline VideoPipeline { get; } | ||||||
| 
 | 
 | ||||||
| 		public bool IsDisposed { get; private set; } | 		public bool IsDisposed { get; private set; } | ||||||
|  | @ -25,8 +23,7 @@ namespace MoonWorks.Graphics | ||||||
| 		public GraphicsDevice( | 		public GraphicsDevice( | ||||||
| 			Backend preferredBackend, | 			Backend preferredBackend, | ||||||
| 			bool debugMode | 			bool debugMode | ||||||
| 		) | 		) { | ||||||
| 		{ |  | ||||||
| 			Backend = (Backend) Refresh.Refresh_SelectBackend((Refresh.Backend) preferredBackend, out windowFlags); | 			Backend = (Backend) Refresh.Refresh_SelectBackend((Refresh.Backend) preferredBackend, out windowFlags); | ||||||
| 
 | 
 | ||||||
| 			if (Backend == Backend.Invalid) | 			if (Backend == Backend.Invalid) | ||||||
|  | @ -38,25 +35,43 @@ namespace MoonWorks.Graphics | ||||||
| 				Conversions.BoolToByte(debugMode) | 				Conversions.BoolToByte(debugMode) | ||||||
| 			); | 			); | ||||||
| 
 | 
 | ||||||
| 			VideoVertexShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.FullscreenVert.spv")); | 			// Check for optional video shaders | ||||||
| 			VideoFragmentShader = new ShaderModule(this, GetEmbeddedResource("MoonWorks.Shaders.YUV2RGBAFrag.spv")); | 			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( | 				VideoPipeline = new GraphicsPipeline( | ||||||
| 				this, | 					this, | ||||||
| 				new GraphicsPipelineCreateInfo | 					new GraphicsPipelineCreateInfo | ||||||
| 				{ | 					{ | ||||||
| 					AttachmentInfo = new GraphicsPipelineAttachmentInfo( | 						AttachmentInfo = new GraphicsPipelineAttachmentInfo( | ||||||
| 						new ColorAttachmentDescription(TextureFormat.R8G8B8A8, ColorAttachmentBlendState.None) | 							new ColorAttachmentDescription( | ||||||
| 					), | 								TextureFormat.R8G8B8A8, | ||||||
| 					DepthStencilState = DepthStencilState.Disable, | 								ColorAttachmentBlendState.None | ||||||
| 					VertexShaderInfo = GraphicsShaderInfo.Create(VideoVertexShader, "main", 0), | 							) | ||||||
| 					FragmentShaderInfo = GraphicsShaderInfo.Create(VideoFragmentShader, "main", 3), | 						), | ||||||
| 					VertexInputState = VertexInputState.Empty, | 						DepthStencilState = DepthStencilState.Disable, | ||||||
| 					RasterizerState = RasterizerState.CCW_CullNone, | 						VertexShaderInfo = GraphicsShaderInfo.Create( | ||||||
| 					PrimitiveType = PrimitiveType.TriangleList, | 							videoVertShader, | ||||||
| 					MultisampleState = MultisampleState.None | 							"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) | 		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) | 		protected virtual void Dispose(bool disposing) | ||||||
| 		{ | 		{ | ||||||
| 			if (!IsDisposed) | 			if (!IsDisposed) | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ using System.IO; | ||||||
| namespace MoonWorks.Graphics | namespace MoonWorks.Graphics | ||||||
| { | { | ||||||
| 	/// <summary> | 	/// <summary> | ||||||
| 	/// Shader modules expect input in SPIR-V bytecode format. | 	/// Shader modules expect input in Refresh bytecode format. | ||||||
| 	/// </summary> | 	/// </summary> | ||||||
| 	public class ShaderModule : GraphicsResource | 	public class ShaderModule : GraphicsResource | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -50,6 +50,11 @@ namespace MoonWorks.Video | ||||||
| 		public VideoPlayer(GraphicsDevice graphicsDevice, AudioDevice audioDevice) | 		public VideoPlayer(GraphicsDevice graphicsDevice, AudioDevice audioDevice) | ||||||
| 		{ | 		{ | ||||||
| 			GraphicsDevice = graphicsDevice; | 			GraphicsDevice = graphicsDevice; | ||||||
|  | 			if (GraphicsDevice.VideoPipeline == null) | ||||||
|  | 			{ | ||||||
|  | 				throw new InvalidOperationException("Missing video shaders!"); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			AudioDevice = audioDevice; | 			AudioDevice = audioDevice; | ||||||
| 			LinearSampler = new Sampler(graphicsDevice, SamplerCreateInfo.LinearClamp); | 			LinearSampler = new Sampler(graphicsDevice, SamplerCreateInfo.LinearClamp); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue