[Impeller] migrate texture fill shaders to half precision. (#40735)

[Impeller] migrate texture fill shaders to half precision.
diff --git a/impeller/compiler/shader_lib/impeller/texture.glsl b/impeller/compiler/shader_lib/impeller/texture.glsl
index 7979e89..3bbb580 100644
--- a/impeller/compiler/shader_lib/impeller/texture.glsl
+++ b/impeller/compiler/shader_lib/impeller/texture.glsl
@@ -6,6 +6,7 @@
 #define TEXTURE_GLSL_
 
 #include <impeller/branching.glsl>
+#include <impeller/types.glsl>
 
 /// Sample from a texture.
 ///
@@ -92,6 +93,26 @@
   return texture(tex, coords);
 }
 
+const float16_t kTileModeDecalHf = 3.0hf;
+
+/// Sample a texture, emulating a specific tile mode.
+///
+/// This is useful for Impeller graphics backend that don't have native support
+/// for Decal.
+f16vec4 IPHalfSampleWithTileMode(f16sampler2D tex,
+                                 f16vec2 coords,
+                                 float16_t x_tile_mode,
+                                 float16_t y_tile_mode) {
+  if (x_tile_mode == kTileModeDecalHf &&
+          (coords.x < 0.0hf || coords.x >= 1.0hf) ||
+      y_tile_mode == kTileModeDecalHf &&
+          (coords.y < 0.0hf || coords.y >= 1.0hf)) {
+    return f16vec4(0.0hf);
+  }
+
+  return texture(tex, coords);
+}
+
 /// Sample a texture, emulating a specific tile mode.
 ///
 /// This is useful for Impeller graphics backend that don't have native support
diff --git a/impeller/entity/BUILD.gn b/impeller/entity/BUILD.gn
index 69c7726..15f745c 100644
--- a/impeller/entity/BUILD.gn
+++ b/impeller/entity/BUILD.gn
@@ -11,6 +11,8 @@
     vulkan_language_version = 130
   }
 
+  use_half_textures = true
+
   shaders = [
     "shaders/blending/advanced_blend.vert",
     "shaders/blending/advanced_blend_color.frag",
diff --git a/impeller/entity/shaders/texture_fill.frag b/impeller/entity/shaders/texture_fill.frag
index 78cb9d9..85aae42 100644
--- a/impeller/entity/shaders/texture_fill.frag
+++ b/impeller/entity/shaders/texture_fill.frag
@@ -4,18 +4,18 @@
 
 #include <impeller/types.glsl>
 
-uniform sampler2D texture_sampler;
+uniform f16sampler2D texture_sampler;
 
 uniform FragInfo {
-  float alpha;
+  float16_t alpha;
 }
 frag_info;
 
-in vec2 v_texture_coords;
+in f16vec2 v_texture_coords;
 
-out vec4 frag_color;
+out f16vec4 frag_color;
 
 void main() {
-  vec4 sampled = texture(texture_sampler, v_texture_coords);
+  f16vec4 sampled = texture(texture_sampler, v_texture_coords);
   frag_color = sampled * frag_info.alpha;
 }
diff --git a/impeller/entity/shaders/texture_fill.vert b/impeller/entity/shaders/texture_fill.vert
index e0f2c78..b6af412 100644
--- a/impeller/entity/shaders/texture_fill.vert
+++ b/impeller/entity/shaders/texture_fill.vert
@@ -14,10 +14,10 @@
 in vec2 position;
 in vec2 texture_coords;
 
-out vec2 v_texture_coords;
+out f16vec2 v_texture_coords;
 
 void main() {
   gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0);
-  v_texture_coords =
-      IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale);
+  v_texture_coords = f16vec2(
+      IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale));
 }
diff --git a/impeller/entity/shaders/tiled_texture_fill.frag b/impeller/entity/shaders/tiled_texture_fill.frag
index 030a94b..9d4a916 100644
--- a/impeller/entity/shaders/tiled_texture_fill.frag
+++ b/impeller/entity/shaders/tiled_texture_fill.frag
@@ -5,24 +5,25 @@
 #include <impeller/texture.glsl>
 #include <impeller/types.glsl>
 
-uniform sampler2D texture_sampler;
+uniform f16sampler2D texture_sampler;
 
 uniform FragInfo {
-  float x_tile_mode;
-  float y_tile_mode;
-  float alpha;
+  float16_t x_tile_mode;
+  float16_t y_tile_mode;
+  float16_t alpha;
 }
 frag_info;
 
-in vec2 v_texture_coords;
+in f16vec2 v_texture_coords;
 
-out vec4 frag_color;
+out f16vec4 frag_color;
 
 void main() {
-  frag_color = IPSampleWithTileMode(texture_sampler,   // sampler
-                                    v_texture_coords,  // texture coordinates
-                                    frag_info.x_tile_mode,  // x tile mode
-                                    frag_info.y_tile_mode   // y tile mode
-                                    ) *
-               frag_info.alpha;
+  frag_color =
+      IPHalfSampleWithTileMode(texture_sampler,        // sampler
+                               v_texture_coords,       // texture coordinates
+                               frag_info.x_tile_mode,  // x tile mode
+                               frag_info.y_tile_mode   // y tile mode
+                               ) *
+      frag_info.alpha;
 }
diff --git a/impeller/entity/shaders/tiled_texture_fill.vert b/impeller/entity/shaders/tiled_texture_fill.vert
index e0f2c78..b6af412 100644
--- a/impeller/entity/shaders/tiled_texture_fill.vert
+++ b/impeller/entity/shaders/tiled_texture_fill.vert
@@ -14,10 +14,10 @@
 in vec2 position;
 in vec2 texture_coords;
 
-out vec2 v_texture_coords;
+out f16vec2 v_texture_coords;
 
 void main() {
   gl_Position = frame_info.mvp * vec4(position, 0.0, 1.0);
-  v_texture_coords =
-      IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale);
+  v_texture_coords = f16vec2(
+      IPRemapCoords(texture_coords, frame_info.texture_sampler_y_coord_scale));
 }