Formatting and minor changes.
This commit is contained in:
parent
60a7609963
commit
7f8e18ff97
|
|
@ -52,9 +52,7 @@ void Context::init(const std::string_view &_app_name, const Version &_app_versio
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 glfw_extension_count = 0;
|
u32 glfw_extension_count = 0;
|
||||||
const char **glfw_extensions = nullptr;
|
const char **glfw_extensions = glfwGetRequiredInstanceExtensions(&glfw_extension_count);
|
||||||
|
|
||||||
glfw_extensions = glfwGetRequiredInstanceExtensions(&glfw_extension_count);
|
|
||||||
std::vector<const char *> vulkan_extensions(glfw_extensions, glfw_extensions + glfw_extension_count);
|
std::vector<const char *> vulkan_extensions(glfw_extensions, glfw_extensions + glfw_extension_count);
|
||||||
if (enable_validation_layers) {
|
if (enable_validation_layers) {
|
||||||
vulkan_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
vulkan_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
|
|
@ -76,7 +74,7 @@ void Context::init(const std::string_view &_app_name, const Version &_app_versio
|
||||||
} };
|
} };
|
||||||
} catch (const std::exception &err) {
|
} catch (const std::exception &err) {
|
||||||
ERROR("Failed to create Vulkan instance with "s + err.what());
|
ERROR("Failed to create Vulkan instance with "s + err.what());
|
||||||
throw err;
|
throw;
|
||||||
}
|
}
|
||||||
INFO("Instance Created.");
|
INFO("Instance Created.");
|
||||||
|
|
||||||
|
|
@ -86,7 +84,7 @@ void Context::init(const std::string_view &_app_name, const Version &_app_versio
|
||||||
debug_messenger = vk::raii::DebugUtilsMessengerEXT{ instance, debug_messenger_create_info };
|
debug_messenger = vk::raii::DebugUtilsMessengerEXT{ instance, debug_messenger_create_info };
|
||||||
} catch (const std::exception &err) {
|
} catch (const std::exception &err) {
|
||||||
ERROR("Debug Messenger creation failed with "s + err.what());
|
ERROR("Debug Messenger creation failed with "s + err.what());
|
||||||
throw err;
|
throw;
|
||||||
}
|
}
|
||||||
INFO("Debug Messenger Created.");
|
INFO("Debug Messenger Created.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,16 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
Device::Device(Device &&_other) noexcept :
|
Device::Device(Device &&_other) noexcept :
|
||||||
physical_device{ _other.physical_device }, device{ std::exchange(_other.device, nullptr) }, queues{ _other.queues }, allocator{ std::exchange(_other.allocator, nullptr) }, name{ std::move(_other.name) } {}
|
physical_device{ std::move(_other.physical_device) },
|
||||||
|
device{ std::exchange(_other.device, nullptr) },
|
||||||
|
queues{ _other.queues },
|
||||||
|
allocator{ std::exchange(_other.allocator, nullptr) },
|
||||||
|
name{ std::move(_other.name) } {}
|
||||||
|
|
||||||
Device &Device::operator=(Device &&_other) noexcept {
|
Device &Device::operator=(Device &&_other) noexcept {
|
||||||
if (this == &_other)
|
if (this == &_other)
|
||||||
return *this;
|
return *this;
|
||||||
physical_device = _other.physical_device;
|
physical_device = std::move(_other.physical_device);
|
||||||
device = std::exchange(_other.device, nullptr);
|
device = std::exchange(_other.device, nullptr);
|
||||||
queues = _other.queues;
|
queues = _other.queues;
|
||||||
allocator = std::exchange(_other.allocator, nullptr);
|
allocator = std::exchange(_other.allocator, nullptr);
|
||||||
|
|
@ -41,6 +45,7 @@ Device::Device(const std::string_view &_name, Context *_context, const PhysicalD
|
||||||
|
|
||||||
std::array<f32, 4> queue_priority = { 1.0f, 1.0f, 1.0f, 1.0f };
|
std::array<f32, 4> queue_priority = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||||
std::vector<vk::DeviceQueueCreateInfo> queue_create_infos;
|
std::vector<vk::DeviceQueueCreateInfo> queue_create_infos;
|
||||||
|
queue_create_infos.reserve(unique_queue_families.size());
|
||||||
for (auto &[index_, count_] : unique_queue_families) {
|
for (auto &[index_, count_] : unique_queue_families) {
|
||||||
queue_create_infos.push_back({
|
queue_create_infos.push_back({
|
||||||
.queueFamilyIndex = index_,
|
.queueFamilyIndex = index_,
|
||||||
|
|
@ -60,7 +65,7 @@ Device::Device(const std::string_view &_name, Context *_context, const PhysicalD
|
||||||
});
|
});
|
||||||
} catch (const std::exception &err) {
|
} catch (const std::exception &err) {
|
||||||
ERROR("Failed to create a logical device with "s + err.what());
|
ERROR("Failed to create a logical device with "s + err.what());
|
||||||
throw err;
|
throw;
|
||||||
}
|
}
|
||||||
INFO("Logical Device Created!");
|
INFO("Logical Device Created!");
|
||||||
|
|
||||||
|
|
@ -70,7 +75,8 @@ Device::Device(const std::string_view &_name, Context *_context, const PhysicalD
|
||||||
.instance = *_context->instance,
|
.instance = *_context->instance,
|
||||||
};
|
};
|
||||||
|
|
||||||
auto result = cast<vk::Result>(vmaCreateAllocator(&allocator_create_info, &allocator));
|
allocator = nullptr;
|
||||||
|
const auto result = cast<vk::Result>(vmaCreateAllocator(&allocator_create_info, &allocator));
|
||||||
if (failed(result)) {
|
if (failed(result)) {
|
||||||
ERROR("Memory allocator creation failed with "s + vk::to_string(result));
|
ERROR("Memory allocator creation failed with "s + vk::to_string(result));
|
||||||
throw std::runtime_error("Memory allocator creation failed with "s + vk::to_string(result));
|
throw std::runtime_error("Memory allocator creation failed with "s + vk::to_string(result));
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ struct SubmitTask;
|
||||||
|
|
||||||
class Device {
|
class Device {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Device(const Device &_other) = delete;
|
Device(const Device &_other) = delete;
|
||||||
Device(Device &&_other) noexcept;
|
Device(Device &&_other) noexcept;
|
||||||
Device &operator=(const Device &_other) = delete;
|
Device &operator=(const Device &_other) = delete;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ struct GlfwContext {
|
||||||
inline static u32 count = 0;
|
inline static u32 count = 0;
|
||||||
|
|
||||||
GlfwContext() {
|
GlfwContext() {
|
||||||
if (count++ > 0) return;
|
if (count++ > 0)
|
||||||
|
return;
|
||||||
if (glfwInit() == GLFW_FALSE) {
|
if (glfwInit() == GLFW_FALSE) {
|
||||||
CRASH(post_error());
|
CRASH(post_error());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <fmt/core.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fmt/core.h>
|
|
||||||
|
|
||||||
#define VULKAN_HPP_ASSERT(expr) DEBUG_IF(!(expr), "Vulkan assert failed")
|
#define VULKAN_HPP_ASSERT(expr) DEBUG_IF(!(expr), "Vulkan assert failed")
|
||||||
#include <vk_mem_alloc.h>
|
#include <vk_mem_alloc.h>
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,4 @@
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
Logger g_logger = Logger();
|
auto g_logger = Logger();
|
||||||
|
|
||||||
/* Credits to Const-me */
|
|
||||||
//namespace eastl {
|
|
||||||
// void __cdecl AssertionFailure(const char* af)
|
|
||||||
// {
|
|
||||||
// ERROR(af);
|
|
||||||
// __debugbreak();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ struct Logger {
|
||||||
return "[DEBUG]:";
|
return "[DEBUG]:";
|
||||||
if constexpr (LogLevel == LogType::eVerbose)
|
if constexpr (LogLevel == LogType::eVerbose)
|
||||||
return "[VERB]: ";
|
return "[VERB]: ";
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <LogType LogLevel>
|
template <LogType LogLevel>
|
||||||
|
|
@ -50,6 +51,7 @@ struct Logger {
|
||||||
return ANSI_White;
|
return ANSI_White;
|
||||||
if constexpr (LogLevel == LogType::eVerbose)
|
if constexpr (LogLevel == LogType::eVerbose)
|
||||||
return ANSI_Blue;
|
return ANSI_Blue;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <LogType LogLevel>
|
template <LogType LogLevel>
|
||||||
|
|
@ -65,7 +67,7 @@ struct Logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <LogType LogLevel>
|
template <LogType LogLevel>
|
||||||
void log_cond(const char *_expr_str, const std::string_view &_message, const char *_loc, u32 _line) const {
|
void log_cond(const char *_expr_str, const std::string_view &_message, const char *_loc, const u32 _line) const {
|
||||||
if (cast<u32>(LogLevel) <= minimum_logging_level) {
|
if (cast<u32>(LogLevel) <= minimum_logging_level) {
|
||||||
printf("%s%s (%s) %s%s| at %s:%u%s\n", to_color_cstr<LogLevel>(), to_cstr<LogLevel>(), _expr_str, _message.data(), ANSI_Black, _loc, _line, ANSI_Reset);
|
printf("%s%s (%s) %s%s| at %s:%u%s\n", to_color_cstr<LogLevel>(), to_cstr<LogLevel>(), _expr_str, _message.data(), ANSI_Black, _loc, _line, ANSI_Reset);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ QueueFamilyIndices PhysicalDevice::get_queue_families(const Window *_window, con
|
||||||
}
|
}
|
||||||
} catch (const std::exception &err) {
|
} catch (const std::exception &err) {
|
||||||
ERROR("Failure in finding surface support, all possibilities fatal. Failed with "s + err.what());
|
ERROR("Failure in finding surface support, all possibilities fatal. Failed with "s + err.what());
|
||||||
throw err;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
++family_index;
|
++family_index;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue