We have a larger project and recently switched from OptiX 7 / PTX to OptiX 8 / optix-ir.
Ever since, we cannot run the project in Debug mode in MSVC anymore. The optixModuleCreate function will throw a runtime error:
COMPILE ERROR: Malformed input. See compile details for more information.
Error: Taking the address of functions is illegal because indirect function calls are illegal.
The stack trace it gives has no address function usage whatsoever. The function it complains at is a utility class constructor, similar to this:
template<typname T, int N>
class container {
container() = default
__host__ __device__
container(std::initializer_list<T> v) {
public:
std::size_t i = 0;
for(const T &val : v){
values[i++] = val;
}
private:
T values[N] = {};
}
};
used by a default constructor in a different class
class foo {
public:
foo() = default;
// contains members and other ctors for member setting, but compile error points to foo() = default; line
};
and on top of the stack there is just an object creation in an optix file
struct ClostestHitContext {
// ... stuff that doesn't matter
__device__
Ray SpawnRay(const Point3f &p) const {
foo f(p1, p2); // erroneous line, goes to the foo() = default; ctor at some point
// ... other code
}
};
I cannot give out more code for this, but according to the error that is all that is failing.
Again, this happens only in Debug mode in Visual Studio (we use 2022). In both Release and RelWithDebInfo, it works fine.
On Debug we use
moduleCompileOptions.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_0;
moduleCompileOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
and on Release
moduleCompileOptions.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_3;
moduleCompileOptions.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_NONE;
I cannot easily try a Debug build with the Optimization settings (i.e. C++ Debug, but OptiX optimized) due to our cmake setup
CMAKE_CUDA_STANDARD is set to 20, it happens with different CUDA versions (I tried 12.2, 12.4 and 12.5) among different graphics cards (RTX A1000 Laptop, RTX 4070) and different driver versions (555.99, 552.74, 552.12).
Is there anything (obviously) wrong with this setup?