pub const GPU_OUT_WGSL: &str = "// The shaders of the UI\'s GPU output (lib/ui/gpu_out.rs): the window\'s textures to the swapchain\r\n// image, pixel for pixel, opaque, no blending. lib/ui embeds them precompiled (gpu_out_spv.rs: UI\r\n// programs do not link lib/wgsl); uigputest --test shaders compares the words with what\r\n// wgsl::compile makes of this file (shader::BASIS, no robustness: only pixels of the texture are\r\n// reached, the scissor keeps the draws inside), uigputest --gen-shaders writes gpu_out_spv.rs again.\r\n@group(0) @binding(0) var frame: texture_2d<f32>;\r\n\r\n// where the texture\'s first pixel lies in the window; an image\'s steps (16.16 source pixels per\r\n// window pixel: Dc::blit_scaled). A scaled tile: x, y in 24.8, its steps the same way\r\nstruct Place {\r\n x: i32,\r\n y: i32,\r\n step_x: u32,\r\n step_y: u32,\r\n}\r\n\r\nvar<immediate> place: Place;\r\n\r\n// a triangle over the whole target\r\n@vertex\r\nfn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {\r\n let x = f32((i << 1u) & 2u);\r\n let y = f32(i & 2u);\r\n return vec4f(x * 2.0 - 1.0, 1.0 - y * 2.0, 0.0, 1.0);\r\n}\r\n\r\n// the pixel at this position; the framebuffer\'s fourth byte is no alpha, the window is opaque\r\n@fragment\r\nfn fs(@builtin(position) p: vec4f) -> @location(0) vec4f {\r\n return vec4f(textureLoad(frame, vec2i(p.xy) - vec2i(place.x, place.y), 0).rgb, 1.0);\r\n}\r\n\r\n// the source pixel of Dc::blit_scaled at this position: (d * step + step / 2) >> 16 in integers\r\n// (d * step stays below the source\'s side << 16; one to one the step is 65536, the pixel d)\r\n@fragment\r\nfn fs_image(@builtin(position) p: vec4f) -> @location(0) vec4f {\r\n let d = vec2u(vec2i(p.xy) - vec2i(place.x, place.y));\r\n let s = vec2u((d.x * place.step_x + (place.step_x >> 1u)) >> 16u, (d.y * place.step_y + (place.step_y >> 1u)) >> 16u);\r\n return vec4f(textureLoad(frame, s, 0).rgb, 1.0);\r\n}\r\n\r\n// a canvas\'s tile through a transform of the running gesture (lib/ui/canvas.rs): bilinear from four\r\n// texels, no sampler; the tile\'s border of one texel keeps them inside and joins the tiles\r\n@fragment\r\nfn fs_tile(@builtin(position) p: vec4f) -> @location(0) vec4f {\r\n let o = vec2f(f32(place.x), f32(place.y)) / 256.0;\r\n let t = (p.xy - o) * vec2f(f32(place.step_x), f32(place.step_y)) / 65536.0 - vec2f(0.5, 0.5);\r\n let f = floor(t);\r\n let w = t - f;\r\n let a = vec2i(f);\r\n let top = mix(textureLoad(frame, a, 0).rgb, textureLoad(frame, a + vec2i(1, 0), 0).rgb, w.x);\r\n let bottom = mix(textureLoad(frame, a + vec2i(0, 1), 0).rgb, textureLoad(frame, a + vec2i(1, 1), 0).rgb, w.x);\r\n return vec4f(mix(top, bottom, w.y), 1.0);\r\n}\r\n";Expand description
the embedded shaders of the output and their source (uigputest: the embedding check)