pub struct SharedTexture { /* private fields */ }Expand description
A shared BGRA8 or half-float texture opened on the renderer’s device, from another device, API
or process.
On Windows: D3D11, D3D12, or Vulkan rendering into D3D12 memory it imports. On macOS: an
IOSurface from another MTLDevice, process or framework. Reopen it after
SurfaceError::DeviceChanged.
Implementations§
Sourcepub fn open(handle: u64) -> Result<Self, SurfaceError>
pub fn open(handle: u64) -> Result<Self, SurfaceError>
Opens a handle this process holds: an NT handle (CreateSharedHandle in D3D11 or D3D12)
or a legacy one (IDXGIResource::GetSharedHandle). The handle stays the caller’s to close.
Sourcepub fn open_from_process(pid: u32, handle: u64) -> Result<Self, SurfaceError>
pub fn open_from_process(pid: u32, handle: u64) -> Result<Self, SurfaceError>
Duplicates the NT handle handle of process pid into this process and opens it. Needs
PROCESS_DUP_HANDLE on that process, which a child or a same-user process grants.
Sourcepub unsafe fn from_iosurface(surface: *mut c_void) -> Result<Self, SurfaceError>
pub unsafe fn from_iosurface(surface: *mut c_void) -> Result<Self, SurfaceError>
Opens an IOSurfaceRef this process holds (macOS): pixel format 'BGRA' (or 'RGhA'), made
by any MTLDevice or framework. It is retained while this lives.
§Safety
surface is null or a live IOSurfaceRef.
Sourcepub fn from_mach_port(port: u32) -> Result<Self, SurfaceError>
pub fn from_mach_port(port: u32) -> Result<Self, SurfaceError>
Opens the IOSurface another process sent as a mach port (IOSurfaceCreateMachPort), a
send right this process holds and stays the caller’s to deallocate.
Sourcepub fn with_keyed_mutex(self, acquire: u64, release: u64) -> Self
pub fn with_keyed_mutex(self, acquire: u64, release: u64) -> Self
Synchronises through the texture’s IDXGIKeyedMutex: each present acquires acquire and
releases release. Required for a texture made with SHARED_KEYEDMUTEX. Windows only; on
macOS a present of it fails with SurfaceError::NotSupported.
Sourcepub fn with_fence(self, fence: u64) -> Result<Self, SurfaceError>
pub fn with_fence(self, fence: u64) -> Result<Self, SurfaceError>
Synchronises through a shared fence, an NT handle this process holds: a D3D12 fence made
D3D12_FENCE_FLAG_SHARED, an ID3D11Fence made D3D11_FENCE_FLAG_SHARED, or a Vulkan
semaphore exported as D3D12_FENCE. Present it with
SurfaceHandle::present_shared_fenced. The handle stays the caller’s to close.
Sourcepub fn with_fence_from_process(
self,
pid: u32,
fence: u64,
) -> Result<Self, SurfaceError>
pub fn with_fence_from_process( self, pid: u32, fence: u64, ) -> Result<Self, SurfaceError>
Self::with_fence for a fence handle of process pid.
Synchronises through an id<MTLSharedEvent> of this process (macOS), from any device:
present it with SurfaceHandle::present_shared_fenced. It is retained while this lives.
§Safety
event is null or a live id<MTLSharedEvent>.
Self::with_shared_event for an event of another process: the MTLSharedEventHandle
it made (newSharedEventHandle) and sent over XPC.
§Safety
handle is null or a live MTLSharedEventHandle.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
How long a present waits for the acquire key, or (under the D3D11 renderer) for the fence; 100 ms by default. Under the D3D12 renderer and on macOS the GPU waits instead.
pub fn size(&self) -> (u32, u32)
Sourcepub fn format(&self) -> SurfaceFormat
pub fn format(&self) -> SurfaceFormat
The texture’s pixels, which the surface it is presented to must be set to.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more