public static unsafe Luid GetDefaultDeviceLuid() { DXGI_ADAPTER_DESC1 dxgiDescription1; _ = TryGetDefaultDevice(null, null, &dxgiDescription1) || TryGetWarpDevice(null, null, &dxgiDescription1); return(Luid.FromLUID(dxgiDescription1.AdapterLuid)); }
/// <summary> /// Creates a new <see cref="GraphicsDeviceInfo"/> instance with the specified parameters. /// </summary> /// <param name="dxgiDescription1">The available info for the associated device.</param> internal unsafe GraphicsDeviceInfo(DXGI_ADAPTER_DESC1 *dxgiDescription1) { Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid); Name = new string((char *)dxgiDescription1->Description); DedicatedMemorySize = dxgiDescription1->DedicatedVideoMemory; SharedMemorySize = dxgiDescription1->SharedSystemMemory; IsHardwareAccelerated = (dxgiDescription1->Flags & (uint)DXGI_ADAPTER_FLAG_SOFTWARE) == 0; }
/// <summary> /// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="ID3D12Device"/>. /// </summary> /// <param name="d3D12Device">The <see cref="ID3D12Device"/> to use for the new <see cref="GraphicsDevice"/> instance.</param> /// <param name="dxgiAdapter">The <see cref="IDXGIAdapter"/> that <paramref name="d3D12Device"/> was created from.</param> /// <param name="dxgiDescription1">The available info for the new <see cref="GraphicsDevice"/> instance.</param> internal GraphicsDevice(ID3D12Device *d3D12Device, IDXGIAdapter *dxgiAdapter, DXGI_ADAPTER_DESC1 *dxgiDescription1) { this.d3D12Device = new ComPtr <ID3D12Device>(d3D12Device); this.d3D12ComputeCommandQueue = d3D12Device->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COMPUTE); this.d3D12CopyCommandQueue = d3D12Device->CreateCommandQueue(D3D12_COMMAND_LIST_TYPE_COPY); this.d3D12ComputeFence = d3D12Device->CreateFence(); this.d3D12CopyFence = d3D12Device->CreateFence(); this.shaderResourceViewDescriptorAllocator = new ID3D12DescriptorHandleAllocator(d3D12Device); this.computeCommandListPool = new ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE_COMPUTE); this.copyCommandListPool = new ID3D12CommandListPool(D3D12_COMMAND_LIST_TYPE_COPY); Luid = Luid.FromLUID(dxgiDescription1->AdapterLuid); Name = new string((char *)dxgiDescription1->Description); DedicatedMemorySize = dxgiDescription1->DedicatedVideoMemory; SharedMemorySize = dxgiDescription1->SharedSystemMemory; IsHardwareAccelerated = (dxgiDescription1->Flags & (uint)DXGI_ADAPTER_FLAG_SOFTWARE) == 0; var d3D12Options1Data = d3D12Device->CheckFeatureSupport <D3D12_FEATURE_DATA_D3D12_OPTIONS1>(D3D12_FEATURE_D3D12_OPTIONS1); ComputeUnits = d3D12Options1Data.TotalLaneCount; WavefrontSize = d3D12Options1Data.WaveLaneCountMin; var d3D12Architecture1Data = d3D12Device->CheckFeatureSupport <D3D12_FEATURE_DATA_ARCHITECTURE1>(D3D12_FEATURE_ARCHITECTURE1); IsCacheCoherentUMA = d3D12Architecture1Data.CacheCoherentUMA != 0; #if NET6_0_OR_GREATER this.allocator = d3D12Device->CreateAllocator(dxgiAdapter); if (IsCacheCoherentUMA) { this.pool = this.allocator.Get()->CreatePoolForCacheCoherentUMA(); } #endif }