Skip to main content

strata_ui/
gpu_surface.rs

1//! Declarative `<GpuSurface>` Component: Low-Level Hardware GPU Escape Hatch.
2
3#![allow(non_snake_case)]
4
5use strata_dom::View;
6use strata_macro::{component, rsx};
7pub use strata_render::custom_shader::{
8    CustomShaderPipeline, FaceCullMode, GpuRenderCallback, GpuRenderContext, PrimitiveTopology,
9    WgslShaderSource, WGSL_COMPUTE_TELEMETRY_SHADER, WGSL_PBR_3D_SHADER,
10};
11
12/// Declarative Low-Level GPU Escape Hatch Component.
13///
14/// Exposes raw GPU rendering pass hooks (`on_render`) and custom WGSL compute/fragment
15/// shaders directly within the Strata component tree.
16#[component]
17pub fn GpuSurface(
18    width: Option<f32>,
19    height: Option<f32>,
20    class: Option<&'static str>,
21    on_render: Option<GpuRenderCallback>,
22) -> View {
23    let _w = width.unwrap_or(400.0);
24    let _h = height.unwrap_or(300.0);
25    let custom = class.unwrap_or("");
26
27    rsx! {
28        <div class={format!("relative overflow-hidden bg-neutral-950 rounded-xl border border-neutral-800/80 {}", custom)}>
29            <div class="absolute inset-0 pointer-events-auto" />
30        </div>
31    }
32}