OWL
OptiX7 Wrapper Library
owl::Context Struct Reference

#include <Context.h>

Inheritance diagram for owl::Context:
owl::Object owl::APIContext

Public Types

typedef std::shared_ptr< ContextSP
 
- Public Types inherited from owl::Object
typedef std::shared_ptr< ObjectSP
 

Public Member Functions

 Context (int32_t *requestedDeviceIDs, int numRequestedDevices)
 
virtual ~Context ()
 
size_t deviceCount () const
 
const std::vector< DeviceContext::SP > & getDevices () const
 
DeviceContext::SP getDevice (int ID) const
 
void buildHitGroupRecordsOn (const DeviceContext::SP &device)
 
void buildRayGenRecordsOn (const DeviceContext::SP &device)
 
void buildMissProgRecordsOn (const DeviceContext::SP &device)
 
void setRayTypeCount (size_t rayTypeCount)
 
void enableMotionBlur ()
 
void setMaxInstancingDepth (int32_t maxInstanceDepth)
 
void buildSBT (OWLBuildSBTFlags flags)
 
void buildPipeline ()
 
void buildPrograms ()
 
void destroyPrograms ()
 
void buildModules ()
 
void destroyModules ()
 
Texture::SP texture2DCreate (OWLTexelFormat texelFormat, OWLTextureFilterMode filterMode, OWLTextureAddressMode addressMode, const vec2i size, uint32_t linePitchInBytes, const void *texels)
 
GeomGroup::SP trianglesGeomGroupCreate (size_t numChildren)
 
GeomGroup::SP userGeomGroupCreate (size_t numChildren)
 
Buffer::SP deviceBufferCreate (OWLDataType type, size_t count, const void *init)
 
Buffer::SP hostPinnedBufferCreate (OWLDataType type, size_t count)
 
Buffer::SP managedMemoryBufferCreate (OWLDataType type, size_t count, const void *init)
 
Buffer::SP graphicsBufferCreate (OWLDataType type, size_t count, cudaGraphicsResource_t resource)
 
RayGenType::SP createRayGenType (Module::SP module, const std::string &progName, size_t varStructSize, const std::vector< OWLVarDecl > &varDecls)
 
RayGen::SP createRayGen (const std::shared_ptr< RayGenType > &type)
 
LaunchParamsType::SP createLaunchParamsType (size_t varStructSize, const std::vector< OWLVarDecl > &varDecls)
 
LaunchParams::SP createLaunchParams (const std::shared_ptr< LaunchParamsType > &type)
 
MissProgType::SP createMissProgType (Module::SP module, const std::string &progName, size_t varStructSize, const std::vector< OWLVarDecl > &varDecls)
 
MissProg::SP createMissProg (const std::shared_ptr< MissProgType > &type)
 
void setMissProg (int rayTypeToSet, MissProg::SP missProgToUse)
 
GeomType::SP createGeomType (OWLGeomKind kind, size_t varStructSize, const std::vector< OWLVarDecl > &varDecls)
 
Module::SP createModule (const std::string &ptxCode)
 
- Public Member Functions inherited from owl::Object
 Object ()
 
virtual std::string toString () const
 
virtual DeviceData::SP createOn (const std::shared_ptr< DeviceContext > &device)
 
void createDeviceData (const std::vector< std::shared_ptr< DeviceContext >> &devices)
 
template<typename T >
std::shared_ptr< T > as ()
 

Static Public Member Functions

static bool logging ()
 

Public Attributes

RangeAllocator sbtRangeAllocator
 
std::vector< MissProg::SPmissProgPerRayType
 
int maxInstancingDepth = 1
 
int numRayTypes { 1 }
 
bool motionBlurEnabled = false
 
LaunchParams::SP dummyLaunchParams
 
ObjectRegistryT< Bufferbuffers
 
ObjectRegistryT< Texturetextures
 
ObjectRegistryT< Groupgroups
 
ObjectRegistryT< RayGenTyperayGenTypes
 
ObjectRegistryT< RayGenrayGens
 
ObjectRegistryT< MissProgTypemissProgTypes
 
ObjectRegistryT< MissProgmissProgs
 
ObjectRegistryT< GeomTypegeomTypes
 
ObjectRegistryT< Geomgeoms
 
ObjectRegistryT< Modulemodules
 
ObjectRegistryT< LaunchParamsTypelaunchParamTypes
 
ObjectRegistryT< LaunchParamslaunchParams
 
- Public Attributes inherited from owl::Object
const size_t uniqueID
 
std::vector< DeviceData::SPdeviceData
 

Private Member Functions

void enablePeerAccess ()
 

Private Attributes

std::vector< DeviceContext::SPdevices
 

Additional Inherited Members

- Static Public Attributes inherited from owl::Object
static std::atomic< uint64_t > nextAvailableID
 

Detailed Description

the root 'context' that spans, and manages, all objects and all devices

Member Typedef Documentation

◆ SP

typedef std::shared_ptr<Context> owl::Context::SP

