Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 31 Oct 2008
Offline Last Active Jan 19 2013 01:01 PM

#5016355 Direct3D UYVY texture.

Posted by on 01 January 2013 - 06:28 AM

Thanks. I got everything working now.

It's a shame that I really didn't see people use the "Pitch" property. I guess they are mostly dealing textures that have the Pitch same as Source width.

		/// <summary>
		/// Copies content into destinationBuffer.
		/// </summary>
		/// <param name="texture">actual texture </param>
		/// <param name="contentToCopy">source bfufer</param>
		/// <param name="sourcePitch">source stride</param>
		private static void CopyToTexture(Texture texture, byte[] contentToCopy, int sourcePitch)
			var data = texture.LockRectangle(0, LockFlags.Discard);
			var y = 0;

			for (var scanLineStart = 0; scanLineStart < contentToCopy.Length; scanLineStart += sourcePitch, y++)
				data.Data.WriteRange(contentToCopy, scanLineStart, sourcePitch);
				data.Data.Seek((y + 1)*data.Pitch, SeekOrigin.Begin);



And if anyone is interested, then I ended up using this for my YUV->RGB shader:

though I am thinking about writing my own shader that could use only one sampler2D, so I could pass packed YUV formats directly into the GPU. Though I am not sure where to begin. Is that even a good idea? The texture is defintely gonna be huge as hell though.