SLProject  4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLOptix.h
Go to the documentation of this file.
1 /**
2  * \file SLOptix.h
3  * \authors Nic Dorner
4  * \date October 2019
5  * \authors Nic Dorner
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifdef SL_HAS_OPTIX
12 # ifndef SLOPTIX_H
13 # define SLOPTIX_H
14 # include <optix_types.h>
15 # include <cuda.h>
16 # include <string>
17 # include <SLOptixDefinitions.h>
18 
19 using std::string;
20 
21 //-----------------------------------------------------------------------------
22 //! SLOptix base instance for static Optix initialization
23 class SLOptix
24 {
25 public:
26  // Public global static Optix objects
27  static void createStreamAndContext();
28  static void createStreamAndContextOrThrow();
29  static OptixDeviceContext context;
30  static CUstream stream;
31  static string exePath;
32 
33  //! True only once a device context exists, i.e. OptiX can really be used
34  /*! Compiling with OptiX says nothing about whether this machine can run it.
35  The implementation lives in the display driver and the kernels are compiled
36  for the actual GPU when they are loaded, so both the driver and the card
37  hold a veto that no build setting can predict. Everything that starts an
38  OptiX render has to ask this first; it stays false when the context, or
39  later a module or a scene, could not be built. */
40  static bool available;
41 };
42 //-----------------------------------------------------------------------------
43 # endif // SLOPTIX_H
44 #endif // SL_HAS_OPTIX