radv_physical_device_to_handle(physical_device),
radv_wsi_proc_addr,
&physical_device->instance->alloc,
- physical_device->master_fd);
+ physical_device->master_fd,
+ &physical_device->instance->dri_options);
}
void
return wsi_device_init(&physical_device->wsi_device,
tu_physical_device_to_handle(physical_device),
tu_wsi_proc_addr, &physical_device->instance->alloc,
- physical_device->master_fd);
+ physical_device->master_fd, NULL);
}
void
anv_physical_device_to_handle(physical_device),
anv_wsi_proc_addr,
&physical_device->instance->alloc,
- physical_device->master_fd);
+ physical_device->master_fd,
+ NULL);
if (result != VK_SUCCESS)
return result;
'vulkan_wsi',
files_vulkan_wsi,
include_directories : [inc_common, inc_vulkan_util, inc_include],
+ link_with: [libxmlconfig],
dependencies : [vulkan_wsi_deps, dep_libdrm],
c_args : [c_vis_args, vulkan_wsi_args],
build_by_default : false,
#include "wsi_common_private.h"
#include "drm-uapi/drm_fourcc.h"
#include "util/macros.h"
+#include "util/xmlconfig.h"
#include "vk_util.h"
#include <time.h>
VkPhysicalDevice pdevice,
WSI_FN_GetPhysicalDeviceProcAddr proc_addr,
const VkAllocationCallbacks *alloc,
- int display_fd)
+ int display_fd,
+ const struct driOptionCache *dri_options)
{
const char *present_mode;
VkResult result;
}
}
+ if (dri_options) {
+ if (driCheckOption(dri_options, "adaptive_sync", DRI_BOOL))
+ wsi->enable_adaptive_sync = driQueryOptionb(dri_options,
+ "adaptive_sync");
+ }
+
return VK_SUCCESS;
fail:
struct wsi_interface;
+struct driOptionCache;
+
#define VK_ICD_WSI_PLATFORM_MAX (VK_ICD_WSI_PLATFORM_DISPLAY + 1)
struct wsi_device {
uint32_t maxImageDimension2D;
VkPresentModeKHR override_present_mode;
+ /* Whether to enable adaptive sync for a swapchain if implemented and
+ * available. Not all window systems might support this. */
+ bool enable_adaptive_sync;
+
uint64_t (*image_get_modifier)(VkImage image);
#define WSI_CB(cb) PFN_vk##cb cb
VkPhysicalDevice pdevice,
WSI_FN_GetPhysicalDeviceProcAddr proc_addr,
const VkAllocationCallbacks *alloc,
- int display_fd);
+ int display_fd,
+ const struct driOptionCache *dri_options);
void
wsi_device_finish(struct wsi_device *wsi,
return VK_SUCCESS;
}
+static void
+wsi_x11_set_adaptive_sync_property(xcb_connection_t *conn,
+ xcb_drawable_t drawable,
+ uint32_t state)
+{
+ static char const name[] = "_VARIABLE_REFRESH";
+ xcb_intern_atom_cookie_t cookie;
+ xcb_intern_atom_reply_t* reply;
+ xcb_void_cookie_t check;
+
+ cookie = xcb_intern_atom(conn, 0, strlen(name), name);
+ reply = xcb_intern_atom_reply(conn, cookie, NULL);
+ if (reply == NULL)
+ return;
+
+ if (state)
+ check = xcb_change_property_checked(conn, XCB_PROP_MODE_REPLACE,
+ drawable, reply->atom,
+ XCB_ATOM_CARDINAL, 32, 1, &state);
+ else
+ check = xcb_delete_property_checked(conn, drawable, reply->atom);
+
+ xcb_discard_reply(conn, check.sequence);
+ free(reply);
+}
+
+
static VkResult
x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
VkDevice device,
for (int i = 0; i < ARRAY_SIZE(modifiers); i++)
vk_free(pAllocator, modifiers[i]);
+
+ /* It is safe to set it here as only one swapchain can be associated with
+ * the window, and swapchain creation does the association. At this point
+ * we know the creation is going to succeed. */
+ wsi_x11_set_adaptive_sync_property(conn, window,
+ wsi_device->enable_adaptive_sync);
+
*swapchain_out = &chain->base;
return VK_SUCCESS;