Skip to content

Commit de4f77b

Browse files
committed
Backends: DX12: comment about using SrvDescriptorAllocFn/SrvDescriptorFreeFn.
Amend 40b2286
1 parent 09654f4 commit de4f77b

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

backends/imgui_impl_dx12.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* init_info)
748748
init_info->SrvDescriptorAllocFn = [](ImGui_ImplDX12_InitInfo*, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_handle)
749749
{
750750
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
751-
IM_ASSERT(bd->LegacySingleDescriptorUsed == false);
751+
IM_ASSERT(bd->LegacySingleDescriptorUsed == false && "Only 1 simultaneous texture allowed with legacy ImGui_ImplDX12_Init() signature!");
752752
*out_cpu_handle = bd->InitInfo.LegacySingleSrvCpuDescriptor;
753753
*out_gpu_handle = bd->InitInfo.LegacySingleSrvGpuDescriptor;
754754
bd->LegacySingleDescriptorUsed = true;

backends/imgui_impl_dx12.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct ImGui_ImplDX12_InitInfo
3434
void* UserData;
3535

3636
// Allocating SRV descriptors for textures is up to the application, so we provide callbacks.
37-
// (current version of the backend will only allocate one descriptor, future versions will need to allocate more)
37+
// (current version of the backend will only allocate one descriptor, from 1.92 the backend will need to allocate more)
3838
ID3D12DescriptorHeap* SrvDescriptorHeap;
3939
void (*SrvDescriptorAllocFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_desc_handle);
4040
void (*SrvDescriptorFreeFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE gpu_desc_handle);

examples/example_win32_directx12/main.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ int main(int, char**)
154154
init_info.SrvDescriptorFreeFn = [](ImGui_ImplDX12_InitInfo*, D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle, D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle) { return g_pd3dSrvDescHeapAlloc.Free(cpu_handle, gpu_handle); };
155155
ImGui_ImplDX12_Init(&init_info);
156156

157+
// Before 1.91.6: our signature was using a single descriptor. From 1.92, specifying SrvDescriptorAllocFn/SrvDescriptorFreeFn will be required to benefit from new features.
158+
//ImGui_ImplDX12_Init(g_pd3dDevice, APP_NUM_FRAMES_IN_FLIGHT, DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap, g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(), g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
159+
157160
// Load Fonts
158161
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
159162
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.

0 commit comments

Comments
 (0)