Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ImGui to 1.91.1 #970

Merged
merged 7 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions src/d3d12/D3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "common/D3D12Downlevel.h"
#include "window/Window.h"

extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
dragonzkiller marked this conversation as resolved.
Show resolved Hide resolved

using TPresentD3D12Downlevel = HRESULT(ID3D12CommandQueueDownlevel*, ID3D12GraphicsCommandList*, ID3D12Resource*, HWND, D3D12_DOWNLEVEL_PRESENT_FLAGS);
using TCreateCommittedResource =
HRESULT(ID3D12Device*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS, const D3D12_RESOURCE_DESC*, D3D12_RESOURCE_STATES, const D3D12_CLEAR_VALUE*, const IID*, void**);
Expand Down
8 changes: 3 additions & 5 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,13 +495,13 @@ void D3D12::PrepareUpdate()

for (auto i = 0; i < drawData.CmdListsCount; ++i)
IM_DELETE(drawData.CmdLists[i]);
delete[] drawData.CmdLists;
WSSDude marked this conversation as resolved.
Show resolved Hide resolved
drawData.CmdLists = nullptr;
drawData.Clear();

drawData = *ImGui::GetDrawData();

auto** copiedDrawLists = new ImDrawList*[drawData.CmdListsCount];
ImVector<ImDrawList*> copiedDrawLists;
WSSDude marked this conversation as resolved.
Show resolved Hide resolved
copiedDrawLists.resize(drawData.CmdListsCount);

for (auto i = 0; i < drawData.CmdListsCount; ++i)
copiedDrawLists[i] = drawData.CmdLists[i]->CloneOutput();
drawData.CmdLists = copiedDrawLists;
WSSDude marked this conversation as resolved.
Show resolved Hide resolved
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
Loading
Loading