NVIDIA IndeX API nvidia_logo_transpbg.gif Up

Functions and macros for XAC programs. More...

Macros

#define printf_condition(PRINT_CONDITION, ...)
 Conditional printf. More...
 
#define printf_thread(THREAD_ID_X, THREAD_ID_Y, ...)
 Conditional printf, thread id comparison. More...
 
#define printf_block(BLOCK_ID_X, BLOCK_ID_Y, ...)
 Conditional printf, block id comparison. More...
 
#define printf_pixel(STATE, PX, PY, ...)
 Conditional printf, pixel position
More...
 
#define printf_box(BOX_MIN, BOX_MAX, POSITION, ...)
 Conditional printf, inside bounding box
More...
 

Enumerations

enum  NV_IDX_kernel_program_return_codes {
  NV_IDX_PROG_OK = 0x00 ,
  NV_IDX_PROG_DISCARD_SAMPLE = 0x01 ,
  NV_IDX_PROG_TERMINATE_PROGRAM_INSTANCE = 0x02
}
 Return codes for XAC programs. More...
 

Functions

float4 nv::index::xaclib::gamma_correct (const float4 &color, float gamma_exp)
 Compute gamma correction of a given input color. More...
 
bool nv::index::xaclib::is_inside_bounding_box (const float3 &box_min, const float3 &box_max, const float3 &position)
 Check if a given position inside an axis aligned bounding box. More...
 
uint2 nv::index::xaclib::get_pixel_position (const xac::Scene &scene)
 Retrieve the pixel position for the current thread. More...
 
xac::Ray nv::index::xaclib::transform_ray (const cuda::Mat4x4f &m, const xac::Ray &r)
 Transform a ray using the given matrix. More...
 
template<const xac::NV_IDX_volume_filter_types filter_type>
float3 nv::index::xaclib::volume_gradient (const xac::Sparse_volume &volume, const float3 &sample_position, float dh=1.0f)
 Sample the gradient vector of a scalar volume using the reference volume. More...
 
template<const xac::Volume_filter_mode filter_mode, const xac::Volume_classification_mode classification_mode>
float3 nv::index::xaclib::volume_gradient (const xac::Sparse_volume_sampler<float, filter_mode, classification_mode> &sampler, const float3 &sample_position, float dh=1.0f)
 Sample the gradient vector of a scalar volume using a given sampler reference (avoids sampler re-generation) More...
 
template<xac::Volume_filter_mode filter_mode, xac::Volume_classification_mode classification_mode>
NV_IDX_DEVICE_INLINE_MEMBER float3 nv::index::xaclib::volume_gradient (const xac::Sparse_volume &sparse_volume, const xac::Sparse_volume_sample_context &sparse_volume_sample_context, const float3 &sample_position, unsigned sparse_volume_attrib_idx=0u, float dh=1.0f)
 Sample the gradient vector of a scalar volume with a given sample context (regenerates sampler) More...
 
float4 nv::index::xaclib::headlight_shading (const xac::Scene &scene, const float3 &normal, const float3 &view_direction, const float4 &sample_color, const float4 &specular_color, const float diffuse_falloff=1.0f, const float shininess=100.0f, const float ambient_factor=0.f)
 Compute fixed headlight shading (light direction is view direction) More...
 
float4 nv::index::xaclib::phong_shading (const xac::Scene &scene, const xac::Material_phong &material, const xac::Light &light, const float3 &view_direction, const float3 &normal, const bool two_sided=false)
 Compute Phong shaded color with predefined colors (ambient, diffuse, specular) More...
 
float4 nv::index::xaclib::phong_shading (const xac::Scene &scene, const uint material_id, const uint light_id, const float3 &view_direction, const float3 &normal, const bool two_sided=false)
 Default Phong shading model. More...
 
bool nv::index::xaclib::intersect_ray_plane (const xac::Ray &ray, const xac::Plane &plane, float &t_hit, float2 &tex_coord_hit)
 Ray-plane intersection. More...
 
bool nv::index::xaclib::intersect_ray_box (const xac::Ray &ray, const float3 &box_min, const float3 &box_max, float &t_near, float &t_far)
 Ray-box intersection tests. More...
 
bool nv::index::xaclib::intersect_ray_cylinder (const xac::Ray &ray, const xac::Cylinder &cylinder, float &t_hit, float3 &hit_normal)
 Ray-cylinder intersection tests. More...
 
bool nv::index::xaclib::intersect_ray_ellipsoid (const xac::Ray &ray, const xac::Ellipsoid &ellipsoid, float &t_hit, float3 &hit_normal)
 Ray-cylinder intersection tests. More...
 
