aboutsummaryrefslogtreecommitdiffstats
path: root/src/vulkan/wsi/wsi_common_x11.c
Commit message (Collapse)AuthorAgeFilesLines
* vulkan/wsi: fix pointer-integer conversion warningsGrazvydas Ignotas2018-08-231-1/+1
| | | | | | For 32bit build. Trivial. Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* vulkan/wsi: initialise image_index to 0 in x11_manage_fifo_queuesKai Wasserbäch2018-08-181-1/+1
| | | | | | | | | | Supresses a maybe-uninitialized warning with GCC 8. Note: image_index should always be initialised due to the result check, but the compiler doesn't see that. Signed-off-by: Kai Wasserbäch <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
* vulkan/wsi: Get rid of the get_capabilities hookJason Ekstrand2018-06-201-1/+0
| | | | | | | Instead, we can just use get_capabilities2. This way back-ends only have to implement one hook. Reviewed-by: Keith Packard <[email protected]>
* vulkan/wsi: Destroy swapchain images after terminating FIFO queuesCameron Kumar2018-06-081-3/+3
| | | | | | | | | The queue_manager thread can access the images from x11_present_to_x11, hence this reorder prevents dereferencing of dangling pointers. Cc: "18.1" <[email protected]> Fixes: e73d136a023080 ("vulkan/wsi/x11: Implement FIFO mode.") Reviewed-by: Lionel Landwerlin <[email protected]>
* vulkan: don't free uninitialised memoryEric Engestrom2018-05-291-1/+1
| | | | | | | | | | The modifiers array hasn't been initialised by then, much less with data that would need freeing. Move the label after the loop to fix this. Fixes: c80c08e22603 ("vulkan/wsi/x11: Add support for DRI3 v1.2") Signed-off-by: Eric Engestrom <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]>
* vulkan/wsi: Only use LINEAR modifier for prime if supported.Bas Nieuwenhuizen2018-05-081-1/+2
| | | | | | | | | | | | This was setting the LINEAR modifier if neither the X server nor the driver supported modifiers. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106180 Fixes: c80c08e226 "vulkan/wsi/x11: Add support for DRI3 v1.2" CC: 18.1 <[email protected]> Tested-by: Abel Garcia Dorta <[email protected]> Acked-by: Daniel Stone <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* dri3: Don't fail on version mismatchDaniel Stone2018-03-201-0/+4
| | | | | | | | | | | | | The previous commit to make DRI3 modifier support optional, breaks with an updated server and old client. Make sure we never set multibuffers_available unless we also support it locally. Make sure we don't call stubs of new-DRI3 functions (or empty branches) which will never succeed. Signed-off-by: Daniel Stone <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Fixes: 7aeef2d4efdc ("dri3: allow building against older xcb (v3)")
* dri3: allow building against older xcb (v3)Dave Airlie2018-03-161-2/+10
| | | | | | | | | | | | | | | | | | | | | I'm not sure everyone wants to be updating their dri3 in a forced march setting, this allows a nicer approach, esp when you want to build on distro that aren't brand new. I'm sure there are plenty of ways this patch could be cleaner, and I've also not built it against an updated dri3. For meson I've just left it alone, since if you are using meson you probably don't mind xcb updates, and if you are using meson you can fix this better than me. v3: just don't put a version in for dri3/present without modifiers, should allow building with 1.11 as well (feel free to supply meson followups) Signed-off-by: Dave Airlie <[email protected]> Signed-off-by: Marek Olšák <[email protected]>
* vulkan/wsi/x11: correct DRI3 version in commentEmil Velikov2018-03-161-1/+1
| | | | | | | | | During development the version was bumped, yet the comment did not get an update. Fixes: c80c08e2260 ("vulkan/wsi/x11: Add support for DRI3 v1.2") Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
* vulkan/wsi/x11: use ARRAY_SIZE where applicableEmil Velikov2018-03-161-2/+2
| | | | | | | | Use the handy macro instead of hard coded numbers. Fixes: c80c08e2260 ("vulkan/wsi/x11: Add support for DRI3 v1.2") Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
* vulkan/wsi/x11: Return VK_SUBOPTIMAL_KHR for X11Louis-Francis Ratté-Boulianne2018-03-091-3/+60
| | | | | | | | | When it is detected that a window could have been flipped but has been copied because of suboptimal format/modifier. The Vulkan client should then re-create the swapchain. Signed-off-by: Louis-Francis Ratté-Boulianne <[email protected]> Reviewed-by: Daniel Stone <[email protected]>
* vulkan/wsi/x11: Add support for DRI3 v1.2Daniel Stone2018-03-091-17/+161
| | | | | | | | Adds support for multiple planes and buffer modifiers. v4: Rename "has_dri3_v1_1" to "has_dri3_modifiers" v12: Multi-planar/modifier support is now DRI3 v1.2; also update release versions
* vulkan/wsi/x11: Consistently update and return swapchain statusDaniel Stone2018-02-211-19/+63
| | | | | | | | | | | | | | | | | Use a helper function for updating the swapchain status. This will be used later to handle VK_SUBOPTIMAL_KHR, where we need to make a non-error status stick to the swapchain until recreation. Instead of direct comparisons to VK_SUCCESS to check for error, test for negative numbers meaning an error status, and positive numbers indicating non-error statuses. v2 (Jason Ekstrand): - Use a pattern of "return x11_swapchain_result(chain, VK_WHATEVER)" - Handle wsi_queue_pull returning VK_TIMEOUT - Call x11_swapchain_result in x11_present_to_x11 Signed-off-by: Daniel Stone <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* vulkan/wsi/x11: Set OUT_OF_DATE if wait_for_special_event failsJason Ekstrand2018-02-211-1/+3
| | | | | | | | | This most likely means we lost our connection to the X server so OUT_OF_DATE is reasonable. This was also the one case where we pushed a UINT32_MAX into the queue without setting an error condition. Cc: [email protected] Reviewed-by: Daniel Stone <[email protected]>
* vulkan/wsi: Add modifiers support to wsi_create_native_imageJason Ekstrand2018-02-211-1/+2
| | | | | | | | | | This involves extending our fake extension a bit to allow for additional querying and passing of modifier information. The added bits are intended to look a lot like the draft of VK_EXT_image_drm_format_modifier. Once the extension gets finalized, we'll simply transition all of the structs used in wsi_common to the real extension structs. Reviewed-by: Daniel Stone <[email protected]>
* vulkan/wsi: Add multiple planes to wsi_imageDaniel Stone2018-02-211-4/+7
| | | | | | | Not currently used. Signed-off-by: Daniel Stone <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* vulkan/wsi: Drop the can_handle_different_gpu parameter from get_supportJason Ekstrand2017-12-041-5/+0
| | | | | | | Both anv and radv can handle prime now. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* vulkan/wsi: Move prime blitting into queue_presentJason Ekstrand2017-12-041-22/+3
| | | | | | | | This lets us save a QueueSubmit and it also makes prime a lot less X11-specific. Also, it means we can only wait on the semaphores once instead of on every blit. Reviewed-by: Dave Airlie <[email protected]>
* vulkan/wsi: Move get_images into common codeJason Ekstrand2017-12-041-24/+5
| | | | | | | | | This moves bits out of all four corners (anv, radv, x11, wayland) and into the wsi common code. We also switch to using an outarray to ensure we get our return code right. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* vulkan/wsi: Do image creation in common codeJason Ekstrand2017-12-041-17/+3
| | | | | | | | | | | This uses the mock extension created in a previous commit to tell the driver that the image it's just been asked to create is, in fact, a window system image with whatever assumptions that implies. There was a lot of redundant code between the two drivers to do basically exactly the same thing. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* vulkan/wsi: Implement prime in a completely generic wayJason Ekstrand2017-12-041-48/+39
| | | | | Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* vulkan/wsi: Add wsi_swapchain_init/finish functionsJason Ekstrand2017-12-041-2/+11
| | | | | Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* vulkan/wsi/x11: Handle the geometry check earlier in create_swapchainJason Ekstrand2017-12-041-9/+10
| | | | | | | | | This fixes a potential leak if allocating the swapchain fails. Since geometry checking and bit-depth fetching is self-contained, it makes sense to just do it first so we can delete the geometry reply. Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* vulkan/wsi: Add a wsi_image structureDaniel Stone2017-12-041-32/+20
| | | | | | | | | | | | | This is used to hold information about the allocated image, rather than an ever-growing function argument list. v2 (Jason Ekstrand): - Rename wsi_image_base to wsi_image Signed-off-by: Daniel Stone <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Chad Versace <[email protected]>
* vulkan/wsi: Free the event in x11_manage_fifo_queues().Henri Verbeet2017-10-171-0/+1
| | | | | | | | Cc: [email protected] Signed-off-by: Henri Verbeet <[email protected]> Fixes: e73d136a023 ("vulkan/wsi/x11: Implement FIFO mode.") Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]
* util/vulkan: Move Vulkan utilities to src/vulkan/utilAlex Smith2017-06-061-1/+1
| | | | | | | | | | | | | We have Vulkan utilities in both src/util and src/vulkan/util. The latter seems a more appropriate place for Vulkan-specific things, so move them there. v2: Android build system changes (from Tapani Pälli) Signed-off-by: Alex Smith <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Acked-by: Jason Ekstrand <[email protected]>
* vulkan/wsi/x11: Add support for VK_KHR_get_surface_capabilities2Jason Ekstrand2017-05-161-0/+32
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* vulkan/wsi: Use vk_outarray for surface_get_formatsJason Ekstrand2017-05-161-11/+12
| | | | Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
* vulkan/wsi: Plumb present regions through the common codeJason Ekstrand2017-04-031-1/+2
| | | | | | Reviewed-by: Lionel Landwerlin <[email protected]> Reviewed-by: Daniel Stone <[email protected]> Acked-by: Dave Airlie <[email protected]>
* vulkan/wsi: Improve the DRI3 error messageJacob Lifshay2017-03-011-10/+41
| | | | | | | | | | | | | | | | | This commit improves the message by telling them that they could probably enable DRI3. More importantly, it includes a little heuristic to check to see if we're running on AMD or NVIDIA's proprietary X11 drivers and, if we are, doesn't emit the warning. This way, users with both a discrete card and Intel graphics don't get the warning when they're just running on the discrete card. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99715 Co-authored-by: Jason Ekstrand <[email protected]> Reviewed-by: Kai Wasserbäch <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Tested-by: Rene Lindsay <[email protected]> Acked-by: Dave Airlie <[email protected]> Cc: "17.0" <[email protected]>
* vulkan/wsi/radv: add initial prime support (v1.1)Dave Airlie2017-02-271-5/+55
| | | | | | | | | | | | | | | | | | | This is a complete rewrite of my previous rfc patches. This adds the ability to present to a different GPU that rendering using a driver side operation that can copy from the tiled to linear shared image. This does prime support completely in the swapchain present code, and each queue has a precreated command buffer for each image and for the each queue family. This means presenting should work on graphics and compute queues and transfer in the future. v1.1: initialise needs_linear_copy in swapchain. Reviewed-by: Bas Nieuwenhuizen <[email protected]> Tested-by: Mike Lothian <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* vulkan/wsi: move image count to shared structure.Dave Airlie2017-02-231-15/+14
| | | | | | | | | For prime support I need to access this, so move it in advance. [airlied: fix int->uint32_t] Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* vulkan/wsi/x11: add support to detect if we can support rendering (v3)Dave Airlie2017-02-201-1/+70
| | | | | | | | | | | | | | | | | This adds support to radv_GetPhysicalDeviceXlibPresentationSupportKHR and radv_GetPhysicalDeviceXcbPresentationSupportKHR to check if the local device file descriptor is compatible with the descriptor retrieved from the X server via DRI3. This will stop radv binding to an X server until we have prime support in place. Hopefully apps use this API before trying to render things. v2: drop unneeded function, don't leak memory. (jekstrand) v3: also check in surface_get_support callback. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* vulkan/wsi: Lower the maximum image sizesJason Ekstrand2017-01-251-1/+2
| | | | | Reviewed-by: Lionel Landwerlin <[email protected]> Cc: "17.0" <[email protected]>
* vulkan/wsi: clarify the severity of lack of DRI3 v2Andres Rodriguez2017-01-191-2/+4
| | | | | | | | | | | | | The current message sounds like a small warning, clarify that it can result in lack of presentation support and application crashes. v2: add "if they do" (Bas) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98263 Signed-off-by: Andres Rodriguez <[email protected]> Acked-by: Jason ekstrand <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* vulkan: Add new cast macros for VkIcd typesChad Versace2017-01-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can't import the latest vk_icd.h because the new header breaks the Mesa build. This patch defines new casting macros, ICD_DEFINE_NONDISP_HANDLE_CASTS() and ICD_FROM_HANDLE(), which can handle both the old and new vk_icd.h, and will prevent the build from breaking when we update the header. In the old vk_icd.h, types were defined as: typedef struct _VkIcdFoo { ... } VkIcdFoo; Commit 6ebba1f6 in the Vulkan loader changed the above to typedef { ... } VkIcdFoo; because the old definitions violated the C and C++ specs. According to the specs, identifiers that begins with an underscore followed by an uppercase letter are reserved. (It's pedantic, I know), See the Github issue referenced below. References: https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/issues/7 References: https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/commit/6ebba1f630015af7a78767a15c1e74ba9b23601c Reviewed-by: Emil Velikov <[email protected]> Cc: [email protected]
* vulkan/wsi/x11: don't crash on null wsi x11 connectionArda Coskunses2016-12-221-0/+3
| | | | | | | | | Without this check driver crash when application window closed unexpectedly. Acked-by: Edward O'Callaghan <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Cc: "13.0" <[email protected]>
* vulkan/wsi/x11: don't crash on null visualArda Coskunses2016-12-221-0/+3
| | | | | | | | | | When application window closed unexpectedly due to lost window visualtypes getting invlaid parameters which is causing a crash. Necessary check is added to prevent the crash. Reviewed-by: Jason Ekstrand <[email protected]> Cc: "13.0" <[email protected]>
* vulkan: use STATIC_ASSERT instead of static_assertEdward O'Callaghan2016-12-071-1/+1
| | | | | | | | Following the spirit of commit 23d1799f, fixes compilation warnings on Android build due to lack of C11 features. Signed-off-by: Edward O'Callaghan <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* vulkan/wsi/x11: Destroy Present event context when destroying swapchainMichel Dänzer2016-11-301-0/+6
| | | | | | | | | | | | | | Without this, the X server may accumulate stale Present event contexts if a client creates and destroys multiple swapchains using the same window. v2: Based on Chris Wilson's review: * Use xcb_present_select_input_checked so that protocol errors generated by old X servers can be handled gracefully * Use xcb_discard_reply() instead of free(xcb_request_check()) v3: Rebased on top of this code having been refactored out of anv Reviewed-by: Dave Airlie <[email protected]>
* wsi: fix VK_INCOMPLETE for vkGetSwapchainImagesKHRDave Airlie2016-11-161-5/+11
| | | | | | | | | This fixes the x11 and wayland backends to not assert: dEQP-VK.wsi.xcb.swapchain.get_images.incomplete Reviewed-by: Jason Ekstrand <[email protected]> Cc: "13.0" <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* vulkan/wsi/x11: Implement FIFO mode.Jason Ekstrand2016-11-101-10/+164
| | | | | | | | | | | This implements VK_PRESENT_MODE_FIFO_KHR for X11. Unfortunately, due to the way the present extension works, we have to manage the queue of presented images in a separate thread. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Cc: "13.0" <[email protected]>
* vulkan/wsi: Report the correct min/maxImageCountJason Ekstrand2016-11-101-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | From the Vulkan spec 1.0.32 section 29.6 docs for vkAcquireNextImageKHR: "Let n be the total number of images in the swapchain, m be the value of VkSurfaceCapabilitiesKHR::minImageCount, and a be the number of presentable images that the application has currently acquired (i.e. images acquired with vkAcquireNextImageKHR, but not yet presented with vkQueuePresentKHR). vkAcquireNextImageKHR can always succeed if a ≤ n - m at the time vkAcquireNextImageKHR is called. vkAcquireNextImageKHR should not be called if a > n - m with a timeout of UINT64_MAX; in such a case, vkAcquireNextImageKHR may block indefinitely." With minImageCount == 2 (as it was previously, the client is allowed to acquire all but one image withoutblocking. If we really need 4 images for mailbox mode + pageflipping, then we need to request a minimum of 4 images up-front. This is a bit unfortunate because it means we will always consume 4 images. In the future, we may be able to optimize this a bit by waiting until the server starts to flip and returning OUT_OF_DATE to get the client to re-allocate with more images or something like that. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Cc: "13.0" <[email protected]>
* vulkan/wsi/x11: Clean up connections in finish_wsiJason Ekstrand2016-11-021-0/+4
| | | | | | | Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Cc: "13.0" <[email protected]>
* vulkan/wsi/x11: Better handle wsi_x11_connection_create failureJason Ekstrand2016-11-021-0/+2
| | | | | | | | | | Without this fix, the function would still end up returning NULL but it would put that NULL connection in the hash table which would be bad. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Cc: "13.0" <[email protected]>
* vulkan/wsi/x11: Smplify implementation of vkGetPhysicalDeviceSurfaceFormatsKHREduardo Lima Mitev2016-10-281-8/+3
| | | | | | | | This patch simplifies x11_surface_get_formats(). It is actually just a readability improvement over the patch I provided earlier this week (750d8cad72). Reviewed-by: Eric Engestrom <[email protected]>
* vulkan/wsi/x11: Fix behavior of vkGetPhysicalDeviceSurfacePresentModesKHREduardo Lima Mitev2016-10-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | x11_surface_get_present_modes() is currently asserting that the number of elements in pPresentModeCount must be greater than or equal to the number of present modes available. This is buggy because pPresentModeCount elements are later copied from the internal modes' array, so if pPresentModeCount is greater, it will overflow it. On top of that, this assertion violates the spec. From the Vulkan 1.0 (revision 32, with KHR extensions), page 581 of the PDF: "If the value of pPresentModeCount is less than the number of presentation modes supported, at most pPresentModeCount values will be written. If pPresentModeCount is smaller than the number of presentation modes supported for the given surface, VK_INCOMPLETE will be returned instead of VK_SUCCESS to indicate that not all the available values were returned." So, the correct behavior is: if pPresentModeCount is greater than the internal number of formats, it is clamped to that many present modes. But if it is lesser than that, then pPresentModeCount elements are copied, and the call returns VK_INCOMPLETE. This fix is similar (but simpler and more readable) than the one I provided in 750d8cad72a for vkGetPhysicalDeviceSurfaceFormatsKHR, which was suffering from the same problem. Reviewed-by: Eric Engestrom <[email protected]>
* vulkan/wsi/x11: add support for IMMEDIATE present modeDave Airlie2016-10-271-1/+3
| | | | | | | | We shouldn't be using ASYNC here, that would be used for immediate mode, so let's implement that. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* vulkan/wsi: store present mode in swapchain base classDave Airlie2016-10-271-0/+1
| | | | | | | | This just moves this up a level as x11 will need it to implement things properly. Reviewed-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* vulkan/wsi/x11: handle timeouts properly in next image acquire (v1.1)Dave Airlie2016-10-271-5/+57
| | | | | | | | | | | | | For 0 timeout, just poll for an event, and if none, return For UINT64_MAX timeout, just wait for special event blocked For other timeouts get the xcb fd and block on it, decreasing the timeout if we get woken up for non-special events. v1.1: return VK_TIMEOUT for poll timeouts. handle timeout going negative. Reviewed-by: Edward O'Callaghan <[email protected]> Signed-off-by: Dave Airlie <[email protected]>