Skip to content

Simplify the methods for pixel reading and writing #14

@maarzt

Description

@maarzt

When writing a OpenCL kernel in clEsperanto, the code for reading a pixel usually looks like this:

const POS_src_TYPE spos = POS_src_INSTANCE(sx, sy, 0, 0);
const float a = READ_src_IMAGE(src,sampler,spos).x;

I understand the benefits that clEsperanto gives us here. But I would suggest to go further and simplify this by adding a C #define such that the example above could be rewritten as:

const float a = READ_PIXEL_2D(src, sx, sy);

The define could look like this:

#define READ_PIXEL_2D(image, x, y) (READ_ ## image ## _IMAGE((image), sampler, POS_ ## image ## _INSTANCE((x), (y), 0, 0)).x)

The same should be done for image writing, and 3d images.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions