Skip to main content

damascene_ash/
lib.rs

1//! Low-level `ash`/Vulkan renderer adapter for custom Damascene hosts.
2//!
3//! Use this crate when your application already owns an `ash` renderer
4//! and wants to draw Damascene UI into its frame graph. The host remains
5//! responsible for the Vulkan instance, physical device selection,
6//! logical device, queues, command pools, command buffers, synchronization,
7//! swapchain/surfaces, frame pacing, and platform event loop.
8//!
9//! The public entry point is [`Runner`]. Its surface intentionally
10//! mirrors `damascene-wgpu` / `damascene-vulkano` where ash allows it: Damascene
11//! owns interaction state and draw-op preparation; the host owns Vulkan
12//! frame management.
13//!
14//! Rendering support is intentionally staged. Stock quad shaders, text,
15//! raster images, flat MSDF icon/vector masks, and tessellated/painted
16//! vectors are wired, and host-owned Vulkan textures can be composited
17//! through [`app_texture`]. Backdrop sampling remains unsupported.
18
19mod buffer;
20mod icon;
21mod image;
22mod naga_compile;
23mod pipeline;
24mod runner;
25mod scene;
26mod surface;
27mod text;
28
29pub use naga_compile::{CompileError, wgsl_to_spirv};
30pub use runner::{
31    AshContext, AshRenderTarget, Error, LoadOp, PreparedFrame, Result, Runner, TargetInfo,
32};
33pub use surface::{AshAppTexture, app_texture, app_texture_with_layout};
34
35pub use damascene_core::paint::PaintItem;
36pub use damascene_core::runtime::{LayoutPrepared, PointerMove, PrepareResult, PrepareTimings};
37
38use ash::vk;
39
40/// Vulkan device features the ash runner's stock pipelines depend on.
41///
42/// Hosts should merge this into their own feature chain before creating
43/// the logical device. For now this matches `damascene-vulkano`: sample-rate
44/// shading is required once MSAA stock pipelines are enabled.
45pub fn required_device_features() -> vk::PhysicalDeviceFeatures {
46    vk::PhysicalDeviceFeatures {
47        sample_rate_shading: vk::TRUE,
48        ..Default::default()
49    }
50}
51
52/// Vulkan 1.3 feature-chain requirements for the ash backend.
53///
54/// `damascene-ash`'s first rendering path uses dynamic rendering rather
55/// than host-created render passes/framebuffers, so hosts creating a
56/// Vulkan 1.3 device should include this in their `p_next` feature
57/// chain. Hosts targeting older device APIs will need the equivalent
58/// `VK_KHR_dynamic_rendering` extension path, which this crate does not
59/// wrap yet.
60pub fn required_vulkan_13_features() -> vk::PhysicalDeviceVulkan13Features<'static> {
61    vk::PhysicalDeviceVulkan13Features::default().dynamic_rendering(true)
62}
63
64/// Device extensions required by the renderer itself.
65///
66/// `damascene-ash` records rendering commands into host-owned command
67/// buffers and does not create or present swapchains, so it has no
68/// mandatory device extensions of its own. A Wayland/winit client host
69/// usually still enables `VK_KHR_swapchain` for presentation.
70pub fn required_device_extensions() -> &'static [*const std::ffi::c_char] {
71    &[]
72}