C
C
cyberpunk99992015-08-03 15:09:40
GPGPU
cyberpunk9999, 2015-08-03 15:09:40

Why does get_global_id in 2d return strange values?

Using, for example, a fragment shader in GLSL results in a gradient from start to finish, but in OpenCL it turns out to be some kind of disgrace. Although offset is zero in all dimensions.
So here is the kernel code

__kernel void simple(__write_only image2d_t tex, int width, int height){
    const int x=get_global_id(0);      //Узнаем x координату
    const int y=get_global_id(1);      //y

    write_imagef (tex, (int2)(x, y), (float4)(x/(float)width,y/(float)height,0.0f,1.0f));   //Закрашиваем текстуру
}

And the result:
5f262c6e3c2a40229b586dc4e82cf0c9.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question