Re: [Mesa-dev] [PATCH 1/3] vl/dri3: handle the case of different GPU(v4.2)

2016-09-20 Thread Mike Lothian
I'm running libva-1.7.2 but I notice this commit in git
https://cgit.freedesktop.org/vaapi/libva/commit/?id=a55ea7cb3143d57c8dba1b76ccea3511ea69adf2
but
that looks like it might only work with wayland

On Tue, 20 Sep 2016 at 14:40 Christian König 
wrote:

> Sounds like your version of libva ignores the DRI_PRIME environment
> parameter.
>
> Not sure what to do with this, but clearly a loader and not a driver
> problem.
>
> Regards,
> Christian.
>
>
> Am 20.09.2016 um 15:36 schrieb Mike Lothian:
>
> Here's what I currently have:
>
> fireburn@axion ~ $ DRI_PRIME=1 vainfo
> libva info: VA-API version 0.39.3
> libva info: va_getDriverName() returns 0
> libva info: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
> libva info: Found init function __vaDriverInit_0_39
> libva info: va_openDriver() returns 0
> vainfo: VA-API version: 0.39 (libva 1.7.2)
> vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.7.2
> vainfo: Supported profile and entrypoints
>   VAProfileMPEG2Simple: VAEntrypointVLD
>   VAProfileMPEG2Simple: VAEntrypointEncSlice
>   VAProfileMPEG2Main  : VAEntrypointVLD
>   VAProfileMPEG2Main  : VAEntrypointEncSlice
>   VAProfileH264ConstrainedBaseline: VAEntrypointVLD
>   VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
>   VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
>   VAProfileH264Main   : VAEntrypointVLD
>   VAProfileH264Main   : VAEntrypointEncSlice
>   VAProfileH264Main   : VAEntrypointEncSliceLP
>   VAProfileH264High   : VAEntrypointVLD
>   VAProfileH264High   : VAEntrypointEncSlice
>   VAProfileH264High   : VAEntrypointEncSliceLP
>   VAProfileH264MultiviewHigh  : VAEntrypointVLD
>   VAProfileH264MultiviewHigh  : VAEntrypointEncSlice
>   VAProfileH264StereoHigh : VAEntrypointVLD
>   VAProfileH264StereoHigh : VAEntrypointEncSlice
>   VAProfileVC1Simple  : VAEntrypointVLD
>   VAProfileVC1Main: VAEntrypointVLD
>   VAProfileVC1Advanced: VAEntrypointVLD
>   VAProfileNone   : VAEntrypointVideoProc
>   VAProfileJPEGBaseline   : VAEntrypointVLD
>   VAProfileJPEGBaseline   : VAEntrypointEncPicture
>   VAProfileVP8Version0_3  : VAEntrypointVLD
>   VAProfileVP8Version0_3  : VAEntrypointEncSlice
>   VAProfileHEVCMain   : VAEntrypointVLD
>   VAProfileHEVCMain   : VAEntrypointEncSlice
>
>
> which picks up the i965 driver despite the DRI_PRIME=1 paramerter being
> fed in - I have to manually specify LIBVA_DRIVER_NAME=radeonsi in order to
> get it to get the details out of vainfo - the same goes for vdpauinfo
>
> fireburn@axion ~ $ LIBVA_DRIVER_NAME=radeonsi DRI_PRIME=1 vainfo
> libva info: VA-API version 0.39.3
> libva info: va_getDriverName() returns 0
> libva info: User requested driver 'radeonsi'
> libva info: Trying to open /usr/lib64/va/drivers/radeonsi_drv_video.so
> libva info: Found init function __vaDriverInit_0_39
> libva info: va_openDriver() returns 0
> vainfo: VA-API version: 0.39 (libva 1.7.2)
> vainfo: Driver version: mesa gallium vaapi
> vainfo: Supported profile and entrypoints
>   VAProfileMPEG2Simple: VAEntrypointVLD
>   VAProfileMPEG2Main  : VAEntrypointVLD
>   VAProfileVC1Simple  : VAEntrypointVLD
>   VAProfileVC1Main: VAEntrypointVLD
>   VAProfileVC1Advanced: VAEntrypointVLD
>   VAProfileH264Baseline   : VAEntrypointVLD
>   VAProfileH264Baseline   : VAEntrypointEncSlice
>   VAProfileH264Main   : VAEntrypointVLD
>   VAProfileH264Main   : VAEntrypointEncSlice
>   VAProfileH264High   : VAEntrypointVLD
>   VAProfileH264High   : VAEntrypointEncSlice
>   VAProfileNone   : VAEntrypointVideoProc
>
>
> On Tue, 20 Sep 2016 at 14:13 Nayan Deshmukh 
> wrote:
>
>> Hi Mike,
>>
>>
>> On Tue, Sep 20, 2016 at 5:45 PM, Mike Lothian 
>> wrote:
>>
>>> Hi
>>>
>>> I've just confirmed this works for getting details from vainfo and
>>> vdpauinfo using DRI_PRIME=1 without needing to set up offloading with xrandr
>>>
>>> I do however need to specify the driver still, is that something being
>>> worked on? It would be great if it autoselected based on the card running
>>> at DRI_PRIME=1 (or x if there's more than one card)
>>>
>>> I have a prime system and I don't need to specify any drivers in my
>> system.
>> Though I am not the right person to answer this question.
>> Maybe Michel can answer this.
>>
>> Cheers,
>> Nayan
>>
>>> Cheers
>>>
>>> Mike
>>>
>>> On Tue, 20 Sep 2016 at 05:52 Nayan Deshmukh 
>>> wrote:
>>>
 In case of 

Re: [Mesa-dev] [PATCH 1/3] vl/dri3: handle the case of different GPU(v4.2)

2016-09-20 Thread Christian König
Sounds like your version of libva ignores the DRI_PRIME environment 
parameter.


Not sure what to do with this, but clearly a loader and not a driver 
problem.


Regards,
Christian.

Am 20.09.2016 um 15:36 schrieb Mike Lothian:

Here's what I currently have:

fireburn@axion ~ $ DRI_PRIME=1 vainfo
libva info: VA-API version 0.39.3
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.2)
vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.7.2
vainfo: Supported profile and entrypoints
  VAProfileMPEG2Simple: VAEntrypointVLD
  VAProfileMPEG2Simple: VAEntrypointEncSlice
  VAProfileMPEG2Main  : VAEntrypointVLD
  VAProfileMPEG2Main  : VAEntrypointEncSlice
  VAProfileH264ConstrainedBaseline: VAEntrypointVLD
  VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
  VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
  VAProfileH264Main   : VAEntrypointVLD
  VAProfileH264Main   : VAEntrypointEncSlice
  VAProfileH264Main   : VAEntrypointEncSliceLP
  VAProfileH264High   : VAEntrypointVLD
  VAProfileH264High   : VAEntrypointEncSlice
  VAProfileH264High   : VAEntrypointEncSliceLP
  VAProfileH264MultiviewHigh  : VAEntrypointVLD
  VAProfileH264MultiviewHigh  : VAEntrypointEncSlice
  VAProfileH264StereoHigh : VAEntrypointVLD
  VAProfileH264StereoHigh : VAEntrypointEncSlice
  VAProfileVC1Simple  : VAEntrypointVLD
  VAProfileVC1Main: VAEntrypointVLD
  VAProfileVC1Advanced: VAEntrypointVLD
  VAProfileNone   : VAEntrypointVideoProc
  VAProfileJPEGBaseline   : VAEntrypointVLD
  VAProfileJPEGBaseline   : VAEntrypointEncPicture
  VAProfileVP8Version0_3  : VAEntrypointVLD
  VAProfileVP8Version0_3  : VAEntrypointEncSlice
  VAProfileHEVCMain   : VAEntrypointVLD
  VAProfileHEVCMain   : VAEntrypointEncSlice


