构造函数调用时出现GLM cuda错误
GLM cuda error on constructor call
已解决
我正在尝试创建一个使用GLM数学库的CUDA程序。我有一个相机和光线的类/结构定义为:
class Camera
{
public:
vec3 pos;
vec3 lookat;
vec3 up;
float fov;
Camera(vec3& p, vec3& la, vec3& u, float f) : pos(p), lookat(la), up(u), fov(f) {}
Camera() : pos(vec3(0.0f, 0.0f, 10.0f)), lookat(vec3(0.0f, 0.0f, -1.0f)), up(vec3(0.0f, 1.0f, 0.0f)), fov(60.0f*0.0174532925f) {}
};
typedef struct Ray
{
vec3 pos;
vec3 dir;
__device__ __host__ Ray(vec3& p, vec3& d) : pos(p), dir(d) {}
__device__ __host__ Ray() {}
} Ray;
当我试图创建一个使用相机和光线的函数时,问题来了:
__device__ __host__ void calculateRay(int x, int y, int width, int height, Camera& camera)
{
float xoff = (x + 0.5f) / width;
float yoff = ((height - y) + 0.5f) / height;
vec3 dir = normalize(camera.lookat);
vec3 right = normalize(cross(dir, camera.up)) * (xoff - 0.5f);
vec3 down = -camera.up * (yoff - 0.5f);
dir += down + right;
vec3 rayDir = normalize(dir);
Ray ray(camera.pos, rayDir); //Error here
/*
Ray ray;
ray.pos.x = camera.pos.x;
ray.pos.y = camera.pos.y;
ray.pos.z = camera.pos.z;
ray.dir.x = rayDir.x;
ray.dir.y = rayDir.y;
ray.dir.z = rayDir.z;
*/
}
如果我注释掉"Ray Ray(camera.pos,rayDir(;"这一行,它编译得很好。如果我把它注释掉并取消注释下面的部分,它也会编译
编译器给出的错误是
error MSB3721: The command ""F:devCUDAbinnvcc.exe"
-gencode=arch=compute_50,code="sm_52,compute_50" --use-local-env
--cl-version 2013 -ccbin "F:programsMicrosoft Visual Studio 12.0VCbin"
-IG:oldthingsincludeglm -IF:devCUDAinclude -IF:devCUDAinclude
-G --keep-dir Debug -maxrregcount=0 --machine 32 --compile
-cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler
"/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debugkernel.cu.obj
"C:UsersaDocumentsVisual Studio 2013ProjectsRayTracerkernel.cu""
exited with code 255.
虽然我似乎找不到任何关于错误代码255 的原因
编辑:已解决-原来是由GLM中的一个错误引起的,返回9.6.2版本修复了这个问题。
这个问题是由GLM中的一个错误引起的,回到9.6.2版本为我修复了这个问题。它也应该在最新版本(此时为9.7.1(中修复。
相关文章:
- 编译时未启用intel oneApi CUDA支持
- 在cuda线程之间共享大量常量数据
- 了解 GLM- openGL 中的相机转换
- 为什么即使使用-cudart-static进行编译,库用户仍然需要链接到cuda运行时
- Cuda C++:设备上的Malloc类,并用来自主机的数据填充它
- OpenGl glm rotate
- CUDA内核和数学函数的显式命名空间
- CUDA:统一内存和指针地址的更改
- OpenGL 和 GLM 矩阵无法正确扩展,总是按比例缩小
- 发布旋转矩阵(openGL/glm)
- 调试 CUDA MMU 故障
- 如何在 glRotatef 中使用 glm::mat4
- 使用 CUDA 和纹理进行图像减法
- OpenGL 转换无法使用 GLM 矩阵
- 将 2D 推力::d evice_vector 复矩阵传递给 CUDA 内核函数
- 编译 CUDA 与数学函数的叮当
- 为什么 CUDA 不会导致C++代码加速?
- 如何防止 CUDA-GDB 中的<优化输出>值
- 通过Python Distutils(用于Python C扩展)使用可重定位的设备代码编译CUDA代码
- 构造函数调用时出现GLM cuda错误