Re: [Mesa-dev] [PATCH 1/2] vulkan/wsi: move image count to shared structure.

2017-02-21 Thread Dave Airlie
On 21 February 2017 at 23:06, Edward O'Callaghan
 wrote:
> wait, why is this needed at all Dave?
>
> The application should be querying and picking the correct GPU as you
> well know. This seems unwise to tamper with the mechanism defined by the
> specification.

how do you propose we get the frames from the discrete GPU to the
integrated GPU for display then?

This doesn't actaully tamper with the querying or picking, the layer I
am hoping to write will do that.

Dave.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] vulkan/wsi: move image count to shared structure.

2017-02-21 Thread Jason Ekstrand
On Tue, Feb 21, 2017 at 5:06 AM, Edward O'Callaghan <
funfunc...@folklore1984.net> wrote:

> wait, why is this needed at all Dave?
>
> The application should be querying and picking the correct GPU as you
> well know. This seems unwise to tamper with the mechanism defined by the
> specification.
>

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.

--Jason


> Kindly,
> Edward.
>
> On 02/21/2017 01:47 PM, Jason Ekstrand wrote:
> > Fine by me
> >
> > Reviewed-by: Jason Ekstrand  > >
> >
> > On Mon, Feb 20, 2017 at 6:26 PM, Dave Airlie  > > wrote:
> >
> > From: Dave Airlie >
> >
> > For prime support I need to access this, so move it in advance.
> >
> > Signed-off-by: Dave Airlie  > >
> > ---
> >  src/vulkan/wsi/wsi_common.h |  1 +
> >  src/vulkan/wsi/wsi_common_wayland.c | 20 +---
> >  src/vulkan/wsi/wsi_common_x11.c | 29
> ++---
> >  3 files changed, 24 insertions(+), 26 deletions(-)
> >
> > diff --git a/src/vulkan/wsi/wsi_common.h
> b/src/vulkan/wsi/wsi_common.h
> > index ae9e587..1a22935 100644
> > --- a/src/vulkan/wsi/wsi_common.h
> > +++ b/src/vulkan/wsi/wsi_common.h
> > @@ -54,6 +54,7 @@ struct wsi_swapchain {
> > const struct wsi_image_fns *image_fns;
> > VkFence fences[3];
> > VkPresentModeKHR present_mode;
> > +   int image_count;
> >
> > VkResult (*destroy)(struct wsi_swapchain *swapchain,
> > const VkAllocationCallbacks *pAllocator);
> > diff --git a/src/vulkan/wsi/wsi_common_wayland.c
> > b/src/vulkan/wsi/wsi_common_wayland.c
> > index 4489736..e6490ee 100644
> > --- a/src/vulkan/wsi/wsi_common_wayland.c
> > +++ b/src/vulkan/wsi/wsi_common_wayland.c
> > @@ -495,7 +495,6 @@ struct wsi_wl_swapchain {
> > VkPresentModeKHR present_mode;
> > bool fifo_ready;
> >
> > -   uint32_t image_count;
> > struct wsi_wl_image  images[0];
> >  };
> >
> > @@ -508,13 +507,13 @@ wsi_wl_swapchain_get_images(struct
> > wsi_swapchain *wsi_chain,
> > VkResult result;
> >
> > if (pSwapchainImages == NULL) {
> > -  *pCount = chain->image_count;
> > +  *pCount = chain->base.image_count;
> >return VK_SUCCESS;
> > }
> >
> > result = VK_SUCCESS;
> > -   ret_count = chain->image_count;
> > -   if (chain->image_count > *pCount) {
> > +   ret_count = chain->base.image_count;
> > +   if (chain->base.image_count > *pCount) {
> >   ret_count = *pCount;
> >   result = VK_INCOMPLETE;
> > }
> > @@ -543,7 +542,7 @@ wsi_wl_swapchain_acquire_next_image(struct
> > wsi_swapchain *wsi_chain,
> >return VK_ERROR_OUT_OF_DATE_KHR;
> >
> > while (1) {
> > -  for (uint32_t i = 0; i < chain->image_count; i++) {
> > +  for (uint32_t i = 0; i < chain->base.image_count; i++) {
> >   if (!chain->images[i].busy) {
> >  /* We found a non-busy image */
> >  *image_index = i;
> > @@ -591,7 +590,7 @@ wsi_wl_swapchain_queue_present(struct
> > wsi_swapchain *wsi_chain,
> >}
> > }
> >
> > -   assert(image_index < chain->image_count);
> > +   assert(image_index < chain->base.image_count);
> > wl_surface_attach(chain->surface,
> > chain->images[image_index].buffer, 0, 0);
> > wl_surface_damage(chain->surface, 0, 0, INT32_MAX, INT32_MAX);
> >
> > @@ -679,7 +678,7 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain
> > *wsi_chain,
> >  {
> > struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain
> > *)wsi_chain;
> >
> > -   for (uint32_t i = 0; i < chain->image_count; i++) {
> > +   for (uint32_t i = 0; i < chain->base.image_count; i++) {
> >if (chain->images[i].buffer)
> >   chain->base.image_fns->free_wsi_image(chain->base.device,
> > pAllocator,
> >
>  chain->images[i].image,
> > @@ -724,6 +723,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase
> > *icd_surface,
> > chain->base.queue_present = wsi_wl_swapchain_queue_present;
> > chain->base.image_fns = image_fns;
> > chain->base.present_mode = pCreateInfo->presentMode;

Re: [Mesa-dev] [PATCH 1/2] vulkan/wsi: move image count to shared structure.

2017-02-21 Thread Jason Ekstrand
On Tue, Feb 21, 2017 at 1:01 AM, Gustaw Smolarczyk 
wrote:

> 21 lut 2017 03:47 "Jason Ekstrand"  napisał(a):
>
> Fine by me
>
> Reviewed-by: Jason Ekstrand 
>
> On Mon, Feb 20, 2017 at 6:26 PM, Dave Airlie  wrote:
>
>> From: Dave Airlie 
>>
>> For prime support I need to access this, so move it in advance.
>>
>> Signed-off-by: Dave Airlie 
>> ---
>>  src/vulkan/wsi/wsi_common.h |  1 +
>>  src/vulkan/wsi/wsi_common_wayland.c | 20 +---
>>  src/vulkan/wsi/wsi_common_x11.c | 29 ++---
>>  3 files changed, 24 insertions(+), 26 deletions(-)
>>
>> diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
>> index ae9e587..1a22935 100644
>> --- a/src/vulkan/wsi/wsi_common.h
>> +++ b/src/vulkan/wsi/wsi_common.h
>> @@ -54,6 +54,7 @@ struct wsi_swapchain {
>> const struct wsi_image_fns *image_fns;
>> VkFence fences[3];
>> VkPresentModeKHR present_mode;
>> +   int image_count;
>>
>> VkResult (*destroy)(struct wsi_swapchain *swapchain,
>> const VkAllocationCallbacks *pAllocator);
>> diff --git a/src/vulkan/wsi/wsi_common_wayland.c
>> b/src/vulkan/wsi/wsi_common_wayland.c
>> index 4489736..e6490ee 100644
>> --- a/src/vulkan/wsi/wsi_common_wayland.c
>> +++ b/src/vulkan/wsi/wsi_common_wayland.c
>> @@ -495,7 +495,6 @@ struct wsi_wl_swapchain {
>> VkPresentModeKHR present_mode;
>> bool fifo_ready;
>>
>> -   uint32_t image_count;
>> struct wsi_wl_image  images[0];
>>  };
>>
>> @@ -508,13 +507,13 @@ wsi_wl_swapchain_get_images(struct wsi_swapchain
>> *wsi_chain,
>> VkResult result;
>>
>> if (pSwapchainImages == NULL) {
>> -  *pCount = chain->image_count;
>> +  *pCount = chain->base.image_count;
>>return VK_SUCCESS;
>> }
>>
>> result = VK_SUCCESS;
>> -   ret_count = chain->image_count;
>> -   if (chain->image_count > *pCount) {
>> +   ret_count = chain->base.image_count;
>> +   if (chain->base.image_count > *pCount) {
>>   ret_count = *pCount;
>>   result = VK_INCOMPLETE;
>> }
>> @@ -543,7 +542,7 @@ wsi_wl_swapchain_acquire_next_image(struct
>> wsi_swapchain *wsi_chain,
>>return VK_ERROR_OUT_OF_DATE_KHR;
>>
>> while (1) {
>> -  for (uint32_t i = 0; i < chain->image_count; i++) {
>> +  for (uint32_t i = 0; i < chain->base.image_count; i++) {
>>
>
> Looks like a comparison between signed and unsigned. Not sure if you care
> about this (it produces a warning at -Wall or -Wextra IIRC).
>

Good point.  All we need to do is tweak it to store a uint32_t instead of
an int.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] vulkan/wsi: move image count to shared structure.

2017-02-21 Thread Edward O'Callaghan
wait, why is this needed at all Dave?

The application should be querying and picking the correct GPU as you
well know. This seems unwise to tamper with the mechanism defined by the
specification.

Kindly,
Edward.

On 02/21/2017 01:47 PM, Jason Ekstrand wrote:
> Fine by me
> 
> Reviewed-by: Jason Ekstrand  >
> 
> On Mon, Feb 20, 2017 at 6:26 PM, Dave Airlie  > wrote:
> 
> From: Dave Airlie >
> 
> For prime support I need to access this, so move it in advance.
> 
> Signed-off-by: Dave Airlie  >
> ---
>  src/vulkan/wsi/wsi_common.h |  1 +
>  src/vulkan/wsi/wsi_common_wayland.c | 20 +---
>  src/vulkan/wsi/wsi_common_x11.c | 29 ++---
>  3 files changed, 24 insertions(+), 26 deletions(-)
> 
> diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
> index ae9e587..1a22935 100644
> --- a/src/vulkan/wsi/wsi_common.h
> +++ b/src/vulkan/wsi/wsi_common.h
> @@ -54,6 +54,7 @@ struct wsi_swapchain {
> const struct wsi_image_fns *image_fns;
> VkFence fences[3];
> VkPresentModeKHR present_mode;
> +   int image_count;
> 
> VkResult (*destroy)(struct wsi_swapchain *swapchain,
> const VkAllocationCallbacks *pAllocator);
> diff --git a/src/vulkan/wsi/wsi_common_wayland.c
> b/src/vulkan/wsi/wsi_common_wayland.c
> index 4489736..e6490ee 100644
> --- a/src/vulkan/wsi/wsi_common_wayland.c
> +++ b/src/vulkan/wsi/wsi_common_wayland.c
> @@ -495,7 +495,6 @@ struct wsi_wl_swapchain {
> VkPresentModeKHR present_mode;
> bool fifo_ready;
> 
> -   uint32_t image_count;
> struct wsi_wl_image  images[0];
>  };
> 
> @@ -508,13 +507,13 @@ wsi_wl_swapchain_get_images(struct
> wsi_swapchain *wsi_chain,
> VkResult result;
> 
> if (pSwapchainImages == NULL) {
> -  *pCount = chain->image_count;
> +  *pCount = chain->base.image_count;
>return VK_SUCCESS;
> }
> 
> result = VK_SUCCESS;
> -   ret_count = chain->image_count;
> -   if (chain->image_count > *pCount) {
> +   ret_count = chain->base.image_count;
> +   if (chain->base.image_count > *pCount) {
>   ret_count = *pCount;
>   result = VK_INCOMPLETE;
> }
> @@ -543,7 +542,7 @@ wsi_wl_swapchain_acquire_next_image(struct
> wsi_swapchain *wsi_chain,
>return VK_ERROR_OUT_OF_DATE_KHR;
> 
> while (1) {
> -  for (uint32_t i = 0; i < chain->image_count; i++) {
> +  for (uint32_t i = 0; i < chain->base.image_count; i++) {
>   if (!chain->images[i].busy) {
>  /* We found a non-busy image */
>  *image_index = i;
> @@ -591,7 +590,7 @@ wsi_wl_swapchain_queue_present(struct
> wsi_swapchain *wsi_chain,
>}
> }
> 
> -   assert(image_index < chain->image_count);
> +   assert(image_index < chain->base.image_count);
> wl_surface_attach(chain->surface,
> chain->images[image_index].buffer, 0, 0);
> wl_surface_damage(chain->surface, 0, 0, INT32_MAX, INT32_MAX);
> 
> @@ -679,7 +678,7 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain
> *wsi_chain,
>  {
> struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain
> *)wsi_chain;
> 
> -   for (uint32_t i = 0; i < chain->image_count; i++) {
> +   for (uint32_t i = 0; i < chain->base.image_count; i++) {
>if (chain->images[i].buffer)
>   chain->base.image_fns->free_wsi_image(chain->base.device,
> pAllocator,
> chain->images[i].image,
> @@ -724,6 +723,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase
> *icd_surface,
> chain->base.queue_present = wsi_wl_swapchain_queue_present;
> chain->base.image_fns = image_fns;
> chain->base.present_mode = pCreateInfo->presentMode;
> +   chain->base.image_count = num_images;
> chain->surface = surface->surface;
> chain->extent = pCreateInfo->imageExtent;
> chain->vk_format = pCreateInfo->imageFormat;
> @@ -731,12 +731,10 @@
> wsi_wl_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
> 
> chain->fifo_ready = true;
> 
> -   chain->image_count = num_images;
> -
> /* Mark a bunch of stuff as NULL.  This way we can just call
>  * destroy_swapchain for cleanup.
>  */
> -   for (uint32_t i = 0; i < chain->image_count; i++)
> +   for (uint32_t i = 0; i < chain->base.image_count; i++)
>

Re: [Mesa-dev] [PATCH 1/2] vulkan/wsi: move image count to shared structure.

2017-02-21 Thread Gustaw Smolarczyk
21 lut 2017 03:47 "Jason Ekstrand"  napisał(a):

Fine by me

Reviewed-by: Jason Ekstrand 

On Mon, Feb 20, 2017 at 6:26 PM, Dave Airlie  wrote:

> From: Dave Airlie 
>
> For prime support I need to access this, so move it in advance.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/vulkan/wsi/wsi_common.h |  1 +
>  src/vulkan/wsi/wsi_common_wayland.c | 20 +---
>  src/vulkan/wsi/wsi_common_x11.c | 29 ++---
>  3 files changed, 24 insertions(+), 26 deletions(-)
>
> diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
> index ae9e587..1a22935 100644
> --- a/src/vulkan/wsi/wsi_common.h
> +++ b/src/vulkan/wsi/wsi_common.h
> @@ -54,6 +54,7 @@ struct wsi_swapchain {
> const struct wsi_image_fns *image_fns;
> VkFence fences[3];
> VkPresentModeKHR present_mode;
> +   int image_count;
>
> VkResult (*destroy)(struct wsi_swapchain *swapchain,
> const VkAllocationCallbacks *pAllocator);
> diff --git a/src/vulkan/wsi/wsi_common_wayland.c
> b/src/vulkan/wsi/wsi_common_wayland.c
> index 4489736..e6490ee 100644
> --- a/src/vulkan/wsi/wsi_common_wayland.c
> +++ b/src/vulkan/wsi/wsi_common_wayland.c
> @@ -495,7 +495,6 @@ struct wsi_wl_swapchain {
> VkPresentModeKHR present_mode;
> bool fifo_ready;
>
> -   uint32_t image_count;
> struct wsi_wl_image  images[0];
>  };
>
> @@ -508,13 +507,13 @@ wsi_wl_swapchain_get_images(struct wsi_swapchain
> *wsi_chain,
> VkResult result;
>
> if (pSwapchainImages == NULL) {
> -  *pCount = chain->image_count;
> +  *pCount = chain->base.image_count;
>return VK_SUCCESS;
> }
>
> result = VK_SUCCESS;
> -   ret_count = chain->image_count;
> -   if (chain->image_count > *pCount) {
> +   ret_count = chain->base.image_count;
> +   if (chain->base.image_count > *pCount) {
>   ret_count = *pCount;
>   result = VK_INCOMPLETE;
> }
> @@ -543,7 +542,7 @@ wsi_wl_swapchain_acquire_next_image(struct
> wsi_swapchain *wsi_chain,
>return VK_ERROR_OUT_OF_DATE_KHR;
>
> while (1) {
> -  for (uint32_t i = 0; i < chain->image_count; i++) {
> +  for (uint32_t i = 0; i < chain->base.image_count; i++) {
>

Looks like a comparison between signed and unsigned. Not sure if you care
about this (it produces a warning at -Wall or -Wextra IIRC).

Regards,
Gustaw
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] vulkan/wsi: move image count to shared structure.

2017-02-20 Thread Jason Ekstrand
Fine by me

Reviewed-by: Jason Ekstrand 

On Mon, Feb 20, 2017 at 6:26 PM, Dave Airlie  wrote:

> From: Dave Airlie 
>
> For prime support I need to access this, so move it in advance.
>
> Signed-off-by: Dave Airlie 
> ---
>  src/vulkan/wsi/wsi_common.h |  1 +
>  src/vulkan/wsi/wsi_common_wayland.c | 20 +---
>  src/vulkan/wsi/wsi_common_x11.c | 29 ++---
>  3 files changed, 24 insertions(+), 26 deletions(-)
>
> diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
> index ae9e587..1a22935 100644
> --- a/src/vulkan/wsi/wsi_common.h
> +++ b/src/vulkan/wsi/wsi_common.h
> @@ -54,6 +54,7 @@ struct wsi_swapchain {
> const struct wsi_image_fns *image_fns;
> VkFence fences[3];
> VkPresentModeKHR present_mode;
> +   int image_count;
>
> VkResult (*destroy)(struct wsi_swapchain *swapchain,
> const VkAllocationCallbacks *pAllocator);
> diff --git a/src/vulkan/wsi/wsi_common_wayland.c
> b/src/vulkan/wsi/wsi_common_wayland.c
> index 4489736..e6490ee 100644
> --- a/src/vulkan/wsi/wsi_common_wayland.c
> +++ b/src/vulkan/wsi/wsi_common_wayland.c
> @@ -495,7 +495,6 @@ struct wsi_wl_swapchain {
> VkPresentModeKHR present_mode;
> bool fifo_ready;
>
> -   uint32_t image_count;
> struct wsi_wl_image  images[0];
>  };
>
> @@ -508,13 +507,13 @@ wsi_wl_swapchain_get_images(struct wsi_swapchain
> *wsi_chain,
> VkResult result;
>
> if (pSwapchainImages == NULL) {
> -  *pCount = chain->image_count;
> +  *pCount = chain->base.image_count;
>return VK_SUCCESS;
> }
>
> result = VK_SUCCESS;
> -   ret_count = chain->image_count;
> -   if (chain->image_count > *pCount) {
> +   ret_count = chain->base.image_count;
> +   if (chain->base.image_count > *pCount) {
>   ret_count = *pCount;
>   result = VK_INCOMPLETE;
> }
> @@ -543,7 +542,7 @@ wsi_wl_swapchain_acquire_next_image(struct
> wsi_swapchain *wsi_chain,
>return VK_ERROR_OUT_OF_DATE_KHR;
>
> while (1) {
> -  for (uint32_t i = 0; i < chain->image_count; i++) {
> +  for (uint32_t i = 0; i < chain->base.image_count; i++) {
>   if (!chain->images[i].busy) {
>  /* We found a non-busy image */
>  *image_index = i;
> @@ -591,7 +590,7 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain
> *wsi_chain,
>}
> }
>
> -   assert(image_index < chain->image_count);
> +   assert(image_index < chain->base.image_count);
> wl_surface_attach(chain->surface, chain->images[image_index].buffer,
> 0, 0);
> wl_surface_damage(chain->surface, 0, 0, INT32_MAX, INT32_MAX);
>
> @@ -679,7 +678,7 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain
> *wsi_chain,
>  {
> struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
>
> -   for (uint32_t i = 0; i < chain->image_count; i++) {
> +   for (uint32_t i = 0; i < chain->base.image_count; i++) {
>if (chain->images[i].buffer)
>   chain->base.image_fns->free_wsi_image(chain->base.device,
> pAllocator,
> chain->images[i].image,
> @@ -724,6 +723,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase
> *icd_surface,
> chain->base.queue_present = wsi_wl_swapchain_queue_present;
> chain->base.image_fns = image_fns;
> chain->base.present_mode = pCreateInfo->presentMode;
> +   chain->base.image_count = num_images;
> chain->surface = surface->surface;
> chain->extent = pCreateInfo->imageExtent;
> chain->vk_format = pCreateInfo->imageFormat;
> @@ -731,12 +731,10 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase
> *icd_surface,
>
> chain->fifo_ready = true;
>
> -   chain->image_count = num_images;
> -
> /* Mark a bunch of stuff as NULL.  This way we can just call
>  * destroy_swapchain for cleanup.
>  */
> -   for (uint32_t i = 0; i < chain->image_count; i++)
> +   for (uint32_t i = 0; i < chain->base.image_count; i++)
>chain->images[i].buffer = NULL;
> chain->queue = NULL;
>
> @@ -753,7 +751,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase
> *icd_surface,
>goto fail;
> }
>
> -   for (uint32_t i = 0; i < chain->image_count; i++) {
> +   for (uint32_t i = 0; i < chain->base.image_count; i++) {
>result = wsi_wl_image_init(chain, >images[i],
>   pCreateInfo, pAllocator);
>if (result != VK_SUCCESS)
> diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_
> x11.c
> index bec4907..9e19b10 100644
> --- a/src/vulkan/wsi/wsi_common_x11.c
> +++ b/src/vulkan/wsi/wsi_common_x11.c
> @@ -565,7 +565,6 @@ struct x11_swapchain {
> xcb_gc_t gc;
> uint32_t depth;
> 

[Mesa-dev] [PATCH 1/2] vulkan/wsi: move image count to shared structure.

2017-02-20 Thread Dave Airlie
From: Dave Airlie 

For prime support I need to access this, so move it in advance.

Signed-off-by: Dave Airlie 
---
 src/vulkan/wsi/wsi_common.h |  1 +
 src/vulkan/wsi/wsi_common_wayland.c | 20 +---
 src/vulkan/wsi/wsi_common_x11.c | 29 ++---
 3 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h
index ae9e587..1a22935 100644
--- a/src/vulkan/wsi/wsi_common.h
+++ b/src/vulkan/wsi/wsi_common.h
@@ -54,6 +54,7 @@ struct wsi_swapchain {
const struct wsi_image_fns *image_fns;
VkFence fences[3];
VkPresentModeKHR present_mode;
+   int image_count;
 
VkResult (*destroy)(struct wsi_swapchain *swapchain,
const VkAllocationCallbacks *pAllocator);
diff --git a/src/vulkan/wsi/wsi_common_wayland.c 
b/src/vulkan/wsi/wsi_common_wayland.c
index 4489736..e6490ee 100644
--- a/src/vulkan/wsi/wsi_common_wayland.c
+++ b/src/vulkan/wsi/wsi_common_wayland.c
@@ -495,7 +495,6 @@ struct wsi_wl_swapchain {
VkPresentModeKHR present_mode;
bool fifo_ready;
 
-   uint32_t image_count;
struct wsi_wl_image  images[0];
 };
 
@@ -508,13 +507,13 @@ wsi_wl_swapchain_get_images(struct wsi_swapchain 
*wsi_chain,
VkResult result;
 
if (pSwapchainImages == NULL) {
-  *pCount = chain->image_count;
+  *pCount = chain->base.image_count;
   return VK_SUCCESS;
}
 
result = VK_SUCCESS;
-   ret_count = chain->image_count;
-   if (chain->image_count > *pCount) {
+   ret_count = chain->base.image_count;
+   if (chain->base.image_count > *pCount) {
  ret_count = *pCount;
  result = VK_INCOMPLETE;
}
@@ -543,7 +542,7 @@ wsi_wl_swapchain_acquire_next_image(struct wsi_swapchain 
*wsi_chain,
   return VK_ERROR_OUT_OF_DATE_KHR;
 
while (1) {
-  for (uint32_t i = 0; i < chain->image_count; i++) {
+  for (uint32_t i = 0; i < chain->base.image_count; i++) {
  if (!chain->images[i].busy) {
 /* We found a non-busy image */
 *image_index = i;
@@ -591,7 +590,7 @@ wsi_wl_swapchain_queue_present(struct wsi_swapchain 
*wsi_chain,
   }
}
 
-   assert(image_index < chain->image_count);
+   assert(image_index < chain->base.image_count);
wl_surface_attach(chain->surface, chain->images[image_index].buffer, 0, 0);
wl_surface_damage(chain->surface, 0, 0, INT32_MAX, INT32_MAX);
 
@@ -679,7 +678,7 @@ wsi_wl_swapchain_destroy(struct wsi_swapchain *wsi_chain,
 {
struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
 
-   for (uint32_t i = 0; i < chain->image_count; i++) {
+   for (uint32_t i = 0; i < chain->base.image_count; i++) {
   if (chain->images[i].buffer)
  chain->base.image_fns->free_wsi_image(chain->base.device, pAllocator,
chain->images[i].image,
@@ -724,6 +723,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
chain->base.queue_present = wsi_wl_swapchain_queue_present;
chain->base.image_fns = image_fns;
chain->base.present_mode = pCreateInfo->presentMode;
+   chain->base.image_count = num_images;
chain->surface = surface->surface;
chain->extent = pCreateInfo->imageExtent;
chain->vk_format = pCreateInfo->imageFormat;
@@ -731,12 +731,10 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
 
chain->fifo_ready = true;
 
-   chain->image_count = num_images;
-
/* Mark a bunch of stuff as NULL.  This way we can just call
 * destroy_swapchain for cleanup.
 */
-   for (uint32_t i = 0; i < chain->image_count; i++)
+   for (uint32_t i = 0; i < chain->base.image_count; i++)
   chain->images[i].buffer = NULL;
chain->queue = NULL;
 
@@ -753,7 +751,7 @@ wsi_wl_surface_create_swapchain(VkIcdSurfaceBase 
*icd_surface,
   goto fail;
}
 
-   for (uint32_t i = 0; i < chain->image_count; i++) {
+   for (uint32_t i = 0; i < chain->base.image_count; i++) {
   result = wsi_wl_image_init(chain, >images[i],
  pCreateInfo, pAllocator);
   if (result != VK_SUCCESS)
diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c
index bec4907..9e19b10 100644
--- a/src/vulkan/wsi/wsi_common_x11.c
+++ b/src/vulkan/wsi/wsi_common_x11.c
@@ -565,7 +565,6 @@ struct x11_swapchain {
xcb_gc_t gc;
uint32_t depth;
VkExtent2D   extent;
-   uint32_t image_count;
 
xcb_present_event_t  event_id;
xcb_special_event_t *special_event;
@@ -591,13 +590,13 @@ x11_get_images(struct wsi_swapchain *anv_chain,
VkResult result;
 
if (pSwapchainImages ==