bool nv::index::xaclib::intersect_ray_cone (const xac::Ray &ray, const xac::Cone &cone, float &t_hit, float3 &hit_normal)
 Ray-cylinder intersection tests. More...
 
template<typename TYPE>
const TYPE * nv::index::xaclib::bind_device_buffer (uint slot_id, uint buffer_index) const
 Retrieve a CUDA buffer that has been assigned to the XAC program. More...
 
bool nv::index::xaclib::device_buffer_available (uint slot_id) const
 Determines if a CUDA buffer that has been assigned to the XAC program. More...
 

Detailed Description

Functions and macros for XAC programs.

The XAC interface also provides a set of convenience macros and functions for printing debugging information, transformation handling, basic shading operations and generic gradient operators.

Macro Definition Documentation

 printf_block

#define printf_block (   BLOCK_ID_X,
  BLOCK_ID_Y,
  ... 
)
Value:
do { \
if (blockIdx.x == BLOCK_ID_X && blockIdx.y == BLOCK_ID_Y) \
printf(__VA_ARGS__); \
} while (0)

Conditional printf, block id comparison.

 printf_box

#define printf_box (   BOX_MIN,
  BOX_MAX,
  POSITION,
  ... 
)
Value:
do { \
if (is_inside_bounding_box(BOX_MIN, BOX_MAX, POSITION)) \
printf(__VA_ARGS__); \
} while (0)
bool is_inside_bounding_box(const float3 &box_min, const float3 &box_max, const float3 &position)
Check if a given position inside an axis aligned bounding box.

Conditional printf, inside bounding box

 printf_condition

#define printf_condition (   PRINT_CONDITION,
  ... 
)
Value:
do { \
if ((bool)PRINT_CONDITION) \
printf(__VA_ARGS__); \
} while (0)

Conditional printf.

 printf_pixel

#define printf_pixel (   STATE,
  PX,
  PY,
  ... 
)
Value:
do { \
const uint2 pixc = nv::index::xaclib::get_pixel_position(STATE.scene); \
if (pixc.x == PX && pixc.y == PY) \
printf(__VA_ARGS__); \
} while (0)
uint2 get_pixel_position(const xac::Scene &scene)
Retrieve the pixel position for the current thread.

Conditional printf, pixel position

 printf_thread

#define printf_thread (   THREAD_ID_X,
  THREAD_ID_Y,
  ... 
)
Value:
do { \
if (threadIdx.x==THREAD_ID_X && threadIdx.y==THREAD_ID_Y) \
printf(__VA_ARGS__); \
} while (0)

Conditional printf, thread id comparison.

Enumeration Type Documentation

 NV_IDX_kernel_program_return_codes

Return codes for XAC programs.

Enumerator
NV_IDX_PROG_OK 

Indicate the sucessfull execution of the sampling program.

NV_IDX_PROG_DISCARD_SAMPLE 

Indicate that the resulting sampling result should be discarded.

NV_IDX_PROG_TERMINATE_PROGRAM_INSTANCE 

Cancel following execution operations on the current ray segment. Applies only to ray inquiry operations.

Function Documentation

 bind_device_buffer()

template<typename TYPE>
const TYPE * nv::index::xaclib::bind_device_buffer ( uint  slot_id,
uint  buffer_index 
) const

Retrieve a CUDA buffer that has been assigned to the XAC program.

The NVIDIA IndeX system can bind a buffer to an XAC program, e.g., to pass results of an inference operation to the subsequent rendering. For that, the contents of the buffer may contain arbitrary information to deal with the plethora of information that an inference operation produces.

The following illustrates the binding process of inference results when using an NVIDIA IndeX's inference technique:

mi::base::Handle<IInference_result> inference_result = ...; // Exposed through nv::index::Distributed_inference_technique::inference(..).
mi::base::Handle<nv::index::ICuda_memory_buffer> device_buffer = ...; // Request a buffer from NVIDIA IndeX's memory manager nv::index::IMemory_manager.
const uint XAC_SLOT_DEVICE_BUFFER_ID = 1; // Define a slot id.
inference_result->bind_inference_result(
mi::neuraylib::NULL_TAG, // Tag that references a specific XAC program. Currently not supported.
XAC_SLOT_DEVICE_BUFFER_ID, // Slot id to identify the device buffer in the XAC program.
device_buffer.get()); // NVIDIA IndeX managed CUDA device buffer with inference results.

Once passed to the NVIDIA IndeX system, the XAC progam can access the data as follows:

const uint XAC_SLOT_DEVICE_BUFFER_ID = 1; // Re-use slot id defined above.
const uint buffer_index = 0; // The i-th element in the buffer.
const float* result_buffer = volume.bind_device_buffer<float>(XAC_SLOT_DEVICE_BUFFER_ID, buffer_index);

 device_buffer_available()

