コード例 #1
0
        /// <summary>
        ///     Initializes the specified device.
        /// </summary>
        /// <param name="graphicsProfiles">The graphics profiles.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        private void InitializePlatformDevice(GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, object windowHandle)
        {
            if (nativeDevice != null)
            {
                // Destroy previous device
                ReleaseDevice();
            }

            // Profiling is supported through pix markers
            IsProfilingSupported = true;

            // Map GraphicsProfile to D3D11 FeatureLevel
            SharpDX.Direct3D.FeatureLevel[] levels = graphicsProfiles.ToFeatureLevel();
            creationFlags = (SharpDX.Direct3D11.DeviceCreationFlags)deviceCreationFlags;

            // Create Device D3D11 with feature Level based on profile
            nativeDevice        = new SharpDX.Direct3D11.Device(Adapter.NativeAdapter, creationFlags, levels);
            nativeDeviceContext = nativeDevice.ImmediateContext;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(this, nativeDeviceContext, "ImmediateContext");
            }

            InitializeStages();

            // Create the input layout manager
            if (InputLayoutManager == null)
            {
                InputLayoutManager = new InputLayoutManager(this).DisposeBy(this);
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDevice" /> class using the default GraphicsAdapter
        /// and the Level10 <see cref="GraphicsProfile" />.
        /// </summary>
        /// <param name="device">The device.</param>
        private GraphicsDevice(GraphicsDevice device)
        {
            RootDevice           = device;
            Adapter              = device.Adapter;
            creationFlags        = device.creationFlags;
            Features             = device.Features;
            sharedDataPerDevice  = device.sharedDataPerDevice;
            InputLayoutManager   = device.InputLayoutManager;
            nativeDevice         = device.NativeDevice;
            nativeDeviceContext  = new SharpDX.Direct3D11.DeviceContext(NativeDevice).DisposeBy(this);
            nativeDeviceProfiler = SharpDX.ComObject.QueryInterfaceOrNull <UserDefinedAnnotation>(nativeDeviceContext.NativePointer);
            isDeferred           = true;
            IsDebugMode          = device.IsDebugMode;
            if (IsDebugMode)
            {
                GraphicsResourceBase.SetDebugName(device, nativeDeviceContext, "DeferredContext");
            }
            NeedWorkAroundForUpdateSubResource = !Features.HasDriverCommandLists;

            primitiveQuad = new PrimitiveQuad(this).DisposeBy(this);

            InitializeStages();
        }