Example #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="PhongMaterialVariables"/> class.
            /// </summary>
            /// <param name="manager">The manager.</param>
            /// <param name="technique">The technique.</param>
            /// <param name="materialCore">The material core.</param>
            /// <param name="materialPassName">Name of the material pass.</param>
            /// <param name="wireframePassName">Name of the wireframe pass.</param>
            /// <param name="materialOITPassName">Name of the material oit pass.</param>
            /// <param name="wireframeOITPassName">Name of the wireframe oit pass.</param>
            /// <param name="shadowPassName">Name of the shadow pass.</param>
            /// <param name="tessellationPassName">Name of the tessellation pass.</param>
            /// <param name="tessellationOITPassName">Name of the tessellation oit pass.</param>
            /// <param name="depthPassName">Name of the depth pass</param>
            public PhongMaterialVariables(IEffectsManager manager, IRenderTechnique technique, PhongMaterialCore materialCore,
                                          string materialPassName        = DefaultPassNames.Default, string wireframePassName    = DefaultPassNames.Wireframe,
                                          string materialOITPassName     = DefaultPassNames.OITPass, string wireframeOITPassName = DefaultPassNames.WireframeOITPass,
                                          string shadowPassName          = DefaultPassNames.ShadowPass,
                                          string tessellationPassName    = DefaultPassNames.MeshTriTessellation,
                                          string tessellationOITPassName = DefaultPassNames.MeshTriTessellationOIT,
                                          string depthPassName           = DefaultPassNames.DepthPrepass)
                : base(manager, technique, DefaultMeshConstantBufferDesc, materialCore)
            {
                this.material      = materialCore;
                texDiffuseSlot     = texAlphaSlot = texDisplaceSlot = texNormalSlot = -1;
                samplerDiffuseSlot = samplerDisplaceSlot = samplerShadowSlot = -1;
                textureManager     = manager.MaterialTextureManager;
                statePoolManager   = manager.StateManager;

                MaterialPass        = technique[materialPassName];
                MaterialOITPass     = technique[materialOITPassName];
                ShadowPass          = technique[shadowPassName];
                WireframePass       = technique[wireframePassName];
                WireframeOITPass    = technique[wireframeOITPassName];
                TessellationPass    = technique[tessellationPassName];
                TessellationOITPass = technique[tessellationOITPassName];
                DepthPass           = technique[depthPassName];
                UpdateMappings(MaterialPass);
                EnableTessellation  = materialCore.EnableTessellation;
                currentMaterialPass = EnableTessellation ? TessellationPass : MaterialPass;
                currentOITPass      = EnableTessellation ? TessellationOITPass : MaterialOITPass;
            }
            /// <summary>
            /// Initializes a new instance of the <see cref="PhongMaterialVariables"/> class.
            /// </summary>
            /// <param name="manager">The manager.</param>
            /// <param name="technique">The technique.</param>
            /// <param name="materialCore">The material core.</param>
            /// <param name="defaultPassName">Default pass name</param>
            public PhongMaterialVariables(IEffectsManager manager, IRenderTechnique technique, PhongMaterialCore materialCore,
                                          string defaultPassName = DefaultPassNames.Default)
                : base(manager, technique, DefaultMeshConstantBufferDesc, materialCore)
            {
                this.material      = materialCore;
                texDiffuseSlot     = texAlphaSlot = texDisplaceSlot = texNormalSlot = -1;
                samplerDiffuseSlot = samplerDisplaceSlot = samplerShadowSlot = -1;
                textureManager     = manager.MaterialTextureManager;
                statePoolManager   = manager.StateManager;

                MaterialPass          = technique[defaultPassName];
                OITPass               = technique[DefaultPassNames.OITPass];
                OITDepthPeelingInit   = technique[DefaultPassNames.OITDepthPeelingInit];
                OITDepthPeeling       = technique[DefaultPassNames.OITDepthPeeling];
                ShadowPass            = technique[DefaultPassNames.ShadowPass];
                WireframePass         = technique[DefaultPassNames.Wireframe];
                WireframeOITPass      = technique[DefaultPassNames.WireframeOITPass];
                WireframeOITDPPass    = technique[DefaultPassNames.WireframeOITDPPass];
                TessellationPass      = technique[DefaultPassNames.MeshTriTessellation];
                TessellationOITPass   = technique[DefaultPassNames.MeshTriTessellationOIT];
                TessellationOITDPPass = technique[DefaultPassNames.MeshPBRTriTessellationOITDP];
                DepthPass             = technique[DefaultPassNames.DepthPrepass];
                UpdateMappings(MaterialPass);
                EnableTessellation = materialCore.EnableTessellation;
            }
