<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 21, 2017 at 5:06 AM, Edward O'Callaghan <span dir="ltr"><<a href="mailto:funfunctor@folklore1984.net" target="_blank">funfunctor@folklore1984.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">wait, why is this needed at all Dave?<br>
<br>
The application should be querying and picking the correct GPU as you<br>
well know. This seems unwise to tamper with the mechanism defined by the<br>
specification.<br></blockquote><div><br></div><div>Yes, and no. This is something we've been discussed quite a bit internally within Khronos. The crux of the problem is that there's no way, without something like prime, for an application to render with the discrete card and display on the integrated card. Also, we want some sort of mechanism for the user to set preferences about which applications land on which GPU regardless of which one is used for display.<br><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Kindly,<br>
Edward.<br>
<span class=""><br>
On 02/21/2017 01:47 PM, Jason Ekstrand wrote:<br>
> Fine by me<br>
><br>
> Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a><br>
</span>> <mailto:<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>>><br>
<span class="">><br>
> On Mon, Feb 20, 2017 at 6:26 PM, Dave Airlie <<a href="mailto:airlied@gmail.com">airlied@gmail.com</a><br>
</span>> <mailto:<a href="mailto:airlied@gmail.com">airlied@gmail.com</a>>> wrote:<br>
><br>
> From: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a> <mailto:<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>>><br>
<span class="">><br>
> For prime support I need to access this, so move it in advance.<br>
><br>
> Signed-off-by: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a><br>
</span>> <mailto:<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>>><br>
<div><div class="h5">> ---<br>
> src/vulkan/wsi/wsi_common.h | 1 +<br>
> src/vulkan/wsi/wsi_common_<wbr>wayland.c | 20 +++++++++-----------<br>
> src/vulkan/wsi/wsi_common_x11.<wbr>c | 29 ++++++++++++++---------------<br>
> 3 files changed, 24 insertions(+), 26 deletions(-)<br>
><br>
> diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h<br>
> index ae9e587..1a22935 100644<br>
> --- a/src/vulkan/wsi/wsi_common.h<br>
> +++ b/src/vulkan/wsi/wsi_common.h<br>
> @@ -54,6 +54,7 @@ struct wsi_swapchain {<br>
> const struct wsi_image_fns *image_fns;<br>
> VkFence fences[3];<br>
> VkPresentModeKHR present_mode;<br>
> + int image_count;<br>
><br>
> VkResult (*destroy)(struct wsi_swapchain *swapchain,<br>
> const VkAllocationCallbacks *pAllocator);<br>
> diff --git a/src/vulkan/wsi/wsi_common_<wbr>wayland.c<br>
> b/src/vulkan/wsi/wsi_common_<wbr>wayland.c<br>
> index 4489736..e6490ee 100644<br>
> --- a/src/vulkan/wsi/wsi_common_<wbr>wayland.c<br>
> +++ b/src/vulkan/wsi/wsi_common_<wbr>wayland.c<br>
> @@ -495,7 +495,6 @@ struct wsi_wl_swapchain {<br>
> VkPresentModeKHR present_mode;<br>
> bool fifo_ready;<br>
><br>
> - uint32_t image_count;<br>
> struct wsi_wl_image images[0];<br>
> };<br>
><br>
> @@ -508,13 +507,13 @@ wsi_wl_swapchain_get_images(<wbr>struct<br>
> wsi_swapchain *wsi_chain,<br>
> VkResult result;<br>
><br>
> if (pSwapchainImages == NULL) {<br>
> - *pCount = chain->image_count;<br>
> + *pCount = chain->base.image_count;<br>
> return VK_SUCCESS;<br>
> }<br>
><br>
> result = VK_SUCCESS;<br>
> - ret_count = chain->image_count;<br>
> - if (chain->image_count > *pCount) {<br>
> + ret_count = chain->base.image_count;<br>
> + if (chain->base.image_count > *pCount) {<br>
> ret_count = *pCount;<br>
> result = VK_INCOMPLETE;<br>
> }<br>
> @@ -543,7 +542,7 @@ wsi_wl_swapchain_acquire_next_<wbr>image(struct<br>
> wsi_swapchain *wsi_chain,<br>
> return VK_ERROR_OUT_OF_DATE_KHR;<br>
><br>
> while (1) {<br>
> - for (uint32_t i = 0; i < chain->image_count; i++) {<br>
> + for (uint32_t i = 0; i < chain->base.image_count; i++) {<br>
> if (!chain->images[i].busy) {<br>
> /* We found a non-busy image */<br>
> *image_index = i;<br>
> @@ -591,7 +590,7 @@ wsi_wl_swapchain_queue_<wbr>present(struct<br>
> wsi_swapchain *wsi_chain,<br>
> }<br>
> }<br>
><br>
> - assert(image_index < chain->image_count);<br>
> + assert(image_index < chain->base.image_count);<br>
> wl_surface_attach(chain-><wbr>surface,<br>
> chain->images[image_index].<wbr>buffer, 0, 0);<br>
> wl_surface_damage(chain-><wbr>surface, 0, 0, INT32_MAX, INT32_MAX);<br>
><br>
> @@ -679,7 +678,7 @@ wsi_wl_swapchain_destroy(<wbr>struct wsi_swapchain<br>
> *wsi_chain,<br>
> {<br>
> struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain<br>
> *)wsi_chain;<br>
><br>
> - for (uint32_t i = 0; i < chain->image_count; i++) {<br>
> + for (uint32_t i = 0; i < chain->base.image_count; i++) {<br>
> if (chain->images[i].buffer)<br>
> chain->base.image_fns->free_<wbr>wsi_image(chain->base.device,<br>
> pAllocator,<br>
> chain->images[i].image,<br>
> @@ -724,6 +723,7 @@ wsi_wl_surface_create_<wbr>swapchain(VkIcdSurfaceBase<br>
> *icd_surface,<br>
> chain->base.queue_present = wsi_wl_swapchain_queue_<wbr>present;<br>
> chain->base.image_fns = image_fns;<br>
> chain->base.present_mode = pCreateInfo->presentMode;<br>
> + chain->base.image_count = num_images;<br>
> chain->surface = surface->surface;<br>
> chain->extent = pCreateInfo->imageExtent;<br>
> chain->vk_format = pCreateInfo->imageFormat;<br>
> @@ -731,12 +731,10 @@<br>
> wsi_wl_surface_create_<wbr>swapchain(VkIcdSurfaceBase *icd_surface,<br>
><br>
> chain->fifo_ready = true;<br>
><br>
> - chain->image_count = num_images;<br>
> -<br>
> /* Mark a bunch of stuff as NULL. This way we can just call<br>
> * destroy_swapchain for cleanup.<br>
> */<br>
> - for (uint32_t i = 0; i < chain->image_count; i++)<br>
> + for (uint32_t i = 0; i < chain->base.image_count; i++)<br>
> chain->images[i].buffer = NULL;<br>
> chain->queue = NULL;<br>
><br>
> @@ -753,7 +751,7 @@ wsi_wl_surface_create_<wbr>swapchain(VkIcdSurfaceBase<br>
> *icd_surface,<br>
> goto fail;<br>
> }<br>
><br>
> - for (uint32_t i = 0; i < chain->image_count; i++) {<br>
> + for (uint32_t i = 0; i < chain->base.image_count; i++) {<br>
> result = wsi_wl_image_init(chain, &chain->images[i],<br>
> pCreateInfo, pAllocator);<br>
> if (result != VK_SUCCESS)<br>
> diff --git a/src/vulkan/wsi/wsi_common_<wbr>x11.c<br>
> b/src/vulkan/wsi/wsi_common_<wbr>x11.c<br>
> index bec4907..9e19b10 100644<br>
> --- a/src/vulkan/wsi/wsi_common_<wbr>x11.c<br>
> +++ b/src/vulkan/wsi/wsi_common_<wbr>x11.c<br>
> @@ -565,7 +565,6 @@ struct x11_swapchain {<br>
> xcb_gc_t gc;<br>
> uint32_t depth;<br>
> VkExtent2D extent;<br>
> - uint32_t image_count;<br>
><br>
> xcb_present_event_t event_id;<br>
> xcb_special_event_t * special_event;<br>
> @@ -591,13 +590,13 @@ x11_get_images(struct wsi_swapchain *anv_chain,<br>
> VkResult result;<br>
><br>
> if (pSwapchainImages == NULL) {<br>
> - *pCount = chain->image_count;<br>
> + *pCount = chain->base.image_count;<br>
> return VK_SUCCESS;<br>
> }<br>
><br>
> result = VK_SUCCESS;<br>
> - ret_count = chain->image_count;<br>
> - if (chain->image_count > *pCount) {<br>
> + ret_count = chain->base.image_count;<br>
> + if (chain->base.image_count > *pCount) {<br>
> ret_count = *pCount;<br>
> result = VK_INCOMPLETE;<br>
> }<br>
> @@ -626,7 +625,7 @@ x11_handle_dri3_present_event(<wbr>struct<br>
> x11_swapchain *chain,<br>
> case XCB_PRESENT_EVENT_IDLE_NOTIFY: {<br>
> xcb_present_idle_notify_event_<wbr>t *idle = (void *) event;<br>
><br>
> - for (unsigned i = 0; i < chain->image_count; i++) {<br>
> + for (unsigned i = 0; i < chain->base.image_count; i++) {<br>
> if (chain->images[i].pixmap == idle->pixmap) {<br>
> chain->images[i].busy = false;<br>
> if (chain->threaded)<br>
> @@ -680,7 +679,7 @@ x11_acquire_next_image_poll_<wbr>x11(struct<br>
> x11_swapchain *chain,<br>
> struct pollfd pfds;<br>
> uint64_t atimeout;<br>
> while (1) {<br>
> - for (uint32_t i = 0; i < chain->image_count; i++) {<br>
> + for (uint32_t i = 0; i < chain->base.image_count; i++) {<br>
> if (!chain->images[i].busy) {<br>
> /* We found a non-busy image */<br>
> xshmfence_await(chain->images[<wbr>i].shm_fence);<br>
> @@ -747,7 +746,7 @@ x11_acquire_next_image_from_<wbr>queue(struct<br>
> x11_swapchain *chain,<br>
> return chain->status;<br>
> }<br>
><br>
> - assert(image_index < chain->image_count);<br>
> + assert(image_index < chain->base.image_count);<br>
> xshmfence_await(chain->images[<wbr>image_index].shm_fence);<br>
><br>
> *image_index_out = image_index;<br>
> @@ -761,7 +760,7 @@ x11_present_to_x11(struct x11_swapchain *chain,<br>
> uint32_t image_index,<br>
> {<br>
> struct x11_image *image = &chain->images[image_index];<br>
><br>
> - assert(image_index < chain->image_count);<br>
> + assert(image_index < chain->base.image_count);<br>
><br>
> uint32_t options = XCB_PRESENT_OPTION_NONE;<br>
><br>
> @@ -971,7 +970,7 @@ x11_swapchain_destroy(struct wsi_swapchain<br>
> *anv_chain,<br>
> struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;<br>
> xcb_void_cookie_t cookie;<br>
><br>
> - for (uint32_t i = 0; i < chain->image_count; i++)<br>
> + for (uint32_t i = 0; i < chain->base.image_count; i++)<br>
> x11_image_finish(chain, pAllocator, &chain->images[i]);<br>
><br>
> if (chain->threaded) {<br>
> @@ -1032,11 +1031,11 @@<br>
> x11_surface_create_swapchain(<wbr>VkIcdSurfaceBase *icd_surface,<br>
> chain->base.queue_present = x11_queue_present;<br>
> chain->base.image_fns = image_fns;<br>
> chain->base.present_mode = pCreateInfo->presentMode;<br>
> + chain->base.image_count = num_images;<br>
> chain->conn = conn;<br>
> chain->window = window;<br>
> chain->depth = geometry->depth;<br>
> chain->extent = pCreateInfo->imageExtent;<br>
> - chain->image_count = num_images;<br>
> chain->send_sbc = 0;<br>
> chain->last_present_msc = 0;<br>
> chain->threaded = false;<br>
> @@ -1072,7 +1071,7 @@ x11_surface_create_swapchain(<wbr>VkIcdSurfaceBase<br>
> *icd_surface,<br>
> xcb_discard_reply(chain->conn, cookie.sequence);<br>
><br>
> uint32_t image = 0;<br>
> - for (; image < chain->image_count; image++) {<br>
> + for (; image < chain->base.image_count; image++) {<br>
> result = x11_image_init(device, chain, pCreateInfo, pAllocator,<br>
> &chain->images[image]);<br>
> if (result != VK_SUCCESS)<br>
> @@ -1082,23 +1081,23 @@<br>
> x11_surface_create_swapchain(<wbr>VkIcdSurfaceBase *icd_surface,<br>
> if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR) {<br>
> chain->threaded = true;<br>
><br>
> - /* Initialize our queues. We make them image_count + 1<br>
> because we will<br>
> + /* Initialize our queues. We make them base.image_count + 1<br>
> because we will<br>
> * occasionally use UINT32_MAX to signal the other thread<br>
> that an error<br>
> * has occurred and we don't want an overflow.<br>
> */<br>
> int ret;<br>
> - ret = wsi_queue_init(&chain-><wbr>acquire_queue,<br>
> chain->image_count + 1);<br>
> + ret = wsi_queue_init(&chain-><wbr>acquire_queue,<br>
> chain->base.image_count + 1);<br>
> if (ret) {<br>
> goto fail_init_images;<br>
> }<br>
><br>
> - ret = wsi_queue_init(&chain-><wbr>present_queue,<br>
> chain->image_count + 1);<br>
> + ret = wsi_queue_init(&chain-><wbr>present_queue,<br>
> chain->base.image_count + 1);<br>
> if (ret) {<br>
> wsi_queue_destroy(&chain-><wbr>acquire_queue);<br>
> goto fail_init_images;<br>
> }<br>
><br>
> - for (unsigned i = 0; i < chain->image_count; i++)<br>
> + for (unsigned i = 0; i < chain->base.image_count; i++)<br>
> wsi_queue_push(&chain-><wbr>acquire_queue, i);<br>
><br>
> ret = pthread_create(&chain->queue_<wbr>manager, NULL,<br>
> --<br>
> 2.9.3<br>
><br>
> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
</div></div>> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a> <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.<wbr>freedesktop.org</a>><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
> <<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.<wbr>org/mailman/listinfo/mesa-dev</a>><br>
<div class="HOEnZb"><div class="h5">><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
><br>
<br>
</div></div></blockquote></div><br></div></div>