#pragma once #ifndef NOMINMAX #define NOMINMAX #endif #include #include #include #include #include #include #include #include #include namespace XCEngine::UI::Editor::Host { class D3D12ShaderResourceDescriptorAllocator { public: bool Initialize(::XCEngine::RHI::RHIDevice& device, UINT descriptorCount = 64u); void Shutdown(); bool IsInitialized() const; ID3D12DescriptorHeap* GetDescriptorHeap() const; UINT GetDescriptorSize() const; UINT GetDescriptorCount() const; void Allocate( D3D12_CPU_DESCRIPTOR_HANDLE* outCpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE* outGpuHandle); bool CreateTextureDescriptor( ::XCEngine::RHI::RHITexture* texture, D3D12_CPU_DESCRIPTOR_HANDLE* outCpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE* outGpuHandle); void Free( D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE gpuHandle); private: void AllocateInternal( D3D12_CPU_DESCRIPTOR_HANDLE* outCpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE* outGpuHandle); ::XCEngine::RHI::RHIDevice* m_device = nullptr; ::XCEngine::RHI::RHIDescriptorPool* m_descriptorPool = nullptr; ::XCEngine::RHI::D3D12DescriptorHeap* m_descriptorHeap = nullptr; std::vector m_descriptorUsage = {}; UINT m_descriptorSize = 0u; UINT m_descriptorCount = 0u; }; } // namespace XCEngine::UI::Editor::Host