27 fastuidraw_cubic_weights(
float x)
29 float x_squared = x * x;
30 float x_cubed = x_squared * x;
31 float one_minus_x = 1.0 - x;
32 float one_minus_x_squared = one_minus_x * one_minus_x;
33 float one_minus_x_cubed = one_minus_x_squared * one_minus_x;
36 w.
x = one_minus_x_cubed;
37 w.y = 3.0 * x_cubed - 6.0 * x_squared + 4.0;
38 w.z = 3.0 * one_minus_x_cubed - 6.0 * one_minus_x_squared + 4.0;
58 adjusted = texel_coord / float(1 << L);
59 return texelFetch(surface,
ivec2(adjusted), L);
72 vec2 recip_sz = 1.0 /
vec2(textureSize(surface, 0));
73 return textureLod(surface, texel_coord * recip_sz, lod);
85 vec2 recip_sz = 1.0 /
vec2(textureSize(surface, 0));
86 vec2 fract_texel_coord, linear_weight;
87 vec4 x_weights, y_weights;
88 vec4 corner_coords, weight_sums, texture_coords;
89 vec4 t00, t10, t01, t11;
96 texel_coord -=
vec2(0.5, 0.5);
97 fract_texel_coord = fract(texel_coord);
98 texel_coord -= fract_texel_coord;
100 x_weights = fastuidraw_cubic_weights(fract_texel_coord.x);
101 y_weights = fastuidraw_cubic_weights(fract_texel_coord.y);
103 corner_coords = texel_coord.xxyy;
104 corner_coords.xz -=
vec2(0.5);
105 corner_coords.yw +=
vec2(1.5);
106 weight_sums =
vec4(x_weights.x + x_weights.y, x_weights.z + x_weights.w,
107 y_weights.x + y_weights.y, y_weights.z + y_weights.w);
109 texture_coords = corner_coords +
vec4(x_weights.yw, y_weights.yw) / weight_sums;
110 texture_coords *= recip_sz.xxyy;
112 t00 = textureLod(surface, texture_coords.xz, 0.0);
113 t10 = textureLod(surface, texture_coords.yz, 0.0);
114 t01 = textureLod(surface, texture_coords.xw, 0.0);
115 t11 = textureLod(surface, texture_coords.yw, 0.0);
117 linear_weight.x = weight_sums.y / (weight_sums.x + weight_sums.y);
118 linear_weight.y = weight_sums.w / (weight_sums.z + weight_sums.w);
120 return mix(mix(t00, t10, linear_weight.x),
121 mix(t01, t11, linear_weight.x),
vec4 fastuidraw_nearest_filter_texture(in sampler2D surface, in vec2 texel_coord, in float lod)
Peform nearest filtering on a sampler2D.
vec4 fastuidraw_linear_filter_texture(in sampler2D surface, in vec2 texel_coord, in float lod)
Peform linear filtering on a sampler2D.
vec4 fastuidraw_cubic_filter_texture(in sampler2D surface, in vec2 texel_coord)
Peform cubic filtering on a sampler2D.