【发布时间】:2014-08-25 00:41:12
【问题描述】:
我有一个内核,它可以拍摄图像并根据亮度生成waveform out of it。在这个内核中,工作人员最终不得不将像素写入与其他工作人员完全相同的位置。这安全吗?
在我看来,它看起来不错(英特尔 5000 显卡),但在朋友的带有独立 GPU 的计算机上,它似乎正在泄漏内存或从 GPU 内存中的其他区域获取内存(可能缓存在 GPU 中的随机图像显示在渲染的图像)。这甚至是问题所在吗?开源代码库是GCVideoWaveform。非常感谢您对此的任何想法!
int clampInt(int value, int lowerBound, int upperBound){
if(value < lowerBound){
return lowerBound;
}
if (value > upperBound){
return upperBound;
}
return value;
}
kernel void waveformLuma(read_only image2d_t input, write_only image2d_t output, uint maxValue) {
size_t x = get_global_id(0);
size_t y = get_global_id(1);
uint4 inputColor = read_imageui(input, sampler, (int2)(x,y));
float luminance01 = (((float)inputColor.x + (float)inputColor.y + (float)inputColor.z) / 3.0) / (float)maxValue;
int newY = (get_image_dim(output).y - (luminance01*(float)(get_image_dim(output).y-1)));
newY = clampInt(newY, 0, get_image_dim(output).y-1);
write_imageui(output, (int2)(x, newY), (uint4)(maxValue, maxValue, maxValue, maxValue));
}
第一台计算机/集成 GPU
第二台计算机/独立 GPU
【问题讨论】:
标签: macos image-processing kernel opencl