which picks up the i965 driver despite the DRI_PRIME=1 paramerter 
being fed in - I have to manually specify LIBVA_DRIVER_NAME=radeonsi 
in order to get it to get the details out of vainfo - the same goes 
for vdpauinfo


fireburn@axion ~ $ LIBVA_DRIVER_NAME=radeonsi DRI_PRIME=1 vainfo
libva info: VA-API version 0.39.3
libva info: va_getDriverName() returns 0
libva info: User requested driver 'radeonsi'
libva info: Trying to open /usr/lib64/va/drivers/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.2)
vainfo: Driver version: mesa gallium vaapi
vainfo: Supported profile and entrypoints
  VAProfileMPEG2Simple: VAEntrypointVLD
  VAProfileMPEG2Main  : VAEntrypointVLD
  VAProfileVC1Simple  : VAEntrypointVLD
  VAProfileVC1Main: VAEntrypointVLD
  VAProfileVC1Advanced: VAEntrypointVLD
  VAProfileH264Baseline   : VAEntrypointVLD
  VAProfileH264Baseline   : VAEntrypointEncSlice
  VAProfileH264Main   : VAEntrypointVLD
  VAProfileH264Main   : VAEntrypointEncSlice
  VAProfileH264High   : VAEntrypointVLD
  VAProfileH264High   : VAEntrypointEncSlice
  VAProfileNone   : VAEntrypointVideoProc


