1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-12-18 18:46:13 +01:00

Backends: DX12: let the user specifies the DepthStencilView format. (#8217)

This is particullarly important for those who use RenderPasses.
This commit is contained in:
bmarques1995 2024-12-09 01:19:23 -03:00 committed by ocornut
parent 2671f68f7f
commit 53dd7552dc
4 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,7 @@
// CHANGELOG // CHANGELOG
// (minor and older changes stripped away, please see git history for details) // (minor and older changes stripped away, please see git history for details)
// 2024-12-09: DirectX12: Let user specifies the DepthStencilView format by setting ImGui_ImplDX12_InitInfo::DSVFormat.
// 2024-11-15: DirectX12: *BREAKING CHANGE* Changed ImGui_ImplDX12_Init() signature to take a ImGui_ImplDX12_InitInfo struct. Legacy ImGui_ImplDX12_Init() signature is still supported (will obsolete). // 2024-11-15: DirectX12: *BREAKING CHANGE* Changed ImGui_ImplDX12_Init() signature to take a ImGui_ImplDX12_InitInfo struct. Legacy ImGui_ImplDX12_Init() signature is still supported (will obsolete).
// 2024-11-15: DirectX12: *BREAKING CHANGE* User is now required to pass function pointers to allocate/free SRV Descriptors. We provide convenience legacy fields to pass a single descriptor, matching the old API, but upcoming features will want multiple. // 2024-11-15: DirectX12: *BREAKING CHANGE* User is now required to pass function pointers to allocate/free SRV Descriptors. We provide convenience legacy fields to pass a single descriptor, matching the old API, but upcoming features will want multiple.
// 2024-10-23: DirectX12: Unmap() call specify written range. The range is informational and may be used by debug tools. // 2024-10-23: DirectX12: Unmap() call specify written range. The range is informational and may be used by debug tools.
@ -72,6 +73,7 @@ struct ImGui_ImplDX12_Data
ID3D12RootSignature* pRootSignature; ID3D12RootSignature* pRootSignature;
ID3D12PipelineState* pPipelineState; ID3D12PipelineState* pPipelineState;
DXGI_FORMAT RTVFormat; DXGI_FORMAT RTVFormat;
DXGI_FORMAT DSVFormat;
ID3D12DescriptorHeap* pd3dSrvDescHeap; ID3D12DescriptorHeap* pd3dSrvDescHeap;
UINT numFramesInFlight; UINT numFramesInFlight;
@ -569,6 +571,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
psoDesc.SampleMask = UINT_MAX; psoDesc.SampleMask = UINT_MAX;
psoDesc.NumRenderTargets = 1; psoDesc.NumRenderTargets = 1;
psoDesc.RTVFormats[0] = bd->RTVFormat; psoDesc.RTVFormats[0] = bd->RTVFormat;
psoDesc.DSVFormat = bd->DSVFormat;
psoDesc.SampleDesc.Count = 1; psoDesc.SampleDesc.Count = 1;
psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE;
@ -735,6 +738,7 @@ bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* init_info)
bd->pd3dDevice = init_info->Device; bd->pd3dDevice = init_info->Device;
bd->RTVFormat = init_info->RTVFormat; bd->RTVFormat = init_info->RTVFormat;
bd->DSVFormat = init_info->DSVFormat;
bd->numFramesInFlight = init_info->NumFramesInFlight; bd->numFramesInFlight = init_info->NumFramesInFlight;
bd->pd3dSrvDescHeap = init_info->SrvDescriptorHeap; bd->pd3dSrvDescHeap = init_info->SrvDescriptorHeap;

View File

@ -29,7 +29,8 @@ struct ImGui_ImplDX12_InitInfo
ID3D12Device* Device; ID3D12Device* Device;
ID3D12CommandQueue* CommandQueue; ID3D12CommandQueue* CommandQueue;
int NumFramesInFlight; int NumFramesInFlight;
DXGI_FORMAT RTVFormat; DXGI_FORMAT RTVFormat; // RenderTarget format.
DXGI_FORMAT DSVFormat; // DepthStencilView format.
void* UserData; void* UserData;
// Allocating SRV descriptors for textures is up to the application, so we provide callbacks. // Allocating SRV descriptors for textures is up to the application, so we provide callbacks.

View File

@ -67,6 +67,8 @@ Other changes:
- Fonts: fixed AddCustomRect() not being packed with TexGlyphPadding + not accounted - Fonts: fixed AddCustomRect() not being packed with TexGlyphPadding + not accounted
for surface area used to determine best-guess texture size. (#8107) [@YarikTH, @ocornut] for surface area used to determine best-guess texture size. (#8107) [@YarikTH, @ocornut]
- Misc: use SSE 4.2 crc32 instructions when available. (#8169, #4933) [@Teselka] - Misc: use SSE 4.2 crc32 instructions when available. (#8169, #4933) [@Teselka]
- Backends: DirectX12: Let user specifies the DepthStencilView format by setting
ImGui_ImplDX12_InitInfo::DSVFormat. (#8217) [@bmarques1995]
- Backends: Vulkan: Make user-provided descriptor pool optional. As a convenience, - Backends: Vulkan: Make user-provided descriptor pool optional. As a convenience,
when setting init_info->DescriptorPoolSize then the backend will create and manage when setting init_info->DescriptorPoolSize then the backend will create and manage
one itself. (#8172, #4867) [@zeux] one itself. (#8172, #4867) [@zeux]

View File

@ -146,6 +146,7 @@ int main(int, char**)
init_info.CommandQueue = g_pd3dCommandQueue; init_info.CommandQueue = g_pd3dCommandQueue;
init_info.NumFramesInFlight = APP_NUM_FRAMES_IN_FLIGHT; init_info.NumFramesInFlight = APP_NUM_FRAMES_IN_FLIGHT;
init_info.RTVFormat = DXGI_FORMAT_R8G8B8A8_UNORM; init_info.RTVFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
init_info.DSVFormat = DXGI_FORMAT_UNKNOWN;
// Allocating SRV descriptors (for textures) is up to the application, so we provide callbacks. // Allocating SRV descriptors (for textures) is up to the application, so we provide callbacks.
// (current version of the backend will only allocate one descriptor, future versions will need to allocate more) // (current version of the backend will only allocate one descriptor, future versions will need to allocate more)
init_info.SrvDescriptorHeap = g_pd3dSrvDescHeap; init_info.SrvDescriptorHeap = g_pd3dSrvDescHeap;