TextureSlice and TextureRegion API
							parent
							
								
									e0f4c19dc2
								
							
						
					
					
						commit
						0e723514df
					
				|  | @ -1 +1 @@ | ||||||
| Subproject commit 031ad4c04781fe4a0d98a177333ebf7764d2fe91 | Subproject commit 020e76782a2aba7861a8e356d1d212a2bffb2d2e | ||||||
|  | @ -1,17 +0,0 @@ | ||||||
| namespace MoonWorks.Graphics |  | ||||||
| { |  | ||||||
| 	/// <summary> |  | ||||||
| 	/// A texture-level pair to be used when binding compute textures. |  | ||||||
| 	/// </summary> |  | ||||||
| 	public struct TextureLevelBinding |  | ||||||
| 	{ |  | ||||||
| 		public Texture Texture; |  | ||||||
| 		public uint MipLevel; |  | ||||||
| 
 |  | ||||||
| 		public TextureLevelBinding(Texture texture, uint mipLevel = 0) |  | ||||||
| 		{ |  | ||||||
| 			Texture = texture; |  | ||||||
| 			MipLevel = mipLevel; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | @ -157,9 +157,9 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = false; | 			hasDepthStencilAttachment = false; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfo.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfo.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 1; | 			colorAttachmentCount = 1; | ||||||
| 			colorFormatOne = colorAttachmentInfo.Texture.Format; | 			colorFormatOne = colorAttachmentInfo.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -182,7 +182,7 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertTextureNotNull(colorAttachmentInfoTwo); | 			AssertTextureNotNull(colorAttachmentInfoTwo); | ||||||
| 			AssertColorTarget(colorAttachmentInfoTwo); | 			AssertColorTarget(colorAttachmentInfoTwo); | ||||||
| 
 | 
 | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoTwo.TextureSlice.Texture); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2]; | 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2]; | ||||||
|  | @ -200,10 +200,10 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = false; | 			hasDepthStencilAttachment = false; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfoOne.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 2; | 			colorAttachmentCount = 2; | ||||||
| 			colorFormatOne = colorAttachmentInfoOne.Texture.Format; | 			colorFormatOne = colorAttachmentInfoOne.TextureSlice.Texture.Format; | ||||||
| 			colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; | 			colorFormatTwo = colorAttachmentInfoTwo.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -232,8 +232,8 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertTextureNotNull(colorAttachmentInfoThree); | 			AssertTextureNotNull(colorAttachmentInfoThree); | ||||||
| 			AssertColorTarget(colorAttachmentInfoThree); | 			AssertColorTarget(colorAttachmentInfoThree); | ||||||
| 
 | 
 | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoTwo.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoThree.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoThree.TextureSlice.Texture); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3]; | 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3]; | ||||||
|  | @ -252,11 +252,11 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = false; | 			hasDepthStencilAttachment = false; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfoOne.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 3; | 			colorAttachmentCount = 3; | ||||||
| 			colorFormatOne = colorAttachmentInfoOne.Texture.Format; | 			colorFormatOne = colorAttachmentInfoOne.TextureSlice.Texture.Format; | ||||||
| 			colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; | 			colorFormatTwo = colorAttachmentInfoTwo.TextureSlice.Texture.Format; | ||||||
| 			colorFormatThree = colorAttachmentInfoThree.Texture.Format; | 			colorFormatThree = colorAttachmentInfoThree.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -290,9 +290,9 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertTextureNotNull(colorAttachmentInfoFour); | 			AssertTextureNotNull(colorAttachmentInfoFour); | ||||||
| 			AssertColorTarget(colorAttachmentInfoFour); | 			AssertColorTarget(colorAttachmentInfoFour); | ||||||
| 
 | 
 | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoTwo.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoThree.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoThree.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoFour.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoFour.TextureSlice.Texture); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4]; | 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4]; | ||||||
|  | @ -312,12 +312,12 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = false; | 			hasDepthStencilAttachment = false; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfoOne.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 4; | 			colorAttachmentCount = 4; | ||||||
| 			colorFormatOne = colorAttachmentInfoOne.Texture.Format; | 			colorFormatOne = colorAttachmentInfoOne.TextureSlice.Texture.Format; | ||||||
| 			colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; | 			colorFormatTwo = colorAttachmentInfoTwo.TextureSlice.Texture.Format; | ||||||
| 			colorFormatThree = colorAttachmentInfoThree.Texture.Format; | 			colorFormatThree = colorAttachmentInfoThree.TextureSlice.Texture.Format; | ||||||
| 			colorFormatFour = colorAttachmentInfoFour.Texture.Format; | 			colorFormatFour = colorAttachmentInfoFour.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -348,8 +348,8 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = true; | 			hasDepthStencilAttachment = true; | ||||||
| 			depthStencilAttachmentSampleCount = depthStencilAttachmentInfo.Texture.SampleCount; | 			depthStencilAttachmentSampleCount = depthStencilAttachmentInfo.TextureSlice.Texture.SampleCount; | ||||||
| 			depthStencilFormat = depthStencilAttachmentInfo.Texture.Format; | 			depthStencilFormat = depthStencilAttachmentInfo.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -370,7 +370,7 @@ namespace MoonWorks.Graphics | ||||||
| 
 | 
 | ||||||
| 			AssertTextureNotNull(colorAttachmentInfo); | 			AssertTextureNotNull(colorAttachmentInfo); | ||||||
| 			AssertColorTarget(colorAttachmentInfo); | 			AssertColorTarget(colorAttachmentInfo); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfo.Texture, depthStencilAttachmentInfo.Texture); | 			AssertSameSampleCount(colorAttachmentInfo.TextureSlice.Texture, depthStencilAttachmentInfo.TextureSlice.Texture); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[1]; | 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[1]; | ||||||
|  | @ -389,11 +389,11 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = true; | 			hasDepthStencilAttachment = true; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfo.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfo.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 1; | 			colorAttachmentCount = 1; | ||||||
| 			depthStencilAttachmentSampleCount = depthStencilAttachmentInfo.Texture.SampleCount; | 			depthStencilAttachmentSampleCount = depthStencilAttachmentInfo.TextureSlice.Texture.SampleCount; | ||||||
| 			colorFormatOne = colorAttachmentInfo.Texture.Format; | 			colorFormatOne = colorAttachmentInfo.TextureSlice.Texture.Format; | ||||||
| 			depthStencilFormat = depthStencilAttachmentInfo.Texture.Format; | 			depthStencilFormat = depthStencilAttachmentInfo.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -420,8 +420,8 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertTextureNotNull(colorAttachmentInfoTwo); | 			AssertTextureNotNull(colorAttachmentInfoTwo); | ||||||
| 			AssertColorTarget(colorAttachmentInfoTwo); | 			AssertColorTarget(colorAttachmentInfoTwo); | ||||||
| 
 | 
 | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoTwo.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, depthStencilAttachmentInfo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, depthStencilAttachmentInfo.TextureSlice.Texture); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2]; | 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[2]; | ||||||
|  | @ -441,11 +441,11 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = true; | 			hasDepthStencilAttachment = true; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfoOne.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 2; | 			colorAttachmentCount = 2; | ||||||
| 			colorFormatOne = colorAttachmentInfoOne.Texture.Format; | 			colorFormatOne = colorAttachmentInfoOne.TextureSlice.Texture.Format; | ||||||
| 			colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; | 			colorFormatTwo = colorAttachmentInfoTwo.TextureSlice.Texture.Format; | ||||||
| 			depthStencilFormat = depthStencilAttachmentInfo.Texture.Format; | 			depthStencilFormat = depthStencilAttachmentInfo.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -477,9 +477,9 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertTextureNotNull(colorAttachmentInfoThree); | 			AssertTextureNotNull(colorAttachmentInfoThree); | ||||||
| 			AssertColorTarget(colorAttachmentInfoThree); | 			AssertColorTarget(colorAttachmentInfoThree); | ||||||
| 
 | 
 | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoTwo.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoTwo.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, depthStencilAttachmentInfo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, depthStencilAttachmentInfo.TextureSlice.Texture); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3]; | 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[3]; | ||||||
