Skip to content

Commit

Permalink
Revert "Merge pull request #970 from dragonzkiller/master"
Browse files Browse the repository at this point in the history
This reverts commit 4aea400, reversing
changes made to ae1cd01.
  • Loading branch information
Andrej Redeky committed Dec 11, 2024
1 parent 960fa82 commit eaee727
Show file tree
Hide file tree
Showing 12 changed files with 533 additions and 2,113 deletions.
3 changes: 1 addition & 2 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ bool IsLuaCData(const sol::object& acpObject)

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

float GetCenteredOffsetForText(const char* acpText)
Expand Down
10 changes: 6 additions & 4 deletions src/d3d12/D3D12_Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ 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 @@ -495,16 +497,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();

ImVector<ImDrawList*> copiedDrawLists;
copiedDrawLists.resize(drawData.CmdListsCount);

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

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

Large diffs are not rendered by default.

45 changes: 19 additions & 26 deletions src/imgui_impl/dx12.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,39 @@
// 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: Large meshes support (64k+ vertices) with 16-bit indices.
// [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// [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.

// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'.
// See imgui_impl_dx12.cpp file for details.
// 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.

// 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
// 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

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

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* 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);
// 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);

// 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);

#endif // #ifndef IMGUI_DISABLE
IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects();
IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(ID3D12CommandQueue* apCommandQueue);
2 changes: 0 additions & 2 deletions src/imgui_impl/imgui_user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// 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 eaee727

Please sign in to comment.