summaryrefslogtreecommitdiffstats
path: root/wgpu/src/shader/offscreen_blit.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/shader/offscreen_blit.wgsl')
-rw-r--r--wgpu/src/shader/offscreen_blit.wgsl22
1 files changed, 22 insertions, 0 deletions
diff --git a/wgpu/src/shader/offscreen_blit.wgsl b/wgpu/src/shader/offscreen_blit.wgsl
new file mode 100644
index 00000000..9c764c36
--- /dev/null
+++ b/wgpu/src/shader/offscreen_blit.wgsl
@@ -0,0 +1,22 @@
+@group(0) @binding(0) var u_texture: texture_2d<f32>;
+@group(0) @binding(1) var out_texture: texture_storage_2d<rgba8unorm, write>;
+
+fn srgb(color: f32) -> f32 {
+ if (color <= 0.0031308) {
+ return 12.92 * color;
+ } else {
+ return (1.055 * (pow(color, (1.0/2.4)))) - 0.055;
+ }
+}
+
+@compute @workgroup_size(1)
+fn main(@builtin(global_invocation_id) id: vec3<u32>) {
+ // texture coord must be i32 due to a naga bug:
+ // https://github.com/gfx-rs/naga/issues/1997
+ let coords = vec2(i32(id.x), i32(id.y));
+
+ let src: vec4<f32> = textureLoad(u_texture, coords, 0);
+ let srgb_color: vec4<f32> = vec4(srgb(src.x), srgb(src.y), srgb(src.z), src.w);
+
+ textureStore(out_texture, coords, srgb_color);
+}