GithubHelp home page GithubHelp logo

gbm_es2_demo's Introduction

GBM ES2 Demo

  • Example OpenGL ES2 demo using GBM and DRM (KMS) modesetting
  • This shows how ChromeOS renders GLES2 contents on the screen.
  • It uses OpenGL ES2/3 without X11 dependency, so it fits pretty good with the embedded devices world.

Alt text

Build

  • If you are on Ubuntu, first make sure you have the dependencies installed
> sudo apt-get install libgles2-mesa-dev libgbm-dev
> mkdir build; cd build
> cmake ../
> make

Run

  • I have successfully ran it on Ubuntu, ChromeOS and Yocto.

Ubuntu

  • Go to tty1 with Ctrl + Alt + F1
  • Kill gdm or lightdm because they are DRM master now. This demo has to be DRM master.
> sudo service lightdm stop
  • Run the demo
> gbm_es2_demo
or
> gbm_es2_demo -M # mmap test

Yocto

  • The easiest way to build embedded linux image is to use Yocto.
  • I make Yocto recipes to make standalone emebeded OpenGL ES2 demo image.
  • Check Yocto GBM ES2 Demo
  • Enjoy building Linux image from the scratch.

Demo detail

gbm_es2_demo

  • Show how to glue DRM, GBM and EGL
  • Show how to swap buffer and vsync
  • Show how to implement GLES2 app

gbm_es2_demo -M

  • Same to gbm_es2_demo except for updating cube surface using dma_buf mmap
  • It's very nice demo to show how Chromium zero-copy texture upload works. Chromium doesn't use glTexImage2D to update texture thank to new dma_buf mmap API. For more Chromium detail, check the chrome issue
  • After Linux kernel v4.6, you can use following code. (currently only Intel Architecture supports it)
  • Tiago Vignatti made this change in kernel.
  void* data = mmap(dma_buf_fd)
  update contents on |data|
  munmap(data)

Code style

> clang-format-5.0 -i `find . -name "*.cpp" -o -name "*.h"`

Reference

gbm_es2_demo's People

Contributors

christophhaag avatar ds-hwang avatar robclark avatar tiagovignatti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gbm_es2_demo's Issues

error: 'GBM_BO_USE_LINEAR' was not declared in this scope

Any idea how to fix?

 # cmake ../
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29")
-- Checking for module 'libdrm'
--   Found libdrm, version 2.4.74
-- Checking for module 'gbm'
--   Found gbm, version 10.4.0
-- Checking for module 'egl'
--   Found egl, version 7.10
-- Checking for module 'glesv2'
--   Found glesv2, version
ged links drmgbmEGLGLESv2
gbm_es2_demo links ged
dma_buf_mmap_demo links ged
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/src/gbm_es2_demo/build
armhf ch root /mnt/src/gbm_es2_demo/build > # make
Scanning dependencies of target ged
[ 12%] Building CXX object ged_lib/CMakeFiles/ged.dir/drm_modesetter.cpp.o
[ 25%] Building CXX object ged_lib/CMakeFiles/ged.dir/egl_drm_glue.cpp.o
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp: In member function 'bool ged::{anonymous}::StreamTextureImpl::Initialize(gbm_device*)':
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:147:46: error: 'GBM_BO_USE_LINEAR' was not declared in this scope
                         GBM_FORMAT_ARGB8888, GBM_BO_USE_LINEAR);
                                              ^~~~~~~~~~~~~~~~~
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:147:46: note: suggested alternative: 'GBM_BO_USE_WRITE'
                         GBM_FORMAT_ARGB8888, GBM_BO_USE_LINEAR);
                                              ^~~~~~~~~~~~~~~~~
                                              GBM_BO_USE_WRITE
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:164:50: warning: narrowing conversion of '((ged::{anonymous}::StreamTextureImpl*)this)->ged::{anonymous}::StreamTextureImpl::dimension_.ged::StreamTexture::Dimension::width' from 'size_t {aka unsigned int}' to 'EGLint {aka int}' inside { } [-Wnarrowing]
                                       dimension_.width,
                                       ~~~~~~~~~~~^~~~~
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:166:50: warning: narrowing conversion of '((ged::{anonymous}::StreamTextureImpl*)this)->ged::{anonymous}::StreamTextureImpl::dimension_.ged::StreamTexture::Dimension::height' from 'size_t {aka unsigned int}' to 'EGLint {aka int}' inside { } [-Wnarrowing]
                                       dimension_.height,
                                       ~~~~~~~~~~~^~~~~~
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:170:50: warning: narrowing conversion of '((ged::{anonymous}::StreamTextureImpl*)this)->ged::{anonymous}::StreamTextureImpl::dimension_.ged::StreamTexture::Dimension::stride' from 'size_t {aka unsigned int}' to 'EGLint {aka int}' inside { } [-Wnarrowing]
                                       dimension_.stride,
                                       ~~~~~~~~~~~^~~~~~
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp: In member function 'bool ged::EGLDRMGlue::Impl::CreateFramebuffer(size_t, size_t, ged::EGLDRMGlue::Impl::Framebuffer&)':
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:478:47: warning: narrowing conversion of 'width' from 'size_t {aka unsigned int}' to 'EGLint {aka int ' inside { } [-Wnarrowing]
                                       EGL_NONE};
                                               ^
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:478:47: warning: narrowing conversion of 'height' from 'size_t {aka unsigned int}' to 'EGLint {aka int}' inside { } [-Wnarrowing]
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:478:47: warning: narrowing conversion of 'stride' from 'uint32_t {aka unsigned int}' to 'EGLint {aka int}' inside { } [-Wnarrowing]
/mnt/src/gbm_es2_demo/ged_lib/egl_drm_glue.cpp:478:47: warning: narrowing conversion of 'offset' from 'uint32_t {aka unsigned int}' to 'EGLint {aka int}' inside { } [-Wnarrowing]
ged_lib/CMakeFiles/ged.dir/build.make:75: recipe for target 'ged_lib/CMakeFiles/ged.dir/egl_drm_glue.cpp.o' failed
make[2]: *** [ged_lib/CMakeFiles/ged.dir/egl_drm_glue.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'ged_lib/CMakeFiles/ged.dir/all' failed
make[1]: *** [ged_lib/CMakeFiles/ged.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Segmentation fault on Ubuntu16.04

The demo was failing with segmentation fault on ubuntu16.04 because of this line:
egl_.display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
If it is changed to
egl_.display = eglGetDisplay((EGLNativeDisplayType)gbm_);
is working.

Why it works only when chrom running?

It write "failed to initialize
failed to initialize EGL
" when it is not running. In joone C demo.
In this demo it write "using card: '/dev/card0': Success
" and it show nothing. Rust demo works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.