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