diff --git a/vulkano/Cargo.toml b/vulkano/Cargo.toml index f7a77ff7..64161c02 100644 --- a/vulkano/Cargo.toml +++ b/vulkano/Cargo.toml @@ -16,4 +16,5 @@ vulkano-shaders = { path = "../vulkano-shaders" } [dev-dependencies] cgmath = "0.7.0" +image = "0.6.1" winit = { git = "https://github.com/tomaka/winit" } diff --git a/vulkano/examples/image.rs b/vulkano/examples/image.rs index b0bb9f3a..65994897 100644 --- a/vulkano/examples/image.rs +++ b/vulkano/examples/image.rs @@ -1,4 +1,5 @@ extern crate cgmath; +extern crate image; extern crate winit; #[cfg(windows)] @@ -97,12 +98,37 @@ fn main() { let texture = vulkano::image::Image::::new(&device, &vulkano::image::Usage::all(), vulkano::memory::DeviceLocal, &queue, - vulkano::formats::R8G8B8A8Unorm, images[0].dimensions(), (), 1).unwrap(); + vulkano::formats::R8G8B8A8Unorm, [93, 93], (), 1).unwrap(); let texture = texture.transition(vulkano::image::Layout::ShaderReadOnlyOptimal, &cb_pool, &mut queue.lock().unwrap()).unwrap(); let texture_view = vulkano::image::ImageView::new(&texture).expect("failed to create image view"); + + let pixel_buffer = { + let image = image::load_from_memory_with_format(include_bytes!("image_img.png"), + image::ImageFormat::PNG).unwrap().to_rgba(); + let image_data = image.into_raw().clone(); + + let pixel_buffer = vulkano::buffer::Buffer::<[[u8; 4]], _> + ::array(&device, image_data.len(), &vulkano::buffer::Usage::all(), + vulkano::memory::HostVisible, &queue) + .expect("failed to create buffer"); + + { + let mut mapping = pixel_buffer.try_write().unwrap(); + for (o, i) in mapping.iter_mut().zip(image_data.chunks(4)) { + o[0] = i[0]; + o[1] = i[1]; + o[2] = i[2]; + o[3] = i[3]; + } + } + + pixel_buffer + }; + + let sampler = vulkano::sampler::Sampler::new(&device, vulkano::sampler::Filter::Linear, - vulkano::sampler::Filter::Linear, vulkano::sampler::MipmapMode::Linear, + vulkano::sampler::Filter::Linear, vulkano::sampler::MipmapMode::Nearest, vulkano::sampler::SamplerAddressMode::Repeat, vulkano::sampler::SamplerAddressMode::Repeat, vulkano::sampler::SamplerAddressMode::Repeat, @@ -175,7 +201,8 @@ fn main() { let command_buffers = framebuffers.iter().map(|framebuffer| { vulkano::command_buffer::PrimaryCommandBufferBuilder::new(&cb_pool).unwrap() - .clear_color_image(&texture, [0.0, 1.0, 0.0, 1.0]) + .copy_buffer_to_color_image(&pixel_buffer, &texture) + //.clear_color_image(&texture, [0.0, 1.0, 0.0, 1.0]) .draw_inline(&renderpass, &framebuffer, ([0.0, 0.0, 1.0, 1.0],)) .draw(&pipeline, vertex_buffer.clone(), &vulkano::command_buffer::DynamicState::none(), set.clone()) .draw_end() diff --git a/vulkano/examples/image_vs.glsl b/vulkano/examples/image_vs.glsl index 592aab26..fd4d8cc7 100644 --- a/vulkano/examples/image_vs.glsl +++ b/vulkano/examples/image_vs.glsl @@ -8,5 +8,5 @@ out vec2 tex_coords; void main() { gl_Position = vec4(position, 0.0, 1.0); - tex_coords = (position + vec2(0.5)) * 2.0; + tex_coords = position + vec2(0.5); } diff --git a/vulkano/src/command_buffer/inner.rs b/vulkano/src/command_buffer/inner.rs index 293f7977..db01ac3f 100644 --- a/vulkano/src/command_buffer/inner.rs +++ b/vulkano/src/command_buffer/inner.rs @@ -11,7 +11,9 @@ use descriptor_set::PipelineLayoutDesc; use descriptor_set::DescriptorSetsCollection; use device::Queue; use formats::ClearValue; +use formats::FloatOrCompressedFormatMarker; use formats::FloatFormatMarker; +use formats::StrongStorage; use framebuffer::Framebuffer; use framebuffer::RenderPass; use framebuffer::RenderPassLayout; @@ -296,31 +298,45 @@ impl InnerCommandBufferBuilder { self } - /*pub unsafe fn copy_buffer_to_image<'a, S, Sm>(mut self, source: S, ) - where S: Into + pub unsafe fn copy_buffer_to_color_image(self, source: S, image: &Arc>) + -> InnerCommandBufferBuilder + where S: Into>, F: StrongStorage + FloatOrCompressedFormatMarker, + Ty: ImageTypeMarker { + let source = source.into(); + //self.add_buffer_resource(source) // FIXME: + + let region = vk::BufferImageCopy { + bufferOffset: source.offset() as vk::DeviceSize, + bufferRowLength: 0, + bufferImageHeight: 0, + imageSubresource: vk::ImageSubresourceLayers { + aspectMask: vk::IMAGE_ASPECT_COLOR_BIT, + mipLevel: 0, // FIXME: + baseArrayLayer: 0, // FIXME: + layerCount: 1, // FIXME: + }, + imageOffset: vk::Offset3D { + x: 0, // FIXME: + y: 0, // FIXME: + z: 0, // FIXME: + }, + imageExtent: vk::Extent3D { + width: 93, // FIXME: + height: 93, // FIXME: + depth: 1, // FIXME: + }, + }; + { let vk = self.device.pointers(); - - let source = source.into(); - self.buffer_resources.push(source.buffer().clone()); - - let region = vk::BufferImageCopy { - bufferOffset: source.offset() as vk::DeviceSize, - bufferRowLength: , - bufferImageHeight: , - imageSubresource: , - imageOffset: , - imageExtent: , - }; - - vk.CmdCopyBufferToImage(self.cmd.unwrap(), source.internal_object(), , + vk.CmdCopyBufferToImage(self.cmd.unwrap(), source.buffer().internal_object(), image.internal_object(), vk::IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL /* FIXME */, 1, ®ion); } self - }*/ + } /// Calls `vkCmdDraw`. // FIXME: push constants diff --git a/vulkano/src/command_buffer/outer.rs b/vulkano/src/command_buffer/outer.rs index 3a9fd504..ff36e10f 100644 --- a/vulkano/src/command_buffer/outer.rs +++ b/vulkano/src/command_buffer/outer.rs @@ -8,7 +8,9 @@ use command_buffer::inner::InnerCommandBuffer; use descriptor_set::PipelineLayoutDesc; use descriptor_set::DescriptorSetsCollection; use device::Queue; +use formats::FloatOrCompressedFormatMarker; use formats::FloatFormatMarker; +use formats::StrongStorage; use framebuffer::Framebuffer; use framebuffer::RenderPass; use framebuffer::RenderPassLayout; @@ -110,6 +112,18 @@ impl PrimaryCommandBufferBuilder { } } + pub fn copy_buffer_to_color_image(self, source: S, destination: &Arc>) + -> PrimaryCommandBufferBuilder + where S: Into>, F: StrongStorage + FloatOrCompressedFormatMarker, + Ty: ImageTypeMarker + { + unsafe { + PrimaryCommandBufferBuilder { + inner: self.inner.copy_buffer_to_color_image(source, destination), + } + } + } + /// /// Note that compressed formats are not supported. pub fn clear_color_image<'a, Ty, F, M>(self, image: &Arc>, diff --git a/vulkano/src/formats.rs b/vulkano/src/formats.rs index b40ee472..6cdc49c8 100644 --- a/vulkano/src/formats.rs +++ b/vulkano/src/formats.rs @@ -115,7 +115,7 @@ unsafe impl Data for u8 { } macro_rules! formats { - ($($name:ident => $vk:ident [$($f_ty:tt)*],)+) => ( + ($($name:ident => $vk:ident [$($f_ty:tt)*] {$($d_ty:tt)*},)+) => ( /// An enumeration of all the possible formats. #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[repr(u32)] @@ -161,6 +161,7 @@ macro_rules! formats { pub struct $name; formats!(__inner_impl__ $name $($f_ty)*); + formats!(__inner_strongstorage__ $name $($d_ty)*); )+ ); @@ -263,194 +264,202 @@ macro_rules! formats { (__inner_ty__ $name:ident stencil) => { FormatTy::Stencil }; (__inner_ty__ $name:ident depthstencil) => { FormatTy::DepthStencil }; (__inner_ty__ $name:ident compressed) => { FormatTy::Compressed }; + + + (__inner_strongstorage__ $name:ident $ty:ty) => { + unsafe impl StrongStorage for $name { + type Pixel = $ty; + } + }; + (__inner_strongstorage__ $name:ident ) => {}; } formats! { //Undefined => FORMAT_UNDEFINED [float], // FIXME: what to do with this one? - R4G4UnormPack8 => FORMAT_R4G4_UNORM_PACK8 [float=2], - R4G4B4A4UnormPack16 => FORMAT_R4G4B4A4_UNORM_PACK16 [float=4], - B4G4R4A4UnormPack16 => FORMAT_B4G4R4A4_UNORM_PACK16 [float=4], - R5G6B5UnormPack16 => FORMAT_R5G6B5_UNORM_PACK16 [float=3], - B5G6R5UnormPack16 => FORMAT_B5G6R5_UNORM_PACK16 [float=3], - R5G5B5A1UnormPack16 => FORMAT_R5G5B5A1_UNORM_PACK16 [float=4], - B5G5R5A1UnormPack16 => FORMAT_B5G5R5A1_UNORM_PACK16 [float=4], - A1R5G5B5UnormPack16 => FORMAT_A1R5G5B5_UNORM_PACK16 [float=4], - R8Unorm => FORMAT_R8_UNORM [float=1], - R8Snorm => FORMAT_R8_SNORM [float=1], - R8Uscaled => FORMAT_R8_USCALED [float=1], - R8Sscaled => FORMAT_R8_SSCALED [float=1], - R8Uint => FORMAT_R8_UINT [uint=1], - R8Sint => FORMAT_R8_SINT [sint=1], - R8Srgb => FORMAT_R8_SRGB [float=1], - R8G8Unorm => FORMAT_R8G8_UNORM [float=2], - R8G8Snorm => FORMAT_R8G8_SNORM [float=2], - R8G8Uscaled => FORMAT_R8G8_USCALED [float=2], - R8G8Sscaled => FORMAT_R8G8_SSCALED [float=2], - R8G8Uint => FORMAT_R8G8_UINT [uint=2], - R8G8Sint => FORMAT_R8G8_SINT [sint=2], - R8G8Srgb => FORMAT_R8G8_SRGB [float=2], - R8G8B8Unorm => FORMAT_R8G8B8_UNORM [float=3], - R8G8B8Snorm => FORMAT_R8G8B8_SNORM [float=3], - R8G8B8Uscaled => FORMAT_R8G8B8_USCALED [float=3], - R8G8B8Sscaled => FORMAT_R8G8B8_SSCALED [float=3], - R8G8B8Uint => FORMAT_R8G8B8_UINT [uint=3], - R8G8B8Sint => FORMAT_R8G8B8_SINT [sint=3], - R8G8B8Srgb => FORMAT_R8G8B8_SRGB [float=3], - B8G8R8Unorm => FORMAT_B8G8R8_UNORM [float=3], - B8G8R8Snorm => FORMAT_B8G8R8_SNORM [float=3], - B8G8R8Uscaled => FORMAT_B8G8R8_USCALED [float=3], - B8G8R8Sscaled => FORMAT_B8G8R8_SSCALED [float=3], - B8G8R8Uint => FORMAT_B8G8R8_UINT [uint=3], - B8G8R8Sint => FORMAT_B8G8R8_SINT [sint=3], - B8G8R8Srgb => FORMAT_B8G8R8_SRGB [float=3], - R8G8B8A8Unorm => FORMAT_R8G8B8A8_UNORM [float=4], - R8G8B8A8Snorm => FORMAT_R8G8B8A8_SNORM [float=4], - R8G8B8A8Uscaled => FORMAT_R8G8B8A8_USCALED [float=4], - R8G8B8A8Sscaled => FORMAT_R8G8B8A8_SSCALED [float=4], - R8G8B8A8Uint => FORMAT_R8G8B8A8_UINT [uint=4], - R8G8B8A8Sint => FORMAT_R8G8B8A8_SINT [sint=4], - R8G8B8A8Srgb => FORMAT_R8G8B8A8_SRGB [float=4], - B8G8R8A8Unorm => FORMAT_B8G8R8A8_UNORM [float=4], - B8G8R8A8Snorm => FORMAT_B8G8R8A8_SNORM [float=4], - B8G8R8A8Uscaled => FORMAT_B8G8R8A8_USCALED [float=4], - B8G8R8A8Sscaled => FORMAT_B8G8R8A8_SSCALED [float=4], - B8G8R8A8Uint => FORMAT_B8G8R8A8_UINT [uint=4], - B8G8R8A8Sint => FORMAT_B8G8R8A8_SINT [sint=4], - B8G8R8A8Srgb => FORMAT_B8G8R8A8_SRGB [float=4], - A8B8G8R8UnormPack32 => FORMAT_A8B8G8R8_UNORM_PACK32 [float=4], - A8B8G8R8SnormPack32 => FORMAT_A8B8G8R8_SNORM_PACK32 [float=4], - A8B8G8R8UscaledPack32 => FORMAT_A8B8G8R8_USCALED_PACK32 [float=4], - A8B8G8R8SscaledPack32 => FORMAT_A8B8G8R8_SSCALED_PACK32 [float=4], - A8B8G8R8UintPack32 => FORMAT_A8B8G8R8_UINT_PACK32 [uint=4], - A8B8G8R8SintPack32 => FORMAT_A8B8G8R8_SINT_PACK32 [sint=4], - A8B8G8R8SrgbPack32 => FORMAT_A8B8G8R8_SRGB_PACK32 [float=4], - A2R10G10B10UnormPack32 => FORMAT_A2R10G10B10_UNORM_PACK32 [float=4], - A2R10G10B10SnormPack32 => FORMAT_A2R10G10B10_SNORM_PACK32 [float=4], - A2R10G10B10UscaledPack32 => FORMAT_A2R10G10B10_USCALED_PACK32 [float=4], - A2R10G10B10SscaledPack32 => FORMAT_A2R10G10B10_SSCALED_PACK32 [float=4], - A2R10G10B10UintPack32 => FORMAT_A2R10G10B10_UINT_PACK32 [uint=4], - A2R10G10B10SintPack32 => FORMAT_A2R10G10B10_SINT_PACK32 [sint=4], - A2B10G10R10UnormPack32 => FORMAT_A2B10G10R10_UNORM_PACK32 [float=4], - A2B10G10R10SnormPack32 => FORMAT_A2B10G10R10_SNORM_PACK32 [float=4], - A2B10G10R10UscaledPack32 => FORMAT_A2B10G10R10_USCALED_PACK32 [float=4], - A2B10G10R10SscaledPack32 => FORMAT_A2B10G10R10_SSCALED_PACK32 [float=4], - A2B10G10R10UintPack32 => FORMAT_A2B10G10R10_UINT_PACK32 [uint=4], - A2B10G10R10SintPack32 => FORMAT_A2B10G10R10_SINT_PACK32 [sint=4], - R16Unorm => FORMAT_R16_UNORM [float=1], - R16Snorm => FORMAT_R16_SNORM [float=1], - R16Uscaled => FORMAT_R16_USCALED [float=1], - R16Sscaled => FORMAT_R16_SSCALED [float=1], - R16Uint => FORMAT_R16_UINT [uint=1], - R16Sint => FORMAT_R16_SINT [sint=1], - R16Sfloat => FORMAT_R16_SFLOAT [float=1], - R16G16Unorm => FORMAT_R16G16_UNORM [float=2], - R16G16Snorm => FORMAT_R16G16_SNORM [float=2], - R16G16Uscaled => FORMAT_R16G16_USCALED [float=2], - R16G16Sscaled => FORMAT_R16G16_SSCALED [float=2], - R16G16Uint => FORMAT_R16G16_UINT [uint=2], - R16G16Sint => FORMAT_R16G16_SINT [sint=2], - R16G16Sfloat => FORMAT_R16G16_SFLOAT [float=2], - R16G16B16Unorm => FORMAT_R16G16B16_UNORM [float=3], - R16G16B16Snorm => FORMAT_R16G16B16_SNORM [float=3], - R16G16B16Uscaled => FORMAT_R16G16B16_USCALED [float=3], - R16G16B16Sscaled => FORMAT_R16G16B16_SSCALED [float=3], - R16G16B16Uint => FORMAT_R16G16B16_UINT [uint=3], - R16G16B16Sint => FORMAT_R16G16B16_SINT [sint=3], - R16G16B16Sfloat => FORMAT_R16G16B16_SFLOAT [float=3], - R16G16B16A16Unorm => FORMAT_R16G16B16A16_UNORM [float=4], - R16G16B16A16Snorm => FORMAT_R16G16B16A16_SNORM [float=4], - R16G16B16A16Uscaled => FORMAT_R16G16B16A16_USCALED [float=4], - R16G16B16A16Sscaled => FORMAT_R16G16B16A16_SSCALED [float=4], - R16G16B16A16Uint => FORMAT_R16G16B16A16_UINT [uint=4], - R16G16B16A16Sint => FORMAT_R16G16B16A16_SINT [sint=4], - R16G16B16A16Sfloat => FORMAT_R16G16B16A16_SFLOAT [float=4], - R32Uint => FORMAT_R32_UINT [uint=1], - R32Sint => FORMAT_R32_SINT [sint=1], - R32Sfloat => FORMAT_R32_SFLOAT [float=1], - R32G32Uint => FORMAT_R32G32_UINT [uint=2], - R32G32Sint => FORMAT_R32G32_SINT [sint=2], - R32G32Sfloat => FORMAT_R32G32_SFLOAT [float=2], - R32G32B32Uint => FORMAT_R32G32B32_UINT [uint=3], - R32G32B32Sint => FORMAT_R32G32B32_SINT [sint=3], - R32G32B32Sfloat => FORMAT_R32G32B32_SFLOAT [float=3], - R32G32B32A32Uint => FORMAT_R32G32B32A32_UINT [uint=4], - R32G32B32A32Sint => FORMAT_R32G32B32A32_SINT [sint=4], - R32G32B32A32Sfloat => FORMAT_R32G32B32A32_SFLOAT [float=4], - R64Uint => FORMAT_R64_UINT [uint=1], - R64Sint => FORMAT_R64_SINT [sint=1], - R64Sfloat => FORMAT_R64_SFLOAT [float=1], - R64G64Uint => FORMAT_R64G64_UINT [uint=2], - R64G64Sint => FORMAT_R64G64_SINT [sint=2], - R64G64Sfloat => FORMAT_R64G64_SFLOAT [float=2], - R64G64B64Uint => FORMAT_R64G64B64_UINT [uint=3], - R64G64B64Sint => FORMAT_R64G64B64_SINT [sint=3], - R64G64B64Sfloat => FORMAT_R64G64B64_SFLOAT [float=3], - R64G64B64A64Uint => FORMAT_R64G64B64A64_UINT [uint=4], - R64G64B64A64Sint => FORMAT_R64G64B64A64_SINT [sint=4], - R64G64B64A64Sfloat => FORMAT_R64G64B64A64_SFLOAT [float=4], - B10G11R11UfloatPack32 => FORMAT_B10G11R11_UFLOAT_PACK32 [float=3], - E5B9G9R9UfloatPack32 => FORMAT_E5B9G9R9_UFLOAT_PACK32 [float=3], - D16Unorm => FORMAT_D16_UNORM [depth], - X8_D24UnormPack32 => FORMAT_X8_D24_UNORM_PACK32 [depth], - D32Sfloat => FORMAT_D32_SFLOAT [depth], - S8Uint => FORMAT_S8_UINT [stencil], - D16Unorm_S8Uint => FORMAT_D16_UNORM_S8_UINT [depthstencil], - D24Unorm_S8Uint => FORMAT_D24_UNORM_S8_UINT [depthstencil], - D32Sfloat_S8Uint => FORMAT_D32_SFLOAT_S8_UINT [depthstencil], - BC1_RGBUnormBlock => FORMAT_BC1_RGB_UNORM_BLOCK [compressed], - BC1_RGBSrgbBlock => FORMAT_BC1_RGB_SRGB_BLOCK [compressed], - BC1_RGBAUnormBlock => FORMAT_BC1_RGBA_UNORM_BLOCK [compressed], - BC1_RGBASrgbBlock => FORMAT_BC1_RGBA_SRGB_BLOCK [compressed], - BC2UnormBlock => FORMAT_BC2_UNORM_BLOCK [compressed], - BC2SrgbBlock => FORMAT_BC2_SRGB_BLOCK [compressed], - BC3UnormBlock => FORMAT_BC3_UNORM_BLOCK [compressed], - BC3SrgbBlock => FORMAT_BC3_SRGB_BLOCK [compressed], - BC4UnormBlock => FORMAT_BC4_UNORM_BLOCK [compressed], - BC4SnormBlock => FORMAT_BC4_SNORM_BLOCK [compressed], - BC5UnormBlock => FORMAT_BC5_UNORM_BLOCK [compressed], - BC5SnormBlock => FORMAT_BC5_SNORM_BLOCK [compressed], - BC6HUfloatBlock => FORMAT_BC6H_UFLOAT_BLOCK [compressed], - BC6HSfloatBlock => FORMAT_BC6H_SFLOAT_BLOCK [compressed], - BC7UnormBlock => FORMAT_BC7_UNORM_BLOCK [compressed], - BC7SrgbBlock => FORMAT_BC7_SRGB_BLOCK [compressed], - ETC2_R8G8B8UnormBlock => FORMAT_ETC2_R8G8B8_UNORM_BLOCK [compressed], - ETC2_R8G8B8SrgbBlock => FORMAT_ETC2_R8G8B8_SRGB_BLOCK [compressed], - ETC2_R8G8B8A1UnormBlock => FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK [compressed], - ETC2_R8G8B8A1SrgbBlock => FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK [compressed], - ETC2_R8G8B8A8UnormBlock => FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK [compressed], - ETC2_R8G8B8A8SrgbBlock => FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK [compressed], - EAC_R11UnormBlock => FORMAT_EAC_R11_UNORM_BLOCK [compressed], - EAC_R11SnormBlock => FORMAT_EAC_R11_SNORM_BLOCK [compressed], - EAC_R11G11UnormBlock => FORMAT_EAC_R11G11_UNORM_BLOCK [compressed], - EAC_R11G11SnormBlock => FORMAT_EAC_R11G11_SNORM_BLOCK [compressed], - ASTC_4x4UnormBlock => FORMAT_ASTC_4x4_UNORM_BLOCK [compressed], - ASTC_4x4SrgbBlock => FORMAT_ASTC_4x4_SRGB_BLOCK [compressed], - ASTC_5x4UnormBlock => FORMAT_ASTC_5x4_UNORM_BLOCK [compressed], - ASTC_5x4SrgbBlock => FORMAT_ASTC_5x4_SRGB_BLOCK [compressed], - ASTC_5x5UnormBlock => FORMAT_ASTC_5x5_UNORM_BLOCK [compressed], - ASTC_5x5SrgbBlock => FORMAT_ASTC_5x5_SRGB_BLOCK [compressed], - ASTC_6x5UnormBlock => FORMAT_ASTC_6x5_UNORM_BLOCK [compressed], - ASTC_6x5SrgbBlock => FORMAT_ASTC_6x5_SRGB_BLOCK [compressed], - ASTC_6x6UnormBlock => FORMAT_ASTC_6x6_UNORM_BLOCK [compressed], - ASTC_6x6SrgbBlock => FORMAT_ASTC_6x6_SRGB_BLOCK [compressed], - ASTC_8x5UnormBlock => FORMAT_ASTC_8x5_UNORM_BLOCK [compressed], - ASTC_8x5SrgbBlock => FORMAT_ASTC_8x5_SRGB_BLOCK [compressed], - ASTC_8x6UnormBlock => FORMAT_ASTC_8x6_UNORM_BLOCK [compressed], - ASTC_8x6SrgbBlock => FORMAT_ASTC_8x6_SRGB_BLOCK [compressed], - ASTC_8x8UnormBlock => FORMAT_ASTC_8x8_UNORM_BLOCK [compressed], - ASTC_8x8SrgbBlock => FORMAT_ASTC_8x8_SRGB_BLOCK [compressed], - ASTC_10x5UnormBlock => FORMAT_ASTC_10x5_UNORM_BLOCK [compressed], - ASTC_10x5SrgbBlock => FORMAT_ASTC_10x5_SRGB_BLOCK [compressed], - ASTC_10x6UnormBlock => FORMAT_ASTC_10x6_UNORM_BLOCK [compressed], - ASTC_10x6SrgbBlock => FORMAT_ASTC_10x6_SRGB_BLOCK [compressed], - ASTC_10x8UnormBlock => FORMAT_ASTC_10x8_UNORM_BLOCK [compressed], - ASTC_10x8SrgbBlock => FORMAT_ASTC_10x8_SRGB_BLOCK [compressed], - ASTC_10x10UnormBlock => FORMAT_ASTC_10x10_UNORM_BLOCK [compressed], - ASTC_10x10SrgbBlock => FORMAT_ASTC_10x10_SRGB_BLOCK [compressed], - ASTC_12x10UnormBlock => FORMAT_ASTC_12x10_UNORM_BLOCK [compressed], - ASTC_12x10SrgbBlock => FORMAT_ASTC_12x10_SRGB_BLOCK [compressed], - ASTC_12x12UnormBlock => FORMAT_ASTC_12x12_UNORM_BLOCK [compressed], - ASTC_12x12SrgbBlock => FORMAT_ASTC_12x12_SRGB_BLOCK [compressed], + R4G4UnormPack8 => FORMAT_R4G4_UNORM_PACK8 [float=2] {u8}, + R4G4B4A4UnormPack16 => FORMAT_R4G4B4A4_UNORM_PACK16 [float=4] {u16}, + B4G4R4A4UnormPack16 => FORMAT_B4G4R4A4_UNORM_PACK16 [float=4] {u16}, + R5G6B5UnormPack16 => FORMAT_R5G6B5_UNORM_PACK16 [float=3] {u16}, + B5G6R5UnormPack16 => FORMAT_B5G6R5_UNORM_PACK16 [float=3] {u16}, + R5G5B5A1UnormPack16 => FORMAT_R5G5B5A1_UNORM_PACK16 [float=4] {u16}, + B5G5R5A1UnormPack16 => FORMAT_B5G5R5A1_UNORM_PACK16 [float=4] {u16}, + A1R5G5B5UnormPack16 => FORMAT_A1R5G5B5_UNORM_PACK16 [float=4] {u16}, + R8Unorm => FORMAT_R8_UNORM [float=1] {u8}, + R8Snorm => FORMAT_R8_SNORM [float=1] {i8}, + R8Uscaled => FORMAT_R8_USCALED [float=1] {u8}, + R8Sscaled => FORMAT_R8_SSCALED [float=1] {i8}, + R8Uint => FORMAT_R8_UINT [uint=1] {u8}, + R8Sint => FORMAT_R8_SINT [sint=1] {i8}, + R8Srgb => FORMAT_R8_SRGB [float=1] {u8}, + R8G8Unorm => FORMAT_R8G8_UNORM [float=2] {[u8; 2]}, + R8G8Snorm => FORMAT_R8G8_SNORM [float=2] {[i8; 2]}, + R8G8Uscaled => FORMAT_R8G8_USCALED [float=2] {[u8; 2]}, + R8G8Sscaled => FORMAT_R8G8_SSCALED [float=2] {[i8; 2]}, + R8G8Uint => FORMAT_R8G8_UINT [uint=2] {[u8; 2]}, + R8G8Sint => FORMAT_R8G8_SINT [sint=2] {[i8; 2]}, + R8G8Srgb => FORMAT_R8G8_SRGB [float=2] {[u8; 2]}, + R8G8B8Unorm => FORMAT_R8G8B8_UNORM [float=3] {[u8; 3]}, + R8G8B8Snorm => FORMAT_R8G8B8_SNORM [float=3] {[i8; 3]}, + R8G8B8Uscaled => FORMAT_R8G8B8_USCALED [float=3] {[u8; 3]}, + R8G8B8Sscaled => FORMAT_R8G8B8_SSCALED [float=3] {[i8; 3]}, + R8G8B8Uint => FORMAT_R8G8B8_UINT [uint=3] {[u8; 3]}, + R8G8B8Sint => FORMAT_R8G8B8_SINT [sint=3] {[i8; 3]}, + R8G8B8Srgb => FORMAT_R8G8B8_SRGB [float=3] {[u8; 3]}, + B8G8R8Unorm => FORMAT_B8G8R8_UNORM [float=3] {[u8; 3]}, + B8G8R8Snorm => FORMAT_B8G8R8_SNORM [float=3] {[i8; 3]}, + B8G8R8Uscaled => FORMAT_B8G8R8_USCALED [float=3] {[u8; 3]}, + B8G8R8Sscaled => FORMAT_B8G8R8_SSCALED [float=3] {[i8; 3]}, + B8G8R8Uint => FORMAT_B8G8R8_UINT [uint=3] {[u8; 3]}, + B8G8R8Sint => FORMAT_B8G8R8_SINT [sint=3] {[i8; 3]}, + B8G8R8Srgb => FORMAT_B8G8R8_SRGB [float=3] {[u8; 3]}, + R8G8B8A8Unorm => FORMAT_R8G8B8A8_UNORM [float=4] {[u8; 4]}, + R8G8B8A8Snorm => FORMAT_R8G8B8A8_SNORM [float=4] {[i8; 4]}, + R8G8B8A8Uscaled => FORMAT_R8G8B8A8_USCALED [float=4] {[u8; 4]}, + R8G8B8A8Sscaled => FORMAT_R8G8B8A8_SSCALED [float=4] {[i8; 4]}, + R8G8B8A8Uint => FORMAT_R8G8B8A8_UINT [uint=4] {[u8; 4]}, + R8G8B8A8Sint => FORMAT_R8G8B8A8_SINT [sint=4] {[i8; 4]}, + R8G8B8A8Srgb => FORMAT_R8G8B8A8_SRGB [float=4] {[u8; 4]}, + B8G8R8A8Unorm => FORMAT_B8G8R8A8_UNORM [float=4] {[u8; 4]}, + B8G8R8A8Snorm => FORMAT_B8G8R8A8_SNORM [float=4] {[i8; 4]}, + B8G8R8A8Uscaled => FORMAT_B8G8R8A8_USCALED [float=4] {[u8; 4]}, + B8G8R8A8Sscaled => FORMAT_B8G8R8A8_SSCALED [float=4] {[i8; 4]}, + B8G8R8A8Uint => FORMAT_B8G8R8A8_UINT [uint=4] {[u8; 4]}, + B8G8R8A8Sint => FORMAT_B8G8R8A8_SINT [sint=4] {[i8; 4]}, + B8G8R8A8Srgb => FORMAT_B8G8R8A8_SRGB [float=4] {[u8; 4]}, + A8B8G8R8UnormPack32 => FORMAT_A8B8G8R8_UNORM_PACK32 [float=4] {[u8; 4]}, + A8B8G8R8SnormPack32 => FORMAT_A8B8G8R8_SNORM_PACK32 [float=4] {[i8; 4]}, + A8B8G8R8UscaledPack32 => FORMAT_A8B8G8R8_USCALED_PACK32 [float=4] {[u8; 4]}, + A8B8G8R8SscaledPack32 => FORMAT_A8B8G8R8_SSCALED_PACK32 [float=4] {[i8; 4]}, + A8B8G8R8UintPack32 => FORMAT_A8B8G8R8_UINT_PACK32 [uint=4] {[u8; 4]}, + A8B8G8R8SintPack32 => FORMAT_A8B8G8R8_SINT_PACK32 [sint=4] {[i8; 4]}, + A8B8G8R8SrgbPack32 => FORMAT_A8B8G8R8_SRGB_PACK32 [float=4] {[u8; 4]}, + A2R10G10B10UnormPack32 => FORMAT_A2R10G10B10_UNORM_PACK32 [float=4] {u32}, + A2R10G10B10SnormPack32 => FORMAT_A2R10G10B10_SNORM_PACK32 [float=4] {u32}, + A2R10G10B10UscaledPack32 => FORMAT_A2R10G10B10_USCALED_PACK32 [float=4] {u32}, + A2R10G10B10SscaledPack32 => FORMAT_A2R10G10B10_SSCALED_PACK32 [float=4] {u32}, + A2R10G10B10UintPack32 => FORMAT_A2R10G10B10_UINT_PACK32 [uint=4] {u32}, + A2R10G10B10SintPack32 => FORMAT_A2R10G10B10_SINT_PACK32 [sint=4] {u32}, + A2B10G10R10UnormPack32 => FORMAT_A2B10G10R10_UNORM_PACK32 [float=4] {u32}, + A2B10G10R10SnormPack32 => FORMAT_A2B10G10R10_SNORM_PACK32 [float=4] {u32}, + A2B10G10R10UscaledPack32 => FORMAT_A2B10G10R10_USCALED_PACK32 [float=4] {u32}, + A2B10G10R10SscaledPack32 => FORMAT_A2B10G10R10_SSCALED_PACK32 [float=4] {u32}, + A2B10G10R10UintPack32 => FORMAT_A2B10G10R10_UINT_PACK32 [uint=4] {u32}, + A2B10G10R10SintPack32 => FORMAT_A2B10G10R10_SINT_PACK32 [sint=4] {u32}, + R16Unorm => FORMAT_R16_UNORM [float=1] {u16}, + R16Snorm => FORMAT_R16_SNORM [float=1] {i16}, + R16Uscaled => FORMAT_R16_USCALED [float=1] {u16}, + R16Sscaled => FORMAT_R16_SSCALED [float=1] {i16}, + R16Uint => FORMAT_R16_UINT [uint=1] {u16}, + R16Sint => FORMAT_R16_SINT [sint=1] {i16}, + R16Sfloat => FORMAT_R16_SFLOAT [float=1] {}, + R16G16Unorm => FORMAT_R16G16_UNORM [float=2] {[u16; 2]}, + R16G16Snorm => FORMAT_R16G16_SNORM [float=2] {[i16; 2]}, + R16G16Uscaled => FORMAT_R16G16_USCALED [float=2] {[u16; 2]}, + R16G16Sscaled => FORMAT_R16G16_SSCALED [float=2] {[i16; 2]}, + R16G16Uint => FORMAT_R16G16_UINT [uint=2] {[u16; 2]}, + R16G16Sint => FORMAT_R16G16_SINT [sint=2] {[i16; 2]}, + R16G16Sfloat => FORMAT_R16G16_SFLOAT [float=2] {}, + R16G16B16Unorm => FORMAT_R16G16B16_UNORM [float=3] {[u16; 3]}, + R16G16B16Snorm => FORMAT_R16G16B16_SNORM [float=3] {[i16; 3]}, + R16G16B16Uscaled => FORMAT_R16G16B16_USCALED [float=3] {[u16; 3]}, + R16G16B16Sscaled => FORMAT_R16G16B16_SSCALED [float=3] {[i16; 3]}, + R16G16B16Uint => FORMAT_R16G16B16_UINT [uint=3] {[u16; 3]}, + R16G16B16Sint => FORMAT_R16G16B16_SINT [sint=3] {[i16; 3]}, + R16G16B16Sfloat => FORMAT_R16G16B16_SFLOAT [float=3] {}, + R16G16B16A16Unorm => FORMAT_R16G16B16A16_UNORM [float=4] {[u16; 4]}, + R16G16B16A16Snorm => FORMAT_R16G16B16A16_SNORM [float=4] {[i16; 4]}, + R16G16B16A16Uscaled => FORMAT_R16G16B16A16_USCALED [float=4] {[u16; 4]}, + R16G16B16A16Sscaled => FORMAT_R16G16B16A16_SSCALED [float=4] {[i16; 4]}, + R16G16B16A16Uint => FORMAT_R16G16B16A16_UINT [uint=4] {[u16; 4]}, + R16G16B16A16Sint => FORMAT_R16G16B16A16_SINT [sint=4] {[i16; 4]}, + R16G16B16A16Sfloat => FORMAT_R16G16B16A16_SFLOAT [float=4] {}, + R32Uint => FORMAT_R32_UINT [uint=1] {u32}, + R32Sint => FORMAT_R32_SINT [sint=1] {i32}, + R32Sfloat => FORMAT_R32_SFLOAT [float=1] {f32}, + R32G32Uint => FORMAT_R32G32_UINT [uint=2] {[u32; 2]}, + R32G32Sint => FORMAT_R32G32_SINT [sint=2] {[i32; 2]}, + R32G32Sfloat => FORMAT_R32G32_SFLOAT [float=2] {[f32; 2]}, + R32G32B32Uint => FORMAT_R32G32B32_UINT [uint=3] {[u32; 3]}, + R32G32B32Sint => FORMAT_R32G32B32_SINT [sint=3] {[i32; 3]}, + R32G32B32Sfloat => FORMAT_R32G32B32_SFLOAT [float=3] {[f32; 3]}, + R32G32B32A32Uint => FORMAT_R32G32B32A32_UINT [uint=4] {[u32; 4]}, + R32G32B32A32Sint => FORMAT_R32G32B32A32_SINT [sint=4] {[i32; 4]}, + R32G32B32A32Sfloat => FORMAT_R32G32B32A32_SFLOAT [float=4] {[f32; 4]}, + R64Uint => FORMAT_R64_UINT [uint=1] {u64}, + R64Sint => FORMAT_R64_SINT [sint=1] {i64}, + R64Sfloat => FORMAT_R64_SFLOAT [float=1] {f64}, + R64G64Uint => FORMAT_R64G64_UINT [uint=2] {[u64; 2]}, + R64G64Sint => FORMAT_R64G64_SINT [sint=2] {[i64; 2]}, + R64G64Sfloat => FORMAT_R64G64_SFLOAT [float=2] {[f64; 2]}, + R64G64B64Uint => FORMAT_R64G64B64_UINT [uint=3] {[u64; 3]}, + R64G64B64Sint => FORMAT_R64G64B64_SINT [sint=3] {[i64; 3]}, + R64G64B64Sfloat => FORMAT_R64G64B64_SFLOAT [float=3] {[f64; 3]}, + R64G64B64A64Uint => FORMAT_R64G64B64A64_UINT [uint=4] {[u64; 4]}, + R64G64B64A64Sint => FORMAT_R64G64B64A64_SINT [sint=4] {[i64; 4]}, + R64G64B64A64Sfloat => FORMAT_R64G64B64A64_SFLOAT [float=4] {[f64; 4]}, + B10G11R11UfloatPack32 => FORMAT_B10G11R11_UFLOAT_PACK32 [float=3] {u32}, + E5B9G9R9UfloatPack32 => FORMAT_E5B9G9R9_UFLOAT_PACK32 [float=3] {u32}, + D16Unorm => FORMAT_D16_UNORM [depth] {}, + X8_D24UnormPack32 => FORMAT_X8_D24_UNORM_PACK32 [depth] {}, + D32Sfloat => FORMAT_D32_SFLOAT [depth] {}, + S8Uint => FORMAT_S8_UINT [stencil] {}, + D16Unorm_S8Uint => FORMAT_D16_UNORM_S8_UINT [depthstencil] {}, + D24Unorm_S8Uint => FORMAT_D24_UNORM_S8_UINT [depthstencil] {}, + D32Sfloat_S8Uint => FORMAT_D32_SFLOAT_S8_UINT [depthstencil] {}, + BC1_RGBUnormBlock => FORMAT_BC1_RGB_UNORM_BLOCK [compressed] {}, + BC1_RGBSrgbBlock => FORMAT_BC1_RGB_SRGB_BLOCK [compressed] {}, + BC1_RGBAUnormBlock => FORMAT_BC1_RGBA_UNORM_BLOCK [compressed] {}, + BC1_RGBASrgbBlock => FORMAT_BC1_RGBA_SRGB_BLOCK [compressed] {}, + BC2UnormBlock => FORMAT_BC2_UNORM_BLOCK [compressed] {}, + BC2SrgbBlock => FORMAT_BC2_SRGB_BLOCK [compressed] {}, + BC3UnormBlock => FORMAT_BC3_UNORM_BLOCK [compressed] {}, + BC3SrgbBlock => FORMAT_BC3_SRGB_BLOCK [compressed] {}, + BC4UnormBlock => FORMAT_BC4_UNORM_BLOCK [compressed] {}, + BC4SnormBlock => FORMAT_BC4_SNORM_BLOCK [compressed] {}, + BC5UnormBlock => FORMAT_BC5_UNORM_BLOCK [compressed] {}, + BC5SnormBlock => FORMAT_BC5_SNORM_BLOCK [compressed] {}, + BC6HUfloatBlock => FORMAT_BC6H_UFLOAT_BLOCK [compressed] {}, + BC6HSfloatBlock => FORMAT_BC6H_SFLOAT_BLOCK [compressed] {}, + BC7UnormBlock => FORMAT_BC7_UNORM_BLOCK [compressed] {}, + BC7SrgbBlock => FORMAT_BC7_SRGB_BLOCK [compressed] {}, + ETC2_R8G8B8UnormBlock => FORMAT_ETC2_R8G8B8_UNORM_BLOCK [compressed] {}, + ETC2_R8G8B8SrgbBlock => FORMAT_ETC2_R8G8B8_SRGB_BLOCK [compressed] {}, + ETC2_R8G8B8A1UnormBlock => FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK [compressed] {}, + ETC2_R8G8B8A1SrgbBlock => FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK [compressed] {}, + ETC2_R8G8B8A8UnormBlock => FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK [compressed] {}, + ETC2_R8G8B8A8SrgbBlock => FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK [compressed] {}, + EAC_R11UnormBlock => FORMAT_EAC_R11_UNORM_BLOCK [compressed] {}, + EAC_R11SnormBlock => FORMAT_EAC_R11_SNORM_BLOCK [compressed] {}, + EAC_R11G11UnormBlock => FORMAT_EAC_R11G11_UNORM_BLOCK [compressed] {}, + EAC_R11G11SnormBlock => FORMAT_EAC_R11G11_SNORM_BLOCK [compressed] {}, + ASTC_4x4UnormBlock => FORMAT_ASTC_4x4_UNORM_BLOCK [compressed] {}, + ASTC_4x4SrgbBlock => FORMAT_ASTC_4x4_SRGB_BLOCK [compressed] {}, + ASTC_5x4UnormBlock => FORMAT_ASTC_5x4_UNORM_BLOCK [compressed] {}, + ASTC_5x4SrgbBlock => FORMAT_ASTC_5x4_SRGB_BLOCK [compressed] {}, + ASTC_5x5UnormBlock => FORMAT_ASTC_5x5_UNORM_BLOCK [compressed] {}, + ASTC_5x5SrgbBlock => FORMAT_ASTC_5x5_SRGB_BLOCK [compressed] {}, + ASTC_6x5UnormBlock => FORMAT_ASTC_6x5_UNORM_BLOCK [compressed] {}, + ASTC_6x5SrgbBlock => FORMAT_ASTC_6x5_SRGB_BLOCK [compressed] {}, + ASTC_6x6UnormBlock => FORMAT_ASTC_6x6_UNORM_BLOCK [compressed] {}, + ASTC_6x6SrgbBlock => FORMAT_ASTC_6x6_SRGB_BLOCK [compressed] {}, + ASTC_8x5UnormBlock => FORMAT_ASTC_8x5_UNORM_BLOCK [compressed] {}, + ASTC_8x5SrgbBlock => FORMAT_ASTC_8x5_SRGB_BLOCK [compressed] {}, + ASTC_8x6UnormBlock => FORMAT_ASTC_8x6_UNORM_BLOCK [compressed] {}, + ASTC_8x6SrgbBlock => FORMAT_ASTC_8x6_SRGB_BLOCK [compressed] {}, + ASTC_8x8UnormBlock => FORMAT_ASTC_8x8_UNORM_BLOCK [compressed] {}, + ASTC_8x8SrgbBlock => FORMAT_ASTC_8x8_SRGB_BLOCK [compressed] {}, + ASTC_10x5UnormBlock => FORMAT_ASTC_10x5_UNORM_BLOCK [compressed] {}, + ASTC_10x5SrgbBlock => FORMAT_ASTC_10x5_SRGB_BLOCK [compressed] {}, + ASTC_10x6UnormBlock => FORMAT_ASTC_10x6_UNORM_BLOCK [compressed] {}, + ASTC_10x6SrgbBlock => FORMAT_ASTC_10x6_SRGB_BLOCK [compressed] {}, + ASTC_10x8UnormBlock => FORMAT_ASTC_10x8_UNORM_BLOCK [compressed] {}, + ASTC_10x8SrgbBlock => FORMAT_ASTC_10x8_SRGB_BLOCK [compressed] {}, + ASTC_10x10UnormBlock => FORMAT_ASTC_10x10_UNORM_BLOCK [compressed] {}, + ASTC_10x10SrgbBlock => FORMAT_ASTC_10x10_SRGB_BLOCK [compressed] {}, + ASTC_12x10UnormBlock => FORMAT_ASTC_12x10_UNORM_BLOCK [compressed] {}, + ASTC_12x10SrgbBlock => FORMAT_ASTC_12x10_SRGB_BLOCK [compressed] {}, + ASTC_12x12UnormBlock => FORMAT_ASTC_12x12_UNORM_BLOCK [compressed] {}, + ASTC_12x12SrgbBlock => FORMAT_ASTC_12x12_SRGB_BLOCK [compressed] {}, } pub unsafe trait FormatMarker { @@ -468,6 +477,10 @@ pub unsafe trait DepthStencilFormatMarker: FormatMarker {} pub unsafe trait CompressedFormatMarker: FormatMarker {} pub unsafe trait FloatOrCompressedFormatMarker: FormatMarker {} +pub unsafe trait StrongStorage: FormatMarker { + type Pixel: Copy; +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum FormatTy { Float,