compiles but bgfx still has that vulkan regression
This commit is contained in:
parent
49b92b83bd
commit
b43765b2c7
5 changed files with 45 additions and 40 deletions
|
@ -1,7 +1,7 @@
|
|||
# CMakeList.txt : CMake project for Keishiki, include source and define
|
||||
# project specific logic here.
|
||||
#
|
||||
cmake_minimum_required (VERSION 3.12)
|
||||
cmake_minimum_required (VERSION 3.16)
|
||||
|
||||
project("Main")
|
||||
|
||||
|
@ -10,7 +10,7 @@ file(GLOB IMGUI_SRC ${PROJECT_SOURCE_DIR}/ext/imgui/*.cpp)
|
|||
file(GLOB IMPLOT_SRC ${PROJECT_SOURCE_DIR}/ext/implot/*.cpp)
|
||||
|
||||
add_executable (Keishiki ${IMGUI_SRC} ${IMPLOT_SRC}
|
||||
"ext/imgui_impl_bgfx.cpp" "ext/imgui/backends/imgui_impl_sdl2.cpp" "ext/imgui/misc/cpp/imgui_stdlib.cpp"
|
||||
"ext/imgui_impl_bgfx.cpp" "ext/imgui/backends/imgui_impl_sdl3.cpp" "ext/imgui/misc/cpp/imgui_stdlib.cpp"
|
||||
${SRC_FILES})
|
||||
|
||||
|
||||
|
@ -19,6 +19,8 @@ set_property(TARGET Keishiki PROPERTY CXX_STANDARD 23)
|
|||
include_directories ("include" "include/ext" "ext/imgui" "ext/implot" "ext/plf_colony")
|
||||
|
||||
add_subdirectory("ext/freetype")
|
||||
|
||||
add_compile_definitions(WL_EGL_PLATFORM)
|
||||
add_subdirectory("ext/bgfx")
|
||||
|
||||
add_compile_definitions(IMGUI_DEFINE_MATH_OPERATORS)
|
||||
|
@ -40,6 +42,9 @@ elseif (APPLE)
|
|||
find_package(SDL2 REQUIRED)
|
||||
target_link_libraries (Keishiki PRIVATE freetype bgfx bx SDL2::SDL2)
|
||||
else ()
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_link_libraries (Keishiki PRIVATE freetype bgfx bx SDL2::SDL2 SDL2::SDL2main)
|
||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
|
||||
find_package(ECM REQUIRED NO_MODULE)
|
||||
set(CMAKE_MODULE_PATH ${ECM_FIND_MODULE_DIR})
|
||||
find_package(Wayland REQUIRED Egl)
|
||||
target_link_libraries (Keishiki PRIVATE freetype bgfx bx SDL3::SDL3 ${Wayland_LIBRARIES})
|
||||
endif ()
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
#include "Graphics.h"
|
||||
#include "UI.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_main.h>
|
||||
#include <SDL_timer.h>
|
||||
#include <SDL_syswm.h>
|
||||
#include <wayland-egl.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_timer.h>
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bgfx/platform.h>
|
||||
|
||||
#include "backends/imgui_impl_sdl2.h"
|
||||
#include "backends/imgui_impl_sdl3.h"
|
||||
#include <imgui.h>
|
||||
|
||||
namespace {
|
||||
|
@ -27,10 +27,8 @@ namespace K {
|
|||
}
|
||||
|
||||
app_state.window = SDL_CreateWindow("Keishiki",
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
SDL_WINDOWPOS_CENTERED,
|
||||
app_state.window_width, app_state.window_height,
|
||||
SDL_WINDOW_SHOWN);
|
||||
0);
|
||||
|
||||
if (app_state.window == nullptr) {
|
||||
LogError(SDL_GetError());
|
||||
|
@ -43,22 +41,25 @@ namespace K {
|
|||
bgfxInit.resolution.height = app_state.window_height;
|
||||
bgfxInit.resolution.reset = BGFX_RESET_VSYNC;
|
||||
|
||||
|
||||
#if !BX_PLATFORM_EMSCRIPTEN
|
||||
SDL_SysWMinfo wmi;
|
||||
SDL_VERSION(&wmi.version);
|
||||
if (!SDL_GetWindowWMInfo(app_state.window, &wmi)) {
|
||||
LogError(SDL_GetError());
|
||||
}
|
||||
#endif
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
bgfxInit.platformData.nwh = wmi.info.win.window;
|
||||
bgfxInit.platformData.nwh = SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
#elif BX_PLATFORM_OSX
|
||||
bgfxInit.platformData.nwh = wmi.info.cocoa.window;
|
||||
bgfxInit.platformData.nwh = SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, NULL);
|
||||
bgfx::renderFrame();
|
||||
#elif BX_PLATFORM_LINUX
|
||||
bgfxInit.platformData.ndt = wmi.info.x11.display;
|
||||
bgfxInit.platformData.nwh = (void*)(uintptr_t)wmi.info.x11.window;
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
|
||||
bgfxInit.platformData.ndt = SDL_GetProperty(SDL_GetWindowProperties(app_state.window), SDL_PROP_WINDOW_X11_DISPLAY_POINTER, NULL);
|
||||
bgfxInit.platformData.nwh = (void*)SDL_GetNumberProperty(SDL_GetWindowProperties(app_state.window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
|
||||
}
|
||||
else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
|
||||
bgfxInit.platformData.type = bgfx::NativeWindowHandleType::Wayland;
|
||||
bgfxInit.platformData.ndt = SDL_GetProperty(SDL_GetWindowProperties(app_state.window), SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, NULL);
|
||||
bgfxInit.platformData.nwh = SDL_GetProperty(SDL_GetWindowProperties(app_state.window), SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER, NULL);
|
||||
if (!bgfxInit.platformData.nwh) {
|
||||
bgfxInit.platformData.nwh = wl_egl_window_create((struct wl_surface *)SDL_GetProperty(SDL_GetWindowProperties(app_state.window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, NULL), app_state.window_width, app_state.window_height);
|
||||
SDL_SetProperty(SDL_GetWindowProperties(app_state.window), SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER, (void*)(uintptr_t)bgfxInit.platformData.nwh);
|
||||
}
|
||||
}
|
||||
#elif BX_PLATFORM_EMSCRIPTEN
|
||||
bgfxInit.platformData.nwh = (void*)"#canvas";
|
||||
#endif
|
||||
|
@ -91,8 +92,7 @@ namespace K {
|
|||
state.current_frame = 0;
|
||||
state.fps = 30.0f;
|
||||
state.frame_max = 200;
|
||||
// state.plugboard.in = Plugboard::K_P_CompositionIn{};
|
||||
// state.plugboard.out = Plugboard::K_P_CompositionOut{};
|
||||
|
||||
K::UI::SetupViewport(state);
|
||||
|
||||
return true;
|
||||
|
@ -114,23 +114,23 @@ namespace K {
|
|||
stat->cpuTimerFreq / stat->cpuTimeFrame);
|
||||
bgfx::dbgTextPrintf(0, app_state.window_height/16 - 7, 0xf8,
|
||||
" Project Keishiki :: %s :: Build %s %s :: SDL %i.%i.%i :: bgfx 1.%i :: Dear ImGui %s :: %s",
|
||||
BX_COMPILER_NAME, __DATE__, __TIME__, SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL,
|
||||
BX_COMPILER_NAME, __DATE__, __TIME__, SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION,
|
||||
BGFX_API_VERSION, ImGui::GetVersion(), bgfx::getRendererName(bgfx::getRendererType()));
|
||||
|
||||
app_state.bgfx_frame = bgfx::frame();
|
||||
}
|
||||
|
||||
void Run() {
|
||||
app_state.init_time = SDL_GetTicks64();
|
||||
app_state.init_time = SDL_GetTicks();
|
||||
app_state.last_time = app_state.init_time;
|
||||
|
||||
while (app_state.running.load()) {
|
||||
app_state.current_time = SDL_GetTicks64();
|
||||
app_state.current_time = SDL_GetTicks();
|
||||
app_state.delta_t = app_state.current_time - app_state.last_time;
|
||||
|
||||
for (SDL_Event current_event; SDL_PollEvent(¤t_event) != 0;) {
|
||||
ImGui_ImplSDL2_ProcessEvent(¤t_event);
|
||||
if (current_event.type == SDL_QUIT) {
|
||||
ImGui_ImplSDL3_ProcessEvent(¤t_event);
|
||||
if (current_event.type == SDL_EVENT_QUIT) {
|
||||
app_state.running.store(false);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ namespace K::Plugboard {
|
|||
}
|
||||
|
||||
T_Map<T_Count>::type FetchCompositionInAppTicks(const CompState& s, const CompositionIn& n) {
|
||||
return T_Map<T_Count>::type{ static_cast<f32>(SDL_GetTicks64()) };
|
||||
return T_Map<T_Count>::type{ static_cast<f32>(SDL_GetTicks()) };
|
||||
}
|
||||
|
||||
void Plugboard::RecollectChains() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <imgui_internal.h>
|
||||
#include <misc/cpp/imgui_stdlib.h>
|
||||
|
||||
#include "backends/imgui_impl_sdl2.h"
|
||||
#include "backends/imgui_impl_sdl3.h"
|
||||
#include "imgui_impl_bgfx.h"
|
||||
|
||||
#include <implot.h>
|
||||
|
@ -1804,7 +1804,7 @@ namespace K::UI {
|
|||
}
|
||||
|
||||
void Draw(u32 frame, CompState& s) {
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
ImGui_Implbgfx_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
@ -1840,16 +1840,16 @@ namespace K::UI {
|
|||
case bgfx::RendererType::Noop:
|
||||
case bgfx::RendererType::Direct3D11:
|
||||
case bgfx::RendererType::Direct3D12:
|
||||
ImGui_ImplSDL2_InitForD3D(window);
|
||||
ImGui_ImplSDL3_InitForD3D(window);
|
||||
break;
|
||||
case bgfx::RendererType::Metal:
|
||||
ImGui_ImplSDL2_InitForMetal(window);
|
||||
ImGui_ImplSDL3_InitForMetal(window);
|
||||
break;
|
||||
case bgfx::RendererType::OpenGL:
|
||||
ImGui_ImplSDL2_InitForOpenGL(window, nullptr);
|
||||
ImGui_ImplSDL3_InitForOpenGL(window, nullptr);
|
||||
break;
|
||||
case bgfx::RendererType::Vulkan:
|
||||
ImGui_ImplSDL2_InitForVulkan(window);
|
||||
ImGui_ImplSDL3_InitForVulkan(window);
|
||||
break;
|
||||
default:
|
||||
LogError("Unsupported Renderer");
|
||||
|
@ -1865,7 +1865,7 @@ namespace K::UI {
|
|||
|
||||
DestroyViewport(s);
|
||||
ImGui_Implbgfx_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui_ImplSDL3_Shutdown();
|
||||
ImPlot::DestroyContext();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Common.h"
|
||||
#include <Resource.h>
|
||||
#include <SDL.h>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <numbers>
|
||||
#include <cmath>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue