OpenCL build->崩溃,无用的错误

时间:2013-12-30 00:59:50

标签: build crash opencl nvidia intel

对于一个小项目,我一直在尝试使用OpenCL与OpenGL结合使用相对python绑定(pyOpenGL和PyOpenCL)来构建应用程序。脚趾更准确,它应该是一个广义的光线追踪器。

安装OpenCL Intel SDK NVIDIA CUDA工具包并使用英特尔的IDE编写程序后我遇到了一个问题:

每当我尝试构建程序时,intel编译器“停止工作”或者NVIDIA会给我一个“无效值 - ”消息。如果我只是编译程序一切顺利,没有任何不好的事情发生。

如果我故意在代码中加入错误,两个编译器都会返回正确的编译错误和行号。

我能够将问题缩小到__kernal函数但我真的不明白为什么它不会构建但仍然编译?有什么我想念的吗?

(请原谅可能不好的opencl代码。我第一次写的是与C类似的东西)

The Kernal:

__kernel void raytrace(__write_only image2d_t renderTexture,
                       int2 pos, __constant float projectionsMatrix[16],
                       //Mesh Data
                       __constant int* meshIndecies, __constant float3* meshVertices,
                       __constant float3* meshNormals, __constant float2* meshUV,
                       __constant int* meshTriangleIndecies, __constant int* meshTriangles,
                       //Material Data
                       __constant float4* emissions, __constant float4* ambients,
                       __constant float4* diffuses, __constant float4* speculars,
                       __constant float* shininesses,
                       //Object Data
                       __constant float* matricies, __constant int* meshes,
                       __constant int* materials) {

    Mesh* meshData;
    int pcMeshv = 0;
    int pcMesht = 0;
    for (int cMesh = 0; cMesh < sizeof(meshIndecies)/sizeof(int); cMesh++) {
        Mesh data;

        //assign data
        for (int index = 0; index < meshIndecies[cMesh] - pcMeshv; index++) {
            data.vertices[index] = meshVertices[pcMeshv + index];
            data.normals[index] = meshNormals[pcMeshv + index];
            data.uv[index] = meshUV[pcMeshv + index];
        }

        pcMeshv = meshIndecies[cMesh];
        for (int index = 0; index < meshTriangleIndecies[cMesh] - pcMesht; index++) {
            data.triangles[index] = meshTriangles[pcMesht + index];
        }
        pcMesht = meshTriangleIndecies[cMesh];

        //add data to array
        meshData[cMesh] = data;
    }

    Material* materialData;
    for (int index = 0; index < sizeof(shininesses)/sizeof(float); index++) {
        Material data;
        data.emission = emissions[index];
        data.ambient = ambients[index];
        data.diffuse = diffuses[index];
        data.specular = speculars[index];
        data.shininess = shininesses[index];
        materialData[index] = data;
    }

    Object* objectData;
    for (int index = 0; index < sizeof(meshes)/sizeof(int); index++) {
        Object data;
        data.mesh = &meshData[meshes[index]];
        data.material = &materialData[materials[index]];

        for (int i = 0; i < 16; i++) {
            data.matrix[i] = matricies[index*16 + i];
        }

        objectData[index] = data;
    }

    //begin trace
    trace(renderTexture, pos, projectionsMatrix,
          objectData, 0);
}

结构:

typedef struct {
    float3* vertices;
    float3* normals;
    float2* uv;
    uint* triangles;
} Mesh;

typedef struct {
    float shininess;
    float4 specular;
    float4 emission;
    float4 ambient;
    float4 diffuse;
} Material;

typedef struct {
    Mesh* mesh;
    Material* material;
    float matrix[16];
} Object;

typedef struct {
    __constant float4 ambient;
    __constant float4 specular;
    __constant float4 diffuse;
    __constant float4 position;

    __constant float3 spotDirection;
    __constant float spotExponent;
    __constant float spotCutoff;

    __constant float constantAttenuation;
    __constant float linearAttenuation;
    __constant float quadraticAttenuation;
} Light;

typedef struct {
    float3 origin;
    float3 direction;
} Ray;

typedef struct {
    float3 point;
    float3 normal;
    float3 bary;
    float dist;
    uint triangle_index;
    Object* object;
} RaycastHit;

谢谢你的帮助,
Benproductions1

0 个答案:

没有答案