#[repr(C)]pub struct cp_drawable { /* private fields */ }drawable only.Expand description
Implementations§
Source§impl cp_drawable
impl cp_drawable
Sourcepub unsafe fn texture_count(drawable: cp_drawable_t) -> usize
pub unsafe fn texture_count(drawable: cp_drawable_t) -> usize
Returns the number of color and depth textures available in the drawable.
- Parameters:
- drawable: The drawable for a frame.
- Returns: The number of textures available for drawing. For example, a return
value of
2indicates there are two color textures and two depth textures available.
Use the returned value as the maximum number of textures to retrieve
from the cp_drawable_get_color_texture or cp_drawable_get_depth_texture
functions.
Sourcepub unsafe fn depth_texture(
drawable: cp_drawable_t,
index: usize,
) -> Retained<ProtocolObject<dyn MTLTexture>>
Available on crate feature objc2-metal only.
pub unsafe fn depth_texture( drawable: cp_drawable_t, index: usize, ) -> Retained<ProtocolObject<dyn MTLTexture>>
objc2-metal only.Returns the depth texture at the specified index in the drawable.
- Parameters:
- drawable: The drawable for a frame.
- index: The index of the depth texture you want. The index must
be greater than or equal to
0and less than the value thatcp_drawable_get_texture_countreturns. - Returns: The Metal depth texture at the specified index.
Use the returned texture in your render pipeline as the depth texture for your content. The layer’s texture topology determines the layout and content for each texture. The drawable’s views contain information about how those views map to the textures.
Sourcepub unsafe fn color_texture(
drawable: cp_drawable_t,
index: usize,
) -> Retained<ProtocolObject<dyn MTLTexture>>
Available on crate feature objc2-metal only.
pub unsafe fn color_texture( drawable: cp_drawable_t, index: usize, ) -> Retained<ProtocolObject<dyn MTLTexture>>
objc2-metal only.Returns the color texture at the specified index in the drawable.
- Parameters:
- drawable: The drawable for a frame.
- index: The index of the color texture you want. The index must
be greater than or equal to
0and less than the value thatcp_drawable_get_texture_countreturns. - Returns: The Metal color texture at the specified index.
Use the returned texture in your render pipeline to store the pixels you want to appear onscreen. The layer’s texture topology determines the layout and content for each texture. The drawable’s views contain information about how those views map to the textures.
Sourcepub unsafe fn rasterization_rate_map_count(drawable: cp_drawable_t) -> usize
pub unsafe fn rasterization_rate_map_count(drawable: cp_drawable_t) -> usize
Returns the number of rasterization rate maps associated with the drawable.
- Parameters:
- drawable: The drawable for a frame.
- Returns: The number of rasterization rate maps available for drawing.
Use the returned value as the maximum number of rate maps to retrieve
from the cp_drawable_get_rasterization_rate_map function.
Sourcepub unsafe fn rasterization_rate_map(
drawable: cp_drawable_t,
index: usize,
) -> Retained<ProtocolObject<dyn MTLRasterizationRateMap>>
Available on crate feature objc2-metal only.
pub unsafe fn rasterization_rate_map( drawable: cp_drawable_t, index: usize, ) -> Retained<ProtocolObject<dyn MTLRasterizationRateMap>>
objc2-metal only.Returns the rasterization rate map at the specified index in the drawable.
- Parameters:
- drawable: The drawable for a frame.
- index: The index of the rasterization rate map you want.
The index must be greater than or equal to
0and less than the value thatcp_drawable_get_rasterization_rate_map_countreturns. - Returns: The rasterization rate map at the specified index.
Apply the rasterization rate map to your render descriptor when you set up your drawing environment. A rate map defines how the GPU scales different parts of the texture to fill the screen. You use these rate maps to save time and render less important parts of your scene at lower resolutions. For example, when foveation is enabled, the drawable includes a rasterization rate map to render the portions of the texture in someone’s peripheral vision at a lower resolution.
Sourcepub unsafe fn flipped_rasterization_rate_map(
drawable: cp_drawable_t,
index: usize,
) -> Retained<ProtocolObject<dyn MTLRasterizationRateMap>>
Available on crate feature objc2-metal only.
pub unsafe fn flipped_rasterization_rate_map( drawable: cp_drawable_t, index: usize, ) -> Retained<ProtocolObject<dyn MTLRasterizationRateMap>>
objc2-metal only.Returns the Y flipped rasterization rate map at the specified index in the drawable.
- Parameters:
- drawable: The drawable for a frame.
- index: The index of the rasterization rate map you want.
The index must be greater than or equal to
0and less than the value thatcp_drawable_get_rasterization_rate_map_countreturns. - Returns: The Y flipped rasterization rate map at the specified index.
This function provides a Y flipped map that is generated form the cp_drawable_get_rasterization_rate_map.
Flipped is defined as +Y = down for clip/normalized device coordinates (flipped from Metal).
If projection matrix is needed, use cp_drawable_compute_projection
with a +Y = down axes convention to generate the correct matrix.
Can only be used for intermediary render passes, the final render pass of the drawable it cannot be flipped and must use Metal convention of +Y = up.
Generating a flipped rasterization rate map will bring additional computational cost to your render loop.
In order to generate Y flipped rasterization rate maps in your rendering session,
update the cp_layer_renderer_configuration_t using the function
cp_layer_renderer_configuration_set_generate_flipped_rasterization_rate_maps.
Sourcepub unsafe fn view_count(drawable: cp_drawable_t) -> usize
pub unsafe fn view_count(drawable: cp_drawable_t) -> usize
Returns the number of separate views to draw for the frame.
- Parameters:
- drawable: The drawable for a frame.
- Returns: The number of separate views to draw.
The number of views corresponds to the number of separate versions of your scene you create for the frame. For a device with stereoscopic video, you render two views — one for each eye. The actual number of views can vary based on the drawing environment or your app’s configuration. For example, you typically render only one view in Simulator.
Fetch the actual views using the cp_drawable_get_view function.
Sourcepub unsafe fn view(drawable: cp_drawable_t, index: usize) -> cp_view_t
Available on crate feature view only.
pub unsafe fn view(drawable: cp_drawable_t, index: usize) -> cp_view_t
view only.Returns the specified view from the drawable.
- Parameters:
- drawable: The drawable for a frame.
- index: The index of the view you want. The index must be
greater than or equal to 0 and less than the value that
cp_drawable_get_view_countreturns. - Returns: The view at the specified index.
Each view contains information you need to render into the drawable’s textures.
Sourcepub unsafe fn encode_present(
drawable: cp_drawable_t,
command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
)
Available on crate feature objc2-metal only.
pub unsafe fn encode_present( drawable: cp_drawable_t, command_buffer: &ProtocolObject<dyn MTLCommandBuffer>, )
objc2-metal only.Encodes a notification event to the specified command buffer to present the drawable’s content onscreen.
- Parameters:
- drawable: The drawable for a frame.
- command_buffer: The command buffer you used to encode your frame’s content. If the command buffer is already committed, this function aborts your app with an error.
Call this function as the last step before committing the specified command buffer. Specifically, call it after you finish encoding all the work required to render the frame, and immediately before you call the command buffer’s <doc ://com.apple.documentation/documentation/metal/mtlcommandbuffer/1443003-commit> method. The function adds a presentation event to the buffer that causes the compositor to display your frame.
Sourcepub unsafe fn state(drawable: cp_drawable_t) -> cp_drawable_state
pub unsafe fn state(drawable: cp_drawable_t) -> cp_drawable_state
Returns a value that indicates the current operational state of the drawable type.
- Parameters: The drawable to test.
- Returns:
cp_drawable_state/cp_drawable_state_renderingif the drawable type is ready for you to draw your content, or any other value if the compositor currently owns the drawable.
Compositor reuses the underlying data structures associated with
drawable types, and the state of the drawable indicates whether
it’s ready for you to use. Perform your drawing operations only
when the drawable is in the cp_drawable_state/cp_drawable_state_rendering state.
Sourcepub unsafe fn presentation_frame_index(
drawable: cp_drawable_t,
) -> cp_compositor_frame_index_t
Available on crate feature cp_types only.
pub unsafe fn presentation_frame_index( drawable: cp_drawable_t, ) -> cp_compositor_frame_index_t
cp_types only.Returns the index of the frame of content for you to produce.
- Parameters:
- drawable: The drawable for a frame.
- Returns: The presentation index of the frame.
When your compositor scene becomes visible, you start drawing frames of content. The compositor assigns a sequential index to each frame to indicate its position in the final output. You can use these indexes to differentiate frames during drawing or predict future frame indexes. For example, you might start playback of an audio file when a specific frame appears onscreen.
Sourcepub unsafe fn frame_timing(drawable: cp_drawable_t) -> cp_frame_timing_t
Available on crate feature frame_timing only.
pub unsafe fn frame_timing(drawable: cp_drawable_t) -> cp_frame_timing_t
frame_timing only.Returns the timing information for the frame of the specified drawable.
- Parameters:
- drawable: The drawable for a frame.
- Returns: The timing information for the drawable’s associated frame.
Pass the returned type to the cp_frame_timing_get_optimal_input_time
function to determine when to start the encoding process for a frame.
Pass it to other functions to determine other time-related deadlines.