pub fn clear_attachments<A, R>(
        &mut self,
        attachments: A,
        rects: R,
    ) -> Result<&mut Self, ClearAttachmentsError>
    where
        A: IntoIterator<Item = ClearAttachment>,
        R: IntoIterator<Item = ClearRect>,
    {
        let pipeline = check_pipeline_graphics(self.state())?;
        self.ensure_inside_render_pass_inline(pipeline)?;

        let render_pass_state = self.render_pass_state.as_ref().unwrap();
        let subpass = &render_pass_state.subpass;
        let multiview = subpass.render_pass().desc().multiview().is_some();
        let has_depth_stencil_attachment = subpass.has_depth_stencil_attachment();
        let num_color_attachments = subpass.num_color_attachments();
        let dimensions = render_pass_state.dimensions;
        let attached_layers_ranges = &render_pass_state.attached_layers_ranges;

        let attachments: SmallVec<[ClearAttachment; 3]> = attachments.into_iter().collect();
        let rects: SmallVec<[ClearRect; 4]> = rects.into_iter().collect();

        for attachment in &attachments {
            match attachment {
                ClearAttachment::Color(_, color_attachment) => {
                    if *color_attachment >= num_color_attachments as u32 {
                        return Err(ClearAttachmentsError::InvalidColorAttachmentIndex(
                            *color_attachment,
                        ));
                    }
                }
                ClearAttachment::Depth(_)
                | ClearAttachment::Stencil(_)
                | ClearAttachment::DepthStencil(_) => {
                    if !has_depth_stencil_attachment {
                        return Err(ClearAttachmentsError::DepthStencilAttachmentNotPresent);
                    }
                }
            }
        }

        for rect in &rects {
            if rect.rect_extent[0] == 0 || rect.rect_extent[1] == 0 {
                return Err(ClearAttachmentsError::ZeroRectExtent);
            }
            if rect.rect_offset[0] + rect.rect_extent[0] > dimensions[0]
                || rect.rect_offset[1] + rect.rect_extent[1] > dimensions[1]
            {
                return Err(ClearAttachmentsError::RectOutOfBounds);
            }

            if rect.layer_count == 0 {
                return Err(ClearAttachmentsError::ZeroLayerCount);
            }
            if multiview && (rect.base_array_layer != 0 || rect.layer_count != 1) {
                return Err(ClearAttachmentsError::InvalidMultiviewLayerRange);
            }

            // make sure rect's layers is inside attached layers ranges
            for range in attached_layers_ranges {
                if rect.base_array_layer < range.start
                    || rect.base_array_layer + rect.layer_count > range.end
                {
                    return Err(ClearAttachmentsError::LayersOutOfBounds);
                }
            }
        }

        unsafe {
            self.inner.clear_attachments(attachments, rects);
        }

        Ok(self)
    }
/// Adds a command that clears specific regions of specific attachments of the framebuffer.
///
/// `attachments` specify the types of attachments and their clear values.
/// `rects` specify the regions to clear.
///
/// A graphics pipeline must have been bound using
/// [`bind_pipeline_graphics`](Self::bind_pipeline_graphics). And the command must be inside render pass.
///
/// If the render pass instance this is recorded in uses multiview,
/// then `ClearRect.base_array_layer` must be zero and `ClearRect.layer_count` must be one.
///
/// The rectangle area must be inside the render area ranges.
Adds a command that clears specific regions of specific attachments of the framebuffer.
`attachments` specify the types of attachments and their clear values.
`rects` specify the regions to clear.

A graphics pipeline must have been bound using
[`bind_pipeline_graphics`](Self::bind_pipeline_graphics). And the command must be inside render pass.

If the render pass instance this is recorded in uses multiview,
then `ClearRect.base_array_layer` must be zero and `ClearRect.layer_count` must be one.

