mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-24 07:45:13 +00:00
Add Format::UNDEFINED
(#2262)
* Add `Format::UNDEFINED` * Use `iter::once`
This commit is contained in:
parent
6dc8e64ac7
commit
0f5e298f29
@ -226,13 +226,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -316,7 +314,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [TRANSFER_GRANULARITY * 2, TRANSFER_GRANULARITY * 2, 1],
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
|
@ -128,13 +128,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -107,13 +107,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -158,7 +158,7 @@ impl FrameSystem {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::A2B10G10R10_UNORM_PACK32),
|
||||
format: Format::A2B10G10R10_UNORM_PACK32,
|
||||
extent: [1, 1, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT
|
||||
| ImageUsage::TRANSIENT_ATTACHMENT
|
||||
@ -175,7 +175,7 @@ impl FrameSystem {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R16G16B16A16_SFLOAT),
|
||||
format: Format::R16G16B16A16_SFLOAT,
|
||||
extent: [1, 1, 1],
|
||||
usage: ImageUsage::TRANSIENT_ATTACHMENT | ImageUsage::INPUT_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -190,7 +190,7 @@ impl FrameSystem {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::D16_UNORM),
|
||||
format: Format::D16_UNORM,
|
||||
extent: [1, 1, 1],
|
||||
usage: ImageUsage::TRANSIENT_ATTACHMENT | ImageUsage::INPUT_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -284,7 +284,7 @@ impl FrameSystem {
|
||||
&self.memory_allocator,
|
||||
ImageCreateInfo {
|
||||
extent,
|
||||
format: Some(Format::A2B10G10R10_UNORM_PACK32),
|
||||
format: Format::A2B10G10R10_UNORM_PACK32,
|
||||
usage: ImageUsage::COLOR_ATTACHMENT
|
||||
| ImageUsage::TRANSIENT_ATTACHMENT
|
||||
| ImageUsage::INPUT_ATTACHMENT,
|
||||
@ -300,7 +300,7 @@ impl FrameSystem {
|
||||
&self.memory_allocator,
|
||||
ImageCreateInfo {
|
||||
extent,
|
||||
format: Some(Format::R16G16B16A16_SFLOAT),
|
||||
format: Format::R16G16B16A16_SFLOAT,
|
||||
usage: ImageUsage::COLOR_ATTACHMENT
|
||||
| ImageUsage::TRANSIENT_ATTACHMENT
|
||||
| ImageUsage::INPUT_ATTACHMENT,
|
||||
@ -316,7 +316,7 @@ impl FrameSystem {
|
||||
&self.memory_allocator,
|
||||
ImageCreateInfo {
|
||||
extent,
|
||||
format: Some(Format::D16_UNORM),
|
||||
format: Format::D16_UNORM,
|
||||
usage: ImageUsage::DEPTH_STENCIL_ATTACHMENT
|
||||
| ImageUsage::TRANSIENT_ATTACHMENT
|
||||
| ImageUsage::INPUT_ATTACHMENT,
|
||||
|
@ -129,13 +129,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
let (swapchain, images) = Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -218,7 +218,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [1024, 1024, 1],
|
||||
usage: ImageUsage::TRANSFER_SRC | ImageUsage::STORAGE,
|
||||
..Default::default()
|
||||
|
@ -121,7 +121,7 @@ mod linux {
|
||||
ImageCreateInfo {
|
||||
flags: ImageCreateFlags::MUTABLE_FORMAT,
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R16G16B16A16_UNORM),
|
||||
format: Format::R16G16B16A16_UNORM,
|
||||
extent: [200, 200, 1],
|
||||
usage: ImageUsage::TRANSFER_SRC | ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
external_memory_handle_types: ExternalMemoryHandleTypes::OPAQUE_FD,
|
||||
@ -562,13 +562,11 @@ mod linux {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -133,13 +133,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -252,7 +250,7 @@ fn main() {
|
||||
let image = Image::new(
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent,
|
||||
usage: ImageUsage::TRANSFER_SRC | ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
|
@ -131,13 +131,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -251,7 +249,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_SRGB),
|
||||
format: Format::R8G8B8A8_SRGB,
|
||||
extent,
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
|
@ -137,13 +137,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -257,7 +255,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_SRGB),
|
||||
format: Format::R8G8B8A8_SRGB,
|
||||
extent,
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
|
@ -146,13 +146,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -144,13 +144,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -161,7 +161,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [1024, 1024, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT | ImageUsage::TRANSIENT_ATTACHMENT,
|
||||
samples: SampleCount::Sample4,
|
||||
@ -178,7 +178,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [1024, 1024, 1],
|
||||
usage: ImageUsage::TRANSFER_SRC
|
||||
| ImageUsage::TRANSFER_DST
|
||||
|
@ -152,13 +152,11 @@ fn main() {
|
||||
|
||||
// The swapchain and framebuffer images for this particular window.
|
||||
let (swapchain, images) = {
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
let window = surface.object().unwrap().downcast_ref::<Window>().unwrap();
|
||||
|
||||
Swapchain::new(
|
||||
@ -362,13 +360,11 @@ fn main() {
|
||||
.into_iter()
|
||||
.next()
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -96,7 +96,7 @@ impl GameOfLifeComputePipeline {
|
||||
memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [size[0], size[1], 1],
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED | ImageUsage::STORAGE,
|
||||
..Default::default()
|
||||
|
@ -140,7 +140,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::B8G8R8A8_SRGB),
|
||||
format: Format::B8G8R8A8_SRGB,
|
||||
extent: [512, 512, 1],
|
||||
array_layers: 2,
|
||||
usage: ImageUsage::TRANSFER_SRC | ImageUsage::COLOR_ATTACHMENT,
|
||||
|
@ -126,13 +126,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -574,7 +572,7 @@ fn window_size_dependent_setup(
|
||||
memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::D16_UNORM),
|
||||
format: Format::D16_UNORM,
|
||||
extent: images[0].extent(),
|
||||
usage: ImageUsage::DEPTH_STENCIL_ATTACHMENT | ImageUsage::TRANSIENT_ATTACHMENT,
|
||||
..Default::default()
|
||||
|
@ -127,13 +127,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -246,7 +244,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_SRGB),
|
||||
format: Format::R8G8B8A8_SRGB,
|
||||
extent,
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
|
@ -134,13 +134,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -139,13 +139,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -312,7 +310,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_SRGB),
|
||||
format: Format::R8G8B8A8_SRGB,
|
||||
extent,
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
@ -360,7 +358,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_SRGB),
|
||||
format: Format::R8G8B8A8_SRGB,
|
||||
extent,
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
|
@ -145,13 +145,11 @@ fn main() {
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -135,13 +135,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -443,7 +441,7 @@ fn window_size_dependent_setup(
|
||||
memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::D16_UNORM),
|
||||
format: Format::D16_UNORM,
|
||||
extent: images[0].extent(),
|
||||
usage: ImageUsage::DEPTH_STENCIL_ATTACHMENT | ImageUsage::TRANSIENT_ATTACHMENT,
|
||||
..Default::default()
|
||||
|
@ -238,13 +238,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
|
@ -133,13 +133,11 @@ fn main() {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
Swapchain::new(
|
||||
device.clone(),
|
||||
@ -230,7 +228,7 @@ fn main() {
|
||||
let extent: [u32; 3] = [128, 128, 1];
|
||||
let array_layers = 3u32;
|
||||
|
||||
let buffer_size = format.block_size().unwrap()
|
||||
let buffer_size = format.block_size()
|
||||
* extent
|
||||
.into_iter()
|
||||
.map(|e| e as DeviceSize)
|
||||
@ -270,7 +268,7 @@ fn main() {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(format),
|
||||
format,
|
||||
extent,
|
||||
array_layers,
|
||||
usage: ImageUsage::TRANSFER_DST | ImageUsage::SAMPLED,
|
||||
|
@ -239,13 +239,11 @@ fn main() {
|
||||
.unwrap();
|
||||
|
||||
// Choosing the internal format that the images will have.
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
// Please take a look at the docs for the meaning of the parameters we didn't mention.
|
||||
Swapchain::new(
|
||||
|
@ -208,13 +208,11 @@ fn main() {
|
||||
.unwrap();
|
||||
|
||||
// Choosing the internal format that the images will have.
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
|
||||
// Please take a look at the docs for the meaning of the parameters we didn't mention.
|
||||
Swapchain::new(
|
||||
|
@ -72,9 +72,7 @@ pub fn derive_vertex(ast: syn::DeriveInput) -> Result<TokenStream> {
|
||||
|
||||
let field_size = ::std::mem::size_of::<#field_ty>();
|
||||
let format = #format;
|
||||
let format_size = format
|
||||
.block_size()
|
||||
.expect("no block size for format") as usize;
|
||||
let format_size = format.block_size() as usize;
|
||||
let num_elements = field_size / format_size;
|
||||
let remainder = field_size % format_size;
|
||||
::std::assert!(
|
||||
|
@ -99,13 +99,11 @@ impl VulkanoWindowRenderer {
|
||||
.physical_device()
|
||||
.surface_capabilities(&surface, Default::default())
|
||||
.unwrap();
|
||||
let image_format = Some(
|
||||
device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0,
|
||||
);
|
||||
let image_format = device
|
||||
.physical_device()
|
||||
.surface_formats(&surface, Default::default())
|
||||
.unwrap()[0]
|
||||
.0;
|
||||
let (swapchain, images) = Swapchain::new(device, surface, {
|
||||
let mut create_info = SwapchainCreateInfo {
|
||||
min_image_count: surface_capabilities.min_image_count.max(2),
|
||||
@ -145,9 +143,7 @@ impl VulkanoWindowRenderer {
|
||||
/// Return swapchain image format.
|
||||
#[inline]
|
||||
pub fn swapchain_format(&self) -> Format {
|
||||
self.final_views[self.image_index as usize]
|
||||
.format()
|
||||
.unwrap()
|
||||
self.final_views[self.image_index as usize].format()
|
||||
}
|
||||
|
||||
/// Returns the index of last swapchain image that is the next render target.
|
||||
@ -234,7 +230,7 @@ impl VulkanoWindowRenderer {
|
||||
&self.memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(format),
|
||||
format,
|
||||
extent: final_view_image.extent(),
|
||||
usage,
|
||||
..Default::default()
|
||||
@ -368,7 +364,7 @@ impl VulkanoWindowRenderer {
|
||||
.map(|c| *c.0)
|
||||
.collect::<Vec<usize>>();
|
||||
for i in resizable_views {
|
||||
let format = self.get_additional_image_view(i).format().unwrap();
|
||||
let format = self.get_additional_image_view(i).format();
|
||||
let usage = self.get_additional_image_view(i).usage();
|
||||
self.remove_additional_image_view(i);
|
||||
self.add_additional_image_view(i, format, usage);
|
||||
|
@ -13,6 +13,7 @@ use once_cell::sync::Lazy;
|
||||
use proc_macro2::{Ident, Literal, TokenStream};
|
||||
use quote::{format_ident, quote};
|
||||
use regex::Regex;
|
||||
use std::iter;
|
||||
use vk_parse::{
|
||||
Enum, EnumSpec, Extension, ExtensionChild, Feature, Format, FormatChild, InterfaceItem,
|
||||
};
|
||||
@ -46,7 +47,7 @@ struct FormatMember {
|
||||
aspect_plane2: bool,
|
||||
|
||||
block_extent: [u32; 3],
|
||||
block_size: Option<u64>,
|
||||
block_size: u64,
|
||||
compatibility: Ident,
|
||||
components: [u8; 4],
|
||||
compression: Option<Ident>,
|
||||
@ -64,11 +65,12 @@ struct FormatMember {
|
||||
|
||||
fn formats_output(members: &[FormatMember]) -> TokenStream {
|
||||
let enum_items = members.iter().map(|FormatMember { name, ffi_name, .. }| {
|
||||
quote! { #name = ash::vk::Format::#ffi_name.as_raw(), }
|
||||
let default = (ffi_name == "UNDEFINED").then(|| quote! { #[default] });
|
||||
quote! { #default #name = ash::vk::Format::#ffi_name.as_raw(), }
|
||||
});
|
||||
let aspects_items = members.iter().map(
|
||||
|FormatMember {
|
||||
name,
|
||||
|&FormatMember {
|
||||
ref name,
|
||||
aspect_color,
|
||||
aspect_depth,
|
||||
aspect_stencil,
|
||||
@ -77,19 +79,31 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
|
||||
aspect_plane2,
|
||||
..
|
||||
}| {
|
||||
let aspect_items = [
|
||||
aspect_color.then(|| quote! { crate::image::ImageAspects::COLOR }),
|
||||
aspect_depth.then(|| quote! { crate::image::ImageAspects::DEPTH }),
|
||||
aspect_stencil.then(|| quote! { crate::image::ImageAspects::STENCIL }),
|
||||
aspect_plane0.then(|| quote! { crate::image::ImageAspects::PLANE_0 }),
|
||||
aspect_plane1.then(|| quote! { crate::image::ImageAspects::PLANE_1 }),
|
||||
aspect_plane2.then(|| quote! { crate::image::ImageAspects::PLANE_2 }),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten();
|
||||
if aspect_color
|
||||
|| aspect_depth
|
||||
|| aspect_stencil
|
||||
|| aspect_plane0
|
||||
|| aspect_plane1
|
||||
|| aspect_plane2
|
||||
{
|
||||
let aspect_items = [
|
||||
aspect_color.then(|| quote! { crate::image::ImageAspects::COLOR }),
|
||||
aspect_depth.then(|| quote! { crate::image::ImageAspects::DEPTH }),
|
||||
aspect_stencil.then(|| quote! { crate::image::ImageAspects::STENCIL }),
|
||||
aspect_plane0.then(|| quote! { crate::image::ImageAspects::PLANE_0 }),
|
||||
aspect_plane1.then(|| quote! { crate::image::ImageAspects::PLANE_1 }),
|
||||
aspect_plane2.then(|| quote! { crate::image::ImageAspects::PLANE_2 }),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten();
|
||||
|
||||
quote! {
|
||||
Self::#name => #(#aspect_items)|*,
|
||||
quote! {
|
||||
Self::#name => #(#aspect_items)|*,
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
Self::#name => crate::image::ImageAspects::empty(),
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
@ -109,14 +123,12 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
|
||||
}
|
||||
},
|
||||
);
|
||||
let block_size_items = members.iter().filter_map(
|
||||
let block_size_items = members.iter().map(
|
||||
|FormatMember {
|
||||
name, block_size, ..
|
||||
}| {
|
||||
block_size.as_ref().map(|size| {
|
||||
let size = Literal::u64_unsuffixed(*size);
|
||||
quote! { Self::#name => Some(#size), }
|
||||
})
|
||||
let block_size = Literal::u64_unsuffixed(*block_size);
|
||||
quote! { Self::#name => #block_size, }
|
||||
},
|
||||
);
|
||||
let compatibility_items = members.iter().map(
|
||||
@ -319,7 +331,7 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
|
||||
|
||||
quote! {
|
||||
/// An enumeration of all the possible formats.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
|
||||
#[repr(i32)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[non_exhaustive]
|
||||
@ -352,20 +364,17 @@ fn formats_output(members: &[FormatMember]) -> TokenStream {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the size in bytes of a single texel block of this format. Returns `None`
|
||||
/// if the texel block size is not well-defined for this format.
|
||||
/// Returns the size in bytes of a single texel block of this format.
|
||||
///
|
||||
/// For regular formats, this is the size of a single texel, but for more specialized
|
||||
/// formats this may be the size of multiple texels.
|
||||
///
|
||||
/// Depth/stencil formats are considered to have an opaque memory representation, and do
|
||||
/// not have a well-defined size. Multi-planar formats store the color components
|
||||
/// disjointly in memory, and therefore do not have a well-defined size for all
|
||||
/// components as a whole. The individual planes do have a well-defined size.
|
||||
pub fn block_size(self) -> Option<DeviceSize> {
|
||||
/// Multi-planar formats store the color components disjointly in memory, and therefore
|
||||
/// the texels do not form a single texel block. The block size for such formats
|
||||
/// indicates the sum of the block size of each plane.
|
||||
pub fn block_size(self) -> DeviceSize {
|
||||
match self {
|
||||
#(#block_size_items)*
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,6 +585,36 @@ fn formats_members(
|
||||
static BLOCK_EXTENT_REGEX: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"^(\d+),(\d+),(\d+)$").unwrap());
|
||||
|
||||
iter::once(
|
||||
FormatMember {
|
||||
name: format_ident!("UNDEFINED"),
|
||||
ffi_name: format_ident!("UNDEFINED"),
|
||||
requires_all_of: Vec::new(),
|
||||
|
||||
aspect_color: false,
|
||||
aspect_depth: false,
|
||||
aspect_stencil: false,
|
||||
aspect_plane0: false,
|
||||
aspect_plane1: false,
|
||||
aspect_plane2: false,
|
||||
|
||||
block_extent: [0; 3],
|
||||
block_size: 0,
|
||||
compatibility: format_ident!("Undefined"),
|
||||
components: [0u8; 4],
|
||||
compression: None,
|
||||
planes: vec![],
|
||||
texels_per_block: 0,
|
||||
type_color: None,
|
||||
type_depth: None,
|
||||
type_stencil: None,
|
||||
ycbcr_chroma_sampling: None,
|
||||
|
||||
type_std_array: None,
|
||||
type_cgmath: None,
|
||||
type_nalgebra: None,
|
||||
}
|
||||
).chain(
|
||||
formats
|
||||
.iter()
|
||||
.map(|format| {
|
||||
@ -603,7 +642,7 @@ fn formats_members(
|
||||
aspect_plane2: false,
|
||||
|
||||
block_extent: [1, 1, 1],
|
||||
block_size: None,
|
||||
block_size: format.blockSize as u64,
|
||||
compatibility: format_ident!(
|
||||
"Class_{}",
|
||||
format.class.replace('-', "").replace(' ', "_")
|
||||
@ -712,10 +751,7 @@ fn formats_members(
|
||||
}
|
||||
};
|
||||
|
||||
// Depth-stencil and multi-planar formats don't have well-defined block sizes.
|
||||
if let (Some(numeric_type), true) = (&member.type_color, member.planes.is_empty()) {
|
||||
member.block_size = Some(format.blockSize as u64);
|
||||
|
||||
if format.compressed.is_some() {
|
||||
member.type_std_array = Some({
|
||||
let block_size = Literal::usize_unsuffixed(format.blockSize as usize);
|
||||
@ -868,6 +904,6 @@ fn formats_members(
|
||||
}
|
||||
|
||||
member
|
||||
})
|
||||
}))
|
||||
.collect()
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
//! let view = BufferView::new(
|
||||
//! buffer,
|
||||
//! BufferViewCreateInfo {
|
||||
//! format: Some(Format::R32_UINT),
|
||||
//! format: Format::R32_UINT,
|
||||
//! ..Default::default()
|
||||
//! },
|
||||
//! )
|
||||
@ -65,7 +65,7 @@ pub struct BufferView {
|
||||
subbuffer: Subbuffer<[u8]>,
|
||||
id: NonZeroU64,
|
||||
|
||||
format: Option<Format>,
|
||||
format: Format,
|
||||
format_features: FormatFeatures,
|
||||
range: Range<DeviceSize>,
|
||||
}
|
||||
@ -93,12 +93,11 @@ impl BufferView {
|
||||
.validate(device)
|
||||
.map_err(|err| err.add_context("create_info"))?;
|
||||
|
||||
let BufferViewCreateInfo { format, _ne: _ } = create_info;
|
||||
let &BufferViewCreateInfo { format, _ne: _ } = create_info;
|
||||
|
||||
let buffer = subbuffer.buffer();
|
||||
let properties = device.physical_device().properties();
|
||||
|
||||
let format = format.unwrap();
|
||||
let format_features = unsafe {
|
||||
device
|
||||
.physical_device()
|
||||
@ -146,7 +145,7 @@ impl BufferView {
|
||||
}));
|
||||
}
|
||||
|
||||
let block_size = format.block_size().unwrap();
|
||||
let block_size = format.block_size();
|
||||
let texels_per_block = format.texels_per_block();
|
||||
|
||||
if subbuffer.size() % block_size != 0 {
|
||||
@ -304,7 +303,7 @@ impl BufferView {
|
||||
let create_info_vk = ash::vk::BufferViewCreateInfo {
|
||||
flags: ash::vk::BufferViewCreateFlags::empty(),
|
||||
buffer: subbuffer.buffer().handle(),
|
||||
format: format.unwrap().into(),
|
||||
format: format.into(),
|
||||
offset: subbuffer.offset(),
|
||||
range: subbuffer.size(),
|
||||
..Default::default()
|
||||
@ -339,7 +338,6 @@ impl BufferView {
|
||||
create_info: BufferViewCreateInfo,
|
||||
) -> Arc<BufferView> {
|
||||
let &BufferViewCreateInfo { format, _ne: _ } = &create_info;
|
||||
let format = format.unwrap();
|
||||
let size = subbuffer.size();
|
||||
let format_features = unsafe {
|
||||
subbuffer
|
||||
@ -353,7 +351,7 @@ impl BufferView {
|
||||
handle,
|
||||
subbuffer: subbuffer.into_bytes(),
|
||||
id: Self::next_id(),
|
||||
format: Some(format),
|
||||
format,
|
||||
format_features,
|
||||
range: 0..size,
|
||||
})
|
||||
@ -367,7 +365,7 @@ impl BufferView {
|
||||
|
||||
/// Returns the format of this view.
|
||||
#[inline]
|
||||
pub fn format(&self) -> Option<Format> {
|
||||
pub fn format(&self) -> Format {
|
||||
self.format
|
||||
}
|
||||
|
||||
@ -421,8 +419,8 @@ impl_id_counter!(BufferView);
|
||||
pub struct BufferViewCreateInfo {
|
||||
/// The format of the buffer view.
|
||||
///
|
||||
/// The default value is `None`, which must be overridden.
|
||||
pub format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub format: Format,
|
||||
|
||||
pub _ne: crate::NonExhaustive,
|
||||
}
|
||||
@ -431,7 +429,7 @@ impl Default for BufferViewCreateInfo {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
format: None,
|
||||
format: Format::UNDEFINED,
|
||||
_ne: crate::NonExhaustive(()),
|
||||
}
|
||||
}
|
||||
@ -441,12 +439,6 @@ impl BufferViewCreateInfo {
|
||||
pub(crate) fn validate(&self, device: &Device) -> Result<(), Box<ValidationError>> {
|
||||
let Self { format, _ne: _ } = self;
|
||||
|
||||
let format = format.ok_or(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `None`".into(),
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
@ -490,7 +482,7 @@ mod tests {
|
||||
BufferView::new(
|
||||
buffer,
|
||||
BufferViewCreateInfo {
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
@ -516,7 +508,7 @@ mod tests {
|
||||
BufferView::new(
|
||||
buffer,
|
||||
BufferViewCreateInfo {
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
@ -542,7 +534,7 @@ mod tests {
|
||||
BufferView::new(
|
||||
buffer,
|
||||
BufferViewCreateInfo {
|
||||
format: Some(Format::R32_UINT),
|
||||
format: Format::R32_UINT,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
@ -569,7 +561,7 @@ mod tests {
|
||||
match BufferView::new(
|
||||
buffer,
|
||||
BufferViewCreateInfo {
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
..Default::default()
|
||||
},
|
||||
) {
|
||||
@ -598,7 +590,7 @@ mod tests {
|
||||
match BufferView::new(
|
||||
buffer,
|
||||
BufferViewCreateInfo {
|
||||
format: Some(Format::R64G64B64A64_SFLOAT),
|
||||
format: Format::R64G64B64A64_SFLOAT,
|
||||
..Default::default()
|
||||
},
|
||||
) {
|
||||
|
@ -1028,7 +1028,6 @@ impl AutoSyncState {
|
||||
.separate_depth_stencil_layouts
|
||||
&& image
|
||||
.format()
|
||||
.unwrap()
|
||||
.aspects()
|
||||
.contains(ImageAspects::DEPTH | ImageAspects::STENCIL)
|
||||
{
|
||||
@ -1604,11 +1603,9 @@ impl RenderPassStateAttachments {
|
||||
.collect(),
|
||||
depth_attachment: (subpass_desc.depth_stencil_attachment.as_ref())
|
||||
.filter(|depth_stencil_attachment| {
|
||||
(rp_attachments[depth_stencil_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap())
|
||||
.aspects()
|
||||
.intersects(ImageAspects::DEPTH)
|
||||
(rp_attachments[depth_stencil_attachment.attachment as usize].format)
|
||||
.aspects()
|
||||
.intersects(ImageAspects::DEPTH)
|
||||
})
|
||||
.map(|depth_stencil_attachment| RenderPassStateAttachmentInfo {
|
||||
image_view: fb_attachments[depth_stencil_attachment.attachment as usize]
|
||||
@ -1625,11 +1622,9 @@ impl RenderPassStateAttachments {
|
||||
}),
|
||||
stencil_attachment: (subpass_desc.depth_stencil_attachment.as_ref())
|
||||
.filter(|depth_stencil_attachment| {
|
||||
(rp_attachments[depth_stencil_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap())
|
||||
.aspects()
|
||||
.intersects(ImageAspects::STENCIL)
|
||||
(rp_attachments[depth_stencil_attachment.attachment as usize].format)
|
||||
.aspects()
|
||||
.intersects(ImageAspects::STENCIL)
|
||||
})
|
||||
.map(|depth_stencil_attachment| RenderPassStateAttachmentInfo {
|
||||
image_view: fb_attachments[depth_stencil_attachment.attachment as usize]
|
||||
|
@ -101,26 +101,26 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
let image_aspects = image.format().unwrap().aspects();
|
||||
let image_aspects = image.format().aspects();
|
||||
|
||||
// VUID-vkCmdClearColorImage-image-00007
|
||||
if image_aspects.intersects(ImageAspects::DEPTH | ImageAspects::STENCIL) {
|
||||
return Err(ClearError::FormatNotSupported {
|
||||
format: image.format().unwrap(),
|
||||
format: image.format(),
|
||||
});
|
||||
}
|
||||
|
||||
// VUID-vkCmdClearColorImage-image-00007
|
||||
if image.format().unwrap().compression().is_some() {
|
||||
if image.format().compression().is_some() {
|
||||
return Err(ClearError::FormatNotSupported {
|
||||
format: image.format().unwrap(),
|
||||
format: image.format(),
|
||||
});
|
||||
}
|
||||
|
||||
// VUID-vkCmdClearColorImage-image-01545
|
||||
if image.format().unwrap().ycbcr_chroma_sampling().is_some() {
|
||||
if image.format().ycbcr_chroma_sampling().is_some() {
|
||||
return Err(ClearError::FormatNotSupported {
|
||||
format: image.format().unwrap(),
|
||||
format: image.format(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -278,12 +278,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
let image_aspects = image.format().unwrap().aspects();
|
||||
let image_aspects = image.format().aspects();
|
||||
|
||||
// VUID-vkCmdClearDepthStencilImage-image-00014
|
||||
if !image_aspects.intersects(ImageAspects::DEPTH | ImageAspects::STENCIL) {
|
||||
return Err(ClearError::FormatNotSupported {
|
||||
format: image.format().unwrap(),
|
||||
format: image.format(),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -300,8 +300,8 @@ where
|
||||
|
||||
let copy_2d_3d_supported =
|
||||
device.api_version() >= Version::V1_1 || device.enabled_extensions().khr_maintenance1;
|
||||
let mut src_image_aspects = src_image.format().unwrap().aspects();
|
||||
let mut dst_image_aspects = dst_image.format().unwrap().aspects();
|
||||
let mut src_image_aspects = src_image.format().aspects();
|
||||
let mut dst_image_aspects = dst_image.format().aspects();
|
||||
|
||||
if device.api_version() >= Version::V1_1 || device.enabled_extensions().khr_maintenance1 {
|
||||
// VUID-VkCopyImageInfo2-srcImage-01995
|
||||
@ -341,8 +341,8 @@ where
|
||||
// VUID-VkCopyImageInfo2-srcImage-01548
|
||||
if src_image.format() != dst_image.format() {
|
||||
return Err(CopyError::FormatsMismatch {
|
||||
src_format: src_image.format().unwrap(),
|
||||
dst_format: dst_image.format().unwrap(),
|
||||
src_format: src_image.format(),
|
||||
dst_format: dst_image.format(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -390,11 +390,11 @@ where
|
||||
|
||||
Some((
|
||||
granularity(
|
||||
src_image.format().unwrap().block_extent(),
|
||||
src_image.format().block_extent(),
|
||||
src_image_aspects.intersects(ImageAspects::PLANE_0),
|
||||
),
|
||||
granularity(
|
||||
dst_image.format().unwrap().block_extent(),
|
||||
dst_image.format().block_extent(),
|
||||
dst_image_aspects.intersects(ImageAspects::PLANE_0),
|
||||
),
|
||||
))
|
||||
@ -493,23 +493,21 @@ where
|
||||
}
|
||||
|
||||
if subresource.aspects.intersects(ImageAspects::PLANE_0) {
|
||||
(image.format().unwrap().planes()[0], image.extent())
|
||||
(image.format().planes()[0], image.extent())
|
||||
} else if subresource.aspects.intersects(ImageAspects::PLANE_1) {
|
||||
(
|
||||
image.format().unwrap().planes()[1],
|
||||
image.format().planes()[1],
|
||||
image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.unwrap()
|
||||
.subsampled_extent(image.extent()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
image.format().unwrap().planes()[2],
|
||||
image.format().planes()[2],
|
||||
image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.unwrap()
|
||||
.subsampled_extent(image.extent()),
|
||||
@ -517,7 +515,7 @@ where
|
||||
}
|
||||
} else {
|
||||
(
|
||||
image.format().unwrap(),
|
||||
image.format(),
|
||||
mip_level_extent(image.extent(), subresource.mip_level).unwrap(),
|
||||
)
|
||||
};
|
||||
@ -1031,7 +1029,7 @@ where
|
||||
assert_eq!(device, src_buffer.device());
|
||||
assert_eq!(device, dst_image.device());
|
||||
|
||||
let mut image_aspects = dst_image.format().unwrap().aspects();
|
||||
let mut image_aspects = dst_image.format().aspects();
|
||||
|
||||
// VUID-VkCopyBufferToImageInfo2-commandBuffer-04477
|
||||
if !queue_family_properties
|
||||
@ -1115,7 +1113,7 @@ where
|
||||
};
|
||||
|
||||
Some(granularity(
|
||||
dst_image.format().unwrap().block_extent(),
|
||||
dst_image.format().block_extent(),
|
||||
image_aspects.intersects(ImageAspects::PLANE_0),
|
||||
))
|
||||
}
|
||||
@ -1188,23 +1186,21 @@ where
|
||||
let (image_subresource_format, image_subresource_extent) =
|
||||
if image_aspects.intersects(ImageAspects::PLANE_0) {
|
||||
if image_subresource.aspects.intersects(ImageAspects::PLANE_0) {
|
||||
(dst_image.format().unwrap().planes()[0], dst_image.extent())
|
||||
(dst_image.format().planes()[0], dst_image.extent())
|
||||
} else if image_subresource.aspects.intersects(ImageAspects::PLANE_1) {
|
||||
(
|
||||
dst_image.format().unwrap().planes()[1],
|
||||
dst_image.format().planes()[1],
|
||||
dst_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.unwrap()
|
||||
.subsampled_extent(dst_image.extent()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
dst_image.format().unwrap().planes()[2],
|
||||
dst_image.format().planes()[2],
|
||||
dst_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.unwrap()
|
||||
.subsampled_extent(dst_image.extent()),
|
||||
@ -1212,7 +1208,7 @@ where
|
||||
}
|
||||
} else {
|
||||
(
|
||||
dst_image.format().unwrap(),
|
||||
dst_image.format(),
|
||||
mip_level_extent(dst_image.extent(), image_subresource.mip_level).unwrap(),
|
||||
)
|
||||
};
|
||||
@ -1346,7 +1342,7 @@ where
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
image_subresource_format.block_size().unwrap()
|
||||
image_subresource_format.block_size()
|
||||
};
|
||||
|
||||
// VUID-VkCopyBufferToImageInfo2-pRegions-04725
|
||||
@ -1452,8 +1448,7 @@ where
|
||||
Resource::Buffer {
|
||||
buffer: src_buffer.clone(),
|
||||
range: buffer_offset
|
||||
..buffer_offset
|
||||
+ region.buffer_copy_size(dst_image.format().unwrap()),
|
||||
..buffer_offset + region.buffer_copy_size(dst_image.format()),
|
||||
memory_access: PipelineStageAccessFlags::Copy_TransferRead,
|
||||
},
|
||||
),
|
||||
@ -1528,7 +1523,7 @@ where
|
||||
assert_eq!(device, dst_buffer.device());
|
||||
assert_eq!(device, src_image.device());
|
||||
|
||||
let mut image_aspects = src_image.format().unwrap().aspects();
|
||||
let mut image_aspects = src_image.format().aspects();
|
||||
|
||||
// VUID-VkCopyImageToBufferInfo2-srcImage-00186
|
||||
if !src_image.usage().intersects(ImageUsage::TRANSFER_SRC) {
|
||||
@ -1603,7 +1598,7 @@ where
|
||||
};
|
||||
|
||||
Some(granularity(
|
||||
src_image.format().unwrap().block_extent(),
|
||||
src_image.format().block_extent(),
|
||||
image_aspects.intersects(ImageAspects::PLANE_0),
|
||||
))
|
||||
}
|
||||
@ -1674,23 +1669,21 @@ where
|
||||
let (image_subresource_format, image_subresource_extent) =
|
||||
if image_aspects.intersects(ImageAspects::PLANE_0) {
|
||||
if image_subresource.aspects.intersects(ImageAspects::PLANE_0) {
|
||||
(src_image.format().unwrap().planes()[0], src_image.extent())
|
||||
(src_image.format().planes()[0], src_image.extent())
|
||||
} else if image_subresource.aspects.intersects(ImageAspects::PLANE_1) {
|
||||
(
|
||||
src_image.format().unwrap().planes()[1],
|
||||
src_image.format().planes()[1],
|
||||
src_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.unwrap()
|
||||
.subsampled_extent(src_image.extent()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
src_image.format().unwrap().planes()[2],
|
||||
src_image.format().planes()[2],
|
||||
src_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.unwrap()
|
||||
.subsampled_extent(src_image.extent()),
|
||||
@ -1698,7 +1691,7 @@ where
|
||||
}
|
||||
} else {
|
||||
(
|
||||
src_image.format().unwrap(),
|
||||
src_image.format(),
|
||||
mip_level_extent(src_image.extent(), image_subresource.mip_level).unwrap(),
|
||||
)
|
||||
};
|
||||
@ -1832,7 +1825,7 @@ where
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
image_subresource_format.block_size().unwrap()
|
||||
image_subresource_format.block_size()
|
||||
};
|
||||
|
||||
// VUID-VkCopyImageToBufferInfo2-pRegions-04725
|
||||
@ -1948,8 +1941,7 @@ where
|
||||
Resource::Buffer {
|
||||
buffer: dst_buffer.clone(),
|
||||
range: buffer_offset
|
||||
..buffer_offset
|
||||
+ region.buffer_copy_size(src_image.format().unwrap()),
|
||||
..buffer_offset + region.buffer_copy_size(src_image.format()),
|
||||
memory_access: PipelineStageAccessFlags::Copy_TransferWrite,
|
||||
},
|
||||
),
|
||||
@ -2045,8 +2037,8 @@ where
|
||||
assert_eq!(device, src_image.device());
|
||||
assert_eq!(device, dst_image.device());
|
||||
|
||||
let src_image_aspects = src_image.format().unwrap().aspects();
|
||||
let dst_image_aspects = dst_image.format().unwrap().aspects();
|
||||
let src_image_aspects = src_image.format().aspects();
|
||||
let dst_image_aspects = dst_image.format().aspects();
|
||||
let src_image_type = src_image.image_type();
|
||||
let dst_image_type = dst_image.image_type();
|
||||
|
||||
@ -2089,28 +2081,18 @@ where
|
||||
}
|
||||
|
||||
// VUID-VkBlitImageInfo2-srcImage-06421
|
||||
if src_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.is_some()
|
||||
{
|
||||
if src_image.format().ycbcr_chroma_sampling().is_some() {
|
||||
return Err(CopyError::FormatNotSupported {
|
||||
resource: CopyErrorResource::Source,
|
||||
format: src_image.format().unwrap(),
|
||||
format: src_image.format(),
|
||||
});
|
||||
}
|
||||
|
||||
// VUID-VkBlitImageInfo2-dstImage-06422
|
||||
if dst_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.ycbcr_chroma_sampling()
|
||||
.is_some()
|
||||
{
|
||||
if dst_image.format().ycbcr_chroma_sampling().is_some() {
|
||||
return Err(CopyError::FormatNotSupported {
|
||||
resource: CopyErrorResource::Destination,
|
||||
format: src_image.format().unwrap(),
|
||||
format: src_image.format(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -2120,8 +2102,8 @@ where
|
||||
// VUID-VkBlitImageInfo2-srcImage-00231
|
||||
if src_image.format() != dst_image.format() {
|
||||
return Err(CopyError::FormatsMismatch {
|
||||
src_format: src_image.format().unwrap(),
|
||||
dst_format: dst_image.format().unwrap(),
|
||||
src_format: src_image.format(),
|
||||
dst_format: dst_image.format(),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@ -2129,8 +2111,8 @@ where
|
||||
// VUID-VkBlitImageInfo2-srcImage-00230
|
||||
if !matches!(
|
||||
(
|
||||
src_image.format().unwrap().type_color().unwrap(),
|
||||
dst_image.format().unwrap().type_color().unwrap(),
|
||||
src_image.format().type_color().unwrap(),
|
||||
dst_image.format().type_color().unwrap(),
|
||||
),
|
||||
(
|
||||
NumericType::SFLOAT
|
||||
@ -2151,8 +2133,8 @@ where
|
||||
| (NumericType::UINT, NumericType::UINT)
|
||||
) {
|
||||
return Err(CopyError::FormatsNotCompatible {
|
||||
src_format: src_image.format().unwrap(),
|
||||
dst_format: dst_image.format().unwrap(),
|
||||
src_format: src_image.format(),
|
||||
dst_format: dst_image.format(),
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -2655,8 +2637,8 @@ where
|
||||
// VUID-VkResolveImageInfo2-srcImage-01386
|
||||
if src_image.format() != dst_image.format() {
|
||||
return Err(CopyError::FormatsMismatch {
|
||||
src_format: src_image.format().unwrap(),
|
||||
dst_format: dst_image.format().unwrap(),
|
||||
src_format: src_image.format(),
|
||||
dst_format: dst_image.format(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -2685,16 +2667,8 @@ where
|
||||
// Should be guaranteed by the requirement that formats match, and that the destination
|
||||
// image format features support color attachments.
|
||||
debug_assert!(
|
||||
src_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.aspects()
|
||||
.intersects(ImageAspects::COLOR)
|
||||
&& dst_image
|
||||
.format()
|
||||
.unwrap()
|
||||
.aspects()
|
||||
.intersects(ImageAspects::COLOR)
|
||||
src_image.format().aspects().intersects(ImageAspects::COLOR)
|
||||
&& dst_image.format().aspects().intersects(ImageAspects::COLOR)
|
||||
);
|
||||
|
||||
for (region_index, region) in regions.iter().enumerate() {
|
||||
@ -4113,7 +4087,7 @@ impl BufferImageCopy {
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
format.block_size().unwrap()
|
||||
format.block_size()
|
||||
};
|
||||
|
||||
num_blocks * block_size
|
||||
@ -4957,10 +4931,7 @@ mod tests {
|
||||
})
|
||||
.product::<DeviceSize>()
|
||||
* layer_count as DeviceSize;
|
||||
let block_size = format
|
||||
.block_size()
|
||||
.expect("this format cannot accept pixels");
|
||||
num_blocks * block_size
|
||||
num_blocks * format.block_size()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -912,7 +912,7 @@ where
|
||||
|
||||
// The SPIR-V Image Format is not compatible with the image view’s format.
|
||||
if let Some(format) = binding_reqs.image_format {
|
||||
if image_view.format() != Some(format) {
|
||||
if image_view.format() != format {
|
||||
return Err(DescriptorResourceInvalidError::ImageViewFormatMismatch {
|
||||
required: format,
|
||||
provided: image_view.format(),
|
||||
@ -959,11 +959,11 @@ where
|
||||
| ImageAspects::PLANE_1
|
||||
| ImageAspects::PLANE_2,
|
||||
) {
|
||||
image_view.format().unwrap().type_color().unwrap()
|
||||
image_view.format().type_color().unwrap()
|
||||
} else if aspects.intersects(ImageAspects::DEPTH) {
|
||||
image_view.format().unwrap().type_depth().unwrap()
|
||||
image_view.format().type_depth().unwrap()
|
||||
} else if aspects.intersects(ImageAspects::STENCIL) {
|
||||
image_view.format().unwrap().type_stencil().unwrap()
|
||||
image_view.format().type_stencil().unwrap()
|
||||
} else {
|
||||
// Per `ImageViewBuilder::aspects` and
|
||||
// VUID-VkDescriptorImageInfo-imageView-01976
|
||||
@ -2652,7 +2652,7 @@ impl Display for PipelineExecutionError {
|
||||
pub enum DescriptorResourceInvalidError {
|
||||
ImageViewFormatMismatch {
|
||||
required: Format,
|
||||
provided: Option<Format>,
|
||||
provided: Format,
|
||||
},
|
||||
ImageViewMultisampledMismatch {
|
||||
required: bool,
|
||||
|
@ -313,7 +313,7 @@ where
|
||||
.enumerate()
|
||||
{
|
||||
let attachment_index = attachment_index as u32;
|
||||
let attachment_format = attachment_desc.format.unwrap();
|
||||
let attachment_format = attachment_desc.format;
|
||||
|
||||
if attachment_desc.load_op == AttachmentLoadOp::Clear
|
||||
|| attachment_desc
|
||||
@ -877,7 +877,7 @@ where
|
||||
|
||||
let resolve_image = resolve_image_view.image();
|
||||
|
||||
match image_view.format().unwrap().type_color().unwrap() {
|
||||
match image_view.format().type_color().unwrap() {
|
||||
NumericType::SFLOAT
|
||||
| NumericType::UFLOAT
|
||||
| NumericType::SNORM
|
||||
@ -987,7 +987,7 @@ where
|
||||
// VUID-VkRenderingAttachmentInfo-storeOp-parameter
|
||||
store_op.validate_device(device)?;
|
||||
|
||||
let image_aspects = image_view.format().unwrap().aspects();
|
||||
let image_aspects = image_view.format().aspects();
|
||||
|
||||
// VUID-VkRenderingInfo-pDepthAttachment-06547
|
||||
if !image_aspects.intersects(ImageAspects::DEPTH) {
|
||||
@ -1127,7 +1127,7 @@ where
|
||||
// VUID-VkRenderingAttachmentInfo-storeOp-parameter
|
||||
store_op.validate_device(device)?;
|
||||
|
||||
let image_aspects = image_view.format().unwrap().aspects();
|
||||
let image_aspects = image_view.format().aspects();
|
||||
|
||||
// VUID-VkRenderingInfo-pStencilAttachment-06548
|
||||
if !image_aspects.intersects(ImageAspects::STENCIL) {
|
||||
@ -2380,7 +2380,7 @@ impl RenderingAttachmentInfo {
|
||||
/// Returns a `RenderingAttachmentInfo` with the specified `image_view`.
|
||||
#[inline]
|
||||
pub fn image_view(image_view: Arc<ImageView>) -> Self {
|
||||
let aspects = image_view.format().unwrap().aspects();
|
||||
let aspects = image_view.format().aspects();
|
||||
let image_layout = if aspects.intersects(ImageAspects::DEPTH | ImageAspects::STENCIL) {
|
||||
ImageLayout::DepthStencilAttachmentOptimal
|
||||
} else {
|
||||
@ -2424,7 +2424,7 @@ impl RenderingAttachmentResolveInfo {
|
||||
/// Returns a `RenderingAttachmentResolveInfo` with the specified `image_view`.
|
||||
#[inline]
|
||||
pub fn image_view(image_view: Arc<ImageView>) -> Self {
|
||||
let aspects = image_view.format().unwrap().aspects();
|
||||
let aspects = image_view.format().aspects();
|
||||
let image_layout = if aspects.intersects(ImageAspects::DEPTH | ImageAspects::STENCIL) {
|
||||
ImageLayout::DepthStencilAttachmentOptimal
|
||||
} else {
|
||||
|
@ -183,7 +183,7 @@ where
|
||||
.enumerate()
|
||||
.filter_map(|(i, (a, f))| a.as_ref().map(|a| (i as u32, &a.image_view, f)))
|
||||
{
|
||||
let required_format = image_view.format().unwrap();
|
||||
let required_format = image_view.format();
|
||||
|
||||
// VUID-vkCmdExecuteCommands-imageView-06028
|
||||
if Some(required_format) != inherited_format {
|
||||
@ -216,11 +216,11 @@ where
|
||||
.map(|a| (&a.image_view, inheritance_info.depth_attachment_format))
|
||||
{
|
||||
// VUID-vkCmdExecuteCommands-pDepthAttachment-06029
|
||||
if Some(image_view.format().unwrap()) != format {
|
||||
if Some(image_view.format()) != format {
|
||||
return Err(
|
||||
ExecuteCommandsError::RenderPassDepthAttachmentFormatMismatch {
|
||||
command_buffer_index,
|
||||
required_format: image_view.format().unwrap(),
|
||||
required_format: image_view.format(),
|
||||
inherited_format: format,
|
||||
},
|
||||
);
|
||||
@ -244,11 +244,11 @@ where
|
||||
.map(|a| (&a.image_view, inheritance_info.stencil_attachment_format))
|
||||
{
|
||||
// VUID-vkCmdExecuteCommands-pStencilAttachment-06030
|
||||
if Some(image_view.format().unwrap()) != format {
|
||||
if Some(image_view.format()) != format {
|
||||
return Err(
|
||||
ExecuteCommandsError::RenderPassStencilAttachmentFormatMismatch {
|
||||
command_buffer_index,
|
||||
required_format: image_view.format().unwrap(),
|
||||
required_format: image_view.format(),
|
||||
inherited_format: format,
|
||||
},
|
||||
);
|
||||
|
@ -551,6 +551,14 @@ impl CommandBufferInheritanceRenderingInfo {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: format!("color_attachment_formats[{}]", index).into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
let potential_format_features = unsafe {
|
||||
device
|
||||
.physical_device()
|
||||
@ -576,6 +584,14 @@ impl CommandBufferInheritanceRenderingInfo {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "depth_attachment_format".into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
if !format.aspects().intersects(ImageAspects::DEPTH) {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "depth_attachment_format".into(),
|
||||
@ -615,6 +631,14 @@ impl CommandBufferInheritanceRenderingInfo {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "stencil_attachment_format".into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
if !format.aspects().intersects(ImageAspects::STENCIL) {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "stencil_attachment_format".into(),
|
||||
|
@ -1027,7 +1027,7 @@ impl PhysicalDevice {
|
||||
..
|
||||
} = &mut image_format_info;
|
||||
|
||||
let aspects = format.unwrap().aspects();
|
||||
let aspects = format.aspects();
|
||||
|
||||
if stencil_usage.is_empty()
|
||||
|| !aspects.contains(ImageAspects::DEPTH | ImageAspects::STENCIL)
|
||||
@ -1055,7 +1055,7 @@ impl PhysicalDevice {
|
||||
let has_separate_stencil_usage = stencil_usage != usage;
|
||||
|
||||
let mut info2_vk = ash::vk::PhysicalDeviceImageFormatInfo2 {
|
||||
format: format.unwrap().into(),
|
||||
format: format.into(),
|
||||
ty: image_type.into(),
|
||||
tiling: tiling.into(),
|
||||
usage: usage.into(),
|
||||
@ -1330,7 +1330,7 @@ impl PhysicalDevice {
|
||||
} = format_info;
|
||||
|
||||
let format_info2 = ash::vk::PhysicalDeviceSparseImageFormatInfo2 {
|
||||
format: format.unwrap().into(),
|
||||
format: format.into(),
|
||||
ty: image_type.into(),
|
||||
samples: samples.into(),
|
||||
usage: usage.into(),
|
||||
|
@ -310,6 +310,7 @@ pub struct FormatCompatibility(pub(crate) &'static FormatCompatibilityInner);
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub(crate) enum FormatCompatibilityInner {
|
||||
Undefined,
|
||||
Class_8bit,
|
||||
Class_16bit,
|
||||
Class_24bit,
|
||||
|
@ -180,7 +180,7 @@ impl Image {
|
||||
}
|
||||
|
||||
fn from_raw(inner: RawImage, memory: ImageMemory, layout: ImageLayout) -> Self {
|
||||
let aspects = inner.format().unwrap().aspects();
|
||||
let aspects = inner.format().aspects();
|
||||
let aspect_list: SmallVec<[ImageAspect; 4]> = aspects.into_iter().collect();
|
||||
let mip_level_size = inner.array_layers() as DeviceSize;
|
||||
let aspect_size = mip_level_size * inner.mip_levels() as DeviceSize;
|
||||
@ -210,7 +210,7 @@ impl Image {
|
||||
let create_info = ImageCreateInfo {
|
||||
flags: ImageCreateFlags::empty(),
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(swapchain.image_format()),
|
||||
format: swapchain.image_format(),
|
||||
extent: [swapchain.image_extent()[0], swapchain.image_extent()[1], 1],
|
||||
array_layers: swapchain.image_array_layers(),
|
||||
mip_levels: 1,
|
||||
@ -249,7 +249,7 @@ impl Image {
|
||||
/// - If the image is a swapchain image, this returns a slice with a length of 0.
|
||||
/// - If `self.flags().disjoint` is not set, this returns a slice with a length of 1.
|
||||
/// - If `self.flags().disjoint` is set, this returns a slice with a length equal to
|
||||
/// `self.format().unwrap().planes().len()`.
|
||||
/// `self.format().planes().len()`.
|
||||
#[inline]
|
||||
pub fn memory_requirements(&self) -> &[MemoryRequirements] {
|
||||
self.inner.memory_requirements()
|
||||
@ -269,7 +269,7 @@ impl Image {
|
||||
|
||||
/// Returns the image's format.
|
||||
#[inline]
|
||||
pub fn format(&self) -> Option<Format> {
|
||||
pub fn format(&self) -> Format {
|
||||
self.inner.format()
|
||||
}
|
||||
|
||||
@ -410,11 +410,7 @@ impl Image {
|
||||
&self,
|
||||
subresource_range: ImageSubresourceRange,
|
||||
) -> SubresourceRangeIterator {
|
||||
assert!(self
|
||||
.format()
|
||||
.unwrap()
|
||||
.aspects()
|
||||
.contains(subresource_range.aspects));
|
||||
assert!(self.format().aspects().contains(subresource_range.aspects));
|
||||
assert!(subresource_range.mip_levels.end <= self.mip_levels());
|
||||
assert!(subresource_range.array_layers.end <= self.array_layers());
|
||||
|
||||
@ -1654,8 +1650,8 @@ pub struct ImageFormatInfo {
|
||||
|
||||
/// The `format` that the image will have.
|
||||
///
|
||||
/// The default value is `None`, which must be overridden.
|
||||
pub format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub format: Format,
|
||||
|
||||
/// The dimension type that the image will have.
|
||||
///
|
||||
@ -1724,7 +1720,7 @@ impl Default for ImageFormatInfo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
flags: ImageCreateFlags::empty(),
|
||||
format: None,
|
||||
format: Format::UNDEFINED,
|
||||
image_type: ImageType::Dim2d,
|
||||
tiling: ImageTiling::Optimal,
|
||||
usage: ImageUsage::empty(),
|
||||
@ -1763,14 +1759,6 @@ impl ImageFormatInfo {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
let format = format.ok_or(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `None`".into(),
|
||||
vuids: &["VUID-VkPhysicalDeviceImageFormatInfo2-format-parameter"],
|
||||
..Default::default()
|
||||
})?;
|
||||
let aspects = format.aspects();
|
||||
|
||||
format
|
||||
.validate_physical_device(physical_device)
|
||||
.map_err(|err| ValidationError {
|
||||
@ -1812,6 +1800,8 @@ impl ImageFormatInfo {
|
||||
}));
|
||||
}
|
||||
|
||||
let aspects = format.aspects();
|
||||
|
||||
let has_separate_stencil_usage = if aspects
|
||||
.contains(ImageAspects::DEPTH | ImageAspects::STENCIL)
|
||||
&& !stencil_usage.is_empty()
|
||||
@ -2109,8 +2099,8 @@ impl From<ash::vk::ImageFormatProperties> for ImageFormatProperties {
|
||||
pub struct SparseImageFormatInfo {
|
||||
/// The `format` that the image will have.
|
||||
///
|
||||
/// The default value is `None`, which must be overridden.
|
||||
pub format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub format: Format,
|
||||
|
||||
/// The dimension type that the image will have.
|
||||
///
|
||||
@ -2139,7 +2129,7 @@ impl Default for SparseImageFormatInfo {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
format: None,
|
||||
format: Format::UNDEFINED,
|
||||
image_type: ImageType::Dim2d,
|
||||
samples: SampleCount::Sample1,
|
||||
usage: ImageUsage::empty(),
|
||||
@ -2163,13 +2153,6 @@ impl SparseImageFormatInfo {
|
||||
_ne: _,
|
||||
} = self;
|
||||
|
||||
let format = format.ok_or(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `None`".into(),
|
||||
vuids: &["VUID-VkPhysicalDeviceImageFormatInfo2-format-parameter"],
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
format
|
||||
.validate_physical_device(physical_device)
|
||||
.map_err(|err| ValidationError {
|
||||
|
@ -402,11 +402,11 @@ impl Sampler {
|
||||
| ImageAspects::PLANE_1
|
||||
| ImageAspects::PLANE_2,
|
||||
) {
|
||||
image_view.format().unwrap().type_color().unwrap()
|
||||
image_view.format().type_color().unwrap()
|
||||
} else if aspects.intersects(ImageAspects::DEPTH) {
|
||||
image_view.format().unwrap().type_depth().unwrap()
|
||||
image_view.format().type_depth().unwrap()
|
||||
} else if aspects.intersects(ImageAspects::STENCIL) {
|
||||
image_view.format().unwrap().type_stencil().unwrap()
|
||||
image_view.format().type_stencil().unwrap()
|
||||
} else {
|
||||
// Per `ImageViewBuilder::aspects` and
|
||||
// VUID-VkDescriptorImageInfo-imageView-01976
|
||||
@ -1077,7 +1077,7 @@ impl SamplerCreateInfo {
|
||||
let potential_format_features = unsafe {
|
||||
device
|
||||
.physical_device()
|
||||
.format_properties_unchecked(sampler_ycbcr_conversion.format().unwrap())
|
||||
.format_properties_unchecked(sampler_ycbcr_conversion.format())
|
||||
.potential_format_features()
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
//! # let descriptor_set_allocator: vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator = return;
|
||||
//! #
|
||||
//! let conversion = SamplerYcbcrConversion::new(device.clone(), SamplerYcbcrConversionCreateInfo {
|
||||
//! format: Some(Format::G8_B8_R8_3PLANE_420_UNORM),
|
||||
//! format: Format::G8_B8_R8_3PLANE_420_UNORM,
|
||||
//! ycbcr_model: SamplerYcbcrModelConversion::YcbcrIdentity,
|
||||
//! ..Default::default()
|
||||
//! })
|
||||
@ -85,7 +85,7 @@
|
||||
//! &memory_allocator,
|
||||
//! ImageCreateInfo {
|
||||
//! image_type: ImageType::Dim2d,
|
||||
//! format: Some(Format::G8_B8_R8_3PLANE_420_UNORM),
|
||||
//! format: Format::G8_B8_R8_3PLANE_420_UNORM,
|
||||
//! extent: [1920, 1080, 1],
|
||||
//! usage: ImageUsage::SAMPLED,
|
||||
//! ..Default::default()
|
||||
@ -127,7 +127,7 @@ pub struct SamplerYcbcrConversion {
|
||||
device: InstanceOwnedDebugWrapper<Arc<Device>>,
|
||||
id: NonZeroU64,
|
||||
|
||||
format: Option<Format>,
|
||||
format: Format,
|
||||
ycbcr_model: SamplerYcbcrModelConversion,
|
||||
ycbcr_range: SamplerYcbcrRange,
|
||||
component_mapping: ComponentMapping,
|
||||
@ -189,7 +189,7 @@ impl SamplerYcbcrConversion {
|
||||
} = &create_info;
|
||||
|
||||
let create_info_vk = ash::vk::SamplerYcbcrConversionCreateInfo {
|
||||
format: format.unwrap().into(),
|
||||
format: format.into(),
|
||||
ycbcr_model: ycbcr_model.into(),
|
||||
ycbcr_range: ycbcr_range.into(),
|
||||
components: component_mapping.into(),
|
||||
@ -287,7 +287,7 @@ impl SamplerYcbcrConversion {
|
||||
|
||||
/// Returns the format that the conversion was created for.
|
||||
#[inline]
|
||||
pub fn format(&self) -> Option<Format> {
|
||||
pub fn format(&self) -> Format {
|
||||
self.format
|
||||
}
|
||||
|
||||
@ -384,8 +384,8 @@ pub struct SamplerYcbcrConversionCreateInfo {
|
||||
/// Compatibility notice: currently, this value must be `Some`, but future additions may allow
|
||||
/// `None` as a valid value as well.
|
||||
///
|
||||
/// The default value is `None`.
|
||||
pub format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub format: Format,
|
||||
|
||||
/// The conversion between the input color model and the output RGB color model.
|
||||
///
|
||||
@ -443,7 +443,7 @@ impl Default for SamplerYcbcrConversionCreateInfo {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
format: None,
|
||||
format: Format::UNDEFINED,
|
||||
ycbcr_model: SamplerYcbcrModelConversion::RgbIdentity,
|
||||
ycbcr_range: SamplerYcbcrRange::ItuFull,
|
||||
component_mapping: ComponentMapping::identity(),
|
||||
@ -468,12 +468,6 @@ impl SamplerYcbcrConversionCreateInfo {
|
||||
_ne: _,
|
||||
} = self;
|
||||
|
||||
let format = format.ok_or(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `None`".into(),
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
|
@ -61,7 +61,7 @@ pub struct RawImage {
|
||||
|
||||
flags: ImageCreateFlags,
|
||||
image_type: ImageType,
|
||||
format: Option<Format>,
|
||||
format: Format,
|
||||
format_features: FormatFeatures,
|
||||
extent: [u32; 3],
|
||||
array_layers: u32,
|
||||
@ -128,7 +128,7 @@ impl RawImage {
|
||||
ref drm_format_modifier_plane_layouts,
|
||||
} = &create_info;
|
||||
|
||||
let aspects = format.map_or_else(Default::default, |format| format.aspects());
|
||||
let aspects = format.aspects();
|
||||
|
||||
let has_separate_stencil_usage = if stencil_usage.is_empty()
|
||||
|| !aspects.contains(ImageAspects::DEPTH | ImageAspects::STENCIL)
|
||||
@ -151,7 +151,7 @@ impl RawImage {
|
||||
let mut info_vk = ash::vk::ImageCreateInfo {
|
||||
flags: flags.into(),
|
||||
image_type: image_type.into(),
|
||||
format: format.map(Into::into).unwrap_or_default(),
|
||||
format: format.into(),
|
||||
extent: ash::vk::Extent3D {
|
||||
width: extent[0],
|
||||
height: extent[1],
|
||||
@ -295,7 +295,6 @@ impl RawImage {
|
||||
drm_format_modifier_plane_layouts: _,
|
||||
} = create_info;
|
||||
|
||||
let format = format.unwrap();
|
||||
let format_properties =
|
||||
unsafe { device.physical_device().format_properties_unchecked(format) };
|
||||
|
||||
@ -355,7 +354,7 @@ impl RawImage {
|
||||
|
||||
flags,
|
||||
image_type,
|
||||
format: Some(format),
|
||||
format,
|
||||
format_features,
|
||||
extent,
|
||||
array_layers,
|
||||
@ -735,7 +734,7 @@ impl RawImage {
|
||||
if self.flags.intersects(ImageCreateFlags::DISJOINT) {
|
||||
match self.tiling {
|
||||
ImageTiling::Optimal | ImageTiling::Linear => {
|
||||
if allocations.len() != self.format.unwrap().planes().len() {
|
||||
if allocations.len() != self.format.planes().len() {
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "`self.flags()` contains `ImageCreateFlags::DISJOINT`, and \
|
||||
`self.tiling()` is `ImageTiling::Optimal` or \
|
||||
@ -1086,10 +1085,7 @@ impl RawImage {
|
||||
let plane_aspect = match self.tiling {
|
||||
// VUID-VkBindImagePlaneMemoryInfo-planeAspect-02283
|
||||
ImageTiling::Optimal | ImageTiling::Linear => {
|
||||
debug_assert_eq!(
|
||||
allocations.len(),
|
||||
self.format.unwrap().planes().len()
|
||||
);
|
||||
debug_assert_eq!(allocations.len(), self.format.planes().len());
|
||||
match plane {
|
||||
0 => ash::vk::ImageAspectFlags::PLANE_0,
|
||||
1 => ash::vk::ImageAspectFlags::PLANE_1,
|
||||
@ -1209,7 +1205,7 @@ impl RawImage {
|
||||
|
||||
/// Returns the image's format.
|
||||
#[inline]
|
||||
pub fn format(&self) -> Option<Format> {
|
||||
pub fn format(&self) -> Format {
|
||||
self.format
|
||||
}
|
||||
|
||||
@ -1294,7 +1290,7 @@ impl RawImage {
|
||||
pub fn subresource_layers(&self) -> ImageSubresourceLayers {
|
||||
ImageSubresourceLayers {
|
||||
aspects: {
|
||||
let aspects = self.format.unwrap().aspects();
|
||||
let aspects = self.format.aspects();
|
||||
|
||||
if aspects.intersects(ImageAspects::PLANE_0) {
|
||||
ImageAspects::PLANE_0
|
||||
@ -1312,7 +1308,7 @@ impl RawImage {
|
||||
#[inline]
|
||||
pub fn subresource_range(&self) -> ImageSubresourceRange {
|
||||
ImageSubresourceRange {
|
||||
aspects: self.format.unwrap().aspects()
|
||||
aspects: self.format.aspects()
|
||||
- (ImageAspects::PLANE_0 | ImageAspects::PLANE_1 | ImageAspects::PLANE_2),
|
||||
mip_levels: 0..self.mip_levels,
|
||||
array_layers: 0..self.array_layers,
|
||||
@ -1388,7 +1384,7 @@ impl RawImage {
|
||||
}));
|
||||
}
|
||||
|
||||
let format = self.format.unwrap();
|
||||
let format = self.format;
|
||||
let format_aspects = format.aspects();
|
||||
|
||||
if let Some((_, drm_format_modifier_plane_count)) = self.drm_format_modifier {
|
||||
@ -1638,8 +1634,8 @@ pub struct ImageCreateInfo {
|
||||
|
||||
/// The format used to store the image data.
|
||||
///
|
||||
/// The default value is `None`, which must be overridden.
|
||||
pub format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub format: Format,
|
||||
|
||||
/// The width, height and depth of the image.
|
||||
///
|
||||
@ -1750,7 +1746,7 @@ impl Default for ImageCreateInfo {
|
||||
Self {
|
||||
flags: ImageCreateFlags::empty(),
|
||||
image_type: ImageType::Dim2d,
|
||||
format: None,
|
||||
format: Format::UNDEFINED,
|
||||
extent: [0; 3],
|
||||
array_layers: 1,
|
||||
mip_levels: 1,
|
||||
@ -1800,13 +1796,6 @@ impl ImageCreateInfo {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
// Can be None for "external formats" but Vulkano doesn't support that yet
|
||||
let format = format.ok_or(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `None`".into(),
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
@ -1848,6 +1837,15 @@ impl ImageCreateInfo {
|
||||
}));
|
||||
}
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
vuids: &["VUID-VkImageCreateInfo-pNext-01975"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
let format_properties = unsafe { physical_device.format_properties_unchecked(format) };
|
||||
let image_create_drm_format_modifiers = &drm_format_modifiers;
|
||||
let image_create_maybe_linear = match tiling {
|
||||
@ -2697,7 +2695,7 @@ impl ImageCreateInfo {
|
||||
physical_device
|
||||
.image_format_properties_unchecked(ImageFormatInfo {
|
||||
flags,
|
||||
format: Some(format),
|
||||
format,
|
||||
image_type,
|
||||
tiling,
|
||||
usage,
|
||||
@ -2850,7 +2848,7 @@ mod tests {
|
||||
device,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [32, 32, 1],
|
||||
usage: ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
@ -2867,7 +2865,7 @@ mod tests {
|
||||
device,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [32, 32, 1],
|
||||
usage: ImageUsage::TRANSIENT_ATTACHMENT | ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -2885,7 +2883,7 @@ mod tests {
|
||||
device,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [32, 32, 1],
|
||||
mip_levels: 0,
|
||||
usage: ImageUsage::SAMPLED,
|
||||
@ -2904,7 +2902,7 @@ mod tests {
|
||||
device,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [32, 32, 1],
|
||||
mip_levels: u32::MAX,
|
||||
usage: ImageUsage::SAMPLED,
|
||||
@ -2926,7 +2924,7 @@ mod tests {
|
||||
device,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [32, 32, 1],
|
||||
samples: SampleCount::Sample2,
|
||||
usage: ImageUsage::STORAGE,
|
||||
@ -2958,7 +2956,7 @@ mod tests {
|
||||
device,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::ASTC_5x4_UNORM_BLOCK),
|
||||
format: Format::ASTC_5x4_UNORM_BLOCK,
|
||||
extent: [32, 32, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -2980,7 +2978,7 @@ mod tests {
|
||||
device,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [32, 32, 1],
|
||||
usage: ImageUsage::TRANSIENT_ATTACHMENT | ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
@ -2999,7 +2997,7 @@ mod tests {
|
||||
ImageCreateInfo {
|
||||
flags: ImageCreateFlags::CUBE_COMPATIBLE,
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [32, 64, 1],
|
||||
usage: ImageUsage::SAMPLED,
|
||||
..Default::default()
|
||||
|
@ -44,7 +44,7 @@ pub struct ImageView {
|
||||
id: NonZeroU64,
|
||||
|
||||
view_type: ImageViewType,
|
||||
format: Option<Format>,
|
||||
format: Format,
|
||||
component_mapping: ComponentMapping,
|
||||
subresource_range: ImageSubresourceRange,
|
||||
usage: ImageUsage,
|
||||
@ -87,7 +87,6 @@ impl ImageView {
|
||||
_ne: _,
|
||||
} = create_info;
|
||||
|
||||
let format = format.unwrap();
|
||||
let format_features = unsafe { get_format_features(format, image) };
|
||||
|
||||
if format_features.is_empty() {
|
||||
@ -381,8 +380,8 @@ impl ImageView {
|
||||
|
||||
/* Check flags requirements */
|
||||
|
||||
if Some(format) != image.format() {
|
||||
if !image.format().unwrap().planes().is_empty()
|
||||
if format != image.format() {
|
||||
if !image.format().planes().is_empty()
|
||||
&& subresource_range.aspects.intersects(ImageAspects::COLOR)
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
@ -409,7 +408,7 @@ impl ImageView {
|
||||
// See https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/2361
|
||||
if device.enabled_extensions().khr_portability_subset
|
||||
&& !device.enabled_features().image_view_format_reinterpretation
|
||||
&& format.components() != image.format().unwrap().components()
|
||||
&& format.components() != image.format().components()
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "this device is a portability subset device, and \
|
||||
@ -428,8 +427,8 @@ impl ImageView {
|
||||
.flags()
|
||||
.intersects(ImageCreateFlags::BLOCK_TEXEL_VIEW_COMPATIBLE)
|
||||
{
|
||||
if !(format.compatibility() == image.format().unwrap().compatibility()
|
||||
|| format.block_size() == image.format().unwrap().block_size())
|
||||
if !(format.compatibility() == image.format().compatibility()
|
||||
|| format.block_size() == image.format().block_size())
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "`image.flags()` contains \
|
||||
@ -470,8 +469,8 @@ impl ImageView {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if image.format().unwrap().planes().is_empty() {
|
||||
if format.compatibility() != image.format().unwrap().compatibility() {
|
||||
if image.format().planes().is_empty() {
|
||||
if format.compatibility() != image.format().compatibility() {
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "`image.flags()` does not contain \
|
||||
`ImageCreateFlags::BLOCK_TEXEL_VIEW_COMPATIBLE`, and \
|
||||
@ -494,7 +493,7 @@ impl ImageView {
|
||||
} else {
|
||||
unreachable!()
|
||||
};
|
||||
let plane_format = image.format().unwrap().planes()[plane];
|
||||
let plane_format = image.format().planes()[plane];
|
||||
|
||||
if format.compatibility() != plane_format.compatibility() {
|
||||
return Err(Box::new(ValidationError {
|
||||
@ -579,7 +578,7 @@ impl ImageView {
|
||||
flags: ash::vk::ImageViewCreateFlags::empty(),
|
||||
image: image.handle(),
|
||||
view_type: view_type.into(),
|
||||
format: format.unwrap().into(),
|
||||
format: format.into(),
|
||||
components: component_mapping.into(),
|
||||
subresource_range: subresource_range.clone().into(),
|
||||
..Default::default()
|
||||
@ -660,7 +659,7 @@ impl ImageView {
|
||||
usage = get_implicit_default_usage(subresource_range.aspects, &image);
|
||||
}
|
||||
|
||||
let format_features = get_format_features(format.unwrap(), &image);
|
||||
let format_features = get_format_features(format, &image);
|
||||
|
||||
let mut filter_cubic = false;
|
||||
let mut filter_cubic_minmax = false;
|
||||
@ -721,7 +720,7 @@ impl ImageView {
|
||||
|
||||
/// Returns the format of this view. This can be different from the parent's format.
|
||||
#[inline]
|
||||
pub fn format(&self) -> Option<Format> {
|
||||
pub fn format(&self) -> Format {
|
||||
self.format
|
||||
}
|
||||
|
||||
@ -823,8 +822,8 @@ pub struct ImageViewCreateInfo {
|
||||
/// [`image_view_format_reinterpretation`](crate::device::Features::image_view_format_reinterpretation)
|
||||
/// feature must be enabled on the device.
|
||||
///
|
||||
/// The default value is `None`, which must be overridden.
|
||||
pub format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub format: Format,
|
||||
|
||||
/// How to map components of each pixel.
|
||||
///
|
||||
@ -877,7 +876,7 @@ impl Default for ImageViewCreateInfo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
view_type: ImageViewType::Dim2d,
|
||||
format: None,
|
||||
format: Format::UNDEFINED,
|
||||
component_mapping: ComponentMapping::identity(),
|
||||
subresource_range: ImageSubresourceRange {
|
||||
aspects: ImageAspects::empty(),
|
||||
@ -940,12 +939,6 @@ impl ImageViewCreateInfo {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
let format = format.ok_or(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `None`".into(),
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
|
@ -883,7 +883,7 @@ impl Display for SuballocatorError {
|
||||
/// &memory_allocator,
|
||||
/// ImageCreateInfo {
|
||||
/// image_type: ImageType::Dim2d,
|
||||
/// format: Some(Format::R8G8B8A8_UNORM),
|
||||
/// format: Format::R8G8B8A8_UNORM,
|
||||
/// extent: [1024, 1024, 1],
|
||||
/// usage: ImageUsage::SAMPLED,
|
||||
/// ..Default::default()
|
||||
|
@ -924,7 +924,7 @@ impl GraphicsPipeline {
|
||||
}
|
||||
};
|
||||
|
||||
let mut color_blend_state_vk =
|
||||
let color_blend_state_vk =
|
||||
color_blend_state_vk.insert(ash::vk::PipelineColorBlendStateCreateInfo {
|
||||
flags: flags.into(),
|
||||
logic_op_enable,
|
||||
@ -2888,7 +2888,6 @@ impl GraphicsPipelineCreateInfo {
|
||||
subpass.render_pass().attachments()
|
||||
[depth_stencil_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap()
|
||||
.aspects()
|
||||
.intersects(ImageAspects::DEPTH)
|
||||
}),
|
||||
@ -2923,7 +2922,6 @@ impl GraphicsPipelineCreateInfo {
|
||||
subpass.render_pass().attachments()
|
||||
[depth_stencil_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap()
|
||||
.aspects()
|
||||
.intersects(ImageAspects::DEPTH)
|
||||
})
|
||||
@ -2955,7 +2953,6 @@ impl GraphicsPipelineCreateInfo {
|
||||
subpass.render_pass().attachments()
|
||||
[depth_stencil_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap()
|
||||
.aspects()
|
||||
.intersects(ImageAspects::STENCIL)
|
||||
}),
|
||||
@ -3006,7 +3003,7 @@ impl GraphicsPipelineCreateInfo {
|
||||
PipelineSubpassType::BeginRenderPass(subpass) => {
|
||||
subpass.subpass_desc().color_attachments[attachment_index]
|
||||
.as_ref()
|
||||
.and_then(|color_attachment| {
|
||||
.map(|color_attachment| {
|
||||
subpass.render_pass().attachments()
|
||||
[color_attachment.attachment as usize]
|
||||
.format
|
||||
|
@ -97,24 +97,18 @@ impl PipelineRenderingCreateInfo {
|
||||
color_attachment_formats: (subpass_desc.color_attachments.iter())
|
||||
.map(|color_attachment| {
|
||||
color_attachment.as_ref().map(|color_attachment| {
|
||||
rp_attachments[color_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap()
|
||||
rp_attachments[color_attachment.attachment as usize].format
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
depth_attachment_format: (subpass_desc.depth_stencil_attachment.as_ref())
|
||||
.map(|depth_stencil_attachment| {
|
||||
rp_attachments[depth_stencil_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap()
|
||||
rp_attachments[depth_stencil_attachment.attachment as usize].format
|
||||
})
|
||||
.filter(|format| format.aspects().intersects(ImageAspects::DEPTH)),
|
||||
stencil_attachment_format: (subpass_desc.depth_stencil_attachment.as_ref())
|
||||
.map(|depth_stencil_attachment| {
|
||||
rp_attachments[depth_stencil_attachment.attachment as usize]
|
||||
.format
|
||||
.unwrap()
|
||||
rp_attachments[depth_stencil_attachment.attachment as usize].format
|
||||
})
|
||||
.filter(|format| format.aspects().intersects(ImageAspects::STENCIL)),
|
||||
_ne: crate::NonExhaustive(()),
|
||||
@ -128,13 +122,13 @@ impl PipelineRenderingCreateInfo {
|
||||
.map(|atch_info| {
|
||||
atch_info
|
||||
.as_ref()
|
||||
.map(|atch_info| atch_info.image_view.format().unwrap())
|
||||
.map(|atch_info| atch_info.image_view.format())
|
||||
})
|
||||
.collect(),
|
||||
depth_attachment_format: (info.depth_attachment.as_ref())
|
||||
.map(|atch_info| atch_info.image_view.format().unwrap()),
|
||||
.map(|atch_info| atch_info.image_view.format()),
|
||||
stencil_attachment_format: (info.stencil_attachment.as_ref())
|
||||
.map(|atch_info| atch_info.image_view.format().unwrap()),
|
||||
.map(|atch_info| atch_info.image_view.format()),
|
||||
_ne: crate::NonExhaustive(()),
|
||||
}
|
||||
}
|
||||
@ -194,11 +188,19 @@ impl PipelineRenderingCreateInfo {
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
context: "format".into(),
|
||||
context: format!("color_attachment_formats[{}]", attachment_index).into(),
|
||||
vuids: &["VUID-VkGraphicsPipelineCreateInfo-renderPass-06580"],
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: format!("color_attachment_formats[{}]", attachment_index).into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
if !unsafe { device.physical_device().format_properties_unchecked(format) }
|
||||
.potential_format_features()
|
||||
.intersects(FormatFeatures::COLOR_ATTACHMENT)
|
||||
@ -218,11 +220,19 @@ impl PipelineRenderingCreateInfo {
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
context: "format".into(),
|
||||
context: "depth_attachment_format".into(),
|
||||
vuids: &["VUID-VkGraphicsPipelineCreateInfo-renderPass-06583"],
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "depth_attachment_format".into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
if !unsafe { device.physical_device().format_properties_unchecked(format) }
|
||||
.potential_format_features()
|
||||
.intersects(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
|
||||
@ -251,17 +261,25 @@ impl PipelineRenderingCreateInfo {
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
context: "format".into(),
|
||||
context: "stencil_attachment_format".into(),
|
||||
vuids: &["VUID-VkGraphicsPipelineCreateInfo-renderPass-06584"],
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "stencil_attachment_format".into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
if !unsafe { device.physical_device().format_properties_unchecked(format) }
|
||||
.potential_format_features()
|
||||
.intersects(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "render_pass.stencil_attachment_format".into(),
|
||||
context: "stencil_attachment_format".into(),
|
||||
problem: "format features do not contain \
|
||||
`FormatFeature::DEPTH_STENCIL_ATTACHMENT`"
|
||||
.into(),
|
||||
@ -272,7 +290,7 @@ impl PipelineRenderingCreateInfo {
|
||||
|
||||
if !format.aspects().intersects(ImageAspects::STENCIL) {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "render_pass.stencil_attachment_format".into(),
|
||||
context: "stencil_attachment_format".into(),
|
||||
problem: "does not have a stencil aspect".into(),
|
||||
vuids: &["VUID-VkGraphicsPipelineCreateInfo-renderPass-06588"],
|
||||
..Default::default()
|
||||
|
@ -84,7 +84,7 @@ unsafe impl VertexDefinition for &[VertexBufferDescription] {
|
||||
}
|
||||
|
||||
let mut offset = infos.offset as DeviceSize;
|
||||
let block_size = infos.format.block_size().unwrap();
|
||||
let block_size = infos.format.block_size();
|
||||
// Double precision formats can exceed a single location.
|
||||
// R64B64G64A64_SFLOAT requires two locations, so we need to adapt how we bind
|
||||
let location_range = if block_size > 16 {
|
||||
|
@ -57,7 +57,7 @@ macro_rules! impl_vertex {
|
||||
}
|
||||
size_of_raw(p)
|
||||
} as u32;
|
||||
let format_size = format.block_size().expect("no block size for format") as u32;
|
||||
let format_size = format.block_size() as u32;
|
||||
let num_elements = field_size / format_size;
|
||||
let remainder = field_size % format_size;
|
||||
assert!(remainder == 0, "struct field `{}` size does not fit multiple of format size", stringify!($member));
|
||||
|
@ -257,8 +257,7 @@ impl VertexInputState {
|
||||
&& !device
|
||||
.enabled_features()
|
||||
.vertex_attribute_access_beyond_stride
|
||||
&& offset as DeviceSize + format.block_size().unwrap()
|
||||
> binding_desc.stride as DeviceSize
|
||||
&& offset as DeviceSize + format.block_size() > binding_desc.stride as DeviceSize
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: format!(
|
||||
@ -281,7 +280,7 @@ impl VertexInputState {
|
||||
// the location following it needs to be empty.
|
||||
let unassigned_locations = attributes
|
||||
.iter()
|
||||
.filter(|&(_, attribute_desc)| attribute_desc.format.block_size().unwrap() > 16)
|
||||
.filter(|&(_, attribute_desc)| attribute_desc.format.block_size() > 16)
|
||||
.map(|(location, _)| location + 1);
|
||||
|
||||
for location in unassigned_locations {
|
||||
|
@ -56,7 +56,7 @@ impl RenderPass {
|
||||
(
|
||||
ash::vk::AttachmentDescription2 {
|
||||
flags: flags.into(),
|
||||
format: format.map_or(ash::vk::Format::UNDEFINED, |f| f.into()),
|
||||
format: format.into(),
|
||||
samples: samples.into(),
|
||||
load_op: load_op.into(),
|
||||
store_op: store_op.into(),
|
||||
@ -561,7 +561,7 @@ impl RenderPass {
|
||||
|
||||
ash::vk::AttachmentDescription {
|
||||
flags: flags.into(),
|
||||
format: format.map_or(ash::vk::Format::UNDEFINED, |f| f.into()),
|
||||
format: format.into(),
|
||||
samples: samples.into(),
|
||||
load_op: load_op.into(),
|
||||
store_op: store_op.into(),
|
||||
|
@ -558,7 +558,7 @@ impl FramebufferCreateInfo {
|
||||
match image_view.view_type() {
|
||||
ImageViewType::Dim2d | ImageViewType::Dim2dArray => {
|
||||
if image_view.image().image_type() == ImageType::Dim3d
|
||||
&& (image_view.format().unwrap().aspects())
|
||||
&& (image_view.format().aspects())
|
||||
.intersects(ImageAspects::DEPTH | ImageAspects::STENCIL)
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
@ -696,7 +696,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [1024, 768, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -777,7 +777,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8_UNORM),
|
||||
format: Format::R8_UNORM,
|
||||
extent: [1024, 768, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -827,7 +827,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [600, 600, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -877,7 +877,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [512, 700, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -933,7 +933,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [256, 512, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -948,7 +948,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [512, 128, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -1007,7 +1007,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [256, 512, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -1055,7 +1055,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [256, 512, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
@ -1070,7 +1070,7 @@ mod tests {
|
||||
&memory_allocator,
|
||||
ImageCreateInfo {
|
||||
image_type: ImageType::Dim2d,
|
||||
format: Some(Format::R8G8B8A8_UNORM),
|
||||
format: Format::R8G8B8A8_UNORM,
|
||||
extent: [256, 512, 1],
|
||||
usage: ImageUsage::COLOR_ATTACHMENT,
|
||||
..Default::default()
|
||||
|
@ -225,7 +225,7 @@ macro_rules! ordered_passes_renderpass {
|
||||
$(layouts.final_layout = Some($final_layout);)*
|
||||
|
||||
$crate::render_pass::AttachmentDescription {
|
||||
format: Some($format),
|
||||
format: $format,
|
||||
samples: $crate::image::SampleCount::try_from($samples).unwrap(),
|
||||
load_op: $crate::render_pass::AttachmentLoadOp::$load_op,
|
||||
store_op: $crate::render_pass::AttachmentStoreOp::$store_op,
|
||||
|
@ -142,7 +142,7 @@ impl RenderPass {
|
||||
.attachments
|
||||
.get(input_attachment.attachment as usize)
|
||||
{
|
||||
input_attachment.aspects = attachment_desc.format.unwrap().aspects();
|
||||
input_attachment.aspects = attachment_desc.format.aspects();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ impl RenderPass {
|
||||
.attachments
|
||||
.get(input_attachment.attachment as usize)
|
||||
{
|
||||
input_attachment.aspects = attachment_desc.format.unwrap().aspects();
|
||||
input_attachment.aspects = attachment_desc.format.aspects();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -870,7 +870,7 @@ impl RenderPassCreateInfo {
|
||||
attachment_potential_format_features[attachment_index] = unsafe {
|
||||
device
|
||||
.physical_device()
|
||||
.format_properties_unchecked(format.unwrap())
|
||||
.format_properties_unchecked(format)
|
||||
.potential_format_features()
|
||||
};
|
||||
}
|
||||
@ -1149,7 +1149,7 @@ impl RenderPassCreateInfo {
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
let format = attachment_desc.format.unwrap();
|
||||
let format = attachment_desc.format;
|
||||
|
||||
if !attachment_potential_format_features[attachment as usize]
|
||||
.intersects(FormatFeatures::DEPTH_STENCIL_ATTACHMENT)
|
||||
@ -1258,7 +1258,7 @@ impl RenderPassCreateInfo {
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
let resolve_format = resolve_attachment_desc.format.unwrap();
|
||||
let resolve_format = resolve_attachment_desc.format;
|
||||
|
||||
if !(resolve_format.components()[0] == format.components()[0]
|
||||
&& resolve_format.type_depth() == format.type_depth())
|
||||
@ -1404,7 +1404,7 @@ impl RenderPassCreateInfo {
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
let format_aspects = attachment_desc.format.unwrap().aspects();
|
||||
let format_aspects = attachment_desc.format.aspects();
|
||||
let is_first_use = !replace(&mut attachment_is_used[attachment as usize], true);
|
||||
|
||||
if is_first_use && attachment_desc.load_op == AttachmentLoadOp::Clear {
|
||||
@ -1652,8 +1652,8 @@ pub struct AttachmentDescription {
|
||||
|
||||
/// The format of the image that is going to be bound.
|
||||
///
|
||||
/// The default value is `None`, which must be overridden.
|
||||
pub format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub format: Format,
|
||||
|
||||
/// The number of samples of the image that is going to be bound.
|
||||
///
|
||||
@ -1724,7 +1724,7 @@ impl Default for AttachmentDescription {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
flags: AttachmentDescriptionFlags::empty(),
|
||||
format: None,
|
||||
format: Format::UNDEFINED,
|
||||
samples: SampleCount::Sample1,
|
||||
load_op: AttachmentLoadOp::DontCare,
|
||||
store_op: AttachmentStoreOp::DontCare,
|
||||
@ -1764,13 +1764,6 @@ impl AttachmentDescription {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
let format = format.ok_or_else(|| ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is None".into(),
|
||||
vuids: &["VUID-VkAttachmentDescription2-format-06698"],
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
@ -1996,6 +1989,15 @@ impl AttachmentDescription {
|
||||
}
|
||||
}
|
||||
|
||||
if format == Format::UNDEFINED {
|
||||
return Err(Box::new(ValidationError {
|
||||
context: "format".into(),
|
||||
problem: "is `Format::UNDEFINED`".into(),
|
||||
vuids: &["VUID-VkAttachmentDescription2-format-06698"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
let format_aspects = format.aspects();
|
||||
|
||||
if format_aspects.intersects(ImageAspects::COLOR) {
|
||||
|
@ -200,7 +200,7 @@
|
||||
//! // How many images to use in the swapchain.
|
||||
//! min_image_count,
|
||||
//! // The format of the images.
|
||||
//! image_format: Some(image_format),
|
||||
//! image_format,
|
||||
//! // The size of each image.
|
||||
//! image_extent,
|
||||
//! // The created swapchain images will be used as a color attachment for rendering.
|
||||
@ -649,19 +649,17 @@ impl Swapchain {
|
||||
}));
|
||||
}
|
||||
|
||||
if let Some(image_format) = image_format {
|
||||
if !surface_formats
|
||||
.iter()
|
||||
.any(|&fc| fc == (image_format, image_color_space))
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "the combination of `create_info.image_format` and \
|
||||
`create_info.image_color_space` is not supported for `surface`"
|
||||
.into(),
|
||||
vuids: &["VUID-VkSwapchainCreateInfoKHR-imageFormat-01273"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
if !surface_formats
|
||||
.iter()
|
||||
.any(|&fc| fc == (image_format, image_color_space))
|
||||
{
|
||||
return Err(Box::new(ValidationError {
|
||||
problem: "the combination of `create_info.image_format` and \
|
||||
`create_info.image_color_space` is not supported for `surface`"
|
||||
.into(),
|
||||
vuids: &["VUID-VkSwapchainCreateInfoKHR-imageFormat-01273"],
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
|
||||
if image_array_layers > surface_capabilities.max_image_array_layers {
|
||||
@ -1017,7 +1015,7 @@ impl Swapchain {
|
||||
flags: flags.into(),
|
||||
surface: surface.handle(),
|
||||
min_image_count,
|
||||
image_format: image_format.unwrap().into(),
|
||||
image_format: image_format.into(),
|
||||
image_color_space: image_color_space.into(),
|
||||
image_extent: ash::vk::Extent2D {
|
||||
width: image_extent[0],
|
||||
@ -1184,7 +1182,7 @@ impl Swapchain {
|
||||
|
||||
flags,
|
||||
min_image_count,
|
||||
image_format: image_format.unwrap(),
|
||||
image_format,
|
||||
image_color_space,
|
||||
image_extent,
|
||||
image_array_layers,
|
||||
@ -1234,7 +1232,7 @@ impl Swapchain {
|
||||
SwapchainCreateInfo {
|
||||
flags: self.flags,
|
||||
min_image_count: self.min_image_count,
|
||||
image_format: Some(self.image_format),
|
||||
image_format: self.image_format,
|
||||
image_color_space: self.image_color_space,
|
||||
image_extent: self.image_extent,
|
||||
image_array_layers: self.image_array_layers,
|
||||
@ -1523,8 +1521,8 @@ pub struct SwapchainCreateInfo {
|
||||
|
||||
/// The format of the created images.
|
||||
///
|
||||
/// The default value is `None`, which must be overridden.
|
||||
pub image_format: Option<Format>,
|
||||
/// The default value is `Format::UNDEFINED`.
|
||||
pub image_format: Format,
|
||||
|
||||
/// The color space of the created images.
|
||||
///
|
||||
@ -1641,7 +1639,7 @@ impl Default for SwapchainCreateInfo {
|
||||
Self {
|
||||
flags: SwapchainCreateFlags::empty(),
|
||||
min_image_count: 2,
|
||||
image_format: None,
|
||||
image_format: Format::UNDEFINED,
|
||||
image_color_space: ColorSpace::SrgbNonLinear,
|
||||
image_extent: [0, 0],
|
||||
image_array_layers: 1,
|
||||
@ -1692,13 +1690,6 @@ impl SwapchainCreateInfo {
|
||||
..ValidationError::from_requirement(err)
|
||||
})?;
|
||||
|
||||
let image_format = image_format.ok_or(ValidationError {
|
||||
context: "image_format".into(),
|
||||
problem: "is `None`".into(),
|
||||
vuids: &["VUID-VkSwapchainCreateInfoKHR-imageFormat-parameter"],
|
||||
..Default::default()
|
||||
})?;
|
||||
|
||||
image_format
|
||||
.validate_device(device)
|
||||
.map_err(|err| ValidationError {
|
||||
@ -1824,7 +1815,7 @@ impl SwapchainCreateInfo {
|
||||
device
|
||||
.physical_device()
|
||||
.image_format_properties_unchecked(ImageFormatInfo {
|
||||
format: Some(image_format),
|
||||
format: image_format,
|
||||
image_type: ImageType::Dim2d,
|
||||
tiling: ImageTiling::Optimal,
|
||||
usage: image_usage,
|
||||
|
Loading…
Reference in New Issue
Block a user