Added cast operator for VkInstance
Now maintains a list of enabled extensions
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "vulkan/basalt_window.h"
|
||||
#include "containers/basalt_darray.h"
|
||||
|
||||
namespace basalt
|
||||
{
|
||||
@@ -15,9 +14,14 @@ namespace basalt
|
||||
Context(const char* app_name, const basalt::darray<const char*>& required_layers, const basalt::darray<const char*>& required_extensions, uint32_t app_version=VK_MAKE_API_VERSION(1, 1, 0, 0), uint32_t vulkan_version = VK_MAKE_API_VERSION(0, 1, 2, 0));
|
||||
~Context();
|
||||
|
||||
operator VkInstance(void) const noexcept;
|
||||
|
||||
VkInstance inst = VK_NULL_HANDLE;
|
||||
VkAllocationCallbacks* vk_alloc = VK_NULL_HANDLE;
|
||||
VkDebugUtilsMessengerEXT dbg_msger = VK_NULL_HANDLE;
|
||||
|
||||
const char** pp_enabled_layers = nullptr;
|
||||
u32 num_enabled_layers = 0;
|
||||
|
||||
bool should_free = true;
|
||||
bool using_validation_layers = false;
|
||||
|
||||
@@ -78,6 +78,10 @@ basalt::Context::Context(const char* app_name,
|
||||
ci.enabledLayerCount = required_layers.m_nelements;
|
||||
ci.ppEnabledLayerNames = required_layers.m_pdata;
|
||||
|
||||
this->num_enabled_layers = required_layers.m_nelements;
|
||||
this->pp_enabled_layers = basalt::mem::allocT<const char*>(required_layers.m_nelements, MEMORY_TAG_CLASS_ARRAY | MEMORY_TAG_ZONE_ENGINE | MEMORY_TAG_ALIGN_ANY);
|
||||
memcpy(this->pp_enabled_layers, required_layers.m_pdata, sizeof(const char*) * required_layers.m_nelements);
|
||||
|
||||
if (this->using_validation_layers)
|
||||
{
|
||||
dbg_ci.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT;
|
||||
@@ -113,8 +117,13 @@ basalt::Context::~Context()
|
||||
}
|
||||
if (this->inst != VK_NULL_HANDLE && this->should_free)
|
||||
vkDestroyInstance(this->inst, this->vk_alloc);
|
||||
if (this->pp_enabled_layers)
|
||||
basalt::mem::dealloc(this->pp_enabled_layers, this->num_enabled_layers * sizeof(const char*), MEMORY_TAG_CLASS_ARRAY | MEMORY_TAG_ZONE_ENGINE | MEMORY_TAG_ALIGN_ANY);
|
||||
}
|
||||
|
||||
basalt::Context::operator VkInstance(void) const noexcept
|
||||
{ return this->inst; }
|
||||
|
||||
|
||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
|
||||
VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||
|
||||
Reference in New Issue
Block a user