bool nv::index::xaclib::device_buffer_available ( uint  slot_id) const

Determines if a CUDA buffer that has been assigned to the XAC program.

 gamma_correct()

float4 nv::index::xaclib::gamma_correct ( const float4 &  color,
float  gamma_exp 
)

Compute gamma correction of a given input color.

 get_pixel_position()

uint2 nv::index::xaclib::get_pixel_position ( const xac::Scene scene)

Retrieve the pixel position for the current thread.

 headlight_shading()

float4 nv::index::xaclib::headlight_shading ( const xac::Scene scene,
const float3 &  normal,
const float3 &  view_direction,
const float4 &  sample_color,
const float4 &  specular_color,
const float  diffuse_falloff = 1.0f,
const float  shininess = 100.0f,
const float  ambient_factor = 0.f 
)

Compute fixed headlight shading (light direction is view direction)

 intersect_ray_box()

bool nv::index::xaclib::intersect_ray_box ( const xac::Ray ray,
const float3 &  box_min,
const float3 &  box_max,
float &  t_near,
float &  t_far 
)

Ray-box intersection tests.

 intersect_ray_cone()

bool nv::index::xaclib::intersect_ray_cone ( const xac::Ray ray,
const xac::Cone cone,
float &  t_hit,
float3 &  hit_normal 
)

Ray-cylinder intersection tests.

 intersect_ray_cylinder()

bool nv::index::xaclib::intersect_ray_cylinder ( const xac::Ray ray,
const xac::Cylinder cylinder,
float &  t_hit,
float3 &  hit_normal 
)

Ray-cylinder intersection tests.

 intersect_ray_ellipsoid()

bool nv::index::xaclib::intersect_ray_ellipsoid ( const xac::Ray ray,
const xac::Ellipsoid ellipsoid,
float &  t_hit,
float3 &  hit_normal 
)

Ray-cylinder intersection tests.

 intersect_ray_plane()

bool nv::index::xaclib::intersect_ray_plane ( const xac::Ray ray,
const xac::Plane plane,
float &  t_hit,
float2 &  tex_coord_hit 
)

Ray-plane intersection.

 is_inside_bounding_box()

bool nv::index::xaclib::is_inside_bounding_box ( const float3 &  box_min,
const float3 &  box_max,
const float3 &  position 
)

Check if a given position inside an axis aligned bounding box.

 phong_shading() [1/2]

float4 nv::index::xaclib::phong_shading ( const xac::Scene scene,
const uint  material_id,
const uint  light_id,
const float3 &  view_direction,
const float3 &  normal,
const bool  two_sided = false 
)

Default Phong shading model.

 phong_shading() [2/2]

float4 nv::index::xaclib::phong_shading ( const xac::Scene scene,
const xac::Material_phong material,
const xac::Light light,
const float3 &  view_direction,
const float3 &  normal,
const bool  two_sided = false 
)

Compute Phong shaded color with predefined colors (ambient, diffuse, specular)

 transform_ray()

xac::Ray nv::index::xaclib::transform_ray ( const cuda::Mat4x4f &  m,
const xac::Ray r 
)

Transform a ray using the given matrix.

 volume_gradient() [1/3]

template<xac::Volume_filter_mode filter_mode, xac::Volume_classification_mode classification_mode>
NV_IDX_DEVICE_INLINE_MEMBER float3 nv::index::xaclib::volume_gradient ( const xac::Sparse_volume &  sparse_volume,
const xac::Sparse_volume_sample_context sparse_volume_sample_context,
const float3 &  sample_position,
unsigned  sparse_volume_attrib_idx = 0u,
float  dh = 1.0f 
)

Sample the gradient vector of a scalar volume with a given sample context (regenerates sampler)

 volume_gradient() [2/3]

template<const xac::NV_IDX_volume_filter_types filter_type>
float3 nv::index::xaclib::volume_gradient ( const xac::Sparse_volume &  volume,
const float3 &  sample_position,
float  dh = 1.0f 
)

Sample the gradient vector of a scalar volume using the reference volume.

 volume_gradient() [3/3]

template<const xac::Volume_filter_mode filter_mode, const xac::Volume_classification_mode classification_mode>
float3 nv::index::xaclib::volume_gradient ( const xac::Sparse_volume_sampler<float, filter_mode, classification_mode> &  sampler,
const float3 &  sample_position,
float  dh = 1.0f 
)

Sample the gradient vector of a scalar volume using a given sampler reference (avoids sampler re-generation)