Merge branch 'master' into fbx
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
@@ -15,7 +16,8 @@ namespace OpenVulkano
|
||||
{
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_condVar;
|
||||
bool m_paused = false;
|
||||
std::atomic_bool m_paused = false;
|
||||
std::atomic_bool m_isSleeping = false;
|
||||
|
||||
public:
|
||||
void Pause() { m_paused = true; }
|
||||
@@ -33,9 +35,13 @@ namespace OpenVulkano
|
||||
{
|
||||
while (m_paused)
|
||||
{
|
||||
m_isSleeping = true;
|
||||
std::unique_lock l(m_mutex);
|
||||
m_condVar.wait(l, [this]{ return !m_paused; });
|
||||
}
|
||||
m_isSleeping = false;
|
||||
}
|
||||
|
||||
bool IsSleeping() const { return m_isSleeping; }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,12 +32,14 @@ namespace OpenVulkano
|
||||
Math::Vector2i position{0, 0};
|
||||
std::string title = "Window Title";
|
||||
WindowMode windowMode = WINDOWED;
|
||||
bool transparentFrameBuffer = false;
|
||||
bool resizeable = true;
|
||||
};
|
||||
|
||||
class IWindow : public ICloseable
|
||||
{
|
||||
public:
|
||||
virtual ~IWindow() = default;
|
||||
~IWindow() override = default;
|
||||
|
||||
virtual void Init(RenderAPI::RenderApi renderApi) = 0;
|
||||
|
||||
@@ -48,22 +50,22 @@ namespace OpenVulkano
|
||||
virtual const std::string& GetTitle() = 0;
|
||||
virtual void SetTitle(const std::string& title) = 0;
|
||||
|
||||
virtual WindowMode GetWindowMode() = 0;
|
||||
[[nodiscard]] virtual WindowMode GetWindowMode() = 0;
|
||||
virtual void SetWindowMode(WindowMode) = 0;
|
||||
inline void SetFullscreen() { SetWindowMode(FULLSCREEN); }
|
||||
inline void SetWindowed() { SetWindowMode(WINDOWED); }
|
||||
void SetFullscreen() { SetWindowMode(FULLSCREEN); }
|
||||
void SetWindowed() { SetWindowMode(WINDOWED); }
|
||||
|
||||
virtual const WindowConfiguration& GetWindowConfiguration() = 0;
|
||||
inline uint32_t GetWidth() { return GetSize().x; }
|
||||
inline uint32_t GetHeight() { return GetSize().y; }
|
||||
virtual Math::Vector2ui GetSize() = 0;
|
||||
[[nodiscard]] virtual const WindowConfiguration& GetWindowConfiguration() = 0;
|
||||
[[nodiscard]] uint32_t GetWidth() { return GetSize().x; }
|
||||
[[nodiscard]] uint32_t GetHeight() { return GetSize().y; }
|
||||
[[nodiscard]] virtual Math::Vector2ui GetSize() = 0;
|
||||
virtual void SetSize(uint32_t width, uint32_t height) = 0;
|
||||
inline void SetSize(Math::Vector2ui size) { SetSize(size.x, size.y); }
|
||||
void SetSize(const Math::Vector2ui& size) { SetSize(size.x, size.y); }
|
||||
virtual void SetSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) = 0;
|
||||
|
||||
virtual Math::Vector2i GetPosition() = 0;
|
||||
[[nodiscard]] virtual Math::Vector2i GetPosition() = 0;
|
||||
virtual void SetPosition(int posX, int posY) = 0;
|
||||
inline void SetPosition(Math::Vector2i pos) { SetPosition(pos.x, pos.y); };
|
||||
void SetPosition(Math::Vector2i pos) { SetPosition(pos.x, pos.y); };
|
||||
|
||||
virtual void SetMouseVisibility(bool hideMouse) {};
|
||||
|
||||
@@ -71,15 +73,15 @@ namespace OpenVulkano
|
||||
virtual void Hide() = 0;
|
||||
virtual void Show(bool show) = 0;
|
||||
|
||||
virtual IWindowHandler* GetWindowHandler() = 0;
|
||||
[[nodiscard]] virtual IWindowHandler* GetWindowHandler() = 0;
|
||||
virtual void SetWindowHandler(IWindowHandler* handler) = 0;
|
||||
|
||||
/**
|
||||
* \brief Gets the vulkan window implementation of the window.
|
||||
* \return The IVulkanWindow reference of the window. nullptr if the current Window dose not implement IVulkanWindow
|
||||
*/
|
||||
virtual IVulkanWindow* GetVulkanWindow() = 0;
|
||||
virtual IOpenGlWindow* GetOpenGlWindow() = 0;
|
||||
[[nodiscard]] virtual IVulkanWindow* GetVulkanWindow() = 0;
|
||||
[[nodiscard]] virtual IOpenGlWindow* GetOpenGlWindow() = 0;
|
||||
|
||||
[[nodiscard]] virtual uint32_t GetWindowId() const = 0;
|
||||
|
||||
|
||||
49
openVulkanoCpp/Base/UUID.cpp
Normal file
49
openVulkanoCpp/Base/UUID.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "UUID.hpp"
|
||||
#include <ctime>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
UUID GenerateTimePrefixedCustomUUID()
|
||||
{
|
||||
UUID uuid = UUID::generate();
|
||||
|
||||
uuid.time_low = 0;
|
||||
uuid.time_mid = 0;
|
||||
time_t now = time(nullptr);
|
||||
struct tm* timeinfo = localtime(&now);
|
||||
|
||||
// Extract time components
|
||||
uint32_t year = timeinfo->tm_year % 100; // Get last two digits of year
|
||||
uint32_t month = timeinfo->tm_mon + 1; // Month is 0-based
|
||||
uint32_t day = timeinfo->tm_mday;
|
||||
uint32_t hour = timeinfo->tm_hour;
|
||||
uint16_t minute = timeinfo->tm_min;
|
||||
uint16_t second = timeinfo->tm_sec;
|
||||
|
||||
// Each decimal digit takes 4 bits in the final hex number
|
||||
uuid.time_low |= (year / 10) << 28;
|
||||
uuid.time_low |= (year % 10) << 24;
|
||||
uuid.time_low |= (month / 10) << 20;
|
||||
uuid.time_low |= (month % 10) << 16;
|
||||
uuid.time_low |= (day / 10) << 12;
|
||||
uuid.time_low |= (day % 10) << 8;
|
||||
uuid.time_low |= (hour / 10) << 4;
|
||||
uuid.time_low |= (hour % 10) << 0;
|
||||
uuid.time_mid |= (minute / 10) << 12;
|
||||
uuid.time_mid |= (minute % 10) << 8;
|
||||
uuid.time_mid |= (second / 10) << 4;
|
||||
uuid.time_mid |= (second % 10) << 0;
|
||||
|
||||
// Set version to custom
|
||||
uuid.time_hiv &= ~(static_cast<uint16_t>(uuid.version()) << 12);
|
||||
uuid.time_hiv |= 8 << 12;
|
||||
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,6 @@
|
||||
namespace OpenVulkano
|
||||
{
|
||||
typedef stud::uuid UUID;
|
||||
|
||||
UUID GenerateTimePrefixedCustomUUID();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
@@ -90,5 +91,15 @@ namespace OpenVulkano
|
||||
template Array<char> Utils::ReadFile<std::string>(const std::string& filePath, bool emptyOnMissing, bool nullTerminateString);
|
||||
template Array<char> Utils::ReadFile<std::filesystem::path>(const std::filesystem::path& filePath,
|
||||
bool emptyOnMissing, bool nullTerminateString);
|
||||
|
||||
|
||||
std::string Utils::DemangleTypeName(const char* name)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
return name;
|
||||
#else
|
||||
int status = 0;
|
||||
std::unique_ptr<char, void(*)(void*)> res(abi::__cxa_demangle(name, NULL, NULL, &status), std::free);
|
||||
return (status==0) ? res.get() : name ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,5 +196,7 @@ namespace OpenVulkano
|
||||
static const int id = uniqueTypeID++;
|
||||
return id;
|
||||
}
|
||||
|
||||
static std::string DemangleTypeName(const char* name);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ if (NOT ANDROID AND NOT IOS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(openVulkanoCpp PUBLIC magic_enum yaml-cpp fmt spdlog glm pugixml stb eigen utf8cpp imgui_internal TracyClient stud-uuid ryml unordered_dense units ktx dds_image)
|
||||
target_link_libraries(openVulkanoCpp PUBLIC magic_enum yaml-cpp fmt spdlog glm pugixml stb eigen utf8cpp imgui_internal TracyClient stud-uuid ryml unordered_dense concurrentqueue units ktx dds_image)
|
||||
LinkAssimp(openVulkanoCpp)
|
||||
LinkLibArchive(openVulkanoCpp)
|
||||
LinkLibJpegTurbo(openVulkanoCpp)
|
||||
|
||||
@@ -52,10 +52,15 @@ namespace OpenVulkano::GLFW
|
||||
|
||||
void WindowGLFW::Create()
|
||||
{
|
||||
glfwWindowHint(GLFW_RESIZABLE, windowConfig.resizeable);
|
||||
glfwWindowHint(GLFW_DECORATED, (~windowConfig.windowMode) & 1);
|
||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, windowConfig.transparentFrameBuffer);
|
||||
//TODO handle full screen resolutions
|
||||
window = glfwCreateWindow(windowConfig.size.x, windowConfig.size.y, windowConfig.title.c_str(), GetTargetMonitor(), nullptr);
|
||||
if (!window) return;
|
||||
float scaleX, scaleY;
|
||||
glfwGetWindowContentScale(window, &scaleX, &scaleY);
|
||||
contentScale = std::max(scaleX, scaleY);
|
||||
glfwSetWindowUserPointer(window, this);
|
||||
RegisterCallbacks();
|
||||
}
|
||||
@@ -114,7 +119,7 @@ namespace OpenVulkano::GLFW
|
||||
throw WindowInitFailedException("Failed to initialize window");
|
||||
}
|
||||
if (renderApi != RenderAPI::Vulkan) MakeCurrentThread();
|
||||
Logger::WINDOW->info("GLFW Window created (id: {0})", GetWindowId());
|
||||
Logger::WINDOW->info("GLFW Window created (id: {0}) with scale {1}", GetWindowId(), contentScale);
|
||||
}
|
||||
|
||||
void WindowGLFW::Close()
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace OpenVulkano::GLFW
|
||||
{
|
||||
class WindowGLFW final : virtual public BaseWindow, virtual public IVulkanWindow, virtual public IOpenGlWindow
|
||||
{
|
||||
private:
|
||||
InputProviderGLFW& inputProvider;
|
||||
GLFWwindow* window = nullptr;
|
||||
IWindowHandler* handler = nullptr;
|
||||
Math::Vector2ui currentSize = {};
|
||||
float contentScale = 1.0f;
|
||||
|
||||
public:
|
||||
WindowGLFW(InputProviderGLFW& inputProvider);
|
||||
@@ -39,9 +39,9 @@ namespace OpenVulkano::GLFW
|
||||
|
||||
void RegisterCallbacks() const;
|
||||
|
||||
static GLFWmonitor* GetPrimaryMonitor();
|
||||
[[nodiscard]] static GLFWmonitor* GetPrimaryMonitor();
|
||||
|
||||
static std::vector<GLFWmonitor*> GetMonitors();
|
||||
[[nodiscard]] static std::vector<GLFWmonitor*> GetMonitors();
|
||||
|
||||
public: // IWindow implementation
|
||||
void Init(RenderAPI::RenderApi renderApi) override;
|
||||
@@ -64,27 +64,29 @@ namespace OpenVulkano::GLFW
|
||||
|
||||
void SetSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) override;
|
||||
|
||||
[[nodiscard]] float GetContentScale() const override { return contentScale; }
|
||||
|
||||
void MakeCurrentThread() override;
|
||||
|
||||
void SetWindowMode(WindowMode windowMode) override;
|
||||
|
||||
void SetWindowHandler(IWindowHandler* handler) override;
|
||||
|
||||
IVulkanWindow* GetVulkanWindow() override { return this; };
|
||||
[[nodiscard]] IVulkanWindow* GetVulkanWindow() override { return this; };
|
||||
|
||||
IOpenGlWindow* GetOpenGlWindow() override { return this; };
|
||||
[[nodiscard]] IOpenGlWindow* GetOpenGlWindow() override { return this; };
|
||||
|
||||
// Status getter
|
||||
Math::Vector2ui GetSize() override;
|
||||
[[nodiscard]] Math::Vector2ui GetSize() override;
|
||||
|
||||
Math::Vector2i GetPosition() override;
|
||||
[[nodiscard]] Math::Vector2i GetPosition() override;
|
||||
|
||||
IWindowHandler* GetWindowHandler() override { return handler; }
|
||||
[[nodiscard]] IWindowHandler* GetWindowHandler() override { return handler; }
|
||||
|
||||
//IVulkanWindow stuff
|
||||
vk::SurfaceKHR CreateSurface(const vk::Instance& instance, const vk::AllocationCallbacks* pAllocator) override;
|
||||
[[nodiscard]] vk::SurfaceKHR CreateSurface(const vk::Instance& instance, const vk::AllocationCallbacks* pAllocator) override;
|
||||
|
||||
std::vector<std::string> GetRequiredInstanceExtensions() override;
|
||||
[[nodiscard]] std::vector<std::string> GetRequiredInstanceExtensions() override;
|
||||
|
||||
void* GetNativeWindowHandle() override { return window; }
|
||||
|
||||
@@ -104,7 +106,7 @@ namespace OpenVulkano::GLFW
|
||||
void OnClose();
|
||||
|
||||
protected:
|
||||
virtual void OnKeyEvent(int key, int scanCode, int action, int mods);
|
||||
void OnKeyEvent(int key, int scanCode, int action, int mods);
|
||||
|
||||
private: // Callbacks
|
||||
static WindowGLFW* GetWindow(GLFWwindow* window);
|
||||
@@ -134,6 +136,6 @@ namespace OpenVulkano::GLFW
|
||||
static void DropCallback(GLFWwindow* window, int count, const char** paths);
|
||||
|
||||
public:
|
||||
static std::vector<std::string> GetVulkanRequiredInstanceExtensions();
|
||||
[[nodiscard]] static std::vector<std::string> GetVulkanRequiredInstanceExtensions();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@ namespace OpenVulkano
|
||||
{
|
||||
auto start = clock::now();
|
||||
inputManager->Tick();
|
||||
mainThreadTaskPool.Tick();
|
||||
app->Tick();
|
||||
if (CURRENT_FRAME.needsRedraw)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "Base/UI/IWindow.hpp"
|
||||
#include "Base/PlatformEnums.hpp"
|
||||
#include "Base/Timer.hpp"
|
||||
#include "Threading/TaskPool.hpp"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
@@ -43,6 +44,7 @@ namespace OpenVulkano
|
||||
std::string windowTitleFormat;
|
||||
Input::InputManager* inputManager;
|
||||
EngineConfiguration* engineConfig;
|
||||
MainThreadTaskPool mainThreadTaskPool;
|
||||
|
||||
private:
|
||||
void OnCappedFPS(const auto& frameStartTime);
|
||||
|
||||
@@ -329,9 +329,9 @@ namespace OpenVulkano
|
||||
{
|
||||
float value;
|
||||
powerSupplyFile >> value;
|
||||
return value;
|
||||
return value / 100.0f;
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void SystemInfo::EnableEnergyEvents()
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace OpenVulkano
|
||||
static bool IsDeviceInLowPowerMode();
|
||||
static bool GetDeviceHasBattery() { return GetDeviceBatteryState() != BatteryState::Unavailable; }
|
||||
static BatteryState GetDeviceBatteryState();
|
||||
// 0 to 1; -1 not available
|
||||
static float GetDeviceBatteryLevel();
|
||||
static void EnableEnergyEvents();
|
||||
|
||||
|
||||
@@ -4,24 +4,46 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#define _WIN32_DCOM
|
||||
|
||||
#include "Host/SystemInfo.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include <iostream>
|
||||
#include <utf8.h>
|
||||
#include <Windows.h>
|
||||
#include <Psapi.h>
|
||||
#include <Lmcons.h>
|
||||
#include <Winsock.h>
|
||||
#include <Winbase.h>
|
||||
#include <powersetting.h>
|
||||
#include <guiddef.h>
|
||||
#include <comdef.h>
|
||||
#include <Wbemidl.h>
|
||||
|
||||
// NOTE(vb): Windows defines macros like GetUserName that are used to automatically select the appropriate function version (GetUserNameA for ANSI and GetUserNameW for Unicode)
|
||||
// based on whether the _UNICODE macro is defined, so we manually undefine these macros to avoid naming collisions.
|
||||
#undef GetUserName
|
||||
|
||||
// link this for power settings
|
||||
#pragma comment(lib, "PowrProf.lib")
|
||||
#pragma comment(lib, "wbemuuid.lib")
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
namespace
|
||||
{
|
||||
enum class SYS_MEM_TYPE { TOTAL_PHYS, AVAIL_PHYS };
|
||||
|
||||
enum BatteryChargeStatus
|
||||
{
|
||||
MEDIUM = 0, // [low, high]
|
||||
HIGH = 1, // > 66%
|
||||
LOW = 2, // < 33%
|
||||
CRITICAL = 4, // <5%
|
||||
CHARGING = 8,
|
||||
NO_SYSTEM_BATTERY = 128,
|
||||
UNKNOWN = 255
|
||||
};
|
||||
|
||||
size_t ReadSystemMemInfo(SYS_MEM_TYPE type)
|
||||
{
|
||||
@@ -67,6 +89,170 @@ namespace OpenVulkano
|
||||
Logger::PERF->error("Failed to get system commit limit");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::optional<std::string> GetWMIProperty(const std::string& propName)
|
||||
{
|
||||
std::optional<std::string> res;
|
||||
|
||||
// https://learn.microsoft.com/en-us/windows/win32/wmisdk/example-creating-a-wmi-application?redirectedfrom=MSDN
|
||||
HRESULT hres;
|
||||
|
||||
// Initialize COM.
|
||||
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
if (FAILED(hres))
|
||||
{
|
||||
Logger::APP->error("Failed to initialize COM library. Error code = 0x{}", hres);
|
||||
return {};
|
||||
}
|
||||
|
||||
// Initialize
|
||||
hres = CoInitializeSecurity(NULL,
|
||||
-1, // COM negotiates service
|
||||
NULL, // Authentication services
|
||||
NULL, // Reserved
|
||||
RPC_C_AUTHN_LEVEL_DEFAULT, // authentication
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, // Impersonation
|
||||
NULL, // Authentication info
|
||||
EOAC_NONE, // Additional capabilities
|
||||
NULL // Reserved
|
||||
);
|
||||
|
||||
|
||||
if (FAILED(hres))
|
||||
{
|
||||
Logger::APP->error("Failed to initialize security. Error code = 0x{}", hres);
|
||||
CoUninitialize();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Obtain the initial locator to Windows Management
|
||||
// on a particular host computer.
|
||||
IWbemLocator* pLoc = 0;
|
||||
|
||||
hres = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID*) &pLoc);
|
||||
|
||||
if (FAILED(hres))
|
||||
{
|
||||
Logger::APP->error("Failed to create IWbemLocator object. Error code = 0x{}", hres);
|
||||
CoUninitialize();
|
||||
return {};
|
||||
}
|
||||
|
||||
IWbemServices* pSvc = 0;
|
||||
|
||||
// Connect to the root\cimv2 namespace with the
|
||||
// current user and obtain pointer pSvc
|
||||
// to make IWbemServices calls.
|
||||
|
||||
hres = pLoc->ConnectServer(
|
||||
_bstr_t(L"ROOT\\CIMV2"), // WMI namespace
|
||||
NULL, // User name
|
||||
NULL, // User password
|
||||
0, // Locale
|
||||
NULL, // Security flags
|
||||
0, // Authority
|
||||
0, // Context object
|
||||
&pSvc // IWbemServices proxy
|
||||
);
|
||||
|
||||
if (FAILED(hres))
|
||||
{
|
||||
Logger::APP->error("Could not connect. Error code = 0x{}", hres);
|
||||
pLoc->Release();
|
||||
CoUninitialize();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Set the IWbemServices proxy so that impersonation
|
||||
// of the user (client) occurs.
|
||||
hres = CoSetProxyBlanket(
|
||||
pSvc, // the proxy to set
|
||||
RPC_C_AUTHN_WINNT, // authentication service
|
||||
RPC_C_AUTHZ_NONE, // authorization service
|
||||
NULL, // Server principal name
|
||||
RPC_C_AUTHN_LEVEL_CALL, // authentication level
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE, // impersonation level
|
||||
NULL, // client identity
|
||||
EOAC_NONE // proxy capabilities
|
||||
);
|
||||
|
||||
if (FAILED(hres))
|
||||
{
|
||||
Logger::APP->error("Could not set proxy blanket. Error code = 0x{}", hres);
|
||||
pSvc->Release();
|
||||
pLoc->Release();
|
||||
CoUninitialize();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Use the IWbemServices pointer to make requests of WMI.
|
||||
// Make requests here:
|
||||
|
||||
// For example, query for all the running processes
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
hres = pSvc->ExecQuery(bstr_t("WQL"), bstr_t("SELECT * FROM Win32_ComputerSystem"),
|
||||
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
|
||||
|
||||
if (FAILED(hres))
|
||||
{
|
||||
Logger::APP->error("Query for processes failed. Error code = 0x{}", hres);
|
||||
pSvc->Release();
|
||||
pLoc->Release();
|
||||
CoUninitialize();
|
||||
return {};
|
||||
}
|
||||
else
|
||||
{
|
||||
IWbemClassObject* pclsObj;
|
||||
ULONG uReturn = 0;
|
||||
|
||||
while (pEnumerator)
|
||||
{
|
||||
hres = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
|
||||
|
||||
if (0 == uReturn)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
VARIANT vtProp;
|
||||
ZeroMemory(&vtProp, sizeof(vtProp));
|
||||
|
||||
std::wstring propNameUtf16;
|
||||
utf8::utf8to16(propName.begin(), propName.end(), std::back_inserter(propNameUtf16));
|
||||
|
||||
// Get the value of the specified property
|
||||
hres = pclsObj->Get(propNameUtf16.data(), 0, &vtProp, 0, 0);
|
||||
|
||||
if (FAILED(hres))
|
||||
{
|
||||
Logger::APP->error("Failed to get property {}. Error code = 0x{}", propName, hres);
|
||||
}
|
||||
else
|
||||
{
|
||||
// init optional
|
||||
res = "";
|
||||
std::wstring propValue = vtProp.bstrVal;
|
||||
utf8::utf16to8(propValue.begin(), propValue.end(), std::back_inserter(*res));
|
||||
}
|
||||
VariantClear(&vtProp);
|
||||
pclsObj->Release();
|
||||
pclsObj = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
// ========
|
||||
|
||||
pSvc->Release();
|
||||
pLoc->Release();
|
||||
pEnumerator->Release();
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
size_t SystemInfo::GetSystemRam()
|
||||
@@ -124,12 +310,14 @@ namespace OpenVulkano
|
||||
|
||||
std::string SystemInfo::GetDeviceVendorName()
|
||||
{
|
||||
return "Microsoft"; //TODO
|
||||
std::optional<std::string> res = GetWMIProperty("Manufacturer");
|
||||
return res ? *res : "Unknown";
|
||||
}
|
||||
|
||||
std::string SystemInfo::GetDeviceModelName()
|
||||
{
|
||||
return "Unknown"; //TODO
|
||||
{
|
||||
std::optional<std::string> res = GetWMIProperty("Model");
|
||||
return res ? *res : "Unknown";
|
||||
}
|
||||
|
||||
std::string SystemInfo::GetOsName()
|
||||
@@ -137,25 +325,31 @@ namespace OpenVulkano
|
||||
return "Windows";
|
||||
}
|
||||
|
||||
OsVersion SystemInfo::GetOsVersion()
|
||||
OsVersion SystemInfo::GetOsVersion()
|
||||
{
|
||||
OSVERSIONINFOA info;
|
||||
ZeroMemory(&info, sizeof(OSVERSIONINFOA));
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
||||
GetVersionExA(&info);
|
||||
NTSTATUS(WINAPI * RtlGetVersion)(LPOSVERSIONINFOEXW);
|
||||
OSVERSIONINFOEXW info;
|
||||
*(FARPROC*) &RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
|
||||
info.dwOSVersionInfoSize = sizeof(info);
|
||||
RtlGetVersion(&info);
|
||||
return { (int)info.dwMajorVersion, (int)info.dwMinorVersion, 0, (int)info.dwBuildNumber };
|
||||
}
|
||||
|
||||
std::string SystemInfo::GetOsNameHumanReadable()
|
||||
{
|
||||
OSVERSIONINFOEXA info;
|
||||
ZeroMemory(&info, sizeof(OSVERSIONINFOEXA));
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
|
||||
GetVersionEx((OSVERSIONINFOA *)&info);
|
||||
NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
|
||||
OSVERSIONINFOEXW info;
|
||||
*(FARPROC*)&RtlGetVersion = GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
|
||||
info.dwOSVersionInfoSize = sizeof(info);
|
||||
RtlGetVersion(&info);
|
||||
if (info.wProductType == VER_NT_WORKSTATION)
|
||||
{
|
||||
if (info.dwMajorVersion == 10)
|
||||
{
|
||||
if (info.dwBuildNumber >= 22000)
|
||||
return "Windows 11";
|
||||
return "Windows 10";
|
||||
}
|
||||
else if (info.dwMajorVersion == 6)
|
||||
{
|
||||
switch (info.dwMinorVersion)
|
||||
@@ -172,7 +366,35 @@ namespace OpenVulkano
|
||||
else
|
||||
{
|
||||
if (info.dwMajorVersion == 10)
|
||||
return "Windows Server 2016";
|
||||
{
|
||||
switch (info.dwBuildNumber)
|
||||
{
|
||||
case 14393:
|
||||
return "Windows Server 2016";
|
||||
case 16299:
|
||||
return "Windows Server 1709";
|
||||
case 17134:
|
||||
return "Windows Server 1803";
|
||||
case 17763:
|
||||
return "Windows Server 2019";
|
||||
case 18362:
|
||||
return "Windows Server 1903";
|
||||
case 18363:
|
||||
return "Windows Server 1909";
|
||||
case 19041:
|
||||
return "Windows Server 2004";
|
||||
case 19042:
|
||||
return "Windows Server 20H2";
|
||||
case 20348:
|
||||
return "Windows Server 2022";
|
||||
case 25398:
|
||||
return "Windows Server 23H2";
|
||||
case 26100:
|
||||
return "Windows Server 2025";
|
||||
default:
|
||||
return "Windows Server";
|
||||
}
|
||||
}
|
||||
else if (info.dwMajorVersion == 6)
|
||||
{
|
||||
switch (info.dwMinorVersion)
|
||||
@@ -188,17 +410,33 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
DeviceType SystemInfo::GetDeviceType()
|
||||
DeviceType SystemInfo::GetDeviceType()
|
||||
{
|
||||
return DeviceType::PC;
|
||||
}
|
||||
|
||||
size_t SystemInfo::GetCpuCoreCount()
|
||||
size_t SystemInfo::GetCpuCoreCount()
|
||||
{
|
||||
return 0; //TODO
|
||||
DWORD bufferSize = 0;
|
||||
GetLogicalProcessorInformationEx(LOGICAL_PROCESSOR_RELATIONSHIP::RelationProcessorCore, nullptr, &bufferSize);
|
||||
|
||||
std::vector<BYTE> buf(bufferSize);
|
||||
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* info = reinterpret_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*>(buf.data());
|
||||
GetLogicalProcessorInformationEx(LOGICAL_PROCESSOR_RELATIONSHIP::RelationProcessorCore, info, &bufferSize);
|
||||
|
||||
size_t physProcessorCount = 0;
|
||||
BYTE* start = buf.data();
|
||||
BYTE* end = buf.data() + bufferSize;
|
||||
while (start < end)
|
||||
{
|
||||
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* current = reinterpret_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*>(start);
|
||||
physProcessorCount++;
|
||||
start += current->Size;
|
||||
}
|
||||
return physProcessorCount;
|
||||
}
|
||||
|
||||
size_t SystemInfo::GetCpuThreadCount()
|
||||
size_t SystemInfo::GetCpuThreadCount()
|
||||
{
|
||||
return std::thread::hardware_concurrency();
|
||||
}
|
||||
@@ -210,22 +448,46 @@ namespace OpenVulkano
|
||||
|
||||
CpuThermalState SystemInfo::GetCpuThermalState()
|
||||
{
|
||||
return CpuThermalState::Normal;
|
||||
return CpuThermalState::Normal; // TODO
|
||||
}
|
||||
|
||||
bool SystemInfo::IsDeviceInLowPowerMode()
|
||||
{
|
||||
return false; //TODO
|
||||
GUID* activePowerMode;
|
||||
bool res = false;
|
||||
if(PowerGetActiveScheme(0, &activePowerMode) == 0)
|
||||
{
|
||||
res = IsEqualGUID(*activePowerMode, GUID_MAX_POWER_SAVINGS);
|
||||
}
|
||||
LocalFree(activePowerMode);
|
||||
return res;
|
||||
}
|
||||
|
||||
BatteryState SystemInfo::GetDeviceBatteryState()
|
||||
{
|
||||
return BatteryState::Unavailable; //TODO
|
||||
SYSTEM_POWER_STATUS info;
|
||||
GetSystemPowerStatus(&info);
|
||||
BYTE batteryFlag = info.BatteryFlag;
|
||||
if (batteryFlag & BatteryChargeStatus::CHARGING)
|
||||
{
|
||||
if (info.BatteryLifePercent == 100)
|
||||
return BatteryState::ChargingFull;
|
||||
return BatteryState::Charging;
|
||||
}
|
||||
else if (batteryFlag < BatteryChargeStatus::CHARGING)
|
||||
{
|
||||
return BatteryState::Unplugged;
|
||||
}
|
||||
// BatteryState::NotCharging is impossible to distinguish
|
||||
// NO_SYSTEM_BATTERY or UNKNOWN
|
||||
return BatteryState::Unavailable;
|
||||
}
|
||||
|
||||
float SystemInfo::GetDeviceBatteryLevel()
|
||||
{
|
||||
return 0; //TODO
|
||||
SYSTEM_POWER_STATUS info;
|
||||
GetSystemPowerStatus(&info);
|
||||
return info.BatteryLifePercent != 255 ? (static_cast<float>(info.BatteryLifePercent / 100.f)) : -1.f;
|
||||
}
|
||||
|
||||
void SystemInfo::EnableEnergyEvents()
|
||||
@@ -240,7 +502,24 @@ namespace OpenVulkano
|
||||
|
||||
DeviceOrientation SystemInfo::GetDeviceOrientation()
|
||||
{
|
||||
return DeviceOrientation::LandscapeRight; //TODO
|
||||
DEVMODEA devmode;
|
||||
ZeroMemory(&devmode, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
if (EnumDisplaySettingsA(0, ENUM_CURRENT_SETTINGS, &devmode))
|
||||
{
|
||||
DWORD width = devmode.dmPelsWidth;
|
||||
DWORD height = devmode.dmPelsHeight;
|
||||
if (width > height)
|
||||
{
|
||||
// landscape
|
||||
return devmode.dmDisplayOrientation == DMDO_180 ? DeviceOrientation::LandscapeLeft :
|
||||
DeviceOrientation::LandscapeRight;
|
||||
}
|
||||
// portrait
|
||||
return devmode.dmDisplayOrientation == DMDO_180 ? DeviceOrientation::PortraitUpsideDown :
|
||||
DeviceOrientation::Portrait;
|
||||
}
|
||||
return DeviceOrientation::Unknown;
|
||||
}
|
||||
|
||||
void SystemInfo::EnableDeviceOrientationEvents()
|
||||
@@ -250,6 +529,19 @@ namespace OpenVulkano
|
||||
|
||||
InterfaceOrientation SystemInfo::GetInterfaceOrientation()
|
||||
{
|
||||
return InterfaceOrientation::Landscape; //TODO
|
||||
DeviceOrientation devOrient = GetDeviceOrientation();
|
||||
switch (devOrient)
|
||||
{
|
||||
case OpenVulkano::DeviceOrientation::Portrait:
|
||||
return InterfaceOrientation::Portrait;
|
||||
case OpenVulkano::DeviceOrientation::PortraitUpsideDown:
|
||||
return InterfaceOrientation::PortraitUpsideDown;
|
||||
case OpenVulkano::DeviceOrientation::LandscapeLeft:
|
||||
return InterfaceOrientation::LandscapeRight;
|
||||
case OpenVulkano::DeviceOrientation::LandscapeRight:
|
||||
return InterfaceOrientation::LandscapeLeft;
|
||||
default:
|
||||
return InterfaceOrientation::Landscape;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,3 +171,9 @@ namespace OpenVulkano::Math
|
||||
typedef Quaternion<double> QuaternionD;
|
||||
typedef Quaternion<int> QuaternionI;
|
||||
}
|
||||
|
||||
template<glm::length_t L, typename T, glm::qualifier Q, typename = std::enable_if_t<std::is_integral_v<T>>>
|
||||
glm::vec<L, float, Q> operator / (const float lhs, const glm::vec<L, T, Q>& rhs)
|
||||
{
|
||||
return lhs / glm::vec<L, float, Q>(rhs);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace OpenVulkano::Math
|
||||
template<typename T, typename = std::enable_if_t<std::is_floating_point_v<T>>>
|
||||
void SetNormalized(Vector4<T> vec4)
|
||||
{
|
||||
Set(Vector4<TYPE>(vec4 * static_cast<float>(MAX_VALUE)));
|
||||
Set(Vector4<TYPE>(Vector3<T>(vec4 * static_cast<T>(MAX_VALUE)), vec4.a * static_cast<T>(MAX_ALPHA_VALUE)));
|
||||
}
|
||||
|
||||
void SetNormalized(const Vector3uc& vec3)
|
||||
@@ -125,14 +125,14 @@ namespace OpenVulkano::Math
|
||||
value.x *= 4;
|
||||
value.y *= 4;
|
||||
value.z *= 4;
|
||||
value.w /= 255;
|
||||
value.w /= 85;
|
||||
}
|
||||
else
|
||||
{
|
||||
value.x *= 2;
|
||||
value.y *= 2;
|
||||
value.z *= 2;
|
||||
value.w /= 85;
|
||||
value.w /= 255;
|
||||
}
|
||||
SetUnchecked(value);
|
||||
}
|
||||
|
||||
@@ -28,12 +28,19 @@ namespace OpenVulkano::Scene
|
||||
UpdateFrequency updateFrequency = UpdateFrequency::Never;
|
||||
const SamplerConfig* m_samplerConfig;
|
||||
bool updated = true;
|
||||
bool ownsData = false;
|
||||
|
||||
Texture(const SamplerConfig* samplerConfig = &SamplerConfig::DEFAULT, bool placeholder = false)
|
||||
: m_samplerConfig(samplerConfig)
|
||||
{ if (placeholder) MakePlaceholder(); }
|
||||
|
||||
~Texture() = default;
|
||||
Texture(Math::Vector2ui resolution, DataFormat format) : resolution(resolution, 1), format(format), ownsData(true)
|
||||
{
|
||||
size = format.CalculatedSize(resolution.x, resolution.y);
|
||||
textureBuffer = malloc(size);
|
||||
}
|
||||
|
||||
~Texture() { if (ownsData) free(textureBuffer); }
|
||||
|
||||
void MakePlaceholder(uint32_t width = 32, uint32_t height = 32,
|
||||
Math::Vector4uc color1 = {248, 123, 255, 255}, Math::Vector4uc color2 = {250, 19, 255, 255});
|
||||
|
||||
30
openVulkanoCpp/Threading/Task.hpp
Normal file
30
openVulkanoCpp/Threading/Task.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
class Task
|
||||
{
|
||||
public:
|
||||
virtual ~Task() = default;
|
||||
virtual void Execute() {}
|
||||
};
|
||||
|
||||
class FunctionalTask final : public Task
|
||||
{
|
||||
std::function<void()> function;
|
||||
|
||||
public:
|
||||
FunctionalTask(const std::function<void()>& function) : function(function) {}
|
||||
FunctionalTask(std::function<void()>&& function) : function(std::move(function)) {}
|
||||
~FunctionalTask() override = default;
|
||||
void Execute() override { function(); }
|
||||
};
|
||||
}
|
||||
12
openVulkanoCpp/Threading/TaskPool.cpp
Normal file
12
openVulkanoCpp/Threading/TaskPool.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "TaskPool.hpp"
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
MainThreadTaskPool* MainThreadTaskPool::INSTANCE;
|
||||
}
|
||||
87
openVulkanoCpp/Threading/TaskPool.hpp
Normal file
87
openVulkanoCpp/Threading/TaskPool.hpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Task.hpp"
|
||||
#include "Base/Logger.hpp"
|
||||
#include "Base/Wrapper.hpp"
|
||||
#include <concurrentqueue.h>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
class ITaskPool
|
||||
{
|
||||
protected:
|
||||
void ExecuteTask(const Ptr<Task>& task)
|
||||
{
|
||||
try
|
||||
{
|
||||
task->Execute();
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
Logger::MANAGER->error("Failed to execute task! With exception: {}", e.what());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
Logger::MANAGER->error("Failed to execute task! With unknown throwable");
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
/*template<class T, typename... Args>
|
||||
void EmplaceTask(Args&&... args)
|
||||
{
|
||||
m_tasks.enqueue(std::make_shared<T>((std::forward<Args>(args)...)));
|
||||
}*/
|
||||
|
||||
virtual void Enqueue(const Ptr<Task>& task) = 0;
|
||||
|
||||
void Enqueue(const std::function<void()>& taskFunction)
|
||||
{
|
||||
Enqueue(std::make_shared<FunctionalTask>(taskFunction));
|
||||
}
|
||||
|
||||
void operator +=(const std::function<void()>& taskFunction)
|
||||
{
|
||||
Enqueue(taskFunction);
|
||||
}
|
||||
};
|
||||
|
||||
class MainThreadTaskPool final : public ITaskPool
|
||||
{
|
||||
static MainThreadTaskPool* INSTANCE;
|
||||
moodycamel::ConcurrentQueue<Ptr<Task>> m_tasks;
|
||||
|
||||
public:
|
||||
MainThreadTaskPool()
|
||||
{
|
||||
if (!INSTANCE) INSTANCE = this;
|
||||
}
|
||||
|
||||
~MainThreadTaskPool()
|
||||
{
|
||||
if (INSTANCE == this) INSTANCE = nullptr;
|
||||
}
|
||||
|
||||
static MainThreadTaskPool& GetInstance() { return *INSTANCE; }
|
||||
|
||||
void Tick()
|
||||
{
|
||||
Ptr<Task> task;
|
||||
while (m_tasks.try_dequeue(task))
|
||||
{
|
||||
ExecuteTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
void Enqueue(const Ptr<Task>& task) override
|
||||
{
|
||||
m_tasks.enqueue(task);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace OpenVulkano::Vulkan
|
||||
vkDestroySurfaceKHR(static_cast<VkInstance>(instance), surface, nullptr);
|
||||
//TODO
|
||||
|
||||
if (enableValidationLayer) Debug::CloseValidationLayers(instance);
|
||||
if (enableValidationLayer) Debug::CloseValidationLayers(instance, dynamicDispatch);
|
||||
|
||||
instance.destroy();
|
||||
initialized = false;
|
||||
@@ -77,9 +77,9 @@ namespace OpenVulkano::Vulkan
|
||||
#endif
|
||||
|
||||
instance = vk::createInstance(createInfo);
|
||||
|
||||
if (enableValidationLayer) Debug::SetupValidationLayers(instance, vk::DebugReportFlagBitsEXT::eError | vk::DebugReportFlagBitsEXT::eWarning | vk::DebugReportFlagBitsEXT::ePerformanceWarning /*| vk::DebugReportFlagBitsEXT::eInformation | vk::DebugReportFlagBitsEXT::eDebug*/);
|
||||
dynamicDispatch.init(instance, &vkGetInstanceProcAddr);
|
||||
|
||||
if (enableValidationLayer) Debug::SetupValidationLayers(instance, vk::DebugReportFlagBitsEXT::eError | vk::DebugReportFlagBitsEXT::eWarning | vk::DebugReportFlagBitsEXT::ePerformanceWarning /*| vk::DebugReportFlagBitsEXT::eInformation | vk::DebugReportFlagBitsEXT::eDebug*/, dynamicDispatch);
|
||||
}
|
||||
|
||||
void Context::CreateDevice()
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include "Debuging/ValidationLayer.hpp"
|
||||
#include "DeviceManager.hpp"
|
||||
#include "SwapChain.hpp"
|
||||
#include "RenderPass.hpp"
|
||||
|
||||
@@ -72,24 +72,23 @@ namespace OpenVulkano::Vulkan
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::once_flag dispatcherInitFlag;
|
||||
vk::DispatchLoaderDynamic dispatcher;
|
||||
vk::DebugReportCallbackEXT msgCallback;
|
||||
namespace
|
||||
{
|
||||
vk::DebugReportCallbackEXT msgCallback;
|
||||
}
|
||||
|
||||
void Debug::SetupValidationLayers(const vk::Instance& instance, const vk::DebugReportFlagsEXT& flags)
|
||||
void Debug::SetupValidationLayers(const vk::Instance& instance, const vk::DebugReportFlagsEXT& flags, vk::DispatchLoaderDynamic& dispatchLoaderDynamic)
|
||||
{
|
||||
Logger::RENDER->info("Setting up Vulkan Validation Layer");
|
||||
std::call_once(dispatcherInitFlag, [&] { dispatcher.init(instance, &vkGetInstanceProcAddr); });
|
||||
vk::DebugReportCallbackCreateInfoEXT dbgCreateInfo = {};
|
||||
dbgCreateInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT)ValidationLayerCallback;
|
||||
dbgCreateInfo.flags = flags;
|
||||
msgCallback = instance.createDebugReportCallbackEXT(dbgCreateInfo, nullptr, dispatcher);
|
||||
msgCallback = instance.createDebugReportCallbackEXT(dbgCreateInfo, nullptr, dispatchLoaderDynamic);
|
||||
Logger::RENDER->info("Vulkan Validation Layer setup");
|
||||
}
|
||||
|
||||
void Debug::CloseValidationLayers(const vk::Instance& instance)
|
||||
void Debug::CloseValidationLayers(const vk::Instance& instance, vk::DispatchLoaderDynamic& dispatchLoaderDynamic)
|
||||
{
|
||||
std::call_once(dispatcherInitFlag, [&] { dispatcher.init(instance, &vkGetInstanceProcAddr); });
|
||||
instance.destroyDebugReportCallbackEXT(msgCallback, nullptr, dispatcher);
|
||||
instance.destroyDebugReportCallbackEXT(msgCallback, nullptr, dispatchLoaderDynamic);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,15 @@
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#if VK_HEADER_VERSION > 302
|
||||
// Vulkan 1.4.303 moved the dynamic dispatch loader definition,
|
||||
// this is a workaround to allow building for both the old and the new verisons
|
||||
namespace vk
|
||||
{
|
||||
using DispatchLoaderDynamic = detail::DispatchLoaderDynamic;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace OpenVulkano::Vulkan
|
||||
{
|
||||
class Debug
|
||||
@@ -20,8 +29,8 @@ namespace OpenVulkano::Vulkan
|
||||
|
||||
static std::vector<const char*> GetValidationLayers();
|
||||
|
||||
static void SetupValidationLayers(const vk::Instance& instance, const vk::DebugReportFlagsEXT& flags);
|
||||
static void SetupValidationLayers(const vk::Instance& instance, const vk::DebugReportFlagsEXT& flags, vk::DispatchLoaderDynamic& dispatchLoaderDynamic);
|
||||
|
||||
static void CloseValidationLayers(const vk::Instance& instance);
|
||||
static void CloseValidationLayers(const vk::Instance& instance, vk::DispatchLoaderDynamic& dispatchLoaderDynamic);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "Context.hpp"
|
||||
#include "UiRenderer.hpp"
|
||||
#include "Resources/ResourceManager.hpp"
|
||||
#include "Data/ReadOnlyAtomicArrayQueue.hpp"
|
||||
#include "Data/Concurent/Containers/ReadOnlyAtomicArrayQueue.hpp"
|
||||
#include "CommandHelper.hpp"
|
||||
#include "Base/EngineConfiguration.hpp"
|
||||
#include "Resources/ResourceManager.hpp"
|
||||
|
||||
Reference in New Issue
Block a user