如果我运行下面的代码(OpenCL C 1.1,JavaCL RC3),我收到错误
Compilation failure : CL_INVALID_VALUE
关于代码的优势在于更换线后:
write_imagef(output, (int2)(coords.y,coords.x), rnd);
与
write_imagef(output, (int2)(coords.y,coords.x), pixel);
完美无缺。 如何正确初始化float4结构并为输出图像赋值?
__kernel void rotate_image(
__read_only image2d_t input,
__write_only image2d_t output,
sampler_t sampler,
int hiddenLayerX,
int hiddenLayerY
)
{
// Store each work-items unique row and column
int2 coords = (int2){get_global_id(0), get_global_id(1)};
float4 pixel = read_imagef(input, sampler, coords);
float4 rnd = (float4){1.0f,1.0f,1.0f,1.0f};
write_imagef(output, (int2)(coords.y,coords.x), rnd);
}
答案 0 :(得分:-1)
这些是不同的初始化方式:
float4 val = (float4)(1.0f); //Extends the single value to the float4
float4 val = (float4)(1.0f,1.0f,1.0f,1.0f); //Set every value
float4 val = (float4)(my_float2, my_float2); //Copy from another component(s)
float4 val = (float4)(my_float2, 1.0f, 1.0f); //Many ways
float4 val = (float4)(1.0f, my_float3); //Many more ways
...