Why only write_imagef for shared gl texture?

Started by
19 comments, last by AndreyVK_D3D 5 years, 4 months ago

Hello.

I'm tring to implement opencl/opengl interop via clCreateFromGLTexture (texture sharing)

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);

With such texture I expected that write_imagei and write_imageui would work but they don't. Only write_imagef works. This behaviour is same for intel and nvidia gpus on my laptop. Why is it and why there is no such information in any documentation and in the entire internet? This pitfall cost me several hours and probably same for many developers.

 

 

Advertisement

Hi @_Flame_,

1) How do you write data to CL image ?

2) May be problem with normalized colors value (float/int/uint) ?

3) Which result from function clGetImageInfo(img, CL_IMAGE_FORMAT, sizeof(cl_image_format), imgFormat, &ret) ?

4) Try to write to CL image simple value (255, 0, 0,), which result will you receive ? 

4) Can you post your code ?

 

3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms

Hello Andrey.


__kernel
void convolution(write_only image2d_t outputImage)
{
    int tidx = get_global_id(0);
    int tidy = get_global_id(1);
    int2 coords = 0;
    coords.x = tidx;
    coords.y = tidy;
    int4 val;
    val.x = 255;
    val.y = 255;
    val.z = 255;
    val.w = 255;
    write_imagei(outputImage, coords, val);
}

2) May be problem with normalized colors value (float/int/uint) ?

The problem is that according to documentation write_imagei can be used with image_channel_data_type set to one of the following values: CL_SIGNED_INT8, CL_SIGNED_INT16, or CL_SIGNED_INT32.

I know how to control it if I create an image by clcreateimage2d by no clue how to do it with shared opengl texture.

I get black color unless i use write_imagef

Hello @_Flame_

Quote

how to do it with shared opengl texture

Which result from function clGetImageInfo(img, CL_IMAGE_FORMAT, sizeof(cl_image_format), imgFormat, &ret) ?

3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms

9 hours ago, Andrey OGL_D3D said:

Hello @_Flame_

Which result from function clGetImageInfo(img, CL_IMAGE_FORMAT, sizeof(cl_image_format), imgFormat, &ret) ?

CL_UNORM_INT8. Is it possible to control it?

According to cl spec internal GL_RGBA32I format corresponds to CL_RGBA, CL_SIGNED_INT32. But when I try to use glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, width, height, 0, GL_RGBA, GL_INT, nullptr) then clCreateFromGLTexture returns CL_INVALID_GL_OBJECT error.

Found needed combination - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, width, height, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, nullptr) or glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, width, height, 0, GL_RGBA_INTEGER, GL_INT, nullptr)

Now format is CL_SIGNED_INT32 but image is still black.

3 hours ago, _Flame_ said:

CL_UNORM_INT8. Is it possible to control it?

I don't know, I think the final format of OpenCL image is depends of OpenGL format, so you have no any means to change the result format.

3 hours ago, _Flame_ said:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32I, width, height, 0, GL_RGBA, GL_INT, nullptr)

Do have you any OpenGL Error(glGetError() ) after this calling ?

2 hours ago, _Flame_ said:

Now format is CL_SIGNED_INT32 but image is still black.

can you attach a test project ?

 

3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms

 

7 hours ago, Andrey OGL_D3D said:

Do have you any OpenGL Error(glGetError() ) after this calling ?

Looks like no.

7 hours ago, Andrey OGL_D3D said:

can you attach a test project ?

write_imagei black screen

 

Hi @_Flame_, Ok, I will chek it

3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms

@_Flame_, can you create a simple project without any dependencies ?

I haven't PkgConfig, GLFW. 

 

3DGraphics,Direct3D12,Vulkan,OpenCL,Algorithms

This topic is closed to new replies.

Advertisement