On Tue, 20 Sep 2016 at 14:13 Nayan Deshmukh > wrote:


Hi Mike,


On Tue, Sep 20, 2016 at 5:45 PM, Mike Lothian > wrote:

Hi

I've just confirmed this works for getting details from vainfo
and vdpauinfo using DRI_PRIME=1 without needing to set up
offloading with xrandr

I do however need to specify the driver still, is that
something being worked on? It would be great if it
autoselected based on the card running at DRI_PRIME=1 (or x if
there's more than one card)

I have a prime system and I don't need to specify any drivers in
my system.
Though I am not the right person to answer this question.
Maybe Michel can answer this.

Cheers,
Nayan

Cheers

Mike

On Tue, 20 Sep 2016 at 05:52 Nayan Deshmukh
>
wrote:

In case of prime when rendering is done on GPU other then the
server GPU, use a seprate linear buffer for each back buffer
which will be displayed using present extension.

v2: Use a seprate linear buffer for each back buffer (Michel)
v3: 

Re: [Mesa-dev] [PATCH 1/3] vl/dri3: handle the case of different GPU(v4.2)

2016-09-20 Thread Mike Lothian
Here's what I currently have:

fireburn@axion ~ $ DRI_PRIME=1 vainfo
libva info: VA-API version 0.39.3
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/va/drivers/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.2)
vainfo: Driver version: Intel i965 driver for Intel(R) Skylake - 1.7.2
vainfo: Supported profile and entrypoints
  VAProfileMPEG2Simple: VAEntrypointVLD
  VAProfileMPEG2Simple: VAEntrypointEncSlice
  VAProfileMPEG2Main  : VAEntrypointVLD
  VAProfileMPEG2Main  : VAEntrypointEncSlice
  VAProfileH264ConstrainedBaseline: VAEntrypointVLD
  VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
  VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
  VAProfileH264Main   : VAEntrypointVLD
  VAProfileH264Main   : VAEntrypointEncSlice
  VAProfileH264Main   : VAEntrypointEncSliceLP
  VAProfileH264High   : VAEntrypointVLD
  VAProfileH264High   : VAEntrypointEncSlice
  VAProfileH264High   : VAEntrypointEncSliceLP
  VAProfileH264MultiviewHigh  : VAEntrypointVLD
  VAProfileH264MultiviewHigh  : VAEntrypointEncSlice
  VAProfileH264StereoHigh : VAEntrypointVLD
  VAProfileH264StereoHigh : VAEntrypointEncSlice
  VAProfileVC1Simple  : VAEntrypointVLD
  VAProfileVC1Main: VAEntrypointVLD
  VAProfileVC1Advanced: VAEntrypointVLD
  VAProfileNone   : VAEntrypointVideoProc
  VAProfileJPEGBaseline   : VAEntrypointVLD
  VAProfileJPEGBaseline   : VAEntrypointEncPicture
  VAProfileVP8Version0_3  : VAEntrypointVLD
  VAProfileVP8Version0_3  : VAEntrypointEncSlice
  VAProfileHEVCMain   : VAEntrypointVLD
  VAProfileHEVCMain   : VAEntrypointEncSlice


which picks up the i965 driver despite the DRI_PRIME=1 paramerter being fed
in - I have to manually specify LIBVA_DRIVER_NAME=radeonsi in order to get
it to get the details out of vainfo - the same goes for vdpauinfo

