#pragma once
#include "DXBuffer.h"

struct ID3D12Resource;
struct ID3D12Device;
struct D3D12_RESOURCE_DESC;
struct ID3D12GraphicsCommandList;

namespace Framework
{
    //! A buffer with data in graphics memory
    class DX12Buffer : public DXBuffer
    {
    protected:
        D3D12_RESOURCE_DESC* description;
        ID3D12Resource* buffer;
        ID3D12Resource* intermediate;
        ID3D12Device* device;
        ID3D12GraphicsCommandList* list;

    public:
        //! Constructor
        //! eSize: The length of an element in bytes
        DLLEXPORT DX12Buffer(int eSize,
            ID3D12Device* device,
            ID3D12GraphicsCommandList* list,
            int bindFlags);
        //! Destructor
        DLLEXPORT virtual ~DX12Buffer();
        //! Copies the data into the buffer if it has changed
        DLLEXPORT virtual void copyToGPU(int byteCount = -1) override;
        //! Returns the buffer
        DLLEXPORT ID3D12Resource* zBuffer() const;
    };

    class DX12IndexBuffer : public DX12Buffer
    {
    private:
        bool ibs;
        DX12DirectCommandQueue* direct;
        DX12CopyCommandQueue* copy;

    public:
        DX12IndexBuffer(int eSize,
            ID3D12Device* device,
            DX12CopyCommandQueue* copy,
            DX12DirectCommandQueue* direct);
        ~DX12IndexBuffer();
        //! Copies the data into the buffer if it has changed
        DLLEXPORT void copyToGPU(int byteCount = -1) override;
    };

    class DX12VertexBuffer : public DX12Buffer
    {
    private:
        bool vbs;
        DX12DirectCommandQueue* direct;
        DX12CopyCommandQueue* copy;

    public:
        DX12VertexBuffer(int eSize,
            ID3D12Device* device,
            DX12CopyCommandQueue* copy,
            DX12DirectCommandQueue* direct);
        ~DX12VertexBuffer();
        //! Copies the data into the buffer if it has changed
        DLLEXPORT void copyToGPU(int byteCount = -1) override;
    };
} // namespace Framework