1#ifndef DIRECTX12TEXTURE_HPP_
2#define DIRECTX12TEXTURE_HPP_
10#include <wrl/client.h>
16class ENGINE_API DirectX12Texture :
public Texture {
18 DirectX12Texture(ID3D12Device* device,
19 ID3D12CommandQueue* commandQueue,
20 ID3D12GraphicsCommandList* commandList =
nullptr);
21 ~DirectX12Texture()
override;
24 bool LoadFromMemory(
const void* data, uint32_t
width, uint32_t
height,
25 TextureFormat format)
override;
27 bool LoadFromFile(
const std::string& filePath)
override;
29 void Bind(uint32_t slot = 0)
const override;
30 void Unbind()
const override;
32 void SetFilter(TextureFilter filter)
override;
33 void SetWrapMode(TextureWrapMode wrapMode)
override;
35 uint32_t GetWidth()
const override {
return m_width; }
36 uint32_t GetHeight()
const override {
return m_height; }
38 TextureType GetType()
const override {
return TextureType::Texture2D; }
40 uint64_t GetImGuiTextureID()
const override {
return m_srvGpuHandle.ptr; }
42 ID3D12Resource* GetResource()
const {
return m_texture.Get(); }
46 void BindToCommandList(ID3D12GraphicsCommandList* cmdList,
47 UINT rootParameterIndex)
const;
50 void SetSharedSrvGPUHandle(D3D12_GPU_DESCRIPTOR_HANDLE handle) { m_srvGpuHandle = handle; m_usesSharedHeap =
true; }
53 bool CreateSRVIntoHandle(DXGI_FORMAT format, D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle);
57 bool CreateTextureResource(uint32_t
width, uint32_t
height,
60 bool UploadTextureData(
const void* data, uint32_t
width,
63 bool CreateSRV(DXGI_FORMAT format);
65 DXGI_FORMAT GetDXGIFormat(TextureFormat format)
const;
69 ID3D12Device* m_device =
nullptr;
70 ID3D12CommandQueue* m_commandQueue =
nullptr;
71 ID3D12GraphicsCommandList* m_commandList =
nullptr;
73 Microsoft::WRL::ComPtr<ID3D12Resource> m_texture;
74 Microsoft::WRL::ComPtr<ID3D12Resource> m_uploadBuffer;
75 Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> m_srvHeap;
76 D3D12_GPU_DESCRIPTOR_HANDLE m_srvGpuHandle = {};
77 bool m_usesSharedHeap =
false;
80 uint32_t m_height = 0;
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.