static void demo_init_vk(struct demo *demo)
{
- // TODO : Should query count w/ GetGlobalExtensionInfo, then enable via CreateInstance
+ VkResult err;
+ // Extensions to enable
+ const char *ext_names[] = {
+ "VK_WSI_X11",
+ };
+ size_t extSize = sizeof(uint32_t);
+ uint32_t extCount = 0;
+ err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &extCount);
+ assert(!err);
+
+ VkExtensionProperties extProp;
+ extSize = sizeof(VkExtensionProperties);
+ bool32_t extFound = 0;
+ for (uint32_t i = 0; i < extCount; i++) {
+ err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_PROPERTIES, i, &extSize, &extProp);
+ if (!strcmp(ext_names[0], extProp.extName))
+ extFound = 1;
+ }
+ assert(extFound);
const VkApplicationInfo app = {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pNext = NULL,
.pAppInfo = &app,
.pAllocCb = NULL,
- .extensionCount = 0,
- .ppEnabledExtensionNames = NULL,
+ .extensionCount = 1,
+ .ppEnabledExtensionNames = ext_names,
};
const VK_WSI_X11_CONNECTION_INFO connection = {
.pConnection = demo->connection,
.queueCount = 1,
};
- const char *ext_names[] = {
- "VK_WSI_X11",
- };
-
const VkDeviceCreateInfo device = {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.pNext = NULL,
.queueRecordCount = 1,
.pRequestedQueues = &queue,
- .extensionCount = 1, // TODO : Should query count w/ GetGlobalExtensionInfo
+ .extensionCount = 1,
.ppEnabledExtensionNames = ext_names,
.flags = VK_DEVICE_CREATE_VALIDATION_BIT,
};
- VkResult err;
uint32_t gpu_count;
uint32_t i;
size_t data_size;
static void demo_init_vk(struct demo *demo)
{
- // TODO : Should query count w/ GetGlobalExtensionInfo, then enable via CreateInstance
+ VkResult err;
+ // Extensions to enable
+ const char *ext_names[] = {
+ "VK_WSI_X11",
+ };
+ size_t extSize = sizeof(uint32_t);
+ uint32_t extCount = 0;
+ err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &extCount);
+ assert(!err);
+
+ VkExtensionProperties extProp;
+ extSize = sizeof(VkExtensionProperties);
+ bool32_t extFound = 0;
+ for (uint32_t i = 0; i < extCount; i++) {
+ err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_PROPERTIES, i, &extSize, &extProp);
+ if (!strcmp(ext_names[0], extProp.extName))
+ extFound = 1;
+ }
+ assert(extFound);
const VkApplicationInfo app = {
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
.pNext = NULL,
.pNext = NULL,
.pAppInfo = &app,
.pAllocCb = NULL,
- .extensionCount = 0,
- .ppEnabledExtensionNames = NULL,
+ .extensionCount = 1,
+ .ppEnabledExtensionNames = ext_names,
};
const VK_WSI_X11_CONNECTION_INFO connection = {
.pConnection = demo->connection,
.queueNodeIndex = 0,
.queueCount = 1,
};
- const char *ext_names[] = {
- "VK_WSI_X11",
- };
const VkDeviceCreateInfo device = {
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
.pNext = NULL,
.queueRecordCount = 1,
.pRequestedQueues = &queue,
- .extensionCount = 1, // TODO : Should query count w/ GetGlobalExtensionInfo
+ .extensionCount = 1,
.ppEnabledExtensionNames = ext_names,
.flags = VK_DEVICE_CREATE_VALIDATION_BIT,
};
- VkResult err;
uint32_t gpu_count;
uint32_t i;
size_t data_size;
static void app_gpu_init_extensions(struct app_gpu *gpu)
{
- //VkResult err;
- uint32_t i;
- // TODO : Should query count w/ GetGlobalExtensionInfo,
- // Then dynamically set extensions based on returned count
-
+ VkResult err;
+ // Extensions to enable
static char *known_extensions[] = {
"VK_WSI_X11",
};
-
- for (i = 0; i < ARRAY_SIZE(known_extensions); i++) {
-/*
- err = vkGetExtensionSupport(gpu->obj, known_extensions[i]);
- if (!err)
-*/
- gpu->extension_count++;
+ size_t extSize = sizeof(uint32_t);
+ uint32_t extCount = 0;
+ err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_COUNT, 0, &extSize, &extCount);
+ assert(!err);
+
+ VkExtensionProperties extProp;
+ extSize = sizeof(VkExtensionProperties);
+ bool32_t extFound = 0; // TODO : Need to enhance this if/when we enable multiple extensions
+ for (uint32_t i = 0; i < extCount; i++) {
+ err = vkGetGlobalExtensionInfo(VK_EXTENSION_INFO_TYPE_PROPERTIES, i, &extSize, &extProp);
+ if (!strcmp(known_extensions[0], extProp.extName)) {
+ extFound = 1;
+ gpu->extension_count++;
+ }
}
+ assert(extFound);
gpu->extensions =
malloc(sizeof(gpu->extensions[0]) * gpu->extension_count);
ERR_EXIT(VK_ERROR_OUT_OF_HOST_MEMORY);
gpu->extension_count = 0;
+ uint32_t i;
for (i = 0; i < ARRAY_SIZE(known_extensions); i++) {
-/*
- err = vkGetExtensionSupport(gpu->obj, known_extensions[i]);
- if (!err)
-*/
+ // known_extensions were validated above so copy them over here
gpu->extensions[gpu->extension_count++] = known_extensions[i];
}
}