[fine] Define the "r8" permutation
The "r8" variant of the fine stage can be used to target storage
textures with the r8unorm texel format. This is specifically intended
to reduce the texture memory required for coverage-mask renderers that
only output 8-bits of coverage-as-alpha in a single channel. This
format is non-standard and requires the an implementation-specific
extension.
Currently this usage requires that any encoded color in a path brush use
only the red channel as the remaning channels will be ignored.
diff --git a/shader/fine.wgsl b/shader/fine.wgsl
index 5f90f6e..a30b0de 100644
--- a/shader/fine.wgsl
+++ b/shader/fine.wgsl
@@ -33,7 +33,15 @@
var<storage> info: array<u32>;
@group(0) @binding(4)
+#ifdef r8
+// The R8 variant is available via a non-standard extension in Dawn. We can't
+// optionally declare that extension here since naga doesn't understand the
+// `enable` directive (see https://github.com/gfx-rs/wgpu/issues/5476). The
+// directive must be injected by the client via some other means.
+var output: texture_storage_2d<r8unorm, write>;
+#else
var output: texture_storage_2d<rgba8unorm, write>;
+#endif
#ifdef full
@group(0) @binding(5)
diff --git a/shader/permutations b/shader/permutations
index b235168..011541e 100644
--- a/shader/permutations
+++ b/shader/permutations
@@ -5,3 +5,6 @@
+ fine_area
+ fine_msaa8: msaa msaa8
+ fine_msaa16: msaa msaa16
++ fine_area_r8: r8
++ fine_msaa8_r8: msaa msaa8 r8
++ fine_msaa16_r8: msaa msaa16 r8