v0.1.0 · macOS · Linux · Windows · iOS · Android · 鸿蒙 NEXT · WASM · 小程序

纯 Rust 跨平台应用框架。 零 WebView,8 端 GPU 硬件直绘。

彻底告别上百 MB 的浏览器内核套壳与跨进程 IPC 序列化开销。GPUX 基于 GPUI 混合模式硬件渲染管线与 GPUI-Kit 原生组件库,让你用一套类型安全的 Rust 代码,直接调用 Metal、Vulkan、DirectX 12、XComponent 与 WebGPU 跑满 120fps 原生帧率。

5 分钟快速上手 浏览 60+ 原生组件
METAL · VULKAN · DX12 · XCOMPONENT · WEBGPU DRAG TO ORBIT · 120Hz
Release 单文件体积 (Strip)
~3.8MB
首屏常驻物理内存 (RSS)
~28MB
冷启动首帧上屏耗时
16ms
进程内服务桥接 / 渲染帧率
1.2µs/ 120fps
真实 API · 零宏污染 · 编译期类型安全
src/views/monitor.rs — 声明式视图与 GPUI-Kit 组件 Rust · Store<T> + Router<R> + ActiveTheme
use gpux::prelude::*;
use gpux::ui::component::button::{Button, ButtonVariants as _};
use gpux::ui::theme::{ActiveTheme as _, Theme, ThemeMode};

pub struct ClusterMonitor {
    services: ServiceRegistry,
    store: Store<ClusterState>,
    router: Router<Route>,
}

impl Render for ClusterMonitor {
    fn render(&mut self, win: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        let state = self.store.read();
        let theme = cx.theme();

        v_flex()
            .size_full().p_5().gap_4()
            .bg(theme.background).text_color(theme.foreground)
            .child(
                h_flex().justify_between().items_center()
                    .child(format!("活跃 GPU 节点: {} · P99: {:.2}ms", state.nodes, state.p99_ms))
                    .child(
                        Button::new("theme-btn").ghost().small()
                            .label("切换主题")
                            .on_click(cx.listener(|_, _, win, cx| {
                                Theme::change(ThemeMode::Dark, Some(win), cx);
                            })),
                    ),
            )
            .child(
                h_flex().gap_2()
                    .child(
                        Button::new("scale-up").primary()
                            .label("+ 扩容推理节点")
                            .on_click(cx.listener(|this, _, _, cx| {
                                this.store.update(|s| s.nodes += 1);
                                cx.notify();
                            })),
                    )
                    .child(
                        Button::new("inspect-rpc").outline()
                            .label("采样集群快照 (ServiceRegistry)")
                            .on_click(cx.listener(Self::on_sample_snapshot)),
                    ),
            )
    }
}
src/services/cluster.rs — 强类型进程内服务桥接 零 #[tauri::command] 宏展开 · 零 JSON ACL 碎片配置
use gpux::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct InspectReq { pub region: String, pub include_vram: bool }

#[derive(Debug, Serialize, Deserialize)]
pub struct ClusterSnapshot {
    pub healthy_nodes: u32,
    pub vram_used_mb: f32,
    pub frame_budget_ms: f32,
}

// 1. 普通强类型 Rust 函数即可作为服务,无需过程宏标记
pub fn inspect_cluster(req: InspectReq) -> anyhow::Result<ClusterSnapshot> {
    Ok(ClusterSnapshot {
        healthy_nodes: 16,
        vram_used_mb: if req.include_vram { 24.8 } else { 0.0 },
        frame_budget_ms: 0.14,
    })
}

// 2. 在视图中以 1.2µs 极低延迟直接做类型安全调用
impl ClusterMonitor {
    fn on_sample_snapshot(&mut self, _: &ClickEvent, _: &mut Window, cx: &mut Context<Self>) {
        let req = InspectReq { region: "ap-east-1".into(), include_vram: true };
        if let Ok(snap) = self.services.call::<InspectReq, ClusterSnapshot>("cluster.inspect", &req) {
            self.store.update(|s| {
                s.nodes = snap.healthy_nodes;
                s.p99_ms = snap.frame_budget_ms;
            });
            cx.notify();
        }
    }
}
src/shell/adaptive.rs — 响应式断点与移动端安全区适配 自动适配桌面分栏、折叠屏、iOS 灵动岛与鸿蒙手势导航条
use gpux::prelude::*;