|  | @ -500,12 +500,12 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = true; | 			hasDepthStencilAttachment = true; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfoOne.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 3; | 			colorAttachmentCount = 3; | ||||||
| 			colorFormatOne = colorAttachmentInfoOne.Texture.Format; | 			colorFormatOne = colorAttachmentInfoOne.TextureSlice.Texture.Format; | ||||||
| 			colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; | 			colorFormatTwo = colorAttachmentInfoTwo.TextureSlice.Texture.Format; | ||||||
| 			colorFormatThree = colorAttachmentInfoThree.Texture.Format; | 			colorFormatThree = colorAttachmentInfoThree.TextureSlice.Texture.Format; | ||||||
| 			depthStencilFormat = depthStencilAttachmentInfo.Texture.Format; | 			depthStencilFormat = depthStencilAttachmentInfo.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -542,10 +542,10 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertTextureNotNull(colorAttachmentInfoFour); | 			AssertTextureNotNull(colorAttachmentInfoFour); | ||||||
| 			AssertColorTarget(colorAttachmentInfoFour); | 			AssertColorTarget(colorAttachmentInfoFour); | ||||||
| 
 | 
 | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoTwo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoTwo.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoThree.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoThree.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, colorAttachmentInfoFour.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, colorAttachmentInfoFour.TextureSlice.Texture); | ||||||
