Skip to content

atkurtul/slcc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

a prototype OpenCL-like language compiler

alt text

alt text

Feeding the upper image to the code below and running it as a vulkan compute shader produces the bottom image

Source Code:

kernel [1,1,1]
fn main(input_image: image2d, size: int) -> (output_image: image2d)
{ 
    int2 image_size  = get_image_size(input_image);
    int width = image_size.x;
    int height = image_size.y;

    uint2 coord = [ get_global_id(0), get_global_id(1) ];

    float4 sum  = 0;
    uint  num  = 0;

    int2 shift = 0;

    for (shift.x = -size; shift.x <= size; ++shift.x) {
        for (shift.y = -size; shift.y <= size; ++shift.y) {
            int2 cur = coord + shift;
            if ((0 <= cur.x) && (cur.x < width) && (0 <= cur.y) && (cur.y < height)) {
                ++num;
                sum += read_image(input_image, cur);
            }
        }
    }
    write_image(output_image, coord, sum  / num);
}

Dissambled spirv generated by the compiler

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages