Make D3D12Texture and D3D12Buffer implement ITexture and IBuffer interfaces
This commit is contained in:
@@ -4,13 +4,14 @@
|
|||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
|
|
||||||
#include "D3D12Enum.h"
|
#include "D3D12Enum.h"
|
||||||
|
#include "../SwapChain.h"
|
||||||
|
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
namespace XCEngine {
|
namespace XCEngine {
|
||||||
namespace RHI {
|
namespace RHI {
|
||||||
|
|
||||||
class D3D12Buffer {
|
class D3D12Buffer : public IBuffer {
|
||||||
public:
|
public:
|
||||||
D3D12Buffer();
|
D3D12Buffer();
|
||||||
~D3D12Buffer();
|
~D3D12Buffer();
|
||||||
@@ -24,13 +25,32 @@ public:
|
|||||||
ID3D12Resource* GetResource() const { return m_resource.Get(); }
|
ID3D12Resource* GetResource() const { return m_resource.Get(); }
|
||||||
D3D12_RESOURCE_DESC GetDesc() const { return m_resource->GetDesc(); }
|
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(); }
|
D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress() const { return m_resource->GetGPUVirtualAddress(); }
|
||||||
|
|
||||||
void UpdateData(const void* data, uint64_t size);
|
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:
|
private:
|
||||||
ComPtr<ID3D12Resource> m_resource;
|
ComPtr<ID3D12Resource> m_resource;
|
||||||
|
ResourceStates m_state = ResourceStates::Common;
|
||||||
|
std::string m_name;
|
||||||
|
uint32_t m_stride = 0;
|
||||||
|
BufferType m_bufferType = BufferType::Vertex;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RHI
|
} // namespace RHI
|
||||||
|
|||||||
@@ -14,13 +14,6 @@ using Microsoft::WRL::ComPtr;
|
|||||||
namespace XCEngine {
|
namespace XCEngine {
|
||||||
namespace RHI {
|
namespace RHI {
|
||||||
|
|
||||||
struct ResourceBarrierDesc {
|
|
||||||
ID3D12Resource* resource;
|
|
||||||
ResourceStates stateBefore;
|
|
||||||
ResourceStates stateAfter;
|
|
||||||
uint32_t subresource;
|
|
||||||
};
|
|
||||||
|
|
||||||
class D3D12CommandList {
|
class D3D12CommandList {
|
||||||
public:
|
public:
|
||||||
D3D12CommandList();
|
D3D12CommandList();
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
|
|
||||||
#include "D3D12Enum.h"
|
#include "D3D12Enum.h"
|
||||||
|
#include "../SwapChain.h"
|
||||||
|
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
namespace XCEngine {
|
namespace XCEngine {
|
||||||
namespace RHI {
|
namespace RHI {
|
||||||
|
|
||||||
class D3D12Texture {
|
class D3D12Texture : public ITexture {
|
||||||
public:
|
public:
|
||||||
D3D12Texture();
|
D3D12Texture();
|
||||||
~D3D12Texture();
|
~D3D12Texture();
|
||||||
@@ -29,10 +30,25 @@ public:
|
|||||||
uint32_t GetHeight() const { return GetDesc().Height; }
|
uint32_t GetHeight() const { return GetDesc().Height; }
|
||||||
uint32_t GetDepth() const { return GetDesc().DepthOrArraySize; }
|
uint32_t GetDepth() const { return GetDesc().DepthOrArraySize; }
|
||||||
uint32_t GetMipLevels() const { return GetDesc().MipLevels; }
|
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<Format>(GetDesc().Format); }
|
||||||
|
TextureType GetTextureType() const override { return TextureType::Texture2D; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ComPtr<ID3D12Resource> m_resource;
|
ComPtr<ID3D12Resource> m_resource;
|
||||||
|
ResourceStates m_state = ResourceStates::Common;
|
||||||
|
std::string m_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RHI
|
} // namespace RHI
|
||||||
|
|||||||
Reference in New Issue
Block a user