<div dir="auto"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Abimathi Natarajan</strong> <span dir="ltr"><<a href="mailto:abimathi08@gmail.com">abimathi08@gmail.com</a>></span><br>Date: Thu, Feb 7, 2019, 6:27 PM<br>Subject: Re: [cairo] cairo_paint() with GPU Buffer<br>To: Uli Schlachter <<a href="mailto:psychon@znc.in">psychon@znc.in</a>><br></div><br><br><div dir="ltr"><div dir="auto"><p style="margin-top:0px;margin-bottom:0px"><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">Hi,</span></p>
<p style="margin-top:0px;margin-bottom:0px"><br>
</p>
<p style="margin-top:0px;margin-bottom:0px"><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">My sample code contains two parts,
<br>
</span></p>
<p style="margin-top:0px;margin-bottom:0px"><br><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"></span></p><p style="margin-top:0px;margin-bottom:0px">PART 1</p><p style="margin-top:0px;margin-bottom:0px">------------<br>
</p>
<ul style="margin-bottom:0px;margin-top:0px"><li><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">Decoding an input file using ffmpeg and get raw buffers (GPU allocated within FFMPEG ) in rgb32 format</span><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">.
 My code does exactly what the below ffmpeg command does.</span><br>
</li></ul>

<pre class="m_8221002412132779190gmail-x_wiki"><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">               <span style="background-color:rgb(255,255,0)">ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i input.mp4 </span></span><br><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt;background-color:rgb(255,255,0)"><span style="background-color:rgb(255,255,255)">       </span><span style="background-color:rgb(255,255,255)">        </span>-vf 'scale_vaapi,hwmap=mode=read+write+direct,format=rgb32' output.rgb</span><br><br><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">         The above command will decode the input file (input.mp4) with hardware accelerations(vaapi) and </span><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"><span style="background-color:rgb(255,255,0)">hwmap</span> will directly map the hardware </span><br><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">         frames to system memory.</span><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"><br><br></span></pre><pre class="m_8221002412132779190gmail-x_wiki"><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">PART 2<br>----------<br></span></pre>
<ul style="margin-bottom:0px;margin-top:0px"><li><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">I will directly feed this memory to
</span></li></ul>
<pre class="m_8221002412132779190gmail-x_wiki"><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"></span><div><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"><span style="background-color:rgb(255,255,255)">  </span><span style="background-color:rgb(255,255,0)"><span style="background-color:rgb(255,255,255)"> </span><span style="background-color:rgb(255,255,255)"><span style="background-color:rgb(255,255,255)"> </span>           </span> cairo_image_surface_create_for_data ((unsigned char *)buffer, CAIRO_FORMAT_ARGB32,width, height, stride)</span> to create a cairo_surface for the given frame.</span></div><div><ul style="margin-bottom:0px;margin-top:0px"><li><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"> </span><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">cairo_paint() in </span><a href="https://github.com/wayland-project/weston/blob/master/clients/image.c#L160" rel="noopener noreferrer noreferrer" class="m_8221002412132779190gmail-x_OWAAutoLink" id="m_8221002412132779190gmail-LPlnk875368" target="_blank"><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">https://github.com/wayland-project/weston/blob/master/clients/image.c#L160</span></a><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"> </span><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">will paint the cairo_surface over weston compositor.</span><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt"> <br></span></li><li><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">When we measured the time taken by this API to paint the GPU buffer, </span><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">we observed it took approximately 400 ms to paint a single 4k frame.</span></li><li><span style="font-family:Calibri,Helvetica,sans-serif,serif,"EmojiFont";font-size:11pt">The github link is not my actual sample code, However my application uses similar flow only. (I'm using cairo with weston compositor).</span></li></ul><div><br></div></div><div><br></div></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 6, 2019, 12:40 AM Uli Schlachter <<a href="mailto:psychon@znc.in" target="_blank" rel="noreferrer">psychon@znc.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On 05.02.19 07:16, Abimathi Natarajan wrote:<br>
> I'm implementing a sample program with Weston to render video (decoded<br>
> using ffmpeg VAAPI)  frames using Cairo graphics.<br>
> Each frame is of 4k size<br>
<br>
How complicated is your example program? Do you have a link to it or can<br>
you send it by mail?<br>
<br>
> I'm passing GPU buffer directly to cairo_image_surface_create_for_data() to<br>
> create a cairo_surface for each frame.<br>
> When I render the buffer using cairo_paint() , the API is taking<br>
> approximately 400 ms for each buffer.<br>
<br>
Uhm, can you tell us more about the cairo_paint() call? I assume you are<br>
copying from the image surface that you created. Where are you copying<br>
to? Is it just the call to cairo_paint() that takes so long or did you<br>
measure more than just that?<br>
<br>
Also, what exactly does "I'm passing GPU buffer directly" mean? Is the<br>
GPU memory directly accessible to the CPU? If so, I would expect this to<br>
be uncached and slow, which is why I am asking.<br>
<br>
Cheers,<br>
Uli<br>
-- <br>
Homophobia - The fear that another man will treat you the way you treat<br>
women.<br>
</blockquote></div>
</div>