Constructor & Destructor Documentation

◆ Context()

owl::Context::Context ( int32_t *  requestedDeviceIDs,
int  numRequestedDevices 
)

creates a context with the given device IDs. If list of device is nullptr, and number requested devices is > 1, then the first N devices will get used; invalid device IDs in the list will automatically get dropped

◆ ~Context()

owl::Context::~Context ( )
virtual

virtual destructor to cleanly wind down upon exit

Member Function Documentation

◆ buildHitGroupRecordsOn()

void owl::Context::buildHitGroupRecordsOn ( const DeviceContext::SP device)

part of the SBT creation - builds the hit group array

◆ buildMissProgRecordsOn()

void owl::Context::buildMissProgRecordsOn ( const DeviceContext::SP device)

part of the SBT creation - builds the miss group array

◆ buildModules()

void owl::Context::buildModules ( )

◆ buildPipeline()

void owl::Context::buildPipeline ( )

◆ buildPrograms()

void owl::Context::buildPrograms ( )

◆ buildRayGenRecordsOn()

void owl::Context::buildRayGenRecordsOn ( const DeviceContext::SP device)

part of the SBT creation - builds the raygen array

◆ buildSBT()

void owl::Context::buildSBT ( OWLBuildSBTFlags  flags)

◆ createGeomType()

GeomType::SP owl::Context::createGeomType ( OWLGeomKind  kind,
size_t  varStructSize,
const std::vector< OWLVarDecl > &  varDecls 
)

creates new geometry type defitiion with given variable declarations

◆ createLaunchParams()

LaunchParams::SP owl::Context::createLaunchParams ( const std::shared_ptr< LaunchParamsType > &  type)

create new instance of a set of launch params of given type

◆ createLaunchParamsType()

LaunchParamsType::SP owl::Context::createLaunchParamsType ( size_t  varStructSize,
const std::vector< OWLVarDecl > &  varDecls 
)

create a new launch param type descriptor with given variables; this can then be used to create actual launch param instances (

See also
createLaunchParams)

◆ createMissProg()

MissProg::SP owl::Context::createMissProg ( const std::shared_ptr< MissProgType > &  type)

create new instance of a miss program of given type

◆ createMissProgType()

MissProgType::SP owl::Context::createMissProgType ( Module::SP  module,
const std::string &  progName,
size_t  varStructSize,
const std::vector< OWLVarDecl > &  varDecls 
)

creates new miss program type with given program name (in given module), and the given variable declarations that describe this type's variables

◆ createModule()

Module::SP owl::Context::createModule ( const std::string &  ptxCode)

creates new module with given precompiled PTX code

◆ createRayGen()

RayGen::SP owl::Context::createRayGen ( const std::shared_ptr< RayGenType > &  type)

create new instance of a ray gen program of given type

◆ createRayGenType()

RayGenType::SP owl::Context::createRayGenType ( Module::SP  module,
const std::string &  progName,
size_t  varStructSize,
const std::vector< OWLVarDecl > &  varDecls 
)

creates new ray gen program type with given program name (in given module), and the given variable declarations that describe this type's variables

◆ destroyModules()

void owl::Context::destroyModules ( )

clearly destroy optix handles of all active modules

◆ destroyPrograms()

void owl::Context::destroyPrograms ( )

clearly destroy pptix handles of all active programs

◆ deviceBufferCreate()

Buffer::SP owl::Context::deviceBufferCreate ( OWLDataType  type,
size_t  count,
const void *  init 
)

create a new device buffer of given data type and count; if init is non-null it will be used to populoate this buffer. Note that for certain non-trivial types (OWLTexture, OWLGroup, etc) you may have to specify the content upon creation

◆ deviceCount()

size_t owl::Context::deviceCount ( ) const
inline

◆ enableMotionBlur()

void owl::Context::enableMotionBlur ( )

enables motoin blur - should be done right after context creation, and before SBT and pipeline get built

◆ enablePeerAccess()

void owl::Context::enablePeerAccess ( )
private

◆ getDevice()

DeviceContext::SP owl::Context::getDevice ( int  ID) const
inline

◆ getDevices()

const std::vector<DeviceContext::SP>& owl::Context::getDevices ( ) const
inline

◆ graphicsBufferCreate()

Buffer::SP owl::Context::graphicsBufferCreate ( OWLDataType  type,
size_t  count,
cudaGraphicsResource_t  resource 
)

creates a buffer that wraps a CUDA graphics resource that can be, for instance, an OpenGL texture

◆ hostPinnedBufferCreate()

Buffer::SP owl::Context::hostPinnedBufferCreate ( OWLDataType  type,
size_t  count 
)

creates a buffer that uses CUDA host pinned memory; that memory is pinned on the host and accessive to all devices in the device group

◆ logging()

static bool owl::Context::logging ( )
inlinestatic

returns whether logging is enabled

◆ managedMemoryBufferCreate()

Buffer::SP owl::Context::managedMemoryBufferCreate ( OWLDataType  type,
size_t  count,
const void *  init 
)

