move even more arrays to the ptk ones

This commit is contained in:
jacekpoz 2024-09-08 12:58:58 +02:00
parent 5c8a21b375
commit b30ff30ed0
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -32,6 +32,7 @@ PTK_LIST_DEFINE(voidptr);
PTK_LIST_DEFINE(VkDescriptorSet);
typedef const char *constcharptr;
PTK_ARRAY_DEFINE(constcharptr);
PTK_LIST_DEFINE(constcharptr);
#ifdef DEBUG
PTK_LIST_DEFINE(VkLayerProperties);
@ -68,10 +69,9 @@ static const size_t m_queue_family_count = sizeof(m_queue_family_indices) / size
VkQueue g_graphics_queue = VK_NULL_HANDLE;
VkQueue g_present_queue = VK_NULL_HANDLE;
static const size_t m_device_extension_count = 1;
static const char *m_device_extensions[] = {
static const PTK_ARRAY(constcharptr) m_device_extensions = PTK_ARRAY_NEW(constcharptr, {
VK_KHR_SWAPCHAIN_EXTENSION_NAME
};
});
static VkRenderPass m_render_pass;
static VkDescriptorSetLayout m_descriptor_set_layout;
@ -184,8 +184,8 @@ bool create_vk_instance(const char *title, const PtkVersion version) {
}
#endif
uint32_t extension_count = 0;
const char * const *extension_names = glfwGetRequiredInstanceExtensions(&extension_count);
PTK_ARRAY(constcharptr) extension_names = PTK_ARRAY_EMPTY(constcharptr);
extension_names.data = glfwGetRequiredInstanceExtensions(&extension_names.size);
VK_TRY(false,
vkCreateInstance(
@ -204,8 +204,8 @@ bool create_vk_instance(const char *title, const PtkVersion version) {
},
.enabledLayerCount = m_validation_layers.size,
.ppEnabledLayerNames = m_validation_layers.data,
.enabledExtensionCount = extension_count,
.ppEnabledExtensionNames = extension_names,
.enabledExtensionCount = extension_names.size,
.ppEnabledExtensionNames = extension_names.data,
},
NULL,
&m_instance
@ -381,16 +381,16 @@ bool are_extensions_supported(const VkPhysicalDevice dev) {
size_t supported_extensions = 0;
for (size_t i = 0; i < m_device_extension_count; ++i) {
for (size_t i = 0; i < m_device_extensions.size; ++i) {
PTK_LIST_FOR_EACH(const VkExtensionProperties, available_extensions, current_extension, {
if (strcmp(m_device_extensions[i], current_extension.extensionName) == 0) {
if (strcmp(m_device_extensions.data[i], current_extension.extensionName) == 0) {
supported_extensions += 1;
break;
}
})
}
return supported_extensions == m_device_extension_count;
return supported_extensions == m_device_extensions.size;
}
bool is_device_suitable(const VkPhysicalDevice dev) {
@ -465,8 +465,8 @@ bool create_logical_dev(void) {
.pQueueCreateInfos = queue_create_infos,
.enabledLayerCount = m_validation_layers.size,
.ppEnabledLayerNames = m_validation_layers.data,
.enabledExtensionCount = m_device_extension_count,
.ppEnabledExtensionNames = m_device_extensions,
.enabledExtensionCount = m_device_extensions.size,
.ppEnabledExtensionNames = m_device_extensions.data,
.pEnabledFeatures = &(VkPhysicalDeviceFeatures){0},
},
NULL,