Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add f16 #78

Merged
merged 1 commit into from
May 19, 2024
Merged

add f16 #78

merged 1 commit into from
May 19, 2024

Conversation

munrocket
Copy link
Contributor

Example of usage with compute-toys/wgpu-compute-toy#24

enable f16;

@compute @workgroup_size(16, 16)
fn main_image(@builtin(global_invocation_id) id: vec3u) {
    let screen_size = textureDimensions(screen);
    if (id.x >= screen_size.x || id.y >= screen_size.y) { return; }
    let fragCoord = vec2f(f32(id.x) + .5, f32(screen_size.y - id.y) - .5);
    let uv = fragCoord / vec2f(screen_size);
    var col = .5 + .5 * cos(time.elapsed + uv.xyx + vec3f(0.,2.,4.));

    // <-- Caclulate pow with f16
    col = vec3f(pow(vec3h(col), vec3h(2.2)));
    
    textureStore(screen, id.xy, vec4f(col, 1.));
}

@davidar davidar merged commit 5838706 into compute-toys:master May 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants