Merge pull request #5490 from Themaister/master
Vulkan: Enable VK_KHR_sampler_mirror_clamp_to_edge extension.
This commit is contained in:
commit
8b4fd58f17
|
@ -1308,11 +1308,15 @@ end:
|
||||||
return ret;
|
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;
|
bool ret = true;
|
||||||
VkExtensionProperties *properties = NULL;
|
VkExtensionProperties *properties = NULL;
|
||||||
uint32_t property_count;
|
uint32_t property_count;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
if (vkEnumerateDeviceExtensionProperties(gpu, NULL, &property_count, NULL) != VK_SUCCESS)
|
if (vkEnumerateDeviceExtensionProperties(gpu, NULL, &property_count, NULL) != VK_SUCCESS)
|
||||||
return false;
|
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))
|
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;
|
ret = false;
|
||||||
goto end;
|
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:
|
end:
|
||||||
free(properties);
|
free(properties);
|
||||||
return ret;
|
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 };
|
VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO };
|
||||||
VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_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[] = {
|
static const char *device_extensions[] = {
|
||||||
"VK_KHR_swapchain",
|
"VK_KHR_swapchain",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char *optional_device_extensions[] = {
|
||||||
|
"VK_KHR_sampler_mirror_clamp_to_edge",
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef VULKAN_DEBUG
|
#ifdef VULKAN_DEBUG
|
||||||
static const char *device_layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
static const char *device_layers[] = { "VK_LAYER_LUNARG_standard_validation" };
|
||||||
#endif
|
#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,
|
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.queueFamilyIndex = vk->context.graphics_queue_index;
|
||||||
queue_info.queueCount = 1;
|
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.queueCreateInfoCount = 1;
|
||||||
device_info.pQueueCreateInfos = &queue_info;
|
device_info.pQueueCreateInfos = &queue_info;
|
||||||
device_info.enabledExtensionCount = use_device_ext ? ARRAY_SIZE(device_extensions) : 0;
|
device_info.enabledExtensionCount = enabled_device_extension_count;
|
||||||
device_info.ppEnabledExtensionNames = use_device_ext ? device_extensions : NULL;
|
device_info.ppEnabledExtensionNames = enabled_device_extension_count ? enabled_device_extensions : NULL;
|
||||||
device_info.pEnabledFeatures = &features;
|
device_info.pEnabledFeatures = &features;
|
||||||
#ifdef VULKAN_DEBUG
|
#ifdef VULKAN_DEBUG
|
||||||
device_info.enabledLayerCount = ARRAY_SIZE(device_layers);
|
device_info.enabledLayerCount = ARRAY_SIZE(device_layers);
|
||||||
|
|
Loading…
Reference in New Issue