コード例 #1
0
ファイル: RenderContextD3D12.cs プロジェクト: Noesis/Managed
        private void CreateDevice()
        {
            using (SharpDX.DXGI.Factory4 factory = new Factory4())
            {
                _dev = new SharpDX.Direct3D12.Device(factory.Adapters[0], FeatureLevel.Level_11_0);
            }

            int[] levels_ =
            {
                (int)FeatureLevel.Level_12_1,
                (int)FeatureLevel.Level_12_0,
                (int)FeatureLevel.Level_11_1,
                (int)FeatureLevel.Level_11_0
            };

            GCHandle pinnedArray = GCHandle.Alloc(levels_, GCHandleType.Pinned);
            IntPtr   pointer     = pinnedArray.AddrOfPinnedObject();

            SharpDX.Direct3D.FeatureLevel level = FeatureLevel.Level_11_0;
            SharpDX.Direct3D12.FeatureDataFeatureLevels levels = new FeatureDataFeatureLevels();
            levels.FeatureLevelCount             = levels_.Length;
            levels.FeatureLevelsRequestedPointer = pointer;
            if (_dev.CheckFeatureSupport(SharpDX.Direct3D12.Feature.FeatureLevels, ref levels))
            {
                level = levels.MaxSupportedFeatureLevel;
            }

            pinnedArray.Free();

            System.Console.WriteLine($"  Feature Level: {(((int)level) >> 12) & 0xF}_{(((int)level) >> 8) & 0xF}");
        }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="minLevel"></param>
 public D3D11(SharpDX.Direct3D.FeatureLevel minLevel)
 {
     m_device = DeviceUtil.Create11(DeviceCreationFlags.BgraSupport, minLevel);
     if (m_device == null)
     {
         throw new NotSupportedException();
     }
 }
コード例 #3
0
        /// <summary>
        /// Function to retrieve the highest feature set for a video adapter.
        /// </summary>
        /// <param name="device">The D3D device to use.</param>
        /// <returns>The highest available feature set for the device.</returns>
        private static FeatureSet?GetFeatureLevel(D3D11.Device5 device)
        {
            D3D.FeatureLevel result = device.FeatureLevel;

            return(((Enum.IsDefined(typeof(D3D.FeatureLevel), (int)result)) &&
                    (result >= D3D.FeatureLevel.Level_12_0))
                ? (FeatureSet?)result
                : null);
        }
コード例 #4
0
        /// <summary>
        /// Unloads all resources.
        /// </summary>
        public void UnloadResources()
        {
            m_immediateContext  = CommonTools.DisposeObject(m_immediateContext);
            m_immediateContext3 = CommonTools.DisposeObject(m_immediateContext3);
            m_device1           = CommonTools.DisposeObject(m_device1);
            m_device3           = CommonTools.DisposeObject(m_device3);

            m_creationFlags = D3D11.DeviceCreationFlags.None;
            m_featureLevel  = D3D.FeatureLevel.Level_11_0;
        }
コード例 #5
0
		public static SharpDX.Direct3D11.Device Create11(
			Direct3D11.DeviceCreationFlags cFlags = Direct3D11.DeviceCreationFlags.None,
			Direct3D.FeatureLevel minLevel = Direct3D.FeatureLevel.Level_9_1
		)
		{
			using (var dg = new DisposeGroup())
			{
				var level = Direct3D11.Device.GetSupportedFeatureLevel();
				if (level < minLevel)
					return null;
				return new Direct3D11.Device(Direct3D.DriverType.Hardware, cFlags, level);
			}
		}
コード例 #6
0
        /// <summary>
        /// Function to enumerate a D3D feature level to a Gorgon device feature level.
        /// </summary>
        /// <param name="featureLevel">D3D Feature level to enumerate.</param>
        /// <returns>Gorgon device feature level.</returns>
        private void EnumerateFeatureLevels(D3DCommon.FeatureLevel featureLevel)
        {
            switch (featureLevel)
            {
            case D3DCommon.FeatureLevel.Level_11_0:
                SupportedFeatureLevel = HardwareFeatureLevel = DeviceFeatureLevel.SM5;
                break;

            case D3DCommon.FeatureLevel.Level_10_1:
                SupportedFeatureLevel = HardwareFeatureLevel = DeviceFeatureLevel.SM4_1;
                break;

            case D3DCommon.FeatureLevel.Level_10_0:
                SupportedFeatureLevel = HardwareFeatureLevel = DeviceFeatureLevel.SM4;
                break;

            default:
                SupportedFeatureLevel = HardwareFeatureLevel = DeviceFeatureLevel.Unsupported;
                break;
            }
        }