The rectangle area must be inside the render area ranges.
Adds a command that clears specific regions of specific attachments of the framebuffer . ` attachments ` specify the types of attachments and their clear values . ` rects ` specify the regions to clear . A graphics pipeline must have been bound using [ ` bind_pipeline_graphics ` ] ( Self :: bind_pipeline_graphics ) . And the command must be inside render pass . If the render pass instance this is recorded in uses multiview then ` ClearRect . base_array_layer ` must be zero and ` ClearRect . layer_count ` must be one . The rectangle area must be inside the render area ranges .
pub fn clear_attachments<A, R>(
        &mut self,
        attachments: A,
        rects: R,
    ) -> Result<&mut Self, ClearAttachmentsError>
    where
        A: IntoIterator<Item = ClearAttachment>,
        R: IntoIterator<Item = ClearRect>,
    {
        let pipeline = check_pipeline_graphics(self.state())?;
        self.ensure_inside_render_pass_inline(pipeline)?;
        let render_pass_state = self.render_pass_state.as_ref().unwrap();
        let subpass = &render_pass_state.subpass;
        let multiview = subpass.render_pass().desc().multiview().is_some();
        let has_depth_stencil_attachment = subpass.has_depth_stencil_attachment();
        let num_color_attachments = subpass.num_color_attachments();
        let dimensions = render_pass_state.dimensions;
        let attached_layers_ranges = &render_pass_state.attached_layers_ranges;
        let attachments: SmallVec<[ClearAttachment; 3]> = attachments.into_iter().collect();
        let rects: SmallVec<[ClearRect; 4]> = rects.into_iter().collect();
        for attachment in &attachments {
            match attachment {
                ClearAttachment::Color(_, color_attachment) => {
                    if *color_attachment >= num_color_attachments as u32 {
                        return Err(ClearAttachmentsError::InvalidColorAttachmentIndex(
                            *color_attachment,
                        ));
                    }
                }
                ClearAttachment::Depth(_)
                | ClearAttachment::Stencil(_)
                | ClearAttachment::DepthStencil(_) => {
                    if !has_depth_stencil_attachment {
                        return Err(ClearAttachmentsError::DepthStencilAttachmentNotPresent);
                    }
                }
            }
        }
        for rect in &rects {
            if rect.rect_extent[0] == 0 || rect.rect_extent[1] == 0 {
                return Err(ClearAttachmentsError::ZeroRectExtent);
            }
            if rect.rect_offset[0] + rect.rect_extent[0] > dimensions[0]
                || rect.rect_offset[1] + rect.rect_extent[1] > dimensions[1]
            {
                return Err(ClearAttachmentsError::RectOutOfBounds);
            }
            if rect.layer_count == 0 {
                return Err(ClearAttachmentsError::ZeroLayerCount);
            }
            if multiview && (rect.base_array_layer != 0 || rect.layer_count != 1) {
                return Err(ClearAttachmentsError::InvalidMultiviewLayerRange);
            }
            // make sure rect's layers is inside attached layers ranges
            for range in attached_layers_ranges {
                if rect.base_array_layer < range.start
                    || rect.base_array_layer + rect.layer_count > range.end
                {
                    return Err(ClearAttachmentsError::LayersOutOfBounds);
                }
            }
        }
        unsafe {
            self.inner.clear_attachments(attachments, rects);
        }
        Ok(self)
    }
pub fn clear_attachments < A , R > ( & mut self , attachments : A , rects : R , ) -> Result < & mut Self , ClearAttachmentsError > where A : IntoIterator < Item = ClearAttachment > , R : IntoIterator < Item = ClearRect > , { let pipeline = check_pipeline_graphics ( self . state ( ) ) ? ; self . ensure_inside_render_pass_inline ( pipeline ) ? ; let render_pass_state = self . render_pass_state . as_ref ( ) . unwrap ( ) ; let subpass = & render_pass_state . subpass ; let multiview = subpass . render_pass ( ) . desc ( ) . multiview ( ) . is_some ( ) ; let has_depth_stencil_attachment = subpass . has_depth_stencil_attachment ( ) ; let num_color_attachments = subpass . num_color_attachments ( ) ; let dimensions = render_pass_state . dimensions ; let attached_layers_ranges = & render_pass_state . attached_layers_ranges ; let attachments : SmallVec < [ ClearAttachment ; 3 ] > = attachments . into_iter ( ) . collect ( ) ; let rects : SmallVec < [ ClearRect ; 4 ] > = rects . into_iter ( ) . collect ( ) ; for attachment in & attachments { match attachment { ClearAttachment :: Color ( _ , color_attachment ) => { if * color_attachment >= num_color_attachments as u32 { return Err ( ClearAttachmentsError :: InvalidColorAttachmentIndex ( * color_attachment , ) ) ; } } ClearAttachment :: Depth ( _ ) | ClearAttachment :: Stencil ( _ ) | ClearAttachment :: DepthStencil ( _ ) => { if ! has_depth_stencil_attachment { return Err ( ClearAttachmentsError :: DepthStencilAttachmentNotPresent ) ; } } } } for rect in & rects { if rect . rect_extent [ 0 ] == 0 || rect . rect_extent [ 1 ] == 0 { return Err ( ClearAttachmentsError :: ZeroRectExtent ) ; } if rect . rect_offset [ 0 ] + rect . rect_extent [ 0 ] > dimensions [ 0 ] || rect . rect_offset [ 1 ] + rect . rect_extent [ 1 ] > dimensions [ 1 ] { return Err ( ClearAttachmentsError :: RectOutOfBounds ) ; } if rect . layer_count == 0 { return Err ( ClearAttachmentsError :: ZeroLayerCount ) ; } if multiview && ( rect . base_array_layer != 0 || rect . layer_count != 1 ) { return Err ( ClearAttachmentsError :: InvalidMultiviewLayerRange ) ; } // make sure rect's layers is inside attached layers ranges for range in attached_layers_ranges { if rect . base_array_layer < range . start || rect . base_array_layer + rect . layer_count > range . end { return Err ( ClearAttachmentsError :: LayersOutOfBounds ) ; } } } unsafe { self . inner . clear_attachments ( attachments , rects ) ; } Ok ( self ) }
Adds a command that clears specific regions of specific attachments of the framebuffer.
Adds a command that clears specific regions of specific attachments of the framebuffer .
&mut self
attachments
A
rects
R
&mut self
attachments
A
rects
R