Skip to content

Commit

Permalink
Merge pull request #970 from dragonzkiller/master
Browse files Browse the repository at this point in the history
Update ImGui to 1.91.1
  • Loading branch information
WSSDude authored Nov 1, 2024
2 parents ae1cd01 + 2891124 commit 4aea400
Show file tree
Hide file tree
Showing 12 changed files with 2,113 additions and 533 deletions.
3 changes: 2 additions & 1 deletion src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ bool IsLuaCData(const sol::object& acpObject)

float GetAlignedItemWidth(const int64_t acItemsCount)
{
return (ImGui::GetWindowContentRegionWidth() - static_cast<float>(acItemsCount - 1) * ImGui::GetStyle().ItemSpacing.x) / static_cast<float>(acItemsCount);
return (ImGui::GetContentRegionAvail().x - static_cast<float>(acItemsCount - 1) * ImGui::GetStyle().ItemSpacing.x) /
static_cast<float>(acItemsCount);
}

float GetCenteredOffsetForText(const char* acpText)
Expand Down
10 changes: 4 additions & 6 deletions src/d3d12/D3D12_Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ bool D3D12::ResetState(const bool acClearDownlevelBackbuffers, const bool acDest
{
for (auto i = 0; i < drawData.CmdListsCount; ++i)
IM_DELETE(drawData.CmdLists[i]);
delete[] drawData.CmdLists;
drawData.CmdLists = nullptr;
drawData.Clear();
}

Expand Down Expand Up @@ -497,16 +495,16 @@ void D3D12::PrepareUpdate()

for (auto i = 0; i < drawData.CmdListsCount; ++i)
IM_DELETE(drawData.CmdLists[i]);
delete[] drawData.CmdLists;
drawData.CmdLists = nullptr;
drawData.Clear();

drawData = *ImGui::GetDrawData();

auto** copiedDrawLists = new ImDrawList*[drawData.CmdListsCount];
ImVector<ImDrawList*> copiedDrawLists;
copiedDrawLists.resize(drawData.CmdListsCount);

for (auto i = 0; i < drawData.CmdListsCount; ++i)
copiedDrawLists[i] = drawData.CmdLists[i]->CloneOutput();
drawData.CmdLists = copiedDrawLists;
drawData.CmdLists = std::move(copiedDrawLists);

std::swap(m_imguiDrawDataBuffers[1], m_imguiDrawDataBuffers[2]);
}
Expand Down
789 changes: 591 additions & 198 deletions src/imgui_impl/dx12.cpp

Large diffs are not rendered by default.

45 changes: 26 additions & 19 deletions src/imgui_impl/dx12.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,46 @@
// This needs to be used along with a Platform Backend (e.g. Win32)

// Implemented features:
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about
// ImTextureID! [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID!
// [X] Renderer: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.

// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*.
// 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.
// See imgui_impl_dx12.cpp file for details.

// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
// Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
// - Introduction, links and more at the top of imgui.cpp

#pragma once
#include "imgui.h" // IMGUI_IMPL_API
#include "imgui.h" // IMGUI_IMPL_API
#ifndef IMGUI_DISABLE
#include <dxgiformat.h> // DXGI_FORMAT

struct ID3D12Device;
struct ID3D12DescriptorHeap;
struct ID3D12GraphicsCommandList;
struct D3D12_CPU_DESCRIPTOR_HANDLE;
struct D3D12_GPU_DESCRIPTOR_HANDLE;

// Follow "Getting Started" link and check examples/ folder to learn about using backends!

// cmd_list is the command list that the implementation will use to render imgui draw lists.
// Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate
// render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle.
// 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.
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(
ID3D12Device* apDevice, int aNumFramesInFlight, DXGI_FORMAT aRTVFormat, ID3D12DescriptorHeap* apSRVHeapDesc, D3D12_CPU_DESCRIPTOR_HANDLE aFontSRVDescCPU,
D3D12_GPU_DESCRIPTOR_HANDLE aFontSRVDescGPU);
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(ID3D12CommandQueue* apCommandQueue);
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* apDrawData, ID3D12GraphicsCommandList* apCommandLists);
// 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.
IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap,
D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle);
IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown();
IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(ID3D12CommandQueue* apCommandQueue);
IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list);

// Use if you want to reset your rendering device without losing Dear ImGui state.
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(ID3D12CommandQueue* apCommandQueue);
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(ID3D12CommandQueue* apCommandQueue);

#endif // #ifndef IMGUI_DISABLE
2 changes: 2 additions & 0 deletions src/imgui_impl/imgui_user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// global declaration "Enable ImGui Assertions"
extern bool g_ImGuiAssertionsEnabled;

#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD

// runtime assertions which can be enabled/disabled inside CET options
void ImGuiAssert(wchar_t const* acpMessage, wchar_t const* acpFile, unsigned aLine);

Expand Down
Loading

0 comments on commit 4aea400

Please sign in to comment.