コード例 #7
0
        /// <summary>
        /// ファイル(リソースファイルも含む)からテクスチャーを作成する
        /// </summary>
        /// <param name="name"></param>
        /// <param name="srcFile"></param>
        /// <returns></returns>
        public static MCBaseTexture CreateTextureFromFile(Application app, string name, string srcFile)
        {
            SharpDX.Direct3D.FeatureLevel flv = app.DXDevice.FeatureLevel;
            MCTexture    tx;
            MC_FILE_TYPE fileType;

            SharpDX.WIC.ImagingFactory2 factory = new SharpDX.WIC.ImagingFactory2();
            var img = LoadBitmap(factory, srcFile, out fileType);


            tx = CreateTexture2DFromBitmap(app, img, srcFile);
            tx.CreateTxResourceView(0);
            tx.ImageFileFormat = fileType;

            img.Dispose();
            factory.Dispose();
            if (!app.ImageMgr.RegisterTexture(name, tx))
            {
                return(null);
            }
            return(tx);
        }
コード例 #8
0
        /// <summary>
        /// Creates device resources.
        /// </summary>
        /// <remarks>
        /// This method is called at the initialization of this instance.
        /// </remarks>
        protected virtual void CreateDeviceResources()
        {
            // Dispose previous references and set to null
            RemoveAndDispose(ref d3dDevice);
            RemoveAndDispose(ref d3dContext);
            RemoveAndDispose(ref d2dDevice);
            RemoveAndDispose(ref d2dContext);

            // Allocate new references
            // Enable compatibility with Direct2D
            // Retrieve the Direct3D 11.1 device amd device context
            var creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.VideoSupport | SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport;

            // Decomment this line to have Debug. Unfortunately, debug is sometimes crashing applications, so it is disable by default
            try
            {
                // Try to create it with Video Support
                // If it is not working, we just use BGRA
                // Force to FeatureLevel.Level_9_1
                using (var defaultDevice = new SharpDX.Direct3D11.Device(DriverType.Hardware, creationFlags))
                    d3dDevice = defaultDevice.QueryInterface <SharpDX.Direct3D11.Device1>();
            } catch (Exception)
            {
                creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport;
                using (var defaultDevice = new SharpDX.Direct3D11.Device(DriverType.Hardware, creationFlags))
                    d3dDevice = defaultDevice.QueryInterface <SharpDX.Direct3D11.Device1>();
            }
            featureLevel = d3dDevice.FeatureLevel;

            // Get Direct3D 11.1 context
            d3dContext = ToDispose(d3dDevice.ImmediateContext.QueryInterface <SharpDX.Direct3D11.DeviceContext1>());

            // Create Direct2D device
            using (var dxgiDevice = d3dDevice.QueryInterface <SharpDX.DXGI.Device>())
                d2dDevice = ToDispose(new SharpDX.Direct2D1.Device(d2dFactory, dxgiDevice));

            // Create Direct2D context
            d2dContext = ToDispose(new SharpDX.Direct2D1.DeviceContext(d2dDevice, SharpDX.Direct2D1.DeviceContextOptions.None));
        }
