Skip to main content

WgpuRenderState

Struct WgpuRenderState 

Source
pub struct WgpuRenderState<'callback> { /* private fields */ }
Expand description

Scoped access to the WGPU resources selected for a raw draw callback.

This corresponds to ImGui_ImplWGPU_RenderState in the C++ implementation. The value can only be obtained through Self::with_current while the renderer is invoking a raw callback. It cannot outlive that callback scope.

The state borrows the renderer’s device and render pass; it does not own either resource and does not provide access to the Dear ImGui Context.

use dear_imgui_wgpu::WgpuRenderState;

// Callback-scoped resources cannot be returned from the higher-ranked borrow.
let _escaped = unsafe { WgpuRenderState::with_current(|state| state.device()) };

Implementations§

Source§

impl WgpuRenderState<'_>

Source

pub unsafe fn with_current<R>( callback: impl for<'callback> FnOnce(WgpuRenderState<'callback>) -> R, ) -> Result<R, WgpuRenderStateAccessError>

Borrows the state published for the current raw draw callback.

§Safety

This function may only be called from a raw draw callback currently invoked by dear-imgui-wgpu. The current Dear ImGui Context must be the renderer owner and its Renderer_RenderState slot must still contain the WGPU state installed for this callback. The callback must not replace that slot while callback is running.

The higher-ranked closure prevents references to the render pass from escaping the callback scope. Recursive access is rejected at runtime.

Source

pub fn device(&self) -> &Device

Returns the renderer device for the callback duration.

Source

pub fn render_pass(&mut self) -> &mut RenderPass<'_>

Returns the active render pass for the duration of this borrow.

Source

pub fn resources(&mut self) -> (&Device, &mut RenderPass<'_>)

Returns the device and render pass as disjoint callback-scoped borrows.

Trait Implementations§

Source§

impl<'callback> Debug for WgpuRenderState<'callback>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'callback> !RefUnwindSafe for WgpuRenderState<'callback>

§

impl<'callback> !Send for WgpuRenderState<'callback>

§

impl<'callback> !Sync for WgpuRenderState<'callback>

§

impl<'callback> !UnwindSafe for WgpuRenderState<'callback>

§

impl<'callback> Freeze for WgpuRenderState<'callback>

§

impl<'callback> Unpin for WgpuRenderState<'callback>

§

impl<'callback> UnsafeUnpin for WgpuRenderState<'callback>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>