impl ClusterMonitor {
    pub fn render_adaptive_shell(&mut self, width: f32, height: f32) -> Div {
        // 根据视口宽度自动计算 Compact (<600px) / Medium / Expanded 断点
        let responsive = ResponsiveContext::from_viewport(width, height)
            .with_safe_area(if width < 600.0 {
                SafeAreaInsets::ios_notch() // top: 59pt, bottom: 34pt
            } else {
                SafeAreaInsets::zero()
            });

        let mut root = v_flex()
            .size_full()
            .pt(px(responsive.safe_area.top))
            .pb(px(responsive.safe_area.bottom));

        if responsive.is_mobile() {
            // 移动与小程序端:单列卡片流 + 底部手势返回路由栈
            root.px_4()
                .child(self.render_mobile_cards())
                .child(self.render_bottom_tab_bar(self.router.can_go_back()))
        } else {
            // 桌面与宽屏平板:左侧导航侧边栏 + 多列监控网格
            root.px_6().child(
                h_flex().size_full().gap_5()
                    .child(self.render_desktop_sidebar())
                    .child(self.render_telemetry_grid(responsive.breakpoint.recommended_columns())),
            )
        }
    }
}
src/lib.rs — 一套 App 定义同时驱动桌面、移动与 WASM macOS · Linux · Windows · iOS · Android · OHOS · Web · 小程序
use gpux::prelude::*;

pub fn build_app() -> gpux::App {
    App::from_manifest(AppManifest::default_for("GPUX Studio"))
        .title("GPUX Telemetry Studio")
        .size(1120.0, 720.0)
        .bind("cluster.inspect", inspect_cluster)
        .with_state(ClusterState::default())
}

// 桌面端入口 (macOS Metal / Linux Vulkan / Windows DX12)
pub fn run_desktop() -> anyhow::Result<()> {
    build_app().run_with_view(|services, win, cx| {
        ClusterMonitor::new(services, win, cx)
    })
}

// 移动端 C-ABI 导出 (iOS UIKit / Android NativeActivity / 鸿蒙 XComponent)
#[unsafe(no_mangle)]
pub extern "C" fn gpux_mobile_entry() -> i32 {
    match build_app().run_mobile() { Ok(_) => 0, Err(_) => -1 }
}

// Web (WASM) 与小程序端入口 (WebGPU / WebGL2 + CJK/Emoji 字体回退)
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn wasm_main() -> Result<(), wasm_bindgen::JsValue> {
    build_app().run_web_with_view("gpux-canvas", |s, w, cx| ClusterMonitor::new(s, w, cx))
        .map_err(|e| wasm_bindgen::JsValue::from_str(&e.to_string()))
}
实时 GPU 窗口模拟器 (Interactive Simulator)
GPUX Telemetry Studio — Metal 120Hz 120 FPS · 0.14ms
Breakpoint::Expanded · 3 Columns Router: Route::Nodes
Active Nodes
16
P99 Frame
0.14ms
VRAM RSS
24.8MB
✓ ServiceRegistry 就绪:点击上方按钮测试响应式 Store<ClusterState> 与强类型 RPC 调用
无 DOM 树 · 无 CSS 重排 · 纯 GPUI 图元着色器硬件直绘 查看 45+ 原生组件文档 →

01 · Core Architecture

为什么工程团队选择 GPUX?

兼顾游戏引擎级的 120Hz GPU 渲染管线与现代声明式 UI 的开发效率,彻底消除前端 JS/TS 与后端 Rust 之间的胶水层割裂。

02 · Write Once in Rust, Render Everywhere on GPU

一套 Rust 视图,8 大宿主平台原生呈现