fireburn@axion ~ $ LIBVA_DRIVER_NAME=radeonsi DRI_PRIME=1 vainfo
libva info: VA-API version 0.39.3
libva info: va_getDriverName() returns 0
libva info: User requested driver 'radeonsi'
libva info: Trying to open /usr/lib64/va/drivers/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_0_39
libva info: va_openDriver() returns 0
vainfo: VA-API version: 0.39 (libva 1.7.2)
vainfo: Driver version: mesa gallium vaapi
vainfo: Supported profile and entrypoints
  VAProfileMPEG2Simple: VAEntrypointVLD
  VAProfileMPEG2Main  : VAEntrypointVLD
  VAProfileVC1Simple  : VAEntrypointVLD
  VAProfileVC1Main: VAEntrypointVLD
  VAProfileVC1Advanced: VAEntrypointVLD
  VAProfileH264Baseline   : VAEntrypointVLD
  VAProfileH264Baseline   : VAEntrypointEncSlice
  VAProfileH264Main   : VAEntrypointVLD
  VAProfileH264Main   : VAEntrypointEncSlice
  VAProfileH264High   : VAEntrypointVLD
  VAProfileH264High   : VAEntrypointEncSlice
  VAProfileNone   : VAEntrypointVideoProc


On Tue, 20 Sep 2016 at 14:13 Nayan Deshmukh 
wrote:

