<?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>i.MX Processors中的主题 Can't get glTexDirectMapVIV to work</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1296203#M175855</link>
    <description>&lt;P&gt;I try to get video from a CSI-2 interface of a custom iMX8QXP board to be displayed using OpenGLES (will need some transformations on the video image). For performance reasons we would like to use&amp;nbsp;glTexDirectMapVIV to directly use the buffers from v4l2 as an OpenGLES texture. But unfortunatly I am not able to get this to work. I stripped our test program as much as possible so no v4l2 involved. Just egl/gles:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;

#include &amp;lt;GLES/gl.h&amp;gt;
#include &amp;lt;GLES/glext.h&amp;gt;

#include &amp;lt;vdk.h&amp;gt;

int main(int argc, char *argv[])
{
    int xRes = 1920;
    int yRes = 720;
    int optNumFrames = 600;
    bool optVivMap = false;

    int c;
    while(-1 != (c = getopt(argc, argv, "n:m")))
    {
        if('n' == c)
        {
            optNumFrames = strtoul(optarg, 0, 0);
        }
        else if('m' == c)
        {
            optVivMap = true;
        }
    }

    vdkEGL egl = {};

    EGLint configAttribs[] =
    {
        EGL_SAMPLES,      0,
        EGL_RED_SIZE,     8,
        EGL_GREEN_SIZE,   8,
        EGL_BLUE_SIZE,    8,
        EGL_ALPHA_SIZE,   EGL_DONT_CARE,
        EGL_DEPTH_SIZE,   16,
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
        EGL_NONE,
    };

    EGLint attribListContext[] =
    {
        // Needs to be set for es2.0 as default client version is es1.1.
        EGL_CONTEXT_CLIENT_VERSION, 1,
        EGL_NONE
    };

    vdkInitialize();
    vdkSetupEGL(0, 0, xRes, yRes, configAttribs, NULL, attribListContext, &amp;amp;egl);
    vdkShowWindow(egl.window);

    glClearColor(0.2f, 0.0f, 0.0f, 0.0f);
    glViewport(0, 0, xRes, yRes);
    glMatrixMode(GL_PROJECTION);
    glOrthof(-10.0f, 10.0f, -10.0f , 10.0f, -1.0f, 1.0f);

    glEnable(GL_TEXTURE_2D);

    unsigned int texture;
    glGenTextures(1, &amp;amp;texture);

    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    //Alloc texture data and write some data into it
    int texXRes = 64;
    int texYRes = 64;
    void * videoData = malloc(texXRes*texYRes*4);

    //Get some data to the texture
    uint8_t * p0 = (uint8_t *)videoData + 0 * texXRes * texYRes;
    uint8_t * p1 = (uint8_t *)videoData + 1 * texXRes * texYRes;
    uint8_t * p2 = (uint8_t *)videoData + 2 * texXRes * texYRes;
    uint8_t * p3 = (uint8_t *)videoData + 3 * texXRes * texYRes;
    for(size_t k = 0; k &amp;lt; texXRes * texYRes; k += 4)
    {
        *p0++ = rand();  *p0++ = rand(); *p0++ = rand(); *p0++ = rand();
        *p1++ = 0xFF;    *p1++ = 0x00;   *p1++ = 0x00;   *p1++ = 0x00;
        *p2++ = 0x00;    *p2++ = 0xFF;   *p2++ = 0x00;   *p2++ = 0x00;
        *p3++ = 0x00;    *p3++ = 0x00;   *p3++ = 0xFF;   *p3++ = 0x00;
    }

    if(optVivMap)
    {
        PFNGLTEXDIRECTMAPVIVPROC glTexDirectMapVIV = (PFNGLTEXDIRECTMAPVIVPROC)eglGetProcAddress("glTexDirectMapVIV");
        PFNGLTEXDIRECTINVALIDATEVIVPROC glTexDirectInvalidateVIV = (PFNGLTEXDIRECTINVALIDATEVIVPROC)eglGetProcAddress("glTexDirectInvalidateVIV");

        GLuint pAddr = ~0U;
        glTexDirectMapVIV(GL_TEXTURE_2D, texXRes, texYRes, GL_BGRA_EXT, &amp;amp;videoData, &amp;amp;pAddr);
        glTexDirectInvalidateVIV(GL_TEXTURE_2D);
    }
    else
    {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, texXRes, texYRes, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, videoData);
    }

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    for(int i = 0; i &amp;lt; optNumFrames; i++)
    {
        glClear(GL_COLOR_BUFFER_BIT);

        float vertices[] = {
                -8.0f,  -8.0f, 0.0f,    //lower left
                    8.0f,  -8.0f, 0.0f,    //lower right
                -8.0f,   8.0f, 0.0f,    //upper left
                    8.0f,   8.0f, 0.0f,    //upper right

        };
        float texCoords[] = {
            0.0f,   1.0f,    //lower left
            1.0f,   1.0f,    //lower right
            0.0f,   0.0f,    //upper left
            1.0f,   0.0f,    //upper right
        };
        glVertexPointer(3, GL_FLOAT, 0, vertices);
        glTexCoordPointer(2, GL_FLOAT, 0, texCoords);

        uint8_t indices[] = { 0, 1, 2, 1, 3, 2 };
        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);

        glFinish();
        eglSwapBuffers(egl.eglDisplay, egl.eglSurface);
    }

    return EXIT_SUCCESS;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If started without option -m (&lt;SPAN&gt;optVivMap == false) I can see the prepared texture. When the application is started with option -m I only see a white rectangle instead of the expected texture. Everything is based on&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;rel_imx_5.4.70_2.3.0.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would be thankful for any hint.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jun 2021 13:47:09 GMT</pubDate>
    <dc:creator>mod42</dc:creator>
    <dc:date>2021-06-22T13:47:09Z</dc:date>
    <item>
      <title>Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1296203#M175855</link>
      <description>&lt;P&gt;I try to get video from a CSI-2 interface of a custom iMX8QXP board to be displayed using OpenGLES (will need some transformations on the video image). For performance reasons we would like to use&amp;nbsp;glTexDirectMapVIV to directly use the buffers from v4l2 as an OpenGLES texture. But unfortunatly I am not able to get this to work. I stripped our test program as much as possible so no v4l2 involved. Just egl/gles:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;

