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 { ... }
}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§
Sourcefn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
Available on crate feature MTLDevice only.
fn device(&self) -> Retained<ProtocolObject<dyn MTLDevice>>
MTLDevice only.Returns: The device on which the rasterization rate map was created
Sourcefn screenSize(&self) -> MTLSize
Available on crate feature MTLTypes only.
fn screenSize(&self) -> MTLSize
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.
Sourcefn physicalGranularity(&self) -> MTLSize
Available on crate feature MTLTypes only.
fn physicalGranularity(&self) -> MTLSize
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.
Sourcefn layerCount(&self) -> NSUInteger
fn layerCount(&self) -> NSUInteger
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]].
Sourcefn parameterBufferSizeAndAlign(&self) -> MTLSizeAndAlign
Available on crate feature MTLDevice only.
fn parameterBufferSizeAndAlign(&self) -> MTLSizeAndAlign
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:
Sourceunsafe fn copyParameterDataToBuffer_offset(
&self,
buffer: &ProtocolObject<dyn MTLBuffer>,
offset: NSUInteger,
)
Available on crate features MTLAllocation and MTLBuffer and MTLResource only.
unsafe fn copyParameterDataToBuffer_offset( &self, buffer: &ProtocolObject<dyn MTLBuffer>, offset: NSUInteger, )
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
buffermay need to be synchronized.buffermay be unretained, you must ensure it is kept alive while in use.buffercontents should be of the correct type.offsetmight not be bounds-checked.
Sourceunsafe fn physicalSizeForLayer(&self, layer_index: NSUInteger) -> MTLSize
Available on crate feature MTLTypes only.
unsafe fn physicalSizeForLayer(&self, layer_index: NSUInteger) -> MTLSize
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.
Sourceunsafe fn mapScreenToPhysicalCoordinates_forLayer(
&self,
screen_coordinates: MTLCoordinate2D,
layer_index: NSUInteger,
) -> MTLCoordinate2D
Available on crate feature MTLTypes only.
unsafe fn mapScreenToPhysicalCoordinates_forLayer( &self, screen_coordinates: MTLCoordinate2D, layer_index: NSUInteger, ) -> MTLCoordinate2D
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.
Sourceunsafe fn mapPhysicalToScreenCoordinates_forLayer(
&self,
physical_coordinates: MTLCoordinate2D,
layer_index: NSUInteger,
) -> MTLCoordinate2D
Available on crate feature MTLTypes only.
unsafe fn mapPhysicalToScreenCoordinates_forLayer( &self, physical_coordinates: MTLCoordinate2D, layer_index: NSUInteger, ) -> MTLCoordinate2D
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.