From bee05c32f28464b78e588b167bb4c7264bf0cc84 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Wed, 31 Jan 2024 14:34:05 +0100 Subject: [PATCH] Fix warnings and formatting --- .../Sources/kinc/backend/graphics5/Vulkan.c.h | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h index cca4ef5d1..2c5e0e774 100644 --- a/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h +++ b/Backends/Graphics5/Vulkan/Sources/kinc/backend/graphics5/Vulkan.c.h @@ -729,7 +729,7 @@ void kinc_g5_internal_init() { assert(!err); // The device with the highest score is chosen. float best_score = 0.0; - for (int gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) { + for (uint32_t gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) { VkPhysicalDevice gpu = physical_devices[gpu_idx]; uint32_t queue_count = 0; vkGetPhysicalDeviceQueueFamilyProperties(gpu, &queue_count, NULL); @@ -742,13 +742,19 @@ void kinc_g5_internal_init() { bool can_compute = false; for (uint32_t i = 0; i < queue_count; i++) { VkBool32 queue_supports_present = kinc_vulkan_get_physical_device_presentation_support(gpu, i); - if(queue_supports_present) can_present = true; + if (queue_supports_present) { + can_present = true; + } VkQueueFamilyProperties queue_properties = queue_props[i]; uint32_t flags = queue_properties.queueFlags; - if(flags & VK_QUEUE_GRAPHICS_BIT != 0) can_render = true; - if(flags & VK_QUEUE_COMPUTE_BIT != 0) can_compute = true; + if ((flags & VK_QUEUE_GRAPHICS_BIT) != 0) { + can_render = true; + } + if ((flags & VK_QUEUE_COMPUTE_BIT) != 0) { + can_compute = true; + } } - if(!can_present || !can_render || !can_compute) { + if (!can_present || !can_render || !can_compute) { // This device is missing required features so move on continue; } @@ -758,26 +764,26 @@ void kinc_g5_internal_init() { float score = 0.0; VkPhysicalDeviceProperties properties; vkGetPhysicalDeviceProperties(gpu, &properties); - switch(properties.deviceType) { - case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: - score += 10; - break; - case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: - score += 7; - break; - case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: - score += 5; - break; - case VK_PHYSICAL_DEVICE_TYPE_OTHER: - score += 1; - break; - case VK_PHYSICAL_DEVICE_TYPE_CPU: - // CPU gets a score of zero - break; + switch (properties.deviceType) { + case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: + score += 10; + break; + case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: + score += 7; + break; + case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: + score += 5; + break; + case VK_PHYSICAL_DEVICE_TYPE_OTHER: + score += 1; + break; + case VK_PHYSICAL_DEVICE_TYPE_CPU: + // CPU gets a score of zero + break; } // TODO: look into using more metrics than just the device type for scoring, eg: available memory, max texture sizes, etc. // If this is the first usable device, skip testing against the previous best. - if(vk_ctx.gpu == VK_NULL_HANDLE || score > best_score) { + if (vk_ctx.gpu == VK_NULL_HANDLE || score > best_score) { vk_ctx.gpu = gpu; best_score = score; } @@ -785,7 +791,8 @@ void kinc_g5_internal_init() { if (vk_ctx.gpu == VK_NULL_HANDLE) { if (headless) { vk_ctx.gpu = physical_devices[0]; - } else { + } + else { kinc_error_message("No Vulkan device that supports presentation found"); } } @@ -793,7 +800,8 @@ void kinc_g5_internal_init() { vkGetPhysicalDeviceProperties(vk_ctx.gpu, &properties); kinc_log(KINC_LOG_LEVEL_INFO, "Chosen Vulkan device: %s", properties.deviceName); free(physical_devices); - } else { + } + else { kinc_error_message("No Vulkan device found"); }