Example #3
0
            public void UpdateTexture(TextureModel texture, ITextureResourceManager manager)
            {
                var tex = manager.Register(texture, true);

                RemoveAndDispose(ref textureView);
                textureView = tex;
            }
Example #4
0
        public MaterialManager(GraphicsContext gfx)
        {
            if (gfx == null)
            {
                throw new ArgumentNullException("gfx");
            }

            _deviceManager          = gfx.DeviceManager;
            _textureResourceManager = gfx.TextureResourceManager;
            _textureSamplerManager  = gfx.TextureSamplerManager;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LineMaterialVariable"/> class.
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="technique">The technique.</param>
 /// <param name="materialCore">The material core.</param>
 /// <param name="defaultPassName">Default pass name</param>
 public LineMaterialVariable(IEffectsManager manager, IRenderTechnique technique, LineMaterialCore materialCore,
                             string defaultPassName = DefaultPassNames.Default)
     : base(manager, technique, DefaultPointLineConstantBufferDesc, materialCore)
 {
     textureManager     = manager.MaterialTextureManager;
     LinePass           = technique[defaultPassName];
     ShadowPass         = technique[DefaultPassNames.ShadowPass];
     DepthPass          = technique[DefaultPassNames.DepthPrepass];
     this.material      = materialCore;
     shaderTextureSlot  = LinePass.PixelShader.ShaderResourceViewMapping.TryGetBindSlot(ShaderTextureName);
     textureSamplerSlot = LinePass.PixelShader.SamplerMapping.TryGetBindSlot(ShaderTextureSamplerName);
     textureSampler     = EffectsManager.StateManager.Register(materialCore.SamplerDescription);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="material"></param>
 private DiffuseMaterialVariables(IEffectsManager manager, PhongMaterialCore material)
 {
     this.material             = material;
     needUpdate                = true;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texDiffuseSlot            = -1;
     samplerDiffuseSlot        = samplerShadowSlot = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="material"></param>
 public TextureSharedPhongMaterialVariables(IEffectsManager manager, PhongMaterialCore material)
 {
     this.material             = material;
     needUpdate                = true;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texDiffuseSlot            = texAlphaSlot = texDisplaceSlot = texNormalSlot = -1;
     samplerDiffuseSlot        = samplerAlphaSlot = samplerDisplaceSlot = samplerNormalSlot = samplerShadowSlot = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     EnableTessellation    = material.EnableTessellation;
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="modelGuid"></param>
 public TextureSharedPhongMaterialVariables(IEffectsManager manager, Guid modelGuid)
 {
     ModelGuid = modelGuid;
     for (int i = 0; i < Constants.NumShaderStages; ++i)
     {
         TextureBindingMap[i] = new int[NUMTEXTURES];
         SamplerBindingMap[i] = new int[NUMSAMPLERS];
     }
     textureManager   = manager.MaterialTextureManager;
     statePoolManager = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
Example #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="material"></param>
 public ColorStripeMaterialVariables(IEffectsManager manager, ColorStripeMaterialCore material)
 {
     this.material             = material;
     deviceResources           = manager;
     needUpdate                = true;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texStripeXSlot            = texStripeYSlot = -1;
     samplerDiffuseSlot        = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     CreateTextureViews();
     CreateSamplers();
     this.PropertyChanged += (s, e) => { OnInvalidateRenderer?.Invoke(this, EventArgs.Empty); };
 }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="technique"></param>
 /// <param name="material"></param>
 public ColorStripeMaterialVariables(IEffectsManager manager, IRenderTechnique technique, ColorStripeMaterialCore material)
     : base(manager, technique, DefaultMeshConstantBufferDesc)
 {
     this.material             = material;
     deviceResources           = manager;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texStripeXSlot            = texStripeYSlot = -1;
     samplerDiffuseSlot        = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     MaterialPass              = technique[defaultShaderPassName];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="technique"></param>
 /// <param name="material"></param>
 private DiffuseMaterialVariables(IEffectsManager manager, IRenderTechnique technique, PhongMaterialCore material)
     : base(manager, technique, DefaultMeshConstantBufferDesc)
 {
     this.material             = material;
     material.PropertyChanged += Material_OnMaterialPropertyChanged;
     texDiffuseSlot            = -1;
     samplerDiffuseSlot        = samplerShadowSlot = -1;
     textureManager            = manager.MaterialTextureManager;
     statePoolManager          = manager.StateManager;
     MaterialPass              = technique[DefaultShaderPassName];
     TransparentPass           = technique[TransparentPassName];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
 }
Example #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="technique"></param>
 /// <param name="materialCore"></param>
 public ColorStripeMaterialVariables(IEffectsManager manager, IRenderTechnique technique, ColorStripeMaterialCore materialCore)
     : base(manager, technique, DefaultMeshConstantBufferDesc, materialCore)
 {
     this.material      = materialCore;
     deviceResources    = manager;
     texStripeXSlot     = texStripeYSlot = -1;
     samplerDiffuseSlot = -1;
     textureManager     = manager.MaterialTextureManager;
     statePoolManager   = manager.StateManager;
     MaterialPass       = technique[defaultShaderPassName];
     WireframePass      = technique[wireframePassName];
     ShadowPass         = technique[shadowPassName];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
 }
 public PBRMaterialVariable(IEffectsManager manager, IRenderTechnique technique, PBRMaterialCore core)
     : base(manager, technique, DefaultMeshConstantBufferDesc, core)
 {
     textureManager   = manager.MaterialTextureManager;
     statePoolManager = manager.StateManager;
     material         = core;
     MaterialPass     = technique[material.EnableTessellation ? DefaultPassNames.MeshPBRTriTessellation : DefaultPassNames.PBR];
     MaterialOITPass  = technique[material.EnableTessellation ? DefaultPassNames.MeshPBRTriTessellationOIT : DefaultPassNames.PBROITPass];
     WireframePass    = technique[DefaultPassNames.Wireframe];
     WireframeOITPass = technique[DefaultPassNames.WireframeOITPass];
     ShadowPass       = technique[DefaultPassNames.ShadowPass];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
     //EnableTessellation = material.EnableTessellation;
 }
Example #14
0
        public MaterialResource(DeviceManager deviceManager, ITextureResourceManager textureManager, ITextureSamplerManager samplerManager, string id) : base(id)
        {
            if (deviceManager == null)
            {
                throw new ArgumentNullException("deviceManager");
            }
            if (textureManager == null)
            {
                throw new ArgumentNullException("textureManager");
            }
            if (samplerManager == null)
            {
                throw new ArgumentNullException("samplerManager");
            }

            _deviceManager  = deviceManager;
            _textureManager = textureManager;
            _samplerManager = samplerManager;
        }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiffuseMaterialVariables"/> class.
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="technique">The technique.</param>
 /// <param name="materialCore">The material core.</param>
 /// <param name="materialPassName">Name of the material pass.</param>
 /// <param name="wireframePassName">Name of the wireframe pass.</param>
 /// <param name="materialOITPassName">Name of the material oit pass.</param>
 /// <param name="wireframeOITPassName">Name of the wireframe oit pass.</param>
 /// <param name="shadowPassName">Name of the shadow pass.</param>
 private DiffuseMaterialVariables(IEffectsManager manager, IRenderTechnique technique, DiffuseMaterialCore materialCore,
                                  string materialPassName    = DefaultPassNames.Default, string wireframePassName    = DefaultPassNames.Wireframe,
                                  string materialOITPassName = DefaultPassNames.OITPass, string wireframeOITPassName = DefaultPassNames.OITPass,
                                  string shadowPassName      = DefaultPassNames.ShadowPass)
     : base(manager, technique, DefaultMeshConstantBufferDesc, materialCore)
 {
     this.material      = materialCore;
     texDiffuseSlot     = -1;
     samplerDiffuseSlot = samplerShadowSlot = -1;
     textureManager     = manager.MaterialTextureManager;
     statePoolManager   = manager.StateManager;
     MaterialPass       = technique[materialPassName];
     TransparentPass    = technique[materialOITPassName];
     ShadowPass         = technique[shadowPassName];
     WireframePass      = technique[wireframePassName];
     WireframeOITPass   = technique[wireframeOITPassName];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
 }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiffuseMaterialVariables"/> class.
 /// </summary>
 /// <param name="manager">The manager.</param>
 /// <param name="technique">The technique.</param>
 /// <param name="materialCore">The material core.</param>
 /// <param name="defaultPassName"></param>
 private DiffuseMaterialVariables(IEffectsManager manager, IRenderTechnique technique, DiffuseMaterialCore materialCore,
                                  string defaultPassName = DefaultPassNames.Default)
     : base(manager, technique, DefaultMeshConstantBufferDesc, materialCore)
 {
     this.material       = materialCore;
     texDiffuseSlot      = -1;
     samplerDiffuseSlot  = samplerShadowSlot = -1;
     textureManager      = manager.MaterialTextureManager;
     statePoolManager    = manager.StateManager;
     MaterialPass        = technique[defaultPassName];
     OITPass             = technique[DefaultPassNames.DiffuseOIT];
     OITDepthPeelingInit = technique[DefaultPassNames.OITDepthPeelingInit];
     OITDepthPeeling     = technique[DefaultPassNames.DiffuseOITDP];
     ShadowPass          = technique[DefaultPassNames.ShadowPass];
     WireframePass       = technique[DefaultPassNames.Wireframe];
     WireframeOITPass    = technique[DefaultPassNames.WireframeOITPass];
     WireframeOITDPPass  = technique[DefaultPassNames.WireframeOITDPPass];
     DepthPass           = technique[DefaultPassNames.DepthPrepass];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
 }
 public PBRMaterialVariable(IEffectsManager manager, IRenderTechnique technique, PBRMaterialCore core,
                            string materialPassName        = DefaultPassNames.PBR, string wireframePassName = DefaultPassNames.Wireframe,
                            string materialOITPassName     = DefaultPassNames.PBROITPass, string wireframeOITPassName = DefaultPassNames.WireframeOITPass,
                            string shadowPassName          = DefaultPassNames.ShadowPass,
                            string tessellationPassName    = DefaultPassNames.MeshPBRTriTessellation,
                            string tessellationOITPassName = DefaultPassNames.MeshPBRTriTessellationOIT,
                            string depthPassName           = DefaultPassNames.DepthPrepass)
     : base(manager, technique, DefaultMeshConstantBufferDesc, core)
 {
     textureManager   = manager.MaterialTextureManager;
     statePoolManager = manager.StateManager;
     material         = core;
     MaterialPass     = technique[material.EnableTessellation ? tessellationPassName : materialPassName];
     MaterialOITPass  = technique[material.EnableTessellation ? tessellationOITPassName : materialOITPassName];
     WireframePass    = technique[wireframePassName];
     WireframeOITPass = technique[wireframeOITPassName];
     ShadowPass       = technique[shadowPassName];
     DepthPass        = technique[depthPassName];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
 }
Example #18
0
 public PBRMaterialVariable(IEffectsManager manager, IRenderTechnique technique, PBRMaterialCore core,
                            string defaultPassName = DefaultPassNames.PBR)
     : base(manager, technique, DefaultMeshConstantBufferDesc, core)
 {
     textureManager        = manager.MaterialTextureManager;
     statePoolManager      = manager.StateManager;
     material              = core;
     MaterialPass          = technique[defaultPassName];
     OITPass               = technique[DefaultPassNames.PBROITPass];
     OITDepthPeelingInit   = technique[DefaultPassNames.OITDepthPeelingInit];
     OITDepthPeeling       = technique[DefaultPassNames.PBROITDPPass];
     TessellationPass      = technique[DefaultPassNames.MeshPBRTriTessellation];
     TessellationOITPass   = technique[DefaultPassNames.MeshPBRTriTessellationOIT];
     TessellationOITDPPass = technique[DefaultPassNames.MeshPBRTriTessellationOITDP];
     WireframePass         = technique[DefaultPassNames.Wireframe];
     WireframeOITPass      = technique[DefaultPassNames.WireframeOITPass];
     WireframeOITDPPass    = technique[DefaultPassNames.WireframeOITDPPass];
     ShadowPass            = technique[DefaultPassNames.ShadowPass];
     DepthPass             = technique[DefaultPassNames.DepthPrepass];
     UpdateMappings(MaterialPass);
     CreateTextureViews();
     CreateSamplers();
 }
Example #19
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private void Initialize(int adapterIndex)
        {
            Log(LogLevel.Information, $"Adapter Index = {adapterIndex}");
            var adapter = GetAdapter(ref adapterIndex);

            AdapterIndex = adapterIndex;
#if DX11
            if (adapter != null)
            {
                if (adapter.Description.VendorId == 0x1414 && adapter.Description.DeviceId == 0x8c)
                {
                    DriverType = DriverType.Warp;
                    device     = new global::SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_0);
                }
                else
                {
                    DriverType = DriverType.Hardware;
#if DEBUGMEMORY
                    device = new global::SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport | DeviceCreationFlags.Debug);
#else
                    device = new global::SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport);
#if DX11_1
                    device1 = device.QueryInterface <global::SharpDX.Direct3D11.Device1>();
#endif
#endif
                    // DeviceCreationFlags.Debug should not be used in productive mode!
                    // See: http://sharpdx.org/forum/4-general/1774-how-to-debug-a-sharpdxexception
                    // See: http://stackoverflow.com/questions/19810462/launching-sharpdx-directx-app-with-devicecreationflags-debug
                }
            }
#else
            device = new global::SharpDX.Direct3D11.Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_1);
#endif
            Log(LogLevel.Information, $"Direct3D device initilized. DriverType: {DriverType}; FeatureLevel: {device.FeatureLevel}");

            #region Initial Internal Pools
            Log(LogLevel.Information, "Initializing resource pools");
            RemoveAndDispose(ref constantBufferPool);
            constantBufferPool = Collect(new ConstantBufferPool(Device, Logger));

            RemoveAndDispose(ref shaderPoolManager);
            shaderPoolManager = Collect(new ShaderPoolManager(Device, constantBufferPool, Logger));

            RemoveAndDispose(ref statePoolManager);
            statePoolManager = Collect(new StatePoolManager(Device));

            RemoveAndDispose(ref geometryBufferManager);
            geometryBufferManager = Collect(new GeometryBufferManager(this));

            RemoveAndDispose(ref materialTextureManager);
            materialTextureManager = Collect(new TextureResourceManager(Device));

            RemoveAndDispose(ref materialVariableManager);
            materialVariableManager = Collect(new MaterialVariablePool(this));

            RemoveAndDispose(ref deviceContextPool);
            deviceContextPool = Collect(new DeviceContextPool(Device));
            #endregion
            Log(LogLevel.Information, "Initializing Direct2D resources");
            factory2D          = Collect(new global::SharpDX.Direct2D1.Factory1(global::SharpDX.Direct2D1.FactoryType.MultiThreaded));
            wicImgFactory      = Collect(new global::SharpDX.WIC.ImagingFactory());
            directWriteFactory = Collect(new global::SharpDX.DirectWrite.Factory(global::SharpDX.DirectWrite.FactoryType.Shared));
            using (var dxgiDevice2 = device.QueryInterface <global::SharpDX.DXGI.Device>())
            {
                device2D        = Collect(new global::SharpDX.Direct2D1.Device(factory2D, dxgiDevice2));
                deviceContext2D = Collect(new global::SharpDX.Direct2D1.DeviceContext(device2D, global::SharpDX.Direct2D1.DeviceContextOptions.EnableMultithreadedOptimizations));
            }
            Initialized = true;
        }
Example #20
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        private void Initialize(int adapterIndex)
        {
            logger.LogInformation("Adapter Index = {}", adapterIndex);
            var adapter = GetAdapter(ref adapterIndex);

            AdapterIndex = adapterIndex;
            if (AdapterIndex < 0 || adapter == null)
            {
                throw new PlatformNotSupportedException("Graphic adapter does not meet minimum requirement, must support DirectX 10 or above.");
            }
#if DX11
            if (adapter != null)
            {
                DriverType = EnableSoftwareRendering ? DriverType.Warp : DriverType.Hardware;
                if (adapter.Description.VendorId == 0x1414 && adapter.Description.DeviceId == 0x8c)
                {
                    DriverType = DriverType.Warp;
                    device     = EnableSoftwareRendering ?
                                 new global::SharpDX.Direct3D11.Device(DriverType, DeviceCreationFlags.BgraSupport)
                        : new global::SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport);
                }
                else
                {
                    if (DriverType == DriverType.Warp)
                    {
#if DEBUGMEMORY
                        device = new global::SharpDX.Direct3D11.Device(DriverType, DeviceCreationFlags.BgraSupport | DeviceCreationFlags.Debug);
#else
                        device = new global::SharpDX.Direct3D11.Device(DriverType, DeviceCreationFlags.BgraSupport);
#endif
                    }
                    else
                    {
#if DEBUGMEMORY
                        device = new global::SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport | DeviceCreationFlags.Debug);
#else
                        device = new global::SharpDX.Direct3D11.Device(adapter, DeviceCreationFlags.BgraSupport);
#endif
                        // DeviceCreationFlags.Debug should not be used in productive mode!
                        // See: http://sharpdx.org/forum/4-general/1774-how-to-debug-a-sharpdxexception
                        // See: http://stackoverflow.com/questions/19810462/launching-sharpdx-directx-app-with-devicecreationflags-debug
                    }
                }

#if DX11_1
                device1 = device.QueryInterface <global::SharpDX.Direct3D11.Device1>();
#endif
            }
#else
            device = new global::SharpDX.Direct3D11.Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport, FeatureLevel.Level_10_1);
