在我的OpenCL代碼中(它不是我自己編寫的,它只是來自Internet的示例代碼),下面的句子使用了鉗位功能。在OpenCL代碼中使用鉗位功能
return clamp(color,0,1);
但是似乎這使得編譯過程中的錯誤,所以我用CL_PROGRAM_BUILD_LOG從clGetProgramBuildInfo得到了錯誤的信息的消息。
Error during compilation! (-11)
4483
build log
:211:9: error: call to 'clamp' is ambiguous
return clamp(color,0,1);
^~~~~
<built-in>:3558:26: note: candidate function
float4 __OVERLOADABLE__ clamp(float4 x, float min, float max) ;
^
<built-in>:3577:25: note: candidate function
float4 __OVERLOADABLE__ clamp(float4, float4, float4);
^
<built-in>:3556:26: note: candidate function
float3 __OVERLOADABLE__ clamp(float3 x, float min, float max) ;
^
<built-in>:3575:25: note: candidate function
float3 __OVERLOADABLE__ clamp(float3, float3, float3);
^
:296:52: error: address expression must be an lvalue or a function designator
r.origin = matrixVectorMultiply(viewTransform, &(float3)(0, 0, -1));
^~~~~~~~~~~~~~~~~~
:297:62: error: address expression must be an lvalue or a function designator
r.dir = normalize(matrixVectorMultiply(viewTransform, &(float3)(x, y, 0)) - r.origin);
^~~~~~~~~~~~~~~~~
在OpenCL代碼中使用鉗位函數有沒有必要的關鍵字?順便說一句,我正在使用Linux Ubuntu 10.04 64位的環境。
您可以從以下網站找到源代碼:http://www.gamedev.net/blog/1241/entry-2254210-realtime-raytracing-with-opencl-ii/ – user1292251 2012-08-16 10:30:32