mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 02:58:11 +08:00
Cache Vello render output as stitchable textures (#3722)
* WIP render caching * Hook up render cache to render pipeline * Fixed offsets * Initial cleanup * Integrate cache with context invalidation * Cleanup * Improve rounding and reduce tile size to fix vello not rendering * Include pointer position in cache key * Avoid unwraps and zero sized textures * Destroy textures after blitting to surface * Fix context dependencies * Exclude footprint from render params * Batch animation frame messages * Add vello max render size to preference dialogue * Remove unused import * Reorder vello preference * Clean up preferences dialog * Apply review suggestions * Cap max render region size --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
5aca75dcbd
commit
0531769c41
@@ -69,6 +69,10 @@ pub struct WasmApplicationIo {
|
||||
|
||||
static WGPU_AVAILABLE: std::sync::atomic::AtomicI8 = std::sync::atomic::AtomicI8::new(-1);
|
||||
|
||||
/// Returns:
|
||||
/// - `None` if the availability of WGPU has not been determined yet
|
||||
/// - `Some(true)` if WGPU is available
|
||||
/// - `Some(false)` if WGPU is not available
|
||||
pub fn wgpu_available() -> Option<bool> {
|
||||
match WGPU_AVAILABLE.load(Ordering::SeqCst) {
|
||||
-1 => None,
|
||||
@@ -332,24 +336,38 @@ pub type WasmSurfaceHandle = SurfaceHandle<wgpu_executor::Window>;
|
||||
#[cfg(feature = "wgpu")]
|
||||
pub type WasmSurfaceHandleFrame = graphene_application_io::SurfaceHandleFrame<wgpu_executor::Window>;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, specta::Type, serde::Serialize, serde::Deserialize)]
|
||||
pub enum VelloPreference {
|
||||
Auto,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, specta::Type, serde::Serialize, serde::Deserialize)]
|
||||
pub struct EditorPreferences {
|
||||
pub use_vello: bool,
|
||||
pub vello_preference: VelloPreference,
|
||||
/// Maximum render region size in pixels along one dimension of the square area.
|
||||
pub max_render_region_size: u32,
|
||||
}
|
||||
|
||||
impl graphene_application_io::GetEditorPreferences for EditorPreferences {
|
||||
fn use_vello(&self) -> bool {
|
||||
self.use_vello
|
||||
match self.vello_preference {
|
||||
VelloPreference::Auto => wgpu_available().unwrap_or(false),
|
||||
VelloPreference::Disabled => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn max_render_region_area(&self) -> u32 {
|
||||
let size = self.max_render_region_size.min(u32::MAX.isqrt());
|
||||
size.pow(2)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EditorPreferences {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
#[cfg(target_family = "wasm")]
|
||||
use_vello: false,
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
use_vello: true,
|
||||
vello_preference: VelloPreference::Auto,
|
||||
max_render_region_size: 1280,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user