> Hi Mike,
>
>
> On Tue, Sep 20, 2016 at 5:45 PM, Mike Lothian  wrote:
>
>> Hi
>>
>> I've just confirmed this works for getting details from vainfo and
>> vdpauinfo using DRI_PRIME=1 without needing to set up offloading with xrandr
>>
>> I do however need to specify the driver still, is that something being
>> worked on? It would be great if it autoselected based on the card running
>> at DRI_PRIME=1 (or x if there's more than one card)
>>
>> I have a prime system and I don't need to specify any drivers in my
> system.
> Though I am not the right person to answer this question.
> Maybe Michel can answer this.
>
> Cheers,
> Nayan
>
>> Cheers
>>
>> Mike
>>
>> On Tue, 20 Sep 2016 at 05:52 Nayan Deshmukh 
>> wrote:
>>
>>> In case of prime when rendering is done on GPU other then the
>>> server GPU, use a seprate linear buffer for each back buffer
>>> which will be displayed using present extension.
>>>
>>> v2: Use a seprate linear buffer for each back buffer (Michel)
>>> v3: Change variable names and fix coding style (Leo and Emil)
>>> v4: Use PIPE_BIND_SAMPLER_VIEW for back buffer in case when
>>> a seprate linear buffer is used (Michel)
>>> v4.1: remove empty line
>>> v4.2: destroy the context and handle the case when
>>>   create_context fails (Emil)
>>>
>>> Signed-off-by: Nayan Deshmukh 
>>> Reviewed-by: Leo Liu 
>>> Acked-by: Michel Dänzer 

Re: [Mesa-dev] [PATCH 1/3] vl/dri3: handle the case of different GPU(v4.2)

2016-09-20 Thread Nayan Deshmukh
Hi Mike,


On Tue, Sep 20, 2016 at 5:45 PM, Mike Lothian  wrote:

> Hi
>
> I've just confirmed this works for getting details from vainfo and
> vdpauinfo using DRI_PRIME=1 without needing to set up offloading with xrandr
>
> I do however need to specify the driver still, is that something being
> worked on? It would be great if it autoselected based on the card running
> at DRI_PRIME=1 (or x if there's more than one card)
>
> I have a prime system and I don't need to specify any drivers in my
system.
Though I am not the right person to answer this question.
Maybe Michel can answer this.

Cheers,
Nayan

> Cheers
>
> Mike
>
> On Tue, 20 Sep 2016 at 05:52 Nayan Deshmukh 
> wrote:
>
>> In case of prime when rendering is done on GPU other then the
>> server GPU, use a seprate linear buffer for each back buffer
>> which will be displayed using present extension.
>>
>> v2: Use a seprate linear buffer for each back buffer (Michel)
>> v3: Change variable names and fix coding style (Leo and Emil)
>> v4: Use PIPE_BIND_SAMPLER_VIEW for back buffer in case when
>> a seprate linear buffer is used (Michel)
>> v4.1: remove empty line
>> v4.2: destroy the context and handle the case when
>>   create_context fails (Emil)
>>
>> Signed-off-by: Nayan Deshmukh 
>> Reviewed-by: Leo Liu 
>> Acked-by: Michel Dänzer 
>> ---
>>  src/gallium/auxiliary/vl/vl_winsys_dri3.c | 66
>> +--
>>  1 file changed, 53 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
>> b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
>> index 3d596a6..191a64b 100644
>> --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
>> +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
>> @@ -49,6 +49,7 @@
>>  struct vl_dri3_buffer
>>  {
>> struct pipe_resource *texture;
>> +   struct pipe_resource *linear_texture;
>>
>> uint32_t pixmap;
>> uint32_t sync_fence;
>> @@ -69,6 +70,8 @@ struct vl_dri3_screen
>> xcb_present_event_t eid;
>> xcb_special_event_t *special_event;
>>
>> +   struct pipe_context *pipe;
>> +
>> struct vl_dri3_buffer *back_buffers[BACK_BUFFER_NUM];
>> int cur_back;
>>
>> @@ -82,6 +85,7 @@ struct vl_dri3_screen
>> int64_t last_ust, ns_frame, last_msc, next_msc;
>>
>> bool flushed;
>> +   bool is_different_gpu;
>>  };
>>
>>  static void
>> @@ -102,6 +106,8 @@ dri3_free_back_buffer(struct vl_dri3_screen *scrn,
>> xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence);
>> xshmfence_unmap_shm(buffer->shm_fence);
>> pipe_resource_reference(>texture, NULL);
>> +   if (buffer->linear_texture)
>> +   pipe_resource_reference(>linear_texture, NULL);
>> FREE(buffer);
>>  }
>>
>> @@ -209,7 +215,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
>> xcb_sync_fence_t sync_fence;
>> struct xshmfence *shm_fence;
>> int buffer_fd, fence_fd;
>> -   struct pipe_resource templ;
>> +   struct pipe_resource templ, *pixmap_buffer_texture;
>> struct winsys_handle whandle;
>> unsigned usage;
>>
>> @@ -226,8 +232,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
>>goto close_fd;
>>
>> memset(, 0, sizeof(templ));
>> -   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
>> -PIPE_BIND_SCANOUT | PIPE_BIND_SHARED;
>> +   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
>> templ.format = PIPE_FORMAT_B8G8R8X8_UNORM;
>> templ.target = PIPE_TEXTURE_2D;
>> templ.last_level = 0;
>> @@ -235,16 +240,34 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
>> templ.height0 = scrn->height;
>> templ.depth0 = 1;
>> templ.array_size = 1;
>> -   buffer->texture = scrn->base.pscreen->resource_
>> create(scrn->base.pscreen,
>> - );
>> -   if (!buffer->texture)
>> -  goto unmap_shm;
>>
>> +   if (scrn->is_different_gpu) {
>> +  buffer->texture = scrn->base.pscreen->resource_
>> create(scrn->base.pscreen,
>> +);
>> +  if (!buffer->texture)
>> + goto unmap_shm;
>> +
>> +  templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED |
>> +PIPE_BIND_LINEAR;
>> +  buffer->linear_texture = scrn->base.pscreen->resource_
>> create(scrn->base.pscreen,
>> +
>> );
>> +  pixmap_buffer_texture = buffer->linear_texture;
>> +
>> +  if (!buffer->linear_texture)
>> + goto no_linear_texture;
>> +   } else {
>> +  templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED;
>> +  buffer->texture = scrn->base.pscreen->resource_
>> create(scrn->base.pscreen,
>> +);
>> +  if (!buffer->texture)
>> + goto unmap_shm;
>> +  pixmap_buffer_texture = buffer->texture;
>> +   }
>> memset(, 0, sizeof(whandle));
>> whandle.type= 

Re: [Mesa-dev] [PATCH 1/3] vl/dri3: handle the case of different GPU(v4.2)

2016-09-20 Thread Mike Lothian
Hi

I've just confirmed this works for getting details from vainfo and
vdpauinfo using DRI_PRIME=1 without needing to set up offloading with xrandr

I do however need to specify the driver still, is that something being
worked on? It would be great if it autoselected based on the card running
at DRI_PRIME=1 (or x if there's more than one card)

Cheers

Mike

On Tue, 20 Sep 2016 at 05:52 Nayan Deshmukh 
wrote:

> In case of prime when rendering is done on GPU other then the
> server GPU, use a seprate linear buffer for each back buffer
> which will be displayed using present extension.
>
> v2: Use a seprate linear buffer for each back buffer (Michel)
> v3: Change variable names and fix coding style (Leo and Emil)
> v4: Use PIPE_BIND_SAMPLER_VIEW for back buffer in case when
> a seprate linear buffer is used (Michel)
> v4.1: remove empty line
> v4.2: destroy the context and handle the case when
>   create_context fails (Emil)
>
> Signed-off-by: Nayan Deshmukh 
> Reviewed-by: Leo Liu 
> Acked-by: Michel Dänzer 
> ---
>  src/gallium/auxiliary/vl/vl_winsys_dri3.c | 66
> +--
>  1 file changed, 53 insertions(+), 13 deletions(-)
>
> diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> index 3d596a6..191a64b 100644
> --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> @@ -49,6 +49,7 @@
>  struct vl_dri3_buffer
>  {
> struct pipe_resource *texture;
> +   struct pipe_resource *linear_texture;
>
> uint32_t pixmap;
> uint32_t sync_fence;
> @@ -69,6 +70,8 @@ struct vl_dri3_screen
> xcb_present_event_t eid;
> xcb_special_event_t *special_event;
>
> +   struct pipe_context *pipe;
> +
> struct vl_dri3_buffer *back_buffers[BACK_BUFFER_NUM];
> int cur_back;
>
> @@ -82,6 +85,7 @@ struct vl_dri3_screen
> int64_t last_ust, ns_frame, last_msc, next_msc;
>
> bool flushed;
> +   bool is_different_gpu;
>  };
>
>  static void
> @@ -102,6 +106,8 @@ dri3_free_back_buffer(struct vl_dri3_screen *scrn,
> xcb_sync_destroy_fence(scrn->conn, buffer->sync_fence);
> xshmfence_unmap_shm(buffer->shm_fence);
> pipe_resource_reference(>texture, NULL);
> +   if (buffer->linear_texture)
> +   pipe_resource_reference(>linear_texture, NULL);
> FREE(buffer);
>  }
>
> @@ -209,7 +215,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
> xcb_sync_fence_t sync_fence;
> struct xshmfence *shm_fence;
> int buffer_fd, fence_fd;
> -   struct pipe_resource templ;
> +   struct pipe_resource templ, *pixmap_buffer_texture;
> struct winsys_handle whandle;
> unsigned usage;
>
> @@ -226,8 +232,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
>goto close_fd;
>
> memset(, 0, sizeof(templ));
> -   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW |
> -PIPE_BIND_SCANOUT | PIPE_BIND_SHARED;
> +   templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
> templ.format = PIPE_FORMAT_B8G8R8X8_UNORM;
> templ.target = PIPE_TEXTURE_2D;
> templ.last_level = 0;
> @@ -235,16 +240,34 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn)
> templ.height0 = scrn->height;
> templ.depth0 = 1;
> templ.array_size = 1;
> -   buffer->texture =
> scrn->base.pscreen->resource_create(scrn->base.pscreen,
> - );
> -   if (!buffer->texture)
> -  goto unmap_shm;
>
> +   if (scrn->is_different_gpu) {
> +  buffer->texture =
> scrn->base.pscreen->resource_create(scrn->base.pscreen,
> +);
> +  if (!buffer->texture)
> + goto unmap_shm;
> +
> +  templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED |
> +PIPE_BIND_LINEAR;
> +  buffer->linear_texture =
> scrn->base.pscreen->resource_create(scrn->base.pscreen,
> +  );
> +  pixmap_buffer_texture = buffer->linear_texture;
> +
> +  if (!buffer->linear_texture)
> + goto no_linear_texture;
> +   } else {
> +  templ.bind |= PIPE_BIND_SCANOUT | PIPE_BIND_SHARED;
> +  buffer->texture =
> scrn->base.pscreen->resource_create(scrn->base.pscreen,
> +);
> +  if (!buffer->texture)
> + goto unmap_shm;
> +  pixmap_buffer_texture = buffer->texture;
> +   }
> memset(, 0, sizeof(whandle));
> whandle.type= DRM_API_HANDLE_TYPE_FD;
> usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ;
> scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL,
> -   buffer->texture, ,
> +   pixmap_buffer_texture,
> ,
> usage);
>