#include "DirectXCommandList.h"

#include <d3d12.h>

void DirectXCommandList::close()
{
	mCommandList->Close();
}

void DirectXCommandList::create(ID3D12Device* device, ID3D12PipelineState* pso)
{
	device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&mCommandAllocator));
	device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, mCommandAllocator.Get(), pso, IID_PPV_ARGS(&mCommandList));
	mCommandList->Close();
}

ID3D12GraphicsCommandList* DirectXCommandList::get() const
{
	return mCommandList.Get();
}

void DirectXCommandList::execute(ID3D12CommandQueue* queue)
{
	ID3D12CommandList* ppCommandLists[] = { mCommandList.Get() };
	queue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists);
}

void DirectXCommandList::reset(ID3D12PipelineState* pso)
{
	mCommandList->Reset(mCommandAllocator.Get(), pso);
}

void DirectXCommandList::resetAllocator()
{
	mCommandAllocator->Reset();
}

