From 83e91b16c779a51d7294a411989ccb51743935ac Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Tue, 17 Mar 2026 01:23:23 +0800 Subject: [PATCH] Add CreateDesc for D3D12DepthStencilView --- engine/include/XCEngine/RHI/D3D12/D3D12DepthStencilView.h | 5 +++++ engine/src/RHI/D3D12/D3D12DepthStencilView.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/engine/include/XCEngine/RHI/D3D12/D3D12DepthStencilView.h b/engine/include/XCEngine/RHI/D3D12/D3D12DepthStencilView.h index 0483cb31..8f08b2e8 100644 --- a/engine/include/XCEngine/RHI/D3D12/D3D12DepthStencilView.h +++ b/engine/include/XCEngine/RHI/D3D12/D3D12DepthStencilView.h @@ -3,6 +3,9 @@ #include #include +#include "../Enums.h" +#include "D3D12Enum.h" + using Microsoft::WRL::ComPtr; namespace XCEngine { @@ -19,6 +22,8 @@ public: D3D12_CPU_DESCRIPTOR_HANDLE GetCPUDescriptorHandle() const { return m_handle; } + static D3D12_DEPTH_STENCIL_VIEW_DESC CreateDesc(Format format, D3D12_DSV_DIMENSION dimension = D3D12_DSV_DIMENSION_TEXTURE2D); + private: D3D12_CPU_DESCRIPTOR_HANDLE m_handle; ID3D12Resource* m_resource; diff --git a/engine/src/RHI/D3D12/D3D12DepthStencilView.cpp b/engine/src/RHI/D3D12/D3D12DepthStencilView.cpp index 63fb8b06..e15add6f 100644 --- a/engine/src/RHI/D3D12/D3D12DepthStencilView.cpp +++ b/engine/src/RHI/D3D12/D3D12DepthStencilView.cpp @@ -29,5 +29,12 @@ void D3D12DepthStencilView::Shutdown() { m_resource = nullptr; } +D3D12_DEPTH_STENCIL_VIEW_DESC D3D12DepthStencilView::CreateDesc(Format format, D3D12_DSV_DIMENSION dimension) { + D3D12_DEPTH_STENCIL_VIEW_DESC desc = {}; + desc.Format = ToD3D12(format); + desc.ViewDimension = dimension; + return desc; +} + } // namespace RHI } // namespace XCEngine