imgui_impl_dx12.h (2621B)
1 // dear imgui: Renderer Backend for DirectX12 2 // This needs to be used along with a Platform Backend (e.g. Win32) 3 4 // Implemented features: 5 // [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! 6 // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 8 // Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. 9 // This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. 10 // This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file. 11 12 // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 13 // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 14 // Read online: https://github.com/ocornut/imgui/tree/master/docs 15 16 #pragma once 17 #include "imgui.h" // IMGUI_IMPL_API 18 19 #ifdef _MSC_VER 20 #pragma warning (push) 21 #pragma warning (disable: 4471) // a forward declaration of an unscoped enumeration must have an underlying type 22 #endif 23 24 enum DXGI_FORMAT; 25 struct ID3D12Device; 26 struct ID3D12DescriptorHeap; 27 struct ID3D12GraphicsCommandList; 28 struct D3D12_CPU_DESCRIPTOR_HANDLE; 29 struct D3D12_GPU_DESCRIPTOR_HANDLE; 30 31 // cmd_list is the command list that the implementation will use to render imgui draw lists. 32 // Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate 33 // render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle. 34 // font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture. 35 IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, 36 D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle); 37 IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown(); 38 IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(); 39 IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list); 40 41 // Use if you want to reset your rendering device without losing Dear ImGui state. 42 IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); 43 IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); 44 45 #ifdef _MSC_VER 46 #pragma warning (pop) 47 #endif 48