/// <inheritdoc/> public CommandList(GraphicsDevice device, CommandListType commandListType) : base(device, commandListType) { CommandAllocator = CommandListType switch { CommandListType.Compute => GraphicsDevice.ComputeAllocatorPool.GetCommandAllocator(), CommandListType.Copy => GraphicsDevice.CopyAllocatorPool.GetCommandAllocator(), CommandListType.Direct => GraphicsDevice.DirectAllocatorPool.GetCommandAllocator(), _ => throw new NotSupportedException($"Unsupported command list type with value {CommandListType}") }; Result result = GraphicsDevice.NativeDevice.CreateCommandList(0, commandListType, CommandAllocator, null, out ID3D12GraphicsCommandList? nativeCommandList); if (result.Failure) { throw new COMException("Failed to create the commands list", result.Code); } NativeCommandList = nativeCommandList !; // Set the heap descriptor if the command list is not for copy operations if (CommandListType != CommandListType.Copy) { NativeCommandList.SetDescriptorHeaps(1, new[] { GraphicsDevice.ShaderResourceViewAllocator.DescriptorHeap }); } }
/// <inheritdoc/> public CommandList(GraphicsDevice device, CommandListType commandListType) : base(device, commandListType) { CommandAllocator = CommandListType switch { CommandListType.Compute => GraphicsDevice.ComputeAllocatorPool.GetCommandAllocator(), CommandListType.Copy => GraphicsDevice.CopyAllocatorPool.GetCommandAllocator(), CommandListType.Direct => GraphicsDevice.DirectAllocatorPool.GetCommandAllocator(), _ => throw new NotSupportedException($"Unsupported command list type with value {CommandListType}") }; NativeCommandList = GraphicsDevice.NativeDevice.CreateCommandList(CommandListType, CommandAllocator, null); // Set the heap descriptor if the command list is not for copy operations if (CommandListType != CommandListType.Copy) { NativeCommandList.SetDescriptorHeaps(1, new[] { GraphicsDevice.ShaderResourceViewAllocator.DescriptorHeap }); } }