OptiX  3.9
NVIDIA OptiX Acceleration Engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
optixu.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
4  *
5  * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
6  * rights in and to this software, related documentation and any modifications thereto.
7  * Any use, reproduction, disclosure or distribution of this software and related
8  * documentation without an express license agreement from NVIDIA Corporation is strictly
9  * prohibited.
10  *
11  * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
12  * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
13  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14  * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
15  * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
16  * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
17  * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
18  * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
19  * SUCH DAMAGES
20  */
21 
27 #ifndef __optix_optixu_h__
28 #define __optix_optixu_h__
29 
30 #include <stddef.h>
31 #include "../optix.h"
32 
33 #ifdef __cplusplus
34 # define RTU_INLINE inline
35 #else
36 # ifdef _MSC_VER
37 # define RTU_INLINE __inline
38 # else
39 # define RTU_INLINE static inline
40 # endif
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
58  RTresult RTAPI rtuNameForType( RTobjecttype type, char* buffer, RTsize bufferSize );
59 
71  RTresult RTAPI rtuGetSizeForRTformat( RTformat format, size_t* size);
72 
86  RTresult RTAPI rtuCUDACompileString( const char* source, const char** preprocessorArguments, unsigned int numPreprocessorArguments, RTsize* resultSize, RTsize* errorSize );
87 
101  RTresult RTAPI rtuCUDACompileFile( const char* filename, const char** preprocessorArguments, unsigned int numPreprocessorArguments, RTsize* resultSize, RTsize* errorSize );
102 
115  RTresult RTAPI rtuCUDAGetCompileResult( char* result, char* error );
116 
117 #ifdef __cplusplus
118 } /* extern "C" */
119 #endif
120 
128 #ifndef __cplusplus
129  RTU_INLINE RTresult rtuGroupAddChild ( RTgroup group, RTobject child, unsigned int* index );
130  RTU_INLINE RTresult rtuSelectorAddChild ( RTselector selector, RTobject child, unsigned int* index );
131 #else
132  RTU_INLINE RTresult rtuGroupAddChild ( RTgroup group, RTgroup child, unsigned int* index );
133  RTU_INLINE RTresult rtuGroupAddChild ( RTgroup group, RTselector child, unsigned int* index );
134  RTU_INLINE RTresult rtuGroupAddChild ( RTgroup group, RTtransform child, unsigned int* index );
135  RTU_INLINE RTresult rtuGroupAddChild ( RTgroup group, RTgeometrygroup child, unsigned int* index );
136  RTU_INLINE RTresult rtuSelectorAddChild ( RTselector selector, RTgroup child, unsigned int* index );
137  RTU_INLINE RTresult rtuSelectorAddChild ( RTselector selector, RTselector child, unsigned int* index );
138  RTU_INLINE RTresult rtuSelectorAddChild ( RTselector selector, RTtransform child, unsigned int* index );
139  RTU_INLINE RTresult rtuSelectorAddChild ( RTselector selector, RTgeometrygroup child, unsigned int* index );
140 #endif
141  RTU_INLINE RTresult rtuGeometryGroupAddChild( RTgeometrygroup geometrygroup, RTgeometryinstance child, unsigned int* index );
150 #ifndef __cplusplus
151  RTU_INLINE RTresult rtuTransformSetChild ( RTtransform transform, RTobject child );
152 #else
153  RTU_INLINE RTresult rtuTransformSetChild ( RTtransform transform, RTgroup child );
154  RTU_INLINE RTresult rtuTransformSetChild ( RTtransform transform, RTselector child );
155  RTU_INLINE RTresult rtuTransformSetChild ( RTtransform transform, RTtransform child );
156  RTU_INLINE RTresult rtuTransformSetChild ( RTtransform transform, RTgeometrygroup child );
157 #endif
158 
166  RTU_INLINE RTresult rtuTransformGetChild ( RTtransform transform, RTobject* type );
167  RTU_INLINE RTresult rtuTransformGetChildType ( RTtransform transform, RTobjecttype* type );
178  RTU_INLINE RTresult rtuGroupRemoveChild ( RTgroup group, RTobject child );
179  RTU_INLINE RTresult rtuSelectorRemoveChild ( RTselector selector, RTobject child );
180  RTU_INLINE RTresult rtuGeometryGroupRemoveChild( RTgeometrygroup geometrygroup, RTgeometryinstance child );
191  RTU_INLINE RTresult rtuGroupRemoveChildByIndex ( RTgroup group, unsigned int index );
192  RTU_INLINE RTresult rtuSelectorRemoveChildByIndex ( RTselector selector, unsigned int index );
193  RTU_INLINE RTresult rtuGeometryGroupRemoveChildByIndex( RTgeometrygroup geometrygroup, unsigned int index );
203  RTU_INLINE RTresult rtuGroupGetChildIndex ( RTgroup group, RTobject child, unsigned int* index );
204  RTU_INLINE RTresult rtuSelectorGetChildIndex ( RTselector selector, RTobject child, unsigned int* index );
205  RTU_INLINE RTresult rtuGeometryGroupGetChildIndex( RTgeometrygroup geometrygroup, RTgeometryinstance child, unsigned int* index );
208  /*
209  * The following implements the child management helpers declared above.
210  */
211 
212 #define RTU_CHECK_ERROR( func ) \
213  do { \
214  RTresult code = func; \
215  if( code != RT_SUCCESS ) \
216  return code; \
217  } while(0)
218 
219 #define RTU_GROUP_ADD_CHILD( _parent, _child, _index ) \
220  unsigned int _count; \
221  RTU_CHECK_ERROR( rtGroupGetChildCount( (_parent), &_count ) ); \
222  RTU_CHECK_ERROR( rtGroupSetChildCount( (_parent), _count+1 ) ); \
223  RTU_CHECK_ERROR( rtGroupSetChild( (_parent), _count, (_child) ) ); \
224  if( _index ) *(_index) = _count; \
225  return RT_SUCCESS
226 
227 #define RTU_SELECTOR_ADD_CHILD( _parent, _child, _index ) \
228  unsigned int _count; \
229  RTU_CHECK_ERROR( rtSelectorGetChildCount( (_parent), &_count ) ); \
230  RTU_CHECK_ERROR( rtSelectorSetChildCount( (_parent), _count+1 ) ); \
231  RTU_CHECK_ERROR( rtSelectorSetChild( (_parent), _count, (_child) ) ); \
232  if( _index ) *(_index) = _count; \
233  return RT_SUCCESS
234 
235 
236 #ifndef __cplusplus
237 
238  RTU_INLINE RTresult rtuGroupAddChild( RTgroup group, RTobject child, unsigned int* index )
239  {
240  RTU_GROUP_ADD_CHILD( group, child, index );
241  }
242 
243  RTU_INLINE RTresult rtuSelectorAddChild( RTselector selector, RTobject child, unsigned int* index )
244  {
245  RTU_SELECTOR_ADD_CHILD( selector, child, index );
246  }
247 
248 #else /* __cplusplus */
249 
250  RTU_INLINE RTresult rtuGroupAddChild( RTgroup group, RTgroup child, unsigned int* index )
251  {
252  RTU_GROUP_ADD_CHILD( group, child, index );
253  }
254 
255  RTU_INLINE RTresult rtuGroupAddChild( RTgroup group, RTselector child, unsigned int* index )
256  {
257  RTU_GROUP_ADD_CHILD( group, child, index );
258  }
259 
260  RTU_INLINE RTresult rtuGroupAddChild( RTgroup group, RTtransform child, unsigned int* index )
261  {
262  RTU_GROUP_ADD_CHILD( group, child, index );
263  }
264 
265  RTU_INLINE RTresult rtuGroupAddChild( RTgroup group, RTgeometrygroup child, unsigned int* index )
266  {
267  RTU_GROUP_ADD_CHILD( group, child, index );
268  }
269 
270  RTU_INLINE RTresult rtuSelectorAddChild( RTselector selector, RTgroup child, unsigned int* index )
271  {
272  RTU_SELECTOR_ADD_CHILD( selector, child, index );
273  }
274 
275  RTU_INLINE RTresult rtuSelectorAddChild( RTselector selector, RTselector child, unsigned int* index )
276  {
277  RTU_SELECTOR_ADD_CHILD( selector, child, index );
278  }
279 
280  RTU_INLINE RTresult rtuSelectorAddChild( RTselector selector, RTtransform child, unsigned int* index )
281  {
282  RTU_SELECTOR_ADD_CHILD( selector, child, index );
283  }
284 
285  RTU_INLINE RTresult rtuSelectorAddChild( RTselector selector, RTgeometrygroup child, unsigned int* index )
286  {
287  RTU_SELECTOR_ADD_CHILD( selector, child, index );
288  }
289 
290 #endif /* __cplusplus */
291 
292 #undef RTU_GROUP_ADD_CHILD
293 #undef RTU_SELECTOR_ADD_CHILD
294 
295 #ifndef __cplusplus
296 
297  RTU_INLINE RTresult rtuTransformSetChild( RTtransform transform, RTobject child )
298  {
299  RTU_CHECK_ERROR( rtTransformSetChild( transform, child ) );
300  return RT_SUCCESS;
301  }
302 
303 #else /* __cplusplus */
304 
305  RTU_INLINE RTresult rtuTransformSetChild( RTtransform transform, RTgroup child )
306  {
307  RTU_CHECK_ERROR( rtTransformSetChild( transform, child ) );
308  return RT_SUCCESS;
309  }
310 
311  RTU_INLINE RTresult rtuTransformSetChild( RTtransform transform, RTselector child )
312  {
313  RTU_CHECK_ERROR( rtTransformSetChild( transform, child ) );
314  return RT_SUCCESS;
315  }
316 
317  RTU_INLINE RTresult rtuTransformSetChild( RTtransform transform, RTtransform child )
318  {
319  RTU_CHECK_ERROR( rtTransformSetChild( transform, child ) );
320  return RT_SUCCESS;
321  }
322 
323  RTU_INLINE RTresult rtuTransformSetChild( RTtransform transform, RTgeometrygroup child )
324  {
325  RTU_CHECK_ERROR( rtTransformSetChild( transform, child ) );
326  return RT_SUCCESS;
327  }
328 
329 #endif /* __cplusplus */
330 
331  RTU_INLINE RTresult rtuTransformGetChild ( RTtransform transform, RTobject* type )
332  {
333  RTU_CHECK_ERROR( rtTransformGetChild( transform, type ) );
334  return RT_SUCCESS;
335  }
336 
338  {
339  RTU_CHECK_ERROR( rtTransformGetChildType( transform, type ) );
340  return RT_SUCCESS;
341  }
342 
343  RTU_INLINE RTresult rtuGeometryGroupAddChild( RTgeometrygroup geometrygroup, RTgeometryinstance child, unsigned int* index )
344  {
345  unsigned int count;
346  RTU_CHECK_ERROR( rtGeometryGroupGetChildCount( geometrygroup, &count ) );
347  RTU_CHECK_ERROR( rtGeometryGroupSetChildCount( geometrygroup, count+1 ) );
348  RTU_CHECK_ERROR( rtGeometryGroupSetChild( geometrygroup, count, child ) );
349  if( index ) *index = count;
350  return RT_SUCCESS;
351  }
352 
353  RTU_INLINE RTresult rtuGroupRemoveChild( RTgroup group, RTobject child )
354  {
355  unsigned int index;
356  RTU_CHECK_ERROR( rtuGroupGetChildIndex( group, child, &index ) );
357  RTU_CHECK_ERROR( rtuGroupRemoveChildByIndex( group, index ) );
358  return RT_SUCCESS;
359  }
360 
361  RTU_INLINE RTresult rtuSelectorRemoveChild( RTselector selector, RTobject child )
362  {
363  unsigned int index;
364  RTU_CHECK_ERROR( rtuSelectorGetChildIndex( selector, child, &index ) );
365  RTU_CHECK_ERROR( rtuSelectorRemoveChildByIndex( selector, index ) );
366  return RT_SUCCESS;
367  }
368 
370  {
371  unsigned int index;
372  RTU_CHECK_ERROR( rtuGeometryGroupGetChildIndex( geometrygroup, child, &index ) );
373  RTU_CHECK_ERROR( rtuGeometryGroupRemoveChildByIndex( geometrygroup, index ) );
374  return RT_SUCCESS;
375  }
376 
377  RTU_INLINE RTresult rtuGroupRemoveChildByIndex( RTgroup group, unsigned int index )
378  {
379  unsigned int count;
380  RTobject temp;
381  RTU_CHECK_ERROR( rtGroupGetChildCount( group, &count ) );
382  RTU_CHECK_ERROR( rtGroupGetChild( group, count-1, &temp ) );
383  RTU_CHECK_ERROR( rtGroupSetChild( group, index, temp ) );
384  RTU_CHECK_ERROR( rtGroupSetChildCount( group, count-1 ) );
385  return RT_SUCCESS;
386  }
387 
388  RTU_INLINE RTresult rtuSelectorRemoveChildByIndex( RTselector selector, unsigned int index )
389  {
390  unsigned int count;
391  RTobject temp;
392  RTU_CHECK_ERROR( rtSelectorGetChildCount( selector, &count ) );
393  RTU_CHECK_ERROR( rtSelectorGetChild( selector, count-1, &temp ) );
394  RTU_CHECK_ERROR( rtSelectorSetChild( selector, index, temp ) );
395  RTU_CHECK_ERROR( rtSelectorSetChildCount( selector, count-1 ) );
396  return RT_SUCCESS;
397  }
398 
399  RTU_INLINE RTresult rtuGeometryGroupRemoveChildByIndex( RTgeometrygroup geometrygroup, unsigned int index )
400  {
401  unsigned int count;
402  RTgeometryinstance temp;
403  RTU_CHECK_ERROR( rtGeometryGroupGetChildCount( geometrygroup, &count ) );
404  RTU_CHECK_ERROR( rtGeometryGroupGetChild( geometrygroup, count-1, &temp ) );
405  RTU_CHECK_ERROR( rtGeometryGroupSetChild( geometrygroup, index, temp ) );
406  RTU_CHECK_ERROR( rtGeometryGroupSetChildCount( geometrygroup, count-1 ) );
407  return RT_SUCCESS;
408  }
409 
410  RTU_INLINE RTresult rtuGroupGetChildIndex(RTgroup group, RTobject child, unsigned int* index)
411  {
412  unsigned int count;
413  RTobject temp;
414  RTU_CHECK_ERROR( rtGroupGetChildCount( group, &count ) );
415  for( *index=0; *index<count; (*index)++ ) {
416  RTU_CHECK_ERROR( rtGroupGetChild( group, *index, &temp ) );
417  if( child==temp ) return RT_SUCCESS;
418  }
419  *index = ~0u;
420  return RT_ERROR_INVALID_VALUE;
421  }
422 
423  RTU_INLINE RTresult rtuSelectorGetChildIndex( RTselector selector, RTobject child, unsigned int* index )
424  {
425  unsigned int count;
426  RTobject temp;
427  RTU_CHECK_ERROR( rtSelectorGetChildCount( selector, &count ) );
428  for( *index=0; *index<count; (*index)++ ) {
429  RTU_CHECK_ERROR( rtSelectorGetChild( selector, *index, &temp ) );
430  if( child==temp ) return RT_SUCCESS;
431  }
432  *index = ~0u;
433  return RT_ERROR_INVALID_VALUE;
434  }
435 
436  RTU_INLINE RTresult rtuGeometryGroupGetChildIndex( RTgeometrygroup geometrygroup, RTgeometryinstance child, unsigned int* index )
437  {
438  unsigned int count;
439  RTgeometryinstance temp;
440  RTU_CHECK_ERROR( rtGeometryGroupGetChildCount( geometrygroup, &count ) );
441  for( *index=0; *index<count; (*index)++ ) {
442  RTU_CHECK_ERROR( rtGeometryGroupGetChild( geometrygroup, *index, &temp ) );
443  if( child==temp ) return RT_SUCCESS;
444  }
445  *index = ~0u;
446  return RT_ERROR_INVALID_VALUE;
447  }
448 
449 
450 #ifdef __cplusplus
451 extern "C" {
452 #endif
453 
481  unsigned int usePTX32InHost64,
482  RTgeometry* mesh,
483  unsigned int num_verts,
484  const float* verts,
485  unsigned int num_tris,
486  const unsigned* indices,
487  const unsigned* mat_indices);
488 
489 
490 
525  unsigned int usePTX32InHost64,
526  RTgeometry* mesh,
527  unsigned int num_verts,
528  const float* verts,
529  unsigned int num_tris,
530  const unsigned* indices,
531  const unsigned* mat_indices,
532  RTbuffer norms,
533  const unsigned* norm_indices,
534  RTbuffer tex_coords,
535  const unsigned* tex_indices );
536 
537 #ifdef __cplusplus
538 } /* extern "C" */
539 #endif
540 
541 
542 #undef RTU_CHECK_ERROR
543 #undef RTU_INLINE
544 
545 #endif /* __optix_optixu_h__ */
546 
RTresult RTAPI rtGeometryGroupGetChild(RTgeometrygroup geometrygroup, unsigned int index, RTgeometryinstance *geometryinstance)
Returns a child node of a geometry group.
RTresult RTAPI rtSelectorSetChild(RTselector selector, unsigned int index, RTobject child)
Attaches a child node to a Selector node.
RTresult RTAPI rtTransformGetChildType(RTtransform transform, RTobjecttype *type)
Returns type information about a Transform child node.
RTU_INLINE RTresult rtuGroupRemoveChildByIndex(RTgroup group, unsigned int index)
Definition: optixu.h:377
RTresult
Definition: optix_declarations.h:236
RTresult RTAPI rtGroupGetChild(RTgroup group, unsigned int index, RTobject *child)
Returns a child node of a group.
RTU_INLINE RTresult rtuGeometryGroupGetChildIndex(RTgeometrygroup geometrygroup, RTgeometryinstance child, unsigned int *index)
Definition: optixu.h:436
struct RTgroup_api * RTgroup
Definition: optix_host.h:84
RTresult RTAPI rtSelectorGetChildCount(RTselector selector, unsigned int *count)
Returns the number of child node slots of a Selector node.
RTU_INLINE RTresult rtuTransformSetChild(RTtransform transform, RTobject child)
Definition: optixu.h:297
RTresult RTAPI rtTransformGetChild(RTtransform transform, RTobject *child)
Returns the child node that is attached to a Transform node.
RTresult RTAPI rtGroupGetChildCount(RTgroup group, unsigned int *count)
Returns the number of child slots for a group.
RTresult RTAPI rtuCUDACompileString(const char *source, const char **preprocessorArguments, unsigned int numPreprocessorArguments, RTsize *resultSize, RTsize *errorSize)
RTU_INLINE RTresult rtuGeometryGroupRemoveChild(RTgeometrygroup geometrygroup, RTgeometryinstance child)
Definition: optixu.h:369
RTresult RTAPI rtuCUDACompileFile(const char *filename, const char **preprocessorArguments, unsigned int numPreprocessorArguments, RTsize *resultSize, RTsize *errorSize)
RTresult RTAPI rtGeometryGroupSetChildCount(RTgeometrygroup geometrygroup, unsigned int count)
Sets the number of child nodes to be attached to the group.
RTresult RTAPI rtGeometryGroupGetChildCount(RTgeometrygroup geometrygroup, unsigned int *count)
Returns the number of child slots for a group.
RTU_INLINE RTresult rtuGroupRemoveChild(RTgroup group, RTobject child)
Definition: optixu.h:353
RTresult RTAPI rtTransformSetChild(RTtransform transform, RTobject child)
Attaches a child node to a Transform node.
RTU_INLINE RTresult rtuGroupAddChild(RTgroup group, RTobject child, unsigned int *index)
Definition: optixu.h:238
RTU_INLINE RTresult rtuSelectorGetChildIndex(RTselector selector, RTobject child, unsigned int *index)
Definition: optixu.h:423
struct RTbuffer_api * RTbuffer
Definition: optix_host.h:69
RTresult RTAPI rtGroupSetChild(RTgroup group, unsigned int index, RTobject child)
Attaches a child node to a group.
RTU_INLINE RTresult rtuSelectorRemoveChildByIndex(RTselector selector, unsigned int index)
Definition: optixu.h:388
struct RTgeometryinstance_api * RTgeometryinstance
Definition: optix_host.h:78
RTobjecttype
Definition: optix_declarations.h:104
RTformat
Definition: optix_declarations.h:63
struct RTgeometry_api * RTgeometry
Definition: optix_host.h:75
RTU_INLINE RTresult rtuSelectorAddChild(RTselector selector, RTobject child, unsigned int *index)
Definition: optixu.h:243
struct RTselector_api * RTselector
Definition: optix_host.h:93
RTresult RTAPI rtuCreateClusteredMeshExt(RTcontext context, unsigned int usePTX32InHost64, RTgeometry *mesh, unsigned int num_verts, const float *verts, unsigned int num_tris, const unsigned *indices, const unsigned *mat_indices, RTbuffer norms, const unsigned *norm_indices, RTbuffer tex_coords, const unsigned *tex_indices)
RTU_INLINE RTresult rtuTransformGetChild(RTtransform transform, RTobject *type)
Definition: optixu.h:331
RTresult RTAPI rtGeometryGroupSetChild(RTgeometrygroup geometrygroup, unsigned int index, RTgeometryinstance geometryinstance)
Attaches a child node to a geometry group.
RTresult RTAPI rtGroupSetChildCount(RTgroup group, unsigned int count)
Sets the number of child nodes to be attached to the group.
void * RTobject
Definition: optix_host.h:105
RTresult RTAPI rtuCreateClusteredMesh(RTcontext context, unsigned int usePTX32InHost64, RTgeometry *mesh, unsigned int num_verts, const float *verts, unsigned int num_tris, const unsigned *indices, const unsigned *mat_indices)
RTU_INLINE RTresult rtuGeometryGroupRemoveChildByIndex(RTgeometrygroup geometrygroup, unsigned int index)
Definition: optixu.h:399
RTresult RTAPI rtuNameForType(RTobjecttype type, char *buffer, RTsize bufferSize)
RTU_INLINE RTresult rtuGeometryGroupAddChild(RTgeometrygroup geometrygroup, RTgeometryinstance child, unsigned int *index)
Definition: optixu.h:343
RTU_INLINE RTresult rtuGroupGetChildIndex(RTgroup group, RTobject child, unsigned int *index)
Definition: optixu.h:410
RTresult RTAPI rtuGetSizeForRTformat(RTformat format, size_t *size)
Definition: optix_declarations.h:243
Definition: optix_declarations.h:238
struct RTtransform_api * RTtransform
Definition: optix_host.h:99
RTresult RTAPI rtuCUDAGetCompileResult(char *result, char *error)
struct RTcontext_api * RTcontext
Definition: optix_host.h:72
RTU_INLINE RTresult rtuTransformGetChildType(RTtransform transform, RTobjecttype *type)
Definition: optixu.h:337
RTresult RTAPI rtSelectorGetChild(RTselector selector, unsigned int index, RTobject *child)
Returns a child node that is attached to a Selector node.
RTresult RTAPI rtSelectorSetChildCount(RTselector selector, unsigned int count)
Specifies the number of child nodes to be attached to a Selector node.
struct RTgeometrygroup_api * RTgeometrygroup
Definition: optix_host.h:81
RTU_INLINE RTresult rtuSelectorRemoveChild(RTselector selector, RTobject child)
Definition: optixu.h:361