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<'_>
impl WgpuRenderState<'_>
Sourcepub unsafe fn with_current<R>(
callback: impl for<'callback> FnOnce(WgpuRenderState<'callback>) -> R,
) -> Result<R, WgpuRenderStateAccessError>
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.
Sourcepub fn render_pass(&mut self) -> &mut RenderPass<'_>
pub fn render_pass(&mut self) -> &mut RenderPass<'_>
Returns the active render pass for the duration of this borrow.
Sourcepub fn resources(&mut self) -> (&Device, &mut RenderPass<'_>)
pub fn resources(&mut self) -> (&Device, &mut RenderPass<'_>)
Returns the device and render pass as disjoint callback-scoped borrows.