summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_wsi_display.c
diff options
context:
space:
mode:
authorKeith Packard <[email protected]>2017-06-15 21:00:56 -0700
committerKeith Packard <[email protected]>2018-06-23 07:59:00 -0700
commit16eb390834daaa153522e63bb17df9526eb9123c (patch)
tree18cb5da23ee5c32bdf6a97aa07adcdbe79f82491 /src/intel/vulkan/anv_wsi_display.c
parent86c8d93e5a045772b6c1c6ce6a24a5404a37f4cb (diff)
anv: add VK_EXT_display_control to anv driver [v5]
This extension provides fences and frame count information to direct display contexts. It uses new kernel ioctls to provide 64-bits of vblank sequence and nanosecond resolution. v2: Adopt Jason Ekstrand's coding conventions Declare variables at first use, eliminate extra whitespace between types and names. Wrap lines to 80 columns. Add extension to list in alphabetical order Suggested-by: Jason Ekstrand <[email protected]> v3: Adapt to WSI fence API change. It now returns VkResult and no longer has an option for relative timeouts. v4: wsi_register_display_event and wsi_register_device_event now use the default allocator when NULL is provided, so remove the computation of 'alloc' here. v5: use zalloc2 instead of alloc2 for the WSI fence. Suggested-by: Jason Ekstrand <[email protected]> Signed-off-by: Keith Packard <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_wsi_display.c')
-rw-r--r--src/intel/vulkan/anv_wsi_display.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_wsi_display.c b/src/intel/vulkan/anv_wsi_display.c
index ed679e85e13..94e16010463 100644
--- a/src/intel/vulkan/anv_wsi_display.c
+++ b/src/intel/vulkan/anv_wsi_display.c
@@ -174,3 +174,88 @@ anv_GetRandROutputDisplayEXT(VkPhysicalDevice physical_device,
display);
}
#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
+
+/* VK_EXT_display_control */
+
+VkResult
+anv_DisplayPowerControlEXT(VkDevice _device,
+ VkDisplayKHR display,
+ const VkDisplayPowerInfoEXT *display_power_info)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+
+ return wsi_display_power_control(
+ _device, &device->instance->physicalDevice.wsi_device,
+ display, display_power_info);
+}
+
+VkResult
+anv_RegisterDeviceEventEXT(VkDevice _device,
+ const VkDeviceEventInfoEXT *device_event_info,
+ const VkAllocationCallbacks *allocator,
+ VkFence *_fence)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ struct anv_fence *fence;
+ VkResult ret;
+
+ fence = vk_zalloc2(&device->instance->alloc, allocator, sizeof (*fence), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (!fence)
+ return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
+
+ fence->permanent.type = ANV_FENCE_TYPE_WSI;
+
+ ret = wsi_register_device_event(_device,
+ &device->instance->physicalDevice.wsi_device,
+ device_event_info,
+ allocator,
+ &fence->permanent.fence_wsi);
+ if (ret == VK_SUCCESS)
+ *_fence = anv_fence_to_handle(fence);
+ else
+ vk_free2(&device->instance->alloc, allocator, fence);
+ return ret;
+}
+
+VkResult
+anv_RegisterDisplayEventEXT(VkDevice _device,
+ VkDisplayKHR display,
+ const VkDisplayEventInfoEXT *display_event_info,
+ const VkAllocationCallbacks *allocator,
+ VkFence *_fence)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+ struct anv_fence *fence;
+ VkResult ret;
+
+ fence = vk_zalloc2(&device->alloc, allocator, sizeof (*fence), 8,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
+ if (!fence)
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+
+ fence->permanent.type = ANV_FENCE_TYPE_WSI;
+
+ ret = wsi_register_display_event(
+ _device, &device->instance->physicalDevice.wsi_device,
+ display, display_event_info, allocator, &(fence->permanent.fence_wsi));
+
+ if (ret == VK_SUCCESS)
+ *_fence = anv_fence_to_handle(fence);
+ else
+ vk_free2(&device->alloc, allocator, fence);
+ return ret;
+}
+
+VkResult
+anv_GetSwapchainCounterEXT(VkDevice _device,
+ VkSwapchainKHR swapchain,
+ VkSurfaceCounterFlagBitsEXT flag_bits,
+ uint64_t *value)
+{
+ ANV_FROM_HANDLE(anv_device, device, _device);
+
+ return wsi_get_swapchain_counter(
+ _device, &device->instance->physicalDevice.wsi_device,
+ swapchain, flag_bits, value);
+}