#pragma once

#include <wrl.h>
#include <d3d12.h>

class DirectXDescriptors
{
public:
    UINT getRtvDescriptorSize() const;
    D3D12_CPU_DESCRIPTOR_HANDLE getRtvHandle(int index = -1) const;
    D3D12_CPU_DESCRIPTOR_HANDLE getDsvHandle() const;

    void setupDefaultDescriptorHeaps(ID3D12Device* device, unsigned numFrames = 2);
private:
    void updateDescriptorSizes(ID3D12Device* device);
    void setupRtvDescriptorHeap(ID3D12Device* device, unsigned numFrames);
    void setupDsvDescriptorHeap(ID3D12Device* device);
    void setupSrvDescriptorHeap(ID3D12Device* device);
    void setupCbvDescriptorHeap(ID3D12Device* device);

    UINT mRtvDescriptorSize{ 0 };
    UINT mDsvDescriptorSize{ 0 };
    UINT mCbvSrvDescriptorSize{ 0 };

    Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mRtvHeap;
    Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mDsvHeap;
    Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mSrvHeap;
    Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mCbvHeap;
};