virtual void SubmitAndFreeContextContainer(int32 Index, int32 Num) override
	{
		if (Index == 0)
		{
			check((IsInRenderingThread() || IsInRHIThread()));

			OwningDevice->GetDefaultCommandContext().FlushCommands();
		}

		// Add the current lists for execution (now or possibly later)
		for (int32 i = 0; i < CommandLists.Num(); ++i)
		{
			OwningDevice->PendingCommandLists.Add(CommandLists[i]);
			OwningDevice->PendingCommandListsTotalWorkCommands +=
				CommandLists[i].GetCurrentOwningContext()->numClears +
				CommandLists[i].GetCurrentOwningContext()->numCopies +
				CommandLists[i].GetCurrentOwningContext()->numDraws;
		}

		CommandLists.Reset();

		// Submission occurs when a batch is finished
		const bool FinalCommandListInBatch = Index == (Num - 1);
		if (FinalCommandListInBatch && OwningDevice->PendingCommandLists.Num() > 0)
		{
#if SUPPORTS_MEMORY_RESIDENCY
			OwningDevice->GetOwningRHI()->GetResourceResidencyManager().MakeResident();
#endif
			OwningDevice->GetCommandListManager().ExecuteCommandLists(OwningDevice->PendingCommandLists);
			OwningDevice->PendingCommandLists.Reset();
			OwningDevice->PendingCommandListsTotalWorkCommands = 0;
		}

		delete this;
	}
FD3D12CommandListHandle FD3D12CommandContext::FlushCommands(bool WaitForCompletion)
{
	// We should only be flushing the default context
	check(IsDefaultContext());

	FD3D12Device* Device = GetParentDevice();
	const bool bExecutePendingWork = GCommandListBatchingMode == CLB_AggressiveBatching || GetParentDevice()->IsGPUIdle();
	const bool bHasPendingWork = bExecutePendingWork && (Device->PendingCommandListsTotalWorkCommands > 0);
	const bool bHasDoneWork = HasDoneWork() || bHasPendingWork;

	// Only submit a command list if it does meaningful work or the flush is expected to wait for completion.
	if (WaitForCompletion || bHasDoneWork)
	{
#if SUPPORTS_MEMORY_RESIDENCY
		Device->GetOwningRHI()->GetResourceResidencyManager().MakeResident();
#endif
		// Close the current command list
		CloseCommandList();

		if (bHasPendingWork)
		{
			// Submit all pending command lists and the current command list
			Device->PendingCommandLists.Add(CommandListHandle);
			GetCommandListManager().ExecuteCommandLists(Device->PendingCommandLists, WaitForCompletion);
			Device->PendingCommandLists.Reset();
			Device->PendingCommandListsTotalWorkCommands = 0;
		}
		else
		{
			// Just submit the current command list
		CommandListHandle.Execute(WaitForCompletion);
		}

		// Get a new command list to replace the one we submitted for execution. 
		// Restore the state from the previous command list.
		OpenCommandList(true);
	}

	return CommandListHandle;
}