diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h b/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h index ce134dea..4477af27 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12Buffer.h @@ -4,13 +4,14 @@ #include #include "D3D12Enum.h" +#include "../SwapChain.h" using Microsoft::WRL::ComPtr; namespace XCEngine { namespace RHI { -class D3D12Buffer { +class D3D12Buffer : public IBuffer { public: D3D12Buffer(); ~D3D12Buffer(); @@ -24,13 +25,32 @@ public: ID3D12Resource* GetResource() const { return m_resource.Get(); } D3D12_RESOURCE_DESC GetDesc() const { return m_resource->GetDesc(); } - uint64_t GetSize() const { return GetDesc().Width; } D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress() const { return m_resource->GetGPUVirtualAddress(); } void UpdateData(const void* data, uint64_t size); + void* GetNativeHandle() const override { return m_resource.Get(); } + ResourceStates GetState() const override { return m_state; } + void SetState(ResourceStates state) override { m_state = state; } + + uint64_t GetGPUAddress() const override { return m_resource->GetGPUVirtualAddress(); } + size_t GetSize() const override { return GetDesc().Width; } + + const std::string& GetName() const override { return m_name; } + void SetName(const std::string& name) override { m_name = name; } + + uint32_t GetStride() const override { return m_stride; } + BufferType GetBufferType() const override { return m_bufferType; } + + void SetStride(uint32_t stride) { m_stride = stride; } + void SetBufferType(BufferType type) { m_bufferType = type; } + private: ComPtr m_resource; + ResourceStates m_state = ResourceStates::Common; + std::string m_name; + uint32_t m_stride = 0; + BufferType m_bufferType = BufferType::Vertex; }; } // namespace RHI diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12CommandList.h b/engine/include/XCEngine/RHI/D3D12/D3D12CommandList.h index cc5e7a2a..16850c3f 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12CommandList.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12CommandList.h @@ -14,13 +14,6 @@ using Microsoft::WRL::ComPtr; namespace XCEngine { namespace RHI { -struct ResourceBarrierDesc { - ID3D12Resource* resource; - ResourceStates stateBefore; - ResourceStates stateAfter; - uint32_t subresource; -}; - class D3D12CommandList { public: D3D12CommandList(); diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h b/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h index e2de0912..54173835 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12Texture.h @@ -4,13 +4,14 @@ #include #include "D3D12Enum.h" +#include "../SwapChain.h" using Microsoft::WRL::ComPtr; namespace XCEngine { namespace RHI { -class D3D12Texture { +class D3D12Texture : public ITexture { public: D3D12Texture(); ~D3D12Texture(); @@ -29,10 +30,25 @@ public: uint32_t GetHeight() const { return GetDesc().Height; } uint32_t GetDepth() const { return GetDesc().DepthOrArraySize; } uint32_t GetMipLevels() const { return GetDesc().MipLevels; } - DXGI_FORMAT GetFormat() const { return GetDesc().Format; } + + void* GetNativeHandle() const override { return m_resource.Get(); } + ResourceStates GetState() const override { return m_state; } + void SetState(ResourceStates state) override { m_state = state; } + + uint64_t GetGPUAddress() const override { return m_resource->GetGPUVirtualAddress(); } + size_t GetSize() const override { return GetDesc().Width * GetDesc().Height * GetDesc().DepthOrArraySize; } + + const std::string& GetName() const override { return m_name; } + void SetName(const std::string& name) override { m_name = name; } + + uint32_t GetArraySize() const override { return GetDesc().DepthOrArraySize; } + Format GetFormat() const override { return static_cast(GetDesc().Format); } + TextureType GetTextureType() const override { return TextureType::Texture2D; } private: ComPtr m_resource; + ResourceStates m_state = ResourceStates::Common; + std::string m_name; }; } // namespace RHI