native_render: HiDPI glyph pages, sharp UI upscaling, 4x MSAA

- CGraphicFontTexture rasterises glyph pages at the swapchain density
  (UISetFontOversample, MT_FONT_OVERSAMPLE) with anti-aliased coverage;
  metrics, packing and UVs stay the 40250 1x values. Default 1 keeps the
  verbatim bilevel path (Godot unchanged).
- native.frag: sharp-bilinear sampling for magnified UI textures.
- Multisampled colour/depth with a resolve into the swapchain (MT_MSAA,
  default 4); stats line reports msaa=N.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-28 16:56:36 +09:00
co-authored by Claude Opus 5.5
parent 22ca5da387
commit 52ccb80d01
4 changed files with 200 additions and 35 deletions
+14 -1
View File
@@ -105,7 +105,20 @@ void main() {
return;
}
// 2D UI batch (UIRenderCommand): vertex color times texture, optionally clipped by a mask.
vec4 color = in_color * texture(tex_sampler, in_uv);
// The UI is laid out in logical pixels and magnified onto a HiDPI swapchain. Plain bilinear
// smears each texel over the scale factor; "sharp bilinear" keeps texels square and only blends
// across a one-pixel seam. Minified or 1:1 texels keep the original bilinear lookup.
vec2 uv = in_uv;
vec2 tex_size = vec2(textureSize(tex_sampler, 0));
vec2 texel = uv * tex_size;
vec2 texels_per_pixel = fwidth(texel);
if (texels_per_pixel.x > 0.0 && texels_per_pixel.y > 0.0 &&
texels_per_pixel.x < 0.99 && texels_per_pixel.y < 0.99) {
vec2 seam = floor(texel + 0.5);
texel = seam + clamp((texel - seam) / texels_per_pixel, -0.5, 0.5);
uv = texel / tex_size;
}
vec4 color = in_color * texture(tex_sampler, uv);
if (draw.params.z > 0.5) {
if (in_mask_uv.x < 0.0 || in_mask_uv.x > 1.0 || in_mask_uv.y < 0.0 || in_mask_uv.y > 1.0)
discard;