コード例 #9
0
        /// <summary>
        /// Find the display mode that most closely matches the requested display mode.
        /// </summary>
        /// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
        /// <param name="mode">The mode.</param>
        /// <returns>Returns the closes display mode.</returns>
        /// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
        /// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order.  ScanlineOrdering Scaling Format Resolution RefreshRate  When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and  other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering,  Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because  the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output.  If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified  display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output.   Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
        public DisplayMode FindClosestMatchingDisplayMode(GraphicsProfile[] targetProfiles, DisplayMode mode)
        {
            if (targetProfiles == null)
            {
                throw new ArgumentNullException("targetProfiles");
            }

            ModeDescription closestDescription;

            SharpDX.Direct3D11.Device deviceTemp = null;
            try
            {
                var features = new SharpDX.Direct3D.FeatureLevel[targetProfiles.Length];
                for (int i = 0; i < targetProfiles.Length; i++)
                {
                    features[i] = (FeatureLevel)targetProfiles[i];
                }

                deviceTemp = new SharpDX.Direct3D11.Device(adapter.NativeAdapter, SharpDX.Direct3D11.DeviceCreationFlags.None, features);
            }
            catch (Exception) { }

            var description = new SharpDX.DXGI.ModeDescription()
            {
                Width            = mode.Width,
                Height           = mode.Height,
                RefreshRate      = mode.RefreshRate.ToSharpDX(),
                Format           = (SharpDX.DXGI.Format)mode.Format,
                Scaling          = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
            };

            using (var device = deviceTemp)
                output.GetClosestMatchingMode(device, description, out closestDescription);

            return(DisplayMode.FromDescription(closestDescription));
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EngineAdapterInfo" /> class.
        /// </summary>
        internal EngineAdapterInfo(int adapterIndex, DXGI.Adapter1 adapter)
        {
            m_outputs      = new List <EngineOutputInfo>();
            m_adapter      = adapter;
            m_adapterIndex = adapterIndex;

            m_adapterDescription = adapter.Description;
            m_isSoftware         =
                (m_adapterDescription.Description == "Microsoft Basic Render Driver") ||
                ((!string.IsNullOrEmpty(m_adapterDescription.Description)) && m_adapterDescription.Description.Contains("Software")) ||
                ((!string.IsNullOrEmpty(m_adapterDescription.Description)) && m_adapterDescription.Description.Contains("Microsoft Basic Render Driver"));

            m_d3d11FeatureLevel = D3D11.Device.GetSupportedFeatureLevel(adapter);

            //Query for output information
            DXGI.Output[] outputs = adapter.Outputs;
            for (int loop = 0; loop < outputs.Length; loop++)
            {
                try
                {
                    DXGI.Output actOutput = outputs[loop];
                    try
                    {
                        m_outputs.Add(new EngineOutputInfo(adapterIndex, loop, actOutput));
                    }
                    finally
                    {
                        actOutput.Dispose();
                    }
                }
                catch (Exception)
                {
                    //Query for output information not possible
                    // .. no special handling needed here
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Creates device resources. 
        /// </summary>
        /// <remarks>
        /// This method is called at the initialization of this instance.
        /// </remarks>
        protected virtual void CreateDeviceResources()
        {
            // Dispose previous references and set to null
            RemoveAndDispose(ref d3dDevice);
            RemoveAndDispose(ref d3dContext);
            RemoveAndDispose(ref d2dDevice);
            RemoveAndDispose(ref d2dContext);

            // Allocate new references
            // Enable compatibility with Direct2D
            // Retrieve the Direct3D 11.1 device amd device context
            var creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.VideoSupport | SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport;

            // Decomment this line to have Debug. Unfortunately, debug is sometimes crashing applications, so it is disable by default
            try
            {
                // Try to create it with Video Support
                // If it is not working, we just use BGRA
                // Force to FeatureLevel.Level_9_1
                using (var defaultDevice = new SharpDX.Direct3D11.Device(DriverType.Hardware, creationFlags))
                    d3dDevice = defaultDevice.QueryInterface<SharpDX.Direct3D11.Device1>();
            } catch (Exception)
            {
                creationFlags = SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport;
                using (var defaultDevice = new SharpDX.Direct3D11.Device(DriverType.Hardware, creationFlags))
                    d3dDevice = defaultDevice.QueryInterface<SharpDX.Direct3D11.Device1>();
            }
            featureLevel = d3dDevice.FeatureLevel;

            // Get Direct3D 11.1 context
            d3dContext = ToDispose(d3dDevice.ImmediateContext.QueryInterface<SharpDX.Direct3D11.DeviceContext1>());

            // Create Direct2D device
            using (var dxgiDevice = d3dDevice.QueryInterface<SharpDX.DXGI.Device>())
                d2dDevice = ToDispose(new SharpDX.Direct2D1.Device(d2dFactory, dxgiDevice));

            // Create Direct2D context
            d2dContext = ToDispose(new SharpDX.Direct2D1.DeviceContext(d2dDevice, SharpDX.Direct2D1.DeviceContextOptions.None));
        }
コード例 #12
0
        /// <summary>
        /// Find the display mode that most closely matches the requested display mode.
        /// </summary>
        /// <param name="targetProfiles">The target profile, as available formats are different depending on the feature level..</param>
        /// <param name="mode">The mode.</param>
        /// <returns>Returns the closes display mode.</returns>
        /// <unmanaged>HRESULT IDXGIOutput::FindClosestMatchingMode([In] const DXGI_MODE_DESC* pModeToMatch,[Out] DXGI_MODE_DESC* pClosestMatch,[In, Optional] IUnknown* pConcernedDevice)</unmanaged>
        /// <remarks>Direct3D devices require UNORM formats. This method finds the closest matching available display mode to the mode specified in pModeToMatch. Similarly ranked fields (i.e. all specified, or all unspecified, etc) are resolved in the following order.  ScanlineOrdering Scaling Format Resolution RefreshRate  When determining the closest value for a particular field, previously matched fields are used to filter the display mode list choices, and  other fields are ignored. For example, when matching Resolution, the display mode list will have already been filtered by a certain ScanlineOrdering,  Scaling, and Format, while RefreshRate is ignored. This ordering doesn't define the absolute ordering for every usage scenario of FindClosestMatchingMode, because  the application can choose some values initially, effectively changing the order that fields are chosen. Fields of the display mode are matched one at a time, generally in a specified order. If a field is unspecified, FindClosestMatchingMode gravitates toward the values for the desktop related to this output.  If this output is not part of the desktop, then the default desktop output is used to find values. If an application uses a fully unspecified  display mode, FindClosestMatchingMode will typically return a display mode that matches the desktop settings for this output.   Unspecified fields are lower priority than specified fields and will be resolved later than specified fields.</remarks>
        public DisplayMode FindClosestMatchingDisplayMode(GraphicsProfile[] targetProfiles, DisplayMode mode)
        {
            if (targetProfiles == null) throw new ArgumentNullException("targetProfiles");

            ModeDescription closestDescription;
            SharpDX.Direct3D11.Device deviceTemp = null;
            try
            {
                var features = new SharpDX.Direct3D.FeatureLevel[targetProfiles.Length];
                for (int i = 0; i < targetProfiles.Length; i++)
                {
                    features[i] = (FeatureLevel)targetProfiles[i];
                }

                deviceTemp = new SharpDX.Direct3D11.Device(adapter.NativeAdapter, SharpDX.Direct3D11.DeviceCreationFlags.None, features);
            }
            catch (Exception) { }

            var description = new SharpDX.DXGI.ModeDescription()
            {
                Width = mode.Width,
                Height = mode.Height,
                RefreshRate = mode.RefreshRate.ToSharpDX(),
                Format = (SharpDX.DXGI.Format)mode.Format,
                Scaling = DisplayModeScaling.Unspecified,
                ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
            };
            using (var device = deviceTemp)
                output.GetClosestMatchingMode(device, description, out closestDescription);

            return DisplayMode.FromDescription(closestDescription);
        }
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeviceHandlerD3D11"/> class.
        /// </summary>
        /// <param name="dxgiAdapter">The tasrget adapter.</param>
        /// <param name="debugEnabled">Is debug mode enabled?</param>
        internal DeviceHandlerD3D11(DXGI.Adapter1 dxgiAdapter, bool debugEnabled)
        {
            m_dxgiAdapter = dxgiAdapter;

            // Define possible create flags
            D3D11.DeviceCreationFlags createFlagsBgra = D3D11.DeviceCreationFlags.BgraSupport;
            D3D11.DeviceCreationFlags createFlags     = D3D11.DeviceCreationFlags.None;
            if (debugEnabled)
            {
                createFlagsBgra |= D3D11.DeviceCreationFlags.Debug;
                createFlags     |= D3D11.DeviceCreationFlags.Debug;
            }

            // Define all steps on which we try to initialize Direct3D
            List <Tuple <D3D.FeatureLevel, D3D11.DeviceCreationFlags, HardwareDriverLevel> > initParameterQueue =
                new List <Tuple <D3D.FeatureLevel, D3D11.DeviceCreationFlags, HardwareDriverLevel> >();

            // Define all trys for hardware initialization
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_11_1, createFlagsBgra, HardwareDriverLevel.Direct3D11));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_11_0, createFlagsBgra, HardwareDriverLevel.Direct3D11));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_10_0, createFlagsBgra, HardwareDriverLevel.Direct3D10));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_9_3, createFlagsBgra, HardwareDriverLevel.Direct3D9_3));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_9_2, createFlagsBgra, HardwareDriverLevel.Direct3D9_2));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_9_1, createFlagsBgra, HardwareDriverLevel.Direct3D9_1));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_10_0, createFlags, HardwareDriverLevel.Direct3D10));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_9_3, createFlags, HardwareDriverLevel.Direct3D9_3));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_9_2, createFlags, HardwareDriverLevel.Direct3D9_2));
            initParameterQueue.Add(Tuple.Create(
                                       D3D.FeatureLevel.Level_9_1, createFlags, HardwareDriverLevel.Direct3D9_1));

            // Try to create the device, each defined configuration step by step
            foreach (Tuple <D3D.FeatureLevel, D3D11.DeviceCreationFlags, HardwareDriverLevel> actInitParameters in initParameterQueue)
            {
                D3D.FeatureLevel          featureLevel    = actInitParameters.Item1;
                D3D11.DeviceCreationFlags direct3D11Flags = actInitParameters.Item2;
                HardwareDriverLevel       actDriverLevel  = actInitParameters.Item3;

                try
                {
                    // Try to create the device using current parameters
                    using (D3D11.Device device = new D3D11.Device(dxgiAdapter, direct3D11Flags, featureLevel))
                    {
                        m_device1 = device.QueryInterface <D3D11.Device1>();
                        m_device3 = CommonTools.TryExecute(() => m_device1.QueryInterface <D3D11.Device3>());
                        if (m_device3 != null)
                        {
                            m_immediateContext3 = m_device3.ImmediateContext3;
                        }
                    }

                    // Device successfully created, save all parameters and break this loop
                    m_featureLevel  = featureLevel;
                    m_creationFlags = direct3D11Flags;
                    m_driverLevel   = actDriverLevel;
                    break;
                }
                catch (Exception) { }
            }

            // Throw exception on failure
            if (m_device1 == null)
            {
                throw new SeeingSharpGraphicsException("Unable to initialize d3d11 device!");
            }

            // Get immediate context from the device
            m_immediateContext = m_device1.ImmediateContext;
        }
コード例 #14
0
        internal static void CreateDevice(out Device device, out DeviceContext context, out bool isInitialized)
        {
            try
            {
                SharpDX.Direct3D.FeatureLevel[] level = new SharpDX.Direct3D.FeatureLevel[] { SharpDX.Direct3D.FeatureLevel.Level_10_0 };
                device = new Device(SharpDX.Direct3D.DriverType.Hardware, DeviceCreationFlags.SingleThreaded, level);

                if (!device.CheckFeatureSupport(Feature.ComputeShaders))
                {
                    // GPU does not support compute shaders
                    device.Dispose();
                    device = new Device(SharpDX.Direct3D.DriverType.Warp, DeviceCreationFlags.SingleThreaded, level);

                    if (!device.CheckFeatureSupport(Feature.ComputeShaders))
                    {
                        // This version of Warp does not support compute shaders
                        device.Dispose();

                        isInitialized = false;
                        context = null;
                    }
                    else
                    {
                        isInitialized = true;
                        context = device.ImmediateContext;
                    }
                }
                else
                {
                    isInitialized = true;
                    context = device.ImmediateContext;
                }
            }
            catch
            {
                device = null;
                context = null;
                isInitialized = false;
            }

            if (!isInitialized)
            {
                System.Windows.Forms.MessageBox.Show("Device creation failed.\n\nPlease ensure that you have the latest drivers for your "
                    + "video card and that it supports DirectCompute.", "Hardware Accelerated Blur Pack");
            }
        }
