-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nikita Krupitskas
committed
Jul 27, 2024
1 parent
5d670af
commit 7f76ba8
Showing
13 changed files
with
293 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
namespace engine_stats | ||
{ | ||
static uint32_t fps; | ||
static uint32_t cpu_frame_ms; | ||
static uint32_t gpu_frame_ms; | ||
//uint32_t triangle_count; // draw.indexCount / 3; | ||
//uint32_t drawcall_count; // increase per draw call | ||
|
||
// Frustum culling stats | ||
// Occlusion culling stats | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,137 @@ | ||
#include "Gui.hpp" | ||
|
||
#include <imgui.h> | ||
#include "imgui_impl_dx12.h" | ||
#include "imgui_impl_win32.h" | ||
|
||
void ysn::SetupColorScheme() | ||
#include <System/Window.hpp> | ||
#include <Renderer/GpuMarker.hpp> | ||
#include <Renderer/D3D12Renderer.hpp> | ||
|
||
namespace ysn | ||
{ | ||
ImVec4* colors = ImGui::GetStyle().Colors; | ||
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); | ||
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); | ||
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); | ||
colors[ImGuiCol_ChildBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.00f); | ||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); | ||
colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); | ||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); | ||
colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.21f, 0.22f, 0.54f); | ||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.40f, 0.40f, 0.40f, 0.40f); | ||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.18f, 0.18f, 0.18f, 0.67f); | ||
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); | ||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f); | ||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); | ||
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); | ||
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); | ||
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); | ||
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); | ||
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); | ||
colors[ImGuiCol_CheckMark] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); | ||
colors[ImGuiCol_SliderGrab] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); | ||
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); | ||
colors[ImGuiCol_Button] = ImVec4(0.44f, 0.44f, 0.44f, 0.40f); | ||
colors[ImGuiCol_ButtonHovered] = ImVec4(0.46f, 0.47f, 0.48f, 1.00f); | ||
colors[ImGuiCol_ButtonActive] = ImVec4(0.42f, 0.42f, 0.42f, 1.00f); | ||
colors[ImGuiCol_Header] = ImVec4(0.70f, 0.70f, 0.70f, 0.31f); | ||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.70f, 0.70f, 0.70f, 0.80f); | ||
colors[ImGuiCol_HeaderActive] = ImVec4(0.48f, 0.50f, 0.52f, 1.00f); | ||
colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); | ||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.72f, 0.72f, 0.72f, 0.78f); | ||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); | ||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.91f, 0.91f, 0.91f, 0.25f); | ||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.81f, 0.81f, 0.81f, 0.67f); | ||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.46f, 0.46f, 0.46f, 0.95f); | ||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); | ||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); | ||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.73f, 0.60f, 0.15f, 1.00f); | ||
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); | ||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.87f, 0.87f, 0.87f, 0.35f); | ||
// colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); | ||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); | ||
colors[ImGuiCol_NavHighlight] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); | ||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); | ||
|
||
ImGuiStyle& style = ImGui::GetStyle(); | ||
style.WindowPadding = ImVec2(8.00f, 8.00f); | ||
style.FramePadding = ImVec2(5.00f, 2.00f); | ||
style.CellPadding = ImVec2(6.00f, 6.00f); | ||
style.ItemSpacing = ImVec2(6.00f, 6.00f); | ||
style.ItemInnerSpacing = ImVec2(6.00f, 6.00f); | ||
style.TouchExtraPadding = ImVec2(0.00f, 0.00f); | ||
style.IndentSpacing = 25; | ||
style.ScrollbarSize = 15; | ||
style.GrabMinSize = 10; | ||
style.WindowBorderSize = 1; | ||
style.ChildBorderSize = 1; | ||
style.PopupBorderSize = 1; | ||
style.FrameBorderSize = 1; | ||
style.TabBorderSize = 1; | ||
style.WindowRounding = 0; | ||
style.ChildRounding = 0; | ||
style.FrameRounding = 0; | ||
style.PopupRounding = 0; | ||
style.ScrollbarRounding = 0; | ||
style.GrabRounding = 0; | ||
style.LogSliderDeadzone = 4; | ||
style.TabRounding = 0; | ||
} | ||
void SetupColorScheme() | ||
{ | ||
ImVec4* colors = ImGui::GetStyle().Colors; | ||
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); | ||
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); | ||
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); | ||
colors[ImGuiCol_ChildBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.00f); | ||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); | ||
colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); | ||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); | ||
colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.21f, 0.22f, 0.54f); | ||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.40f, 0.40f, 0.40f, 0.40f); | ||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.18f, 0.18f, 0.18f, 0.67f); | ||
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); | ||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.29f, 0.29f, 0.29f, 1.00f); | ||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); | ||
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); | ||
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); | ||
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); | ||
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); | ||
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); | ||
colors[ImGuiCol_CheckMark] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); | ||
colors[ImGuiCol_SliderGrab] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); | ||
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); | ||
colors[ImGuiCol_Button] = ImVec4(0.44f, 0.44f, 0.44f, 0.40f); | ||
colors[ImGuiCol_ButtonHovered] = ImVec4(0.46f, 0.47f, 0.48f, 1.00f); | ||
colors[ImGuiCol_ButtonActive] = ImVec4(0.42f, 0.42f, 0.42f, 1.00f); | ||
colors[ImGuiCol_Header] = ImVec4(0.70f, 0.70f, 0.70f, 0.31f); | ||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.70f, 0.70f, 0.70f, 0.80f); | ||
colors[ImGuiCol_HeaderActive] = ImVec4(0.48f, 0.50f, 0.52f, 1.00f); | ||
colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); | ||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.72f, 0.72f, 0.72f, 0.78f); | ||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); | ||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.91f, 0.91f, 0.91f, 0.25f); | ||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.81f, 0.81f, 0.81f, 0.67f); | ||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.46f, 0.46f, 0.46f, 0.95f); | ||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); | ||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); | ||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.73f, 0.60f, 0.15f, 1.00f); | ||
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); | ||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.87f, 0.87f, 0.87f, 0.35f); | ||
// colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); | ||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); | ||
colors[ImGuiCol_NavHighlight] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); | ||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); | ||
|
||
ImGuiStyle& style = ImGui::GetStyle(); | ||
style.WindowPadding = ImVec2(8.00f, 8.00f); | ||
style.FramePadding = ImVec2(5.00f, 2.00f); | ||
style.CellPadding = ImVec2(6.00f, 6.00f); | ||
style.ItemSpacing = ImVec2(6.00f, 6.00f); | ||
style.ItemInnerSpacing = ImVec2(6.00f, 6.00f); | ||
style.TouchExtraPadding = ImVec2(0.00f, 0.00f); | ||
style.IndentSpacing = 25; | ||
style.ScrollbarSize = 15; | ||
style.GrabMinSize = 10; | ||
style.WindowBorderSize = 1; | ||
style.ChildBorderSize = 1; | ||
style.PopupBorderSize = 1; | ||
style.FrameBorderSize = 1; | ||
style.TabBorderSize = 1; | ||
style.WindowRounding = 0; | ||
style.ChildRounding = 0; | ||
style.FrameRounding = 0; | ||
style.PopupRounding = 0; | ||
style.ScrollbarRounding = 0; | ||
style.GrabRounding = 0; | ||
style.LogSliderDeadzone = 4; | ||
style.TabRounding = 0; | ||
} | ||
|
||
void InitializeImgui(std::shared_ptr<Window> window, std::shared_ptr<D3D12Renderer> renderer) | ||
{ | ||
IMGUI_CHECKVERSION(); | ||
ImGui::CreateContext(); | ||
ImGuiIO& io = ImGui::GetIO(); | ||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; | ||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; | ||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; | ||
|
||
// io.IniFilename = nullptr; | ||
io.LogFilename = nullptr; | ||
|
||
ysn::SetupColorScheme(); | ||
|
||
ImGui_ImplWin32_Init(window->GetWindowHandle()); | ||
|
||
auto imgui_srv_descriptor = renderer->GetCbvSrvUavDescriptorHeap()->GetNewHandle(); | ||
|
||
ImGui_ImplDX12_Init( | ||
renderer->GetDevice().get(), | ||
window->BufferCount, | ||
renderer->GetBackBufferFormat(), | ||
renderer->GetCbvSrvUavDescriptorHeap()->GetHeapPtr(), | ||
imgui_srv_descriptor.cpu, | ||
imgui_srv_descriptor.gpu); | ||
} | ||
|
||
void ShutdownImgui() | ||
{ | ||
ImGui_ImplDX12_Shutdown(); | ||
ImGui_ImplWin32_Shutdown(); | ||
ImGui::DestroyContext(); | ||
} | ||
|
||
void ImguiPrepareNewFrame() | ||
{ | ||
ImGui_ImplDX12_NewFrame(); | ||
ImGui_ImplWin32_NewFrame(); | ||
ImGui::NewFrame(); | ||
} | ||
|
||
void ImguiRenderFrame(wil::com_ptr<ID3D12GraphicsCommandList4> command_list) | ||
{ | ||
GpuMarker imgui_marker(command_list, "Imgui"); | ||
|
||
|
||
ImGui::Render(); | ||
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), command_list.get()); | ||
|
||
// PIXEndEvent(command_list.get()); | ||
|
||
imgui_marker.EndEvent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
#pragma once | ||
|
||
#include "imgui.h" | ||
#include "imgui_impl_dx12.h" | ||
#include "imgui_impl_win32.h" | ||
#include <wil/com.h> | ||
#include <d3d12.h> | ||
|
||
#include <imgui.h> | ||
|
||
namespace ysn | ||
{ | ||
void SetupColorScheme(); | ||
class Window; | ||
class D3D12Renderer; | ||
|
||
void InitializeImgui(std::shared_ptr<Window> window, std::shared_ptr<D3D12Renderer> renderer); | ||
void ShutdownImgui(); | ||
void ImguiPrepareNewFrame(); | ||
void ImguiRenderFrame(wil::com_ptr<ID3D12GraphicsCommandList4> command_list); | ||
} |
Oops, something went wrong.