Formatting and minor changes.
This commit is contained in:
parent
60a7609963
commit
7f8e18ff97
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
int main(int, char **) {
|
||||
GlfwContext glfw = {};
|
||||
Context context = {"Aster", VERSION};
|
||||
Window window = {"Aster1", &context, { 640, 480 }};
|
||||
Context context = { "Aster", VERSION };
|
||||
Window window = { "Aster1", &context, { 640, 480 } };
|
||||
|
||||
while (window.poll()) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,9 +52,7 @@ void Context::init(const std::string_view &_app_name, const Version &_app_versio
|
|||
};
|
||||
|
||||
u32 glfw_extension_count = 0;
|
||||
const char **glfw_extensions = nullptr;
|
||||
|
||||
glfw_extensions = glfwGetRequiredInstanceExtensions(&glfw_extension_count);
|
||||
const char **glfw_extensions = glfwGetRequiredInstanceExtensions(&glfw_extension_count);
|
||||
std::vector<const char *> vulkan_extensions(glfw_extensions, glfw_extensions + glfw_extension_count);
|
||||
if (enable_validation_layers) {
|
||||
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) {
|
||||
ERROR("Failed to create Vulkan instance with "s + err.what());
|
||||
throw err;
|
||||
throw;
|
||||
}
|
||||
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 };
|
||||
} catch (const std::exception &err) {
|
||||
ERROR("Debug Messenger creation failed with "s + err.what());
|
||||
throw err;
|
||||
throw;
|
||||
}
|
||||
INFO("Debug Messenger Created.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,16 @@
|
|||
#include <vector>
|
||||
|
||||
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 {
|
||||
if (this == &_other)
|
||||
return *this;
|
||||
physical_device = _other.physical_device;
|
||||
physical_device = std::move(_other.physical_device);
|
||||
device = std::exchange(_other.device, nullptr);
|
||||
queues = _other.queues;
|
||||
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::vector<vk::DeviceQueueCreateInfo> queue_create_infos;
|
||||
queue_create_infos.reserve(unique_queue_families.size());
|
||||
for (auto &[index_, count_] : unique_queue_families) {
|
||||
queue_create_infos.push_back({
|
||||
.queueFamilyIndex = index_,
|
||||
|
|
@ -60,7 +65,7 @@ Device::Device(const std::string_view &_name, Context *_context, const PhysicalD
|
|||
});
|
||||
} catch (const std::exception &err) {
|
||||
ERROR("Failed to create a logical device with "s + err.what());
|
||||
throw err;
|
||||
throw;
|
||||
}
|
||||
INFO("Logical Device Created!");
|
||||
|
||||
|
|
@ -70,7 +75,8 @@ Device::Device(const std::string_view &_name, Context *_context, const PhysicalD
|
|||
.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)) {
|
||||
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 {
|
||||
public:
|
||||
|
||||
Device(const Device &_other) = delete;
|
||||
Device(Device &&_other) noexcept;
|
||||
Device &operator=(const Device &_other) = delete;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
struct GlfwContext {
|
||||
static i32 post_error() noexcept {
|
||||
static const char* error_ = nullptr;
|
||||
static const char *error_ = nullptr;
|
||||
const auto code = glfwGetError(&error_);
|
||||
ERROR("GLFW "s + error_);
|
||||
return code;
|
||||
|
|
@ -18,7 +18,8 @@ struct GlfwContext {
|
|||
inline static u32 count = 0;
|
||||
|
||||
GlfwContext() {
|
||||
if (count++ > 0) return;
|
||||
if (count++ > 0)
|
||||
return;
|
||||
if (glfwInit() == GLFW_FALSE) {
|
||||
CRASH(post_error());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@
|
|||
#include "logger.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <fmt/core.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <string>
|
||||
#include <fmt/core.h>
|
||||
|
||||
#define VULKAN_HPP_ASSERT(expr) DEBUG_IF(!(expr), "Vulkan assert failed")
|
||||
#include <vk_mem_alloc.h>
|
||||
|
|
|
|||
|
|
@ -5,13 +5,4 @@
|
|||
|
||||
#include "logger.h"
|
||||
|
||||
Logger g_logger = Logger();
|
||||
|
||||
/* Credits to Const-me */
|
||||
//namespace eastl {
|
||||
// void __cdecl AssertionFailure(const char* af)
|
||||
// {
|
||||
// ERROR(af);
|
||||
// __debugbreak();
|
||||
// }
|
||||
//}
|
||||
auto g_logger = Logger();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ struct Logger {
|
|||
return "[DEBUG]:";
|
||||
if constexpr (LogLevel == LogType::eVerbose)
|
||||
return "[VERB]: ";
|
||||
return "";
|
||||
}
|
||||
|
||||
template <LogType LogLevel>
|
||||
|
|
@ -50,6 +51,7 @@ struct Logger {
|
|||
return ANSI_White;
|
||||
if constexpr (LogLevel == LogType::eVerbose)
|
||||
return ANSI_Blue;
|
||||
return "";
|
||||
}
|
||||
|
||||
template <LogType LogLevel>
|
||||
|
|
@ -65,7 +67,7 @@ struct Logger {
|
|||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ QueueFamilyIndices PhysicalDevice::get_queue_families(const Window *_window, con
|
|||
continue;
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& err) {
|
||||
} catch (const std::exception &err) {
|
||||
ERROR("Failure in finding surface support, all possibilities fatal. Failed with "s + err.what());
|
||||
throw err;
|
||||
throw;
|
||||
}
|
||||
|
||||
++family_index;
|
||||
|
|
|
|||
|
|
@ -47,5 +47,5 @@ struct PhysicalDevice {
|
|||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]] static QueueFamilyIndices get_queue_families(const Window * _window, const vk::raii::PhysicalDevice* _device) ;
|
||||
[[nodiscard]] static QueueFamilyIndices get_queue_families(const Window *_window, const vk::raii::PhysicalDevice *_device);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue