pub struct SessionProxy { /* private fields */ }
Implementations§
Source§impl SessionProxy
impl SessionProxy
Sourcepub fn take_event_stream(&self) -> SessionEventStream
pub fn take_event_stream(&self) -> SessionEventStream
Get a Stream of events from the remote end of the protocol.
§Panics
Panics if the event stream was already taken.
pub fn enqueue(&self, cmds: Vec<Command>) -> Result<(), Error>
Sourcepub fn present(
&self,
presentation_time: u64,
acquire_fences: Vec<Event>,
release_fences: Vec<Event>,
) -> QueryResponseFut<PresentationInfo, DefaultFuchsiaResourceDialect>
pub fn present( &self, presentation_time: u64, acquire_fences: Vec<Event>, release_fences: Vec<Event>, ) -> QueryResponseFut<PresentationInfo, DefaultFuchsiaResourceDialect>
Present all previously enqueued operations. In order to pipeline the preparation of the resources required to render the scene, two lists of fences (implemented as events) are passed.
SCHEDULING PRESENTATION
presentation_time
specifies the time on or after which the
client would like the enqueued operations should take visible effect
(light up pixels on the screen), expressed in nanoseconds in the
CLOCK_MONOTONIC
timebase. Desired presentation times must be
monotonically non-decreasing.
Using a desired presentation time in the present or past (such as 0) schedules enqueued operations to take visible effect as soon as possible (during the next frame to be prepared).
Using a desired presentation time in the future schedules the enqueued operations to take visible effect as closely as possible to or after the stated time (but no earlier).
Each rendered frame has a target presentation time. Before rendering
a frame, the scene manager applies all enqueued operations associated
with all prior calls to Present()
whose desired presentation time
is on or before the frame’s target presentation time.
The Present()
method does not return until the scene manager begins
preparing the first frame which includes its presented content.
Upon return, the PresentationInfo
provides timing information for the
frame which includes the presented content.
To present new content on each successive frame, wait for Present()
to return before calling Present()
again with content for the next
frame.
It is also possible to enqueue and present successive frames of content
all at once with increasing desired presentation times, incrementing by
PresentationInfo.presentation_interval
for each one.
Animation updates are also coordinated in terms of presentation time.
SYNCHRONIZATION
acquire_fences
are used by Scenic to wait until all of the session’s
resources are ready to render (or to allow downstream components, such as
the Vulkan driver, to wait for these resources).
For example, Fuchsia’s Vulkan driver allows an zx::event to be obtained
from a VkSemaphore. This allows a Scenic client to submit a Vulkan command
buffer to generate images/meshes/etc., and instructing Vulkan to signal a
VkSemaphore when it is done. By inserting the zx::event corresponding to
this semaphore into acquire_fences
, the client allows Scenic to submit work
to the Vulkan driver without waiting on the CPU for the event to be
signalled.
release_fences
is a list of events that will be signalled by Scenic when
the updated session state has been fully committed: future frames will be
rendered using this state, and all frames generated using previous session
states have been fully-rendered and presented to the display.
Together, acquire_fences
and release_fences
are intended to allow clients
to implement strategies such as double-buffering. For example, a client
might do the following in the Scenic subsystem:
- create two Image with resource IDs #1 and #2.
- create two Materials with resource IDs #3 and #4, which respectively use Images #1 and #2 as their texture.
- create a tree of Nodes and attach them to the scene.
- set one of the nodes above, say #5, to use Material #3.
- submit a Vulkan command-buffer which renders into Image #1, and will signal a VkSemaphore.
- call Present() with one acquire-fence (obtained from the VkSemaphore above) and one newly-created release-fence.
After the steps above, Scenic will use the committed session state to render frames whenever necessary. When the client wants to display something different than Image #1, it would do something similar to steps 4) to 6): 7) set Node #5 to use Material #4. 8) submit a Vulkan command-buffer which renders into Image #1, and will signal a VkSemaphore. 9) call Present() with one acquire-fence (obtained from the VkSemaphore above) and one newly-created release-fence.
Finally, to continually draw new content, the client could repeat steps 4) to 9), with one important difference: step 5) must wait on the event signalled by step 9). Otherwise, it might render into Image #1 while that image is still being used by Scenic to render a frame. Similarly, step 8) must wait on the event signalled by step 6).
The scenario described above uses one acquire-fence and one release-fence, but it is easy to imagine cases that require more. For example, in addition to using Vulkan to render into Images #1 and #2, the client might also upload other resources to Vulkan on a different VkQueue, which would would signal a separate semaphore, and therefore require an additional acquire-fence.
Note: acquire_fences
and release_fences
are only necessary to synchronize
access to memory (and other external resources). Any modification to
resources made via the Session API are automatically synchronized.
Sourcepub fn present2(
&self,
args: Present2Args,
) -> QueryResponseFut<FuturePresentationTimes, DefaultFuchsiaResourceDialect>
pub fn present2( &self, args: Present2Args, ) -> QueryResponseFut<FuturePresentationTimes, DefaultFuchsiaResourceDialect>
Present all previously enqueued operations. In order to pipeline the preparation of the resources required to render the scene, two lists of fences, implemented as events, are passed.
When a client calls Present2, they receive an immediate callback
consisting of the same information they would get as if they had called
RequestPresentationTimes
with the equivalent
requested_prediction_span
. See its documentation below for more
information, as Present2’s functionality is a superset of it.
Then, when the commands flushed by Present2 make it to display, an
OnFramePresented
event is fired. This event includes information
pertaining to all Present2s that had content that were part of that
frame.
Clients may only use one of Present/Present2 per Session. Switching between both is an error that will result in the Session being closed.
See Present2Args
documentation above for more detailed information on
what arguments are passed in and their role.
Sourcepub fn request_presentation_times(
&self,
requested_prediction_span: i64,
) -> QueryResponseFut<FuturePresentationTimes, DefaultFuchsiaResourceDialect>
pub fn request_presentation_times( &self, requested_prediction_span: i64, ) -> QueryResponseFut<FuturePresentationTimes, DefaultFuchsiaResourceDialect>
Returns information about future presentation times, and their
respective latch points. Clients can use the returned information to
make informed scheduling decisions: if a client wants their frame to be
displayed at a given presentation_time
, they should aim to have all
acquire_fences
fired before the associated latch_point
.
Scenic will attempt to return predictions that span a duration equal to
requested_prediction_span
, up to a limit.
A value of 0 is guaranteed to give at least one future presentation info.
Sourcepub fn register_buffer_collection(
&self,
buffer_id: u32,
token: ClientEnd<BufferCollectionTokenMarker>,
) -> Result<(), Error>
pub fn register_buffer_collection( &self, buffer_id: u32, token: ClientEnd<BufferCollectionTokenMarker>, ) -> Result<(), Error>
Registers BufferCollection referenced by the token
and sets contraints on it.
It does not block on the buffers being allocated until content backed by one of the
collection’s VMOs is created, e.g. an Image2.
A value of 0 for the buffer_id
is invalid. All other values are valid as long as they
are not currently in use.
Sourcepub fn deregister_buffer_collection(&self, buffer_id: u32) -> Result<(), Error>
pub fn deregister_buffer_collection(&self, buffer_id: u32) -> Result<(), Error>
Deregisters the BufferCollection previously registered with the buffer_id
and sets it
to be garbage collected as soon as it is no longer referenced by any resources.
Only buffer_id
that have been previously registered and not yet deregistered are valid.
Sourcepub fn set_debug_name(&self, debug_name: &str) -> Result<(), Error>
pub fn set_debug_name(&self, debug_name: &str) -> Result<(), Error>
Set an optional debug name for the session. The debug name will be output in things such as logging and trace events.
Trait Implementations§
Source§impl Clone for SessionProxy
impl Clone for SessionProxy
Source§fn clone(&self) -> SessionProxy
fn clone(&self) -> SessionProxy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SessionProxy
impl Debug for SessionProxy
Source§impl Proxy for SessionProxy
impl Proxy for SessionProxy
Source§type Protocol = SessionMarker
type Protocol = SessionMarker
Proxy
controls.Source§fn from_channel(inner: AsyncChannel) -> Self
fn from_channel(inner: AsyncChannel) -> Self
Source§fn into_channel(self) -> Result<AsyncChannel, Self>
fn into_channel(self) -> Result<AsyncChannel, Self>
Source§fn as_channel(&self) -> &AsyncChannel
fn as_channel(&self) -> &AsyncChannel
§fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>
fn into_client_end(self) -> Result<ClientEnd<Self::Protocol>, Self>
Source§impl SessionProxyInterface for SessionProxy
impl SessionProxyInterface for SessionProxy
type PresentResponseFut = QueryResponseFut<PresentationInfo>
type Present2ResponseFut = QueryResponseFut<FuturePresentationTimes>
type RequestPresentationTimesResponseFut = QueryResponseFut<FuturePresentationTimes>
fn enqueue(&self, cmds: Vec<Command>) -> Result<(), Error>
fn present( &self, presentation_time: u64, acquire_fences: Vec<Event>, release_fences: Vec<Event>, ) -> Self::PresentResponseFut
fn present2(&self, args: Present2Args) -> Self::Present2ResponseFut
fn request_presentation_times( &self, requested_prediction_span: i64, ) -> Self::RequestPresentationTimesResponseFut
fn register_buffer_collection( &self, buffer_id: u32, token: ClientEnd<BufferCollectionTokenMarker>, ) -> Result<(), Error>
fn deregister_buffer_collection(&self, buffer_id: u32) -> Result<(), Error>
fn set_debug_name(&self, debug_name: &str) -> Result<(), Error>
Auto Trait Implementations§
impl Freeze for SessionProxy
impl !RefUnwindSafe for SessionProxy
impl Send for SessionProxy
impl Sync for SessionProxy
impl Unpin for SessionProxy
impl !UnwindSafe for SessionProxy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)