blob: f197167629baecd006be93066e8b638ee64654f1 [file] [log] [blame] [view]
Jon Ashburn8c519362015-01-06 10:33:36 -07001# Loader Description
2
3## Overview
4The Loader implements the main XGL library: libXGL.so on Linux. It handles
5layer management and driver management. Loader driver management includes
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -07006finding driver librairies and loading them. Additionally, the loader dispatches
Jon Ashburn8c519362015-01-06 10:33:36 -07007the API calls to the correct driver based on the GPU selected by the app. The
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -07008loader fully supports multi-gpu operation.
Jon Ashburn8c519362015-01-06 10:33:36 -07009
10Loader layer management includes finding layer libraries and activating them
11as requested. Loader correctly sets up layer and its own dispatch tables to
12support multiple layers activated. Each active layer can intercept a subset of
13the full API entrypoints. A layer which doesn't intercept a given entrypoint
14will be skipped for that entrypoint. The loader supports layers that operate
15on multiple GPUs.
16
17## Environment Variables
18LIBXGL\_DRIVERS\_PATH directory for loader to search for ICD driver libraries to open
Courtney Goeltzenleuchterc507e3d2015-01-07 09:24:45 -070019
20LIBXGL\_LAYERS\_PATH directory for loader to search for layer libraries that may get activated and used at xglCreateDevice() time.
21
22LIBXGL\_LAYER\_NAMES colon separate list of layer names to be activated. Example,
Jon Ashburn8c519362015-01-06 10:33:36 -070023 LIBXGL\_LAYER\_NAMES=MemTracker:DrawState
24
25## Interface to driver (ICD)
Jon Ashburn117a0d42015-02-11 12:40:00 -070026- xglEnumerateGpus exported
27- xglCreateInstance exported
28- xglDestroyInstance exported
Jon Ashburn8c519362015-01-06 10:33:36 -070029- xglGetProcAddr exported and returns valid function pointers for all the XGL API entrypoints
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -070030- all objects created by ICD can be cast to (XGL\_LAYER\_DISPATCH\_TABLE \*\*)
Jon Ashburn8c519362015-01-06 10:33:36 -070031 where the loader will replace the first entry with a pointer to the dispatch table which is
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -070032 owned by the loader. This implies three things for ICD drivers:
Courtney Goeltzenleuchterc507e3d2015-01-07 09:24:45 -070033 1. the ICD must return a pointer for the opaque object handle
Jon Ashburn117a0d42015-02-11 12:40:00 -070034 2. this pointer points to a regular C structure with the first entry being a pointer.
35 Note: for any C++ ICD's that implement XGL objects directly as C++ classes.
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -070036 The C++ compiler may put a vtable at offset zero if your class is virtual.
37 In this case use a regular C structure as follows for your C++ objects:
Jon Ashburn117a0d42015-02-11 12:40:00 -070038```
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -070039 #include "xglIcd.h"
Jon Ashburn117a0d42015-02-11 12:40:00 -070040 struct {
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -070041 XGL_LOADER_DATA *reservedForLoader;
Jon Ashburn117a0d42015-02-11 12:40:00 -070042 myObjectClass myObj;
43 } xglObj;
44```
Courtney Goeltzenleuchterba7133b2015-02-10 18:40:14 -070045 3. the reservedForLoader.loaderMagic member must be initialized with ICD\_LOADER\_MAGIC
Courtney Goeltzenleuchterc507e3d2015-01-07 09:24:45 -070046- the ICD may or may not implement a dispatch table
Jon Ashburn117a0d42015-02-11 12:40:00 -070047- ICD entrypoints can be named anything including the offcial xgl name such as xglCreateDevice(). However, beware of interposing by dynamic OS library loaders if the offical names are used. On Linux, if offical names are used, the ICD library must be linked with -Bsymbolic
Courtney Goeltzenleuchterc507e3d2015-01-07 09:24:45 -070048