protected override void PlatformDispose() { // Dispose staging buffers foreach (DeviceBuffer buffer in _availableStagingBuffers) { buffer.Dispose(); } _availableStagingBuffers.Clear(); _d3d11ResourceFactory.Dispose(); _mainSwapchain?.Dispose(); _immediateContext.Dispose(); ID3D11Debug deviceDebug = _device.QueryInterfaceOrNull <ID3D11Debug>(); _device.Dispose(); _dxgiAdapter?.Dispose(); // Need to enable native debugging to see live objects in VisualStudio console. if (deviceDebug != null) { deviceDebug.ReportLiveDeviceObjects(ReportLiveDeviceObjectFlags.Summary | ReportLiveDeviceObjectFlags.Detail | ReportLiveDeviceObjectFlags.IgnoreInternal); deviceDebug.Dispose(); } }
protected override void PlatformDispose() { // Dispose staging buffers foreach (DeviceBuffer buffer in _availableStagingBuffers) { buffer.Dispose(); } _availableStagingBuffers.Clear(); _d3d11ResourceFactory.Dispose(); _mainSwapchain?.Dispose(); _immediateContext.Dispose(); ID3D11Debug deviceDebug = _device.QueryInterfaceOrNull <ID3D11Debug>(); _device.Dispose(); _dxgiAdapter.Dispose(); // Report live objects using DXGI if available (DXGIGetDebugInterface1 will fail on pre Windows 8 OS). if (VorticeDXGI.DXGIGetDebugInterface1(out IDXGIDebug1 dxgiDebug).Success) { deviceDebug?.Dispose(); dxgiDebug.ReportLiveObjects(VorticeDXGI.All, ReportLiveObjectFlags.Summary | ReportLiveObjectFlags.IgnoreInternal); dxgiDebug.Dispose(); }
protected override void PlatformDispose() { _d3d11ResourceFactory.Dispose(); _mainSwapchain?.Dispose(); _immediateContext.Dispose(); IDXGIDebug deviceDebug = _device.QueryInterfaceOrNull <IDXGIDebug>(); _device.Dispose(); _dxgiAdapter?.Dispose(); if (deviceDebug != null) { deviceDebug.ReportLiveObjects(DXGI.All, ReportLiveObjectFlags.Summary); deviceDebug.ReportLiveObjects(DXGI.All, ReportLiveObjectFlags.Detail); deviceDebug.Dispose(); } }
public DeviceD3D11(IDXGIFactory1 factory, bool validation) { DXGIFactory = factory; var adapters = DXGIFactory.EnumAdapters1(); for (var i = 0; i < adapters.Length; i++) { var adapter = adapters[0]; var desc = adapter.Description1; // Don't select the Basic Render Driver adapter. if ((desc.Flags & AdapterFlags.Software) != AdapterFlags.None) { continue; } var creationFlags = DeviceCreationFlags.BgraSupport /* | DeviceCreationFlags.VideoSupport*/; if (validation) { creationFlags |= DeviceCreationFlags.Debug; } if (D3D11CreateDevice( null, DriverType.Hardware, creationFlags, s_featureLevels, out D3D11Device, out FeatureLevel, out D3D11DeviceContext).Failure) { // Remove debug flag not being supported. creationFlags &= ~DeviceCreationFlags.Debug; if (D3D11CreateDevice(null, DriverType.Hardware, creationFlags, s_featureLevels, out D3D11Device, out FeatureLevel, out D3D11DeviceContext).Failure) { throw new GraphicsException("Cannot create D3D11 Device"); } } DXGIAdapter = adapter; break; } D3D11Device1 = D3D11Device.QueryInterfaceOrNull <ID3D11Device1>(); // Detect multithreading FeatureDataThreading featureDataThreading = default; if (D3D11Device.CheckFeatureSupport(DirectX.Direct3D11.Feature.Threading, ref featureDataThreading)) { SupportsConcurrentResources = featureDataThreading.DriverConcurrentCreates; SupportsCommandLists = featureDataThreading.DriverCommandLists; } // Init device features. InitializeFeatures(); // Create command queue's. _graphicsCommandQueue = new CommandQueueD3D11(this, D3D11DeviceContext); _computeCommandQueue = new CommandQueueD3D11(this, CommandQueueType.Compute); _copyCommandQueue = new CommandQueueD3D11(this, CommandQueueType.Copy); }