mirror of
https://github.com/ocornut/imgui.git
synced 2026-06-02 03:00:39 +08:00
Backends: DX12: comment about using SrvDescriptorAllocFn/SrvDescriptorFreeFn.
Amend 40b2286d16
This commit is contained in:
@@ -748,7 +748,7 @@ bool ImGui_ImplDX12_Init(ImGui_ImplDX12_InitInfo* init_info)
|
|||||||
init_info->SrvDescriptorAllocFn = [](ImGui_ImplDX12_InitInfo*, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_handle)
|
init_info->SrvDescriptorAllocFn = [](ImGui_ImplDX12_InitInfo*, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_handle)
|
||||||
{
|
{
|
||||||
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
|
||||||
IM_ASSERT(bd->LegacySingleDescriptorUsed == false);
|
IM_ASSERT(bd->LegacySingleDescriptorUsed == false && "Only 1 simultaneous texture allowed with legacy ImGui_ImplDX12_Init() signature!");
|
||||||
*out_cpu_handle = bd->InitInfo.LegacySingleSrvCpuDescriptor;
|
*out_cpu_handle = bd->InitInfo.LegacySingleSrvCpuDescriptor;
|
||||||
*out_gpu_handle = bd->InitInfo.LegacySingleSrvGpuDescriptor;
|
*out_gpu_handle = bd->InitInfo.LegacySingleSrvGpuDescriptor;
|
||||||
bd->LegacySingleDescriptorUsed = true;
|
bd->LegacySingleDescriptorUsed = true;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ struct ImGui_ImplDX12_InitInfo
|
|||||||
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.
|
||||||
// (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, from 1.92 the backend will need to allocate more)
|
||||||
ID3D12DescriptorHeap* SrvDescriptorHeap;
|
ID3D12DescriptorHeap* SrvDescriptorHeap;
|
||||||
void (*SrvDescriptorAllocFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_desc_handle);
|
void (*SrvDescriptorAllocFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE* out_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE* out_gpu_desc_handle);
|
||||||
void (*SrvDescriptorFreeFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE gpu_desc_handle);
|
void (*SrvDescriptorFreeFn)(ImGui_ImplDX12_InitInfo* info, D3D12_CPU_DESCRIPTOR_HANDLE cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE gpu_desc_handle);
|
||||||
|
|||||||
@@ -154,6 +154,9 @@ int main(int, char**)
|
|||||||
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); };
|
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); };
|
||||||
ImGui_ImplDX12_Init(&init_info);
|
ImGui_ImplDX12_Init(&init_info);
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
//ImGui_ImplDX12_Init(g_pd3dDevice, APP_NUM_FRAMES_IN_FLIGHT, DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap, g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(), g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
|
||||||
|
|
||||||
// Load Fonts
|
// Load Fonts
|
||||||
// - 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.
|
// - 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.
|
||||||
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
|
||||||
|
|||||||
Reference in New Issue
Block a user