- D3D12Device, D3D12CommandQueue, D3D12CommandAllocator, D3D12Fence - D3D12DescriptorHeap, D3D12QueryHeap, D3D12RootSignature - D3D12PipelineState, D3D12Sampler, D3D12Shader - D3D12Buffer, D3D12Texture, D3D12SwapChain All D3D12 backend classes now directly use D3D12 APIs without going through RHI interface abstraction. This decouples the D3D12 backend from the RHI abstraction layer. Test: D3D12 rendering test passed (screenshot comparison 100% match)
58 lines
1.9 KiB
C++
58 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <d3d12.h>
|
|
#include <wrl/client.h>
|
|
|
|
#include "D3D12Enum.h"
|
|
#include "../SwapChain.h"
|
|
|
|
using Microsoft::WRL::ComPtr;
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
class D3D12Buffer {
|
|
public:
|
|
D3D12Buffer();
|
|
~D3D12Buffer();
|
|
|
|
bool Initialize(ID3D12Device* device, uint64_t size, D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_COMMON, D3D12_HEAP_TYPE heapType = D3D12_HEAP_TYPE_DEFAULT);
|
|
bool InitializeFromExisting(ID3D12Resource* resource);
|
|
bool InitializeWithData(ID3D12Device* device, ID3D12GraphicsCommandList* commandList,
|
|
const void* data, uint64_t size, D3D12_RESOURCE_STATES finalState);
|
|
void Shutdown();
|
|
|
|
ID3D12Resource* GetResource() const { return m_resource.Get(); }
|
|
D3D12_RESOURCE_DESC GetDesc() const { return m_resource->GetDesc(); }
|
|
|
|
D3D12_GPU_VIRTUAL_ADDRESS GetGPUVirtualAddress() const { return m_resource->GetGPUVirtualAddress(); }
|
|
|
|
void UpdateData(const void* data, uint64_t size);
|
|
|
|
void* GetNativeHandle() const { return m_resource.Get(); }
|
|
ResourceStates GetState() const { return m_state; }
|
|
void SetState(ResourceStates state) { m_state = state; }
|
|
|
|
uint64_t GetGPUAddress() const { return m_resource->GetGPUVirtualAddress(); }
|
|
size_t GetSize() const { return GetDesc().Width; }
|
|
|
|
const std::string& GetName() const { return m_name; }
|
|
void SetName(const std::string& name) { m_name = name; }
|
|
|
|
uint32_t GetStride() const { return m_stride; }
|
|
BufferType GetBufferType() const { return m_bufferType; }
|
|
|
|
void SetStride(uint32_t stride) { m_stride = stride; }
|
|
void SetBufferType(BufferType type) { m_bufferType = type; }
|
|
|
|
private:
|
|
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 XCEngine
|