#include &amp;lt;GLES/gl.h&amp;gt;
#include &amp;lt;GLES/glext.h&amp;gt;

#include &amp;lt;vdk.h&amp;gt;

int main(int argc, char *argv[])
{
    int xRes = 1920;
    int yRes = 720;
    int optNumFrames = 600;
    bool optVivMap = false;

    int c;
    while(-1 != (c = getopt(argc, argv, "n:m")))
    {
        if('n' == c)
        {
            optNumFrames = strtoul(optarg, 0, 0);
        }
        else if('m' == c)
        {
            optVivMap = true;
        }
    }

    vdkEGL egl = {};

    EGLint configAttribs[] =
    {
        EGL_SAMPLES,      0,
        EGL_RED_SIZE,     8,
        EGL_GREEN_SIZE,   8,
        EGL_BLUE_SIZE,    8,
        EGL_ALPHA_SIZE,   EGL_DONT_CARE,
        EGL_DEPTH_SIZE,   16,
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
        EGL_NONE,
    };

    EGLint attribListContext[] =
    {
        // Needs to be set for es2.0 as default client version is es1.1.
        EGL_CONTEXT_CLIENT_VERSION, 1,
        EGL_NONE
    };

    vdkInitialize();
    vdkSetupEGL(0, 0, xRes, yRes, configAttribs, NULL, attribListContext, &amp;amp;egl);
    vdkShowWindow(egl.window);

    glClearColor(0.2f, 0.0f, 0.0f, 0.0f);
    glViewport(0, 0, xRes, yRes);
    glMatrixMode(GL_PROJECTION);
    glOrthof(-10.0f, 10.0f, -10.0f , 10.0f, -1.0f, 1.0f);

    glEnable(GL_TEXTURE_2D);

    unsigned int texture;
    glGenTextures(1, &amp;amp;texture);

    glBindTexture(GL_TEXTURE_2D, texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    //Alloc texture data and write some data into it
    int texXRes = 64;
    int texYRes = 64;
    void * videoData = malloc(texXRes*texYRes*4);

    //Get some data to the texture
    uint8_t * p0 = (uint8_t *)videoData + 0 * texXRes * texYRes;
    uint8_t * p1 = (uint8_t *)videoData + 1 * texXRes * texYRes;
    uint8_t * p2 = (uint8_t *)videoData + 2 * texXRes * texYRes;
    uint8_t * p3 = (uint8_t *)videoData + 3 * texXRes * texYRes;
    for(size_t k = 0; k &amp;lt; texXRes * texYRes; k += 4)
    {
        *p0++ = rand();  *p0++ = rand(); *p0++ = rand(); *p0++ = rand();
        *p1++ = 0xFF;    *p1++ = 0x00;   *p1++ = 0x00;   *p1++ = 0x00;
        *p2++ = 0x00;    *p2++ = 0xFF;   *p2++ = 0x00;   *p2++ = 0x00;
        *p3++ = 0x00;    *p3++ = 0x00;   *p3++ = 0xFF;   *p3++ = 0x00;
    }

    if(optVivMap)
    {
        PFNGLTEXDIRECTMAPVIVPROC glTexDirectMapVIV = (PFNGLTEXDIRECTMAPVIVPROC)eglGetProcAddress("glTexDirectMapVIV");
        PFNGLTEXDIRECTINVALIDATEVIVPROC glTexDirectInvalidateVIV = (PFNGLTEXDIRECTINVALIDATEVIVPROC)eglGetProcAddress("glTexDirectInvalidateVIV");

        GLuint pAddr = ~0U;
        glTexDirectMapVIV(GL_TEXTURE_2D, texXRes, texYRes, GL_BGRA_EXT, &amp;amp;videoData, &amp;amp;pAddr);
        glTexDirectInvalidateVIV(GL_TEXTURE_2D);
    }
    else
    {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, texXRes, texYRes, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, videoData);
    }

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    for(int i = 0; i &amp;lt; optNumFrames; i++)
    {
        glClear(GL_COLOR_BUFFER_BIT);

        float vertices[] = {
                -8.0f,  -8.0f, 0.0f,    //lower left
                    8.0f,  -8.0f, 0.0f,    //lower right
                -8.0f,   8.0f, 0.0f,    //upper left
                    8.0f,   8.0f, 0.0f,    //upper right

        };
        float texCoords[] = {
            0.0f,   1.0f,    //lower left
            1.0f,   1.0f,    //lower right
            0.0f,   0.0f,    //upper left
            1.0f,   0.0f,    //upper right
        };
        glVertexPointer(3, GL_FLOAT, 0, vertices);
        glTexCoordPointer(2, GL_FLOAT, 0, texCoords);

        uint8_t indices[] = { 0, 1, 2, 1, 3, 2 };
        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);

        glFinish();
        eglSwapBuffers(egl.eglDisplay, egl.eglSurface);
    }

    return EXIT_SUCCESS;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If started without option -m (&lt;SPAN&gt;optVivMap == false) I can see the prepared texture. When the application is started with option -m I only see a white rectangle instead of the expected texture. Everything is based on&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;rel_imx_5.4.70_2.3.0.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would be thankful for any hint.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 13:47:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1296203#M175855</guid>
      <dc:creator>mod42</dc:creator>
      <dc:date>2021-06-22T13:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1297724#M176013</link>
      <description>&lt;P&gt;Hello mod42,&lt;/P&gt;
&lt;DIV id="bodyDisplay_0" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;From quickly test, L4.14.98 BSP has no this issue, but L5.4.70 BSP has it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some difference for the two kernel:&lt;/P&gt;
&lt;P&gt;L5.4.70's GPU driver will create a DRM device "/dev/dri/card0" and DPU display driver will be&amp;nbsp;"/dev/dri/card1".&lt;/P&gt;
&lt;P&gt;But in L4.14.98 kernel, there is only one drm device "/dev/dri/card0" for DPU display.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had tried to change "/etc/xdg/weston/weston.ini", set "drm-device=card1". But the issue is still there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 12:56:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1297724#M176013</guid>
      <dc:creator>Bio_TICFSL</dc:creator>
      <dc:date>2021-06-24T12:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1298158#M176038</link>
      <description>&lt;P&gt;So, your suggestion is to downgrade to&amp;nbsp;&lt;SPAN&gt;L4.14.98 and stay there or will this be fixed in a future revision?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 06:25:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1298158#M176038</guid>
      <dc:creator>mod42</dc:creator>
      <dc:date>2021-06-25T06:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1298468#M176052</link>
      <description>&lt;P&gt;This will be fixed for next revision.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 12:56:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1298468#M176052</guid>
      <dc:creator>Bio_TICFSL</dc:creator>
      <dc:date>2021-06-25T12:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1304070#M176551</link>
      <description>&lt;P&gt;Is this supposed to be fixed in the 5.10.35_2.0.0 release? I rebuild all our stuff based on this revision and can't get it to work. The behavior is the same as in the 5.4.70 release.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 15:05:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1304070#M176551</guid>
      <dc:creator>mod42</dc:creator>
      <dc:date>2021-07-07T15:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1430963#M188398</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I tried to build your posted example and can't find vdk.h anywhere in /usr/include.&amp;nbsp; I'm using 5.10.72-2.2.0 BSP image.&amp;nbsp; Anyone have ideas?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 21:38:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1430963#M188398</guid>
      <dc:creator>marcus-castlepeakinc</dc:creator>
      <dc:date>2022-03-20T21:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1430964#M188399</link>
      <description>&lt;P&gt;I've built this on my imx8mp with 5.10.72-2.2.0&amp;nbsp; and the white texture with glTexDirectMapVIV still&amp;nbsp; occurs.&amp;nbsp; When is this going to be fixed?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Mar 2022 23:13:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1430964#M188399</guid>
      <dc:creator>marcus-castlepeakinc</dc:creator>
      <dc:date>2022-03-20T23:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get glTexDirectMapVIV to work</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1536304#M196276</link>
      <description>&lt;P&gt;This is still not fixed in 5.15.52 with Vivante binaries&amp;nbsp;&lt;SPAN&gt;imx-gpu-viv-6.4.3.p4.4-aarch64.bin. Any updates on this?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 14:13:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Can-t-get-glTexDirectMapVIV-to-work/m-p/1536304#M196276</guid>
      <dc:creator>mod42</dc:creator>
      <dc:date>2022-10-12T14:13:24Z</dc:date>
    </item>
  </channel>
</rss>

