1#ifndef DIRECTX12TEXTURE_HPP_
2#define DIRECTX12TEXTURE_HPP_
10#include <wrl/client.h>
17class ENGINE_API DirectX12Texture :
public Texture {
20 DirectX12Texture(ID3D12Device* device, ID3D12CommandQueue* commandQueue,
21 ID3D12GraphicsCommandList* commandList =
nullptr,
22 DirectX12UploadContext* uploader =
nullptr);
23 ~DirectX12Texture()
override;
26 bool LoadFromMemory(
const void* data, uint32_t
width, uint32_t
height,
27 TextureFormat format)
override;
29 bool LoadFromFile(
const std::string& filePath)
override;
31 void Bind(uint32_t slot = 0)
const override;
32 void Unbind()
const override;
34 void SetFilter(TextureFilter filter)
override;
35 void SetWrapMode(TextureWrapMode wrapMode)
override;
37 uint32_t GetWidth()
const override {
return m_width; }
38 uint32_t GetHeight()
const override {
return m_height; }
40 TextureType GetType()
const override {
return TextureType::Texture2D; }
42 uint64_t GetImGuiTextureID()
const override {
return m_srvGpuHandle.ptr; }
44 ID3D12Resource* GetResource()
const {
return m_texture.Get(); }
48 void BindToCommandList(ID3D12GraphicsCommandList* cmdList,
49 UINT rootParameterIndex)
const;
52 void SetSharedSrvGPUHandle(D3D12_GPU_DESCRIPTOR_HANDLE handle) {
53 m_srvGpuHandle = handle;
54 m_usesSharedHeap =
true;
58 bool CreateSRVIntoHandle(DXGI_FORMAT format, D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle);
62 bool CreateTextureResource(uint32_t
width, uint32_t
height,
65 bool UploadTextureData(
const void* data, uint32_t
width,
68 bool CreateSRV(DXGI_FORMAT format);
70 DXGI_FORMAT GetDXGIFormat(TextureFormat format)
const;
72 ID3D12Device* m_device =
nullptr;
73 ID3D12CommandQueue* m_commandQueue =
nullptr;
74 ID3D12GraphicsCommandList* m_commandList =
nullptr;
75 DirectX12UploadContext* m_uploader =
nullptr;
77 Microsoft::WRL::ComPtr<ID3D12Resource> m_texture;
78 Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> m_srvHeap;
79 D3D12_GPU_DESCRIPTOR_HANDLE m_srvGpuHandle = {};
80 bool m_usesSharedHeap =
false;
83 uint32_t m_height = 0;
84 uint32_t m_mipLevels = 1;
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.