27 #ifndef __optix_optix_primepp_h__
28 #define __optix_optix_primepp_h__
34 #include "internal/Handle.h"
58 typedef Handle<BufferDescObj> BufferDesc;
59 typedef Handle<ContextObj> Context;
60 typedef Handle<ModelObj> Model;
61 typedef Handle<QueryObj> Query;
72 std::string getVersionString();
147 void setRange( RTPsize begin, RTPsize end );
198 void update(
unsigned hints );
329 virtual const char* what()
const throw();
334 std::string m_errorMessage;
351 #define CHK( code ) checkError( code, getContext()->getRTPcontext() )
357 inline std::string getVersionString()
359 const char* versionString;
361 return versionString;
392 checkError( r, m_ctx );
395 inline ContextObj::~ContextObj() {
405 if( deviceNumbers.size()==0 ) {
434 inline ContextObj::operator
Context()
436 Context context(
this ); context->ref();
440 inline Context ContextObj::getContext()
455 inline BufferDescObj::~BufferDescObj() {
490 inline ModelObj::ModelObj(
const Context& ctx ) : m_model(0) {
496 inline ModelObj::~ModelObj() {
509 if( indices.isValid() ) {
510 CHK(
rtpModelSetTriangles(m_model, indices->getRTPbufferdesc(), vertices->getRTPbufferdesc()) );
524 vtxBufDesc->setRange( 0, 3*triCount );
527 vtxBufDesc->setStride( stride );
539 idxBufDesc->setRange( 0, triCount );
540 vtxBufDesc->setRange( 0, vertCount );
543 vtxBufDesc->setStride( stride );
553 instances->setRange(0, count);
554 BufferDesc transforms(m_ctx->createBufferDesc(transformFormat, transformType, const_cast<void*>(transformList)));
555 transforms->setRange(0, count);
557 CHK(
rtpModelSetInstances(m_model, instances->getRTPbufferdesc(), transforms->getRTPbufferdesc()));
562 CHK(
rtpModelSetInstances(m_model, instances->getRTPbufferdesc(), transforms->getRTPbufferdesc()) );
588 inline ModelObj::operator
Model()
590 Model model(
this ); model->ref();
608 setBuilderParameter( param,
sizeof(T), &val );
615 inline QueryObj::QueryObj(
const Model& model,
RTPquerytype queryType ) : m_query(0) {
621 inline QueryObj::~QueryObj() {
629 return m_model->getContext();
639 BufferDesc desc(m_model->m_ctx->createBufferDesc(format, type, rays) );
640 desc->setRange( 0, count );
652 BufferDesc desc(m_model->m_ctx->createBufferDesc(format, type, hits) );
653 desc->setRange( 0, count );
703 inline Exception::Exception(
const std::string& message,
RTPresult error_code )
704 : m_errorMessage(message), m_errorCode( error_code )
715 return m_errorMessage;
718 inline const char* Exception::what()
const throw()
720 return m_errorMessage.c_str();
745 #endif // #ifndef __optix_optix_primepp_h__
Definition: optix_prime_declarations.h:89
Definition: optix_device.h:417
Context getContext()
Returns the context associated within this object.
Definition: optix_primepp.h:461
RTPresult RTPAPI rtpQueryCreate(RTPmodel model, RTPquerytype queryType, RTPquery *query)
Creates a query on a model.
void setCudaDeviceNumber(unsigned deviceNumber)
Sets the CUDA device number for a buffer. See rtpBufferDescSetCudaDeviceNumber.
Definition: optix_primepp.h:476
int isFinished()
Polls the status of a model update. See rtpModelGetFinished.
Definition: optix_primepp.h:575
RTPresult RTPAPI rtpBufferDescDestroy(RTPbufferdesc desc)
Destroys a buffer descriptor.
void setHits(RTPsize count, RTPbufferformat format, RTPbuffertype type, void *hits)
Sets a hit buffer for the query. See rtpQuerySetHits.
Definition: optix_primepp.h:650
RTPresult RTPAPI rtpBufferDescSetRange(RTPbufferdesc desc, RTPsize begin, RTPsize end)
Sets the element range of a buffer to use.
RTPresult RTPAPI rtpBufferDescSetStride(RTPbufferdesc desc, unsigned strideBytes)
Sets the stride for elements in a buffer.
void setRays(RTPsize count, RTPbufferformat format, RTPbuffertype type, void *rays)
Creates a buffer descriptor and sets the rays of a query. See rtpQuerySetRays.
Definition: optix_primepp.h:637
RTPresult RTPAPI rtpQueryExecute(RTPquery query, unsigned hints)
Executes a raytracing query.
Definition: optix_prime_declarations.h:67
RTPresult RTPAPI rtpGetErrorString(RTPresult errorCode, const char **errorString)
Translates an RTPresult error code to a string.
RTPresult RTPAPI rtpBufferDescSetCudaDeviceNumber(RTPbufferdesc desc, unsigned deviceNumber)
Sets the CUDA device number for a buffer.
RTPresult RTPAPI rtpModelCopy(RTPmodel model, RTPmodel srcModel)
Copies one model to another.
RTPresult RTPAPI rtpContextCreate(RTPcontexttype type, RTPcontext *context)
Creates an OptiX Prime context.
Context getContext()
Returns the context associated within this object.
Definition: optix_primepp.h:502
void setRange(RTPsize begin, RTPsize end)
Sets the range of a buffer to be used. See rtpBufferDescSetRange.
Definition: optix_primepp.h:466
void update(unsigned hints)
Creates the acceleration structure over the triangles. See rtpModelUpdate.
Definition: optix_primepp.h:565
void setCudaDeviceNumbers(const std::vector< unsigned > &deviceNumbers)
Sets the CUDA devices used by a context. See rtpContextSetCudaDeviceNumbers.
Definition: optix_primepp.h:403
RTPresult RTPAPI rtpModelSetTriangles(RTPmodel model, RTPbufferdesc indices, RTPbufferdesc vertices)
Sets the triangle data for a model.
void setCudaStream(cudaStream_t stream)
Sets a stream for a query. See rtpQuerySetCudaStream.
Definition: optix_primepp.h:676
RTPquerytype
Definition: optix_prime_declarations.h:97
Model createModel()
Creates a Model object. See rtpModelCreate.
Definition: optix_primepp.h:381
void setInstances(RTPsize count, RTPbuffertype instanceType, const RTPmodel *instanceList, RTPbufferformat transformFormat, RTPbuffertype transformType, const void *transformList)
Definition: optix_primepp.h:550
std::string getLastErrorString()
Returns a string describing last error encountered. See rtpContextGetLastErrorString.
Definition: optix_primepp.h:422
void setTriangles(RTPsize triCount, RTPbuffertype type, const void *vertPtr, unsigned stride=0)
Definition: optix_primepp.h:521
RTPresult RTPAPI rtpQueryFinish(RTPquery query)
Blocks current thread until query is finished.
RTPresult RTPAPI rtpModelDestroy(RTPmodel model)
Destroys a model.
Definition: optix_prime_declarations.h:36
RTPbufferdesc getRTPbufferdesc()
Returns the RTPbufferdesc descriptor stored within this object.
Definition: optix_primepp.h:481
void setCpuThreads(unsigned numThreads)
Sets the number of CPU threads used by a CPU context. See rtpContextSetCpuThreads.
Definition: optix_primepp.h:417
Encapsulates an OptiX Prime model. The purpose of a model is to represent a set of triangles and an a...
Definition: optix_primepp.h:175
RTPresult RTPAPI rtpQueryGetFinished(RTPquery query, int *isFinished)
Polls the status of a query.
RTPbuilderparam
Definition: optix_prime_declarations.h:121
Definition: optix_prime_declarations.h:46
void finish()
Blocks current thread until model update is finished. See rtpModelFinish.
Definition: optix_primepp.h:570
RTPresult RTPAPI rtpQuerySetHits(RTPquery query, RTPbufferdesc hits)
Sets the hits buffer for a query.
RTPbufferformat
Definition: optix_prime_declarations.h:64
void setBuilderParameter(RTPbuilderparam param, RTPsize size, const void *p)
Definition: optix_primepp.h:600
static Context create(RTPcontexttype type)
Creates a Context object. See rtpContextCreate.
Definition: optix_primepp.h:369
RTPresult RTPAPI rtpContextGetLastErrorString(RTPcontext context, const char **return_string)
Returns a string describing last error encountered.
BufferDesc createBufferDesc(RTPbufferformat format, RTPbuffertype type, void *buffer)
Creates a BufferDesc object. See rtpBufferDescCreate.
Definition: optix_primepp.h:375
struct RTPbufferdesc_api * RTPbufferdesc
Definition: optix_prime.h:69
RTPcontexttype
Definition: optix_prime_declarations.h:50
RTPresult RTPAPI rtpBufferDescCreate(RTPcontext context, RTPbufferformat format, RTPbuffertype type, void *buffer, RTPbufferdesc *desc)
Create a buffer descriptor.
struct RTPcontext_api * RTPcontext
Definition: optix_prime.h:63
RTPbuffertype
Definition: optix_prime_declarations.h:57
int isFinished()
Polls the status of a query. See rtpQueryGetFinished.
Definition: optix_primepp.h:668
RTPresult RTPAPI rtpModelSetBuilderParameter(RTPmodel model_api, RTPbuilderparam param, RTPsize size, const void *ptr)
Specifies a builder parameter for a model.
Encapsulates an OptiX Prime exception.
Definition: optix_primepp.h:313
RTPresult RTPAPI rtpContextSetCpuThreads(RTPcontext context, unsigned numThreads)
Sets the number of CPU threads used by a CPU context.
RTPresult RTPAPI rtpGetVersionString(const char **versionString)
Gets OptiX Prime version string.
void setStride(unsigned strideBytes)
Sets the stride for elements in a buffer. See rtpBufferDescSetStride.
Definition: optix_primepp.h:471
struct RTPquery_api * RTPquery
Definition: optix_prime.h:67
Definition: optix_prime_declarations.h:71
RTPresult RTPAPI rtpModelCreate(RTPcontext context, RTPmodel *model)
Creates a model.
RTPresult RTPAPI rtpModelFinish(RTPmodel model)
Blocks current thread until model update is finished.
RTPmodel getRTPmodel()
Returns the RTPmodel model stored within this object.
Definition: optix_primepp.h:237
void execute(unsigned hint)
Executes a raytracing query. See rtpQueryExecute.
Definition: optix_primepp.h:658
RTPresult RTPAPI rtpContextDestroy(RTPcontext context)
Destroys an OptiX Prime context.
RTPresult
Definition: optix_prime_declarations.h:34
RTPresult getErrorCode() const
Stores the RTPresult error code for this exception.
Definition: optix_primepp.h:708
Encapsulates an OptiX Prime buffer descriptor. The purpose of a buffer descriptor is to provide infor...
Definition: optix_primepp.h:137
struct RTPmodel_api * RTPmodel
Definition: optix_prime.h:65
RTPresult RTPAPI rtpQuerySetRays(RTPquery query, RTPbufferdesc rays)
Sets the rays buffer for a query.
RTPresult RTPAPI rtpModelGetFinished(RTPmodel model, int *isFinished)
Polls the status of a model update.
Query createQuery(RTPquerytype queryType)
Creates a Query object. See rtpQueryCreate.
Definition: optix_primepp.h:594
RTPresult RTPAPI rtpModelSetInstances(RTPmodel model, RTPbufferdesc instances, RTPbufferdesc transforms)
Sets the instance data for a model.
Context getContext()
Returns the context associated within this object.
Definition: optix_primepp.h:627
void finish()
Blocks current thread until query is finished. See rtpQueryFinish.
Definition: optix_primepp.h:663
RTPresult RTPAPI rtpContextSetCudaDeviceNumbers(RTPcontext context, unsigned deviceCount, const unsigned *deviceNumbers)
Sets the CUDA devices used by a context.
Wraps the OptiX Prime C API RTPcontext opaque type and its associated function set representing an Op...
Definition: optix_primepp.h:84
void copy(const Model &srcModel)
Copies one model to another. See rtpModelCopy.
Definition: optix_primepp.h:583
static Exception makeException(RTPresult code)
Returns a string describing last error encountered. See rtpGetErrorString.
Definition: optix_primepp.h:685
RTPquery getRTPquery()
Returns the RTPquery query stored within this object.
Definition: optix_primepp.h:290
Encapsulates an OptiX Prime query. The purpose of a query is to coordinate the intersection of rays w...
Definition: optix_primepp.h:257
RTPcontext getRTPcontext()
Returns the RTPcontext context stored within this object.
Definition: optix_primepp.h:429
const std::string & getErrorString() const
Stores the human-readable error string associated with this exception.
Definition: optix_primepp.h:713
RTPresult RTPAPI rtpModelUpdate(RTPmodel model, unsigned hints)
Updates data, or creates an acceleration structure over triangles or instances.
RTPresult RTPAPI rtpQuerySetCudaStream(RTPquery query, cudaStream_t stream)
Sets a sync stream for a query.
RTPresult RTPAPI rtpQueryDestroy(RTPquery query)
Destroys a query.