コード例 #15
0
        public override void InitDevice()
        {
            Width  = 100;
            Height = 100;
            DriverType[] driverTypes = new DriverType[] {
                DriverType.Hardware,
                DriverType.Warp,
                DriverType.Reference,
            };

            DeviceCreationFlags deviceCreationFlags = DeviceCreationFlags.BgraSupport;

            if (IsDebugMode)
            {
                deviceCreationFlags |= DeviceCreationFlags.Debug;
            }

            FeatureLevel[] levels = new FeatureLevel[] {
                FeatureLevel.Level_11_0,
                FeatureLevel.Level_10_1,
                FeatureLevel.Level_10_0,
            };

            foreach (var driverType in driverTypes)
            {
                DeviceRef = new Device(driverType, deviceCreationFlags, levels);
                if (DeviceRef != null)
                {
                    CurrentDriverType = driverType;
                    break;
                }
            }

            DeviceRef.DebugName = "Interop Device";
            DeviceRef.ImmediateContext.DebugName = "Interop Context";

            CheckFeatures();

            ZBufferTextureDescription = new Texture2DDescription
            {
                Format            = Format.R32_Typeless,
                ArraySize         = 1,
                MipLevels         = 1,
                Width             = Width,
                Height            = Height,
                SampleDescription = new SampleDescription(MSamplesCount, 0),
                Usage             = ResourceUsage.Default,
                BindFlags         = BindFlags.DepthStencil | BindFlags.ShaderResource,
                CpuAccessFlags    = CpuAccessFlags.None,
                OptionFlags       = ResourceOptionFlags.None,
            };

            Factory2D                = new Factory(FactoryType.SingleThreaded, DebugLevel.Information);
            FactoryDWrite            = new SharpDX.DirectWrite.Factory();
            RenderTarget2DProperites = new RenderTargetProperties()
            {
                MinLevel = SharpDX.Direct2D1.FeatureLevel.Level_DEFAULT,
                //PixelFormat = new PixelFormat(Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied),
                PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied),
                Type        = RenderTargetType.Default,
                Usage       = RenderTargetUsage.None,
            };
        }