<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">I'm trusting that not much changed other than what was explicitly called out.  I didn't want to re-read in *that* much detail again. :-)</div><div class="gmail_quote"><br></div><div class="gmail_quote">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Mon, Jun 11, 2018 at 10:39 PM, Keith Packard <span dir="ltr"><<a href="mailto:keithp@keithp.com" target="_blank">keithp@keithp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This adds support for the KHR_display extension support to the vulkan<br>
WSI layer. Driver support will be added separately.<br>
<br>
v2:<br>
        * fix double ;; in wsi_common_display.c<br>
<br>
        * Move mode list from wsi_display to wsi_display_connector<br>
<br>
        * Fix scope for wsi_display_mode andwsi_display_connector<br>
          allocs<br>
<br>
        * Switch all allocations to vk_zalloc instead of vk_alloc.<br>
<br>
        * Fix DRM failure in<br>
          wsi_display_get_physical_<wbr>device_display_properties<br>
<br>
          When DRM fails, or when we don't have a master fd<br>
          (presumably due to application errors), just return 0<br>
          properties from this function, which is at least a valid<br>
          response.<br>
<br>
        * Use vk_outarray for all property queries<br>
<br>
          This is a bit less error-prone than open-coding the same<br>
          stuff.<br>
<br>
        * Remove VK_COMPOSITE_ALPHA_INHERIT_<wbr>BIT_KHR from surface caps<br>
<br>
          Until we have multi-plane support, we shouldn't pretend to<br>
          have any multi-plane semantics, even if undefined.<br>
<br>
        Suggested-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
<br>
        * Simplify addition of VK_USE_PLATFORM_DISPLAY_KHR to<br>
          vulkan_wsi_args<br>
<br>
        Suggested-by: Eric Engestrom <<a href="mailto:eric.engestrom@imgtec.com">eric.engestrom@imgtec.com</a>><br>
<br>
v3:<br>
        Add separate 'display_fd' and 'render_fd' arguments to<br>
        wsi_device_init API. This allows drivers to use different FDs<br>
        for the different aspects of the device.<br>
<br>
        Use largest mode as display size when no preferred mode.<br>
<br>
        If the display doesn't provide a preferred mode, we'll assume<br>
        that the largest supported mode is the "physical size" of the<br>
        device and report that.<br>
<br>
v4:<br>
        Make wsi_image_state enumeration values uppercase.<br>
        Follow more common mesa conventions.<br>
<br>
        Remove 'render_fd' from wsi_device_init API.  The<br>
        wsi_common_display code doesn't use this fd at all, so stop<br>
        passing it in. This avoids any potential confusion over which<br>
        fd to use when creating display-relative object handles.<br>
<br>
        Remove call to wsi_create_prime_image which would never have<br>
        been reached as the necessary condition (use_prime_blit) is<br>
        never set.<br>
<br>
        whitespace cleanups in wsi_common_display.c<br>
<br>
        Suggested-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
<br>
        Add depth/bpp info to available surface formats.  Instead of<br>
        hard-coding depth 24 bpp 32 in the drmModeAddFB call, use the<br>
        requested format to find suitable values.<br>
<br>
        Destroy kernel buffers and FBs when swapchain is destroyed. We<br>
        were leaking both of these kernel objects across swapchain<br>
        destruction.<br>
<br>
        Note that wsi_display_wait_for_event waits for anything to<br>
        happen.  wsi_display_wait_for_event is simply a yield so that<br>
        the caller can then check to see if the desired state change<br>
        has occurred.<br>
<br>
        Record swapchain failures in chain for later return. If some<br>
        asynchronous swapchain activity fails, we need to tell the<br>
        application eventually. Record the failure in the swapchain<br>
        and report it at the next acquire_next_image or queue_present<br>
        call.<br>
<br>
        Fix error returns from wsi_display_setup_connector.  If a<br>
        malloc failed, then the result should be<br>
        VK_ERROR_OUT_OF_HOST_MEMORY. Otherwise, the associated ioctl<br>
        failed and we're either VT switched away, or our lease has<br>
        been revoked, in which case we should return<br>
        VK_ERROR_OUT_OF_DATE_KHR.<br>
<br>
        Make sure both sides of if/else brace use matches<br>
<br>
        Note that we assume drmModeSetCrtc is synchronous. Add a<br>
        comment explaining why we can idle any previous displayed<br>
        image as soon as the mode set returns.<br>
<br>
        Note that EACCES from drmModePageFlip means VT inactive.  When<br>
        vt switched away drmModePageFlip returns EACCES. Poll once a<br>
        second waiting until we get some other return value back.<br>
<br>
        Clean up after alloc failure in<br>
        wsi_display_surface_create_<wbr>swapchain. Destroy any created<br>
        images, free the swapchain.<br>
<br>
        Remove physical_device from wsi_display_init_wsi. We never<br>
        need this value, so remove it from the API and from the<br>
        internal wsi_display structure.<br>
<br>
        Use drmModeAddFB2 in wsi_display_image_init.  This takes a drm<br>
        format instead of depth/bpp, which provides more control over<br>
        the format of the data.<br>
<br>
v5:<br>
        Set the 'currentStackIndex' member of the<br>
        VkDisplayPlanePropertiesKHR record to zero, instead of<br>
        indexing across all displays. This value is the stack depth of<br>
        the plane within an individual display, and as the current<br>
        code supports only a single plane per display, should be set<br>
        to zero for all elements<br>
<br>
        Discovered-by: David Mao <<a href="mailto:David.Mao@amd.com">David.Mao@amd.com</a>><br>
<br>
v6:<br>
        Remove 'platform_display' bits from the build and use the<br>
        existing 'platform_drm' instead.<br>
<br>
v7:<br>
        Ensure VK_ICD_WSI_PLATFORM_MAX is large enough by<br>
        setting to VK_ICD_WSI_PLATFORM_DISPLAY + 1<br>
<br>
v8:<br>
        Simplify wsi_device_init failure from wsi_display_init_wsi<br>
        by using the same pattern as the other wsi layers.<br>
<br>
    Adopt Jason Ekstrand's white space and variable declaration<br>
        suggestions. Declare variables at first use, eliminate extra<br>
        whitespace between types and names, add list iterator helpers,<br>
        switch to lower-case list_ macros.<br>
<br>
    Respond to Jason's April 8 review:<br>
<br>
        * Create a function to convert relative to absolute timeouts<br>
          to catch overflow issues in one place<br>
<br>
        * use VK_NULL_HANDLE to clear prop->currentDisplay<br>
<br>
        * Get rid of available_present_modes array.<br>
<br>
        * return OUT_OF_DATE_KHR when display_queue_next called after<br>
          display has been released.<br>
<br>
        * Make errors from mode setting fatal in display_queue_next<br>
<br>
        * Remove duplicate pthread_mutex_init call<br>
<br>
        * Add wsi_init_pthread_cond_<wbr>monotonic helper function to<br>
          isolate pthread error handling from wsi_display_init_wsi<br>
<br>
        Suggested-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br>
<br>
Signed-off-by: Keith Packard <<a href="mailto:keithp@keithp.com">keithp@keithp.com</a>><br>
---<br>
 src/amd/vulkan/radv_device.c        |    8 +<br>
 src/amd/vulkan/radv_private.h       |    1 +<br>
 src/amd/vulkan/radv_wsi.c           |    3 +-<br>
 src/intel/vulkan/anv_device.c       |    4 +<br>
 src/intel/vulkan/anv_private.h      |    1 +<br>
 src/intel/vulkan/anv_wsi.c          |    3 +-<br>
 src/vulkan/Makefile.am              |    7 +<br>
 src/vulkan/Makefile.sources         |    4 +<br>
 src/vulkan/wsi/meson.build          |    8 +<br>
 src/vulkan/wsi/wsi_common.c         |   12 +-<br>
 src/vulkan/wsi/wsi_common.h         |    5 +-<br>
 src/vulkan/wsi/wsi_common_<wbr>display.c | 1432 +++++++++++++++++++++++++++<br>
 src/vulkan/wsi/wsi_common_<wbr>display.h |   77 ++<br>
 src/vulkan/wsi/wsi_common_<wbr>private.h |    9 +<br>
 14 files changed, 1569 insertions(+), 5 deletions(-)<br>
 create mode 100644 src/vulkan/wsi/wsi_common_<wbr>display.c<br>
 create mode 100644 src/vulkan/wsi/wsi_common_<wbr>display.h<br></blockquote></div></div></div>