Skip to content

Commit

Permalink
allow updating dynamic rendering parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-ben committed Apr 30, 2024
1 parent 79e81d9 commit 1ba5868
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
6 changes: 2 additions & 4 deletions examples/common/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
pub mod vulkan;

#[cfg(any(target_os = "macos", target_os = "ios"))]
use ash::vk::{KhrGetPhysicalDeviceProperties2Fn, KhrPortabilityEnumerationFn};
use ash::{
extensions::{
ext::DebugUtils,
khr::{Surface, Swapchain as SwapchainLoader},
},
vk, Device, Entry, Instance,
};
#[cfg(any(target_os = "macos", target_os = "ios"))]
use ash::vk::{
KhrGetPhysicalDeviceProperties2Fn, KhrPortabilityEnumerationFn,
};
use egui::{ClippedPrimitive, Context, TextureId, ViewportId};
use egui_ash_renderer::{Options, Renderer};
use egui_winit::State;
Expand Down
32 changes: 29 additions & 3 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ impl Renderer {

/// Change the render pass to render to.
///
/// Useful if you need to render to a new render pass but don't want to rebuild
/// the entire renderer. It will rebuild the graphics pipeline from scratch so it
/// is an expensive operation.
/// 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
///
Expand All @@ -279,6 +278,33 @@ impl Renderer {
Ok(())
}

/// Change the dynamic rendering parameters.
///
/// Useful if you need to render to a target of with another color/depth format.
/// It will rebuild the graphics pipeline from scratch so it is an expensive operation.
///
/// # Arguments
///
/// * `dynamic_rendering` - The new dynamic rendering parameters.
///
/// # Errors
///
/// * [`RendererError`] - If any Vulkan error is encountered during pipeline creation.
#[cfg(feature = "dynamic-rendering")]
pub fn set_dynamic_rendering(
&mut self,
dynamic_rendering: DynamicRendering,
) -> RendererResult<()> {
unsafe { self.device.destroy_pipeline(self.pipeline, None) };
self.pipeline = create_vulkan_pipeline(
&self.device,
self.pipeline_layout,
dynamic_rendering,
self.options,
)?;
Ok(())
}

/// Free egui managed textures.
///
/// You should pass the list of textures detla contained in the [`egui::TexturesDelta::set`].
Expand Down

0 comments on commit 1ba5868

Please sign in to comment.