MTLRasterizationRateMap

Trait MTLRasterizationRateMap 

Source
pub unsafe trait MTLRasterizationRateMap:
    NSObjectProtocol
    + Send
    + Sync {
    // Provided methods
    fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
       where Self: Sized + Message { ... }
    fn label(&self) -> Option<Retained<NSString>>
       where Self: Sized + Message { ... }
    fn screenSize(&self) -> MTLSize
       where Self: Sized + Message { ... }
    fn physicalGranularity(&self) -> MTLSize
       where Self: Sized + Message { ... }
    fn layerCount(&self) -> NSUInteger
       where Self: Sized + Message { ... }
    fn parameterBufferSizeAndAlign(&self) -> MTLSizeAndAlign
       where Self: Sized + Message { ... }
    unsafe fn copyParameterDataToBuffer_offset(
        &self,
        buffer: &ProtocolObject<dyn MTLBuffer>,
        offset: NSUInteger,
    )
       where Self: Sized + Message { ... }
    unsafe fn physicalSizeForLayer(&self, layer_index: NSUInteger) -> MTLSize
       where Self: Sized + Message { ... }
    unsafe fn mapScreenToPhysicalCoordinates_forLayer(
        &self,
        screen_coordinates: MTLCoordinate2D,
        layer_index: NSUInteger,
    ) -> MTLCoordinate2D
       where Self: Sized + Message { ... }
    unsafe fn mapPhysicalToScreenCoordinates_forLayer(
        &self,
        physical_coordinates: MTLCoordinate2D,
        layer_index: NSUInteger,
    ) -> MTLCoordinate2D
       where Self: Sized + Message { ... }
}
Available on crate feature MTLRasterizationRate only.
Expand description

Compiled read-only object that determines how variable rasterization rate is applied when rendering.

A variable rasterization rate map is compiled by MTLDevice from a MTLRasterizationRateMapDescriptor containing one or more MTLRasterizationRateLayerDescriptor. During compilation, the quality samples provided in the MTLRasterizationRateLayerDescriptor may be rounded up to the nearest supported value or granularity, depending on hardware support. However, the compilation will never round values down, so the actual rasterization will always happen at a quality level matching or exceeding the provided quality samples. During rasterization using the MTLRasterizationRateMap the screen space rendering is stored in a smaller area of the framebuffer, such that lower quality regions will not occupy as many texels as higher quality regions. The quality will never exceed 1:1 in any region of screen space. Because a smaller area of the framebuffer is populated, less fragment shader invocations are required to render content, and less bandwidth is consumed to store the shaded values. Use a rasterization rate map to reduce rendering quality in less-important or less-sampled regions of the framebuffer, such as the periphery of a VR/AR display or a far-away cascade of a shadow map.

See also Apple’s documentation

Provided Methods§

Source

fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
where Self: Sized + Message,

Available on crate feature MTLDevice only.

Returns: The device on which the rasterization rate map was created

Source

fn label(&self) -> Option<Retained<NSString>>
where Self: Sized + Message,

A string to help identify this object.

Source

fn screenSize(&self) -> MTLSize
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Returns: The dimensions, in screen space pixels, of the region where variable rasterization is applied.

The region always has its origin at [0, 0]. The depth component of the returned MTLSize is always 0.

Source

fn physicalGranularity(&self) -> MTLSize
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Returns: The granularity, in physical pixels, at which variable rasterization rate varies.

Rendering algorithms that use binning or tiling in screen space may want to determine the screen space bin size using this value. The depth component of the returned MTLSize is always 0.

Source

fn layerCount(&self) -> NSUInteger
where Self: Sized + Message,

Returns: The number of different configured layers in the rasterization map.

Different render-target layers may target different variable rasterization configurations. The rasterization rate layer for a primitive is selected on the [[render_target_layer_index]].

Source

fn parameterBufferSizeAndAlign(&self) -> MTLSizeAndAlign
where Self: Sized + Message,

Available on crate feature MTLDevice only.

Returns the size and alignment requirements of the parameter buffer for this rate map.

The parameter data can be copied into a buffer with this size and alignment using copyParameterDataToBuffer:offset:

Source

unsafe fn copyParameterDataToBuffer_offset( &self, buffer: &ProtocolObject<dyn MTLBuffer>, offset: NSUInteger, )
where Self: Sized + Message,

Available on crate features MTLAllocation and MTLBuffer and MTLResource only.

Copy the parameter data into the provided buffer at the provided offset.

The buffer must have storageMode MTLStorageModeShared, and a size of at least parameterBufferSizeAndAlign.size + offset. The specified offset must be a multiple of parameterBufferSize.align. The buffer can be bound to a shader stage to map screen space to physical fragment space, or vice versa.

§Safety
  • buffer may need to be synchronized.
  • buffer may be unretained, you must ensure it is kept alive while in use.
  • buffer contents should be of the correct type.
  • offset might not be bounds-checked.
Source

unsafe fn physicalSizeForLayer(&self, layer_index: NSUInteger) -> MTLSize
where Self: Sized + Message,

Available on crate feature MTLTypes only.

The dimensions, in physical fragments, of the area in the render target where variable rasterization is applied

Different configured layers may have a different rasterization rate and may have different size after rendering. The rasterization rate layer for a primitive is selected on the [[render_target_layer_index]].

§Safety

layerIndex might not be bounds-checked.

Source

unsafe fn mapScreenToPhysicalCoordinates_forLayer( &self, screen_coordinates: MTLCoordinate2D, layer_index: NSUInteger, ) -> MTLCoordinate2D
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Computes where an offset relative to the top-left of screen space, in screen space pixels, would end up in the framebuffer, in physical fragments. The returned value is less-or-equal the input value because the rasterization quality never exceeds 1:1 in any region.

§Safety

layerIndex might not be bounds-checked.

Source

unsafe fn mapPhysicalToScreenCoordinates_forLayer( &self, physical_coordinates: MTLCoordinate2D, layer_index: NSUInteger, ) -> MTLCoordinate2D
where Self: Sized + Message,

Available on crate feature MTLTypes only.

Computes where an offset relative to the top-left of the framebuffer, in physical pixels, would end up in screen space, in screen space pixels. The returned value is greater-or-equal the input value because the rasterization quality never exceeds 1:1 in any region.

§Safety

layerIndex might not be bounds-checked.

Trait Implementations§

Source§

impl ProtocolType for dyn MTLRasterizationRateMap

Source§

const NAME: &'static str = "MTLRasterizationRateMap"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn MTLRasterizationRateMap

Implementations on Foreign Types§

Source§

impl<T> MTLRasterizationRateMap for ProtocolObject<T>

Implementors§