| 			AssertSameSampleCount(colorAttachmentInfoOne.Texture, depthStencilAttachmentInfo.Texture); | 			AssertSameSampleCount(colorAttachmentInfoOne.TextureSlice.Texture, depthStencilAttachmentInfo.TextureSlice.Texture); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4]; | 			var refreshColorAttachmentInfos = stackalloc Refresh.ColorAttachmentInfo[4]; | ||||||
|  | @ -567,13 +567,13 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			renderPassActive = true; | 			renderPassActive = true; | ||||||
| 			hasDepthStencilAttachment = true; | 			hasDepthStencilAttachment = true; | ||||||
| 			colorAttachmentSampleCount = colorAttachmentInfoOne.Texture.SampleCount; | 			colorAttachmentSampleCount = colorAttachmentInfoOne.TextureSlice.Texture.SampleCount; | ||||||
| 			colorAttachmentCount = 4; | 			colorAttachmentCount = 4; | ||||||
| 			colorFormatOne = colorAttachmentInfoOne.Texture.Format; | 			colorFormatOne = colorAttachmentInfoOne.TextureSlice.Texture.Format; | ||||||
| 			colorFormatTwo = colorAttachmentInfoTwo.Texture.Format; | 			colorFormatTwo = colorAttachmentInfoTwo.TextureSlice.Texture.Format; | ||||||
| 			colorFormatThree = colorAttachmentInfoThree.Texture.Format; | 			colorFormatThree = colorAttachmentInfoThree.TextureSlice.Texture.Format; | ||||||
| 			colorFormatFour = colorAttachmentInfoFour.Texture.Format; | 			colorFormatFour = colorAttachmentInfoFour.TextureSlice.Texture.Format; | ||||||
| 			depthStencilFormat = depthStencilAttachmentInfo.Texture.Format; | 			depthStencilFormat = depthStencilAttachmentInfo.TextureSlice.Texture.Format; | ||||||
| #endif | #endif | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -1662,9 +1662,9 @@ namespace MoonWorks.Graphics | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Binds a texture to be used in the compute shader. | 		/// Binds a texture to be used in the compute shader. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="binding">A texture-level pair to bind.</param> | 		/// <param name="slice">A texture slice to bind.</param> | ||||||
| 		public unsafe void BindComputeTextures( | 		public unsafe void BindComputeTextures( | ||||||
| 			TextureLevelBinding binding | 			TextureSlice slice | ||||||
| 		) { | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
|  | @ -1673,28 +1673,24 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertComputeTextureCount(1); | 			AssertComputeTextureCount(1); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var texturePtrs = stackalloc IntPtr[1]; | 			var textureSlicePtrs = stackalloc Refresh.TextureSlice[1]; | ||||||
| 			texturePtrs[0] = binding.Texture.Handle; | 			textureSlicePtrs[0] = slice.ToRefreshTextureSlice(); | ||||||
| 
 |  | ||||||
| 			var mipLevels = stackalloc uint[1]; |  | ||||||
| 			mipLevels[0] = binding.MipLevel; |  | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_BindComputeTextures( | 			Refresh.Refresh_BindComputeTextures( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				(IntPtr) texturePtrs, | 				(IntPtr) textureSlicePtrs | ||||||
| 				(IntPtr) mipLevels |  | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Binds textures to be used in the compute shader. | 		/// Binds textures to be used in the compute shader. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="bindingOne">A texture-level pair to bind.</param> | 		/// <param name="sliceOne">A texture-level pair to bind.</param> | ||||||
| 		/// <param name="bindingTwo">A texture-level pair to bind.</param> | 		/// <param name="sliceTwo">A texture-level pair to bind.</param> | ||||||
| 		public unsafe void BindComputeTextures( | 		public unsafe void BindComputeTextures( | ||||||
| 			TextureLevelBinding bindingOne, | 			TextureSlice sliceOne, | ||||||
| 			TextureLevelBinding bindingTwo | 			TextureSlice sliceTwo | ||||||
| 		) { | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
|  | @ -1703,32 +1699,27 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertComputeTextureCount(2); | 			AssertComputeTextureCount(2); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var texturePtrs = stackalloc IntPtr[2]; | 			var textureSlicePtrs = stackalloc Refresh.TextureSlice[2]; | ||||||
| 			texturePtrs[0] = bindingOne.Texture.Handle; | 			textureSlicePtrs[0] = sliceOne.ToRefreshTextureSlice(); | ||||||
| 			texturePtrs[1] = bindingTwo.Texture.Handle; | 			textureSlicePtrs[1] = sliceTwo.ToRefreshTextureSlice(); | ||||||
| 
 |  | ||||||
| 			var mipLevels = stackalloc uint[2]; |  | ||||||
| 			mipLevels[0] = bindingOne.MipLevel; |  | ||||||
| 			mipLevels[1] = bindingTwo.MipLevel; |  | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_BindComputeTextures( | 			Refresh.Refresh_BindComputeTextures( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				(IntPtr) texturePtrs, | 				(IntPtr) textureSlicePtrs | ||||||
| 				(IntPtr) mipLevels |  | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Binds textures to be used in the compute shader. | 		/// Binds textures to be used in the compute shader. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="bindingOne">A texture-level pair to bind.</param> | 		/// <param name="sliceOne">A texture-level pair to bind.</param> | ||||||
| 		/// <param name="bindingTwo">A texture-level pair to bind.</param> | 		/// <param name="sliceTwo">A texture-level pair to bind.</param> | ||||||
| 		/// <param name="bindingThree">A texture-level pair to bind.</param> | 		/// <param name="sliceThree">A texture-level pair to bind.</param> | ||||||
| 		public unsafe void BindComputeTextures( | 		public unsafe void BindComputeTextures( | ||||||
| 			TextureLevelBinding bindingOne, | 			TextureSlice sliceOne, | ||||||
| 			TextureLevelBinding bindingTwo, | 			TextureSlice sliceTwo, | ||||||
| 			TextureLevelBinding bindingThree | 			TextureSlice sliceThree | ||||||
| 		) { | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
|  | @ -1737,36 +1728,30 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertComputeTextureCount(3); | 			AssertComputeTextureCount(3); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var texturePtrs = stackalloc IntPtr[3]; | 			var textureSlicePtrs = stackalloc Refresh.TextureSlice[3]; | ||||||
| 			texturePtrs[0] = bindingOne.Texture.Handle; | 			textureSlicePtrs[0] = sliceOne.ToRefreshTextureSlice(); | ||||||
| 			texturePtrs[1] = bindingTwo.Texture.Handle; | 			textureSlicePtrs[1] = sliceTwo.ToRefreshTextureSlice(); | ||||||
| 			texturePtrs[2] = bindingThree.Texture.Handle; | 			textureSlicePtrs[2] = sliceThree.ToRefreshTextureSlice(); | ||||||
| 
 |  | ||||||
| 			var mipLevels = stackalloc uint[3]; |  | ||||||
| 			mipLevels[0] = bindingOne.MipLevel; |  | ||||||
| 			mipLevels[1] = bindingTwo.MipLevel; |  | ||||||
| 			mipLevels[2] = bindingThree.MipLevel; |  | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_BindComputeTextures( | 			Refresh.Refresh_BindComputeTextures( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				(IntPtr) texturePtrs, | 				(IntPtr) textureSlicePtrs | ||||||
| 				(IntPtr) mipLevels |  | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Binds textures to be used in the compute shader. | 		/// Binds textures to be used in the compute shader. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="bindingOne">A texture-level pair to bind.</param> | 		/// <param name="sliceOne">A texture-level pair to bind.</param> | ||||||
| 		/// <param name="bindingTwo">A texture-level pair to bind.</param> | 		/// <param name="sliceTwo">A texture-level pair to bind.</param> | ||||||
| 		/// <param name="bindingThree">A texture-level pair to bind.</param> | 		/// <param name="sliceThree">A texture-level pair to bind.</param> | ||||||
| 		/// <param name="bindingFour">A texture-level pair to bind.</param> | 		/// <param name="sliceFour">A texture-level pair to bind.</param> | ||||||
| 		public unsafe void BindComputeTextures( | 		public unsafe void BindComputeTextures( | ||||||
| 			TextureLevelBinding bindingOne, | 			TextureSlice sliceOne, | ||||||
| 			TextureLevelBinding bindingTwo, | 			TextureSlice sliceTwo, | ||||||
| 			TextureLevelBinding bindingThree, | 			TextureSlice sliceThree, | ||||||
| 			TextureLevelBinding bindingFour | 			TextureSlice sliceFour | ||||||
| 		) { | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
|  | @ -1775,55 +1760,49 @@ namespace MoonWorks.Graphics | ||||||
| 			AssertComputeTextureCount(4); | 			AssertComputeTextureCount(4); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var texturePtrs = stackalloc IntPtr[4]; | 			var textureSlicePtrs = stackalloc Refresh.TextureSlice[4]; | ||||||
| 			texturePtrs[0] = bindingOne.Texture.Handle; | 			textureSlicePtrs[0] = sliceOne.ToRefreshTextureSlice(); | ||||||
| 			texturePtrs[1] = bindingTwo.Texture.Handle; | 			textureSlicePtrs[1] = sliceTwo.ToRefreshTextureSlice(); | ||||||
| 			texturePtrs[2] = bindingThree.Texture.Handle; | 			textureSlicePtrs[2] = sliceThree.ToRefreshTextureSlice(); | ||||||
| 			texturePtrs[3] = bindingFour.Texture.Handle; | 			textureSlicePtrs[3] = sliceFour.ToRefreshTextureSlice(); | ||||||
| 
 |  | ||||||
| 			var mipLevels = stackalloc uint[4]; |  | ||||||
| 			mipLevels[0] = bindingOne.MipLevel; |  | ||||||
| 			mipLevels[1] = bindingTwo.MipLevel; |  | ||||||
| 			mipLevels[2] = bindingThree.MipLevel; |  | ||||||
| 			mipLevels[3] = bindingFour.MipLevel; |  | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_BindComputeTextures( | 			Refresh.Refresh_BindComputeTextures( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				(IntPtr) texturePtrs, | 				(IntPtr) textureSlicePtrs | ||||||
| 				(IntPtr) mipLevels |  | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Binds textures to be used in the compute shader. | 		/// Binds textures to be used in the compute shader. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="bindings">A set of texture-level pairs to bind.</param> | 		/// <param name="slices">A set of texture-level pairs to bind.</param> | ||||||
| 		public unsafe void BindComputeTextures( | 		public unsafe void BindComputeTextures( | ||||||
| 			in Span<TextureLevelBinding> bindings | 			in Span<TextureSlice> slices | ||||||
| 		) { | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
| 			AssertInComputePass("Cannot bind compute textures outside of compute pass!"); | 			AssertInComputePass("Cannot bind compute textures outside of compute pass!"); | ||||||
| 			AssertComputePipelineBound(); | 			AssertComputePipelineBound(); | ||||||
| 			AssertComputeTextureCount(bindings.Length); | 			AssertComputeTextureCount(slices.Length); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			var texturePtrs = stackalloc IntPtr[bindings.Length]; | 			Refresh.TextureSlice* textureSlicePtrs = (Refresh.TextureSlice*) NativeMemory.Alloc( | ||||||
| 			var mipLevels = stackalloc uint[bindings.Length]; | 				(nuint) (Marshal.SizeOf<Refresh.TextureSlice>() * slices.Length) | ||||||
|  | 			); | ||||||
| 
 | 
 | ||||||
| 			for (var i = 0; i < bindings.Length; i += 1) | 			for (var i = 0; i < slices.Length; i += 1) | ||||||
| 			{ | 			{ | ||||||
| 				texturePtrs[i] = bindings[i].Texture.Handle; | 				textureSlicePtrs[i] = slices[i].ToRefreshTextureSlice(); | ||||||
| 				mipLevels[i] = bindings[i].MipLevel; |  | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_BindComputeTextures( | 			Refresh.Refresh_BindComputeTextures( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				(IntPtr) texturePtrs, | 				(IntPtr) textureSlicePtrs | ||||||
| 				(IntPtr) mipLevels |  | ||||||
| 			); | 			); | ||||||
|  | 
 | ||||||
|  | 			NativeMemory.Free(textureSlicePtrs); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
|  | @ -1948,7 +1927,7 @@ namespace MoonWorks.Graphics | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		public void UploadToTexture( | 		public void UploadToTexture( | ||||||
| 			TransferBuffer transferBuffer, | 			TransferBuffer transferBuffer, | ||||||
| 			in TextureSlice textureSlice, | 			in TextureRegion textureRegion, | ||||||
| 			in BufferImageCopy copyParams, | 			in BufferImageCopy copyParams, | ||||||
| 			CopyOptions option | 			CopyOptions option | ||||||
| 		) | 		) | ||||||
|  | @ -1956,14 +1935,14 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
| 			AssertInCopyPass("Cannot upload to texture outside of copy pass!"); | 			AssertInCopyPass("Cannot upload to texture outside of copy pass!"); | ||||||
| 			AssertBufferBoundsCheck(transferBuffer.Size, copyParams.BufferOffset, textureSlice.Size); | 			AssertBufferBoundsCheck(transferBuffer.Size, copyParams.BufferOffset, textureRegion.Size); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_UploadToTexture( | 			Refresh.Refresh_UploadToTexture( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				transferBuffer.Handle, | 				transferBuffer.Handle, | ||||||
| 				textureSlice.ToRefreshTextureSlice(), | 				textureRegion.ToRefreshTextureRegion(), | ||||||
| 				copyParams.ToRefresh(), | 				copyParams.ToRefresh(), | ||||||
| 				(Refresh.CopyOptions) option | 				(Refresh.CopyOptions) option | ||||||
| 			); | 			); | ||||||
|  | @ -1979,7 +1958,7 @@ namespace MoonWorks.Graphics | ||||||
| 		) { | 		) { | ||||||
| 			UploadToTexture( | 			UploadToTexture( | ||||||
| 				transferBuffer, | 				transferBuffer, | ||||||
| 				new TextureSlice(texture), | 				new TextureRegion(texture), | ||||||
| 				new BufferImageCopy(0, 0, 0), | 				new BufferImageCopy(0, 0, 0), | ||||||
| 				option | 				option | ||||||
| 			); | 			); | ||||||
|  | @ -2070,7 +2049,7 @@ namespace MoonWorks.Graphics | ||||||
| 		/// fully copied until the command buffer has finished execution. | 		/// fully copied until the command buffer has finished execution. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		public void DownloadFromTexture( | 		public void DownloadFromTexture( | ||||||
| 			in TextureSlice textureSlice, | 			in TextureRegion textureRegion, | ||||||
| 			TransferBuffer transferBuffer, | 			TransferBuffer transferBuffer, | ||||||
| 			in BufferImageCopy copyParams, | 			in BufferImageCopy copyParams, | ||||||
| 			TransferOptions option | 			TransferOptions option | ||||||
|  | @ -2078,13 +2057,13 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
| 			AssertInCopyPass("Cannot download from texture outside of copy pass!"); | 			AssertInCopyPass("Cannot download from texture outside of copy pass!"); | ||||||
| 			AssertBufferBoundsCheck(transferBuffer.Size, copyParams.BufferOffset, textureSlice.Size); | 			AssertBufferBoundsCheck(transferBuffer.Size, copyParams.BufferOffset, textureRegion.Size); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_DownloadFromTexture( | 			Refresh.Refresh_DownloadFromTexture( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				textureSlice.ToRefreshTextureSlice(), | 				textureRegion.ToRefreshTextureRegion(), | ||||||
| 				transferBuffer.Handle, | 				transferBuffer.Handle, | ||||||
| 				copyParams.ToRefresh(), | 				copyParams.ToRefresh(), | ||||||
| 				(Refresh.TransferOptions) option | 				(Refresh.TransferOptions) option | ||||||
|  | @ -2100,7 +2079,7 @@ namespace MoonWorks.Graphics | ||||||
| 			TransferOptions option | 			TransferOptions option | ||||||
| 		) { | 		) { | ||||||
| 			DownloadFromTexture( | 			DownloadFromTexture( | ||||||
| 				new TextureSlice(texture), | 				new TextureRegion(texture), | ||||||
| 				transferBuffer, | 				transferBuffer, | ||||||
| 				new BufferImageCopy(0, 0, 0), | 				new BufferImageCopy(0, 0, 0), | ||||||
| 				option | 				option | ||||||
|  | @ -2164,8 +2143,8 @@ namespace MoonWorks.Graphics | ||||||
| 		/// You MAY assume that the copy has finished in subsequent commands. | 		/// You MAY assume that the copy has finished in subsequent commands. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		public void CopyTextureToTexture( | 		public void CopyTextureToTexture( | ||||||
| 			in TextureSlice source, | 			in TextureRegion source, | ||||||
| 			in TextureSlice destination, | 			in TextureRegion destination, | ||||||
| 			CopyOptions option | 			CopyOptions option | ||||||
| 		) { | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
|  | @ -2177,8 +2156,8 @@ namespace MoonWorks.Graphics | ||||||
| 			Refresh.Refresh_CopyTextureToTexture( | 			Refresh.Refresh_CopyTextureToTexture( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				source.ToRefreshTextureSlice(), | 				source.ToRefreshTextureRegion(), | ||||||
| 				destination.ToRefreshTextureSlice(), | 				destination.ToRefreshTextureRegion(), | ||||||
| 				(Refresh.CopyOptions) option | 				(Refresh.CopyOptions) option | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
|  | @ -2193,8 +2172,8 @@ namespace MoonWorks.Graphics | ||||||
| 			CopyOptions option | 			CopyOptions option | ||||||
| 		) { | 		) { | ||||||
| 			CopyTextureToTexture( | 			CopyTextureToTexture( | ||||||
| 				new TextureSlice(source), | 				new TextureRegion(source), | ||||||
| 				new TextureSlice(destination), | 				new TextureRegion(destination), | ||||||
| 				option | 				option | ||||||
| 			); | 			); | ||||||
| 		} | 		} | ||||||
|  | @ -2206,7 +2185,7 @@ namespace MoonWorks.Graphics | ||||||
| 		/// You MAY assume that the copy has finished in subsequent commands. | 		/// You MAY assume that the copy has finished in subsequent commands. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		public void CopyTextureToBuffer( | 		public void CopyTextureToBuffer( | ||||||
| 			in TextureSlice textureSlice, | 			in TextureRegion textureRegion, | ||||||
| 			GpuBuffer buffer, | 			GpuBuffer buffer, | ||||||
| 			in BufferImageCopy copyParams, | 			in BufferImageCopy copyParams, | ||||||
| 			CopyOptions option | 			CopyOptions option | ||||||
|  | @ -2214,13 +2193,13 @@ namespace MoonWorks.Graphics | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
| 			AssertInCopyPass("Cannot download from texture outside of copy pass!"); | 			AssertInCopyPass("Cannot download from texture outside of copy pass!"); | ||||||
| 			AssertBufferBoundsCheck(buffer.Size, copyParams.BufferOffset, textureSlice.Size); | 			AssertBufferBoundsCheck(buffer.Size, copyParams.BufferOffset, textureRegion.Size); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_CopyTextureToBuffer( | 			Refresh.Refresh_CopyTextureToBuffer( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				textureSlice.ToRefreshTextureSlice(), | 				textureRegion.ToRefreshTextureRegion(), | ||||||
| 				buffer.Handle, | 				buffer.Handle, | ||||||
| 				copyParams.ToRefresh(), | 				copyParams.ToRefresh(), | ||||||
| 				(Refresh.CopyOptions) option | 				(Refresh.CopyOptions) option | ||||||
|  | @ -2236,7 +2215,7 @@ namespace MoonWorks.Graphics | ||||||
| 			CopyOptions option | 			CopyOptions option | ||||||
| 		) { | 		) { | ||||||
| 			CopyTextureToBuffer( | 			CopyTextureToBuffer( | ||||||
| 				new TextureSlice(texture), | 				new TextureRegion(texture), | ||||||
| 				buffer, | 				buffer, | ||||||
| 				new BufferImageCopy(0, 0, 0), | 				new BufferImageCopy(0, 0, 0), | ||||||
| 				option | 				option | ||||||
|  | @ -2251,21 +2230,21 @@ namespace MoonWorks.Graphics | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		public void CopyBufferToTexture( | 		public void CopyBufferToTexture( | ||||||
| 			GpuBuffer gpuBuffer, | 			GpuBuffer gpuBuffer, | ||||||
| 			in TextureSlice textureSlice, | 			in TextureRegion textureRegion, | ||||||
| 			in BufferImageCopy copyParams, | 			in BufferImageCopy copyParams, | ||||||
| 			CopyOptions option | 			CopyOptions option | ||||||
| 		) { | 		) { | ||||||
| #if DEBUG | #if DEBUG | ||||||
| 			AssertNotSubmitted(); | 			AssertNotSubmitted(); | ||||||
| 			AssertInCopyPass("Cannot download from texture outside of copy pass!"); | 			AssertInCopyPass("Cannot download from texture outside of copy pass!"); | ||||||
| 			AssertBufferBoundsCheck(gpuBuffer.Size, copyParams.BufferOffset, textureSlice.Size); | 			AssertBufferBoundsCheck(gpuBuffer.Size, copyParams.BufferOffset, textureRegion.Size); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 			Refresh.Refresh_CopyBufferToTexture( | 			Refresh.Refresh_CopyBufferToTexture( | ||||||
| 				Device.Handle, | 				Device.Handle, | ||||||
| 				Handle, | 				Handle, | ||||||
| 				gpuBuffer.Handle, | 				gpuBuffer.Handle, | ||||||
| 				textureSlice.ToRefreshTextureSlice(), | 				textureRegion.ToRefreshTextureRegion(), | ||||||
| 				copyParams.ToRefresh(), | 				copyParams.ToRefresh(), | ||||||
| 				(Refresh.CopyOptions) option | 				(Refresh.CopyOptions) option | ||||||
| 			); | 			); | ||||||
|  | @ -2281,7 +2260,7 @@ namespace MoonWorks.Graphics | ||||||
| 		) { | 		) { | ||||||
| 			CopyBufferToTexture( | 			CopyBufferToTexture( | ||||||
| 				buffer, | 				buffer, | ||||||
| 				new TextureSlice(texture), | 				new TextureRegion(texture), | ||||||
| 				new BufferImageCopy(0, 0, 0), | 				new BufferImageCopy(0, 0, 0), | ||||||
| 				option | 				option | ||||||
| 			); | 			); | ||||||
|  | @ -2458,7 +2437,7 @@ namespace MoonWorks.Graphics | ||||||
| 
 | 
 | ||||||
| 		private void AssertTextureNotNull(ColorAttachmentInfo colorAttachmentInfo) | 		private void AssertTextureNotNull(ColorAttachmentInfo colorAttachmentInfo) | ||||||
| 		{ | 		{ | ||||||
| 			if (colorAttachmentInfo.Texture == null || colorAttachmentInfo.Texture.Handle == IntPtr.Zero) | 			if (colorAttachmentInfo.TextureSlice.Texture == null || colorAttachmentInfo.TextureSlice.Texture.Handle == IntPtr.Zero) | ||||||
| 			{ | 			{ | ||||||
| 				throw new System.ArgumentException("Render pass color attachment Texture cannot be null!"); | 				throw new System.ArgumentException("Render pass color attachment Texture cannot be null!"); | ||||||
| 			} | 			} | ||||||
|  | @ -2466,7 +2445,7 @@ namespace MoonWorks.Graphics | ||||||
| 
 | 
 | ||||||
| 		private void AssertColorTarget(ColorAttachmentInfo colorAttachmentInfo) | 		private void AssertColorTarget(ColorAttachmentInfo colorAttachmentInfo) | ||||||
| 		{ | 		{ | ||||||
| 			if ((colorAttachmentInfo.Texture.UsageFlags & TextureUsageFlags.ColorTarget) == 0) | 			if ((colorAttachmentInfo.TextureSlice.Texture.UsageFlags & TextureUsageFlags.ColorTarget) == 0) | ||||||
| 			{ | 			{ | ||||||
| 				throw new System.ArgumentException("Render pass color attachment UsageFlags must include TextureUsageFlags.ColorTarget!"); | 				throw new System.ArgumentException("Render pass color attachment UsageFlags must include TextureUsageFlags.ColorTarget!"); | ||||||
| 			} | 			} | ||||||
|  | @ -2482,13 +2461,13 @@ namespace MoonWorks.Graphics | ||||||
| 
 | 
 | ||||||
| 		private void AssertValidDepthAttachment(DepthStencilAttachmentInfo depthStencilAttachmentInfo) | 		private void AssertValidDepthAttachment(DepthStencilAttachmentInfo depthStencilAttachmentInfo) | ||||||
| 		{ | 		{ | ||||||
| 			if (depthStencilAttachmentInfo.Texture == null || | 			if (depthStencilAttachmentInfo.TextureSlice.Texture == null || | ||||||
| 				depthStencilAttachmentInfo.Texture.Handle == IntPtr.Zero) | 				depthStencilAttachmentInfo.TextureSlice.Texture.Handle == IntPtr.Zero) | ||||||
| 			{ | 			{ | ||||||
| 				throw new System.ArgumentException("Render pass depth stencil attachment Texture cannot be null!"); | 				throw new System.ArgumentException("Render pass depth stencil attachment Texture cannot be null!"); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if ((depthStencilAttachmentInfo.Texture.UsageFlags & TextureUsageFlags.DepthStencilTarget) == 0) | 			if ((depthStencilAttachmentInfo.TextureSlice.Texture.UsageFlags & TextureUsageFlags.DepthStencilTarget) == 0) | ||||||
| 			{ | 			{ | ||||||
| 				throw new System.ArgumentException("Render pass depth stencil attachment UsageFlags must include TextureUsageFlags.DepthStencilTarget!"); | 				throw new System.ArgumentException("Render pass depth stencil attachment UsageFlags must include TextureUsageFlags.DepthStencilTarget!"); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -174,40 +174,33 @@ namespace MoonWorks.Graphics | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	[StructLayout(LayoutKind.Sequential)] |  | ||||||
| 	public struct ColorAttachmentInfo | 	public struct ColorAttachmentInfo | ||||||
| 	{ | 	{ | ||||||
| 		public Texture Texture; | 		public TextureSlice TextureSlice; | ||||||
| 		public uint Depth; |  | ||||||
| 		public uint Layer; |  | ||||||
| 		public uint Level; |  | ||||||
| 		public Color ClearColor; | 		public Color ClearColor; | ||||||
| 		public LoadOp LoadOp; | 		public LoadOp LoadOp; | ||||||
| 		public StoreOp StoreOp; | 		public StoreOp StoreOp; | ||||||
|  | 		public bool SafeDiscard; | ||||||
| 
 | 
 | ||||||
| 		public ColorAttachmentInfo( | 		public ColorAttachmentInfo( | ||||||
| 			Texture texture, | 			TextureSlice textureSlice, | ||||||
| 			Color clearColor, | 			Color clearColor, | ||||||
|  | 			bool safeDiscard = true, | ||||||
| 			StoreOp storeOp = StoreOp.Store | 			StoreOp storeOp = StoreOp.Store | ||||||
| 		) { | 		) { | ||||||
| 			Texture = texture; | 			TextureSlice = textureSlice; | ||||||
| 			Depth = 0; |  | ||||||
| 			Layer = 0; |  | ||||||
| 			Level = 0; |  | ||||||
| 			ClearColor = clearColor; | 			ClearColor = clearColor; | ||||||
| 			LoadOp = LoadOp.Clear; | 			LoadOp = LoadOp.Clear; | ||||||
| 			StoreOp = storeOp; | 			StoreOp = storeOp; | ||||||
|  | 			SafeDiscard = safeDiscard; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public ColorAttachmentInfo( | 		public ColorAttachmentInfo( | ||||||
| 			Texture texture, | 			TextureSlice textureSlice, | ||||||
| 			LoadOp loadOp = LoadOp.DontCare, | 			LoadOp loadOp = LoadOp.DontCare, | ||||||
| 			StoreOp storeOp = StoreOp.Store | 			StoreOp storeOp = StoreOp.Store | ||||||
| 		) { | 		) { | ||||||
| 			Texture = texture; | 			TextureSlice = textureSlice; | ||||||
| 			Depth = 0; |  | ||||||
| 			Layer = 0; |  | ||||||
| 			Level = 0; |  | ||||||
| 			ClearColor = Color.White; | 			ClearColor = Color.White; | ||||||
| 			LoadOp = loadOp; | 			LoadOp = loadOp; | ||||||
| 			StoreOp = storeOp; | 			StoreOp = storeOp; | ||||||
|  | @ -217,10 +210,7 @@ namespace MoonWorks.Graphics | ||||||
| 		{ | 		{ | ||||||
| 			return new Refresh.ColorAttachmentInfo | 			return new Refresh.ColorAttachmentInfo | ||||||
| 			{ | 			{ | ||||||
| 				texture = Texture.Handle, | 				textureSlice = TextureSlice.ToRefreshTextureSlice(), | ||||||
| 				depth = Depth, |  | ||||||
| 				layer = Layer, |  | ||||||
| 				level = Level, |  | ||||||
| 				clearColor = new Refresh.Vec4 | 				clearColor = new Refresh.Vec4 | ||||||
| 				{ | 				{ | ||||||
| 					x = ClearColor.R / 255f, | 					x = ClearColor.R / 255f, | ||||||
|  | @ -229,53 +219,46 @@ namespace MoonWorks.Graphics | ||||||
| 					w = ClearColor.A / 255f | 					w = ClearColor.A / 255f | ||||||
| 				}, | 				}, | ||||||
| 				loadOp = (Refresh.LoadOp) LoadOp, | 				loadOp = (Refresh.LoadOp) LoadOp, | ||||||
| 				storeOp = (Refresh.StoreOp) StoreOp | 				storeOp = (Refresh.StoreOp) StoreOp, | ||||||
|  | 				safeDiscard = Conversions.BoolToByte(SafeDiscard) | ||||||
| 			}; | 			}; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	[StructLayout(LayoutKind.Sequential)] |  | ||||||
| 	public struct DepthStencilAttachmentInfo | 	public struct DepthStencilAttachmentInfo | ||||||
| 	{ | 	{ | ||||||
| 		public Texture Texture; | 		public TextureSlice TextureSlice; | ||||||
| 		public uint Depth; |  | ||||||
| 		public uint Layer; |  | ||||||
| 		public uint Level; |  | ||||||
| 		public DepthStencilValue DepthStencilClearValue; | 		public DepthStencilValue DepthStencilClearValue; | ||||||
| 		public LoadOp LoadOp; | 		public LoadOp LoadOp; | ||||||
| 		public StoreOp StoreOp; | 		public StoreOp StoreOp; | ||||||
| 		public LoadOp StencilLoadOp; | 		public LoadOp StencilLoadOp; | ||||||
| 		public StoreOp StencilStoreOp; | 		public StoreOp StencilStoreOp; | ||||||
|  | 		public bool SafeDiscard; | ||||||
| 
 | 
 | ||||||
| 		public DepthStencilAttachmentInfo( | 		public DepthStencilAttachmentInfo( | ||||||
| 			Texture texture, | 			TextureSlice textureSlice, | ||||||
| 			DepthStencilValue clearValue, | 			DepthStencilValue clearValue, | ||||||
|  | 			bool safeDiscard = true, | ||||||
| 			StoreOp depthStoreOp = StoreOp.Store, | 			StoreOp depthStoreOp = StoreOp.Store, | ||||||
| 			StoreOp stencilStoreOp = StoreOp.Store | 			StoreOp stencilStoreOp = StoreOp.Store | ||||||
| 		) | 		){ | ||||||
| 		{ | 			TextureSlice = textureSlice; | ||||||
| 			Texture = texture; |  | ||||||
| 			Depth = 0; |  | ||||||
| 			Layer = 0; |  | ||||||
| 			Level = 0; |  | ||||||
| 			DepthStencilClearValue = clearValue; | 			DepthStencilClearValue = clearValue; | ||||||
| 			LoadOp = LoadOp.Clear; | 			LoadOp = LoadOp.Clear; | ||||||
| 			StoreOp = depthStoreOp; | 			StoreOp = depthStoreOp; | ||||||
| 			StencilLoadOp = LoadOp.Clear; | 			StencilLoadOp = LoadOp.Clear; | ||||||
| 			StencilStoreOp = stencilStoreOp; | 			StencilStoreOp = stencilStoreOp; | ||||||
|  | 			SafeDiscard = safeDiscard; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public DepthStencilAttachmentInfo( | 		public DepthStencilAttachmentInfo( | ||||||
| 			Texture texture, | 			TextureSlice textureSlice, | ||||||
| 			LoadOp loadOp = LoadOp.DontCare, | 			LoadOp loadOp = LoadOp.DontCare, | ||||||
| 			StoreOp storeOp = StoreOp.Store, | 			StoreOp storeOp = StoreOp.Store, | ||||||
| 			LoadOp stencilLoadOp = LoadOp.DontCare, | 			LoadOp stencilLoadOp = LoadOp.DontCare, | ||||||
| 			StoreOp stencilStoreOp = StoreOp.Store | 			StoreOp stencilStoreOp = StoreOp.Store | ||||||
| 		) { | 		) { | ||||||
| 			Texture = texture; | 			TextureSlice = textureSlice; | ||||||
| 			Depth = 0; |  | ||||||
| 			Layer = 0; |  | ||||||
| 			Level = 0; |  | ||||||
| 			DepthStencilClearValue = new DepthStencilValue(); | 			DepthStencilClearValue = new DepthStencilValue(); | ||||||
| 			LoadOp = loadOp; | 			LoadOp = loadOp; | ||||||
| 			StoreOp = storeOp; | 			StoreOp = storeOp; | ||||||
|  | @ -283,38 +266,17 @@ namespace MoonWorks.Graphics | ||||||
| 			StencilStoreOp = stencilStoreOp; | 			StencilStoreOp = stencilStoreOp; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public DepthStencilAttachmentInfo( |  | ||||||
| 			Texture texture, |  | ||||||
| 			DepthStencilValue depthStencilValue, |  | ||||||
| 			LoadOp loadOp, |  | ||||||
| 			StoreOp storeOp, |  | ||||||
| 			LoadOp stencilLoadOp, |  | ||||||
| 			StoreOp stencilStoreOp |  | ||||||
| 		) { |  | ||||||
| 			Texture = texture; |  | ||||||
| 			Depth = 0; |  | ||||||
| 			Layer = 0; |  | ||||||
| 			Level = 0; |  | ||||||
| 			DepthStencilClearValue = depthStencilValue; |  | ||||||
| 			LoadOp = loadOp; |  | ||||||
| 			StoreOp = storeOp; |  | ||||||
| 			StencilLoadOp = stencilLoadOp; |  | ||||||
| 			StencilStoreOp = stencilStoreOp; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		public Refresh.DepthStencilAttachmentInfo ToRefresh() | 		public Refresh.DepthStencilAttachmentInfo ToRefresh() | ||||||
| 		{ | 		{ | ||||||
| 			return new Refresh.DepthStencilAttachmentInfo | 			return new Refresh.DepthStencilAttachmentInfo | ||||||
| 			{ | 			{ | ||||||
| 				texture = Texture.Handle, | 				textureSlice = TextureSlice.ToRefreshTextureSlice(), | ||||||
| 				depth = Depth, |  | ||||||
| 				layer = Layer, |  | ||||||
| 				level = Level, |  | ||||||
| 				depthStencilClearValue = DepthStencilClearValue.ToRefresh(), | 				depthStencilClearValue = DepthStencilClearValue.ToRefresh(), | ||||||
| 				loadOp = (Refresh.LoadOp) LoadOp, | 				loadOp = (Refresh.LoadOp) LoadOp, | ||||||
| 				storeOp = (Refresh.StoreOp) StoreOp, | 				storeOp = (Refresh.StoreOp) StoreOp, | ||||||
| 				stencilLoadOp = (Refresh.LoadOp) StencilLoadOp, | 				stencilLoadOp = (Refresh.LoadOp) StencilLoadOp, | ||||||
| 				stencilStoreOp = (Refresh.StoreOp) StencilStoreOp | 				stencilStoreOp = (Refresh.StoreOp) StencilStoreOp, | ||||||
|  | 				safeDiscard = Conversions.BoolToByte(SafeDiscard) | ||||||
| 			}; | 			}; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ namespace MoonWorks.Graphics | ||||||
| 		uint dataSize = 1024; | 		uint dataSize = 1024; | ||||||
| 
 | 
 | ||||||
| 		List<(GpuBuffer, BufferCopy, CopyOptions)> BufferUploads = new List<(GpuBuffer, BufferCopy, CopyOptions)>(); | 		List<(GpuBuffer, BufferCopy, CopyOptions)> BufferUploads = new List<(GpuBuffer, BufferCopy, CopyOptions)>(); | ||||||
| 		List<(TextureSlice, uint, CopyOptions)> TextureUploads = new List<(TextureSlice, uint, CopyOptions)>(); | 		List<(TextureRegion, uint, CopyOptions)> TextureUploads = new List<(TextureRegion, uint, CopyOptions)>(); | ||||||
| 
 | 
 | ||||||
| 		public ResourceUploader(GraphicsDevice device) : base(device) | 		public ResourceUploader(GraphicsDevice device) : base(device) | ||||||
| 		{ | 		{ | ||||||
|  | @ -142,12 +142,14 @@ namespace MoonWorks.Graphics | ||||||
| 					var byteSpan = new Span<byte>(byteBuffer, levelSize); | 					var byteSpan = new Span<byte>(byteBuffer, levelSize); | ||||||
| 					stream.ReadExactly(byteSpan); | 					stream.ReadExactly(byteSpan); | ||||||
| 
 | 
 | ||||||
| 					var textureSlice = new TextureSlice | 					var textureRegion = new TextureRegion | ||||||
|  | 					{ | ||||||
|  | 						TextureSlice = new TextureSlice | ||||||
| 						{ | 						{ | ||||||
| 							Texture = texture, | 							Texture = texture, | ||||||
| 						MipLevel = (uint) level, | 							Layer = (uint) face, | ||||||
| 						BaseLayer = (uint) face, | 							MipLevel = (uint) level | ||||||
| 						LayerCount = 1, | 						}, | ||||||
| 						X = 0, | 						X = 0, | ||||||
| 						Y = 0, | 						Y = 0, | ||||||
| 						Z = 0, | 						Z = 0, | ||||||
|  | @ -156,7 +158,7 @@ namespace MoonWorks.Graphics | ||||||
| 						Depth = 1 | 						Depth = 1 | ||||||
| 					}; | 					}; | ||||||
| 
 | 
 | ||||||
| 					SetTextureData(textureSlice, byteSpan, CopyOptions.SafeOverwrite); | 					SetTextureData(textureRegion, byteSpan, CopyOptions.SafeOverwrite); | ||||||
| 
 | 
 | ||||||
| 					NativeMemory.Free(byteBuffer); | 					NativeMemory.Free(byteBuffer); | ||||||
| 				} | 				} | ||||||
|  | @ -174,36 +176,36 @@ namespace MoonWorks.Graphics | ||||||
| 			return CreateTextureFromDDS(stream); | 			return CreateTextureFromDDS(stream); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public void SetTextureDataFromCompressed(TextureSlice textureSlice, Span<byte> compressedImageData) | 		public void SetTextureDataFromCompressed(TextureRegion textureRegion, Span<byte> compressedImageData) | ||||||
| 		{ | 		{ | ||||||
| 			var pixelData = ImageUtils.GetPixelDataFromBytes(compressedImageData, out var _, out var _, out var sizeInBytes); | 			var pixelData = ImageUtils.GetPixelDataFromBytes(compressedImageData, out var _, out var _, out var sizeInBytes); | ||||||
| 			var pixelSpan = new Span<byte>((void*) pixelData, (int) sizeInBytes); | 			var pixelSpan = new Span<byte>((void*) pixelData, (int) sizeInBytes); | ||||||
| 
 | 
 | ||||||
| 			SetTextureData(textureSlice, pixelSpan, CopyOptions.SafeOverwrite); | 			SetTextureData(textureRegion, pixelSpan, CopyOptions.SafeOverwrite); | ||||||
| 
 | 
 | ||||||
| 			ImageUtils.FreePixelData(pixelData); | 			ImageUtils.FreePixelData(pixelData); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public void SetTextureDataFromCompressed(TextureSlice textureSlice, Stream compressedImageStream) | 		public void SetTextureDataFromCompressed(TextureRegion textureRegion, Stream compressedImageStream) | ||||||
| 		{ | 		{ | ||||||
| 			var length = compressedImageStream.Length; | 			var length = compressedImageStream.Length; | ||||||
| 			var buffer = NativeMemory.Alloc((nuint) length); | 			var buffer = NativeMemory.Alloc((nuint) length); | ||||||
| 			var span = new Span<byte>(buffer, (int) length); | 			var span = new Span<byte>(buffer, (int) length); | ||||||
| 			compressedImageStream.ReadExactly(span); | 			compressedImageStream.ReadExactly(span); | ||||||
| 			SetTextureDataFromCompressed(textureSlice, span); | 			SetTextureDataFromCompressed(textureRegion, span); | ||||||
| 			NativeMemory.Free(buffer); | 			NativeMemory.Free(buffer); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public void SetTextureDataFromCompressed(TextureSlice textureSlice, string compressedImageFilePath) | 		public void SetTextureDataFromCompressed(TextureRegion textureRegion, string compressedImageFilePath) | ||||||
| 		{ | 		{ | ||||||
| 			var fileStream = new FileStream(compressedImageFilePath, FileMode.Open, FileAccess.Read); | 			var fileStream = new FileStream(compressedImageFilePath, FileMode.Open, FileAccess.Read); | ||||||
| 			SetTextureDataFromCompressed(textureSlice, fileStream); | 			SetTextureDataFromCompressed(textureRegion, fileStream); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Prepares upload of pixel data into a TextureSlice. | 		/// Prepares upload of pixel data into a TextureSlice. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		public void SetTextureData<T>(TextureSlice textureSlice, Span<T> data, CopyOptions option) where T : unmanaged | 		public void SetTextureData<T>(TextureRegion textureRegion, Span<T> data, CopyOptions option) where T : unmanaged | ||||||
| 		{ | 		{ | ||||||
| 			var elementSize = Marshal.SizeOf<T>(); | 			var elementSize = Marshal.SizeOf<T>(); | ||||||
| 			var dataLengthInBytes = (uint) (elementSize * data.Length); | 			var dataLengthInBytes = (uint) (elementSize * data.Length); | ||||||
|  | @ -211,10 +213,10 @@ namespace MoonWorks.Graphics | ||||||
| 			uint resourceOffset; | 			uint resourceOffset; | ||||||
| 			fixed (T* dataPtr = data) | 			fixed (T* dataPtr = data) | ||||||
| 			{ | 			{ | ||||||
| 				resourceOffset = CopyDataAligned(dataPtr, dataLengthInBytes, Texture.TexelSize(textureSlice.Texture.Format)); | 				resourceOffset = CopyDataAligned(dataPtr, dataLengthInBytes, Texture.TexelSize(textureRegion.TextureSlice.Texture.Format)); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			TextureUploads.Add((textureSlice, resourceOffset, option)); | 			TextureUploads.Add((textureRegion, resourceOffset, option)); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// Upload | 		// Upload | ||||||
|  | @ -274,11 +276,11 @@ namespace MoonWorks.Graphics | ||||||
| 				); | 				); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			foreach (var (textureSlice, offset, option) in TextureUploads) | 			foreach (var (textureRegion, offset, option) in TextureUploads) | ||||||
| 			{ | 			{ | ||||||
| 				commandBuffer.UploadToTexture( | 				commandBuffer.UploadToTexture( | ||||||
| 					TransferBuffer, | 					TransferBuffer, | ||||||
| 					textureSlice, | 					textureRegion, | ||||||
| 					new BufferImageCopy( | 					new BufferImageCopy( | ||||||
| 						offset, | 						offset, | ||||||
| 						0, | 						0, | ||||||
|  |  | ||||||
|  | @ -14,6 +14,7 @@ namespace MoonWorks.Graphics | ||||||
| 		public uint Depth { get; } | 		public uint Depth { get; } | ||||||
| 		public TextureFormat Format { get; internal set; } | 		public TextureFormat Format { get; internal set; } | ||||||
| 		public bool IsCube { get; } | 		public bool IsCube { get; } | ||||||
|  | 		public uint LayerCount { get; } | ||||||
| 		public uint LevelCount { get; } | 		public uint LevelCount { get; } | ||||||
| 		public SampleCount SampleCount { get; } | 		public SampleCount SampleCount { get; } | ||||||
| 		public TextureUsageFlags UsageFlags { get; } | 		public TextureUsageFlags UsageFlags { get; } | ||||||
|  | @ -46,6 +47,7 @@ namespace MoonWorks.Graphics | ||||||
| 				Height = height, | 				Height = height, | ||||||
| 				Depth = 1, | 				Depth = 1, | ||||||
| 				IsCube = false, | 				IsCube = false, | ||||||
|  | 				LayerCount = 1, | ||||||
| 				LevelCount = levelCount, | 				LevelCount = levelCount, | ||||||
| 				SampleCount = sampleCount, | 				SampleCount = sampleCount, | ||||||
| 				Format = format, | 				Format = format, | ||||||
|  | @ -56,15 +58,43 @@ namespace MoonWorks.Graphics | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// Creates a 3D texture. | 		/// Creates a 2D texture array. | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <param name="device">An initialized GraphicsDevice.</param> | 		/// <param name="device">An initialized GraphicsDevice.</param> | ||||||
| 		/// <param name="width">The width of the texture.</param> | 		/// <param name="width">The width of the texture.</param> | ||||||
| 		/// <param name="height">The height of the texture.</param> | 		/// <param name="height">The height of the texture.</param> | ||||||
| 		/// <param name="depth">The depth of the texture.</param> | 		/// <param name="layerCount">The layer count of the texture.</param> | ||||||
| 		/// <param name="format">The format of the texture.</param> | 		/// <param name="format">The format of the texture.</param> | ||||||
| 		/// <param name="usageFlags">Specifies how the texture will be used.</param> | 		/// <param name="usageFlags">Specifies how the texture will be used.</param> | ||||||
| 		/// <param name="levelCount">Specifies the number of mip levels.</param> | 		/// <param name="levelCount">Specifies the number of mip levels.</param> | ||||||
|  | 		public static Texture CreateTexture2DArray( | ||||||
|  | 			GraphicsDevice device, | ||||||
|  | 			uint width, | ||||||
|  | 			uint height, | ||||||
|  | 			uint layerCount, | ||||||
|  | 			TextureFormat format, | ||||||
|  | 			TextureUsageFlags usageFlags, | ||||||
|  | 			uint levelCount = 1 | ||||||
|  | 		) { | ||||||
|  | 			var textureCreateInfo = new TextureCreateInfo | ||||||
|  | 			{ | ||||||
|  | 				Width = width, | ||||||
|  | 				Height = height, | ||||||
|  | 				Depth = 1, | ||||||
|  | 				IsCube = false, | ||||||
|  | 				LayerCount = layerCount, | ||||||
|  | 				LevelCount = levelCount, | ||||||
|  | 				Format = format, | ||||||
|  | 				UsageFlags = usageFlags | ||||||
|  | 			}; | ||||||
|  | 
 | ||||||
|  | 			return new Texture(device, textureCreateInfo); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		/// <summary> | ||||||
|  | 		/// Creates a 3D texture. | ||||||
|  | 		/// Note that the width, height and depth all form one slice and cannot be subdivided in a texture slice. | ||||||
|  | 		/// </summary> | ||||||
| 		public static Texture CreateTexture3D( | 		public static Texture CreateTexture3D( | ||||||
| 			GraphicsDevice device, | 			GraphicsDevice device, | ||||||
| 			uint width, | 			uint width, | ||||||
|  | @ -80,6 +110,7 @@ namespace MoonWorks.Graphics | ||||||
| 				Height = height, | 				Height = height, | ||||||
| 				Depth = depth, | 				Depth = depth, | ||||||
| 				IsCube = false, | 				IsCube = false, | ||||||
|  | 				LayerCount = 1, | ||||||
| 				LevelCount = levelCount, | 				LevelCount = levelCount, | ||||||
| 				Format = format, | 				Format = format, | ||||||
| 				UsageFlags = usageFlags | 				UsageFlags = usageFlags | ||||||
|  | @ -109,6 +140,7 @@ namespace MoonWorks.Graphics | ||||||
| 				Height = size, | 				Height = size, | ||||||
| 				Depth = 1, | 				Depth = 1, | ||||||
| 				IsCube = true, | 				IsCube = true, | ||||||
|  | 				LayerCount = 6, | ||||||
| 				LevelCount = levelCount, | 				LevelCount = levelCount, | ||||||
| 				Format = format, | 				Format = format, | ||||||
| 				UsageFlags = usageFlags | 				UsageFlags = usageFlags | ||||||
|  | @ -137,14 +169,13 @@ namespace MoonWorks.Graphics | ||||||
| 			Height = textureCreateInfo.Height; | 			Height = textureCreateInfo.Height; | ||||||
| 			Depth = textureCreateInfo.Depth; | 			Depth = textureCreateInfo.Depth; | ||||||
| 			IsCube = textureCreateInfo.IsCube; | 			IsCube = textureCreateInfo.IsCube; | ||||||
|  | 			LayerCount = textureCreateInfo.LayerCount; | ||||||
| 			LevelCount = textureCreateInfo.LevelCount; | 			LevelCount = textureCreateInfo.LevelCount; | ||||||
| 			SampleCount = textureCreateInfo.SampleCount; | 			SampleCount = textureCreateInfo.SampleCount; | ||||||
| 			UsageFlags = textureCreateInfo.UsageFlags; | 			UsageFlags = textureCreateInfo.UsageFlags; | ||||||
| 			Size = Width * Height * BytesPerPixel(Format) / BlockSizeSquared(Format); | 			Size = Width * Height * BytesPerPixel(Format) / BlockSizeSquared(Format); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public static implicit operator TextureSlice(Texture t) => new TextureSlice(t); |  | ||||||
| 
 |  | ||||||
| 		// Used by AcquireSwapchainTexture. | 		// Used by AcquireSwapchainTexture. | ||||||
| 		// Should not be tracked, because swapchain textures are managed by Vulkan. | 		// Should not be tracked, because swapchain textures are managed by Vulkan. | ||||||
| 		internal Texture( | 		internal Texture( | ||||||
|  | @ -270,5 +301,8 @@ namespace MoonWorks.Graphics | ||||||
| 					return 0; | 					return 0; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 
 | ||||||
|  | 		public static implicit operator TextureSlice(Texture t) => new TextureSlice(t); | ||||||
|  | 		public static implicit operator TextureRegion(Texture t) => new TextureRegion(t); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ namespace MoonWorks.Graphics | ||||||
| 		public uint Height; | 		public uint Height; | ||||||
| 		public uint Depth; | 		public uint Depth; | ||||||
| 		public bool IsCube; | 		public bool IsCube; | ||||||
|  | 		public uint LayerCount; | ||||||
| 		public uint LevelCount; | 		public uint LevelCount; | ||||||
| 		public SampleCount SampleCount; | 		public SampleCount SampleCount; | ||||||
| 		public TextureFormat Format; | 		public TextureFormat Format; | ||||||
|  | @ -24,6 +25,7 @@ namespace MoonWorks.Graphics | ||||||
| 				height = Height, | 				height = Height, | ||||||
| 				depth = Depth, | 				depth = Depth, | ||||||
| 				isCube = Conversions.BoolToByte(IsCube), | 				isCube = Conversions.BoolToByte(IsCube), | ||||||
|  | 				layerCount = LayerCount, | ||||||
| 				levelCount = LevelCount, | 				levelCount = LevelCount, | ||||||
| 				sampleCount = (Refresh.SampleCount) SampleCount, | 				sampleCount = (Refresh.SampleCount) SampleCount, | ||||||
| 				format = (Refresh.TextureFormat) Format, | 				format = (Refresh.TextureFormat) Format, | ||||||
|  |  | ||||||
|  | @ -0,0 +1,46 @@ | ||||||
|  | using RefreshCS; | ||||||
|  | 
 | ||||||
|  | namespace MoonWorks.Graphics | ||||||
|  | { | ||||||
|  | 	/// <summary> | ||||||
|  | 	/// A texture region specifies a subregion of a texture. | ||||||
|  | 	/// These are used by copy commands. | ||||||
|  | 	/// </summary> | ||||||
|  | 	public struct TextureRegion | ||||||
|  | 	{ | ||||||
|  | 		public TextureSlice TextureSlice; | ||||||
|  | 		public uint X; | ||||||
|  | 		public uint Y; | ||||||
|  | 		public uint Z; | ||||||
|  | 		public uint Width; | ||||||
|  | 		public uint Height; | ||||||
|  | 		public uint Depth; | ||||||
|  | 
 | ||||||
|  | 		public uint Size => (Width * Height * Depth * Texture.BytesPerPixel(TextureSlice.Texture.Format) / Texture.BlockSizeSquared(TextureSlice.Texture.Format)) >> (int) TextureSlice.MipLevel; | ||||||
|  | 
 | ||||||
|  | 		public TextureRegion(Texture texture) | ||||||
|  | 		{ | ||||||
|  | 			TextureSlice = new TextureSlice(texture); | ||||||
|  | 			X = 0; | ||||||
|  | 			Y = 0; | ||||||
|  | 			Z = 0; | ||||||
|  | 			Width = texture.Width; | ||||||
|  | 			Height = texture.Height; | ||||||
|  | 			Depth = texture.Depth; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		public Refresh.TextureRegion ToRefreshTextureRegion() | ||||||
|  | 		{ | ||||||
|  | 			return new Refresh.TextureRegion | ||||||
|  | 			{ | ||||||
|  | 				textureSlice = TextureSlice.ToRefreshTextureSlice(), | ||||||
|  | 				x = X, | ||||||
|  | 				y = Y, | ||||||
|  | 				z = Z, | ||||||
|  | 				w = Width, | ||||||
|  | 				h = Height, | ||||||
|  | 				d = Depth | ||||||
|  | 			}; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | @ -3,55 +3,31 @@ | ||||||
| namespace MoonWorks.Graphics | namespace MoonWorks.Graphics | ||||||
| { | { | ||||||
| 	/// <summary> | 	/// <summary> | ||||||
| 	/// A texture slice specifies a subregion of a texture. | 	/// A texture slice specifies a subresource of a texture. | ||||||
| 	/// Many operations can use texture slices in place of textures for the sake of convenience. |  | ||||||
| 	/// </summary> | 	/// </summary> | ||||||
| 	public struct TextureSlice | 	public struct TextureSlice | ||||||
| 	{ | 	{ | ||||||
| 		public Texture Texture; | 		public Texture Texture; | ||||||
| 		public uint MipLevel; | 		public uint MipLevel; | ||||||
| 		public uint BaseLayer; | 		public uint Layer; | ||||||
| 		public uint LayerCount; |  | ||||||
| 		public uint X; |  | ||||||
| 		public uint Y; |  | ||||||
| 		public uint Z; |  | ||||||
| 		public uint Width; |  | ||||||
| 		public uint Height; |  | ||||||
| 		public uint Depth; |  | ||||||
| 
 | 
 | ||||||
| 		public uint Size => (Width * Height * Depth * LayerCount * Texture.BytesPerPixel(Texture.Format) / Texture.BlockSizeSquared(Texture.Format)) >> (int) MipLevel; | 		public uint Size => (Texture.Width * Texture.Height * Texture.Depth * Texture.BytesPerPixel(Texture.Format) / Texture.BlockSizeSquared(Texture.Format)) >> (int) MipLevel; | ||||||
| 
 | 
 | ||||||
| 		public TextureSlice(Texture texture) | 		public TextureSlice(Texture texture) | ||||||
| 		{ | 		{ | ||||||
| 			Texture = texture; | 			Texture = texture; | ||||||
| 			MipLevel = 0; | 			MipLevel = 0; | ||||||
| 			BaseLayer = 0; | 			Layer = 0; | ||||||
| 			LayerCount = (uint) (texture.IsCube ? 6 : 1); |  | ||||||
| 			X = 0; |  | ||||||
| 			Y = 0; |  | ||||||
| 			Z = 0; |  | ||||||
| 			Width = texture.Width; |  | ||||||
| 			Height = texture.Height; |  | ||||||
| 			Depth = texture.Depth; |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		public Refresh.TextureSlice ToRefreshTextureSlice() | 		public Refresh.TextureSlice ToRefreshTextureSlice() | ||||||
| 		{ | 		{ | ||||||
| 			Refresh.TextureSlice textureSlice = new Refresh.TextureSlice | 			return new Refresh.TextureSlice | ||||||
| 			{ | 			{ | ||||||
| 				texture = Texture.Handle, | 				texture = Texture.Handle, | ||||||
| 				mipLevel = MipLevel, | 				mipLevel = MipLevel, | ||||||
| 				baseLayer = BaseLayer, | 				layer = Layer | ||||||
| 				layerCount = LayerCount, |  | ||||||
| 				x = X, |  | ||||||
| 				y = Y, |  | ||||||
| 				z = Z, |  | ||||||
| 				w = Width, |  | ||||||
| 				h = Height, |  | ||||||
| 				d = Depth |  | ||||||
| 			}; | 			}; | ||||||
| 
 |  | ||||||
| 			return textureSlice; |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -287,7 +287,7 @@ namespace MoonWorks.Video | ||||||
| 				commandBuffer.EndCopyPass(); | 				commandBuffer.EndCopyPass(); | ||||||
| 
 | 
 | ||||||
| 				commandBuffer.BeginRenderPass( | 				commandBuffer.BeginRenderPass( | ||||||
| 					new ColorAttachmentInfo(RenderTexture, Color.Black) | 					new ColorAttachmentInfo(RenderTexture, Color.Black, true) | ||||||
| 				); | 				); | ||||||
| 
 | 
 | ||||||
| 				commandBuffer.BindGraphicsPipeline(Device.VideoPipeline); | 				commandBuffer.BindGraphicsPipeline(Device.VideoPipeline); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue