/// <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 }); } }
public T CreateCommandList1 <T>(CommandListType type, CommandListFlags commandListFlags = CommandListFlags.None) where T : ID3D12GraphicsCommandList1 { Result result = CreateCommandList1(0, type, commandListFlags, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) { return(default);
/// <summary> /// The AllocateContext /// </summary> /// <param name="type">The <see cref="CommandListType"/></param> /// <returns>The <see cref="CommandContext"/></returns> public CommandContext AllocateContext(CommandListType type) { lock (_ContextAllocationMutex) { var availableContexts = _AvailableContexts[(int)type]; CommandContext ret = null; if (availableContexts.Count == 0) { ret = new CommandContext(type); _ContextPool[(int)type].Add(ret); ret.Initialize(); } else { ret = availableContexts.Peek(); availableContexts.Dequeue(); ret.Reset(); } Debug.Assert(ret != null); Debug.Assert(ret._Type == type); return(ret); } }
/// <summary> /// The CreateCommandList /// </summary> /// <param name="type">The <see cref="CommandListType"/></param> /// <param name="list">The <see cref="GraphicsCommandList"/></param> /// <param name="allocator">The <see cref="CommandAllocator"/></param> public void CreateNewCommandList(CommandListType type, out GraphicsCommandList list, out CommandAllocator allocator) { Debug.Assert(type != CommandListType.Bundle, "Bundles are not yet supported"); CommandAllocator tempAllocatorRef = null; switch (type) { case CommandListType.Direct: tempAllocatorRef = _GraphicsQueue.RequestAllocator(); break; case CommandListType.Bundle: break; case CommandListType.Compute: tempAllocatorRef = _ComputeQueue.RequestAllocator(); break; case CommandListType.Copy: tempAllocatorRef = _CopyQueue.RequestAllocator(); break; } list = _Device.CreateCommandList(type, tempAllocatorRef, null); list.Name = "CommandList"; allocator = tempAllocatorRef; Debug.Assert(list != null); }
/// <summary> /// Initializes a new instance of the <see cref="CommandQueueDescription"/> struct. /// </summary> /// <param name="type">The queue type.</param> /// <param name="priority">The priority.</param> /// <param name="flags">Options flags.</param> /// <param name="nodeMask">Node mask.</param> public CommandQueueDescription(CommandListType type, CommandQueuePriority priority, CommandQueueFlags flags = CommandQueueFlags.None, int nodeMask = 0) { Type = type; Priority = (int)priority; Flags = flags; NodeMask = nodeMask; }
public CommandQueueDescription(CommandListType type, CommandQueueFlags flags = CommandQueueFlags.None) { Type = type; Priority = 0; Flags = flags; NodeMask = 0; }
public CommandQueue(GraphicsDevice device, CommandListType type) : base(device) { Type = type; Recreate(); Queue = CreateCommandQueueDirect(); }
public ID3D12GraphicsCommandList CreateCommandList(int nodeMask, CommandListType type, ID3D12CommandAllocator commandAllocator, ID3D12PipelineState initialState = null) { Guard.NotNull(commandAllocator, nameof(commandAllocator)); var nativePtr = CreateCommandList(nodeMask, type, commandAllocator, initialState, typeof(ID3D12GraphicsCommandList).GUID); return(new ID3D12GraphicsCommandList(nativePtr)); }
/// <summary> /// Initializes a new instance of the <see cref="CommandContext"/> class. /// </summary> /// <param name="type">The <see cref="CommandListType"/></param> private CommandContext(CommandListType type) { _Type = type; _DynamicViewDescriptorHeap = new DynamicDescriptorHeap(this, DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView); _DynamicSamplerDescriptorHeap = new DynamicDescriptorHeap(this, DescriptorHeapType.Sampler); _CpuLinearAllocator = new LinearAllocator(ELinearAllocatorType.CpuWritable); _GpuLinearAllocator = new LinearAllocator(ELinearAllocatorType.GpuExclusive); }
public CommandQueueDescription( CommandListType type, int nodeMask) { Type = type; Priority = 0; Flags = CommandQueueFlags.None; NodeMask = nodeMask; }
/// <summary> /// Initializes a new instance of the <see cref="CCommandQueue"/> class. /// </summary> /// <param name="type">The <see cref="CommandListType"/></param> public CCommandQueue(CommandListType type) { _Type = type; _CommandQueue = null; _Fence = null; _NextFenceValue = (long)_Type << 56 | 1; _LastCompletedFenceValue = (long)_Type << 56; _AllocatorPool = new CommandAllocatorPool(_Type); }
public CommandBufferD3D12(CommandQueueD3D12 queue, CommandListType type) : base(queue) { var d3d12Device = ((D3D12GraphicsDevice)queue.Device).D3D12Device; _commandAllocator = d3d12Device.CreateCommandAllocator(type); CommandList = d3d12Device.CreateCommandList(type, _commandAllocator, null); _type = type; }
public CommandListSingleAllocationPolicy(CommandListType type, Device device) { var allocatorDesc = new CommandAllocator.Descriptor() { Type = type }; Allocator = device.Create(ref allocatorDesc); Allocator.AddRef(); }
public CommandList(GraphicsDevice device, CommandListType commandListType) { GraphicsDevice = device; CommandListType = commandListType; NativeCommandAllocator = GraphicsDevice.NativeDevice.CreateCommandAllocator((Vortice.Direct3D12.CommandListType)CommandListType); NativeCommandList = GraphicsDevice.NativeDevice.CreateCommandList((Vortice.Direct3D12.CommandListType)CommandListType, NativeCommandAllocator, null); SetDescriptorHeaps(GraphicsDevice.ShaderVisibleShaderResourceViewAllocator, GraphicsDevice.ShaderVisibleSamplerAllocator); }
/// <summary> /// The Queue /// </summary> /// <param name="type">The <see cref="CommandListType"/></param> /// <returns>The <see cref="CCommandQueue"/></returns> public CCommandQueue Queue(CommandListType type = CommandListType.Direct) { switch (type) { case CommandListType.Compute: return(_ComputeQueue); case CommandListType.Copy: return(_CopyQueue); default: return(_GraphicsQueue); } }
public CommandList(GraphicsDevice device, CommandListType commandListType) { GraphicsDevice = device; CommandListType = commandListType; ID3D12CommandAllocator commandAllocator = GetCommandAllocator(); ID3D12GraphicsCommandList nativeCommandList = GraphicsDevice.NativeDevice.CreateCommandList((Vortice.Direct3D12.CommandListType)CommandListType, commandAllocator, null); currentCommandList = new CompiledCommandList(this, commandAllocator, nativeCommandList); SetDescriptorHeaps(GraphicsDevice.ShaderVisibleShaderResourceViewAllocator, GraphicsDevice.ShaderVisibleSamplerAllocator); }
public Result CreateCommandList1 <T>(int nodeMask, CommandListType type, CommandListFlags commandListFlags, out T?commandList) where T : ID3D12GraphicsCommandList1 { Result result = CreateCommandList1(nodeMask, type, commandListFlags, typeof(T).GUID, out IntPtr nativePtr); if (result.Failure) { commandList = default; return(result); } commandList = MarshallingHelpers.FromPointer <T>(nativePtr); return(result); }
public static dynamic ByType(CommandListType type) { switch (type) { case CommandListType.FLOW: return(new CommandList <FlowCommand>()); case CommandListType.ANIMATION: return(new CommandList <AnimationCommand>()); case CommandListType.TRANSITION: return(new CommandList <TransitionCommand>()); case CommandListType.STATE: return(new CommandList <StateCommand>()); case CommandListType.SPEED: return(new CommandList <SpeedCommand>()); case CommandListType.PHYSICS: return(new CommandList <PhysicsCommand>()); case CommandListType.CANCELS: return(new CommandList <CancelCommand>()); case CommandListType.HURTBOX: return(new CommandList <HurtboxCommand>()); case CommandListType.ETC: return(new CommandList <EtcCommand>()); case CommandListType.HITBOX: return(new CommandList <HitboxCommand>()); case CommandListType.INVINC: return(new CommandList <HurtNodeCommand>()); case CommandListType.TARGETLOCK: return(new CommandList <TargetLockCommand>()); case CommandListType.SFX: return(new CommandList <SfxCommand>()); default: return(new CommandList <BaseCommand>()); } }
/// <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 }); } }
public DXGraphicsCommandListPool(DXGraphicsHost graphicsHost, CommandAllocator allocator, CommandListType type, string debugName = "CMDLIST") : base() { if (graphicsHost == null) { throw new ArgumentNullException(nameof(graphicsHost)); } if (allocator == null) { throw new ArgumentNullException(nameof(allocator)); } this.graphicsHost = graphicsHost; this.allocator = allocator; this.type = type; this.debugName = debugName; this.spareObjects = new ConcurrentBag <GraphicsCommandList>(); }
public CommandListInFlightFrameAllocationPolicy(CommandListType type, SwapChain swapChain) { var allocatorDesc = new CommandAllocator.Descriptor() { Type = type }; PerInflightFrameAllocators = new CommandAllocator[swapChain.Desc.MaxFramesInFlight]; for (int i = 0; i < swapChain.Desc.MaxFramesInFlight; ++i) { PerInflightFrameAllocators[i] = swapChain.Device.Create(ref allocatorDesc); PerInflightFrameAllocators[i].AddRef(); } swapChain.OnBeginFrame += SetActiveAllocator; swapChain.AddRef(); // Swap chain is not allowed to die earlier than this object. this.swapChain = swapChain; }
private void PlatformConstruct(GraphicsDevice graphicsDevice) { const CommandListType commandListType = CommandListType.Direct; var device = graphicsDevice.Device; DeviceCommandQueue = AddDisposable(device.CreateCommandQueue(new CommandQueueDescription(commandListType))); _fence = AddDisposable(device.CreateFence(0, FenceFlags.None)); _fenceEvent = AddDisposable(new AutoResetEvent(false)); _allocatorPool = AddDisposable(new CommandAllocatorPool(graphicsDevice, commandListType)); _nextFenceValue = 1; _commandBuffer = AddDisposable(new CommandBuffer(graphicsDevice, this)); }
public T CreateCommandList1 <T>(CommandListType type, CommandListFlags commandListFlags = CommandListFlags.None) where T : ID3D12GraphicsCommandList1 { CreateCommandList1(0, type, commandListFlags, typeof(T).GUID, out IntPtr nativePtr).CheckError(); return(MarshallingHelpers.FromPointer <T>(nativePtr)); }
public Result CreateCommandList1 <T>(CommandListType type, CommandListFlags commandListFlags, out T?commandList) where T : ID3D12GraphicsCommandList1 { return(CreateCommandList1 <T>(0, type, commandListFlags, out commandList)); }
public void AddInfo(BaseCommand cmd, CommandListType type, EventType et) { switch (type) { case CommandListType.FLOW: var flow = (FlowCommand)cmd; this.Flow = AppendString(this.Flow, flow.Type + ":" + flow.TargetScript.Name, et); return; case CommandListType.ANIMATION: var anim = (AnimationCommand)cmd; var animName = new IndexReferenceTypeConverter().Convert( new object[] { anim.Type, anim.Animation }, null, null, null); this.Animation = AppendString(this.Animation, anim.Type + ":" + animName, et); return; case CommandListType.TRANSITION: var transition = (TransitionCommand)cmd; this.Transition = AppendString(this.Transition, string.Join("/", transition.Flag1, transition.Flag2), et); return; case CommandListType.STATE: var state = (StateCommand)cmd; this.State = AppendString(this.State, state.Flags.ToString(), et); return; case CommandListType.SPEED: var speed = (SpeedCommand)cmd; this.Speed = AppendString(this.Speed, speed.Multiplier + "x", et); return; case CommandListType.PHYSICS: var physics = (PhysicsCommand)cmd; this.Physics = AppendString(this.Physics, physics.PhysicsFlags.ToString(), et); return; case CommandListType.CANCELS: var cancel = (CancelCommand)cmd; this.Cancels = AppendString(this.Cancels, cancel.Condition + ":" + cancel.CancelList, et); return; case CommandListType.HITBOX: var hitbox = (HitboxCommand)cmd; string str = hitbox.Type == HitboxCommand.HitboxType.PROXIMITY ? "PROX" : "#" + hitbox.HitboxDataSet.Index; this.Hitbox = AppendString(this.Hitbox, str, et); return; case CommandListType.INVINC: var invinc = (HurtNodeCommand)cmd; this.Invinc = AppendString(this.Invinc, invinc.Flags.ToString(), et); return; case CommandListType.HURTBOX: var hurtbox = (HurtboxCommand)cmd; this.Hurtbox = AppendString(this.Hurtbox, string.Format("{0},{1}/{2},{3}", hurtbox.X, hurtbox.Y, hurtbox.Width, hurtbox.Height), et); return; case CommandListType.ETC: var etc = (EtcCommand)cmd; this.Etc = AppendString(this.Etc, string.Join("/", etc.Type, etc.ShortParam, etc.Unknown00, etc.Unknown01), et); return; case CommandListType.TARGETLOCK: var dmgAnim = (TargetLockCommand)cmd; this.TgtLock = AppendString(this.TgtLock, dmgAnim.Type + ":" + dmgAnim.DmgScript, et); return; case CommandListType.SFX: var sfx = (SfxCommand)cmd; this.Sfx = AppendString(this.Sfx, sfx.Type + ":" + sfx.Sound, et); return; default: throw new InvalidOperationException(); } }
public CommandQueueDescription(CommandListType type, CommandQueueFlags flags = CommandQueueFlags.None) : this() { Type = type; Flags = flags; }
public ID3D12GraphicsCommandList1 CreateCommandList1(CommandListType type, CommandListFlags commandListFlags = CommandListFlags.None) { return(CreateCommandList1(0, type, commandListFlags, typeof(ID3D12GraphicsCommandList1).GUID)); }
public ID3D12GraphicsCommandList CreateCommandList(CommandListType type, ID3D12CommandAllocator commandAllocator, ID3D12PipelineState initialState = null) { return(CreateCommandList(0, type, commandAllocator, initialState)); }
public ID3D12CommandAllocator CreateCommandAllocator(CommandListType type) { return(CreateCommandAllocator(type, typeof(ID3D12CommandAllocator).GUID)); }
public CommandQueue(GraphicsDevice device, CommandListType commandListType) { GraphicsDevice = device; NativeCommandQueue = GraphicsDevice.NativeDevice.CreateCommandQueue(new CommandQueueDescription((Vortice.Direct3D12.CommandListType)commandListType)); Fence = GraphicsDevice.NativeDevice.CreateFence(0); }
/// <summary> /// Initializes a new instance of the <see cref="CommandAllocatorPool"/> class. /// </summary> /// <param name="type">The <see cref="CommandListType"/></param> public CommandAllocatorPool(CommandListType type) { _Type = type; }
public CommandListSingleAllocationPolicy(CommandListType type, Device device) { var allocatorDesc = new CommandAllocator.Descriptor() {Type = type}; Allocator = device.Create(ref allocatorDesc); Allocator.AddRef(); }