gpux-desktop、gpux-mobile 与内置 Web/小程序运行时自动接管不同操作系统的窗口句柄、高刷垂直同步(VSync)、输入法(IME)与异形屏安全区。

Desktop · Apple Silicon & Intel
macOS (Metal + CoreText)

原生支持 120Hz ProMotion 自适应高刷、沉浸式透明标题栏与红绿灯控制、macOS 全局系统菜单栏以及公证签名 .dmg 打包。

Desktop · Wayland & X11
Linux (Vulkan + Cosmic-Text)

原生支持 Wayland 分数缩放协议与 DMA-BUF 零拷贝合成,彻底摆脱 webkit2gtk 依赖地狱,在 GNOME / KDE / Hyprland / Niri 下极速直绘。

Desktop · Win32 & Windows 11
Windows (DirectX 12 + DirectWrite)

无需捆绑 Evergreen WebView2 运行时,原生支持 Windows 11 Mica / Acrylic 云母材质、高 DPI 缩放、系统托盘与单文件 .msi 安装包。

Mobile · iPhone & iPad
iOS / iPadOS (Metal + UIKit Host)

编译为 staticlib 嵌入 Xcode 宿主工程,原生对接 CADisplayLink 120Hz 触控采样、灵动岛 SafeAreaInsets 与 FaceID。

Mobile · NativeActivity JNI
Android (Vulkan / GLES3 + NDK)

编译为 cdylib 挂载至 Android SurfaceView,内置软键盘弹出避让、全面屏侧滑返回手势拦截与 Gradle 自动化签名构建。

Mobile · Native ArkTS Shell
HarmonyOS NEXT (XComponent)

原生适配 aarch64-unknown-linux-ohos 编译目标,直接通过纯血鸿蒙 Native XComponent 获取 EGL/Vulkan 表面满帧直绘。

Web · wasm32-unknown-unknown
Web (WASM + WebGPU / WebGL2)

通过 gpui-kit/web 编译为超轻量 WASM 模块,自动协商浏览器 WebGPU 或 WebGL2 上下文,内置 CJK 中日韩与彩色 Emoji 字体智能回退。

MiniProgram · WeChat / Alipay / Douyin
小程序 (MiniProgram WebGL2)

自动生成小程序 OffscreenCanvas + WebGL2 适配层与 app.json 宿主脚手架,将同一套 Rust GPU 视图直接嵌入微信、支付宝与抖音小程序。

CLI · Unified Toolchain
全平台一键构建 (gpux-cli)

内置 gpux doctor 实时检测本机 Rust targets、NDK、OHOS SDK 与 wasm-bindgen,一行 gpux build --platform <target> 搞定交付。

03 · Verified Telemetry

同场景跨框架实测基准对比

在相同硬件(Apple M3 Max / Linux Wayland Vulkan)下运行同一「响应式状态 + 10,000 行虚拟列表 + 1,000 次服务调用」应用,实测安装包体积与物理内存占用。查看 完整基准测试报告 →

Release 二进制体积 · Strip 后单文件 (越短越好)

无需打包 Chromium 内核或庞大运行时引擎。

  • GPUX 3.8 MB
  • Tauri 2.0 8.9 MB
  • Flutter 18.4 MB
  • Electron 85.0 MB

首屏常驻物理内存 RSS · 含全部子进程 (越短越好)

GPUX 采用单进程 GPU 图元直绘,无独立浏览器渲染进程开销。

  • GPUX 28 MB
  • Flutter 62 MB
  • Tauri 2.0 96 MB
  • Electron 210 MB

04 · Documentation & Native UI Book

探索完整工程文档体系

涵盖从环境搭建、架构剖析、强类型服务桥接、8 端宿主适配到 60+ 原生 GPU 组件的详尽开发手册。

05 · Community & Global Ecosystem

加入 GPUX 全球开源社区

与全球 Rust、GPUI、WGSL 着色器与跨端系统工程师实时交流架构设计、分享 120fps 原生应用案例,并订阅最新版本与安全公告。