From cc4fd7cc9d1470d6ebaaa4e3a7a356c8ad0c34c4 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 15 May 2025 17:17:08 -0700 Subject: [PATCH] vulkan: fix random tabs to spaces Only the vk_time_max_deviation tab usage requires a manual fix to make sense. Others are boring replacements. Reviewed-by: Faith Ekstrand Part-of: --- src/virtio/vulkan/vn_physical_device.c | 5 ++++ .../device-select-layer/device_select_layer.c | 20 ++++++------- .../device_select_wayland.c | 28 +++++++++---------- .../device-select-layer/device_select_x11.c | 16 +++++------ src/vulkan/runtime/vk_device.c | 6 ++-- src/vulkan/runtime/vk_device.h | 24 ++++++++-------- src/vulkan/runtime/vk_meta_copy_fill_update.c | 6 ++-- src/vulkan/runtime/vk_meta_object_list.h | 2 +- src/vulkan/wsi/wsi_common.c | 3 +- src/vulkan/wsi/wsi_common_wayland.c | 4 +-- src/vulkan/wsi/wsi_common_x11.c | 6 ++-- 11 files changed, 62 insertions(+), 58 deletions(-) diff --git a/src/virtio/vulkan/vn_physical_device.c b/src/virtio/vulkan/vn_physical_device.c index 05e8d54fa33..b2d7d1ba8d1 100644 --- a/src/virtio/vulkan/vn_physical_device.c +++ b/src/virtio/vulkan/vn_physical_device.c @@ -519,6 +519,11 @@ vn_physical_device_sanitize_properties(struct vn_physical_device *physical_dev) } memcpy(props->deviceName, device_name, device_name_len + 1); + /* force prime blit on NV proprietary driver */ + if (props->driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY) { + physical_dev->base.vk.supported_extensions.EXT_image_drm_format_modifier = false; + } + /* store renderer VkDriverId for implementation specific workarounds */ physical_dev->renderer_driver_id = props->driverID; props->driverID = VK_DRIVER_ID_MESA_VENUS; diff --git a/src/vulkan/device-select-layer/device_select_layer.c b/src/vulkan/device-select-layer/device_select_layer.c index ba1a7a81b22..19cfc556f54 100644 --- a/src/vulkan/device-select-layer/device_select_layer.c +++ b/src/vulkan/device-select-layer/device_select_layer.c @@ -66,7 +66,7 @@ device_select_init_instances(void) simple_mtx_lock(&device_select_mutex); if (!device_select_instance_ht) device_select_instance_ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer, - _mesa_key_pointer_equal); + _mesa_key_pointer_equal); simple_mtx_unlock(&device_select_mutex); } @@ -76,8 +76,8 @@ device_select_try_free_ht(void) simple_mtx_lock(&device_select_mutex); if (device_select_instance_ht) { if (_mesa_hash_table_num_entries(device_select_instance_ht) == 0) { - _mesa_hash_table_destroy(device_select_instance_ht, NULL); - device_select_instance_ht = NULL; + _mesa_hash_table_destroy(device_select_instance_ht, NULL); + device_select_instance_ht = NULL; } } simple_mtx_unlock(&device_select_mutex); @@ -115,8 +115,8 @@ device_select_layer_remove_instance(VkInstance instance) } static VkResult device_select_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, - const VkAllocationCallbacks *pAllocator, - VkInstance *pInstance) + const VkAllocationCallbacks *pAllocator, + VkInstance *pInstance) { VkLayerInstanceCreateInfo *chain_info; for(chain_info = (VkLayerInstanceCreateInfo*)pCreateInfo->pNext; chain_info; chain_info = (VkLayerInstanceCreateInfo*)chain_info->pNext) @@ -550,8 +550,8 @@ static uint32_t get_default_device(const struct instance_info *info, } static VkResult device_select_EnumeratePhysicalDevices(VkInstance instance, - uint32_t* pPhysicalDeviceCount, - VkPhysicalDevice *pPhysicalDevices) + uint32_t* pPhysicalDeviceCount, + VkPhysicalDevice *pPhysicalDevices) { struct instance_info *info = device_select_layer_get_instance(instance); uint32_t physical_device_count = 0; @@ -582,14 +582,14 @@ static VkResult device_select_EnumeratePhysicalDevices(VkInstance instance, uint32_t count; info->EnumerateDeviceExtensionProperties(physical_devices[i], NULL, &count, NULL); if (count > 0) { - VkExtensionProperties *extensions = calloc(count, sizeof(VkExtensionProperties)); + VkExtensionProperties *extensions = calloc(count, sizeof(VkExtensionProperties)); if (info->EnumerateDeviceExtensionProperties(physical_devices[i], NULL, &count, extensions) == VK_SUCCESS) { - for (unsigned j = 0; j < count; j++) { + for (unsigned j = 0; j < count; j++) { if (!strcmp(extensions[j].extensionName, VK_EXT_PCI_BUS_INFO_EXTENSION_NAME)) info->has_pci_bus = true; } } - free(extensions); + free(extensions); } } if (should_debug_device_selection() || (selection && strcmp(selection, "list") == 0)) { diff --git a/src/vulkan/device-select-layer/device_select_wayland.c b/src/vulkan/device-select-layer/device_select_wayland.c index b9a1bed2ef5..6bfcbaccf41 100644 --- a/src/vulkan/device-select-layer/device_select_wayland.c +++ b/src/vulkan/device-select-layer/device_select_wayland.c @@ -156,7 +156,7 @@ static const struct zwp_linux_dmabuf_feedback_v1_listener dmabuf_feedback_listen static void device_select_registry_global(void *data, struct wl_registry *registry, uint32_t name, - const char *interface, uint32_t version) + const char *interface, uint32_t version) { struct device_select_wayland_info *info = data; if (strcmp(interface, wl_drm_interface.name) == 0) { @@ -176,7 +176,7 @@ device_select_registry_global(void *data, struct wl_registry *registry, uint32_t static void device_select_registry_global_remove_cb(void *data, struct wl_registry *registry, - uint32_t name) + uint32_t name) { } @@ -216,19 +216,19 @@ int device_select_find_wayland_pci_default(struct device_pci_info *devices, uint for (unsigned i = 0; i < device_count; i++) { if (devices[i].has_bus_info) { - if (target->businfo.pci->domain == devices[i].bus_info.domain && - target->businfo.pci->bus == devices[i].bus_info.bus && - target->businfo.pci->dev == devices[i].bus_info.dev && - target->businfo.pci->func == devices[i].bus_info.func) { - default_idx = i; - break; - } + if (target->businfo.pci->domain == devices[i].bus_info.domain && + target->businfo.pci->bus == devices[i].bus_info.bus && + target->businfo.pci->dev == devices[i].bus_info.dev && + target->businfo.pci->func == devices[i].bus_info.func) { + default_idx = i; + break; + } } else { - if (target->deviceinfo.pci->vendor_id == devices[i].dev_info.vendor_id && - target->deviceinfo.pci->device_id == devices[i].dev_info.device_id) { - default_idx = i; - break; - } + if (target->deviceinfo.pci->vendor_id == devices[i].dev_info.vendor_id && + target->deviceinfo.pci->device_id == devices[i].dev_info.device_id) { + default_idx = i; + break; + } } } diff --git a/src/vulkan/device-select-layer/device_select_x11.c b/src/vulkan/device-select-layer/device_select_x11.c index 6bf6e0c5c57..7e15f1534ed 100644 --- a/src/vulkan/device-select-layer/device_select_x11.c +++ b/src/vulkan/device-select-layer/device_select_x11.c @@ -33,8 +33,8 @@ #include "device_select.h" static int ds_dri3_open(xcb_connection_t *conn, - xcb_window_t root, - uint32_t provider) + xcb_window_t root, + uint32_t provider) { xcb_dri3_open_cookie_t cookie; xcb_dri3_open_reply_t *reply; @@ -104,15 +104,15 @@ int device_select_find_xcb_pci_default(struct device_pci_info *devices, uint32_t for (unsigned i = 0; i < device_count; i++) { if (devices[i].has_bus_info) { if (xdev->businfo.pci->domain == devices[i].bus_info.domain && - xdev->businfo.pci->bus == devices[i].bus_info.bus && - xdev->businfo.pci->dev == devices[i].bus_info.dev && - xdev->businfo.pci->func == devices[i].bus_info.func) { - default_idx = i; + xdev->businfo.pci->bus == devices[i].bus_info.bus && + xdev->businfo.pci->dev == devices[i].bus_info.dev && + xdev->businfo.pci->func == devices[i].bus_info.func) { + default_idx = i; } } else { if (xdev->deviceinfo.pci->vendor_id == devices[i].dev_info.vendor_id && - xdev->deviceinfo.pci->device_id == devices[i].dev_info.device_id) - default_idx = i; + xdev->deviceinfo.pci->device_id == devices[i].dev_info.device_id) + default_idx = i; } if (default_idx != -1) break; diff --git a/src/vulkan/runtime/vk_device.c b/src/vulkan/runtime/vk_device.c index 08498b19f21..a25e3331a52 100644 --- a/src/vulkan/runtime/vk_device.c +++ b/src/vulkan/runtime/vk_device.c @@ -111,9 +111,9 @@ vk_device_memory_report_init(struct vk_device *device, vk_foreach_struct_const(pnext, pCreateInfo->pNext) { if (pnext->sType == VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT) { const struct VkDeviceDeviceMemoryReportCreateInfoEXT *report = (void *)pnext; - mem_reports[count].callback = report->pfnUserCallback; - mem_reports[count].data = report->pUserData; - count++; + mem_reports[count].callback = report->pfnUserCallback; + mem_reports[count].data = report->pUserData; + count++; } } diff --git a/src/vulkan/runtime/vk_device.h b/src/vulkan/runtime/vk_device.h index e7cbce4942d..d297d5c301b 100644 --- a/src/vulkan/runtime/vk_device.h +++ b/src/vulkan/runtime/vk_device.h @@ -455,24 +455,24 @@ vk_time_max_deviation(uint64_t begin, uint64_t end, uint64_t max_clock_period) * period and that the application is sampling GPU and monotonic: * * s e - * w x y z 0 1 2 3 4 5 6 7 8 9 a b c d e f - * Raw -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- + * w x y z 0 1 2 3 4 5 6 7 8 9 a b c d e f + * Raw -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- * * g - * 0 1 2 3 - * GPU -----_____-----_____-----_____-----_____ + * 0 1 2 3 + * GPU -----_____-----_____-----_____-----_____ * * m - * x y z 0 1 2 3 4 5 6 7 8 9 a b c - * Monotonic -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- + * x y z 0 1 2 3 4 5 6 7 8 9 a b c + * Monotonic -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- * - * Interval <-----------------> - * Deviation <--------------------------> + * Interval <-----------------> + * Deviation <--------------------------> * - * s = read(raw) 2 - * g = read(GPU) 1 - * m = read(monotonic) 2 - * e = read(raw) b + * s = read(raw) 2 + * g = read(GPU) 1 + * m = read(monotonic) 2 + * e = read(raw) b * * We round the sample interval up by one tick to cover sampling error * in the interval clock diff --git a/src/vulkan/runtime/vk_meta_copy_fill_update.c b/src/vulkan/runtime/vk_meta_copy_fill_update.c index 1ee59636d2f..e1f2f66b029 100644 --- a/src/vulkan/runtime/vk_meta_copy_fill_update.c +++ b/src/vulkan/runtime/vk_meta_copy_fill_update.c @@ -2035,14 +2035,14 @@ copy_image_prepare_gfx_push_const(struct vk_command_buffer *cmd, struct vk_meta_copy_image_fs_info info = { .dst_to_src_offs = { /* The subtraction may lead to negative values, but that's fine - * because the shader does the mirror operation thus guaranteeing - * a src_coords >= 0. */ + * because the shader does the mirror operation thus guaranteeing + * a src_coords >= 0. */ .x = src_img_offs.x - region->dstOffset.x, .y = src_img_offs.y - region->dstOffset.y, /* Render image view only contains the layers needed for rendering, * so we consider the coordinate containing the layer to always be * zero. - */ + */ .z = src_img_offs.z, }, }; diff --git a/src/vulkan/runtime/vk_meta_object_list.h b/src/vulkan/runtime/vk_meta_object_list.h index c6ce1830d7b..8c3591db302 100644 --- a/src/vulkan/runtime/vk_meta_object_list.h +++ b/src/vulkan/runtime/vk_meta_object_list.h @@ -40,6 +40,6 @@ vk_meta_object_list_add_handle(struct vk_meta_object_list *mol, } void vk_meta_destroy_object(struct vk_device *device, - struct vk_object_base *obj); + struct vk_object_base *obj); #endif diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index 0cd119dd2d9..c6d93396e41 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -1565,8 +1565,7 @@ wsi_common_queue_present(const struct wsi_device *wsi, } if (wsi->sw) - wsi->WaitForFences(device, 1, &swapchain->fences[image_index], - true, ~0ull); + wsi->WaitForFences(device, 1, &swapchain->fences[image_index], true, ~0ull); const VkPresentRegionKHR *region = NULL; if (regions && regions->pRegions) diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 6be46f49d14..7c1efda1f27 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -1856,7 +1856,7 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface, static VkResult wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface, - struct wsi_device *wsi_device, + struct wsi_device *wsi_device, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats) { @@ -1900,7 +1900,7 @@ wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface, static VkResult wsi_wl_surface_get_formats2(VkIcdSurfaceBase *icd_surface, - struct wsi_device *wsi_device, + struct wsi_device *wsi_device, const void *info_next, uint32_t* pSurfaceFormatCount, VkSurfaceFormat2KHR* pSurfaceFormats) diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index 65b7fdf7212..fb1809e4d57 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -110,8 +110,8 @@ struct wsi_x11_vk_surface { */ static int wsi_dri3_open(xcb_connection_t *conn, - xcb_window_t root, - uint32_t provider) + xcb_window_t root, + uint32_t provider) { xcb_dri3_open_cookie_t cookie; xcb_dri3_open_reply_t *reply; @@ -2324,7 +2324,7 @@ wsi_x11_get_dri3_modifiers(struct wsi_x11_connection *wsi_conn, counts[n] * sizeof(uint64_t), 8, VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); if (!modifiers[n]) { - if (n > 0) + if (n > 0) vk_free(pAllocator, modifiers[0]); free(mod_reply); goto out;