pub struct Renderer { /* private fields */ }Expand description
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn with_default_allocator(
instance: &Instance,
physical_device: PhysicalDevice,
device: Device,
render_pass: RenderPass,
options: Options,
) -> RendererResult<Self>
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 parametersoptions- Rendering options.
§Errors
RendererError- If the number of in flight frame in incorrect.RendererError- If any Vulkan or io error is encountered during initialization.
Sourcepub fn set_render_pass(&mut self, render_pass: RenderPass) -> RendererResult<()>
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.
Sourcepub fn set_textures(
&mut self,
queue: Queue,
command_pool: CommandPool,
textures_delta: &[(TextureId, ImageDelta)],
) -> RendererResult<()>
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.
Sourcepub fn free_textures(&mut self, ids: &[TextureId]) -> RendererResult<()>
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.
Sourcepub fn add_user_texture(&mut self, set: DescriptorSet) -> TextureId
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.
Sourcepub fn remove_user_texture(&mut self, id: TextureId)
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.
Sourcepub fn cmd_draw(
&mut self,
command_buffer: CommandBuffer,
extent: Extent2D,
pixels_per_point: f32,
primitives: &[ClippedPrimitive],
) -> RendererResult<()>
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. Seeegui::FullOutput::pixels_per_point.primitives- The primitives to render. Seeegui::Context::tessellate.
§Errors
RendererError- If any Vulkan error is encountered when recording.