vulkan_context_init_device - simplify some string concatenation

This commit is contained in:
LibretroAdmin 2022-08-29 12:09:40 +02:00
parent 12bc84bc08
commit 22a12c9861

View File

@ -1646,38 +1646,26 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
{ {
char device_str[128]; char device_str[128];
char driver_version[64];
char api_version[64];
char version_str[128]; char version_str[128];
size_t len = 0; size_t len = strlcpy(device_str, vk->context.gpu_properties.deviceName, sizeof(device_str));
int pos = 0; device_str[len ] = ' ';
driver_version[0] = api_version[0] = '\0'; device_str[++len] = '\0';
len = strlcpy(device_str, vk->context.gpu_properties.deviceName, sizeof(device_str)); len += snprintf(device_str + len, sizeof(device_str) - len, "%u", VK_VERSION_MAJOR(vk->context.gpu_properties.driverVersion));
device_str[len ] = ' '; device_str[len ] = '.';
device_str[len+1] = '\0'; device_str[++len] = '\0';
len += snprintf(device_str + len, sizeof(device_str) - len, "%u", VK_VERSION_MINOR(vk->context.gpu_properties.driverVersion));
device_str[len ] = '.';
device_str[++len] = '\0';
snprintf(device_str + len, sizeof(device_str) - len, "%u", VK_VERSION_PATCH(vk->context.gpu_properties.driverVersion));
pos += snprintf(driver_version + pos, sizeof(driver_version) - pos, "%u", VK_VERSION_MAJOR(vk->context.gpu_properties.driverVersion)); len = snprintf(version_str , sizeof(version_str) , "%u", VK_VERSION_MAJOR(vk->context.gpu_properties.apiVersion));
strlcat(driver_version, ".", sizeof(driver_version)); version_str[len ] = '.';
pos++; version_str[++len] = '\0';
pos += snprintf(driver_version + pos, sizeof(driver_version) - pos, "%u", VK_VERSION_MINOR(vk->context.gpu_properties.driverVersion)); len += snprintf(version_str + len, sizeof(version_str) - len, "%u", VK_VERSION_MINOR(vk->context.gpu_properties.apiVersion));
pos++; version_str[len ] = '.';
strlcat(driver_version, ".", sizeof(driver_version)); version_str[++len] = '\0';
pos += snprintf(driver_version + pos, sizeof(driver_version) - pos, "%u", VK_VERSION_PATCH(vk->context.gpu_properties.driverVersion)); snprintf(version_str + len, sizeof(version_str) - len, "%u", VK_VERSION_PATCH(vk->context.gpu_properties.apiVersion));
strlcat(device_str, driver_version, sizeof(device_str));
pos = 0;
pos += snprintf(api_version + pos, sizeof(api_version) - pos, "%u", VK_VERSION_MAJOR(vk->context.gpu_properties.apiVersion));
strlcat(api_version, ".", sizeof(api_version));
pos++;
pos += snprintf(api_version + pos, sizeof(api_version) - pos, "%u", VK_VERSION_MINOR(vk->context.gpu_properties.apiVersion));
pos++;
strlcat(api_version, ".", sizeof(api_version));
pos += snprintf(api_version + pos, sizeof(api_version) - pos, "%u", VK_VERSION_PATCH(vk->context.gpu_properties.apiVersion));
strlcpy(version_str, api_version, sizeof(device_str));
video_driver_set_gpu_device_string(device_str); video_driver_set_gpu_device_string(device_str);
video_driver_set_gpu_api_version_string(version_str); video_driver_set_gpu_api_version_string(version_str);