Struct VulkanRenderer

Source
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.

Source

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())
}
Source

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);
}
Source

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);
}
Source

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);
}
Source

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.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats a non-exhaustive summary of stable diagnostic state.

Source§

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.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> ErasedDestructor for T
where T: 'static,