#endif
            logger.LogInformation("Direct3D device initilized. DriverType: {}; FeatureLevel: {}", DriverType, device.FeatureLevel);

            #region Initial Internal Pools
            logger.LogInformation("Initializing resource pools");
            RemoveAndDispose(ref constantBufferPool);
            constantBufferPool = new ConstantBufferPool(Device);

            RemoveAndDispose(ref shaderPoolManager);
            shaderPoolManager = new ShaderPoolManager(Device, constantBufferPool);

            RemoveAndDispose(ref statePoolManager);
            statePoolManager = new StatePoolManager(Device);

            RemoveAndDispose(ref geometryBufferManager);
            geometryBufferManager = new GeometryBufferManager(this);

            RemoveAndDispose(ref materialTextureManager);
            materialTextureManager = new TextureResourceManager(Device);

            RemoveAndDispose(ref materialVariableManager);
            materialVariableManager = new MaterialVariablePool(this);

            RemoveAndDispose(ref deviceContextPool);
            deviceContextPool = new DeviceContextPool(Device);

            RemoveAndDispose(ref structArrayPool);
            structArrayPool = new StructArrayPool();
            #endregion
            logger.LogInformation("Initializing Direct2D resources");
            factory2D          = new global::SharpDX.Direct2D1.Factory1(global::SharpDX.Direct2D1.FactoryType.MultiThreaded);
            wicImgFactory      = new global::SharpDX.WIC.ImagingFactory();
            directWriteFactory = new global::SharpDX.DirectWrite.Factory(global::SharpDX.DirectWrite.FactoryType.Shared);
            using (var dxgiDevice2 = device.QueryInterface <global::SharpDX.DXGI.Device>())
            {
                device2D        = new global::SharpDX.Direct2D1.Device(factory2D, dxgiDevice2);
                deviceContext2D = new global::SharpDX.Direct2D1.DeviceContext(device2D,
                                                                              global::SharpDX.Direct2D1.DeviceContextOptions.EnableMultithreadedOptimizations);
            }
            Initialized = true;
        }
 public MaterialResource(DeviceManager deviceManager, ITextureResourceManager textureManager, ITextureSamplerManager samplerManager, string id)
     : base(id)
 {
     _deviceManager = deviceManager;
     _textureManager = textureManager;
     _samplerManager = samplerManager;
 }