Skip to content

Latest commit

 

History

History
113 lines (88 loc) · 3.8 KB

README.md

File metadata and controls

113 lines (88 loc) · 3.8 KB

SupportOSMesa

SupportOSMesa is a support class library with OSMesa (Off-screen Mesa) for KVS. By checking the flag KVS_SUPPORT_OSMESA in the kvs.conf, OSMesa supported classes are compiled and availabl.

Prerequisite

The OSMesa is required to compile the SupportOSMesa. Although the OSMesa can be easily installed with the package manager, such as apt-get on Ubuntu, we recommend the compile and install it by downloading the source codes of the OSMesa on your developping environment in order to use high-perfrmance rendering functionalities.

OSMesa installation

The OSMesa can be easily compiled and installed by using osmesa-install as follows.

  1. Create install target directories for OSMesa and LLVM. In the following example, the target directries; osmesa and llvm are created under "~/local".
$ cd
$ mkdir local
$ cd local
$ mkdir osmesa
$ mkdir llvm
  1. Move to your working directory (e.g. ~/Work/GitHub), in which the osmesa-install will be cloned.
$ cd ~/Work/GitHub
  1. Download the osmesa install script.
$ git clone https://github.com/devernay/osmesa-install.git
$ cd osmesa-install
  1. Modify the install-script 'osmesa-install.sh' as follows. Note that these options can also be specified directly via environmental variables at compile time.
a) Specify the install target directory of OSMesa.
osmesaprefix="${OSMESA_PREFIX:-${HOME}/local/osmesa}

b) Specify the driver of 4. (1:swrast, 2:softpipe, 3:llvmpipe, 4:swr)
osmesadriver=${OSMESA_DRIVER:-4}

c) Disable 'mangled'. (1:compile mangled OSMesa or 0:not)
mangled=0

d) Specify the install target directory for LLVM.
llvmprefix="${LLVM_PREFIX:-${HOME}/local/llvm}

e) Enable 'buildllvm'. (1:download and build LLVM or 0:not)
buildllvm="${LLVM_BUILD:-1}

Rendering driver

  • swrast: OSMesa original resterizer. very slow and not supported GLSL shader. Not recommended.
  • softpipe: Gallium driver. Supported GLSL shader but very slow. Not recommended.
  • llvmpipe: LLVM optimized Gallium driver. Very fast but LLVM is required. Recommended.
  • swr: Intel CPU optimized Gallium driver (known as OpenSWR). Very fast. Recommended if you use Intel CPUs.

For Mac, several packages need to be installed with homebrew before cmpiling OSMesa as follows:

$ brew install gsed pkg-config cmake libtool automake autoconf
  1. Compile and install OSMesa.
$ mkdir build
$ cd build
$ ../osmesa-install.sh

To specify the options directly via environmental variables, compile and install as follows:

$ OSMESA_PREFIX=${HOME}/local/osmesa OSMESA_DRIVER=3 MANGLED=0 LLVM_PREFIX=${HOME}/local/llvm LLVM_BUILD=1 ../osmesa-install.sh
  1. Set environment variables for using the SupportOSMesa.
export KVS_OSMESA_DIR=${HOME}/local/osmesa
export KVS_OSMESA_LINK_LIBRARY="-lOSMesa32 -lz `~/local/llvm/bin/llvm-config --libs` `~/local/llvm/bin/llvm-config --ldflags` -lrt -ldl -lpthread -lm"

Example Program

An example program for the SupportOSMesa is available in the Example/SupportOSMesa directory. You can easily compiple the example program with the kvsmake as follows:

$ cd Example/SupportOSMesa
$ cd Hello
$ kvsmake -G
$ kvsmake

The offscreen rendering results (12 images) will be generated by executing the compiled program as follows:

e.g)
$ ./Hello
OSMesa version: 11.2.0
rendering to ... output_000.bmp
rendering to ... output_001.bmp
rendering to ... output_002.bmp
rendering to ... output_003.bmp
rendering to ... output_004.bmp
rendering to ... output_005.bmp
rendering to ... output_006.bmp
rendering to ... output_007.bmp
rendering to ... output_008.bmp
rendering to ... output_009.bmp
rendering to ... output_010.bmp
rendering to ... output_011.bmp
Total rendering time:   5.92246 [sec]
Average rendering time: 0.493539 [sec]