forked from MoonsideGames/MoonWorks
				
			allow pushing raw uniform data
							parent
							
								
									515c2ebbca
								
							
						
					
					
						commit
						bd825b6c91
					
				|  | @ -1408,10 +1408,10 @@ namespace MoonWorks.Graphics | ||||||
| 		/// Pushes vertex shader uniforms to the device. | 		/// Pushes vertex shader uniforms to the device. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <returns>A starting offset value to be used with draw calls.</returns> | 		/// <returns>A starting offset value to be used with draw calls.</returns> | ||||||
| 		public unsafe uint PushVertexShaderUniforms<T>( | 		public unsafe uint PushVertexShaderUniforms( | ||||||
| 			in T uniforms | 			void* uniformsPtr, | ||||||
| 		) where T : unmanaged | 			uint size | ||||||
| 		{ | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertGraphicsPipelineBound(); | 			AssertGraphicsPipelineBound(); | ||||||
| 
 | 
 | ||||||
|  | @ -1421,15 +1421,51 @@ namespace MoonWorks.Graphics | ||||||
| 			} | 			} | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			fixed (T* uniformsPtr = &uniforms) |  | ||||||
| 			{ |  | ||||||
| 			return Refresh.Refresh_PushVertexShaderUniforms( | 			return Refresh.Refresh_PushVertexShaderUniforms( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				(IntPtr) uniformsPtr, | 				(IntPtr) uniformsPtr, | ||||||
| 					(uint) Marshal.SizeOf<T>() | 				size | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		/// <summary> | ||||||
|  | 		/// Pushes vertex shader uniforms to the device. | ||||||
|  | 		/// </summary> | ||||||
|  | 		/// <returns>A starting offset value to be used with draw calls.</returns> | ||||||
|  | 		public unsafe uint PushVertexShaderUniforms<T>( | ||||||
|  | 			in T uniforms | ||||||
|  | 		) where T : unmanaged | ||||||
|  | 		{ | ||||||
|  | 			fixed (T* uniformsPtr = &uniforms) | ||||||
|  | 			{ | ||||||
|  | 				return PushVertexShaderUniforms(uniformsPtr, (uint) Marshal.SizeOf<T>()); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		/// <summary> | ||||||
|  | 		/// Pushes fragment shader uniforms to the device. | ||||||
|  | 		/// </summary> | ||||||
|  | 		/// <returns>A starting offset to be used with draw calls.</returns> | ||||||
|  | 		public unsafe uint PushFragmentShaderUniforms( | ||||||
|  | 			void* uniformsPtr, | ||||||
|  | 			uint size | ||||||
|  | 		) { | ||||||
|  | #if DEBUG | ||||||
|  | 			AssertGraphicsPipelineBound(); | ||||||
|  | 
 | ||||||
|  | 			if (currentGraphicsPipeline.FragmentShaderInfo.UniformBufferSize == 0) | ||||||
|  | 			{ | ||||||
|  | 				throw new InvalidOperationException("The current fragment shader does not take a uniform buffer!"); | ||||||
|  | 			} | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | 			return Refresh.Refresh_PushFragmentShaderUniforms( | ||||||
|  | 				Device.Handle, | ||||||
|  | 				Handle, | ||||||
|  | 				(IntPtr) uniformsPtr, | ||||||
|  | 				size | ||||||
|  | 			); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
|  | @ -1440,24 +1476,36 @@ namespace MoonWorks.Graphics | ||||||
| 			in T uniforms | 			in T uniforms | ||||||
| 		) where T : unmanaged | 		) where T : unmanaged | ||||||
| 		{ | 		{ | ||||||
| #if DEBUG |  | ||||||
| 			AssertGraphicsPipelineBound(); |  | ||||||
| 
 |  | ||||||
| 			if (currentGraphicsPipeline.FragmentShaderInfo.UniformBufferSize == 0) |  | ||||||
| 			{ |  | ||||||
| 				throw new InvalidOperationException("The current fragment shader does not take a uniform buffer!"); |  | ||||||
| 			} |  | ||||||
| #endif |  | ||||||
| 			fixed (T* uniformsPtr = &uniforms) | 			fixed (T* uniformsPtr = &uniforms) | ||||||
| 			{ | 			{ | ||||||
| 				return Refresh.Refresh_PushFragmentShaderUniforms( | 				return PushFragmentShaderUniforms(uniformsPtr, (uint) Marshal.SizeOf<T>()); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		/// <summary> | ||||||
|  | 		/// Pushes compute shader uniforms to the device. | ||||||
|  | 		/// </summary> | ||||||
|  | 		/// <returns>A starting offset to be used with dispatch calls.</returns> | ||||||
|  | 		public unsafe uint PushComputeShaderUniforms( | ||||||
|  | 			void* uniformsPtr, | ||||||
|  | 			uint size | ||||||
|  | 		) { | ||||||
|  | #if DEBUG | ||||||
|  | 			AssertComputePipelineBound(); | ||||||
|  | 
 | ||||||
|  | 			if (currentComputePipeline.ComputeShaderInfo.UniformBufferSize == 0) | ||||||
|  | 			{ | ||||||
|  | 				throw new System.InvalidOperationException("The current compute shader does not take a uniform buffer!"); | ||||||
|  | 			} | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | 			return Refresh.Refresh_PushComputeShaderUniforms( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				(IntPtr) uniformsPtr, | 				(IntPtr) uniformsPtr, | ||||||
| 					(uint) Marshal.SizeOf<T>() | 				size | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Pushes compute shader uniforms to the device. | 		/// Pushes compute shader uniforms to the device. | ||||||
|  | @ -1467,23 +1515,9 @@ namespace MoonWorks.Graphics | ||||||
| 			in T uniforms | 			in T uniforms | ||||||
| 		) where T : unmanaged | 		) where T : unmanaged | ||||||
| 		{ | 		{ | ||||||
| #if DEBUG |  | ||||||
| 			AssertComputePipelineBound(); |  | ||||||
| 
 |  | ||||||
| 			if (currentComputePipeline.ComputeShaderInfo.UniformBufferSize == 0) |  | ||||||
| 			{ |  | ||||||
| 				throw new System.InvalidOperationException("The current compute shader does not take a uniform buffer!"); |  | ||||||
| 			} |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| 			fixed (T* uniformsPtr = &uniforms) | 			fixed (T* uniformsPtr = &uniforms) | ||||||
| 			{ | 			{ | ||||||
| 				return Refresh.Refresh_PushComputeShaderUniforms( | 				return PushComputeShaderUniforms(uniformsPtr, (uint) Marshal.SizeOf<T>()); | ||||||
| 					Device.Handle, |  | ||||||
| 					Handle, |  | ||||||
| 					(IntPtr) uniformsPtr, |  | ||||||
| 					(uint) Marshal.SizeOf<T>() |  | ||||||
| 				); |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue