No display output when testing drawing with wayland, EGL, and OpenGLES on i.MX8MPlus

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

No display output when testing drawing with wayland, EGL, and OpenGLES on i.MX8MPlus

826 次查看
kuri
Contributor III

Hi NXP,

I am currently testing filling with wayland, EGL, and OpenGLES, but nothing is being displayed on the monitor.

  • There are no errors occurring.
  • The sample "tiger" is displayed correctly on the monitor.

Could you please let me know if there are any possible reasons why nothing is being displayed on the monitor? Also, if there are any specific things I should investigate, please advise.

CPU: i.MX8MPlus

Here is the log and the source code I am testing with:

--------------------------

test software

--------------------------

#include <stdio.h>
#include <stdlib.h>
#include <EGL/egl.h>
#include <VG/openvg.h>
#include <VG/vgu.h>
#include <errno.h>
#include <EGL/eglext.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
#include <wayland-egl.h>
#include <GLES2/gl2.h>

#define WINDOW_WIDTH 1920
#define WINDOW_HEIGHT 1080
EGLDisplay egl_display = EGL_NO_DISPLAY;
EGLSurface egl_surface;

typedef struct
{
    struct wl_display* display;
    struct wl_compositor* compositor;
} display_t;
display_t disp;

static void _registry_global(
    void *data,struct wl_registry *registry,
    uint32_t id,const char *interface,uint32_t version)
   {
    struct display* d = (struct display*)data;
    printf("_registry_global()=%s ver=%d\n",interface,version);
    if(strcmp(interface, "wl_compositor") == 0)
    {
        disp.compositor = wl_registry_bind(registry, id, &wl_compositor_interface, 1);
    }

}
static void _registry_global_remove(void *data,struct wl_registry *registry,uint32_t id)
{
    printf("%s line=%d\n",__func__,__LINE__);
}
static const struct wl_registry_listener g_reg_listener = {
    _registry_global, _registry_global_remove
};
static void egl_error_print(int line)
{
    EGLint error = eglGetError();
    printf("%s line=%d error=%d\n",__func__,line,error);
    switch (error) {
    case EGL_BAD_DISPLAY:   printf("EGL error: EGL_BAD_DISPLAY\n");     break;
    case EGL_BAD_CONFIG:    printf("EGL error: EGL_BAD_CONFIG\n");      break;
    case EGL_BAD_CONTEXT:   printf("EGL error: EGL_BAD_CONTEXT\n");     break;
    case EGL_BAD_ATTRIBUTE: printf("EGL error: EGL_BAD_ATTRIBUTE\n");   break;
    default:                printf("EGL error: Unknown error\n");       break;
    }
}

static void gles_error_print(int line)
{
    GLenum error = glGetError();
    if (error != GL_NO_ERROR) {
        switch (error) {
        case GL_INVALID_ENUM:   printf("GLES error:GL_INVALID_ENUM line=%d\n\n",line);  break;
        case GL_INVALID_VALUE:  printf("GLES error:GL_INVALID_VALUE\n line=%d", line);  break;
        default:                printf("GLES error:%d line=%d\n",error,line);           break;
        }
    }
    else
    {
        printf("GLES:GL_NO_ERROR line=%d\n",line);
    }
    return;
}

