1#![deny(unsafe_code)]
2#![allow(clippy::too_many_arguments)]
3
4mod capture;
5mod damage;
6mod device;
7mod diagnostics;
8mod draw;
9mod feathering;
10mod geometry;
11mod gpu;
12mod interop;
13mod output;
14mod path_cache;
15mod paths;
16mod primitives;
17mod renderer;
18mod resources;
19mod retained;
20mod scene;
21mod shaders;
22mod submission;
23mod surface;
24#[cfg(test)]
25mod tests;
26mod text;
27mod text_background;
28mod text_engine;
29mod text_hinting;
30mod text_policy;
31mod text_raster;
32mod uploads;
33
34pub use sui_scene::TextSubpixelOrder;
35
36pub use capture::DebugCaptureArtifact;
37pub use capture::DebugCaptureId;
38pub use capture::HdrRgbaImage;
39pub use capture::RgbaImage;
40pub use diagnostics::RendererFrameStats;
41pub use diagnostics::RendererPacketHotspot;
42pub use diagnostics::RetainedPacketRebuildStats;
43pub use interop::RendererInterop;
44pub use interop::WgpuExternalTextureContext;
45pub use interop::WgpuExternalTextureRegistry;
46pub use output::ColorManagementMode;
47pub use output::DEFAULT_SDR_CONTENT_BRIGHTNESS_NITS;
48pub use output::DebugCaptureEncoding;
49pub use output::DebugCaptureRequest;
50pub use output::DebugCaptureStage;
51pub use output::DebugSdrVisualization;
52pub use output::DisplayCapabilities;
53pub use output::DisplayColorPrimaries;
54pub use output::DisplayTransferFunction;
55pub use output::DynamicRangeMode;
56pub use output::OutputGamut;
57pub use output::OutputStrategy;
58pub use output::RendererCapabilities;
59pub use output::RequestedColorManagementMode;
60pub use output::RequestedDynamicRangeMode;
61pub use output::RequestedOutputColorPrimaries;
62pub use output::RequestedToneMappingMode;
63pub use output::fit_to_sdr;
64pub use renderer::MemoryTrimLevel;
65pub use text::GlyphCacheSnapshot;
66pub use text::RendererTextCacheSnapshot;
67pub use text_policy::FeatheringOptions;
68pub use text_policy::StemDarkening;
69pub use text_policy::TextCoveragePolicy;
70pub use text_policy::TextHinting;
71pub use text_policy::TextRenderMode;
72
73use crate::gpu::SharedRenderer;
74use crate::resources::CachedAnalyticPathGpu;
75use crate::resources::CachedExternalTextureBindGroup;
76use crate::resources::CachedImageTexture;
77use crate::resources::CachedTextAtlasTexture;
78use crate::resources::FrameResources;
79use crate::resources::ImageTextureCacheKey;
80use crate::resources::OffscreenTarget;
81use crate::retained::RetainedCompositorState;
82use crate::surface::SurfaceState;
83use crate::text_engine::TextEngine;
84use std::collections::HashMap;
85use sui_core::ImageHandle;
86use sui_core::WindowId;
87use sui_scene::SceneFrame;
88
89pub struct WgpuRenderer {
90 instance: wgpu::Instance,
91 feathering_enabled: bool,
92 feather_width: f32,
93 text_render_mode: TextRenderMode,
94 text_subpixel_order: TextSubpixelOrder,
95 text_hinting: TextHinting,
96 stem_darkening: StemDarkening,
97 text_coverage_policy: TextCoveragePolicy,
98 vsync_enabled: bool,
99 runtime_feathering_override: Option<FeatheringOptions>,
100 runtime_text_subpixel_order_override: Option<TextSubpixelOrder>,
101 runtime_system_text_smoothing_enabled: bool,
102 runtime_text_hinting_override: Option<TextHinting>,
103 runtime_stem_darkening_override: Option<StemDarkening>,
104 runtime_text_coverage_policy_override: Option<TextCoveragePolicy>,
105 runtime_diagnostics_enabled: bool,
106 pending_device_prepare_time_us: u64,
107 pending_device_wait_time_us: u64,
108 #[cfg(any(target_os = "linux", target_os = "windows", target_os = "macos"))]
109 device_preparation: Option<device::DevicePreparation>,
110 prepared_surfaces: HashMap<WindowId, surface::PreparedSurface>,
111 frames_rendered: usize,
112 capabilities: RendererCapabilities,
113 last_frames: HashMap<WindowId, SceneFrame>,
114 last_frame_stats: HashMap<WindowId, RendererFrameStats>,
115 shared: Option<SharedRenderer>,
116 text_engine: Option<TextEngine>,
117 image_cache: HashMap<ImageTextureCacheKey, CachedImageTexture>,
118 external_texture_registry: Option<WgpuExternalTextureRegistry>,
119 external_image_cache: HashMap<ImageHandle, CachedExternalTextureBindGroup>,
120 text_atlas_array: Option<CachedTextAtlasTexture>,
121 analytic_path_cache: HashMap<u64, CachedAnalyticPathGpu>,
122 compositors: HashMap<WindowId, RetainedCompositorState>,
123 surfaces: HashMap<WindowId, SurfaceState>,
124 offscreen_outputs: HashMap<WindowId, output::OffscreenOutput>,
127 offscreen_targets: HashMap<WindowId, OffscreenTarget>,
128 intermediate_targets: HashMap<WindowId, OffscreenTarget>,
129 swapchain_frames: HashMap<WindowId, OffscreenTarget>,
132 frame_resources: FrameResources,
133 debug_captures_in_flight: Vec<capture::InFlightCapture>,
135 next_debug_capture_id: u64,
136}