creates a buffer that uses CUDA managed memory; that memory is managed by CUDA (see CUDAs documentation on managed memory) and accessive to all devices in the deviec group

creates a buffer that uses CUDA managed memory; that memory is managed by CUDA (see CUDAs documentatoin on managed memory) and accessive to all devices in the deviec group

◆ setMaxInstancingDepth()

void owl::Context::setMaxInstancingDepth ( int32_t  maxInstanceDepth)

sets maximum instancing depth for the given context:

'0' means 'no instancing allowed, only bottom-level accels;

'1' means 'at most one layer of instances' (ie, a two-level scene), where the 'root' world rays are traced against can be an instance group, but every child in that inscne group is a geometry group.

'N>1" means "up to N layers of instances are allowed.

The default instancing depth is 1 (ie, a two-level scene), since this allows for most use cases of instancing and is still hardware-accelerated. Using a node graph with instancing deeper than the configured value will result in wrong results; but be aware that using any value > 1 here will come with a cost. It is recommended to, if at all possible, leave this value to one and convert the input scene to a two-level scene layout (ie, with only one level of instances)

◆ setMissProg()

void owl::Context::setMissProg ( int  rayTypeToSet,
MissProg::SP  missProgToUse 
)

sets miss prog to use for a given ray type

◆ setRayTypeCount()

void owl::Context::setRayTypeCount ( size_t  rayTypeCount)

sets number of ray types to be used - should be done right after context creation, and before SBT and pipeline get built

◆ texture2DCreate()

Texture::SP owl::Context::texture2DCreate ( OWLTexelFormat  texelFormat,
OWLTextureFilterMode  filterMode,
OWLTextureAddressMode  addressMode,
const vec2i  size,
uint32_t  linePitchInBytes,
const void *  texels 
)

creates a 2D texture object with given parameters; this will internally be mapped to a cuda texture object, and uploaded as such to the device

◆ trianglesGeomGroupCreate()

GeomGroup::SP owl::Context::trianglesGeomGroupCreate ( size_t  numChildren)

create a new triangles geometry group that will eventually create a BVH over all the trinalges in all its child geometries. only TrianglesGeoms can be added to this group. These triangle geoms can all have different types, different programs, etc, but must all be of "OWL_TRIANGLES" kind

◆ userGeomGroupCreate()

GeomGroup::SP owl::Context::userGeomGroupCreate ( size_t  numChildren)

create a new user geometry group that will eventually create a BVH over all the user geoms / custom prims in all its child geometries. only UserGeom's can be added to this group. These user geoms can all have different types, different programs, etc, but must all be of "OWL_TRIANGLES" kind

Member Data Documentation

◆ buffers

ObjectRegistryT<Buffer> owl::Context::buffers

registries for all the different object types within this context. allows for keeping track what's alive, and what has to be compiled, put into SBTs, etc

◆ devices

std::vector<DeviceContext::SP> owl::Context::devices
private

◆ dummyLaunchParams

LaunchParams::SP owl::Context::dummyLaunchParams

a set of dummy (ie, empty) launch params. allows us for always using the same launch code, with launch params, even if th user didn't specify any during launch

◆ geoms

ObjectRegistryT<Geom> owl::Context::geoms

◆ geomTypes

ObjectRegistryT<GeomType> owl::Context::geomTypes

◆ groups

ObjectRegistryT<Group> owl::Context::groups

◆ launchParams

ObjectRegistryT<LaunchParams> owl::Context::launchParams

◆ launchParamTypes

ObjectRegistryT<LaunchParamsType> owl::Context::launchParamTypes

◆ maxInstancingDepth

int owl::Context::maxInstancingDepth = 1

maximum depth instancing tree as specified by setMaxInstancingDepth

◆ missProgPerRayType

std::vector<MissProg::SP> owl::Context::missProgPerRayType

one miss prog per ray type

◆ missProgs

ObjectRegistryT<MissProg> owl::Context::missProgs

◆ missProgTypes

ObjectRegistryT<MissProgType> owl::Context::missProgTypes

◆ modules

ObjectRegistryT<Module> owl::Context::modules

◆ motionBlurEnabled

bool owl::Context::motionBlurEnabled = false

by default motion blur is off, as it costs performacne - set via enableMotimBlur()

◆ numRayTypes

int owl::Context::numRayTypes { 1 }

number of ray types - change via setRayTypeCount()

◆ rayGens

ObjectRegistryT<RayGen> owl::Context::rayGens

◆ rayGenTypes

ObjectRegistryT<RayGenType> owl::Context::rayGenTypes

◆ sbtRangeAllocator

RangeAllocator owl::Context::sbtRangeAllocator

tracks which ID regions in the SBT have already been used - newly created groups allocate ranges of IDs in the SBT (to allow its geometries to be in successive SBT regions), and this struct keeps track of whats already used, and what is available

◆ textures

ObjectRegistryT<Texture> owl::Context::textures

The documentation for this struct was generated from the following files: