pub struct Surface {
pub ty: SurfaceType,
pub init: SurfaceInit,
pub format: Option<String>,
pub format_hint: Option<Box<FormatHint>>,
pub size: Option<Box<[u32; 3]>>,
pub viewport_ratio: Option<Box<[f32; 2]>>,
pub mip_levels: u32,
pub mipmap_generate: bool,
pub extra: Vec<Extra>,
}
Expand description
Declares a resource that can be used both as the source for texture samples and as the target of a rendering pass.
Fields§
§ty: SurfaceType
The type of this surface.
init: SurfaceInit
An initialization option for this surface.
format: Option<String>
Contains a string representing the texel format for this surface.
If this element is not specified or understood by the application,
then the application will attempt to use format_hint
if it is provided;
otherwise, it should use a common format linear R8G8B8A8
.
format_hint: Option<Box<FormatHint>>
An application uses format_hint
if format
does not exist or
is not understood by the application and format_hint
exists.
This element describes the important features intended by the author
so that the application can pick a format that best represents what the author wanted.
size: Option<Box<[u32; 3]>>
Contains three integer values. If specified, the surface is
sized to these exact dimensions in texels. Surfaces of
type 1D
and CUBE
use only the first value. Surfaces of
type 2D
and RECT
use only the first two values,
representing width and then height. Type 3D
uses all
three values, representing width, height, and depth.
Invalid if viewport_ratio
is used.
viewport_ratio: Option<Box<[f32; 2]>>
Contains two floating-point values representing width and then height.
If specified, the surface is sized to a dimension
based on these ratios of the viewport’s (backbuffer’s) dimensions.
For example, viewport_ratio = Some([0.5, 2])
scales the surface’s width to half the viewport’s width
and its height to twice the viewport’s height.
This element is valid only for surfaces of type 2D
or RECT
.
Invalid if size
is used.
mip_levels: u32
Contains the number of MIP levels in the surface. A value
of 0 assumes that all MIP levels exist until a dimension
becomes 1 texel. To create a surface that has only one
level of MIP maps (mip
= 0), set this to 1.
mipmap_generate: bool
If false and not all subsurfaces are initialized because you have not provided MIP-map levels, the generated surface will have profile- and
platform-specific behavior. If true, the application is
responsible for initializing the remainder of the
subsurfaces; this is typically done through a graphics API
render state or function that does this automatically, such
as glGenerateMipmap()
.
extra: Vec<Extra>
Provides arbitrary additional information about this element.
Implementations§
Source§impl Surface
impl Surface
Sourcepub fn new(ty: SurfaceType, init: SurfaceInit) -> Self
pub fn new(ty: SurfaceType, init: SurfaceInit) -> Self
Construct a new Surface
from mandatory parameters.