pub struct VulkanRenderer { /* private fields */ }Expand description
Stateful renderer for host-owned Vulkan frame targets.
One format-specific pipeline set is cached at a time. Changing target format destroys the prior set and rebuilds all five pipelines. The glyph atlas is lazy and remains independent of target format.
§Examples
use ailloli_ui_render_vulkan::{VulkanRenderContext, VulkanRenderer};
fn build(context: &VulkanRenderContext<'_>) {
let renderer: VulkanRenderer = VulkanRenderer::new(context, Default::default()).unwrap();
assert_eq!(renderer.stats().rects_rendered, 0);
}Implementations§
Source§impl VulkanRenderer
Construction, configuration, statistics, and synchronous frame rendering.
impl VulkanRenderer
Construction, configuration, statistics, and synchronous frame rendering.
Sourcepub fn new(
context: &VulkanRenderContext<'_>,
options: VulkanRendererOptions,
) -> Result<Self, VulkanRendererError>
pub fn new( context: &VulkanRenderContext<'_>, options: VulkanRendererOptions, ) -> Result<Self, VulkanRendererError>
Creates pipeline layouts; pipelines and the glyph atlas remain lazy.
context.memory_properties is not needed until a frame allocates geometry
or a glyph-atlas image, so construction can succeed without it.
§Errors
Returns a typed pipeline-layout or descriptor-layout error. Any layout created before a later failure is destroyed before returning.
§Examples
use ailloli_ui_render_vulkan::{VulkanRenderContext, VulkanRenderer, VulkanRendererError};
fn build(context: &VulkanRenderContext<'_>) -> Result<VulkanRenderer, VulkanRendererError> {
VulkanRenderer::new(context, Default::default())
}Sourcepub fn options(&self) -> VulkanRendererOptions
pub fn options(&self) -> VulkanRendererOptions
Returns the copyable construction options.
§Examples
use ailloli_ui_render_vulkan::VulkanRenderer;
fn inspect(renderer: &VulkanRenderer) {
let enabled: bool = renderer.options().enable_debug_labels;
assert!(!enabled);
}Sourcepub fn stats(&self) -> VulkanRendererStats
pub fn stats(&self) -> VulkanRendererStats
Returns counters for the most recently lowered scene.
§Examples
use ailloli_ui_render_vulkan::{VulkanRenderer, VulkanRendererStats};
fn inspect(renderer: &VulkanRenderer) {
let stats: VulkanRendererStats = renderer.stats();
println!("glyphs: {}", stats.glyphs_rendered);
}Sourcepub fn set_text_face_blobs(&mut self, blobs: Arc<HashMap<u64, Arc<[u8]>>>)
pub fn set_text_face_blobs(&mut self, blobs: Arc<HashMap<u64, Arc<[u8]>>>)
Replaces the shared map used to resolve non-Lucide text face IDs.
Existing atlas entries are not invalidated. Callers must assign a new face ID when blob contents change, or construct a new renderer. Missing IDs skip affected glyphs without failing the frame.
§Examples
use std::{collections::HashMap, sync::Arc};
use ailloli_ui_render_vulkan::VulkanRenderer;
fn install(renderer: &mut VulkanRenderer) {
let blobs: Arc<HashMap<u64, Arc<[u8]>>> = Arc::new(HashMap::new());
renderer.set_text_face_blobs(blobs);
}Sourcepub fn render_scene(
&mut self,
context: &VulkanRenderContext<'_>,
clear: Color,
scene: &Scene,
scale: Scale,
target: &VulkanFrameTarget,
) -> Result<(), VulkanRendererError>
pub fn render_scene( &mut self, context: &VulkanRenderContext<'_>, clear: Color, scene: &Scene, scale: Scale, target: &VulkanFrameTarget, ) -> Result<(), VulkanRendererError>
Clears and renders one scene into a host-owned target, then waits for queue idle.
Logical scene coordinates are multiplied by scale.dpr. Target image and
view ownership remain with the host; the renderer records transitions from
initial_layout to color attachment and then to final_layout. Geometry
buffers and framebuffer are allocated per call and destroyed after the
synchronous submission. An empty scene still clears the target.
§Errors
Rejects null handles and zero extents before Vulkan calls. Then propagates glyph, memory, pipeline, framebuffer, command, submission, and queue-idle errors. The target’s actual layout after a driver error is host-dependent.
§Panics
Panics only if successful text-atlas initialization fails to leave the renderer’s internal atlas slot populated.
§Examples
use ailloli_ui_core::{math::Scale, Color};
use ailloli_ui_render_vulkan::{VulkanFrameTarget, VulkanRenderContext, VulkanRenderer};
use ailloli_ui_runtime::Scene;
fn draw(renderer: &mut VulkanRenderer, context: &VulkanRenderContext<'_>,
target: &VulkanFrameTarget, scene: &Scene) {
renderer.render_scene(context, Color::BLACK, scene, Scale::new(1.0), target).unwrap();
}Trait Implementations§
Source§impl Debug for VulkanRenderer
Debug output exposes options/stats without leaking raw Vulkan handles.
impl Debug for VulkanRenderer
Debug output exposes options/stats without leaking raw Vulkan handles.
Source§impl Drop for VulkanRenderer
Releases atlas, format resources, pipeline layouts, then descriptor layout.
impl Drop for VulkanRenderer
Releases atlas, format resources, pipeline layouts, then descriptor layout.
The host must ensure no in-flight work references these objects; normal
VulkanRenderer::render_scene calls wait for queue idle before returning.