<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Zero copy between GPU and VPU in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044160#M153757</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the code sample. It was helpful insofar as showing how to map memory from vpudec into a texture.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But as I mentioned, I also need to encode the texture data afterwards, using imxvpuenc_h264. This is why I'm looking at the virtual framebuffer solution from that thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My gstreamer pipeline looks like this:&lt;/P&gt;&lt;P&gt;imxv4l2videosrc device=/dev/video1 input=0 fps=30/1 ! "image/jpeg, width=1920,height=1080, framerate=30/1" ! queue max-size-bytes=0 max-size-time=0 max-size-buffers=0 ! imxvpudec ! zerocopygpuoverlay ! imxvpuenc_h264 bitrate=14000 ! h264parse&amp;nbsp; ! mp4mux ! filesink location=/videos/out.mp4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where "zerocopygpuoverlay" is my custom element, modifying the yuv data directly without copying it into or out from the texture.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Jul 2020 09:27:21 GMT</pubDate>
    <dc:creator>erlend_eriksen</dc:creator>
    <dc:date>2020-07-01T09:27:21Z</dc:date>
    <item>
      <title>Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044158#M153755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to take physical buffers from the imxvpudec gstreamer element, and modify them using the GPU with GLES and EGL, before passing them to the VPU encoder with imxvpuenc_h264.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For passing the memory used by the decoder to the GPU, I assume I can use the glTexDirectVIVMap function as here:&amp;nbsp;&lt;A class="link-titled" href="https://github.com/Freescale/gstreamer-imx/blob/master/src/eglvivsink/gles2_renderer.c#L722" title="https://github.com/Freescale/gstreamer-imx/blob/master/src/eglvivsink/gles2_renderer.c#L722"&gt;gstreamer-imx/gles2_renderer.c at master · Freescale/gstreamer-imx · GitHub&lt;/A&gt;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I am not so sure how to pass the memory to the encoder after having modified it with the GPU.&amp;nbsp;I saw this thread:&amp;nbsp;&lt;A href="https://community.nxp.com/thread/309677"&gt;Texture input to video encoder?&lt;/A&gt;&amp;nbsp; . However it is from 2013, so I guess some things may have changed since then.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The accepted solution in the thread was to use the virtual framebuffer from here:&amp;nbsp;&lt;A href="https://github.com/Freescale/linux-module-virtfb" title="https://github.com/Freescale/linux-module-virtfb"&gt;GitHub - Freescale/linux-module-virtfb: Virtual frame buffer driver for iMX devices&lt;/A&gt;&amp;nbsp;&amp;nbsp;. Is this still the recommended approach? In that case, I guess some updates are in order since it seg faults on initialization. My error trace is here:&amp;nbsp;&lt;A class="link-titled" href="https://github.com/Freescale/linux-module-virtfb/issues/2" title="https://github.com/Freescale/linux-module-virtfb/issues/2"&gt;Segmentation fault on module initialization · Issue #2 · Freescale/linux-module-virtfb · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the same thread, &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/AndreSilva"&gt;AndreSilva&lt;/A&gt;‌ says that the&amp;nbsp;&lt;SPAN&gt;glTexDirectVIV function can't be used to get a pointer that can be read from, so I can't pass it to the vpu encoder. However, maybe such a function has been implemented since then?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2020 15:37:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044158#M153755</guid>
      <dc:creator>erlend_eriksen</dc:creator>
      <dc:date>2020-06-30T15:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044159#M153756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erlend,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That was a different topic, I believe you are looking for glTextDirectVIVMap extension, this one should be able to do what you need. Please, use the attached code for reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;andre&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jun 2020 15:56:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044159#M153756</guid>
      <dc:creator>andre_silva</dc:creator>
      <dc:date>2020-06-30T15:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044160#M153757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the code sample. It was helpful insofar as showing how to map memory from vpudec into a texture.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But as I mentioned, I also need to encode the texture data afterwards, using imxvpuenc_h264. This is why I'm looking at the virtual framebuffer solution from that thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My gstreamer pipeline looks like this:&lt;/P&gt;&lt;P&gt;imxv4l2videosrc device=/dev/video1 input=0 fps=30/1 ! "image/jpeg, width=1920,height=1080, framerate=30/1" ! queue max-size-bytes=0 max-size-time=0 max-size-buffers=0 ! imxvpudec ! zerocopygpuoverlay ! imxvpuenc_h264 bitrate=14000 ! h264parse&amp;nbsp; ! mp4mux ! filesink location=/videos/out.mp4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where "zerocopygpuoverlay" is my custom element, modifying the yuv data directly without copying it into or out from the texture.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2020 09:27:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044160#M153757</guid>
      <dc:creator>erlend_eriksen</dc:creator>
      <dc:date>2020-07-01T09:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044161#M153758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to somewhat resolve the segmentation fault in the virtual framebuffer kernel module:&amp;nbsp;&lt;A class="link-titled" href="https://github.com/Freescale/linux-module-virtfb/issues/2#issuecomment-652531936" title="https://github.com/Freescale/linux-module-virtfb/issues/2#issuecomment-652531936"&gt;Segmentation fault on module initialization · Issue #2 · Freescale/linux-module-virtfb · GitHub&lt;/A&gt;&amp;nbsp; . Not sure if it works like it's supposed to though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2020 16:59:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044161#M153758</guid>
      <dc:creator>erlend_eriksen</dc:creator>
      <dc:date>2020-07-01T16:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044162#M153759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am glad you getting it working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2020 05:27:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044162#M153759</guid>
      <dc:creator>andre_silva</dc:creator>
      <dc:date>2020-07-02T05:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044163#M153760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2020 18:49:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044163#M153760</guid>
      <dc:creator>Bio_TICFSL</dc:creator>
      <dc:date>2020-07-02T18:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044164#M153761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;I have modified the eglvivsink from gstreamer-imx, so that after it has rendered to my virtual framebuffer, it writes the physical address of the framebuffer to the buffer before sending it downstream. However, I have encountered a problem with opengl on imx6: The&amp;nbsp;GL_EXT_yuv_target extension is not supported by the gpu, so it can only render rgb data to the framebuffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means that in order to encode the rendered image with the vpu, I first need to do a rgba to planar yuv conversion. The entire point with using zero copy between gpu and vpu was so that I wouldn't need to deal with the annoying color space restrictions of the g2d system, so it seems like my solution is worthless for this scenario.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2020 15:48:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044164#M153761</guid>
      <dc:creator>erlend_eriksen</dc:creator>
      <dc:date>2020-07-06T15:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044165#M153762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erlend,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there is another demo we have that might help you somehow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;Attached is the patch (0001-YUYV-to-NV12-Converter.patch) to generate the &amp;nbsp;YUYV -&amp;gt; NV12 converter using the GPU. I modified the DirectMultiSamplingVideoYUV for simplicity. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;The 0001-GPU-YUV-RGB.patch just modifies the original DirectMultiSamplingVideoYUV project.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 11.0pt; "&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;The solution is developed in Linux using the GPU SDK &lt;A class="link-titled" href="https://github.com/NXPmicro/gtec-demo-framework/tree/master/DemoApps/GLES3/DirectMultiSamplingVideoYUV" title="https://github.com/NXPmicro/gtec-demo-framework/tree/master/DemoApps/GLES3/DirectMultiSamplingVideoYUV"&gt;gtec-demo-framework/DemoApps/GLES3/DirectMultiSamplingVideoYUV at master · NXPmicro/gtec-demo-framework · GitHub&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG style="font-size: 11.0pt; "&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;The application creates a video in NV12 format from the camera output in YUV422 (YUYV). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;The example and solution now works in the next way:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;1.- Setting Gstreamer to output the camera video in the default YUV422 YUYV format. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;2.- The GPU maps a texture directly to the video buffer. The texture is defined as a RGBA because we need a 4 8-bit component (YUYV). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;3.- Create 2 Color attachments as render targets. These buffers/render targets will contain the Y and UV components of the NV12 format. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;4.- In the Fragment shader the Y contents are copied&amp;nbsp; to the first render target.&amp;nbsp; The Cb and Cr are downsampled by ½&amp;nbsp; in the fragment shader&amp;nbsp; and copied to the last render target. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;5.- Using the PBO to get a reference to the pixels in each render target.&amp;nbsp; We have a pointer to Y and a different one for the UV components. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;This is better shown below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/114875iE6358E5409B09CE4/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.jpg" alt="pastedImage_1.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt;"&gt;Andre&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2020 17:11:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044165#M153762</guid>
      <dc:creator>andre_silva</dc:creator>
      <dc:date>2020-07-07T17:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044166#M153763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Andre, this was very helpful. Will definitely have another go at this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the moment I am instead trying to use the blending functionality in g2d on just the Y plane of the NV12 image, so that I won't need to convert back and forth between rgb and planar yuv just to overlay text in the image.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2020 11:50:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044166#M153763</guid>
      <dc:creator>erlend_eriksen</dc:creator>
      <dc:date>2020-07-08T11:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Zero copy between GPU and VPU</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044167#M153764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it helped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Andre&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2020 16:07:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Zero-copy-between-GPU-and-VPU/m-p/1044167#M153764</guid>
      <dc:creator>andre_silva</dc:creator>
      <dc:date>2020-07-08T16:07:17Z</dc:date>
    </item>
  </channel>
</rss>

