Renderer

Struct Renderer 

Source
pub struct Renderer { /* private fields */ }
Expand description

Vulkan renderer for egui.

It records rendering command to the provided command buffer at each call to cmd_draw.

The renderer holds a set of vertex/index buffers per in flight frames. Vertex and index buffers are resized at each call to cmd_draw if draw data does not fit.

Implementations§

Source§

impl Renderer

Source

pub fn with_default_allocator( instance: &Instance, physical_device: PhysicalDevice, device: Device, render_pass: RenderPass, options: Options, ) -> RendererResult<Self>

Create a renderer using the default allocator.

At initialization all Vulkan resources are initialized. Vertex and index buffers are not created yet.

§Arguments
  • instance - A reference to a Vulkan instance.
  • physical_device - A Vulkan physical device.
  • device - A Vulkan device.
  • render_pass - without dynamic-rendering feature - The render pass used to render the gui.
  • dynamic_rendering - with dynamic-rendering feature - Dynamic rendeing parameters
  • options - Rendering options.
§Errors
  • RendererError - If the number of in flight frame in incorrect.
  • RendererError - If any Vulkan or io error is encountered during initialization.
Source

pub fn set_render_pass(&mut self, render_pass: RenderPass) -> RendererResult<()>

Change the render pass to render to.

Useful if you need to render to a new render pass. It will rebuild the graphics pipeline from scratch so it is an expensive operation.

§Arguments
  • render_pass - The render pass used to render the gui.
§Errors
  • RendererError - If any Vulkan error is encountered during pipeline creation.
Source

pub fn set_textures( &mut self, queue: Queue, command_pool: CommandPool, textures_delta: &[(TextureId, ImageDelta)], ) -> RendererResult<()>

Free egui managed textures.

You should pass the list of textures detla contained in the egui::TexturesDelta::set. This method should be called before the frame starts rendering.

§Arguments
  • ids - The list of ids of textures to free.
  • queue - The queue used to copy image data on the GPU.
  • command_pool - A Vulkan command pool used to allocate command buffers to upload textures to the gpu.
  • textures_delta - The modifications to apply to the textures.
§Errors
  • RendererError - If any Vulkan error is encountered during pipeline creation.
Source

pub fn free_textures(&mut self, ids: &[TextureId]) -> RendererResult<()>

Free egui managed textures.

You should pass the list of ids contained in the egui::TexturesDelta::free. This method should be called after the frame is done rendering.

§Arguments
  • ids - The list of ids of textures to free.
§Errors
  • RendererError - If any Vulkan error is encountered when free the texture.
Source

pub fn add_user_texture(&mut self, set: DescriptorSet) -> TextureId

Add a user managed texture used by egui.

The descriptors set passed in this method are managed by the used and will not be freed by the renderer. This method will return a egui::TextureId which can then be used in a egui::Image.

§Arguments
  • set - The descpritor set referencing the texture to display.
§Caveat

Provided vk::DescriptorSets must be created with a descriptor set layout that is compatible with the one used by the renderer. See Pipeline Layout Compatibility.

Source

pub fn remove_user_texture(&mut self, id: TextureId)

Remove a user managed texture.

This does not free the resources, it just forgets about the texture.

§Arguments
  • id - The id of the texture to remove.
Source

pub fn cmd_draw( &mut self, command_buffer: CommandBuffer, extent: Extent2D, pixels_per_point: f32, primitives: &[ClippedPrimitive], ) -> RendererResult<()>

Record commands to render the egui::Ui.

§Arguments
  • command_buffer - The Vulkan command buffer that command will be recorded to.
  • extent - The extent of the surface to render to.
  • pixel_per_point - The number of physical pixels per point. See egui::FullOutput::pixels_per_point.
  • primitives - The primitives to render. See egui::Context::tessellate.
§Errors
  • RendererError - If any Vulkan error is encountered when recording.

Trait Implementations§

Source§

impl Drop for Renderer

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