int main()
{
    static struct wl_display *display = NULL;
    static struct wl_egl_window *egl_window = NULL;
    int i;

    display = wl_display_connect(NULL);
    if (!display)
    {
        printf("Failed to connect to Wayland display\n");
    }
    static struct wl_registry* registry = NULL;
    registry = wl_display_get_registry(display);
    if (registry == NULL) {
        printf("Failed to create Wayland registry\n");
    }
    wl_registry_add_listener(registry, &g_reg_listener, NULL);
    wl_display_dispatch(display);
    wl_display_roundtrip(display);

    egl_display = eglGetDisplay(display);
    if (egl_display == EGL_NO_DISPLAY)
    {
        printf("display error\n");
    }
    EGLint major = 0, minor = 0;
    if ( EGL_FALSE == eglInitialize(egl_display, &major, &minor) )
    {
        printf("init error\n");
    }
    printf("major=%d minor=%d\n",major,minor);

    if( eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE )
    {
        printf("bind error\n");
    }
    printf("%s line=%d\n",__func__,__LINE__);

    EGLint config_attribs[] = {
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_DEPTH_SIZE,24,
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
        EGL_SAMPLES, 0,
        EGL_RED_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_BLUE_SIZE, 8,
        EGL_ALPHA_SIZE, 0,
        EGL_NONE,
    };
    EGLConfig egl_config;
    EGLint num_configs = 0;
    if( eglChooseConfig(egl_display, config_attribs, &egl_config, 1, &num_configs) == EGL_FALSE )
    {
        printf("eglChooseConfig error\n");
    }
    printf("num_configs=%d\n",num_configs);

    struct wl_surface *surface = wl_compositor_create_surface(disp.compositor);
    if (surface == NULL)
    {
        printf("Failed to create Wayland surface\n");
    }
    printf("%s line=%d\n",__func__,__LINE__);

    egl_window = wl_egl_window_create(surface, WINDOW_WIDTH, WINDOW_HEIGHT);
    if (egl_window == NULL) {
        printf("Failed to create Wayland EGL window\n");
    }
    printf("%s line=%d\n",__func__,__LINE__);

    egl_surface = eglCreateWindowSurface(egl_display, egl_config, egl_window, NULL/*context_attribs*/);
    if (egl_surface == EGL_NO_SURFACE) {
        printf("Failed to create EGL surface\n");
    }
    printf("%s line=%d\n",__func__,__LINE__);

    EGLint context_attribs[] = {
        EGL_CONTEXT_CLIENT_VERSION, 2,
        EGL_NONE
    };
    EGLContext egl_context = eglCreateContext(egl_display, egl_config, EGL_NO_CONTEXT, context_attribs);
    if (egl_context == EGL_NO_CONTEXT) {
        egl_error_print(__LINE__);
        printf("Failed to create EGL context\n");
    }

    if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context) == EGL_FALSE) {
        printf("Failed to make EGL context current\n");
    }
    printf("%s line=%d\n",__func__,__LINE__);

    {
        EGLint val = 0;
        printf("%s\n", glGetString(GL_VENDOR));
        printf("%s\n", glGetString(GL_RENDERER));
        printf("%s\n", glGetString(GL_VERSION));    
        eglGetConfigAttrib(egl_display, egl_config, EGL_RED_SIZE, &val);
        printf("EGL_RED_SIZE:%d\n", (int)val);
        eglGetConfigAttrib(egl_display, egl_config, EGL_GREEN_SIZE, &val);
        printf("EGL_GREEN_SIZE:%d\n", (int)val);
        eglGetConfigAttrib(egl_display, egl_config, EGL_BLUE_SIZE, &val);
        printf("EGL_BLUE_SIZE:%d\n", (int)val);
        eglGetConfigAttrib(egl_display, egl_config, EGL_ALPHA_SIZE, &val);
        printf("EGL_ALPHA_SIZE:%d\n", (int)val);
        eglGetConfigAttrib(egl_display, egl_config, EGL_DEPTH_SIZE, &val);
        printf("EGL_DEPTH_SIZE:%d\n", (int)val);
        eglGetConfigAttrib(egl_display, egl_config, EGL_SAMPLES, &val);
        printf("EGL_SAMPLES:%d\n", (int)val);
        eglGetConfigAttrib(egl_display, egl_config, EGL_RENDERABLE_TYPE, &val);
        printf("EGL_RENDERABLE_TYPE:%d\n", (int)val);
       
        glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
        gles_error_print(__LINE__);
        glClear(GL_COLOR_BUFFER_BIT);
        gles_error_print(__LINE__);
    }

    if( eglSwapBuffers(egl_display, egl_surface) == EGL_TRUE )
    {
        printf("eglSwapBuffers:Success\n");
    }
    else
    {
        printf("eglSwapBuffers:Error\n");
    }
    glFlush();
   
    return 0;
}

--------------------------

log

--------------------------

_registry_global()=wl_compositor ver=4
_registry_global()=wl_subcompositor ver=1
_registry_global()=wp_viewporter ver=1
_registry_global()=zxdg_output_manager_v1 ver=2
_registry_global()=wp_presentation ver=1
_registry_global()=zwp_alpha_compositing_v1 ver=1
_registry_global()=zwp_relative_pointer_manager_v1 ver=1
_registry_global()=zwp_pointer_constraints_v1 ver=1
_registry_global()=zwp_input_timestamps_manager_v1 ver=1
_registry_global()=wl_data_device_manager ver=3
_registry_global()=wl_shm ver=1
_registry_global()=weston_touch_calibration ver=1
_registry_global()=wl_viv ver=1
_registry_global()=wl_drm ver=2
_registry_global()=wl_seat ver=7
_registry_global()=zwp_linux_dmabuf_v1 ver=4
_registry_global()=weston_direct_display_v1 ver=1
_registry_global()=zwp_linux_explicit_synchronization_v1 ver=2
_registry_global()=weston_content_protection ver=1
_registry_global()=zwp_hdr10_metadata_v1 ver=1
_registry_global()=wl_output ver=3
_registry_global()=zwp_input_panel_v1 ver=1
_registry_global()=zwp_input_method_v1 ver=1
_registry_global()=zwp_text_input_manager_v1 ver=1
_registry_global()=xdg_wm_base ver=3
_registry_global()=wl_shell ver=1
_registry_global()=weston_desktop_shell ver=1
_registry_global()=weston_screenshooter ver=1
major=1 minor=5
main line=110
num_configs=1
main line=137
main line=143
main line=150
main line=165
Vivante Corporation
Vivante GC7000UL
OpenGL ES 3.1 V6.4.3.p4.398061
EGL_RED_SIZE:8
EGL_GREEN_SIZE:8
EGL_BLUE_SIZE:8
EGL_ALPHA_SIZE:0
EGL_DEPTH_SIZE:24
EGL_SAMPLES:0
EGL_RENDERABLE_TYPE:77
GLES:GL_NO_ERROR line=188
GLES:GL_NO_ERROR line=190
eglSwapBuffers:Success

0 项奖励
回复
1 回复

775 次查看
Dhruvit
NXP TechSupport
NXP TechSupport

Hi @kuri,

I hope you are doing well.

Please make sure that you have followed the correct steps to build the Wayland image.

Please refer to Setup for Specific Backends in i.MX Yocto Project User's Guide

One can try various tests specified at weston/tests.

Thanks & Regards,
Dhruvit Vasavada

0 项奖励
回复