|
|
@ -10,7 +10,7 @@ use wgpu::util::DeviceExt as _; |
|
|
|
/// You can use this for storage when implementing [`CallbackTrait`].
|
|
|
|
pub type CallbackResources = type_map::concurrent::TypeMap; |
|
|
|
|
|
|
|
/// You can use this to do custom `wgpu` rendering in an egui app.
|
|
|
|
/// You can use this to do custom [`wgpu`] rendering in an egui app.
|
|
|
|
///
|
|
|
|
/// Implement [`CallbackTrait`] and call [`Callback::new_paint_callback`].
|
|
|
|
///
|
|
|
@ -50,7 +50,7 @@ impl Callback { |
|
|
|
///
|
|
|
|
/// ## Command Encoder
|
|
|
|
///
|
|
|
|
/// The passed-in `CommandEncoder` is egui's and can be used directly to register
|
|
|
|
/// The passed-in [`wgpu::CommandEncoder`] is egui's and can be used directly to register
|
|
|
|
/// wgpu commands for simple use cases.
|
|
|
|
/// This allows reusing the same [`wgpu::CommandEncoder`] for all callbacks and egui
|
|
|
|
/// rendering itself.
|
|
|
@ -58,7 +58,7 @@ impl Callback { |
|
|
|
/// ## Command Buffers
|
|
|
|
///
|
|
|
|
/// For more complicated use cases, one can also return a list of arbitrary
|
|
|
|
/// `CommandBuffer`s and have complete control over how they get created and fed.
|
|
|
|
/// [`wgpu::CommandBuffer`]s and have complete control over how they get created and fed.
|
|
|
|
/// In particular, this gives an opportunity to parallelize command registration and
|
|
|
|
/// prevents a faulty callback from poisoning the main wgpu pipeline.
|
|
|
|
///
|
|
|
@ -498,7 +498,7 @@ impl Renderer { |
|
|
|
render_pass.set_scissor_rect(0, 0, size_in_pixels[0], size_in_pixels[1]); |
|
|
|
} |
|
|
|
|
|
|
|
/// Should be called before `render()`.
|
|
|
|
/// Should be called before [`Self::render`].
|
|
|
|
pub fn update_texture( |
|
|
|
&mut self, |
|
|
|
device: &wgpu::Device, |
|
|
@ -631,12 +631,11 @@ impl Renderer { |
|
|
|
self.textures.get(id) |
|
|
|
} |
|
|
|
|
|
|
|
/// Registers a `wgpu::Texture` with a `epaint::TextureId`.
|
|
|
|
/// Registers a [`wgpu::Texture`] with a [`epaint::TextureId`].
|
|
|
|
///
|
|
|
|
/// This enables the application to reference the texture inside an image ui element.
|
|
|
|
/// This effectively enables off-screen rendering inside the egui UI. Texture must have
|
|
|
|
/// the texture format `TextureFormat::Rgba8UnormSrgb` and
|
|
|
|
/// Texture usage `TextureUsage::SAMPLED`.
|
|
|
|
/// the texture format [`wgpu::TextureFormat::Rgba8UnormSrgb`].
|
|
|
|
pub fn register_native_texture( |
|
|
|
&mut self, |
|
|
|
device: &wgpu::Device, |
|
|
@ -655,9 +654,9 @@ impl Renderer { |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
/// Registers a `wgpu::Texture` with an existing `epaint::TextureId`.
|
|
|
|
/// Registers a [`wgpu::Texture`] with an existing [`epaint::TextureId`].
|
|
|
|
///
|
|
|
|
/// This enables applications to reuse `TextureId`s.
|
|
|
|
/// This enables applications to reuse [`epaint::TextureId`]s.
|
|
|
|
pub fn update_egui_texture_from_wgpu_texture( |
|
|
|
&mut self, |
|
|
|
device: &wgpu::Device, |
|
|
@ -678,15 +677,14 @@ impl Renderer { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
/// Registers a `wgpu::Texture` with a `epaint::TextureId` while also accepting custom
|
|
|
|
/// `wgpu::SamplerDescriptor` options.
|
|
|
|
/// Registers a [`wgpu::Texture`] with a [`epaint::TextureId`] while also accepting custom
|
|
|
|
/// [`wgpu::SamplerDescriptor`] options.
|
|
|
|
///
|
|
|
|
/// This allows applications to specify individual minification/magnification filters as well as
|
|
|
|
/// custom mipmap and tiling options.
|
|
|
|
///
|
|
|
|
/// The `Texture` must have the format `TextureFormat::Rgba8UnormSrgb` and usage
|
|
|
|
/// `TextureUsage::SAMPLED`. Any compare function supplied in the `SamplerDescriptor` will be
|
|
|
|
/// ignored.
|
|
|
|
/// The texture must have the format [`wgpu::TextureFormat::Rgba8UnormSrgb`].
|
|
|
|
/// Any compare function supplied in the [`wgpu::SamplerDescriptor`] will be ignored.
|
|
|
|
#[allow(clippy::needless_pass_by_value)] // false positive
|
|
|
|
pub fn register_native_texture_with_sampler_options( |
|
|
|
&mut self, |
|
|
@ -723,10 +721,10 @@ impl Renderer { |
|
|
|
id |
|
|
|
} |
|
|
|
|
|
|
|
/// Registers a `wgpu::Texture` with an existing `epaint::TextureId` while also accepting custom
|
|
|
|
/// `wgpu::SamplerDescriptor` options.
|
|
|
|
/// Registers a [`wgpu::Texture`] with an existing [`epaint::TextureId`] while also accepting custom
|
|
|
|
/// [`wgpu::SamplerDescriptor`] options.
|
|
|
|
///
|
|
|
|
/// This allows applications to reuse `TextureId`s created with custom sampler options.
|
|
|
|
/// This allows applications to reuse [`epaint::TextureId`]s created with custom sampler options.
|
|
|
|
#[allow(clippy::needless_pass_by_value)] // false positive
|
|
|
|
pub fn update_egui_texture_from_wgpu_texture_with_sampler_options( |
|
|
|
&mut self, |
|
|
@ -766,7 +764,7 @@ impl Renderer { |
|
|
|
} |
|
|
|
|
|
|
|
/// Uploads the uniform, vertex and index data used by the renderer.
|
|
|
|
/// Should be called before `render()`.
|
|
|
|
/// Should be called before [`Self::render`].
|
|
|
|
///
|
|
|
|
/// Returns all user-defined command buffers gathered from [`CallbackTrait::prepare`] & [`CallbackTrait::finish_prepare`] callbacks.
|
|
|
|
pub fn update_buffers( |
|
|
|