加载 RGB 纹理缓冲区时出现 OpenCL returns "OUT_OF_RESOURCES" 错误,使用 RGBA 一切正常
OpenCL returns "OUT_OF_RESOURCES" error when loading an RGB texture-buffer and everything works fine with RGBA
OpenCL 固执地拒绝加载三分量纹理,但如果您添加一个空的第四分量,一切正常。我想这是某种与 2 的幂相关的硬件限制?有可能解决吗?
无效(“OUT_OF_RESOURCES”):
img = Image.open(path + "\color_" + str(n).zfill(4) + ".jpg")
temp_colors = np.asarray(img, dtype=np.uint8).tobytes();
clImageFormat = cl.ImageFormat(cl.channel_order.RGB,
cl.channel_type.UNSIGNED_INT8)
input_cols = cl.Image(context,
cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR,
clImageFormat,
imgSize,
None,
temp_colors)
现在工作正常:
img = Image.open(path + "\color_" + str(n).zfill(4) + ".jpg")
temp_colors = np.asarray(img, dtype=np.uint8)
zeros=np.zeros((500,500,1), dtype=np.uint8)
temp_colors=np.concatenate((temp_colors,zeros), axis=2).tobytes();
clImageFormat = cl.ImageFormat(cl.channel_order.RGBA,
cl.channel_type.UNSIGNED_INT8)
input_cols = cl.Image(context,
cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR,
clImageFormat,
imgSize,
None,
temp_colors)
内核只包含一个接受image2d_t
的空函数
来自 OpenCL spec:
For 3-component vector data types, the size of the data type is 4 *
sizeof(component). This means that a 3-component vector data type will
be aligned to a 4 * sizeof(component) boundary.
OpenCL 固执地拒绝加载三分量纹理,但如果您添加一个空的第四分量,一切正常。我想这是某种与 2 的幂相关的硬件限制?有可能解决吗?
无效(“OUT_OF_RESOURCES”):
img = Image.open(path + "\color_" + str(n).zfill(4) + ".jpg")
temp_colors = np.asarray(img, dtype=np.uint8).tobytes();
clImageFormat = cl.ImageFormat(cl.channel_order.RGB,
cl.channel_type.UNSIGNED_INT8)
input_cols = cl.Image(context,
cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR,
clImageFormat,
imgSize,
None,
temp_colors)
现在工作正常:
img = Image.open(path + "\color_" + str(n).zfill(4) + ".jpg")
temp_colors = np.asarray(img, dtype=np.uint8)
zeros=np.zeros((500,500,1), dtype=np.uint8)
temp_colors=np.concatenate((temp_colors,zeros), axis=2).tobytes();
clImageFormat = cl.ImageFormat(cl.channel_order.RGBA,
cl.channel_type.UNSIGNED_INT8)
input_cols = cl.Image(context,
cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR,
clImageFormat,
imgSize,
None,
temp_colors)
内核只包含一个接受image2d_t
的空函数来自 OpenCL spec:
For 3-component vector data types, the size of the data type is 4 * sizeof(component). This means that a 3-component vector data type will be aligned to a 4 * sizeof(component) boundary.