/// <summary> /// Creates a Texture from a DirectX11 native texture /// This method internally will call AddReference on the dxTexture2D texture. /// </summary> /// <param name="device">The GraphicsDevice in use</param> /// <param name="dxTexture2D">The DX11 texture</param> /// <param name="takeOwnership">If false AddRef will be called on the texture, if true will not, effectively taking ownership</param> /// <param name="isSRgb">Set the format to SRgb</param> /// <returns></returns> private static Texture CreateTextureFromNativeImpl(GraphicsDevice device, Texture2D dxTexture2D, bool takeOwnership, bool isSRgb = false) { var tex = new Texture(device); if (takeOwnership) { var unknown = dxTexture2D as IUnknown; unknown.AddReference(); } tex.InitializeFromImpl(dxTexture2D, isSRgb); return(tex); }