Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8355323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:49:38+00:00 2026-06-09T09:49:38+00:00

I am developing some kernels which works with image buffers. The problem is that

  • 0

I am developing some kernels which works with image buffers. The problem is that when I create my Image2D by directly copying the data of the image, everything works well.

If I try to enqueue a write to my image buffer, it won’t works for my GPU.

Here is a basic kernel :

__kernel void myKernel(__read_only image2d_t in, __write_only image2d_t out) {
    const int x = get_global_id(0);
    const int y = get_global_id(1);
    const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;

    uint4 pixel = read_imageui(in, sampler, (int2)(x, y));
    write_imageui(out, (int2)(x, y), pixel);
}

Well, that simple kernel give me a black image on my GPU, but works well on my CPU.

To make it works, I have to do release the buffer image and creating a new one by directly passing data using CL_MEM_COPY_HOST_PTR.
I use the good data format : CL_RGBA, CL_UNSIGNED_INT8 and the size of my image is good.

The problem has been encountered with JOCL and the C++ binding of the API. (I didn’t test the C API).

Finally, it runs by recreating the buffer, but is it a good idea ? Is it just normal ? Which actions can I perform to avoid it ?

By the way, I’m running on Intel SDK for OpenCL (Intel Core I7) and ATI AMD APP SDK (HD6800).

[edit]

Here is the code I use to write in my buffers.

First, the allocation part :

cl_image_format imageFormat = new cl_image_format();
imageFormat.image_channel_order = CL_RGBA;
imageFormat.image_channel_data_type = CL_UNSIGNED_INT8;

inputImageMem = clCreateImage2D(
    context, CL_MEM_READ_ONLY,
    new cl_image_format[]{imageFormat}, imageSizeX, imageSizeY,
    0, null, null);

And when running, called for each frame, the part which doesn’t work on GPU :

clEnqueueWriteImage(commandQueue, inputImageMem, CL_TRUE, new long[]{0, 0, 0},
        new long[]{imageSizeX, imageSizeY, 1}, 0, 0,
        Pointer.to(data), 0, null, null);

The part which works on both GPU and CPU but force me to recreate the buffer :

clReleaseMemObject(inputImageMem);
cl_image_format imageFormat = new cl_image_format();
imageFormat.image_channel_order = CL_RGBA;
imageFormat.image_channel_data_type = CL_UNSIGNED_INT8;
inputImageMem = clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, new cl_image_format[]{imageFormat}, imageSizeX, imageSizeY, 0, Pointer.to(data), null);

The data sent is an array of int of size imageSizeX*imageSizeY. I get it by this code :

DataBufferInt dataBuffer = (DataBufferInt)image.getRaster().getDataBuffer();
int data[] = dataBuffer.getData();

The code above is in java using JOCL, the same problem appear in an another C++ program using the C++ OpenCL Wrapper. The only differences are that in Java the virtual machine crash (after 3~4 frames) and in C++ the result is a black image.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:49:40+00:00Added an answer on June 9, 2026 at 9:49 am

    Well, I found the problem. That was my drivers acting weird.

    I was using the 12.4 version (the version I installed when I began to work with OpenCL) and I just installed the 12.6 version and the problem just disappeared.

    So, keep your drivers up to date !

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing some REST API's which are returning data in json format. ASP.net
I'm developing some sample code. I had some problem using cocos2d. That is the
I have been developing some code that uses Data.Array to use multidimensional arrays, now
I am developing some convenience wrappers around another software package that defines a bash
I am currently developing some user controls so that I can use them at
I am developing some program in C# which will send the mail using outlook
I am developing some JavaScript that should work with either Prototype.js or JQuery, thus
I'm developing some script, which developers will include on their pages. I need jQuery
I am developing some apps which depends on one of them. I see pip
I'm developing some website which is a kind of online workplace, there will be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.