Add KHR_display through GOOGLE_display_timing [v2]
cover Add KHR_display through GOOGLE_display_timing [v2]
Dave Airlie asked me to split these up so that the core and anv/radv bits were all in separate patches.
There are no code changes here aside from fixing the KHR_display version from 1 to 23. I also fixed the indentation in the changes to the radv driver from spaces to tabs as per convention.
-keith
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/21 vulkan: Add KHR_display extension using DRM
This adds support for the KHR_display extension support to the vulkan WSI layer. Driver support will be added separately.
--- configure.ac | 1 + meson.build | 4 +- src/amd/vulkan/radv_wsi.c | 3 +- src/intel/vulkan/anv_wsi.c | 3 +- src/vulkan/Makefile.am | 7 + src/vulkan/Makefile.sources | 4 + src/vulkan/wsi/meson.build | 10 + src/vulkan/wsi/wsi_common.c | 19 +- src/vulkan/wsi/wsi_common.h | 5 +- src/vulkan/wsi/wsi_common_display.c | 1368 +++++++++++++++++++++++++++++++++++ src/vulkan/wsi/wsi_common_display.h | 72 ++ src/vulkan/wsi/wsi_common_private.h | 10 + 12 files changed, 1500 insertions(+), 6 deletions(-) create mode 100644 src/vulkan/wsi/wsi_common_display.c create mode 100644 src/vulkan/wsi/wsi_common_display.h
configure.ac +1 -0
@@ -1849,6 +1849,7 @@ fi AM_CONDITIONAL(HAVE_PLATFORM_X11, echo "$platforms" | grep -q 'x11') AM_CONDITIONAL(HAVE_PLATFORM_WAYLAND, echo "$platforms" | grep -q 'wayland') AM_CONDITIONAL(HAVE_PLATFORM_DRM, echo "$platforms" | grep -q 'drm') +AM_CONDITIONAL(HAVE_PLATFORM_DISPLAY, echo "$platforms" | grep -q 'drm') AM_CONDITIONAL(HAVE_PLATFORM_SURFACELESS, echo "$platforms" | grep -q 'surfaceless') AM_CONDITIONAL(HAVE_PLATFORM_ANDROID, echo "$platforms" | grep -q 'android')
meson.build +3 -1
@@ -239,11 +239,12 @@ with_platform_wayland = false with_platform_x11 = false with_platform_drm = false with_platform_surfaceless = false +with_platform_display = false egl_native_platform = '' _platforms = get_option('platforms') if _platforms == 'auto' if system_has_kms_drm - _platforms = 'x11,wayland,drm,surfaceless' + _platforms = 'x11,wayland,drm,surfaceless,display' elif ['darwin', 'windows', 'cygwin'].contains(host_machine.system()) _platforms = 'x11,surfaceless' else
@@ -257,6 +258,7 @@ if _platforms != '' with_platform_wayland = _split.contains('wayland') with_platform_drm = _split.contains('drm') with_platform_surfaceless = _split.contains('surfaceless') + with_platform_display = _split.contains('display') egl_native_platform = _split[0] endif
src/amd/vulkan/radv_wsi.c +2 -1
@@ -41,7 +41,8 @@ radv_init_wsi(struct radv_physical_device *physical_device)return wsi_device_init (&physical_device->wsi_device,radv_physical_device_to_handle (physical_device), radv_wsi_proc_addr, - &physical_device->instance->alloc); + &physical_device->instance->alloc, + physical_device->local_fd); }void
src/intel/vulkan/anv_wsi.c +2 -1
@@ -39,7 +39,8 @@ anv_init_wsi(struct anv_physical_device *physical_device)return wsi_device_init (&physical_device->wsi_device,anv_physical_device_to_handle (physical_device), anv_wsi_proc_addr, - &physical_device->instance->alloc); + &physical_device->instance->alloc, + physical_device->local_fd); }void
src/vulkan/Makefile.am +7 -0
@@ -57,6 +57,13 @@ AM_CPPFLAGS += \ VULKAN_WSI_SOURCES += $(VULKAN_WSI_X11_FILES) endif +if HAVE_PLATFORM_DISPLAY +AM_CPPFLAGS += \ + -DVK_USE_PLATFORM_DISPLAY_KHR + +VULKAN_WSI_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) +endif + BUILT_SOURCES += $(VULKAN_WSI_WAYLAND_GENERATED_FILES) CLEANFILES = $(BUILT_SOURCES)
src/vulkan/Makefile.sources +4 -0
@@ -17,6 +17,10 @@ VULKAN_WSI_X11_FILES := \ wsi/wsi_common_x11.c \ wsi/wsi_common_x11.h +VULKAN_WSI_DISPLAY_FILES := \ + wsi/wsi_common_display.c \ + wsi/wsi_common_display.h + VULKAN_UTIL_FILES := \ util/vk_alloc.h \ util/vk_debug_report.c \
src/vulkan/wsi/meson.build +10 -0
@@ -57,6 +57,16 @@ if with_platform_wayland ] endif +if with_platform_display + vulkan_wsi_args += [ + '-DVK_USE_PLATFORM_DISPLAY_KHR', + ] + files_vulkan_wsi += files( + 'wsi_common_display.c', + 'wsi_common_display.h', + ) +endif + libvulkan_wsi = static_library( 'vulkan_wsi', files_vulkan_wsi,
src/vulkan/wsi/wsi_common.c +18 -1
@@ -29,7 +29,8 @@ VkResult wsi_device_init(struct wsi_device *wsi, VkPhysicalDevice pdevice, WSI_FN_GetPhysicalDeviceProcAddr proc_addr, - const VkAllocationCallbacks *alloc) + const VkAllocationCallbacks *alloc, + int device_fd) { VkResult result;
@@ -89,6 +90,19 @@ wsi_device_init(struct wsi_device *wsi, }#endif +#ifdef VK_USE_PLATFORM_DISPLAY_KHR + result =wsi_display_init_wsi (wsi, alloc, pdevice, device_fd); +if (result !=VK_SUCCESS ) { +#ifdef VK_USE_PLATFORM_WAYLAND_KHR +wsi_wl_finish_wsi (wsi, alloc); +#endif +#ifdef VK_USE_PLATFORM_XCB_KHR +wsi_x11_finish_wsi (wsi, alloc); +#endif +return result; + } +#endif +return VK_SUCCESS ; }
@@ -96,6 +110,9 @@ void wsi_device_finish(struct wsi_device *wsi, const VkAllocationCallbacks *alloc) { +#ifdef VK_USE_PLATFORM_DISPLAY_KHR +wsi_display_finish_wsi (wsi, alloc); +#endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR wsi_wl_finish_wsi (wsi, alloc);#endif
src/vulkan/wsi/wsi_common.h +3 -2
@@ -50,7 +50,7 @@ struct wsi_memory_allocate_info {struct wsi_interface ; -#define VK_ICD_WSI_PLATFORM_MAX 5 +#define VK_ICD_WSI_PLATFORM_MAX 6struct wsi_device {VkPhysicalDeviceMemoryProperties memory_props;
@@ -93,7 +93,8 @@ VkResult wsi_device_init(struct wsi_device *wsi, VkPhysicalDevice pdevice, WSI_FN_GetPhysicalDeviceProcAddr proc_addr, - const VkAllocationCallbacks *alloc); + const VkAllocationCallbacks *alloc, + int device_fd); void wsi_device_finish(struct wsi_device *wsi,
src/vulkan/wsi/wsi_common_display.c new file +1368 -0
1,368 lines not on this page · raw message
src/vulkan/wsi/wsi_common_display.h new file +72 -0
72 lines not on this page · raw message
src/vulkan/wsi/wsi_common_private.h +10 -0
@@ -135,6 +135,16 @@ void wsi_wl_finish_wsi(struct wsi_device *wsi_device, const VkAllocationCallbacks *alloc); +VkResult +wsi_display_init_wsi (struct wsi_device *wsi_device, +const VkAllocationCallbacks *alloc, +VkPhysicalDevice physical_device, +int device_fd); + +void +wsi_display_finish_wsi (struct wsi_device *wsi_device, +const VkAllocationCallbacks *alloc); +#define WSI_DEFINE_NONDISP_HANDLE_CASTS (__wsi_type, __VkType) \ \ static inline struct __wsi_type * \
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 01/21] vulkan: Add KHR_display extension using DRM
Continuing on the new version of the patch...
src/vulkan/wsi/wsi_common_display.c line 102
Quoted 8 lines · Keith Packard
src/vulkan/wsi/wsi_common_display.c new file +7
-0+enum wsi_image_state { + wsi_image_idle, + wsi_image_drawing, + wsi_image_queued, + wsi_image_flipping, + wsi_image_displaying +};
With the exception of NIR (which is a bit odd), we usually use ALL_CAPS for enum values.
src/vulkan/wsi/wsi_common_display.c line 695
Quoted 4 lines
src/vulkan/wsi/wsi_common_display.c new file +3
-0+ +static const VkPresentModeKHR available_present_modes[] = { +VK_PRESENT_MODE_FIFO_KHR ,
Yes, this does seem like the only reasonable mode for now. I suppose you could check to see if the platform supports ASYNC_FLIP and advertise IMMEDIATE in that case. I know intel doesn't advertise it but I thought amdgpu does.
Quoted 18 lines
src/vulkan/wsi/wsi_common_display.c new file +5
-0+}; + +static VkResult +wsi_display_surface_get_present_modes (VkIcdSurfaceBase *surface, + uint32_t
*present_mode_count,src/vulkan/wsi/wsi_common_display.c new file +8
-0+ VkPresentModeKHR *present_modes) +{ +if (present_modes ==NULL ) { + *present_mode_count =ARRAY_SIZE (available_present_modes); +return VK_SUCCESS ; + } + + *present_mode_count = MIN2(*present_mode_count,
ARRAY_SIZE(available_present_modes));
+ typed_memcpy(present_modes,available_present_modes,*present_mode_count);
src/vulkan/wsi/wsi_common_display.c line 713
Quoted 4 lines
src/vulkan/wsi/wsi_common_display.c new file +4
-0+ +if (*present_mode_count <ARRAY_SIZE (available_present_modes)) +return VK_INCOMPLETE ; +return VK_SUCCESS ;
vk_outarray, though I suppose you've probably already made that change.
Quoted 18 lines
src/vulkan/wsi/wsi_common_display.c new file +10
-0+} + +static VkResult +wsi_display_image_init (VkDevice device_h, +struct wsi_swapchain *drv_chain, +const VkSwapchainCreateInfoKHR *create_info, +const VkAllocationCallbacks *allocator, +struct wsi_display_image *image) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *)
drv_chain;src/vulkan/wsi/wsi_common_display.c new file +7
-0+struct wsi_display *wsi = chain->wsi; +VkResult result; +int ret; +uint32_t image_handle; + +if (chain->base.use_prime_blit) + result = wsi_create_prime_image(&chain->base, create_info,
Quoted 2 lines
&image->base);
I don't see use_prime_blit being set anywhere. Perhaps that comes in a later patch? The line is obviously correct, so I'm fine with leaving it.
Quoted 4 lines
(quoted diff) +2
-0+ else + result = wsi_create_native_image(&chain->base, create_info,
&image->base);
This will have to be updated for modifiers. I'm reasonably happy for it to be the no-op update for now though KHR_display supporting real modifiers would be nice. :-)
Quoted 6 lines
src/vulkan/wsi/wsi_common_display.c new file +4
-0+if (result !=VK_SUCCESS ) +return result; + + ret = drmPrimeFDToHandle(wsi->master_fd, image->base.fd,
&image_handle);
This opens up some interesting questions. GEM handles are not reference counted by the kernel. If the driver that we're running on is using master_fd, then we shouldn't close our handle because that would close the handle for the driver as well. If it's not using master_fd, we should close the handle to avoid leaking it. The later is only a worry in the prime case but given that I saw a line above about use_prime_blit, you have me scared. :-)
One solution to this connundrum would be to simply never use the master FD for the Vulkan driver itself and always open a render node. If handed a master FD, you could check if it matches your render node and set use_prime_blit accordingly. Then the driver and WSI would have separate handle domains and this problem would be solved. You could also just open the master FD twice, once for WSI and once for the driver.
src/vulkan/wsi/wsi_common_display.c line 748
Quoted 13 lines
src/vulkan/wsi/wsi_common_display.c new file +12
-0+ +close (image->base.fd); + image->base.fd =-1 ; + +if (ret <0 ) + goto fail_handle; + + image->chain = chain; + image->state = wsi_image_idle; + image->fb_id =0 ; + +/* XXX extract depth and bpp from image somehow */
You have the format in create_info. We could add some generic VkFormat introspection or we can just handle the 2-4 cases we care about directly.
Quoted 5 lines
+ ret = drmModeAddFB(wsi->master_fd,
create_info->imageExtent.width,create_info->imageExtent.height,
+ 24, 32,image->base.row_pitch,image_handle,&image->fb_id);
What happens if we close the handle immediately after calling drmModeAddFB? Does the FB become invalid? If so, then we probably want to stash the handle so we can clean it up when we destroy the swapchain. Unless, of course, we're willing to make the assumption (as stated above) that the driver and WSI are always using the same FD.
Quoted 131 lines
src/vulkan/wsi/wsi_common_display.c new file +21
-0+ +if (ret) + goto fail_fb; + +return VK_SUCCESS ; + +fail_fb: +/* fall through */ + +fail_handle: +wsi_destroy_image (&chain->base, &image->base); + +return VK_ERROR_OUT_OF_HOST_MEMORY ; +} + +static void +wsi_display_image_finish (struct wsi_swapchain *drv_chain, +const VkAllocationCallbacks *allocator, +struct wsi_display_image *image) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *)
drv_chain;src/vulkan/wsi/wsi_common_display.c new file +6
-0+ +wsi_destroy_image (&chain->base, &image->base); +} + +static VkResult +wsi_display_swapchain_destroy(struct wsi_swapchain
*drv_chain,(quoted diff) +3
-0+ const VkAllocationCallbacks *allocator) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *)
drv_chain;src/vulkan/wsi/wsi_common_display.c new file +12
-0+ +for (uint32_t i =0 ; i < chain->base.image_count; i++) +wsi_display_image_finish (drv_chain, allocator, &chain->images[i]); +vk_free (allocator, chain); +return VK_SUCCESS ; +} + +static struct wsi_image * +wsi_display_get_wsi_image (struct wsi_swapchain *drv_chain, +uint32_t image_index) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *)
drv_chain;src/vulkan/wsi/wsi_common_display.c new file +10
-0+ +return &chain->images[image_index].base; +} + +static void +wsi_display_idle_old_displaying (struct wsi_display_image *active_image) +{ +struct wsi_display_swapchain *chain = active_image->chain; + + wsi_display_debug("idle everyone but %ld\n", active_image -&(chain->images[0]));
(quoted diff) +2
-0+ for (uint32_t i = 0; i < chain->base.image_count; i++) + if (chain->images[i].state == wsi_image_displaying &&&chain->images[i] !=
active_image) {src/vulkan/wsi/wsi_common_display.c new file +19
-0+wsi_display_debug ("idle %d\n" , i); + chain->images[i].state = wsi_image_idle; + } +} + +static VkResult +_wsi_display_queue_next (struct wsi_swapchain *drv_chain); + +static void +wsi_display_page_flip_handler2 (int fd, +unsigned int frame, +unsigned int sec, +unsigned int usec, +uint32_t crtc_id, +void *data) +{ +struct wsi_display_image *image = data; + + wsi_display_debug("image %ld displayed at %d\n", image -&(image->chain->images[0]), frame);
src/vulkan/wsi/wsi_common_display.c new file +7
-0+ image->state = wsi_image_displaying; +wsi_display_idle_old_displaying (image); + (void )_wsi_display_queue_next (&(image->chain->base)); +} + +static void wsi_display_page_flip_handler (int fd,unsigned int frame, + unsigned int sec, unsigned intusec, void *data)
src/vulkan/wsi/wsi_common_display.c new file +40
-0+{ +wsi_display_page_flip_handler2 (fd, frame, sec, usec,0 , data); +} + +static drmEventContext event_context = { + .version =DRM_EVENT_CONTEXT_VERSION , + .page_flip_handler = wsi_display_page_flip_handler, +#if DRM_EVENT_CONTEXT_VERSION >= 3 + .page_flip_handler2 = wsi_display_page_flip_handler2, +#endif +}; + +static void * +wsi_display_wait_thread (void *data) +{ +struct wsi_display *wsi = data; +struct pollfd pollfd = { + .fd = wsi->master_fd, + .events =POLLIN + }; +int ret; + +pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS ,NULL ); +for (;;) { + ret =poll (&pollfd,1 ,-1 ); +if (ret >0 ) { +pthread_mutex_lock (&wsi->wait_mutex); + (void )drmHandleEvent (wsi->master_fd, &event_context); +pthread_mutex_unlock (&wsi->wait_mutex); +pthread_cond_broadcast (&wsi->wait_cond); + } + } +return NULL ; +} + +static int +wsi_display_start_wait_thread (struct wsi_display *wsi) +{ +if (!wsi->wait_thread) { + int ret = pthread_create(&wsi->wait_thread, NULL,
wsi_display_wait_thread, wsi);
src/vulkan/wsi/wsi_common_display.c line 877
Quoted 7 lines
src/vulkan/wsi/wsi_common_display.c new file +7
-0+if (ret) +return ret; + } +return 0 ; +} + +/* call with wait_mutex held */
It might be worth a line in the comment to say that this function does not guarntee that any particular type of event (or indeed any event at all) has been processed. It's just a yield.
Quoted 19 lines
src/vulkan/wsi/wsi_common_display.c new file +13
-0+static int +wsi_display_wait_for_event(struct wsi_display *wsi, + uint64_t timeout_ns) +{ + int ret; + + ret = wsi_display_start_wait_thread(wsi); + + if (ret) + return ret; + + struct timespec abs_timeout = { + .tv_sec = timeout_ns / ((uint64_t) 1000 * (uint64_t) 1000 *(
uint64_t) 1000),
+ .tv_nsec =timeout_ns% ((uint64_t) 1000 * (uint64_t) 1000 *
(uint64_t) 1000)src/vulkan/wsi/wsi_common_display.c new file +3
-0+ }; + + ret = pthread_cond_timedwait(&wsi->wait_cond, &wsi->wait_mutex,
Quoted 2 lines
&abs_timeout);
+
Quoted 34 lines
+ wsi_display_debug("%9ld done waiting for event %d\n",
pthread_self(),
ret);src/vulkan/wsi/wsi_common_display.c new file +10
-0+return ret; +} + +static VkResult +wsi_display_acquire_next_image (struct wsi_swapchain *drv_chain, +uint64_t timeout, +VkSemaphore semaphore, +uint32_t *image_index) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain*)drv_chain;
src/vulkan/wsi/wsi_common_display.c new file +18
-0+struct wsi_display *wsi = chain->wsi; +int ret =0 ; +VkResult result =VK_SUCCESS ; + +if (timeout !=0 && timeout !=UINT64_MAX ) + timeout +=wsi_get_current_monotonic (); + +pthread_mutex_lock (&wsi->wait_mutex); +for (;;) { +for (uint32_t i =0 ; i < chain->base.image_count; i++) { +if (chain->images[i].state == wsi_image_idle) { + *image_index = i; +wsi_display_debug ("image %d available\n" , i); + chain->images[i].state = wsi_image_drawing; + result =VK_SUCCESS ; + goto done; + } + wsi_display_debug("image %d state %d\n", i,chain->images[i].state);
src/vulkan/wsi/wsi_common_display.c new file +1
-0+ }
src/vulkan/wsi/wsi_common_display.c line 935
Quoted 10 lines
src/vulkan/wsi/wsi_common_display.c new file +10
-0+ +if (ret ==ETIMEDOUT ) { + result =VK_TIMEOUT ; + goto done; + } + + ret =wsi_display_wait_for_event (wsi, timeout); + +if (ret && ret !=ETIMEDOUT ) { + result =VK_ERROR_OUT_OF_DATE_KHR ;
I don't see anywhere where you track any sort of per-swapchain error status. We need something so that, once you get VK_ERROR_OUT_OF_DATE, most of the other functions will start bailing immediately with OUT_OF_DATE instead of assuming the client catches it the first time it's returned. In particular, if wsi_display_queue_next fails inside an event handler, we need to know. In the X11 WSI patches, we just have a VkResult called "status" in the swapchain.
Quoted 28 lines
src/vulkan/wsi/wsi_common_display.c new file +25
-0+ goto done; + } + } +done: +pthread_mutex_unlock (&wsi->wait_mutex); +return result; +} + +/* +* Check whether there are any other connectors driven by this crtc +*/ +static bool +wsi_display_crtc_solo (struct wsi_display *wsi, +drmModeResPtr mode_res, +drmModeConnectorPtr connector, +uint32_t crtc_id) +{ +int c, e; + +/* See if any other connectors share the same encoder */ +for (c =0 ; c < mode_res->count_connectors; c++) { +if (mode_res->connectors[c] == connector->connector_id) +continue ; + + drmModeConnectorPtr other_connector =
drmModeGetConnector(wsi->master_fd, mode_res->connectors[c]);(quoted diff) +2
-0+ if (other_connector) { + bool match = (other_connector->encoder_id
Quoted 2 lines
==
connector->encoder_id);
Lots of whitespace in here. We don't usually try to line stuff up in code unless there's a good reason.
Quoted 15 lines
src/vulkan/wsi/wsi_common_display.c new file +12
-0+drmModeFreeConnector (other_connector); +if (match) +return false; + } + } + +/* See if any other encoders share the same crtc */ +for (e =0 ; e < mode_res->count_encoders; e++) { +if (mode_res->encoders[e] == connector->encoder_id) +continue ; + + drmModeEncoderPtr other_encoder =
drmModeGetEncoder(wsi->master_fd, mode_res->encoders[e]);(quoted diff) +2
-0+ if (other_encoder) { + bool match = (other_encoder->crtc_id ==
Quoted 2 lines
crtc_id);
Same here.
Quoted 41 lines
src/vulkan/wsi/wsi_common_display.c new file +25
-0+drmModeFreeEncoder (other_encoder); +if (match) +return false; + } + } +return true; +} + +/* +* Pick a suitable CRTC to drive this connector. Prefer a CRTC which is +* currently driving this connector and not any others. Settle for a CRTC +* which is currently idle. +*/ +static uint32_t +wsi_display_select_crtc (struct wsi_display_connector *connector, +drmModeResPtr mode_res, +drmModeConnectorPtr drm_connector) +{ +struct wsi_display *wsi = connector->wsi; +int c; +uint32_t crtc_id; + +/* See what CRTC is currently driving this connector */ +if (drm_connector->encoder_id) { + drmModeEncoderPtr encoder = drmModeGetEncoder(wsi->master_fd,
drm_connector->encoder_id);src/vulkan/wsi/wsi_common_display.c new file +5
-0+if (encoder) { + crtc_id = encoder->crtc_id; +drmModeFreeEncoder (encoder); +if (crtc_id) { + if (wsi_display_crtc_solo(wsi, mode_res, drm_connector,
crtc_id))src/vulkan/wsi/wsi_common_display.c new file +7
-0+return crtc_id; + } + } + } + crtc_id =0 ; +for (c =0 ; crtc_id ==0 && c < mode_res->count_crtcs; c++) { + drmModeCrtcPtr crtc = drmModeGetCrtc(wsi->master_fd,mode_res->crtcs[c]);
src/vulkan/wsi/wsi_common_display.c line 1016
Quoted 3 lines
src/vulkan/wsi/wsi_common_display.c new file +3
-0+if (crtc && crtc->buffer_id ==0 ) + crtc_id = crtc->crtc_id; +drmModeFreeCrtc (crtc);
I take it that 0 is not a valid crtc_id?
Quoted 12 lines
src/vulkan/wsi/wsi_common_display.c new file +11
-0+ } +return crtc_id; +} + +static VkResult +wsi_display_setup_connector (wsi_display_connector *connector, +wsi_display_mode *display_mode) +{ +struct wsi_display *wsi = connector->wsi; +drmModeModeInfoPtr drm_mode; +drmModeConnectorPtr drm_connector;
src/vulkan/wsi/wsi_common_display.c line 1037
Quoted 10 lines
src/vulkan/wsi/wsi_common_display.c new file +10
-0+drmModeResPtr mode_res; +VkResult result; +int m; + +if (connector->current_mode == display_mode && connector->crtc_id) +return VK_SUCCESS ; + + mode_res =drmModeGetResources (wsi->master_fd); +if (!mode_res) { + result =VK_ERROR_INITIALIZATION_FAILED ;
This looks more like an OUT_OF_DATE to me. Unless, of course, it's actually an OUT_OF_HOST_MEMORY.
src/vulkan/wsi/wsi_common_display.c line 1043
Quoted 8 lines
src/vulkan/wsi/wsi_common_display.c new file +4
-0+ goto bail; + } + + drm_connector = drmModeGetConnectorCurrent(wsi->master_fd,
connector->id);src/vulkan/wsi/wsi_common_display.c new file +2
-0+if (!drm_connector) { + result =VK_ERROR_INITIALIZATION_FAILED ;
Same here.
Quoted 8 lines
src/vulkan/wsi/wsi_common_display.c new file +6
-0+ goto bail_mode_res; + } + +/* Pick a CRTC if we don't have one */ +if (!connector->crtc_id) { + connector->crtc_id = wsi_display_select_crtc(connector, mode_res,
drm_connector);
src/vulkan/wsi/wsi_common_display.c line 1057
Quoted 8 lines
src/vulkan/wsi/wsi_common_display.c new file +8
-0+if (!connector->crtc_id) { + result =VK_ERROR_OUT_OF_DATE_KHR ; + goto bail_connector; + } + } + +if (connector->current_mode != display_mode) { +
Extra new line?
Quoted 45 lines
src/vulkan/wsi/wsi_common_display.c new file +37
-0+/* Find the drm mode cooresponding to the requested VkDisplayMode */ + drm_mode =NULL ; +for (m =0 ; m < drm_connector->count_modes; m++) { + drm_mode = &drm_connector->modes[m]; +if (wsi_display_mode_matches_drm (display_mode, drm_mode)) +break ; + drm_mode =NULL ; + } + +if (!drm_mode) { + result =VK_ERROR_OUT_OF_DATE_KHR ; + goto bail_connector; + } + + connector->current_mode = display_mode; + connector->current_drm_mode = *drm_mode; + } + + result =VK_SUCCESS ; + +bail_connector: +drmModeFreeConnector (drm_connector); +bail_mode_res: +drmModeFreeResources (mode_res); +bail: +return result; + +} + +/* +* Check to see if the kernel has no flip queued and if there's an image +* waiting to be displayed. +*/ +static VkResult +_wsi_display_queue_next (struct wsi_swapchain *drv_chain) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *)
drv_chain;src/vulkan/wsi/wsi_common_display.c new file +5
-0+struct wsi_display *wsi = chain->wsi; +uint32_t i; +struct wsi_display_image *image =NULL ; +VkIcdSurfaceDisplay *surface = chain->surface; + wsi_display_mode *display_mode =
wsi_display_mode_from_handle(surface->displayMode);
src/vulkan/wsi/wsi_common_display.c line 1105
Quoted 6 lines
src/vulkan/wsi/wsi_common_display.c new file +6
-0+wsi_display_connector *connector = display_mode->connector; +int ret; +VkResult result; + +if (wsi->master_fd <0 ) +return VK_ERROR_INITIALIZATION_FAILED ;
Is this possible? If so, it should be OUT_OF_DATE
Quoted 32 lines
src/vulkan/wsi/wsi_common_display.c new file +6
-0+ +if (display_mode != connector->current_mode) + connector->active = false; + +for (;;) { +/* Check to see if there is an image to display, or if some image is already queued */
src/vulkan/wsi/wsi_common_display.c new file +23
-0+ +for (i =0 ; i < chain->base.image_count; i++) { +struct wsi_display_image *tmp_image = &chain->images[i]; + +switch (tmp_image->state) { +case wsi_image_flipping: +/* already flipping, don't send another to the kernel yet */ +return VK_SUCCESS ; +case wsi_image_queued: +/* find the oldest queued */ +if (!image || tmp_image->flip_sequence < image->flip_sequence) + image = tmp_image; +break ; +default : +break ; + } + } + +if (!image) +return VK_SUCCESS ; + +if (connector->active) { + ret = drmModePageFlip(wsi->master_fd, connector->crtc_id,
image->fb_id,
src/vulkan/wsi/wsi_common_display.c line 1142
Quoted 8 lines
src/vulkan/wsi/wsi_common_display.c new file +8
-0+ DRM_MODE_PAGE_FLIP_EVENT, image); +if (ret ==0 ) { + image->state = wsi_image_flipping; +return VK_SUCCESS ; + } +wsi_display_debug ("page flip err %d %s\n" , ret,strerror (-ret)); + }else + ret = -EINVAL ;
If one half uses braces, please use braces on the other half.
src/vulkan/wsi/wsi_common_display.c line 1152
Quoted 12 lines
src/vulkan/wsi/wsi_common_display.c new file +6
-0+ +if (ret) { +switch (-ret) { +case EINVAL : + + result = wsi_display_setup_connector(connector,
display_mode);src/vulkan/wsi/wsi_common_display.c new file +4
-0+ +if (result !=VK_SUCCESS ) { + image->state = wsi_image_idle; +return result;
As I stated earlier, I think we want some sort of chain->status so that we can easily know that things have gone out-of-date and we don't end up retrying just because the client called QueuePresent again.
src/vulkan/wsi/wsi_common_display.c line 1162
Quoted 13 lines
src/vulkan/wsi/wsi_common_display.c new file +5
-0+ } + +/* XXX allow setting of position */ + + ret = drmModeSetCrtc(wsi->master_fd, connector->crtc_id,
image->fb_id, 0, 0,
+&connector->id, 1,&connector->current_drm_mode);src/vulkan/wsi/wsi_common_display.c new file +4
-0+ +if (ret ==0 ) { + image->state = wsi_image_displaying; +wsi_display_idle_old_displaying (image);
Can we really idle them immediately or do we need to wait until this image has begun to scan out before returning a new image from AcquireNextImage? I suppose we do use implicit fencing for all WSI images today so this is probably ok. Still, might be worth a TODO comment or something.
src/vulkan/wsi/wsi_common_display.c line 1168
Quoted 7 lines
src/vulkan/wsi/wsi_common_display.c new file +6
-0+ connector->active = true; +return VK_SUCCESS ; + } +break ; +case EACCES : +usleep (1000 *1000 );
?
Quoted 19 lines
src/vulkan/wsi/wsi_common_display.c new file +17
-0+ connector->active = false; +break ; +default : + connector->active = false; + image->state = wsi_image_idle; +return VK_ERROR_OUT_OF_DATE_KHR ; + } + } + } +} + +static VkResult +wsi_display_queue_present (struct wsi_swapchain *drv_chain, +uint32_t image_index, +const VkPresentRegionKHR *damage) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *)
drv_chain;
src/vulkan/wsi/wsi_common_display.c line 1194
Quoted 9 lines
src/vulkan/wsi/wsi_common_display.c new file +9
-0+struct wsi_display *wsi = chain->wsi; +struct wsi_display_image *image = &chain->images[image_index]; +VkResult result; + +assert (image->state == wsi_image_drawing); +wsi_display_debug ("present %d\n" , image_index); + +pthread_mutex_lock (&wsi->wait_mutex); +
assert(image->state == wsi_image_idle);
Quoted 61 lines
src/vulkan/wsi/wsi_common_display.c new file +14
-0+ image->flip_sequence = ++chain->flip_sequence; + image->state = wsi_image_queued; + + result =_wsi_display_queue_next (drv_chain); + +pthread_mutex_unlock (&wsi->wait_mutex); + +return result; +} + +static VkResult +wsi_display_surface_create_swapchain (VkIcdSurfaceBase *icd_surface, +VkDevice device, + struct wsi_device
*wsi_device,
+ intlocal_fd,(quoted diff) +2
-0+ const VkSwapchainCreateInfoKHR *create_info, + const VkAllocationCallbacks*allocator,
(quoted diff) +3
-0+ struct wsi_swapchain **swapchain_out) +{ + struct wsi_display *wsi = (struct wsi_display *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
src/vulkan/wsi/wsi_common_display.c new file +3
-0+VkResult result; + + assert(create_info->sType == VK_STRUCTURE_TYPE_SWAPCHAIN_
CREATE_INFO_KHR);src/vulkan/wsi/wsi_common_display.c new file +27
-0+ +struct wsi_display_swapchain *chain; +const unsigned num_images = create_info->minImageCount; +size_t size =sizeof (*chain) + num_images *sizeof (chain->images[0 ]); + + chain =vk_alloc (allocator, size,8 , +VK_SYSTEM_ALLOCATION_SCOPE_OBJECT ); + +if (chain ==NULL ) +return VK_ERROR_OUT_OF_HOST_MEMORY ; + + result =wsi_swapchain_init (wsi_device, &chain->base, device, + create_info, allocator); + + chain->base.destroy = wsi_display_swapchain_destroy; + chain->base.get_wsi_image = wsi_display_get_wsi_image; + chain->base.acquire_next_image = wsi_display_acquire_next_image; + chain->base.queue_present = wsi_display_queue_present; + chain->base.present_mode = create_info->presentMode; + chain->base.image_count = num_images; + + chain->wsi = wsi; + + chain->surface = (VkIcdSurfaceDisplay *) icd_surface; + +for (uint32_t image =0 ; image < chain->base.image_count; image++) { + result = wsi_display_image_init(device, &chain->base, create_info,allocator,
src/vulkan/wsi/wsi_common_display.c line 1254
Quoted 10 lines
src/vulkan/wsi/wsi_common_display.c new file +10
-0+ &chain->images[image]); +if (result !=VK_SUCCESS ) + goto fail_init_images; + } + + *swapchain_out = &chain->base; + +return VK_SUCCESS ; + +fail_init_images:
You need to clean up if you are only able to create some of the images.
src/vulkan/wsi/wsi_common_display.c line 1261
Quoted 8 lines
src/vulkan/wsi/wsi_common_display.c new file +7
-0+return result; +} + +VkResult +wsi_display_init_wsi(struct wsi_device *wsi_device, + const VkAllocationCallbacks *alloc, + VkPhysicalDevice physical_device,
You can get the physical device from the wsi_device. No need to pass it in separately.
Quoted 11 lines
src/vulkan/wsi/wsi_common_display.c new file +10
-0+ int device_fd) +{ +struct wsi_display *wsi; +VkResult result; + + wsi =vk_alloc (alloc,sizeof (*wsi),8 , +VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE ); +if (!wsi) { + result =VK_ERROR_OUT_OF_HOST_MEMORY ; + goto fail;
src/vulkan/wsi/wsi_common_display.c line 1281
Quoted 10 lines
src/vulkan/wsi/wsi_common_display.c new file +10
-0+ } +memset (wsi,'\0' ,sizeof (*wsi)); + + wsi->master_fd =-1 ; +if (drmGetNodeTypeFromFd (device_fd) ==DRM_NODE_PRIMARY ) + wsi->master_fd = device_fd; + wsi->render_fd = device_fd; + +pthread_mutex_init (&wsi->wait_mutex,NULL ); + wsi->physical_device = physical_device;
I don't see this being used anywhere. Is it needed?
Quoted 231 lines
src/vulkan/wsi/wsi_common_display.c new file +62
-0+ wsi->alloc = alloc; + +LIST_INITHEAD (&wsi->display_modes); +LIST_INITHEAD (&wsi->connectors); + +pthread_condattr_t condattr; +int ret; + + ret =pthread_mutex_init (&wsi->wait_mutex,NULL ); +if (ret) { + result =VK_ERROR_OUT_OF_HOST_MEMORY ; + goto fail_mutex; + } + + ret =pthread_condattr_init (&condattr); +if (ret) { + result =VK_ERROR_OUT_OF_HOST_MEMORY ; + goto fail_condattr; + } + + ret =pthread_condattr_setclock (&condattr,CLOCK_MONOTONIC ); +if (ret) { + result =VK_ERROR_OUT_OF_HOST_MEMORY ; + goto fail_setclock; + } + + ret =pthread_cond_init (&wsi->wait_cond, &condattr); +if (ret) { + result =VK_ERROR_OUT_OF_HOST_MEMORY ; + goto fail_cond; + } + +pthread_condattr_destroy (&condattr); + + wsi->base.get_support = wsi_display_surface_get_support; + wsi->base.get_capabilities = wsi_display_surface_get_capabilities; + wsi->base.get_capabilities2 = wsi_display_surface_get_capabilities2; + wsi->base.get_formats = wsi_display_surface_get_formats; + wsi->base.get_formats2 = wsi_display_surface_get_formats2; + wsi->base.get_present_modes = wsi_display_surface_get_present_modes; + wsi->base.create_swapchain = wsi_display_surface_create_swapchain; + + wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY ] = &wsi->base; + +return VK_SUCCESS ; + +fail_cond: +fail_setclock: +pthread_condattr_destroy (&condattr); +fail_condattr: +pthread_mutex_destroy (&wsi->wait_mutex); +fail_mutex: +vk_free (alloc, wsi); +fail: +return result; +} + +void +wsi_display_finish_wsi (struct wsi_device *wsi_device, +const VkAllocationCallbacks *alloc) +{ + struct wsi_display *wsi = (struct wsi_display *)wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY];
src/vulkan/wsi/wsi_common_display.c new file +5
-0+ +if (wsi) { + +struct wsi_display_connector *connector, *connector_storage; + LIST_FOR_EACH_ENTRY_SAFE(connector, connector_storage,
&wsi->connectors, list) {src/vulkan/wsi/wsi_common_display.c new file +5
-0+vk_free (wsi->alloc, connector); + } + +struct wsi_display_mode *mode, *mode_storage; + LIST_FOR_EACH_ENTRY_SAFE(mode, mode_storage, &wsi->display_modes,list) {
src/vulkan/wsi/wsi_common_display.c new file +15
-0+vk_free (wsi->alloc, mode); + } + +pthread_mutex_lock (&wsi->wait_mutex); +if (wsi->wait_thread) { +pthread_cancel (wsi->wait_thread); +pthread_join (wsi->wait_thread,NULL ); + } +pthread_mutex_unlock (&wsi->wait_mutex); +pthread_mutex_destroy (&wsi->wait_mutex); +pthread_cond_destroy (&wsi->wait_cond); + +vk_free (alloc, wsi); + } +}src/vulkan/wsi/wsi_common_display.h new file +4
-0@@ -0,0 +1,72 @@ +/* +* Copyright © 2017 Keith Packard +* +* Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */src/vulkan/wsi/wsi_common_display.h new file +21
-0+ +#ifndef WSI_COMMON_DISPLAY_H +#define WSI_COMMON_DISPLAY_H + +#include "wsi_common.h" +#include <xf86drm.h> +#include <xf86drmMode.h> + +#define typed_memcpy (dest, src, count) ({ \ + STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \ + memcpy((dest), (src), (count) * sizeof(*(src))); \ +}) + +VkResult +wsi_display_get_physical_device_display_properties (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +uint32_t *property_count, +VkDisplayPropertiesKHR *properties); +VkResult +wsi_display_get_physical_device_display_plane_properties(VkPhysicalDevice physical_device, + struct
wsi_device*wsi_device,src/vulkan/wsi/wsi_common_display.h new file +12
-0+uint32_t *property_count, + VkDisplayPlanePropertiesKHR *properties); + +VkResult +wsi_display_get_display_plane_supported_displays (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +uint32_t plane_index, +uint32_t *display_count, +VkDisplayKHR *displays); +VkResult +wsi_display_get_display_mode_properties (VkPhysicalDevice physical_device, + struct wsi_device
*wsi_device,src/vulkan/wsi/wsi_common_display.h new file +7
-0+VkDisplayKHR display, + uint32_t *property_count, + VkDisplayModePropertiesKHR *properties); + +VkResult +wsi_get_display_plane_capabilities (VkPhysicalDevice physical_device, + struct wsi_device
*wsi_device,
+ VkDisplayModeKHRmode_khr,
+uint32_tplane_index,src/vulkan/wsi/wsi_common_display.h new file +6
-0+VkDisplayPlaneCapabilitiesKHR *capabilities); + +VkResult +wsi_create_display_surface (VkInstance instance, +const VkAllocationCallbacks *pAllocator, + const VkDisplaySurfaceCreateInfoKHR*pCreateInfo,
src/vulkan/wsi/wsi_common_display.h new file +3
-0+ VkSurfaceKHR *pSurface); + +#endif src/vulkan/wsi/wsi_common_private.h +10
-0@@ -135,6 +135,16 @@ void wsi_wl_finish_wsi(struct wsi_device *wsi_device, const VkAllocationCallbacks *alloc); +VkResult +wsi_display_init_wsi (struct wsi_device *wsi_device, +const VkAllocationCallbacks *alloc, +VkPhysicalDevice physical_device, +int device_fd); + +void +wsi_display_finish_wsi (struct wsi_device *wsi_device, +const VkAllocationCallbacks *alloc); +#define WSI_DEFINE_NONDISP_HANDLE_CASTS (__wsi_type, __VkType) \\
static inline struct__wsi_type*
\
--
2.15.1
Quoted 5 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 01/21] vulkan: Add KHR_display extension using DRM
Hi,
Quoted 9 lines · Jason Ekstrand
src/vulkan/wsi/wsi_common_display.c line 748
Quoted 5 lines · Keith Packard
src/vulkan/wsi/wsi_common_display.c new file +5
-0+ image->chain = chain; + image->state = wsi_image_idle; + image->fb_id =0 ; + +/* XXX extract depth and bpp from image somehow */ You have the format in
create_info. We could add some generic VkFormat introspection or we can just handle the 2-4 cases we care about directly.
Or better, just use drmModeAddFB2 and pass the format directly. That landed back in 3.2 or so, and I don't think there's anyone trying to use Vulkan on a kernel from 2011.
Cheers,
Daniel
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 01/21] vulkan: Add KHR_display extension using DRM
Quoted 3 lines · Daniel Stone
Or better, just use drmModeAddFB2 and pass the format directly. That landed back in 3.2 or so, and I don't think there's anyone trying to use Vulkan on a kernel from 2011.
Yeah, that's probably a better plan. I've pushed a patch that does this on top of the long list of patches made in response to Jason's email.
Once he's replied to that, I'll go ahead and smash the new patches back on top of the original series and re-publish that.
Signature · 1 line
-keith
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 01/21] vulkan: Add KHR_display extension using DRM
In reply to Jason EkstrandJason Ekstrand <[email protected]> writes:
Thanks a million for the intense review. I've pushed 15 tiny patches that address individual questions in this message. If you want to look at those separately, that would be great. When we're done, I'll merge them back into the giant patch.
Sorry for the delay in answering; you asked a hard question about GEM handles and reference counting which I think I've resolved by eliminating the ability to share the same fd for modesetting and rendering.
Let me know if I've deleted too much context from your answers.
Quoted 2 lines
With the exception of NIR (which is a bit odd), we usually use
ALL_CAPSfor enum values.
Thanks, fixed.
Quoted 4 lines
Yes, this does seem like the only reasonable mode for now. I suppose you could check to see if the platform supports
ASYNC_FLIPand advertise IMMEDIATE in that case. I know intel doesn't advertise it but I thought amdgpu does.
Ok, we'll put that on the wish list, along with MAILBOX (which applications actually want :-)
Quoted 2 lines
vk_outarray, though I suppose you've probably already made that change.
Yup, vk_outarray everywhere now.
Quoted 3 lines
I don't see
use_prime_blitbeing set anywhere. Perhaps that comes in a later patch? The line is obviously correct, so I'm fine with leaving it.
You're right -- this was a cult-n-paste error. I don't support prime at all, so I've removed this bit.
Quoted 3 lines
This will have to be updated for modifiers. I'm reasonably happy for it to be the no-op update for now though
KHR_displaysupporting real modifiers would be nice. :-)
Yeah, "patches welcome", of course. I don't have a requirement for them on Radeon at this point.
Quoted 7 lines
Quoted 6 lines
src/vulkan/wsi/wsi_common_display.c new file +4
-0+if (result !=VK_SUCCESS ) +return result; + + ret = drmPrimeFDToHandle(wsi->master_fd, image->base.fd,
&image_handle);
Quoted 7 lines
This opens up some interesting questions. GEM handles are not reference counted by the kernel. If the driver that we're running on is using
master_fd, then we shouldn't close our handle because that would close the handle for the driver as well. If it's not usingmaster_fd, we should close the handle to avoid leaking it. The later is only a worry in the prime case but given that I saw a line above aboutuse_prime_blit, you have me scared. :-)
Ok, as I mentioned in the header of this message, I've eliminated any code which talks about potentially sharing master_fd and render_fd. I removed render_fd from the wsi layer entirely as it is no longer used anywhere.
In the drivers, when you request KHR_display, I attempt to open the related primary node and if that succeeds, I pass that to the wsi layer for use there. That fd is otherwise unused by the driver, and in fact the driver doesn't need to close it as the wsi layer will.
Obviously having two FDs is "wasteful" at some level as we really don't need that, but that's what the acquire_xlib extension will have to do anyways.
Quoted 6 lines
One solution to this connundrum would be to simply never use the master FD for the Vulkan driver itself and always open a render node. If handed a master FD, you could check if it matches your render node and set
use_prime_blitaccordingly. Then the driver and WSI would have separate handle domains and this problem would be solved. You could also just open the master FD twice, once for WSI and once for the driver.
Yup, two FDs, one master, one render. That way, the kludge seen in this patch where it opens the master when you request the KHR_display extension works the same as the acquire_xlib code in the later patch.
Quoted 3 lines
You have the format in
create_info. We could add some generic VkFormat introspection or we can just handle the 2-4 cases we care about directly.
Given that this layer provides the list of valid surface formats which that image could contain, I've added depth/bpp information to that list and the image_init code walks over the list of possible formats to find the associated depth/bpp values.
If the application provides an invalid format, I'm returning VK_ERROR_DEVICE_LOST as that is a valid error return and I couldn't find anything else that seemed like a better value. If we get here, the application made a mistake anyways.
Quoted 5 lines
What happens if we close the handle immediately after calling drmModeAddFB? Does the FB become invalid? If so, then we probably want to stash the handle so we can clean it up when we destroy the swapchain. Unless, of course, we're willing to make the assumption (as stated above) that the driver and WSI are always using the same FD.
It looks like the FB ends up with a reference to the object, so it would should be safe to just close the handle at this point. However, to make it less dependent on the kernel behavior, I've changed the code to store the buffer_object handle in the image and then added code to free both the buffer object and the frame buffer in wsi_display_image_finish.
Thanks for finding the leak.
Quoted 6 lines
Quoted 2 lines
+/* call with
wait_mutexheld */It might be worth a line in the comment to say that this function does not guarntee that any particular type of event (or indeed any event at all) has been processed. It's just a yield.
Yeah, more comments are always good :-)
Quoted 7 lines
I don't see anywhere where you track any sort of per-swapchain error status. We need something so that, once you get
VK_ERROR_OUT_OF_DATE, most of the other functions will start bailing immediately withOUT_OF_DATEinstead of assuming the client catches it the first time it's returned. In particular, ifwsi_display_queue_nextfails inside an event handler, we need to know. In the X11 WSI patches, we just have a VkResult called "status" in the swapchain.
Failure is not an option? In reality, failures in the display backend should only result from an actual unexpected error condition, unlike the X backend where windows get destroyed or resized without the applications knowledge.
However, that doesn't mean we shouldn't handle them correctly. I now record asynchronous failures in a 'chain->status' value and return that to applications in acquire_next_image and queue_present.
Quoted 4 lines
Lots of whitespace in here. We don't usually try to line stuff up in code unless there's a good reason.
Same here.
Fixed.
Quoted 1 line
I take it that 0 is not a valid
crtc_id?
Correct.
Quoted 7 lines
src/vulkan/wsi/wsi_common_display.c line 1037
Quoted 4 lines
src/vulkan/wsi/wsi_common_display.c new file +3
-0+ mode_res =drmModeGetResources (wsi->master_fd); +if (!mode_res) { + result =VK_ERROR_INITIALIZATION_FAILED ;This looks more like an
OUT_OF_DATEto me. Unless, of course, it's actually anOUT_OF_HOST_MEMORY.
Yeah, VK_ERROR_OUT_OF_HOST_MEMORY if errno is ENOMEM, otherwise the ioctl failed and we've lost our ability to do master operations (vt switched away, or a revoked lease), in which case OUT_OF_DATE_KHR seems appropriate.
Quoted 5 lines
src/vulkan/wsi/wsi_common_display.c line 1043
Quoted 3 lines
src/vulkan/wsi/wsi_common_display.c new file +2
-0+if (!drm_connector) { + result =VK_ERROR_INITIALIZATION_FAILED ;Same here.
Same fix.
Quoted 1 line
Extra new line?
There's a comment afterwards, so I like a bit of whitespace to highlight that.
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ if (wsi->master_fd < 0) + return VK_ERROR_INITIALIZATION_FAILED;Is this possible? If so, it should be
OUT_OF_DATE
It's only possible if you call into this API without having gotten a master_fd set, or after calling vkReleaseDisplay (part of the direct_mode_display extension).
I don't know what the right error is in this case as the application did something wrong or didn't have the right permissions. It "can't happen" in normal operation, so OUT_OF_DATE seems inappropriate to me.
Suggestions welcome.
Quoted 1 line
If one half uses braces, please use braces on the other half.
I found another case doing this
Quoted 3 lines
As I stated earlier, I think we want some sort of
chain->statusso that we can easily know that things have gone out-of-date and we don't end up retrying just because the client called QueuePresent again.
All fixed -- queue_next returns are captured in chain->status and returned at subsequent calls to queue_present or acquire_next_image.
Quoted 10 lines
src/vulkan/wsi/wsi_common_display.c line 1162
Quoted 9 lines
+ ret = drmModeSetCrtc(wsi->master_fd,
connector->crtc_id,image->fb_id, 0, 0,
+&connector->id, 1,&connector->current_drm_mode);src/vulkan/wsi/wsi_common_display.c new file +4
-0+ +if (ret ==0 ) { + image->state = wsi_image_displaying; +wsi_display_idle_old_displaying (image);
Quoted 3 lines
Can we really idle them immediately or do we need to wait until this image has begun to scan out before returning a new image from AcquireNextImage?
After ModeSetCrtc, the old image is no longer being used. There's no event delivered that could tell us that the scanout started later anyways.
Quoted 2 lines
I suppose we do use implicit fencing for all WSI images today so this is probably ok. Still, might be worth a TODO comment or something.
Given that we're not going to receive an event telling us that the image is idle, I'm not sure what we could ever do, but a comment is probably wise.
Quoted 5 lines
src/vulkan/wsi/wsi_common_display.c line 1168
Quoted 3 lines
src/vulkan/wsi/wsi_common_display.c new file +2
-0+case EACCES : +usleep (1000 *1000 );?
We get EACCES when VT switched away, so we just want to idle until VT switched back. After we get back, we'll get EINVAL from the page flip ioctl, which will cause us to re-set the mode.
If there were an event delivered on VT switch, I could monitor for that and make the switch back happen faster.
I'll add a comment.
Quoted 11 lines
Quoted 11 lines
src/vulkan/wsi/wsi_common_display.c new file +6
-0+static VkResult +wsi_display_queue_present (struct wsi_swapchain *drv_chain, +uint32_t image_index, +const VkPresentRegionKHR *damage) +{ + struct wsi_display_swapchain *chain = (struct wsi_display_swapchain *)
drv_chain;src/vulkan/wsi/wsi_common_display.c new file +4
-0+struct wsi_display *wsi = chain->wsi; +struct wsi_display_image *image = &chain->images[image_index]; +VkResult result; +
Quoted 8 lines
src/vulkan/wsi/wsi_common_display.c line 1194
Quoted 6 lines
src/vulkan/wsi/wsi_common_display.c new file +5
-0+assert (image->state == wsi_image_drawing); +wsi_display_debug ("present %d\n" , image_index); + +pthread_mutex_lock (&wsi->wait_mutex); +
assert(image->state == wsi_image_idle);
I don't understand. I'm asserting that you can't queue an image that you haven't gotten from acquire_next_image, which puts the image in WSI_IMAGE_DRAWING state.
Quoted 2 lines
You need to clean up if you are only able to create some of the images.
Oops.
Quoted 8 lines
src/vulkan/wsi/wsi_common_display.c line 1261
Quoted 5 lines
src/vulkan/wsi/wsi_common_display.c new file +4
-0+VkResult +wsi_display_init_wsi(struct wsi_device *wsi_device, + const VkAllocationCallbacks *alloc, + VkPhysicalDevice physical_device,You can get the physical device from the
wsi_device. No need to pass it in separately.
No, you can't (there's very little in wsi_device), but it turns out that I never needed this value anyways. I've removed it from the API and from 'struct wsi_display'.
Quoted 1 line
I don't see this being used anywhere. Is it needed?
Nope. See above.
Signature · 1 line
-keith
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/21 anv: Add KHR_display extension to anv
In reply to Keith PackardThis adds support for the KHR_display extension to the anv Vulkan driver. The driver now attempts to open the master DRM node when the KHR_display extension is requested so that the common winsys code can perform the necessary operations.
--- src/intel/Makefile.sources | 3 + src/intel/Makefile.vulkan.am | 7 ++ src/intel/vulkan/anv_device.c | 18 ++++- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_extensions_gen.py | 5 +- src/intel/vulkan/anv_wsi_display.c | 129 +++++++++++++++++++++++++++++++++ src/intel/vulkan/meson.build | 7 ++ 7 files changed, 165 insertions(+), 5 deletions(-) create mode 100644 src/intel/vulkan/anv_wsi_display.c
src/intel/Makefile.sources +3 -0
@@ -240,6 +240,9 @@ VULKAN_WSI_WAYLAND_FILES := \ VULKAN_WSI_X11_FILES := \ vulkan/anv_wsi_x11.c +VULKAN_WSI_DISPLAY_FILES := \ + vulkan/anv_wsi_display.c + VULKAN_GEM_FILES := \ vulkan/anv_gem.c
src/intel/Makefile.vulkan.am +7 -0
@@ -187,6 +187,13 @@ VULKAN_SOURCES += $(VULKAN_WSI_WAYLAND_FILES) VULKAN_LIB_DEPS += $(WAYLAND_CLIENT_LIBS) endif +if HAVE_PLATFORM_DISPLAY +VULKAN_CPPFLAGS += \ + -DVK_USE_PLATFORM_DISPLAY_KHR + +VULKAN_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) +endif + noinst_LTLIBRARIES += vulkan/libvulkan_common.la vulkan_libvulkan_common_la_SOURCES = $(VULKAN_SOURCES) vulkan_libvulkan_common_la_CFLAGS = $(VULKAN_CFLAGS)
src/intel/vulkan/anv_device.c +15 -3
@@ -277,14 +277,25 @@ anv_physical_device_init_uuids(struct anv_physical_device *device)static VkResult anv_physical_device_init (struct anv_physical_device *device,struct anv_instance *instance, -const char *path) +const char *primary_path, +const char *render_path) {VkResult result; -int fd; +int fd =-1 ; +const char *path;brw_process_intel_debug_variable (); - fd =open (path,O_RDWR |O_CLOEXEC ); +if (instance->enabled_extensions.KHR_display) { + path = primary_path; + fd =open (path,O_RDWR |O_CLOEXEC ); + } + +if (fd <0 ) { + path = render_path; + fd =open (path,O_RDWR |O_CLOEXEC ); + } +if (fd <0 )return vk_error (VK_ERROR_INCOMPATIBLE_DRIVER );
@@ -652,6 +663,7 @@ anv_enumerate_devices(struct anv_instance *instance) result =anv_physical_device_init (&instance->physicalDevice, instance, + devices[i]->nodes[DRM_NODE_PRIMARY ], devices[i]->nodes[DRM_NODE_RENDER ]);if (result !=VK_ERROR_INCOMPATIBLE_DRIVER )break ;
src/intel/vulkan/anv_extensions.py +1 -0
@@ -83,6 +83,7 @@ EXTENSIONS = [ Extension('VK_KHR_wayland_surface', 6, 'VK_USE_PLATFORM_WAYLAND_KHR'), Extension('VK_KHR_xcb_surface', 6, 'VK_USE_PLATFORM_XCB_KHR'), Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), + Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_KHX_multiview', 1, True), Extension('VK_EXT_debug_report', 8, True), Extension('VK_EXT_external_memory_dma_buf', 1, True),
src/intel/vulkan/anv_extensions_gen.py +3 -2
@@ -113,7 +113,7 @@ _TEMPLATE_C = Template(COPYRIGHT + """ #include "vk_util.h" /* Convert the VK_USE_PLATFORM_* defines to booleans */ -%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB']: +%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB', 'DISPLAY']: #ifdef VK_USE_PLATFORM_${platform}_KHR # undef VK_USE_PLATFORM_${platform}_KHR # define VK_USE_PLATFORM_${platform}_KHR true
@@ -132,7 +132,8 @@ _TEMPLATE_C = Template(COPYRIGHT + """ #define ANV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || \\ VK_USE_PLATFORM_XCB_KHR || \\ - VK_USE_PLATFORM_XLIB_KHR) + VK_USE_PLATFORM_XLIB_KHR || \\ + VK_USE_PLATFORM_DISPLAY_KHR) const VkExtensionProperties anv_instance_extensions[ANV_INSTANCE_EXTENSION_COUNT] = { %for ext in instance_extensions:
src/intel/vulkan/anv_wsi_display.c new file +129 -0
129 lines not on this page · raw message
src/intel/vulkan/meson.build +7 -0
@@ -171,6 +171,13 @@ if with_platform_wayland libanv_files += files('anv_wsi_wayland.c') endif +if with_platform_display + anv_flags += [ + '-DVK_USE_PLATFORM_DISPLAY_KHR', + ] + libanv_files += files('anv_wsi_display.c') +endif + libanv_common = static_library( 'anv_common', [libanv_files, anv_entrypoints, anv_extensions_c, anv_extensions_h],
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/21 radv: Add KHR_display extension to radv
In reply to Keith PackardThis adds support for the KHR_display extension to the radv Vulkan driver. The driver now attempts to open the master DRM node when the KHR_display extension is requested so that the common winsys code can perform the necessary operations.
--- src/amd/vulkan/Makefile.am | 8 +++ src/amd/vulkan/Makefile.sources | 3 + src/amd/vulkan/meson.build | 7 ++ src/amd/vulkan/radv_device.c | 25 ++++++- src/amd/vulkan/radv_extensions.py | 7 +- src/amd/vulkan/radv_private.h | 2 + src/amd/vulkan/radv_wsi_display.c | 143 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 src/amd/vulkan/radv_wsi_display.c
src/amd/vulkan/Makefile.am +8 -0
@@ -76,6 +76,14 @@ VULKAN_LIB_DEPS = \ $(DLOPEN_LIBS) \ -lm +if HAVE_PLATFORM_DISPLAY +AM_CPPFLAGS += \ + -DVK_USE_PLATFORM_DISPLAY_KHR + +VULKAN_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) + +endif + if HAVE_PLATFORM_X11 AM_CPPFLAGS += \ $(XCB_DRI3_CFLAGS) \
src/amd/vulkan/Makefile.sources +3 -0
@@ -78,6 +78,9 @@ VULKAN_WSI_WAYLAND_FILES := \ VULKAN_WSI_X11_FILES := \ radv_wsi_x11.c +VULKAN_WSI_DISPLAY_FILES := \ + radv_wsi_display.c + VULKAN_GENERATED_FILES := \ radv_entrypoints.c \ radv_entrypoints.h \
src/amd/vulkan/meson.build +7 -0
@@ -112,6 +112,13 @@ if with_platform_wayland libradv_files += files('radv_wsi_wayland.c') endif +if with_platform_display + radv_flags += [ + '-DVK_USE_PLATFORM_DISPLAY_KHR', + ] + libradv_files += files('radv_wsi_display.c') +endif + libvulkan_radeon = shared_library( 'vulkan_radeon', [libradv_files, radv_entrypoints, radv_extensions_c, vk_format_table_c],
src/amd/vulkan/radv_device.c +23 -2
@@ -191,9 +191,26 @@ radv_physical_device_init(struct radv_physical_device *device,const char *path = drm_device->nodes[DRM_NODE_RENDER ];VkResult result;drmVersionPtr version; -int fd; +int fd =-1 ; + +if (instance->khr_display_requested) { + fd =open (drm_device->nodes[DRM_NODE_PRIMARY ],O_RDWR |O_CLOEXEC ); +if (fd >=0 ) { +uint32_t accel_working =0 ; +struct drm_amdgpu_info request = { + .return_pointer = (uintptr_t )&accel_working, + .return_size =sizeof (accel_working), + .query =AMDGPU_INFO_ACCEL_WORKING + }; - fd =open (path,O_RDWR |O_CLOEXEC ); +if (drmCommandWrite (fd,DRM_AMDGPU_INFO , &request,sizeof (struct drm_amdgpu_info )) <0 || !accel_working) { +close (fd); + fd =-1 ; + } + } + } +if (fd <0 ) + fd =open (path,O_RDWR |O_CLOEXEC );if (fd <0 )return vk_error (VK_ERROR_INCOMPATIBLE_DRIVER );
@@ -387,6 +404,7 @@ VkResult radv_CreateInstance( {struct radv_instance *instance;VkResult result; +bool khr_display_requested = false;assert (pCreateInfo->sType ==VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO );
@@ -411,6 +429,8 @@ VkResult radv_CreateInstance(const char *ext_name = pCreateInfo->ppEnabledExtensionNames[i];if (!radv_instance_extension_supported (ext_name))return vk_error (VK_ERROR_EXTENSION_NOT_PRESENT ); +if (strcmp (ext_name,VK_KHR_DISPLAY_EXTENSION_NAME ) ==0 ) + khr_display_requested = true; } instance = vk_zalloc2(&default_alloc, pAllocator, sizeof(*instance), 8,
@@ -427,6 +447,7 @@ VkResult radv_CreateInstance( instance->apiVersion = client_version; instance->physicalDeviceCount =-1 ; + instance->khr_display_requested = khr_display_requested; result =vk_debug_report_instance_init (&instance->debug_report_callbacks);if (result !=VK_SUCCESS ) {
src/amd/vulkan/radv_extensions.py +5 -2
@@ -81,6 +81,7 @@ EXTENSIONS = [ Extension('VK_KHR_wayland_surface', 6, 'VK_USE_PLATFORM_WAYLAND_KHR'), Extension('VK_KHR_xcb_surface', 6, 'VK_USE_PLATFORM_XCB_KHR'), Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), + Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_KHX_multiview', 1, '!ANDROID'), Extension('VK_EXT_debug_report', 9, True), Extension('VK_EXT_discard_rectangles', 1, True),
@@ -168,7 +169,7 @@ _TEMPLATE = Template(COPYRIGHT + """ #include "vk_util.h" /* Convert the VK_USE_PLATFORM_* defines to booleans */ -%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB']: +%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB', 'DISPLAY']: #ifdef VK_USE_PLATFORM_${platform}_KHR # undef VK_USE_PLATFORM_${platform}_KHR # define VK_USE_PLATFORM_${platform}_KHR true
@@ -187,7 +188,9 @@ _TEMPLATE = Template(COPYRIGHT + """ #define RADV_HAS_SURFACE (VK_USE_PLATFORM_WAYLAND_KHR || \\ VK_USE_PLATFORM_XCB_KHR || \\ - VK_USE_PLATFORM_XLIB_KHR) + VK_USE_PLATFORM_XLIB_KHR || \\ + VK_USE_PLATFORM_DISPLAY_KHR) + bool radv_instance_extension_supported(const char *name)
src/amd/vulkan/radv_private.h +2 -0
@@ -75,6 +75,7 @@ typedef uint32_t xcb_window_t;#include "radv_entrypoints.h" #include "wsi_common.h" +#include "wsi_common_display.h" #define ATI_VENDOR_ID 0x1002
@@ -300,6 +301,7 @@ struct radv_instance {uint64_t perftest_flags;struct vk_debug_report_instance debug_report_callbacks; +bool khr_display_requested; };VkResult radv_init_wsi (struct radv_physical_device *physical_device);
src/amd/vulkan/radv_wsi_display.c new file +143 -0
143 lines not on this page · raw message
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/21 vulkan: Add EXT_direct_mode_display
In reply to Keith PackardAdd support for the EXT_direct_mode_display extension. This just provides the vkReleaseDisplayEXT function.
--- src/vulkan/wsi/wsi_common_display.c | 17 +++++++++++++++++ src/vulkan/wsi/wsi_common_display.h | 5 +++++ 2 files changed, 22 insertions(+)
src/vulkan/wsi/wsi_common_display.c +17 -0
@@ -1366,3 +1366,20 @@ wsi_display_finish_wsi(struct wsi_device *wsi_device,vk_free (alloc, wsi); } } + +/* +* Implement vkReleaseDisplay +*/ +VkResult +wsi_release_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +VkDisplayKHR display) +{ +struct wsi_display *wsi = (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY ]; + +if (wsi->master_fd >=0 && wsi->master_fd != wsi->render_fd) { +close (wsi->master_fd); + wsi->master_fd =-1 ; + } +return VK_SUCCESS ; +}
src/vulkan/wsi/wsi_common_display.h +5 -0
@@ -69,4 +69,9 @@ wsi_create_display_surface(VkInstance instance,const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, VkSurfaceKHR *pSurface); +VkResult +wsi_release_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +VkDisplayKHR display); +#endif
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 5/21 anv: Add EXT_direct_mode_display to anv driver
In reply to Keith PackardAdd support for the EXT_direct_mode_display extension. This just provides the vkReleaseDisplayEXT function.
--- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_wsi_display.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
src/intel/vulkan/anv_extensions.py +1 -0
@@ -84,6 +84,7 @@ EXTENSIONS = [ Extension('VK_KHR_xcb_surface', 6, 'VK_USE_PLATFORM_XCB_KHR'), Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), + Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_KHX_multiview', 1, True), Extension('VK_EXT_debug_report', 8, True), Extension('VK_EXT_external_memory_dma_buf', 1, True),
src/intel/vulkan/anv_wsi_display.c +11 -0
@@ -127,3 +127,14 @@ anv_CreateDisplayPlaneSurfaceKHR(VkInstance _instancereturn wsi_create_display_surface (_instance, alloc, create_info, surface); } + +VkResult +anv_ReleaseDisplayEXT (VkPhysicalDevice physical_device, +VkDisplayKHR display) +{ +ANV_FROM_HANDLE (anv_physical_device, pdevice, physical_device); + +return wsi_release_display (physical_device, + &pdevice->wsi_device, + display); +}
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/21 radv: Add EXT_direct_mode_display to radv driver
In reply to Keith PackardAdd support for the EXT_direct_mode_display extension. This just provides the vkReleaseDisplayEXT function.
--- src/amd/vulkan/radv_extensions.py | 1 + src/amd/vulkan/radv_wsi_display.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
src/amd/vulkan/radv_extensions.py +1 -0
@@ -82,6 +82,7 @@ EXTENSIONS = [ Extension('VK_KHR_xcb_surface', 6, 'VK_USE_PLATFORM_XCB_KHR'), Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), + Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_KHX_multiview', 1, '!ANDROID'), Extension('VK_EXT_debug_report', 9, True), Extension('VK_EXT_discard_rectangles', 1, True),
src/amd/vulkan/radv_wsi_display.c +11 -0
@@ -141,3 +141,14 @@ radv_CreateDisplayPlaneSurfaceKHR(VkInstance _instancreturn wsi_create_display_surface (_instance, alloc, create_info, surface); } + +VkResult +radv_ReleaseDisplayEXT (VkPhysicalDevice physical_device, +VkDisplayKHR display) +{ +RADV_FROM_HANDLE (radv_physical_device, pdevice, physical_device); + +return wsi_release_display (physical_device, + &pdevice->wsi_device, + display); +}
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/21 vulkan: Add EXT_acquire_xlib_display
In reply to Keith PackardThis extension adds the ability to borrow an X RandR output for temporary use directly by a Vulkan application. For DRM, we use the Linux resource leasing mechanism.
--- configure.ac | 32 +++ meson.build | 17 ++ meson_options.txt | 7 + src/vulkan/Makefile.am | 5 + src/vulkan/wsi/meson.build | 7 + src/vulkan/wsi/wsi_common_display.c | 472 ++++++++++++++++++++++++++++++++++++ src/vulkan/wsi/wsi_common_display.h | 17 ++ 7 files changed, 557 insertions(+)
configure.ac +32 -0
@@ -1547,6 +1547,7 @@ AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = x AM_CONDITIONAL(HAVE_LMSENSORS, test "x$enable_lmsensors" = xyes ) AM_CONDITIONAL(HAVE_GALLIUM_EXTRA_HUD, test "x$enable_gallium_extra_hud" = xyes ) AM_CONDITIONAL(HAVE_WINDOWSDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xwindows ) +AM_CONDITIONAL(HAVE_XLEASE, test "x$have_xlease" = xyes ) AC_ARG_ENABLE([shared-glapi], [AS_HELP_STRING([--enable-shared-glapi],
@@ -1846,6 +1847,18 @@ if test x"$enable_dri3" = xyes; then PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules]) fi + +if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 'drm'; then + have_xlease=yes +else + have_xlease=no +fi + +if test x"$have_xlease" = xyes; then + randr_modules="x11-xcb xcb-randr" + PKG_CHECK_MODULES([XCB_RANDR], [$randr_modules]) +fi + AM_CONDITIONAL(HAVE_PLATFORM_X11, echo "$platforms" | grep -q 'x11') AM_CONDITIONAL(HAVE_PLATFORM_WAYLAND, echo "$platforms" | grep -q 'wayland') AM_CONDITIONAL(HAVE_PLATFORM_DRM, echo "$platforms" | grep -q 'drm')
@@ -1853,6 +1866,25 @@ AM_CONDITIONAL(HAVE_PLATFORM_DISPLAY, echo "$platforms" | grep -q 'drm') AM_CONDITIONAL(HAVE_PLATFORM_SURFACELESS, echo "$platforms" | grep -q 'surfaceless') AM_CONDITIONAL(HAVE_PLATFORM_ANDROID, echo "$platforms" | grep -q 'android') +AC_ARG_ENABLE(xlib-lease, + [AS_HELP_STRING([--enable-xlib-lease] + [enable VK_acquire_xlib_display using X leases])], + [enable_xlib_lease=$enableval], [enable_xlib_lease=auto]) +case "x$enable_xlib_lease" in +xyes) + ;; +xno) + ;; +*) + if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 'drm'; then + enable_xlib_lease=yes + else + enable_xlib_lease=no + fi +esac + +AM_CONDITIONAL(HAVE_XLIB_LEASE, test "x$enable_xlib_lease" = xyes) + dnl dnl More DRI setup dnl
meson.build +17 -0
@@ -262,6 +262,19 @@ if _platforms != '' egl_native_platform = _split[0] endif +with_xlib_lease = get_option('xlib-lease') +if with_xlib_lease == 'auto' + if with_platform_x11 and with_platform_display + with_xlib_lease = true + else + with_xlib_lease = false + endif +elif with_xlib_lease == 'true' + with_xlib_lease = true +else + with_xlib_lease = false +endif + with_glx = get_option('glx') if with_glx == 'auto' if with_dri
@@ -1151,6 +1164,7 @@ dep_xcb_present = [] dep_xcb_sync = [] dep_xcb_xfixes = [] dep_xshmfence = [] +dep_xcb_xrandr = [] if with_platform_x11 if with_glx == 'xlib' or with_glx == 'gallium-xlib' dep_x11 = dependency('x11')
@@ -1190,6 +1204,9 @@ if with_platform_x11 if with_egl dep_xcb_xfixes = dependency('xcb-xfixes') endif + if with_xlib_lease + dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.12') + endif endif if get_option('gallium-extra-hud')
meson_options.txt +7 -0
@@ -286,3 +286,10 @@ option( value : '', description : 'Comma delimited list of tools to build. choices : freedreno,glsl,intel,nir,nouveau or all' ) +option( + 'xlib-lease', + type : 'combo', + value : 'auto', + choices : ['auto', 'true', 'false'], + description : 'Enable VK_EXT_acquire_xlib_display.' +)
src/vulkan/Makefile.am +5 -0
@@ -64,6 +64,11 @@ AM_CPPFLAGS += \ VULKAN_WSI_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) endif +if HAVE_XLIB_LEASE +AM_CPPFLAGS += \ + -DVK_USE_PLATFORM_XLIB_XRANDR_EXT +endif + BUILT_SOURCES += $(VULKAN_WSI_WAYLAND_GENERATED_FILES) CLEANFILES = $(BUILT_SOURCES)
src/vulkan/wsi/meson.build +7 -0
@@ -67,6 +67,13 @@ if with_platform_display ) endif +if with_xlib_lease + vulkan_wsi_deps += dep_xcb_xrandr + vulkan_wsi_args += [ + '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', + ] +endif + libvulkan_wsi = static_library( 'vulkan_wsi', files_vulkan_wsi,
src/vulkan/wsi/wsi_common_display.c +472 -0
489 lines not on this page · raw message
src/vulkan/wsi/wsi_common_display.h +17 -0
@@ -74,4 +74,21 @@ wsi_release_display(VkPhysicalDevice physical_device,struct wsi_device *wsi_device, VkDisplayKHR display); + +#if VK_USE_PLATFORM_XLIB_XRANDR_EXT +VkResult +wsi_acquire_xlib_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +Display *dpy, +VkDisplayKHR display); + +VkResult +wsi_get_randr_output_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +Display *dpy, +RROutput output, +VkDisplayKHR *display); + +#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */ +#endif
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 07/21] vulkan: Add EXT_acquire_xlib_display
Quoted 82 lines · Keith Packard
This extension adds the ability to borrow an X RandR output for temporary use directly by a Vulkan application. For DRM, we use the Linux resource leasing mechanism.
Signed-off-by Keith Packard <[email protected]>--- configure.ac | 32 +++ meson.build | 17 ++ meson_options.txt | 7 + src/vulkan/Makefile.am | 5 + src/vulkan/wsi/meson.build | 7 + src/vulkan/wsi/wsi_common_display.c | 472 ++++++++++++++++++++++++++++++++++++ src/vulkan/wsi/wsi_common_display.h | 17 ++ 7 files changed, 557 insertions(+)configure.ac +32
-0@@ -1547,6 +1547,7 @@ AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = x AM_CONDITIONAL(HAVE_LMSENSORS, test "x$enable_lmsensors" = xyes ) AM_CONDITIONAL(HAVE_GALLIUM_EXTRA_HUD, test "x$enable_gallium_extra_hud" = xyes ) AM_CONDITIONAL(HAVE_WINDOWSDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = xwindows ) +AM_CONDITIONAL(HAVE_XLEASE, test "x$have_xlease" = xyes ) AC_ARG_ENABLE([shared-glapi], [AS_HELP_STRING([--enable-shared-glapi],@@ -1846,6 +1847,18 @@ if test x"$enable_dri3" = xyes; then PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules]) fi + +if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 'drm'; then + have_xlease=yes +else + have_xlease=no +fi + +if test x"$have_xlease" = xyes; then + randr_modules="x11-xcb xcb-randr" + PKG_CHECK_MODULES([XCB_RANDR], [$randr_modules]) +fi + AM_CONDITIONAL(HAVE_PLATFORM_X11, echo "$platforms" | grep -q 'x11') AM_CONDITIONAL(HAVE_PLATFORM_WAYLAND, echo "$platforms" | grep -q 'wayland') AM_CONDITIONAL(HAVE_PLATFORM_DRM, echo "$platforms" | grep -q 'drm')@@ -1853,6 +1866,25 @@ AM_CONDITIONAL(HAVE_PLATFORM_DISPLAY, echo "$platforms" | grep -q 'drm') AM_CONDITIONAL(HAVE_PLATFORM_SURFACELESS, echo "$platforms" | grep -q 'surfaceless') AM_CONDITIONAL(HAVE_PLATFORM_ANDROID, echo "$platforms" | grep -q 'android') +AC_ARG_ENABLE(xlib-lease, + [AS_HELP_STRING([--enable-xlib-lease] + [enable VK_acquire_xlib_display using X leases])], + [enable_xlib_lease=$enableval], [enable_xlib_lease=auto]) +case "x$enable_xlib_lease" in +xyes) + ;; +xno) + ;; +*) + if echo "$platforms" | grep -q 'x11' && echo "$platforms" | grep -q 'drm'; then + enable_xlib_lease=yes + else + enable_xlib_lease=no + fi +esac + +AM_CONDITIONAL(HAVE_XLIB_LEASE, test "x$enable_xlib_lease" = xyes) + dnl dnl More DRI setup dnlmeson.build +2
-0@@ -262,6 +262,19 @@ if _platforms != '' egl_native_platform = _split[0] endif +with_xlib_lease = get_option('xlib-lease') +if with_xlib_lease == 'auto'
meson.build if _platforms != '' · line 276
Quoted 10 lines
meson.build +10
-0+ if with_platform_x11 and with_platform_display + with_xlib_lease = true + else + with_xlib_lease = false + endif +elif with_xlib_lease == 'true' + with_xlib_lease = true +else + with_xlib_lease = false +endif
Can be simplified a bit:
_xlib_lease = get_option('xlib-lease')
if _xlib_lease == 'auto'
with_xlib_lease = with_platform_x11 and with_platform_display
else
with_xlib_lease = _xlib_lease == 'true'
endif
(We also usually try to avoid changing the type of a var, and meson might start being more strict with types in future releases)
Quoted 58 lines
meson.build +5
-0+ with_glx = get_option('glx') if with_glx == 'auto' if with_dri@@ -1151,6 +1164,7 @@ dep_xcb_present = [] dep_xcb_sync = [] dep_xcb_xfixes = [] dep_xshmfence = [] +dep_xcb_xrandr = [] if with_platform_x11 if with_glx == 'xlib' or with_glx == 'gallium-xlib' dep_x11 = dependency('x11')@@ -1190,6 +1204,9 @@ if with_platform_x11 if with_egl dep_xcb_xfixes = dependency('xcb-xfixes') endif + if with_xlib_lease + dep_xcb_xrandr = dependency('xcb-randr', version : '>= 1.12') + endif endif if get_option('gallium-extra-hud')meson_options.txt +7
-0@@ -286,3 +286,10 @@ option( value : '', description : 'Comma delimited list of tools to build. choices : freedreno,glsl,intel,nir,nouveau or all' ) +option( + 'xlib-lease', + type : 'combo', + value : 'auto', + choices : ['auto', 'true', 'false'], + description : 'Enable VK_EXT_acquire_xlib_display.' +)src/vulkan/Makefile.am +5
-0@@ -64,6 +64,11 @@ AM_CPPFLAGS += \ VULKAN_WSI_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) endif +if HAVE_XLIB_LEASE +AM_CPPFLAGS += \ + -DVK_USE_PLATFORM_XLIB_XRANDR_EXT +endif + BUILT_SOURCES += $(VULKAN_WSI_WAYLAND_GENERATED_FILES) CLEANFILES = $(BUILT_SOURCES)src/vulkan/wsi/meson.build +0
-0
src/vulkan/wsi/meson.build if with_platform_display · line 74
Quoted 8 lines
src/vulkan/wsi/meson.build +5
-0@@ -67,6 +67,13 @@ if with_platform_display ) endif +if with_xlib_lease + vulkan_wsi_deps += dep_xcb_xrandr + vulkan_wsi_args += [ + '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', + ]
vulkan_wsi_args += '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
with that, the meson part of this is
Quoted 530 lines
src/vulkan/wsi/meson.build +2
-0+endif + libvulkan_wsi = static_library( 'vulkan_wsi', files_vulkan_wsi,src/vulkan/wsi/wsi_common_display.c +472
-0@@ -32,6 +32,10 @@#include <math.h> #include <xf86drm.h> #include <xf86drmMode.h> +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +#include <xcb/randr.h> +#include <X11/Xlib-xcb.h> +#endif #include "util/hash_table.h" #include "util/list.h" @@ -73,6 +77,9 @@ typedef struct wsi_display_connector {bool active;wsi_display_mode *current_mode;drmModeModeInfo current_drm_mode; +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +xcb_randr_output_t output; +#endif } wsi_display_connector;struct wsi_display {@@ -1381,5 +1388,470 @@ wsi_release_display(VkPhysicalDevice physical_device,close (wsi->master_fd); wsi->master_fd =-1 ; } +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +wsi_display_connector_from_handle (display)->output = None; +#endif +return VK_SUCCESS ; } + +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT + +static struct wsi_display_connector * +wsi_display_find_output (struct wsi_device *wsi_device, +RROutput output) +{ +struct wsi_display *wsi = (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY ]; +struct wsi_display_connector *connector; + + connector =NULL ; + LIST_FOR_EACH_ENTRY(connector, &wsi->connectors, list) { +if (connector->output == output) +return connector; + } + +return NULL ; +} + +/* +* Given a RandR output, find the associated kernel connector_id by +* looking at the CONNECTOR_ID property provided by the X server +*/ + +static uint32_t +wsi_display_output_to_connector_id (xcb_connection_t *connection, +xcb_atom_t *connector_id_atom_p, +RROutput output) +{ +uint32_t connector_id =0 ; +xcb_atom_t connector_id_atom = *connector_id_atom_p; + +if (connector_id_atom ==0 ) { +/* Go dig out the CONNECTOR_ID property */ +xcb_intern_atom_cookie_t ia_c =xcb_intern_atom (connection, + true, +12 , +"CONNECTOR_ID" ); +xcb_intern_atom_reply_t *ia_r =xcb_intern_atom_reply (connection, + ia_c, +NULL ); +if (ia_r) { + *connector_id_atom_p = connector_id_atom = ia_r->atom; +free (ia_r); + } + } + +/* If there's an CONNECTOR_ID atom in the server, then there may be a CONNECTOR_ID property. Otherwise, +* there will not be and we don't even need to bother. +*/ +if (connector_id_atom) { + +xcb_randr_query_version_cookie_t qv_c =xcb_randr_query_version (connection,1 ,6 ); +xcb_randr_get_output_property_cookie_t gop_c =xcb_randr_get_output_property (connection, + output, + connector_id_atom, +0 , +0 , +0xffffffffUL , +0 , +0 ); +xcb_randr_query_version_reply_t *qv_r =xcb_randr_query_version_reply (connection, qv_c,NULL ); +free (qv_r); +xcb_randr_get_output_property_reply_t *gop_r =xcb_randr_get_output_property_reply (connection, + gop_c, +NULL ); +if (gop_r) { +if (gop_r->num_items ==1 && gop_r->format ==32 ) +memcpy (&connector_id,xcb_randr_get_output_property_data (gop_r),4 ); +free (gop_r); + } + } +return connector_id; +} + +static bool +wsi_display_check_randr_version (xcb_connection_t *connection) +{ +xcb_randr_query_version_cookie_t qv_c =xcb_randr_query_version (connection,1 ,6 ); +xcb_randr_query_version_reply_t *qv_r =xcb_randr_query_version_reply (connection, qv_c,NULL ); +bool ret = false; + +if (!qv_r) +return false; + +/* Check for version 1.6 or newer */ + ret = qv_r->major_version >1 || (qv_r->major_version ==1 && qv_r->minor_version >=6 ); + +free (qv_r); +return ret; +} + +/* +* Given a kernel connector id, find the associated RandR output using the +* CONNECTOR_ID property +*/ + +static xcb_randr_output_t +wsi_display_connector_id_to_output (xcb_connection_t *connection, +uint32_t connector_id) +{ +if (!wsi_display_check_randr_version (connection)) +return 0 ; + +const xcb_setup_t *setup =xcb_get_setup (connection); + +xcb_atom_t connector_id_atom =0 ; +xcb_randr_output_t output =0 ; + +/* Search all of the screens for the provided output */ +xcb_screen_iterator_t iter; +for (iter =xcb_setup_roots_iterator (setup); output ==0 && iter.rem;xcb_screen_next (&iter)) { + +xcb_randr_get_screen_resources_cookie_t gsr_c =xcb_randr_get_screen_resources (connection, iter.data->root); +xcb_randr_get_screen_resources_reply_t *gsr_r =xcb_randr_get_screen_resources_reply (connection, gsr_c,NULL ); + +if (!gsr_r) +return 0 ; + +xcb_randr_output_t *ro =xcb_randr_get_screen_resources_outputs (gsr_r); +int o; + +for (o =0 ; o < gsr_r->num_outputs; o++) { +if (wsi_display_output_to_connector_id (connection, &connector_id_atom, ro[o]) == connector_id) { + output = ro[o]; +break ; + } + } +free (gsr_r); + } +return output; +} + +/* +* Given a RandR output, find out which screen it's associated with +*/ +static xcb_window_t +wsi_display_output_to_root (xcb_connection_t *connection, +xcb_randr_output_t output) +{ +if (!wsi_display_check_randr_version (connection)) +return 0 ; + +const xcb_setup_t *setup =xcb_get_setup (connection); +xcb_window_t root =0 ; + +/* Search all of the screens for the provided output */ +xcb_screen_iterator_t iter; +for (iter =xcb_setup_roots_iterator (setup); root ==0 && iter.rem;xcb_screen_next (&iter)) { +xcb_randr_get_screen_resources_cookie_t gsr_c =xcb_randr_get_screen_resources (connection, iter.data->root); +xcb_randr_get_screen_resources_reply_t *gsr_r =xcb_randr_get_screen_resources_reply (connection, gsr_c,NULL ); + +if (!gsr_r) +return 0 ; + +xcb_randr_output_t *ro =xcb_randr_get_screen_resources_outputs (gsr_r); +int o; + +for (o =0 ; o < gsr_r->num_outputs; o++) { +if (ro[o] == output) { + root = iter.data->root; +break ; + } + } +free (gsr_r); + } +return root; +} + +static bool +wsi_display_mode_matches_x (struct wsi_display_mode *wsi, +xcb_randr_mode_info_t *xcb) +{ +return wsi->clock == (xcb->dot_clock +500 ) /1000 && + wsi->hdisplay == xcb->width && + wsi->hsync_start == xcb->hsync_start && + wsi->hsync_end == xcb->hsync_end && + wsi->htotal == xcb->htotal && + wsi->hskew == xcb->hskew && + wsi->vdisplay == xcb->height && + wsi->vsync_start == xcb->vsync_start && + wsi->vsync_end == xcb->vsync_end && + wsi->vtotal == xcb->vtotal && + wsi->flags == xcb->mode_flags; +} + +static struct wsi_display_mode * +wsi_display_find_x_mode (struct wsi_device *wsi_device, +struct wsi_display_connector *connector, +xcb_randr_mode_info_t *mode) +{ +struct wsi_display *wsi = (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY ]; +struct wsi_display_mode *display_mode; + + LIST_FOR_EACH_ENTRY(display_mode, &wsi->display_modes, list) { +if (display_mode->connector == connector && +wsi_display_mode_matches_x (display_mode, mode)) +return display_mode; + } +return NULL ; +} + +static VkResult +wsi_display_register_x_mode (struct wsi_device *wsi_device, +struct wsi_display_connector *connector, +xcb_randr_mode_info_t *x_mode, +bool preferred) +{ +struct wsi_display *wsi = (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY ]; +struct wsi_display_mode *display_mode; + + display_mode =wsi_display_find_x_mode (wsi_device, connector, x_mode); + +if (display_mode) { + display_mode->valid = true; +return VK_SUCCESS ; + } + + display_mode =vk_alloc (wsi->alloc,sizeof (struct wsi_display_mode ),8 ,VK_SYSTEM_ALLOCATION_SCOPE_OBJECT ); +if (!display_mode) +return VK_ERROR_OUT_OF_HOST_MEMORY ; + + display_mode->connector = connector; + display_mode->valid = true; + display_mode->preferred = preferred; + display_mode->clock = (x_mode->dot_clock +500 ) /1000 ;/* kHz */ + display_mode->hdisplay = x_mode->width; + display_mode->hsync_start = x_mode->hsync_start; + display_mode->hsync_end = x_mode->hsync_end; + display_mode->htotal = x_mode->htotal; + display_mode->hskew = x_mode->hskew; + display_mode->vdisplay = x_mode->height; + display_mode->vsync_start = x_mode->vsync_start; + display_mode->vsync_end = x_mode->vsync_end; + display_mode->vtotal = x_mode->vtotal; + display_mode->vscan =0 ; +if (x_mode->mode_flags &XCB_RANDR_MODE_FLAG_DOUBLE_SCAN ) + display_mode->vscan =1 ; + display_mode->flags = x_mode->mode_flags; + +LIST_ADDTAIL (&display_mode->list, &wsi->display_modes); +return VK_SUCCESS ; +} + +static struct wsi_display_connector * +wsi_display_get_output (struct wsi_device *wsi_device, +xcb_connection_t *connection, +RROutput output) +{ +struct wsi_display *wsi = (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY ]; +struct wsi_display_connector *connector; +uint32_t connector_id; +xcb_window_t root; +xcb_randr_get_screen_resources_cookie_t src; +xcb_randr_get_screen_resources_reply_t *srr; +xcb_randr_get_output_info_cookie_t oic; +xcb_randr_get_output_info_reply_t *oir; +xcb_randr_mode_t *x_modes; +int m; + + root =wsi_display_output_to_root (connection, output); +if (!root) +return NULL ; + + src =xcb_randr_get_screen_resources (connection, root); + oic =xcb_randr_get_output_info (connection, output,XCB_CURRENT_TIME ); + srr =xcb_randr_get_screen_resources_reply (connection, src,NULL ); + oir =xcb_randr_get_output_info_reply (connection, oic,NULL ); + +/* See if we already have a connector for this output */ + connector =wsi_display_find_output (wsi_device, output); + +if (!connector) { +xcb_atom_t connector_id_atom =0 ; + +/* +* Go get the kernel connector ID for this X output +*/ + connector_id =wsi_display_output_to_connector_id (connection, &connector_id_atom, output); + +/* Any X server with lease support will have this atom */ +if (!connector_id) { +free (oir); +free (srr); +return NULL ; + } + +if (!connector) { +/* See if we already have a connector for this id */ + connector =wsi_display_find_connector (wsi_device, connector_id); + +if (connector) + connector->output = output; + } + } + +if (!connector) { + connector =wsi_display_alloc_connector (wsi, connector_id); +if (!connector) { +free (oir); +free (srr); +return NULL ; + } +LIST_ADDTAIL (&connector->list, &wsi->connectors); + connector->output = output; + } + +if (oir && srr) { +/* Get X modes and add them */ + + connector->connected = oir->connection !=XCB_RANDR_CONNECTION_DISCONNECTED ; + +wsi_display_invalidate_connector_modes (wsi_device, connector); + + x_modes =xcb_randr_get_output_info_modes (oir); +for (m =0 ; m < oir->num_modes; m++) { +xcb_randr_mode_info_iterator_t i =xcb_randr_get_screen_resources_modes_iterator (srr); +while (i.rem) { +xcb_randr_mode_info_t *mi = i.data; +if (mi->id == x_modes[m]) { +VkResult result =wsi_display_register_x_mode (wsi_device, connector, mi, m < oir->num_preferred); +if (result !=VK_SUCCESS ) { +free (oir); +free (srr); +return NULL ; + } +break ; + } +xcb_randr_mode_info_next (&i); + } + } + } + +free (oir); +free (srr); +return connector; +} + +static xcb_randr_crtc_t +wsi_display_find_crtc_for_output (xcb_connection_t *connection, +xcb_window_t root, +xcb_randr_output_t output) +{ +xcb_randr_get_screen_resources_cookie_t gsr_c =xcb_randr_get_screen_resources (connection, root); +xcb_randr_get_screen_resources_reply_t *gsr_r =xcb_randr_get_screen_resources_reply (connection, gsr_c,NULL ); + +if (!gsr_r) +return 0 ; + +xcb_randr_crtc_t *rc =xcb_randr_get_screen_resources_crtcs (gsr_r); +xcb_randr_crtc_t idle_crtc =0 ; +xcb_randr_crtc_t active_crtc =0 ; + +/* Find either a crtc already connected to the desired output or idle */ +int c; +for (c =0 ; active_crtc ==0 && c < gsr_r->num_crtcs; c++) { +xcb_randr_get_crtc_info_cookie_t gci_c =xcb_randr_get_crtc_info (connection, rc[c], gsr_r->config_timestamp); +xcb_randr_get_crtc_info_reply_t *gci_r =xcb_randr_get_crtc_info_reply (connection, gci_c,NULL ); +if (gci_r) { +if (gci_r->mode) { +int num_outputs =xcb_randr_get_crtc_info_outputs_length (gci_r); +xcb_randr_output_t *outputs =xcb_randr_get_crtc_info_outputs (gci_r); +for (int o =0 ; o < num_outputs; o++) +if (outputs[o] == output && num_outputs ==1 ) { + active_crtc = rc[c]; +break ; + } + }else if (idle_crtc ==0 ) { +int num_possible =xcb_randr_get_crtc_info_possible_length (gci_r); +xcb_randr_output_t *possible =xcb_randr_get_crtc_info_possible (gci_r); +for (int p =0 ; p < num_possible; p++) +if (possible[p] == output) { + idle_crtc = rc[c]; +break ; + } + } +free (gci_r); + } + } +free (gsr_r); + +if (active_crtc) +return active_crtc; +return idle_crtc; +} + +VkResult +wsi_acquire_xlib_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +Display *dpy, +VkDisplayKHR display) +{ +struct wsi_display *wsi = (struct wsi_display *) wsi_device->wsi[VK_ICD_WSI_PLATFORM_DISPLAY ]; +xcb_connection_t *connection =XGetXCBConnection (dpy); +struct wsi_display_connector *connector =wsi_display_connector_from_handle (display); +xcb_window_t root; + +if (!connector->output) { + connector->output =wsi_display_connector_id_to_output (connection, connector->id); + +/* Check and see if we found the output */ +if (!connector->output) +return VK_ERROR_OUT_OF_DATE_KHR ; + } + + root =wsi_display_output_to_root (connection, connector->output); +if (!root) +return VK_ERROR_OUT_OF_DATE_KHR ; + +xcb_randr_crtc_t crtc =wsi_display_find_crtc_for_output (connection, + root, + connector->output); + +if (!crtc) +return VK_ERROR_OUT_OF_DATE_KHR ; + +xcb_randr_lease_t lease =xcb_generate_id (connection); +xcb_randr_create_lease_cookie_t cl_c =xcb_randr_create_lease (connection, + root, + lease, +1 , +1 , + &crtc, + &connector->output); +xcb_randr_create_lease_reply_t *cl_r =xcb_randr_create_lease_reply (connection, cl_c,NULL ); +if (!cl_r) +return VK_ERROR_OUT_OF_DATE_KHR ; + +int fd =-1 ; +if (cl_r->nfd >0 ) { +int *rcl_f =xcb_randr_create_lease_reply_fds (connection, cl_r); + + fd = rcl_f[0 ]; + } +free (cl_r); +if (fd <0 ) +return VK_ERROR_OUT_OF_DATE_KHR ; + + wsi->master_fd = fd; + +return VK_SUCCESS ; +} + +VkResult +wsi_get_randr_output_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +Display *dpy, +RROutput output, +VkDisplayKHR *display) +{ +xcb_connection_t *connection =XGetXCBConnection (dpy); +struct wsi_display_connector *connector =wsi_display_get_output (wsi_device, connection, output); + +if (connector) + *display =wsi_display_connector_to_handle (connector); +else + *display =NULL ; +return VK_SUCCESS ; +} + +#endif src/vulkan/wsi/wsi_common_display.h +17
-0@@ -74,4 +74,21 @@ wsi_release_display(VkPhysicalDevice physical_device,struct wsi_device *wsi_device, VkDisplayKHR display); + +#if VK_USE_PLATFORM_XLIB_XRANDR_EXT +VkResult +wsi_acquire_xlib_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +Display *dpy, +VkDisplayKHR display); + +VkResult +wsi_get_randr_output_display (VkPhysicalDevice physical_device, +struct wsi_device *wsi_device, +Display *dpy, +RROutput output, +VkDisplayKHR *display); + +#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */ +#endif Signature · 1 line
2.15.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 07/21] vulkan: Add EXT_acquire_xlib_display
Quoted 11 lines · Eric Engestrom
Can be simplified a bit:
_xlib_lease=get_option('xlib-lease')
if_xlib_lease== 'auto'
with_xlib_lease=with_platform_x11andwith_platform_display
elsewith_xlib_lease = _xlib_lease == 'true'endif
(We also usually try to avoid changing the type of a var, and meson might start being more strict with types in future releases)
I wondered about that in the places I copied my code from. Good to know there's a better practice. I've switched to using this form.
Quoted 7 lines
src/vulkan/wsi/meson.build if with_platform_display · line 74
Quoted 5 lines
src/vulkan/wsi/meson.build +5
-0+if with_xlib_lease + vulkan_wsi_deps += dep_xcb_xrandr + vulkan_wsi_args += [ + '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', + ]
vulkan_wsi_args+= '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT'
I switched all of the inappropriate usage to this form for six separate patches (three each for core/anv/radv by two extensions (DISPLAY and XLIB_XRANDR).
Quoted 2 lines
with that, the meson part of this is
Reviewed-by Eric Engestrom <[email protected]>
Awesome!
Thanks for reviewing the build system bits; I'm just starting to use meson and every new change is a learning opportunity at this point.
Signature · 1 line
-keith
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 8/21 anv: Add EXT_acquire_xlib_display to anv driver
In reply to Keith PackardThis extension adds the ability to borrow an X RandR output for temporary use directly by a Vulkan application to the anv driver.
--- src/intel/Makefile.vulkan.am | 7 +++++++ src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_extensions_gen.py | 10 +++++----- src/intel/vulkan/anv_wsi_display.c | 30 ++++++++++++++++++++++++++++++ src/intel/vulkan/meson.build | 7 +++++++ 5 files changed, 50 insertions(+), 5 deletions(-)
src/intel/Makefile.vulkan.am +7 -0
@@ -194,6 +194,13 @@ VULKAN_CPPFLAGS += \ VULKAN_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) endif +if HAVE_XLIB_LEASE +VULKAN_CPPFLAGS += \ + -DVK_USE_PLATFORM_XLIB_XRANDR_EXT \ + $(XCB_RANDR_CFLAGS) +VULKAN_LIB_DEPS += $(XCB_RANDR_LIBS) +endif + noinst_LTLIBRARIES += vulkan/libvulkan_common.la vulkan_libvulkan_common_la_SOURCES = $(VULKAN_SOURCES) vulkan_libvulkan_common_la_CFLAGS = $(VULKAN_CFLAGS)
src/intel/vulkan/anv_extensions.py +1 -0
@@ -85,6 +85,7 @@ EXTENSIONS = [ Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), + Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'), Extension('VK_KHX_multiview', 1, True), Extension('VK_EXT_debug_report', 8, True), Extension('VK_EXT_external_memory_dma_buf', 1, True),
src/intel/vulkan/anv_extensions_gen.py +5 -5
@@ -113,12 +113,12 @@ _TEMPLATE_C = Template(COPYRIGHT + """ #include "vk_util.h" /* Convert the VK_USE_PLATFORM_* defines to booleans */ -%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB', 'DISPLAY']: -#ifdef VK_USE_PLATFORM_${platform}_KHR -# undef VK_USE_PLATFORM_${platform}_KHR -# define VK_USE_PLATFORM_${platform}_KHR true +%for platform in ['ANDROID_KHR', 'WAYLAND_KHR', 'XCB_KHR', 'XLIB_KHR', 'DISPLAY_KHR', 'XLIB_XRANDR_EXT']: +#ifdef VK_USE_PLATFORM_${platform} +# undef VK_USE_PLATFORM_${platform} +# define VK_USE_PLATFORM_${platform} true #else -# define VK_USE_PLATFORM_${platform}_KHR false +# define VK_USE_PLATFORM_${platform} false #endif %endfor
src/intel/vulkan/anv_wsi_display.c +30 -0
@@ -138,3 +138,33 @@ anv_ReleaseDisplayEXT(VkPhysicalDevice physical_device, &pdevice->wsi_device, display); } + +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +VkResult +anv_AcquireXlibDisplayEXT (VkPhysicalDevice physical_device, +Display *dpy, +VkDisplayKHR display) +{ +ANV_FROM_HANDLE (anv_physical_device, pdevice, physical_device); + +return wsi_acquire_xlib_display (physical_device, + &pdevice->wsi_device, + dpy, + display); +} + +VkResult +anv_GetRandROutputDisplayEXT (VkPhysicalDevice physical_device, +Display *dpy, +RROutput output, +VkDisplayKHR *display) +{ +ANV_FROM_HANDLE (anv_physical_device, pdevice, physical_device); + +return wsi_get_randr_output_display (physical_device, + &pdevice->wsi_device, + dpy, + output, + display); +} +#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
src/intel/vulkan/meson.build +7 -0
@@ -178,6 +178,13 @@ if with_platform_display libanv_files += files('anv_wsi_display.c') endif +if with_xlib_lease + anv_deps += dep_xcb_xrandr + anv_flags += [ + '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', + ] +endif + libanv_common = static_library( 'anv_common', [libanv_files, anv_entrypoints, anv_extensions_c, anv_extensions_h],
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 9/21 radv: Add EXT_acquire_xlib_display to radv driver
In reply to Keith PackardThis extension adds the ability to borrow an X RandR output for temporary use directly by a Vulkan application to the radv driver.
--- src/amd/vulkan/Makefile.am | 7 +++++++ src/amd/vulkan/meson.build | 7 +++++++ src/amd/vulkan/radv_extensions.py | 11 ++++++----- src/amd/vulkan/radv_wsi_display.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-)
src/amd/vulkan/Makefile.am +7 -0
@@ -81,7 +81,14 @@ AM_CPPFLAGS += \ -DVK_USE_PLATFORM_DISPLAY_KHR VULKAN_SOURCES += $(VULKAN_WSI_DISPLAY_FILES) +endif + +if HAVE_XLIB_LEASE +AM_CPPFLAGS += \ + -DVK_USE_PLATFORM_XLIB_XRANDR_EXT \ + $(XCB_RANDR_CFLAGS) +VULKAN_LIB_DEPS += $(XCB_RANDR_LIBS) endif if HAVE_PLATFORM_X11
src/amd/vulkan/meson.build +7 -0
@@ -119,6 +119,13 @@ if with_platform_display libradv_files += files('radv_wsi_display.c') endif +if with_xlib_lease + radv_deps += dep_xcb_xrandr + radv_flags += [ + '-DVK_USE_PLATFORM_XLIB_XRANDR_EXT', + ] +endif + libvulkan_radeon = shared_library( 'vulkan_radeon', [libradv_files, radv_entrypoints, radv_extensions_c, vk_format_table_c],
src/amd/vulkan/radv_extensions.py +6 -5
@@ -83,6 +83,7 @@ EXTENSIONS = [ Extension('VK_KHR_xlib_surface', 6, 'VK_USE_PLATFORM_XLIB_KHR'), Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), + Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'), Extension('VK_KHX_multiview', 1, '!ANDROID'), Extension('VK_EXT_debug_report', 9, True), Extension('VK_EXT_discard_rectangles', 1, True),
@@ -170,12 +171,12 @@ _TEMPLATE = Template(COPYRIGHT + """ #include "vk_util.h" /* Convert the VK_USE_PLATFORM_* defines to booleans */ -%for platform in ['ANDROID', 'WAYLAND', 'XCB', 'XLIB', 'DISPLAY']: -#ifdef VK_USE_PLATFORM_${platform}_KHR -# undef VK_USE_PLATFORM_${platform}_KHR -# define VK_USE_PLATFORM_${platform}_KHR true +%for platform in ['ANDROID_KHR', 'WAYLAND_KHR', 'XCB_KHR', 'XLIB_KHR', 'DISPLAY_KHR', 'XLIB_XRANDR_EXT']: +#ifdef VK_USE_PLATFORM_${platform} +# undef VK_USE_PLATFORM_${platform} +# define VK_USE_PLATFORM_${platform} true #else -# define VK_USE_PLATFORM_${platform}_KHR false +# define VK_USE_PLATFORM_${platform} false #endif %endfor
src/amd/vulkan/radv_wsi_display.c +30 -0
@@ -152,3 +152,33 @@ radv_ReleaseDisplayEXT(VkPhysicalDevice physical_device, &pdevice->wsi_device, display); } + +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +VkResult +radv_AcquireXlibDisplayEXT (VkPhysicalDevice physical_device, +Display *dpy, +VkDisplayKHR display) +{ +RADV_FROM_HANDLE (radv_physical_device, pdevice, physical_device); + +return wsi_acquire_xlib_display (physical_device, + &pdevice->wsi_device, + dpy, + display); +} + +VkResult +radv_GetRandROutputDisplayEXT (VkPhysicalDevice physical_device, +Display *dpy, +RROutput output, +VkDisplayKHR *display) +{ +RADV_FROM_HANDLE (radv_physical_device, pdevice, physical_device); + +return wsi_get_randr_output_display (physical_device, + &pdevice->wsi_device, + dpy, + output, + display); +} +#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/21 vulkan: Add VK_EXT_display_surface_counter [v3]
In reply to Keith PackardThis extension is required to support EXT_display_control as it offers a way to query whether the vblank counter is supported.
v2: Thanks to kisak
Fix spelling of VkSurfaceCapabilities2EXT in wsi_common_wayland.c, it was using ext instead of EXT.
Fix spelling of VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT
v3: Fix wayland WSI, regularize spelling
Misspelled 'surface' in get_capabilities2ext
Remove extra _ from get_capabilities_2ext in a couple of places
--- src/vulkan/wsi/wsi_common.c | 11 +++++++++++ src/vulkan/wsi/wsi_common.h | 5 +++++ src/vulkan/wsi/wsi_common_display.c | 27 +++++++++++++++++++++++++++ src/vulkan/wsi/wsi_common_private.h | 2 ++ src/vulkan/wsi/wsi_common_wayland.c | 27 +++++++++++++++++++++++++++ src/vulkan/wsi/wsi_common_x11.c | 27 +++++++++++++++++++++++++++ 6 files changed, 99 insertions(+)
src/vulkan/wsi/wsi_common.c +11 -0
@@ -579,6 +579,17 @@ wsi_common_get_surface_capabilities2(struct wsi_device *wsi_device, pSurfaceCapabilities); } +VkResult +wsi_common_get_surface_capabilities2ext (struct wsi_device *wsi_device, +VkSurfaceKHR _surface, +VkSurfaceCapabilities2EXT *pSurfaceCapabilities) +{ +ICD_FROM_HANDLE (VkIcdSurfaceBase, surface, _surface); +struct wsi_interface *iface = wsi_device->wsi[surface->platform]; + +return iface->get_capabilities2ext (surface, pSurfaceCapabilities); +} + VkResult wsi_common_get_surface_formats(struct wsi_device *wsi_device, VkSurfaceKHR _surface,
src/vulkan/wsi/wsi_common.h +5 -0
@@ -155,6 +155,11 @@ wsi_common_get_surface_present_modes(struct wsi_device *wsi_device,uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes); +VkResult +wsi_common_get_surface_capabilities2ext (struct wsi_device *wsi_device, +VkSurfaceKHR surface, +VkSurfaceCapabilities2EXT *pSurfaceCapabilities); + VkResult wsi_common_get_images(VkSwapchainKHR _swapchain, uint32_t *pSwapchainImageCount,
src/vulkan/wsi/wsi_common_display.c +27 -0
@@ -655,6 +655,32 @@ wsi_display_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,return wsi_display_surface_get_capabilities (icd_surface, &caps->surfaceCapabilities); } +static VkResult +wsi_display_surface_get_capabilities2ext (VkIcdSurfaceBase *icd_surface, +VkSurfaceCapabilities2EXT *caps) +{ +VkSurfaceCapabilitiesKHR khr_caps; +VkResult ret; + +assert (caps->sType ==VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT ); + ret =wsi_display_surface_get_capabilities (icd_surface, &khr_caps); +if (ret) +return ret; + + caps->minImageCount = khr_caps.minImageCount; + caps->maxImageCount = khr_caps.maxImageCount; + caps->currentExtent = khr_caps.currentExtent; + caps->minImageExtent = khr_caps.minImageExtent; + caps->maxImageExtent = khr_caps.maxImageExtent; + caps->maxImageArrayLayers = khr_caps.maxImageArrayLayers; + caps->supportedTransforms = khr_caps.supportedTransforms; + caps->currentTransform = khr_caps.currentTransform; + caps->supportedCompositeAlpha = khr_caps.supportedCompositeAlpha; + caps->supportedUsageFlags = khr_caps.supportedUsageFlags; + caps->supportedSurfaceCounters =0 ; +return ret; +} +static const VkFormat available_surface_formats[] = {VK_FORMAT_B8G8R8A8_SRGB ,VK_FORMAT_B8G8R8A8_UNORM ,
@@ -1323,6 +1349,7 @@ wsi_display_init_wsi(struct wsi_device *wsi_device, wsi->base.get_support = wsi_display_surface_get_support; wsi->base.get_capabilities = wsi_display_surface_get_capabilities; wsi->base.get_capabilities2 = wsi_display_surface_get_capabilities2; + wsi->base.get_capabilities2ext = wsi_display_surface_get_capabilities2ext; wsi->base.get_formats = wsi_display_surface_get_formats; wsi->base.get_formats2 = wsi_display_surface_get_formats2; wsi->base.get_present_modes = wsi_display_surface_get_present_modes;
src/vulkan/wsi/wsi_common_private.h +2 -0
@@ -103,6 +103,8 @@ struct wsi_interface {VkResult (*get_capabilities2)(VkIcdSurfaceBase *surface,const void *info_next,VkSurfaceCapabilities2KHR * pSurfaceCapabilities); +VkResult (*get_capabilities2ext)(VkIcdSurfaceBase *surface, + VkSurfaceCapabilities2EXT* pSurfaceCapabilities); VkResult (*get_formats)(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device, uint32_t* pSurfaceFormatCount,
src/vulkan/wsi/wsi_common_wayland.c +27 -0
@@ -457,6 +457,32 @@ wsi_wl_surface_get_capabilities2(VkIcdSurfaceBase *surface,return wsi_wl_surface_get_capabilities (surface, &caps->surfaceCapabilities); } +static VkResult +wsi_wl_surface_get_capabilities2ext (VkIcdSurfaceBase *surface, +VkSurfaceCapabilities2EXT * caps) +{ +VkSurfaceCapabilitiesKHR khr_caps; +VkResult ret; + +assert (caps->sType ==VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT ); + ret =wsi_wl_surface_get_capabilities (surface, &khr_caps); +if (ret) +return ret; + + caps->minImageCount = khr_caps.minImageCount; + caps->maxImageCount = khr_caps.maxImageCount; + caps->currentExtent = khr_caps.currentExtent; + caps->minImageExtent = khr_caps.minImageExtent; + caps->maxImageExtent = khr_caps.maxImageExtent; + caps->maxImageArrayLayers = khr_caps.maxImageArrayLayers; + caps->supportedTransforms = khr_caps.supportedTransforms; + caps->currentTransform = khr_caps.currentTransform; + caps->supportedCompositeAlpha = khr_caps.supportedCompositeAlpha; + caps->supportedUsageFlags = khr_caps.supportedUsageFlags; + caps->supportedSurfaceCounters =0 ; +return ret; +} + static VkResult wsi_wl_surface_get_formats(VkIcdSurfaceBase *icd_surface, struct wsi_device *wsi_device,
@@ -891,6 +917,7 @@ wsi_wl_init_wsi(struct wsi_device *wsi_device, wsi->base.get_support = wsi_wl_surface_get_support; wsi->base.get_capabilities = wsi_wl_surface_get_capabilities; wsi->base.get_capabilities2 = wsi_wl_surface_get_capabilities2; + wsi->base.get_capabilities2ext = wsi_wl_surface_get_capabilities2ext; wsi->base.get_formats = wsi_wl_surface_get_formats; wsi->base.get_formats2 = wsi_wl_surface_get_formats2; wsi->base.get_present_modes = wsi_wl_surface_get_present_modes;
src/vulkan/wsi/wsi_common_x11.c +27 -0
@@ -516,6 +516,32 @@ x11_surface_get_capabilities2(VkIcdSurfaceBase *icd_surface,return x11_surface_get_capabilities (icd_surface, &caps->surfaceCapabilities); } +static VkResult +x11_surface_get_capabilities2ext (VkIcdSurfaceBase *icd_surface, +VkSurfaceCapabilities2EXT *caps) +{ +VkSurfaceCapabilitiesKHR khr_caps; +VkResult ret; + +assert (caps->sType ==VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT ); + ret =x11_surface_get_capabilities (icd_surface, &khr_caps); +if (ret) +return ret; + + caps->minImageCount = khr_caps.minImageCount; + caps->maxImageCount = khr_caps.maxImageCount; + caps->currentExtent = khr_caps.currentExtent; + caps->minImageExtent = khr_caps.minImageExtent; + caps->maxImageExtent = khr_caps.maxImageExtent; + caps->maxImageArrayLayers = khr_caps.maxImageArrayLayers; + caps->supportedTransforms = khr_caps.supportedTransforms; + caps->currentTransform = khr_caps.currentTransform; + caps->supportedCompositeAlpha = khr_caps.supportedCompositeAlpha; + caps->supportedUsageFlags = khr_caps.supportedUsageFlags; + caps->supportedSurfaceCounters =0 ; +return ret; +} + static VkResult x11_surface_get_formats(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device,
@@ -1207,6 +1233,7 @@ wsi_x11_init_wsi(struct wsi_device *wsi_device, wsi->base.get_support = x11_surface_get_support; wsi->base.get_capabilities = x11_surface_get_capabilities; wsi->base.get_capabilities2 = x11_surface_get_capabilities2; + wsi->base.get_capabilities2ext = x11_surface_get_capabilities2ext; wsi->base.get_formats = x11_surface_get_formats; wsi->base.get_formats2 = x11_surface_get_formats2; wsi->base.get_present_modes = x11_surface_get_present_modes;
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 11/21 anv: Add VK_EXT_display_surface_counter to anv driver [v4]
In reply to Keith PackardThis extension is required to support EXT_display_control as it offers a way to query whether the vblank counter is supported.
v4: Add anv support
--- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_wsi.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
src/intel/vulkan/anv_extensions.py +1 -0
@@ -89,6 +89,7 @@ EXTENSIONS = [ Extension('VK_KHX_multiview', 1, True), Extension('VK_EXT_debug_report', 8, True), Extension('VK_EXT_external_memory_dma_buf', 1, True), + Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), ] class VkVersion:
src/intel/vulkan/anv_wsi.c +12 -0
@@ -104,6 +104,18 @@ VkResult anv_GetPhysicalDeviceSurfaceCapabilities2KHR( pSurfaceCapabilities); } +VkResult anv_GetPhysicalDeviceSurfaceCapabilities2EXT ( +VkPhysicalDevice physicalDevice, +VkSurfaceKHR surface, +VkSurfaceCapabilities2EXT * pSurfaceCapabilities) +{ +ANV_FROM_HANDLE (anv_physical_device, device, physicalDevice); + +return wsi_common_get_surface_capabilities2ext (&device->wsi_device, + surface, + pSurfaceCapabilities); +} + VkResult anv_GetPhysicalDeviceSurfaceFormatsKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 12/21 radv: Add VK_EXT_display_surface_counter to radv driver
In reply to Keith PackardThis extension is required to support EXT_display_control as it offers a way to query whether the vblank counter is supported.
--- src/amd/vulkan/radv_extensions.py | 1 + src/amd/vulkan/radv_wsi.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
src/amd/vulkan/radv_extensions.py +1 -0
@@ -84,6 +84,7 @@ EXTENSIONS = [ Extension('VK_KHR_display', 23, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'), + Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_KHX_multiview', 1, '!ANDROID'), Extension('VK_EXT_debug_report', 9, True), Extension('VK_EXT_discard_rectangles', 1, True),
src/amd/vulkan/radv_wsi.c +12 -0
@@ -103,6 +103,18 @@ VkResult radv_GetPhysicalDeviceSurfaceCapabilities2KHR( pSurfaceCapabilities); } +VkResult radv_GetPhysicalDeviceSurfaceCapabilities2EXT ( +VkPhysicalDevice physicalDevice, +VkSurfaceKHR surface, +VkSurfaceCapabilities2EXT * pSurfaceCapabilities) +{ +RADV_FROM_HANDLE (radv_physical_device, device, physicalDevice); + +return wsi_common_get_surface_capabilities2ext (&device->wsi_device, + surface, + pSurfaceCapabilities); +} + VkResult radv_GetPhysicalDeviceSurfaceFormatsKHR( VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 13/21 vulkan: add VK_EXT_display_control [v3]
In reply to Keith PackardThis 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: Remove DRM_CRTC_SEQUENCE_FIRST_PIXEL_OUT flag. This has
been removed from the proposed kernel API.
Add NULL parameter to drmCrtcQueueSequence ioctl as we don't care what sequence the event was actually queued to.
v3: Adapt to pthread clock switch to MONOTONIC
--- src/vulkan/wsi/wsi_common.h | 9 ++ src/vulkan/wsi/wsi_common_display.c | 286 +++++++++++++++++++++++++++++++++++- src/vulkan/wsi/wsi_common_display.h | 29 ++++ 3 files changed, 323 insertions(+), 1 deletion(-)
src/vulkan/wsi/wsi_common.h +9 -0
@@ -48,6 +48,15 @@ struct wsi_memory_allocate_info {bool implicit_sync; }; +struct wsi_fence { +VkDevice device; +const struct wsi_device *wsi_device; +VkDisplayKHR display; +const VkAllocationCallbacks *alloc; +bool (*wait)(struct wsi_fence *fence,bool absolute,uint64_t timeout); +void (*destroy)(struct wsi_fence *fence); +}; +struct wsi_interface ;#define VK_ICD_WSI_PLATFORM_MAX 6
src/vulkan/wsi/wsi_common_display.c +285 -1
337 lines not on this page · raw message
src/vulkan/wsi/wsi_common_display.h +29 -0
@@ -91,4 +91,33 @@ wsi_get_randr_output_display(VkPhysicalDevice physical_device,#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */ +/* VK_EXT_display_control */ +VkResult +wsi_display_power_control (VkDevice device, +struct wsi_device *wsi_device, +VkDisplayKHR display, +const VkDisplayPowerInfoEXT *display_power_info); + +VkResult +wsi_register_device_event (VkDevice device, +struct wsi_device *wsi_device, +const VkDeviceEventInfoEXT *device_event_info, +const VkAllocationCallbacks *allocator, +struct wsi_fence **fence); + +VkResult +wsi_register_display_event (VkDevice device, +struct wsi_device *wsi_device, +VkDisplayKHR display, +const VkDisplayEventInfoEXT *display_event_info, +const VkAllocationCallbacks *allocator, +struct wsi_fence **fence); + +VkResult +wsi_get_swapchain_counter (VkDevice device, +struct wsi_device *wsi_device, +VkSwapchainKHR swapchain, +VkSurfaceCounterFlagBitsEXT flag_bits, +uint64_t *value); +#endif
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 14/21 anv: add VK_EXT_display_control to anv driver
In reply to Keith PackardThis 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.
--- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_private.h | 4 ++ src/intel/vulkan/anv_queue.c | 59 ++++++++++++++++++--- src/intel/vulkan/anv_wsi_display.c | 103 +++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 7 deletions(-)
src/intel/vulkan/anv_extensions.py +1 -0
@@ -90,6 +90,7 @@ EXTENSIONS = [ Extension('VK_EXT_debug_report', 8, True), Extension('VK_EXT_external_memory_dma_buf', 1, True), Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), + Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), ] class VkVersion:
src/intel/vulkan/anv_private.h +4 -0
@@ -1941,6 +1941,7 @@ enum anv_fence_type {ANV_FENCE_TYPE_NONE =0 ,ANV_FENCE_TYPE_BO ,ANV_FENCE_TYPE_SYNCOBJ , + ANV_FENCE_TYPE_WSI, }; enum anv_bo_fence_state {
@@ -1975,6 +1976,9 @@ struct anv_fence_impl {/** DRM syncobj handle for syncobj-based fences */ uint32_t syncobj; + +/** WSI fence */ +struct wsi_fence *fence_wsi; }; };
src/intel/vulkan/anv_queue.c +52 -7
104 lines not on this page · raw message
src/intel/vulkan/anv_wsi_display.c +103 -0
106 lines not on this page · raw message
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 15/21 radv: add VK_EXT_display_control to radv driver
In reply to Keith PackardThis 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.
--- src/amd/vulkan/radv_extensions.py | 1 + src/amd/vulkan/radv_private.h | 11 +++- src/amd/vulkan/radv_wsi_display.c | 109 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-)
src/amd/vulkan/radv_extensions.py +1 -0
@@ -85,6 +85,7 @@ EXTENSIONS = [ Extension('VK_EXT_direct_mode_display', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_acquire_xlib_display', 1, 'VK_USE_PLATFORM_XLIB_XRANDR_EXT'), Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), + Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_KHX_multiview', 1, '!ANDROID'), Extension('VK_EXT_debug_report', 9, True), Extension('VK_EXT_discard_rectangles', 1, True),
src/amd/vulkan/radv_private.h +10 -1
@@ -1647,8 +1647,17 @@ void radv_initialise_cmask(struct radv_cmd_buffer *cmd_buffer,void radv_initialize_dcc (struct radv_cmd_buffer *cmd_buffer,struct radv_image *image,uint32_t value); +enum radv_fence_type { +RADV_FENCE_TYPE_WINSYS =0 , +RADV_FENCE_TYPE_WSI =1 +}; +struct radv_fence { -struct radeon_winsys_fence *fence; +enum radv_fence_type type; +union { +struct radeon_winsys_fence *fence; +struct wsi_fence *fence_wsi; + };bool submitted;bool signalled;
src/amd/vulkan/radv_wsi_display.c +109 -0
112 lines not on this page · raw message
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 16/21 vulkan: Define new VK_MESA_query_timestamp extension
In reply to Keith PackardThis extension adds a single function to query the current GPU timestamp, just like glGetInteger64v(GL_TIMESTAMP, ×tamp). This function is needed to complete the implementation of GOOGLE_display_timing, which needs to be able to coorelate GPU and CPU timestamps.
--- include/vulkan/vulkan.h | 6 ++++++ src/Makefile.am | 1 + src/vulkan/meson.build | 1 + src/vulkan/registry/vk_mesa_query_timestamp.xml | 22 ++++++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 src/vulkan/registry/vk_mesa_query_timestamp.xml
include/vulkan/vulkan.h +6 -0
@@ -7025,6 +7025,12 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryHostPointerPropertiesEXT( VkMemoryHostPointerPropertiesEXT* pMemoryHostPointerProperties);#endif +typedef VkResult (VKAPI_PTR *PFN_vkQueryCurrentTimestampMESA)(VkDevice device, uint64_t *timestamp); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueryCurrentTimestampMESA( +VkDevice _device, +uint64_t *timestamp); + #ifdef __cplusplus }#endif
src/Makefile.am +1 -0
@@ -68,6 +68,7 @@ endif EXTRA_DIST += vulkan/registry/vk.xml EXTRA_DIST += vulkan/registry/vk_android_native_buffer.xml +EXTRA_DIST += vulkan/registry/vk_mesa_query_timestamp.xml if HAVE_AMD_DRIVERS SUBDIRS += amd
src/vulkan/meson.build +1 -0
@@ -20,6 +20,7 @@ vk_api_xml = files('registry/vk.xml') vk_android_native_buffer_xml = files('registry/vk_android_native_buffer.xml') +vk_mesa_query_timestamp_xml = files('registry/vk_mesa_query_timestamp.xml') inc_vulkan_util = include_directories('util') inc_vulkan_wsi = include_directories('wsi')
src/vulkan/registry/vk_mesa_query_timestamp.xml new file +22 -0
@@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<registry> + <commands> + <command> + <proto><type>VkResult</type> <name>vkQueryCurrentTimestampMESA</name></proto> + <param><type>VkDevice</type> <name>device</name></param> + <param><type>uint64_t</type>* <name>pTimestamp</name></param> + </command> + </commands> + <extensions> + <extension name="VK_MESA_query_timestamp" number="200" + type="device" author="MESA" + contact="Keith Packard @keithp" + supported="vulkan"> + <require> + <enum value="1" name="VK_MESA_QUERY_TIMESTAMP_SPEC_VERSION"/> + <enum value=""VK_MESA_query_timestamp"" name="VK_MESA_QUERY_TIMESTAMP_NAME"/> + <command name="vkQueryCurrentTimestampMESA"/> + </require> + </extension> + </extensions> +</registry>
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 17/21 anv: Add new VK_MESA_query_timestamp extension to anv driver
In reply to Keith PackardThis extension adds a single function to query the current GPU timestamp, just like glGetInteger64v(GL_TIMESTAMP, ×tamp). This function is needed to complete the implementation of GOOGLE_display_timing, which needs to be able to coorelate GPU and CPU timestamps.
--- src/intel/Makefile.vulkan.am | 7 +++++++ src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_gem.c | 13 +++++++++++++ src/intel/vulkan/anv_private.h | 1 + src/intel/vulkan/genX_query.c | 15 +++++++++++++++ src/intel/vulkan/meson.build | 12 ++++++------ 6 files changed, 43 insertions(+), 6 deletions(-)
src/intel/Makefile.vulkan.am +7 -0
@@ -24,36 +24,43 @@ # out and we'll fail at `make dist' vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml vk_android_native_buffer_xml = $(top_srcdir)/src/vulkan/registry/vk_android_native_buffer.xml +vk_mesa_query_timestamp_xml = $(top_srcdir)/src/vulkan/registry/vk_mesa_query_timestamp.xml vulkan/anv_entrypoints.c: vulkan/anv_entrypoints_gen.py \ vulkan/anv_extensions.py \ $(vulkan_api_xml) \ + $(vk_mesa_query_timestamp_xml) \ $(vk_android_native_buffer_xml) $(MKDIR_GEN) $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_entrypoints_gen.py \ --xml $(vulkan_api_xml) \ --xml $(vk_android_native_buffer_xml) \ + --xml $(vk_mesa_query_timestamp_xml) \ --outdir $(builddir)/vulkan vulkan/anv_entrypoints.h: vulkan/anv_entrypoints.c vulkan/anv_extensions.c: vulkan/anv_extensions_gen.py \ vulkan/anv_extensions.py \ $(vulkan_api_xml) \ + $(vk_mesa_query_timestamp_xml) \ $(vk_android_native_buffer_xml) $(MKDIR_GEN) $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_extensions_gen.py \ --xml $(vulkan_api_xml) \ --xml $(vk_android_native_buffer_xml) \ + --xml $(vk_mesa_query_timestamp_xml) \ --out-c $@ vulkan/anv_extensions.h: vulkan/anv_extensions_gen.py \ vulkan/anv_extensions.py \ $(vulkan_api_xml) \ + $(vk_mesa_query_timestamp_xml) \ $(vk_android_native_buffer_xml) $(MKDIR_GEN) $(AM_V_GEN)$(PYTHON2) $(srcdir)/vulkan/anv_extensions_gen.py \ --xml $(vulkan_api_xml) \ --xml $(vk_android_native_buffer_xml) \ + --xml $(vk_mesa_query_timestamp_xml) \ --out-h $@ BUILT_SOURCES += $(VULKAN_GENERATED_FILES)
src/intel/vulkan/anv_extensions.py +1 -0
@@ -91,6 +91,7 @@ EXTENSIONS = [ Extension('VK_EXT_external_memory_dma_buf', 1, True), Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), + Extension('VK_MESA_query_timestamp', 1, True), ] class VkVersion:
src/intel/vulkan/anv_gem.c +13 -0
@@ -418,6 +418,19 @@ anv_gem_fd_to_handle(struct anv_device *device, int fd)return args.handle; } +int +anv_gem_reg_read (struct anv_device *device,uint32_t offset,uint64_t *result) +{ +struct drm_i915_reg_read args = { + .offset = offset + }; + +int ret =anv_ioctl (device->fd,DRM_IOCTL_I915_REG_READ , &args); + + *result = args.val; +return ret; +} +#ifndef SYNC_IOC_MAGIC /* duplicated from linux/sync_file.h to avoid build-time dependency * on new (v4.7) kernel headers. Once distro's are mostly using
src/intel/vulkan/anv_private.h +1 -0
@@ -932,6 +932,7 @@ bool anv_gem_supports_48b_addresses(int fd);int anv_gem_gpu_get_reset_stats (struct anv_device *device,uint32_t *active,uint32_t *pending);int anv_gem_handle_to_fd (struct anv_device *device,uint32_t gem_handle); +int anv_gem_reg_read (struct anv_device *device,uint32_t offset,uint64_t *result);uint32_t anv_gem_fd_to_handle (struct anv_device *device,int fd);int anv_gem_set_caching (struct anv_device *device,uint32_t gem_handle,uint32_t caching); int anv_gem_set_domain(struct anv_device *device, uint32_t gem_handle,
src/intel/vulkan/genX_query.c +15 -0
@@ -546,6 +546,21 @@ void genX(CmdWriteTimestamp)( } } +VkResult genX (QueryCurrentTimestampMESA )( +VkDevice _device, +uint64_t *timestamp) +{ +ANV_FROM_HANDLE (anv_device, device, _device); +int ret; + +/* XXX older kernels don't support this interface. */ + ret =anv_gem_reg_read (device,TIMESTAMP |1 , timestamp); + +if (ret !=0 ) +return VK_ERROR_DEVICE_LOST ; +return VK_SUCCESS ; +} +#if GEN_GEN >7 ||GEN_IS_HASWELL static uint32_t
src/intel/vulkan/meson.build +6 -6
@@ -20,11 +20,11 @@ anv_entrypoints = custom_target( 'anv_entrypoints.[ch]', - input : ['anv_entrypoints_gen.py', vk_api_xml, vk_android_native_buffer_xml, + input : ['anv_entrypoints_gen.py', vk_api_xml, vk_android_native_buffer_xml, vk_mesa_query_timestamp_xml, 'anv_extensions.py'], output : ['anv_entrypoints.h', 'anv_entrypoints.c'], command : [ - prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', + prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', '--xml', '@INPUT3@', '--outdir', meson.current_build_dir(), ], depend_files : files('anv_extensions.py'),
@@ -32,22 +32,22 @@ anv_entrypoints = custom_target( anv_extensions_c = custom_target( 'anv_extensions.c', - input : ['anv_extensions_gen.py', vk_api_xml, vk_android_native_buffer_xml, + input : ['anv_extensions_gen.py', vk_api_xml, vk_android_native_buffer_xml, vk_mesa_query_timestamp_xml, 'anv_extensions.py'], output : 'anv_extensions.c', command : [ - prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', + prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', '--xml', '@INPUT3@', '--out-c', '@OUTPUT@', ], ) anv_extensions_h = custom_target( 'anv_extensions.h', - input : ['anv_extensions_gen.py', vk_api_xml, vk_android_native_buffer_xml, + input : ['anv_extensions_gen.py', vk_api_xml, vk_android_native_buffer_xml, vk_mesa_query_timestamp_xml, 'anv_extensions.py'], output : 'anv_extensions.h', command : [ - prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', + prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', '--xml', '@INPUT3@', '--out-h', '@OUTPUT@', ], )
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
PATCH 18/21 radv: Add new VK_MESA_query_timestamp extension to radv driver
In reply to Keith PackardThis extension adds a single function to query the current GPU timestamp, just like glGetInteger64v(GL_TIMESTAMP, ×tamp). This function is needed to complete the implementation of GOOGLE_display_timing, which needs to be able to coorelate GPU and CPU timestamps.
--- src/amd/vulkan/Makefile.am | 3 +++ src/amd/vulkan/meson.build | 8 ++++---- src/amd/vulkan/radv_device.c | 8 ++++++++ src/amd/vulkan/radv_extensions.py | 1 + 4 files changed, 16 insertions(+), 4 deletions(-)
src/amd/vulkan/Makefile.am +3 -0
@@ -129,12 +129,14 @@ libvulkan_radeon_la_SOURCES = $(VULKAN_GEM_FILES) vulkan_api_xml = $(top_srcdir)/src/vulkan/registry/vk.xml vk_android_native_buffer_xml = $(top_srcdir)/src/vulkan/registry/vk_android_native_buffer.xml +vk_mesa_query_timestamp_xml = $(top_srcdir)/src/vulkan/registry/vk_mesa_query_timestamp.xml radv_entrypoints.c: radv_entrypoints_gen.py radv_extensions.py $(vulkan_api_xml) $(MKDIR_GEN) $(AM_V_GEN)$(PYTHON2) $(srcdir)/radv_entrypoints_gen.py \ --xml $(vulkan_api_xml) \ --xml $(vk_android_native_buffer_xml) \ + --xml $(vk_mesa_query_timestamp_xml) \ --outdir $(builddir) radv_entrypoints.h: radv_entrypoints.c
@@ -144,6 +146,7 @@ radv_extensions.c: radv_extensions.py \ $(AM_V_GEN)$(PYTHON2) $(srcdir)/radv_extensions.py \ --xml $(vulkan_api_xml) \ --xml $(vk_android_native_buffer_xml) \ + --xml $(vk_mesa_query_timestamp_xml) \ --out $@ vk_format_table.c: vk_format_table.py \
src/amd/vulkan/meson.build +4 -4
@@ -20,10 +20,10 @@ radv_entrypoints = custom_target( 'radv_entrypoints.[ch]', - input : ['radv_entrypoints_gen.py', vk_api_xml], + input : ['radv_entrypoints_gen.py', vk_api_xml, vk_android_native_buffer_xml, vk_mesa_query_timestamp_xml], output : ['radv_entrypoints.h', 'radv_entrypoints.c'], command : [ - prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--outdir', + prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', '--xml', '@INPUT3@', '--outdir', meson.current_build_dir() ], depend_files : files('radv_extensions.py'),
@@ -31,10 +31,10 @@ radv_entrypoints = custom_target( radv_extensions_c = custom_target( 'radv_extensions.c', - input : ['radv_extensions.py', vk_api_xml, vk_android_native_buffer_xml], + input : ['radv_extensions.py', vk_api_xml, vk_android_native_buffer_xml, vk_mesa_query_timestamp_xml], output : ['radv_extensions.c'], command : [ - prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', '--out', '@OUTPUT@', + prog_python2, '@INPUT0@', '--xml', '@INPUT1@', '--xml', '@INPUT2@', '--xml', '@INPUT3@', '--out', '@OUTPUT@', ], )
src/amd/vulkan/radv_device.c +8 -0
@@ -4083,3 +4083,11 @@ radv_DebugReportMessageEXT(VkInstance _instance,vk_debug_report (&instance->debug_report_callbacks, flags, objectType, object, location, messageCode, pLayerPrefix, pMessage); } + +VkResult radv_QueryCurrentTimestampMESA (VkDevice _device,uint64_t *timestamp) +{ +RADV_FROM_HANDLE (radv_device, device, _device); + + *timestamp = device->ws->query_value (device->ws,RADEON_TIMESTAMP ); +return VK_SUCCESS ; +}
src/amd/vulkan/radv_extensions.py +1 -0
@@ -95,6 +95,7 @@ EXTENSIONS = [ Extension('VK_AMD_draw_indirect_count', 1, True), Extension('VK_AMD_rasterization_order', 1, 'device->rad_info.chip_class >= VI && device->rad_info.max_se >= 2'), Extension('VK_AMD_shader_info', 1, True), + Extension('VK_MESA_query_timestamp', 1, True), ] class VkVersion:
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 19/21 vulkan: Add VK_GOOGLE_display_timing extension (x11 and display backends)
In reply to Keith PackardThis adds support for the VK_GOOGLE_display timing extension, which provides two things:
1) Detailed information about when frames are displayed, including slack time between GPU execution and display frame.
2) Absolute time control over swapchain queue processing. This allows the application to request frames be displayed at specific absolute times, using the same timebase as that provided in vblank events.
Support for this extension has been implemented for the x11 and display backends; adding support to other backends should be reasonable straightforward for one familiar with those systems and should not require any additional device-specific code.
--- src/vulkan/wsi/wsi_common.c | 254 +++++++++++++++++++++++++++++++++++- src/vulkan/wsi/wsi_common.h | 24 ++++ src/vulkan/wsi/wsi_common_display.c | 143 +++++++++++++++++++- src/vulkan/wsi/wsi_common_private.h | 35 +++++ src/vulkan/wsi/wsi_common_x11.c | 69 +++++++++- 5 files changed, 514 insertions(+), 11 deletions(-)
src/vulkan/wsi/wsi_common.c +251 -3
@@ -40,11 +40,16 @@ wsi_device_init(struct wsi_device *wsi, PFN_vk##func func = (PFN_vk##func)proc_addr(pdevice, "vk" #func)WSI_GET_CB (GetPhysicalDeviceMemoryProperties);WSI_GET_CB (GetPhysicalDeviceQueueFamilyProperties); +WSI_GET_CB (GetPhysicalDeviceProperties);#undef WSI_GET_CBGetPhysicalDeviceMemoryProperties (pdevice, &wsi->memory_props);GetPhysicalDeviceQueueFamilyProperties (pdevice, &wsi->queue_family_count,NULL ); +VkPhysicalDeviceProperties properties; +GetPhysicalDeviceProperties (pdevice, &properties); + wsi->timestamp_period = properties.limits.timestampPeriod; +#define WSI_GET_CB (func) \ wsi->func = (PFN_vk##func)proc_addr(pdevice, "vk" #func)WSI_GET_CB (AllocateMemory);
@@ -53,14 +58,18 @@ wsi_device_init(struct wsi_device *wsi,WSI_GET_CB (BindImageMemory);WSI_GET_CB (BeginCommandBuffer);WSI_GET_CB (CmdCopyImageToBuffer); +WSI_GET_CB (CmdResetQueryPool); +WSI_GET_CB (CmdWriteTimestamp);WSI_GET_CB (CreateBuffer);WSI_GET_CB (CreateCommandPool);WSI_GET_CB (CreateFence);WSI_GET_CB (CreateImage); +WSI_GET_CB (CreateQueryPool);WSI_GET_CB (DestroyBuffer);WSI_GET_CB (DestroyCommandPool);WSI_GET_CB (DestroyFence);WSI_GET_CB (DestroyImage); +WSI_GET_CB (DestroyQueryPool);WSI_GET_CB (EndCommandBuffer);WSI_GET_CB (FreeMemory);WSI_GET_CB (FreeCommandBuffers);
@@ -68,9 +77,13 @@ wsi_device_init(struct wsi_device *wsi,WSI_GET_CB (GetImageMemoryRequirements);WSI_GET_CB (GetImageSubresourceLayout);WSI_GET_CB (GetMemoryFdKHR); +WSI_GET_CB (GetPhysicalDeviceProperties);WSI_GET_CB (GetPhysicalDeviceFormatProperties); +WSI_GET_CB (GetPhysicalDeviceQueueFamilyProperties); +WSI_GET_CB (GetQueryPoolResults);WSI_GET_CB (ResetFences);WSI_GET_CB (QueueSubmit); +WSI_GET_CB (QueryCurrentTimestampMESA);WSI_GET_CB (WaitForFences);#undef WSI_GET_CB
@@ -136,6 +149,8 @@ wsi_swapchain_init(const struct wsi_device *wsi, chain->device = device; chain->alloc = *pAllocator; chain->use_prime_blit = false; + chain->timing_insert =0 ; + chain->timing_count =0 ; chain->cmd_pools = vk_zalloc(pAllocator, sizeof(VkCommandPool) * wsi->queue_family_count, 8,
@@ -209,6 +224,60 @@ align_u32(uint32_t v, uint32_t a)return (v + a -1 ) & ~(a -1 ); } +static VkResult +wsi_image_init_timestamp (const struct wsi_swapchain *chain, +struct wsi_image *image) +{ +const struct wsi_device *wsi = chain->wsi; +VkResult result; +/* Set up command buffer to get timestamp info */ + + result = wsi->CreateQueryPool (chain->device, + &(const VkQueryPoolCreateInfo ) { + .sType =VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO , + .queryType =VK_QUERY_TYPE_TIMESTAMP , + .queryCount =1 , + }, +NULL , + &image->query_pool); + +if (result !=VK_SUCCESS ) + goto fail; + + result = wsi->AllocateCommandBuffers (chain->device, + &(const VkCommandBufferAllocateInfo ) { + .sType =VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO , + .pNext =NULL , + .commandPool = chain->cmd_pools[0 ], + .level =VK_COMMAND_BUFFER_LEVEL_PRIMARY , + .commandBufferCount =1 , + }, + &image->timestamp_buffer); +if (result !=VK_SUCCESS ) + goto fail; + + wsi->BeginCommandBuffer (image->timestamp_buffer, + &(VkCommandBufferBeginInfo ) { + .sType =VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO , + .flags =0 + }); + + wsi->CmdResetQueryPool (image->timestamp_buffer, + image->query_pool, +0 ,1 ); + + wsi->CmdWriteTimestamp (image->timestamp_buffer, +VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT , + image->query_pool, +0 ); + + wsi->EndCommandBuffer (image->timestamp_buffer); + +return VK_SUCCESS ; +fail: +return result; +} + VkResult wsi_create_native_image(const struct wsi_swapchain *chain, const VkSwapchainCreateInfoKHR *pCreateInfo,
@@ -303,6 +372,11 @@ wsi_create_native_image(const struct wsi_swapchain *chain, };int fd; result = wsi->GetMemoryFdKHR (chain->device, &memory_get_fd_info, &fd); +if (result !=VK_SUCCESS ) + goto fail; + + result =wsi_image_init_timestamp (chain, image); +if (result !=VK_SUCCESS ) goto fail;
@@ -497,6 +571,11 @@ wsi_create_prime_image(const struct wsi_swapchain *chain, goto fail; } + result =wsi_image_init_timestamp (chain, image); + +if (result !=VK_SUCCESS ) + goto fail; +const VkMemoryGetFdInfoKHR linear_memory_get_fd_info = { .sType =VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR , .pNext =NULL ,
@@ -695,6 +774,87 @@ wsi_common_acquire_next_image(const struct wsi_device *wsi, semaphore, pImageIndex); } +static struct wsi_timing * +wsi_get_timing (struct wsi_swapchain *chain,uint32_t i) +{ +uint32_t j =WSI_TIMING_HISTORY + chain->timing_insert - chain->timing_count + i; + +if (j >=WSI_TIMING_HISTORY ) + j -=WSI_TIMING_HISTORY ; +return &chain->timing[j]; +} + +static struct wsi_timing * +wsi_next_timing (struct wsi_swapchain *chain,int image_index) +{ +uint32_t j; +struct wsi_timing *timing; + + j = chain->timing_insert; + ++chain->timing_insert; +if (chain->timing_insert >=WSI_TIMING_HISTORY ) + chain->timing_insert =0 ; +if (chain->timing_count <WSI_TIMING_HISTORY ) + ++chain->timing_count; + timing = &chain->timing[j]; +memset (timing,'\0' ,sizeof (*timing)); +return timing; +} + +void +wsi_mark_timing (struct wsi_swapchain *swapchain, +struct wsi_image *image, +uint64_t ust, +uint64_t msc) +{ +const struct wsi_device *wsi = swapchain->wsi; +struct wsi_timing *timing = image->timing; +VkResult result; + +if (!timing) +return ; + + swapchain->frame_msc = msc; + swapchain->frame_ust = ust; + +uint64_t render_timestamp; + + result = wsi->GetQueryPoolResults (swapchain->device, image->query_pool, +0 ,1 ,sizeof (render_timestamp), &render_timestamp, +sizeof (uint64_t ), +VK_QUERY_RESULT_64_BIT |VK_QUERY_RESULT_WAIT_BIT ); + +if (result !=VK_SUCCESS ) +return ; + +uint64_t current_gpu_timestamp; + result = wsi->QueryCurrentTimestampMESA (swapchain->device, ¤t_gpu_timestamp); +if (result !=VK_SUCCESS ) +return ; +uint64_t current_time = swapchain->get_current_time (); + +VkRefreshCycleDurationGOOGLE display_timings; + swapchain->get_refresh_cycle_duration (swapchain, &display_timings); + +uint64_t refresh_duration = display_timings.refreshDuration; + +/* When did drawing complete (in nsec) */ + +uint64_t render_time = current_time - (current_gpu_timestamp - render_timestamp) * wsi->timestamp_period; + +if (render_time > ust) + render_time = ust; + +uint64_t render_frames = (ust - render_time) / refresh_duration; + +uint64_t earliest_time = ust - render_frames * refresh_duration; + + timing->timing.actualPresentTime = ust; + timing->timing.earliestPresentTime = earliest_time; + timing->timing.presentMargin = earliest_time - render_time; + timing->complete = true; +} + VkResult wsi_common_queue_present(const struct wsi_device *wsi, VkDevice device,
@@ -706,10 +866,13 @@ wsi_common_queue_present(const struct wsi_device *wsi,const VkPresentRegionsKHR *regions =vk_find_struct_const (pPresentInfo->pNext,PRESENT_REGIONS_KHR ); +const VkPresentTimesInfoGOOGLE *present_times_info = +vk_find_struct_const (pPresentInfo->pNext,PRESENT_TIMES_INFO_GOOGLE );for (uint32_t i =0 ; i < pPresentInfo->swapchainCount; i++) {WSI_FROM_HANDLE (wsi_swapchain, swapchain, pPresentInfo->pSwapchains[i]);VkResult result; +struct wsi_timing *timing =NULL ;if (swapchain->fences[0 ] ==VK_NULL_HANDLE ) { const VkFenceCreateInfo fence_info = {
@@ -726,9 +889,12 @@ wsi_common_queue_present(const struct wsi_device *wsi, wsi->ResetFences (device,1 , &swapchain->fences[0 ]); } +VkCommandBuffer submit_buffers[2 ];VkSubmitInfo submit_info = { .sType =VK_STRUCTURE_TYPE_SUBMIT_INFO , .pNext =NULL , + .pCommandBuffers = submit_buffers, + .commandBufferCount =0 };VkPipelineStageFlags *stage_flags =NULL ;
@@ -761,9 +927,44 @@ wsi_common_queue_present(const struct wsi_device *wsi,*/ struct wsi_image *image = swapchain->get_wsi_image (swapchain, pPresentInfo->pImageIndices[i]); - submit_info.commandBufferCount =1 ; - submit_info.pCommandBuffers = - &image->prime.blit_cmd_buffers[queue_family_index]; + submit_buffers[submit_info.commandBufferCount++] = + image->prime.blit_cmd_buffers[queue_family_index]; + } + +/* Set up GOOGLE_display_timing bits */ +if (present_times_info && + present_times_info->pTimes !=NULL && + i < present_times_info->swapchainCount) + { +const VkPresentTimeGOOGLE *present_time = &present_times_info->pTimes[i]; + +struct wsi_image *image = swapchain->get_wsi_image (swapchain, pPresentInfo->pImageIndices[i]); + + timing =wsi_next_timing (swapchain, pPresentInfo->pImageIndices[i]); + timing->timing.presentID = present_time->presentID; + timing->timing.desiredPresentTime = present_time->desiredPresentTime; + timing->target_msc =0 ; + image->timing = timing; + +if (present_time->desiredPresentTime !=0 ) + { +int64_t delta_nsec = (int64_t ) (present_time->desiredPresentTime - swapchain->frame_ust); + +/* Set the target msc only if it's no more than two seconds from +* now, and not stale +*/ +if (0 <= delta_nsec && delta_nsec <=2000000000ul ) { +VkRefreshCycleDurationGOOGLE refresh_timing; + + swapchain->get_refresh_cycle_duration (swapchain, &refresh_timing); + +int64_t refresh = (int64_t ) refresh_timing.refreshDuration; +int64_t frames = (delta_nsec + refresh/2 ) / refresh; + timing->target_msc = swapchain->frame_msc + frames; + } + } + + submit_buffers[submit_info.commandBufferCount++] = image->timestamp_buffer; } result = wsi->QueueSubmit (queue,1 , &submit_info, swapchain->fences[0 ]);
@@ -801,3 +1002,50 @@ wsi_common_queue_present(const struct wsi_device *wsi,return final_result; } + +VkResult +wsi_common_get_refresh_cycle_duration (const struct wsi_device *wsi, +VkDevice device_h, +VkSwapchainKHR _swapchain, +VkRefreshCycleDurationGOOGLE *pDisplayTimingProperties) +{ +WSI_FROM_HANDLE (wsi_swapchain, swapchain, _swapchain); + +if (!swapchain->get_refresh_cycle_duration) +return VK_ERROR_EXTENSION_NOT_PRESENT ; +return swapchain->get_refresh_cycle_duration (swapchain, pDisplayTimingProperties); +} + + +VkResult +wsi_common_get_past_presentation_timing (const struct wsi_device *wsi, +VkDevice device_h, +VkSwapchainKHR _swapchain, +uint32_t *count, +VkPastPresentationTimingGOOGLE *timings) +{ +WSI_FROM_HANDLE (wsi_swapchain, swapchain, _swapchain); +uint32_t timing_count_requested = *count; +uint32_t timing_count_available =0 ; +uint32_t t; + +/* Count the number of completed entries, copy */ +for (t =0 ; t < swapchain->timing_count; t++) { +struct wsi_timing *timing =wsi_get_timing (swapchain, t); + +if (timing->complete && !timing->consumed) { +if (timings && timing_count_available < timing_count_requested) { + timings[timing_count_available] = timing->timing; + timing->consumed = true; + } + timing_count_available++; + } + } + + *count = timing_count_available; + +if (timing_count_available > timing_count_requested && timings !=NULL ) +return VK_INCOMPLETE ; + +return VK_SUCCESS ; +}
src/vulkan/wsi/wsi_common.h +24 -0
@@ -64,6 +64,7 @@ struct wsi_interface;struct wsi_device {VkPhysicalDeviceMemoryProperties memory_props;uint32_t queue_family_count; +float timestamp_period;#define WSI_CB (cb) PFN_vk##cb cbWSI_CB (AllocateMemory);
@@ -72,14 +73,18 @@ struct wsi_device {WSI_CB (BindImageMemory);WSI_CB (BeginCommandBuffer);WSI_CB (CmdCopyImageToBuffer); +WSI_CB (CmdResetQueryPool); +WSI_CB (CmdWriteTimestamp);WSI_CB (CreateBuffer);WSI_CB (CreateCommandPool);WSI_CB (CreateFence);WSI_CB (CreateImage); +WSI_CB (CreateQueryPool);WSI_CB (DestroyBuffer);WSI_CB (DestroyCommandPool);WSI_CB (DestroyFence);WSI_CB (DestroyImage); +WSI_CB (DestroyQueryPool);WSI_CB (EndCommandBuffer);WSI_CB (FreeMemory);WSI_CB (FreeCommandBuffers);
@@ -87,9 +92,13 @@ struct wsi_device {WSI_CB (GetImageMemoryRequirements);WSI_CB (GetImageSubresourceLayout);WSI_CB (GetMemoryFdKHR); +WSI_CB (GetPhysicalDeviceProperties);WSI_CB (GetPhysicalDeviceFormatProperties); +WSI_CB (GetPhysicalDeviceQueueFamilyProperties); +WSI_CB (GetQueryPoolResults);WSI_CB (ResetFences);WSI_CB (QueueSubmit); +WSI_CB (QueryCurrentTimestampMESA);WSI_CB (WaitForFences);#undef WSI_CB
@@ -201,4 +210,19 @@ wsi_common_queue_present(const struct wsi_device *wsi,int queue_family_index, const VkPresentInfoKHR *pPresentInfo); +/* VK_GOOGLE_display_timing */ +VkResult +wsi_common_get_refresh_cycle_duration (const struct wsi_device *wsi, +VkDevice device_h, +VkSwapchainKHR swapchain, +VkRefreshCycleDurationGOOGLE *pDisplayTimingProperties); + + +VkResult +wsi_common_get_past_presentation_timing (const struct wsi_device *wsi, +VkDevice device_h, +VkSwapchainKHR swapchain, +uint32_t *pPresentationTimingCount, +VkPastPresentationTimingGOOGLE *pPresentationTimings); +#endif
src/vulkan/wsi/wsi_common_display.c +138 -5
263 lines not on this page · raw message
src/vulkan/wsi/wsi_common_private.h +35 -0
@@ -25,6 +25,13 @@#include "wsi_common.h" +struct wsi_timing { +bool complete; +bool consumed; +uint64_t target_msc; +VkPastPresentationTimingGOOGLE timing; +}; +struct wsi_image {VkImage image;VkDeviceMemory memory;
@@ -39,8 +46,16 @@ struct wsi_image {uint32_t offset;uint32_t row_pitch;int fd; + +VkQueryPool query_pool; + +VkCommandBuffer timestamp_buffer; + +struct wsi_timing *timing; }; +#define WSI_TIMING_HISTORY 16 +struct wsi_swapchain {const struct wsi_device *wsi;
@@ -52,6 +67,16 @@ struct wsi_swapchain {bool use_prime_blit; +uint32_t timing_insert; +uint32_t timing_count; + +struct wsi_timing timing[WSI_TIMING_HISTORY ]; + +uint64_t frame_msc; +uint64_t frame_ust; + +float timestamp_period; +/* Command pools, one per queue family */ VkCommandPool *cmd_pools;
@@ -65,6 +90,10 @@ struct wsi_swapchain {VkResult (*queue_present)(struct wsi_swapchain *swap_chain,uint32_t image_index,const VkPresentRegionKHR *damage); +VkResult (*get_refresh_cycle_duration)(struct wsi_swapchain *swap_chain, +VkRefreshCycleDurationGOOGLE *pDisplayTimingProperties); + +uint64_t (*get_current_time)(void ); }; VkResult
@@ -91,6 +120,12 @@ wsi_destroy_image(const struct wsi_swapchain *chain, struct wsi_image *image); +void +wsi_mark_timing (struct wsi_swapchain *swapchain, +struct wsi_image *image, +uint64_t ust, +uint64_t msc); +struct wsi_interface { VkResult (*get_support)(VkIcdSurfaceBase *surface, struct wsi_device *wsi_device,
src/vulkan/wsi/wsi_common_x11.c +66 -3
135 lines not on this page · raw message
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 20/21 anv: Add VK_GOOGLE_display_timing extension to anv driver
In reply to Keith PackardThis adds support for the VK_GOOGLE_display timing extension.
--- src/intel/vulkan/anv_extensions.py | 1 + src/intel/vulkan/anv_wsi.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+)
src/intel/vulkan/anv_extensions.py +1 -0
@@ -92,6 +92,7 @@ EXTENSIONS = [ Extension('VK_EXT_display_surface_counter', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_EXT_display_control', 1, 'VK_USE_PLATFORM_DISPLAY_KHR'), Extension('VK_MESA_query_timestamp', 1, True), + Extension('VK_GOOGLE_display_timing', 1, True), ] class VkVersion:
src/intel/vulkan/anv_wsi.c +29 -0
@@ -239,3 +239,32 @@ VkResult anv_QueuePresentKHR( _queue,0 , pPresentInfo); } + +/* VK_GOOGLE_display_timing */ +VkResult +anv_GetRefreshCycleDurationGOOGLE (VkDevice _device, +VkSwapchainKHR swapchain, +VkRefreshCycleDurationGOOGLE *pDisplayTimingProperties) +{ +ANV_FROM_HANDLE (anv_device, device, _device); + +return wsi_common_get_refresh_cycle_duration (&device->instance->physicalDevice.wsi_device, + _device, + swapchain, + pDisplayTimingProperties); +} + +VkResult +anv_GetPastPresentationTimingGOOGLE (VkDevice _device, +VkSwapchainKHR swapchain, +uint32_t *pPresentationTimingCount, +VkPastPresentationTimingGOOGLE *pPresentationTimings) +{ +ANV_FROM_HANDLE (anv_device, device, _device); + +return wsi_common_get_past_presentation_timing (&device->instance->physicalDevice.wsi_device, + _device, + swapchain, + pPresentationTimingCount, + pPresentationTimings); +}
Signature · 6 lines
2.15.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 21/21 radv: Add VK_GOOGLE_display_timing extension to radv driver
In reply to Keith PackardThis adds support for the VK_GOOGLE_display timing extension.
--- src/amd/vulkan/radv_extensions.py | 1 + src/amd/vulkan/radv_wsi.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
src/amd/vulkan/radv_extensions.py +1 -0
@@ -96,6 +96,7 @@ EXTENSIONS = [ Extension('VK_AMD_rasterization_order', 1, 'device->rad_info.chip_class >= VI && device->rad_info.max_se >= 2'), Extension('VK_AMD_shader_info', 1, True), Extension('VK_MESA_query_timestamp', 1, True), + Extension('VK_GOOGLE_display_timing', 1, True), ] class VkVersion:
src/amd/vulkan/radv_wsi.c +32 -0
@@ -247,3 +247,35 @@ VkResult radv_QueuePresentKHR( queue->queue_family_index, pPresentInfo); } + +/* VK_GOOGLE_display_timing */ +VkResult +radv_GetRefreshCycleDurationGOOGLE ( +VkDevice _device, +VkSwapchainKHR swapchain, +VkRefreshCycleDurationGOOGLE *pDisplayTimingProperties) +{ +RADV_FROM_HANDLE (radv_device, device, _device); +struct radv_physical_device *pdevice = device->physical_device; + +return wsi_common_get_refresh_cycle_duration (&pdevice->wsi_device, + _device, + swapchain, + pDisplayTimingProperties); +} + +VkResult +radv_GetPastPresentationTimingGOOGLE (VkDevice _device, +VkSwapchainKHR swapchain, +uint32_t *pPresentationTimingCount, +VkPastPresentationTimingGOOGLE *pPresentationTimings) +{ +RADV_FROM_HANDLE (radv_device, device, _device); +struct radv_physical_device *pdevice = device->physical_device; + +return wsi_common_get_past_presentation_timing (&pdevice->wsi_device, + _device, + swapchain, + pPresentationTimingCount, + pPresentationTimings); +}
Signature · 6 lines
2.15.1 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev