我正在尝试将SFML图像发送到OpenCL。但我只会收到损坏的数据。我的猜测是我处理了pixelData错误,但我不知道如何正确地做到这一点:/
void ImageWindow::xBlend()
{
size_t size = sizeof(cl_uchar4) * textureSize.x * textureSize.y;
cl::Buffer bufferIn(manager->context, CL_MEM_READ_ONLY, size);
cl::Buffer bufferOut(manager->context, CL_MEM_WRITE_ONLY, size);
auto pixelData = (cl_uchar4*)image.getPixelsPtr();
manager->queue.enqueueWriteBuffer(bufferIn, CL_TRUE, 0, size, pixelData);
functorXBlend(bufferIn, bufferOut);
manager->queue.enqueueReadBuffer(bufferOut, CL_TRUE, 0, size, pixelData);
newTexture.update(image);
}
答案 0 :(得分:0)
自己发现错误。最愚蠢的错误。上面的代码是正确的,问题是我弄乱了本地的工作。
functorXBlend = cl::KernelFunctor(
cl::Kernel(manager->program, "xBlend"),
manager->queue, cl::NullRange,
cl::NDRange(textureSize.x, textureSize.y),
cl::NullRange);
相反,我有这个:
functorXBlend = cl::KernelFunctor(
cl::Kernel(manager->program, "xBlend"),
manager->queue, cl::NullRange,
cl::NDRange(textureSize.x, textureSize.y),
cl::NDRange(textureSize.x, textureSize.y));