clCreateImage problems

Hi Guys. I am learning openCL from “OpenCL in action”. It is book from 2011. Example code uses clCreateImage2D. It is out of use so I tried to use clCreateImage. I wanted to create a 5 by 5 image with
pixels saved in array and second empty image object where I wanted to write new image with kernel function. My problem appeared after calling clEnqueueNDRangeKernel. With Intel GPU it didn’t even start excuting kernel and with Nvidia GPU I got error code -5 (cl_out_of_resources). I will paste part of my code below, so maybe someone will notice a mistake. Thanks in advance :slight_smile:

png_format.image_channel_order = CL_LUMINANCE;
png_format.image_channel_data_type = CL_UNORM_INT16;


img_desc.image_type = CL_MEM_OBJECT_IMAGE2D;
img_desc.image_array_size = 1;
img_desc.image_width = width;
img_desc.image_height = height;
img_desc.image_depth = 0;
img_desc.image_row_pitch = 0;
img_desc.image_slice_pitch = 0;
img_desc.num_mip_levels = 0;
img_desc.num_samples = 0;
img_desc.buffer = NULL;

input_image = clCreateImage(context,
    CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
    &png_format, &img_desc, (void*)pixels, &err);
if (err != CL_SUCCESS)
{
    printf("err code: %d\n", err);
    perror("Could not create a image object");
    exit(1);
}
output_image = clCreateImage(context,
    CL_MEM_WRITE_ONLY, &png_format, &img_desc, NULL, &err);
if (err != CL_SUCCESS)
{
    perror("Could not create the image object");
    exit(1);
}


err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &input_image);
if (err != CL_SUCCESS)
{
    perror("Could not set the kernel arg 0 ");
    exit(1);
}
err = clSetKernelArg(kernel, 1, sizeof(cl_mem), &output_image);
if (err != CL_SUCCESS)
{
    perror("Could not set the kernel arg 1");
    exit(1);
}

queue = clCreateCommandQueue(context, device, NULL, 0);
if (err != CL_SUCCESS)
{
    perror("Could not create a command queue");
    exit(1);
}

err = clEnqueueNDRangeKernel(queue, kernel, 2, NULL, global_size,
    NULL, 0, NULL, NULL);
if (err != CL_SUCCESS)
{
    perror("Could not enqueue a kernel");
    exit(1);
}