gfx_hal/command/
structs.rs

1use crate::{buffer, image};
2
3use std::ops::Range;
4
5/// Specifies a source region and a destination
6/// region in a buffer for copying.  All values
7/// are in units of bytes.
8#[derive(Clone, Copy, Debug)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub struct BufferCopy {
11    /// Buffer region source offset.
12    pub src: buffer::Offset,
13    /// Buffer region destination offset.
14    pub dst: buffer::Offset,
15    /// Region size.
16    pub size: buffer::Offset,
17}
18
19/// Bundles together all the parameters needed to copy data from one `Image`
20/// to another.
21#[derive(Clone, Debug)]
22#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
23pub struct ImageCopy {
24    /// The image subresource to copy from.
25    pub src_subresource: image::SubresourceLayers,
26    /// The source offset.
27    pub src_offset: image::Offset,
28    /// The image subresource to copy to.
29    pub dst_subresource: image::SubresourceLayers,
30    /// The destination offset.
31    pub dst_offset: image::Offset,
32    /// The extent of the region to copy.
33    pub extent: image::Extent,
34}
35
36/// Bundles together all the parameters needed to copy a buffer
37/// to an image or vice-versa.
38#[derive(Clone, Debug)]
39#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
40pub struct BufferImageCopy {
41    /// Buffer offset in bytes.
42    pub buffer_offset: buffer::Offset,
43    /// Width of a buffer 'row' in texels.
44    pub buffer_width: u32,
45    /// Height of a buffer 'image slice' in texels.
46    pub buffer_height: u32,
47    /// The image subresource.
48    pub image_layers: image::SubresourceLayers,
49    /// The offset of the portion of the image to copy.
50    pub image_offset: image::Offset,
51    /// Size of the portion of the image to copy.
52    pub image_extent: image::Extent,
53}
54
55/// Parameters for an image resolve operation,
56/// where a multi-sampled image is copied into a single-sampled
57/// image.
58#[derive(Clone, Debug)]
59#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
60pub struct ImageResolve {
61    /// Source image and layers.
62    pub src_subresource: image::SubresourceLayers,
63    /// Source image offset.
64    pub src_offset: image::Offset,
65    /// Destination image and layers.
66    pub dst_subresource: image::SubresourceLayers,
67    /// Destination image offset.
68    pub dst_offset: image::Offset,
69    /// Image extent.
70    pub extent: image::Extent,
71}
72
73/// Parameters for an image blit operation, where a portion of one image
74/// is copied into another, possibly with scaling and filtering.
75#[derive(Clone, Debug)]
76#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
77pub struct ImageBlit {
78    /// Source image and layers.
79    pub src_subresource: image::SubresourceLayers,
80    /// Source image bounds.
81    pub src_bounds: Range<image::Offset>,
82    /// Destination image and layers.
83    pub dst_subresource: image::SubresourceLayers,
84    /// Destination image bounds.
85    pub dst_bounds: Range<image::Offset>,
86}