Hello, I am trying to print log messages only when a ray intersects with a specific primitive type like spheres. I added the following code to my closesthit function:
// print the medium as it changes
if (optixGetPrimitiveType() == OPTIX_PRIMITIVE_TYPE_SPHERE){
printf(
"\nHit detected, Primitive index: %d hit kind: %d (0 if outside-inside, 1 if "
"inside-outside), \n previous medium id: %d \n Optical Properties: "
“%f, %f, %f, %f”,
optixGetPrimitiveIndex(), optixGetHitKind(), pl.currentMedium, medium.absorption,
medium.scattering, medium.anisotropy, medium.refractiveIndex);
}
and it seems to break the code with the following runtime error:
WARNING: additional exceptions ignored
[ 2][ ERROR]: Validation mode caught builtin exception OPTIX_EXCEPTION_CODE_UNSUPPORTED_PRIMITIVE_TYPE
Error recording resource event on user stream (CUDA error string: unspecified launch failure, CUDA error code: 719)
[ 4][ DISK CACHE]: Closed database: “/var/tmp/OptixCache_aidenlewis/optix7cache.db”
[ 4][ DISK CACHE]: Cache data size: “27.3 MiB”
[ 2][ ERROR]: Error releasing namedConstant’s internal resources (CUDA error string: unspecified launch failure, CUDA error code: 719)
Error synching on OptixPipeline event (CUDA error string: unspecified launch failure, CUDA error code: 719)
Error destroying OptixPipeline event (CUDA error string: unspecified launch failure, CUDA error code: 719)
Failed to destroy launch resources (CUDA error string: unspecified launch failure, CUDA error code: 719)
Error de-initializing device (CUDA error string: unspecified launch failure, CUDA error code: 719)
A runtime error occured.
An Optix runtime error occurred:
‘Error during validation mode run’
at (mcx_context.cpp:809)
What should I change in order to use optixGetPrimitiveType?
I’m not sure why you’re getting an error here. It’s possible the validation message could be wrong.
Off the top of my head, here are a few things I can think to try:
Since you’re using printf, try with and without the environment variable OPTIX_FORCE_DEPRECATED_LAUNCHER=1
Try running without validation, see if it works without error, or crashes / misbehaves.
Try using the other variant of optixGetPrimitiveType(hitKind) where you pass hitKind explicitly. (You can call optixGetHitKind()).
Make sure the SDK samples that call optixGetPrimitiveType() are working for you, and compare to your code to see if you can spot any setup differences. The optixHair SDK sample calls this function, for example.
Let us know how those tests pan out, and we’ll see if we have a bug that needs fixing.
Does that only happen when adding that printf statement or always when enabling the validation inside the OptixDeviceContext and using built-in sphere primitives?
What’s your system configuration?
OS version, installed GPU(s), VRAM amount, display driver version, OptiX major.minor.micro version, CUDA toolkit version used to generate the input PTX, host compiler version.
If you’re running R530 drivers, please update to R535 drivers. There was a problem with printf inside R530 drivers which required to set that environment variable David mentions, but you shouldn’t need to set that at all in this case.
Personally I would not place the OptiX intrinsics into the variadic printf function. Just read the primitive index and hit kind into local variables and print from there. You normally need them anyway inside the closest hit function to calculate the per primitive attributes, esp. when reusing the same closest hit program for different geometric primitive types.