Vulkan: Enable VK_KHR_sampler_mirror_clamp_to_edge extension.

This commit is contained in:
Hans-Kristian Arntzen 2017-10-01 20:20:45 +02:00
parent 43b4c65b1e
commit 5c67fc3040

View File

@ -1308,11 +1308,15 @@ end:
return ret;
}
static bool vulkan_find_device_extensions(VkPhysicalDevice gpu, const char **exts, unsigned num_exts)
static bool vulkan_find_device_extensions(VkPhysicalDevice gpu,
const char **enabled, unsigned *enabled_count,
const char **exts, unsigned num_exts,
const char **optional_exts, unsigned num_optional_exts)
{
bool ret = true;
VkExtensionProperties *properties = NULL;
uint32_t property_count;
unsigned i;
if (vkEnumerateDeviceExtensionProperties(gpu, NULL, &property_count, NULL) != VK_SUCCESS)
return false;
@ -1332,11 +1336,18 @@ static bool vulkan_find_device_extensions(VkPhysicalDevice gpu, const char **ext
if (!vulkan_find_extensions(exts, num_exts, properties, property_count))
{
RARCH_ERR("[Vulkan]: Could not find device extensions. Will attempt without them.\n");
RARCH_ERR("[Vulkan]: Could not find device extension. Will attempt without it.\n");
ret = false;
goto end;
}
memcpy(enabled, exts, num_exts * sizeof(*exts));
*enabled_count = num_exts;
for (i = 0; i < num_optional_exts; i++)
if (vulkan_find_extensions(&optional_exts[i], 1, properties, property_count))
enabled[(*enabled_count)++] = optional_exts[i];
end:
free(properties);
return ret;
@ -1396,10 +1407,17 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO };
VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
const char *enabled_device_extensions[8];
unsigned enabled_device_extension_count = 0;
static const char *device_extensions[] = {
"VK_KHR_swapchain",
};
static const char *optional_device_extensions[] = {
"VK_KHR_sampler_mirror_clamp_to_edge",
};
#ifdef VULKAN_DEBUG
static const char *device_layers[] = { "VK_LAYER_LUNARG_standard_validation" };
#endif
@ -1523,7 +1541,15 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
}
use_device_ext = vulkan_find_device_extensions(vk->context.gpu,
device_extensions, ARRAY_SIZE(device_extensions));
enabled_device_extensions, &enabled_device_extension_count,
device_extensions, ARRAY_SIZE(device_extensions),
optional_device_extensions, ARRAY_SIZE(optional_device_extensions));
if (!use_device_ext)
{
RARCH_ERR("[Vulkan]: Could not find required device extensions.\n");
return false;
}
queue_info.queueFamilyIndex = vk->context.graphics_queue_index;
queue_info.queueCount = 1;
@ -1531,8 +1557,8 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
device_info.queueCreateInfoCount = 1;
device_info.pQueueCreateInfos = &queue_info;
device_info.enabledExtensionCount = use_device_ext ? ARRAY_SIZE(device_extensions) : 0;
device_info.ppEnabledExtensionNames = use_device_ext ? device_extensions : NULL;
device_info.enabledExtensionCount = enabled_device_extension_count;
device_info.ppEnabledExtensionNames = enabled_device_extension_count ? enabled_device_extensions : NULL;
device_info.pEnabledFeatures = &features;
#ifdef VULKAN_DEBUG
device_info.enabledLayerCount = ARRAY_SIZE(device_layers);