From 89e6cbbd8912f91af8a333f5252cefa818df7c14 Mon Sep 17 00:00:00 2001 From: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:08:11 +0100 Subject: [PATCH] Revert "Support nv12 texture format (#4573)" This reverts commit a6503e59c909a8870a91f3eab82e0a84ea19a85f. --- deno_webgpu/texture.rs | 1 - examples/src/mipmap/mod.rs | 1 - examples/src/shadow/mod.rs | 1 - tests/tests/bgra8unorm_storage.rs | 1 - tests/tests/nv12_texture/mod.rs | 250 --------------------- tests/tests/nv12_texture/nv12_texture.wgsl | 33 --- tests/tests/root.rs | 1 - wgpu-core/src/command/clear.rs | 5 - wgpu-core/src/device/resource.rs | 88 ++------ wgpu-core/src/present.rs | 1 - wgpu-core/src/resource.rs | 12 - wgpu-core/src/validation.rs | 1 - wgpu-hal/examples/halmark/main.rs | 2 - wgpu-hal/examples/raw-gles.rs | 1 - wgpu-hal/src/auxil/dxgi/conv.rs | 1 - wgpu-hal/src/dx12/adapter.rs | 3 +- wgpu-hal/src/dx12/device.rs | 6 +- wgpu-hal/src/dx12/view.rs | 14 +- wgpu-hal/src/gles/adapter.rs | 1 - wgpu-hal/src/gles/conv.rs | 1 - wgpu-hal/src/lib.rs | 1 - wgpu-hal/src/metal/adapter.rs | 2 - wgpu-hal/src/vulkan/adapter.rs | 27 +-- wgpu-hal/src/vulkan/conv.rs | 22 +- wgpu-hal/src/vulkan/device.rs | 2 +- wgpu-types/src/lib.rs | 42 +--- wgpu/src/backend/direct.rs | 1 - wgpu/src/lib.rs | 2 - 28 files changed, 39 insertions(+), 484 deletions(-) delete mode 100644 tests/tests/nv12_texture/mod.rs delete mode 100644 tests/tests/nv12_texture/nv12_texture.wgsl diff --git a/deno_webgpu/texture.rs b/deno_webgpu/texture.rs index fb9640f59f..5eadd5b3c2 100644 --- a/deno_webgpu/texture.rs +++ b/deno_webgpu/texture.rs @@ -124,7 +124,6 @@ pub fn op_webgpu_create_texture_view( format: args.format, dimension: args.dimension, range: args.range, - plane: None, }; gfx_put!(texture => instance.texture_create_view( diff --git a/examples/src/mipmap/mod.rs b/examples/src/mipmap/mod.rs index 59c9aab4d4..c6dc7fa251 100644 --- a/examples/src/mipmap/mod.rs +++ b/examples/src/mipmap/mod.rs @@ -133,7 +133,6 @@ impl Example { mip_level_count: Some(1), base_array_layer: 0, array_layer_count: None, - ..Default::default() }) }) .collect::>(); diff --git a/examples/src/shadow/mod.rs b/examples/src/shadow/mod.rs index 3c4aa88067..485d0d78d6 100644 --- a/examples/src/shadow/mod.rs +++ b/examples/src/shadow/mod.rs @@ -398,7 +398,6 @@ impl crate::framework::Example for Example { mip_level_count: None, base_array_layer: i as u32, array_layer_count: Some(1), - ..Default::default() })) }) .collect::>(); diff --git a/tests/tests/bgra8unorm_storage.rs b/tests/tests/bgra8unorm_storage.rs index 0caf7f80e3..5cfcb27a29 100644 --- a/tests/tests/bgra8unorm_storage.rs +++ b/tests/tests/bgra8unorm_storage.rs @@ -49,7 +49,6 @@ static BGRA8_UNORM_STORAGE: GpuTestConfiguration = GpuTestConfiguration::new() base_array_layer: 0, mip_level_count: Some(1), array_layer_count: Some(1), - ..Default::default() }); let readback_buffer = device.create_buffer(&wgpu::BufferDescriptor { diff --git a/tests/tests/nv12_texture/mod.rs b/tests/tests/nv12_texture/mod.rs deleted file mode 100644 index 0d9b4b5d4d..0000000000 --- a/tests/tests/nv12_texture/mod.rs +++ /dev/null @@ -1,250 +0,0 @@ -//! Tests for nv12 texture creation and sampling. - -use wgpu_test::{fail, gpu_test, GpuTestConfiguration, TestParameters}; - -#[gpu_test] -static NV12_TEXTURE_CREATION_SAMPLING: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().features(wgpu::Features::TEXTURE_FORMAT_NV12)) - .run_sync(|ctx| { - let size = wgpu::Extent3d { - width: 256, - height: 256, - depth_or_array_layers: 1, - }; - let target_format = wgpu::TextureFormat::Bgra8UnormSrgb; - - let shader = ctx - .device - .create_shader_module(wgpu::include_wgsl!("nv12_texture.wgsl")); - let pipeline = ctx - .device - .create_render_pipeline(&wgpu::RenderPipelineDescriptor { - label: Some("nv12 pipeline"), - layout: None, - vertex: wgpu::VertexState { - module: &shader, - entry_point: "vs_main", - buffers: &[], - }, - fragment: Some(wgpu::FragmentState { - module: &shader, - entry_point: "fs_main", - targets: &[Some(target_format.into())], - }), - primitive: wgpu::PrimitiveState { - topology: wgpu::PrimitiveTopology::TriangleStrip, - strip_index_format: Some(wgpu::IndexFormat::Uint32), - ..Default::default() - }, - depth_stencil: None, - multisample: wgpu::MultisampleState::default(), - multiview: None, - }); - - let tex = ctx.device.create_texture(&wgpu::TextureDescriptor { - label: None, - dimension: wgpu::TextureDimension::D2, - size, - format: wgpu::TextureFormat::NV12, - usage: wgpu::TextureUsages::TEXTURE_BINDING, - mip_level_count: 1, - sample_count: 1, - view_formats: &[wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::Rg8Unorm], - }); - let y_view = tex.create_view(&wgpu::TextureViewDescriptor { - format: Some(wgpu::TextureFormat::R8Unorm), - plane: Some(0), - ..Default::default() - }); - let uv_view = tex.create_view(&wgpu::TextureViewDescriptor { - format: Some(wgpu::TextureFormat::Rg8Unorm), - plane: Some(1), - ..Default::default() - }); - let sampler = ctx.device.create_sampler(&wgpu::SamplerDescriptor { - min_filter: wgpu::FilterMode::Linear, - mag_filter: wgpu::FilterMode::Linear, - ..Default::default() - }); - let bind_group = ctx.device.create_bind_group(&wgpu::BindGroupDescriptor { - label: None, - layout: &pipeline.get_bind_group_layout(0), - entries: &[ - wgpu::BindGroupEntry { - binding: 0, - resource: wgpu::BindingResource::Sampler(&sampler), - }, - wgpu::BindGroupEntry { - binding: 1, - resource: wgpu::BindingResource::TextureView(&y_view), - }, - wgpu::BindGroupEntry { - binding: 2, - resource: wgpu::BindingResource::TextureView(&uv_view), - }, - ], - }); - - let target_tex = ctx.device.create_texture(&wgpu::TextureDescriptor { - label: None, - size, - mip_level_count: 1, - sample_count: 1, - dimension: wgpu::TextureDimension::D2, - format: target_format, - usage: wgpu::TextureUsages::RENDER_ATTACHMENT, - view_formats: &[], - }); - let target_view = target_tex.create_view(&wgpu::TextureViewDescriptor::default()); - - let mut encoder = ctx - .device - .create_command_encoder(&wgpu::CommandEncoderDescriptor::default()); - let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - label: None, - color_attachments: &[Some(wgpu::RenderPassColorAttachment { - ops: wgpu::Operations::default(), - resolve_target: None, - view: &target_view, - })], - depth_stencil_attachment: None, - timestamp_writes: None, - occlusion_query_set: None, - }); - rpass.set_pipeline(&pipeline); - rpass.set_bind_group(0, &bind_group, &[]); - rpass.draw(0..4, 0..1); - drop(rpass); - ctx.queue.submit(Some(encoder.finish())); - }); - -#[gpu_test] -static NV12_TEXTURE_CREATION_BAD_VIEW_FORMATS: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().features(wgpu::Features::TEXTURE_FORMAT_NV12)) - .run_sync(|ctx| { - let size = wgpu::Extent3d { - width: 256, - height: 256, - depth_or_array_layers: 1, - }; - fail(&ctx.device, || { - let _ = ctx.device.create_texture(&wgpu::TextureDescriptor { - label: None, - dimension: wgpu::TextureDimension::D2, - size, - format: wgpu::TextureFormat::NV12, - usage: wgpu::TextureUsages::TEXTURE_BINDING, - mip_level_count: 1, - sample_count: 1, - view_formats: &[wgpu::TextureFormat::Rgba8Unorm], - }); - }); - }); - -#[gpu_test] -static NV12_TEXTURE_VIEW_PLANE_ON_NON_PLANAR_FORMAT: GpuTestConfiguration = - GpuTestConfiguration::new() - .parameters(TestParameters::default().features(wgpu::Features::TEXTURE_FORMAT_NV12)) - .run_sync(|ctx| { - let size = wgpu::Extent3d { - width: 256, - height: 256, - depth_or_array_layers: 1, - }; - let tex = ctx.device.create_texture(&wgpu::TextureDescriptor { - label: None, - dimension: wgpu::TextureDimension::D2, - size, - format: wgpu::TextureFormat::R8Unorm, - usage: wgpu::TextureUsages::TEXTURE_BINDING, - mip_level_count: 1, - sample_count: 1, - view_formats: &[], - }); - fail(&ctx.device, || { - let _ = tex.create_view(&wgpu::TextureViewDescriptor { - plane: Some(0), - ..Default::default() - }); - }); - }); - -#[gpu_test] -static NV12_TEXTURE_VIEW_PLANE_OUT_OF_BOUNDS: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().features(wgpu::Features::TEXTURE_FORMAT_NV12)) - .run_sync(|ctx| { - let size = wgpu::Extent3d { - width: 256, - height: 256, - depth_or_array_layers: 1, - }; - let tex = ctx.device.create_texture(&wgpu::TextureDescriptor { - label: None, - dimension: wgpu::TextureDimension::D2, - size, - format: wgpu::TextureFormat::NV12, - usage: wgpu::TextureUsages::TEXTURE_BINDING, - mip_level_count: 1, - sample_count: 1, - view_formats: &[wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::Rg8Unorm], - }); - fail(&ctx.device, || { - let _ = tex.create_view(&wgpu::TextureViewDescriptor { - format: Some(wgpu::TextureFormat::R8Unorm), - plane: Some(2), - ..Default::default() - }); - }); - }); - -#[gpu_test] -static NV12_TEXTURE_BAD_FORMAT_VIEW_PLANE: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().features(wgpu::Features::TEXTURE_FORMAT_NV12)) - .run_sync(|ctx| { - let size = wgpu::Extent3d { - width: 256, - height: 256, - depth_or_array_layers: 1, - }; - let tex = ctx.device.create_texture(&wgpu::TextureDescriptor { - label: None, - dimension: wgpu::TextureDimension::D2, - size, - format: wgpu::TextureFormat::NV12, - usage: wgpu::TextureUsages::TEXTURE_BINDING, - mip_level_count: 1, - sample_count: 1, - view_formats: &[wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::Rg8Unorm], - }); - fail(&ctx.device, || { - let _ = tex.create_view(&wgpu::TextureViewDescriptor { - format: Some(wgpu::TextureFormat::Rg8Unorm), - plane: Some(0), - ..Default::default() - }); - }); - }); - -#[gpu_test] -static NV12_TEXTURE_BAD_SIZE: GpuTestConfiguration = GpuTestConfiguration::new() - .parameters(TestParameters::default().features(wgpu::Features::TEXTURE_FORMAT_NV12)) - .run_sync(|ctx| { - let size = wgpu::Extent3d { - width: 255, - height: 255, - depth_or_array_layers: 1, - }; - - fail(&ctx.device, || { - let _ = ctx.device.create_texture(&wgpu::TextureDescriptor { - label: None, - dimension: wgpu::TextureDimension::D2, - size, - format: wgpu::TextureFormat::NV12, - usage: wgpu::TextureUsages::TEXTURE_BINDING, - mip_level_count: 1, - sample_count: 1, - view_formats: &[wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::Rg8Unorm], - }); - }); - }); diff --git a/tests/tests/nv12_texture/nv12_texture.wgsl b/tests/tests/nv12_texture/nv12_texture.wgsl deleted file mode 100644 index ea974100b1..0000000000 --- a/tests/tests/nv12_texture/nv12_texture.wgsl +++ /dev/null @@ -1,33 +0,0 @@ -struct VertexOutput { - @builtin(position) pos: vec4, - @location(0) uv: vec2, -} - -@vertex -fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; - // 0, 0 - // 2, 0 - // 0, 2 - // 2, 2 - let v_data = vec2(f32((vertexIndex << 1u) & 2u), f32(vertexIndex & 2u)); - output.pos = vec4(v_data - 1.0, 0.0, 1.0); - output.uv = v_data / 2.0; - return output; -} - -@group(0) @binding(0) var s: sampler; -@group(0) @binding(1) var tex_y: texture_2d; -@group(0) @binding(2) var tex_uv: texture_2d; - -@fragment -fn fs_main(v_ouput: VertexOutput) -> @location(0) vec4 { - let luminance = textureSample(tex_y, s, v_ouput.uv).r; - let chrominance = textureSample(tex_uv, s, v_ouput.uv).rg; - let rgb = mat3x3( - 1.000000, 1.000000, 1.000000, - 0.000000,-0.187324, 1.855600, - 1.574800,-0.468124, 0.000000, - ) * vec3(luminance, chrominance.r - 0.5, chrominance.g - 0.5); - return vec4(rgb, 1.0); -} diff --git a/tests/tests/root.rs b/tests/tests/root.rs index 5fd119b2c9..fbb56a7b2f 100644 --- a/tests/tests/root.rs +++ b/tests/tests/root.rs @@ -18,7 +18,6 @@ mod external_texture; mod instance; mod life_cycle; mod mem_leaks; -mod nv12_texture; mod occlusion_query; mod partially_bounded_arrays; mod pipeline; diff --git a/wgpu-core/src/command/clear.rs b/wgpu-core/src/command/clear.rs index 620911c181..5405c926e5 100644 --- a/wgpu-core/src/command/clear.rs +++ b/wgpu-core/src/command/clear.rs @@ -337,11 +337,6 @@ fn clear_texture_via_buffer_copies( hal::FormatAspects::COLOR ); - if texture_desc.format == wgt::TextureFormat::NV12 { - // TODO: Currently COPY_DST for NV12 textures is unsupported. - return; - } - // Gather list of zero_buffer copies and issue a single command then to perform them let mut zero_buffer_copy_regions = Vec::new(); let buffer_copy_pitch = alignments.buffer_copy_pitch.get() as u32; diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index fb48115ca8..cab72ee788 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -751,8 +751,7 @@ impl Device { if desc.format == *format { continue; } - - if !check_texture_view_format_compatible(desc.format, *format) { + if desc.format.remove_srgb_suffix() != format.remove_srgb_suffix() { return Err(CreateTextureError::InvalidViewFormat(*format, desc.format)); } hal_view_formats.push(*format); @@ -805,35 +804,23 @@ impl Device { let mut clear_views = SmallVec::new(); for mip_level in 0..desc.mip_level_count { for array_layer in 0..desc.size.depth_or_array_layers { - macro_rules! push_clear_view { - ($format:expr, $plane:expr) => { - let desc = hal::TextureViewDescriptor { - label: clear_label, - format: $format, - dimension, - usage, - range: wgt::ImageSubresourceRange { - aspect: wgt::TextureAspect::All, - base_mip_level: mip_level, - mip_level_count: Some(1), - base_array_layer: array_layer, - array_layer_count: Some(1), - }, - plane: $plane, - }; - clear_views.push(Some( - unsafe { self.raw().create_texture_view(&raw_texture, &desc) } - .map_err(DeviceError::from)?, - )); - }; - } - - if desc.format == wgt::TextureFormat::NV12 { - push_clear_view!(wgt::TextureFormat::R8Unorm, Some(0)); - push_clear_view!(wgt::TextureFormat::Rg8Unorm, Some(1)); - } else { - push_clear_view!(desc.format, None); - } + let desc = hal::TextureViewDescriptor { + label: clear_label, + format: desc.format, + dimension, + usage, + range: wgt::ImageSubresourceRange { + aspect: wgt::TextureAspect::All, + base_mip_level: mip_level, + mip_level_count: Some(1), + base_array_layer: array_layer, + array_layer_count: Some(1), + }, + }; + clear_views.push(Some( + unsafe { self.raw().create_texture_view(&raw_texture, &desc) } + .map_err(DeviceError::from)?, + )); } } resource::TextureClearMode::RenderPass { @@ -1028,8 +1015,6 @@ impl Device { }); }; - validate_texture_view_plane(texture.desc.format, resolved_format, desc.plane)?; - // https://gpuweb.github.io/gpuweb/#abstract-opdef-renderable-texture-view let render_extent = 'b: loop { if !texture @@ -1121,7 +1106,6 @@ impl Device { dimension: resolved_dimension, usage, range: resolved_range, - plane: desc.plane, }; let raw = unsafe { @@ -3365,39 +3349,3 @@ impl Resource for Device { &mut self.info } } - -fn check_texture_view_format_compatible( - texture_format: TextureFormat, - view_format: TextureFormat, -) -> bool { - use TextureFormat::*; - - match (texture_format, view_format) { - (NV12, R8Unorm | R8Uint | Rg8Unorm | Rg8Uint) => true, - _ => texture_format.remove_srgb_suffix() == view_format.remove_srgb_suffix(), - } -} - -fn validate_texture_view_plane( - texture_format: TextureFormat, - view_format: TextureFormat, - plane: Option, -) -> Result<(), resource::CreateTextureViewError> { - use TextureFormat::*; - - match (texture_format, view_format, plane) { - (NV12, R8Unorm | R8Uint, Some(0)) => Ok(()), - (NV12, Rg8Unorm | Rg8Uint, Some(1)) => Ok(()), - (NV12, _, _) => { - Err(resource::CreateTextureViewError::InvalidTextureViewPlane { plane, view_format }) - } - - (_, _, Some(_)) => Err( - resource::CreateTextureViewError::InvalidTextureViewPlaneOnNonplanarTexture { - plane, - texture_format, - }, - ), - _ => Ok(()), - } -} diff --git a/wgpu-core/src/present.rs b/wgpu-core/src/present.rs index 0e0ca9a1a6..4c2a042b15 100644 --- a/wgpu-core/src/present.rs +++ b/wgpu-core/src/present.rs @@ -202,7 +202,6 @@ impl Global { dimension: wgt::TextureViewDimension::D2, usage: hal::TextureUses::COLOR_TARGET, range: wgt::ImageSubresourceRange::default(), - plane: None, }; let clear_view = unsafe { hal::Device::create_texture_view( diff --git a/wgpu-core/src/resource.rs b/wgpu-core/src/resource.rs index 49d36a7acc..2d4f142aff 100644 --- a/wgpu-core/src/resource.rs +++ b/wgpu-core/src/resource.rs @@ -988,8 +988,6 @@ pub struct TextureViewDescriptor<'a> { pub dimension: Option, /// Range within the texture that is accessible via this view. pub range: wgt::ImageSubresourceRange, - /// The plane of the texture view. - pub plane: Option, } #[derive(Debug)] @@ -1100,16 +1098,6 @@ pub enum CreateTextureViewError { texture: wgt::TextureFormat, view: wgt::TextureFormat, }, - #[error("Invalid texture view plane `{plane:?}` with view format `{view_format:?}`")] - InvalidTextureViewPlane { - plane: Option, - view_format: wgt::TextureFormat, - }, - #[error("Invalid texture view plane `{plane:?}` on non-planar texture `{texture_format:?}`")] - InvalidTextureViewPlaneOnNonplanarTexture { - plane: Option, - texture_format: wgt::TextureFormat, - }, } #[derive(Clone, Debug, Error)] diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 6eb52376b8..caa23592c7 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -692,7 +692,6 @@ impl NumericType { | Tf::Depth24PlusStencil8 => { panic!("Unexpected depth format") } - Tf::NV12 => panic!("Unexpected nv12 format"), Tf::Rgb9e5Ufloat => (NumericDimension::Vector(Vs::Tri), Scalar::F32), Tf::Bc1RgbaUnorm | Tf::Bc1RgbaUnormSrgb diff --git a/wgpu-hal/examples/halmark/main.rs b/wgpu-hal/examples/halmark/main.rs index 60b2c144f2..609146454a 100644 --- a/wgpu-hal/examples/halmark/main.rs +++ b/wgpu-hal/examples/halmark/main.rs @@ -422,7 +422,6 @@ impl Example { dimension: wgt::TextureViewDimension::D2, usage: hal::TextureUses::RESOURCE, range: wgt::ImageSubresourceRange::default(), - plane: None, }; let texture_view = unsafe { device.create_texture_view(&texture, &view_desc).unwrap() }; @@ -659,7 +658,6 @@ impl Example { dimension: wgt::TextureViewDimension::D2, usage: hal::TextureUses::COLOR_TARGET, range: wgt::ImageSubresourceRange::default(), - plane: None, }; let surface_tex_view = unsafe { self.device diff --git a/wgpu-hal/examples/raw-gles.rs b/wgpu-hal/examples/raw-gles.rs index 71e08443ea..81ab4171e3 100644 --- a/wgpu-hal/examples/raw-gles.rs +++ b/wgpu-hal/examples/raw-gles.rs @@ -142,7 +142,6 @@ fn fill_screen(exposed: &hal::ExposedAdapter, width: u32, height dimension: wgt::TextureViewDimension::D2, usage: hal::TextureUses::COLOR_TARGET, range: wgt::ImageSubresourceRange::default(), - plane: None, }, ) .unwrap() diff --git a/wgpu-hal/src/auxil/dxgi/conv.rs b/wgpu-hal/src/auxil/dxgi/conv.rs index eb74b5adf8..f3f4a18317 100644 --- a/wgpu-hal/src/auxil/dxgi/conv.rs +++ b/wgpu-hal/src/auxil/dxgi/conv.rs @@ -62,7 +62,6 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option DXGI_FORMAT_D24_UNORM_S8_UINT, Tf::Depth32Float => DXGI_FORMAT_D32_FLOAT, Tf::Depth32FloatStencil8 => DXGI_FORMAT_D32_FLOAT_S8X24_UINT, - Tf::NV12 => DXGI_FORMAT_NV12, Tf::Bc1RgbaUnorm => DXGI_FORMAT_BC1_UNORM, Tf::Bc1RgbaUnormSrgb => DXGI_FORMAT_BC1_UNORM_SRGB, Tf::Bc2RgbaUnorm => DXGI_FORMAT_BC2_UNORM, diff --git a/wgpu-hal/src/dx12/adapter.rs b/wgpu-hal/src/dx12/adapter.rs index c28e88c658..cff1303762 100644 --- a/wgpu-hal/src/dx12/adapter.rs +++ b/wgpu-hal/src/dx12/adapter.rs @@ -249,8 +249,7 @@ impl super::Adapter { | wgt::Features::PUSH_CONSTANTS | wgt::Features::SHADER_PRIMITIVE_INDEX | wgt::Features::RG11B10UFLOAT_RENDERABLE - | wgt::Features::DUAL_SOURCE_BLENDING - | wgt::Features::TEXTURE_FORMAT_NV12; + | wgt::Features::DUAL_SOURCE_BLENDING; //TODO: in order to expose this, we need to run a compute shader // that extract the necessary statistics out of the D3D12 result. diff --git a/wgpu-hal/src/dx12/device.rs b/wgpu-hal/src/dx12/device.rs index 90af93661e..649fdb4f8b 100644 --- a/wgpu-hal/src/dx12/device.rs +++ b/wgpu-hal/src/dx12/device.rs @@ -467,11 +467,7 @@ impl crate::Device for super::Device { aspects: view_desc.aspects, target_base: ( texture.resource.clone(), - texture.calc_subresource( - desc.range.base_mip_level, - desc.range.base_array_layer, - desc.plane.unwrap_or(0), - ), + texture.calc_subresource(desc.range.base_mip_level, desc.range.base_array_layer, 0), ), handle_srv: if desc.usage.intersects(crate::TextureUses::RESOURCE) { let raw_desc = unsafe { view_desc.to_srv() }; diff --git a/wgpu-hal/src/dx12/view.rs b/wgpu-hal/src/dx12/view.rs index 9a597e464c..e7a051b535 100644 --- a/wgpu-hal/src/dx12/view.rs +++ b/wgpu-hal/src/dx12/view.rs @@ -14,7 +14,6 @@ pub(super) struct ViewDescriptor { array_layer_count: u32, mip_level_base: u32, mip_level_count: u32, - plane: u32, } impl crate::TextureViewDescriptor<'_> { @@ -31,7 +30,6 @@ impl crate::TextureViewDescriptor<'_> { mip_level_count: self.range.mip_level_count.unwrap_or(!0), array_layer_base: self.range.base_array_layer, array_layer_count: self.range.array_layer_count.unwrap_or(!0), - plane: self.plane.unwrap_or(0), } } } @@ -81,7 +79,7 @@ impl ViewDescriptor { *desc.u.Texture2D_mut() = d3d12_ty::D3D12_TEX2D_SRV { MostDetailedMip: self.mip_level_base, MipLevels: self.mip_level_count, - PlaneSlice: self.plane, + PlaneSlice: 0, ResourceMinLODClamp: 0.0, } } @@ -105,7 +103,7 @@ impl ViewDescriptor { MipLevels: self.mip_level_count, FirstArraySlice: self.array_layer_base, ArraySize: self.array_layer_count, - PlaneSlice: self.plane, + PlaneSlice: 0, ResourceMinLODClamp: 0.0, } } @@ -181,7 +179,7 @@ impl ViewDescriptor { unsafe { *desc.u.Texture2D_mut() = d3d12_ty::D3D12_TEX2D_UAV { MipSlice: self.mip_level_base, - PlaneSlice: self.plane, + PlaneSlice: 0, } } } @@ -192,7 +190,7 @@ impl ViewDescriptor { MipSlice: self.mip_level_base, FirstArraySlice: self.array_layer_base, ArraySize: self.array_layer_count, - PlaneSlice: self.plane, + PlaneSlice: 0, } } } @@ -252,7 +250,7 @@ impl ViewDescriptor { unsafe { *desc.u.Texture2D_mut() = d3d12_ty::D3D12_TEX2D_RTV { MipSlice: self.mip_level_base, - PlaneSlice: self.plane, + PlaneSlice: 0, } } } @@ -274,7 +272,7 @@ impl ViewDescriptor { MipSlice: self.mip_level_base, FirstArraySlice: self.array_layer_base, ArraySize: self.array_layer_count, - PlaneSlice: self.plane, + PlaneSlice: 0, } } } diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 0e8285240a..9ee0904906 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -1072,7 +1072,6 @@ impl crate::Adapter for super::Adapter { | Tf::Depth32FloatStencil8 | Tf::Depth24Plus | Tf::Depth24PlusStencil8 => depth, - Tf::NV12 => unreachable!(), Tf::Rgb9e5Ufloat => filterable, Tf::Bc1RgbaUnorm | Tf::Bc1RgbaUnormSrgb diff --git a/wgpu-hal/src/gles/conv.rs b/wgpu-hal/src/gles/conv.rs index ebf0c65f52..3fb8383a51 100644 --- a/wgpu-hal/src/gles/conv.rs +++ b/wgpu-hal/src/gles/conv.rs @@ -87,7 +87,6 @@ impl super::AdapterShared { glow::DEPTH_STENCIL, glow::UNSIGNED_INT_24_8, ), - Tf::NV12 => unreachable!(), Tf::Rgb9e5Ufloat => (glow::RGB9_E5, glow::RGB, glow::UNSIGNED_INT_5_9_9_9_REV), Tf::Bc1RgbaUnorm => (glow::COMPRESSED_RGBA_S3TC_DXT1_EXT, glow::RGBA, 0), Tf::Bc1RgbaUnormSrgb => (glow::COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, glow::RGBA, 0), diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index 6a03b32a72..cb3ac98e71 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -976,7 +976,6 @@ pub struct TextureViewDescriptor<'a> { pub dimension: wgt::TextureViewDimension, pub usage: TextureUses, pub range: wgt::ImageSubresourceRange, - pub plane: Option, } #[derive(Clone, Debug)] diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 1d3e2e5016..f793596eca 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -232,7 +232,6 @@ impl crate::Adapter for super::Adapter { } flags } - Tf::NV12 => return Tfc::empty(), Tf::Rgb9e5Ufloat => { if pc.msaa_apple3 { all_caps @@ -1014,7 +1013,6 @@ impl super::PrivateCapabilities { Depth32Float_Stencil8 } } - Tf::NV12 => unreachable!(), Tf::Rgb9e5Ufloat => RGB9E5Float, Tf::Bc1RgbaUnorm => BC1_RGBA, Tf::Bc1RgbaUnormSrgb => BC1_RGBA_sRGB, diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index e0f465db52..f64ed57277 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -301,7 +301,6 @@ impl PhysicalDeviceFeatures { fn to_wgpu( &self, - adapter_info: &wgt::AdapterInfo, instance: &ash::Instance, phd: vk::PhysicalDevice, caps: &PhysicalDeviceCapabilities, @@ -536,22 +535,6 @@ impl PhysicalDeviceFeatures { supports_bgra8unorm_storage(instance, phd, caps.device_api_version), ); - features.set( - F::TEXTURE_FORMAT_NV12, - (caps.device_api_version >= vk::API_VERSION_1_1 - || caps.supports_extension(vk::KhrSamplerYcbcrConversionFn::name())) - && supports_format( - instance, - phd, - vk::Format::G8_B8R8_2PLANE_420_UNORM, - vk::ImageTiling::OPTIMAL, - vk::FormatFeatureFlags::SAMPLED_IMAGE - | vk::FormatFeatureFlags::TRANSFER_SRC - | vk::FormatFeatureFlags::TRANSFER_DST, - ) - && !adapter_info.driver.contains("MoltenVK"), - ); - (features, dl_flags) } @@ -986,7 +969,7 @@ impl super::Instance { }; let (available_features, downlevel_flags) = - phd_features.to_wgpu(&info, &self.shared.raw, phd, &phd_capabilities); + phd_features.to_wgpu(&self.shared.raw, phd, &phd_capabilities); let mut workarounds = super::Workarounds::empty(); { // see https://github.com/gfx-rs/gfx/issues/1930 @@ -1568,14 +1551,14 @@ impl crate::Adapter for super::Adapter { .framebuffer_stencil_sample_counts .min(limits.sampled_image_stencil_sample_counts) } else { - match format.sample_type(None) { - Some(wgt::TextureSampleType::Float { filterable: _ }) => limits + match format.sample_type(None).unwrap() { + wgt::TextureSampleType::Float { filterable: _ } => limits .framebuffer_color_sample_counts .min(limits.sampled_image_color_sample_counts), - Some(wgt::TextureSampleType::Sint) | Some(wgt::TextureSampleType::Uint) => { + wgt::TextureSampleType::Sint | wgt::TextureSampleType::Uint => { limits.sampled_image_integer_sample_counts } - _ => vk::SampleCountFlags::TYPE_1, + _ => unreachable!(), } }; diff --git a/wgpu-hal/src/vulkan/conv.rs b/wgpu-hal/src/vulkan/conv.rs index e2d33b20e7..c27fdf9f72 100644 --- a/wgpu-hal/src/vulkan/conv.rs +++ b/wgpu-hal/src/vulkan/conv.rs @@ -74,7 +74,6 @@ impl super::PrivateCapabilities { } } Tf::Depth16Unorm => F::D16_UNORM, - Tf::NV12 => F::G8_B8R8_2PLANE_420_UNORM, Tf::Rgb9e5Ufloat => F::E5B9G9R9_UFLOAT_PACK32, Tf::Bc1RgbaUnorm => F::BC1_RGBA_UNORM_BLOCK, Tf::Bc1RgbaUnormSrgb => F::BC1_RGBA_SRGB_BLOCK, @@ -402,18 +401,10 @@ pub fn map_vertex_format(vertex_format: wgt::VertexFormat) -> vk::Format { } } -pub fn map_aspects(aspects: crate::FormatAspects, plane: Option) -> vk::ImageAspectFlags { +pub fn map_aspects(aspects: crate::FormatAspects) -> vk::ImageAspectFlags { let mut flags = vk::ImageAspectFlags::empty(); - match plane { - Some(0) => flags |= vk::ImageAspectFlags::PLANE_0, - Some(1) => flags |= vk::ImageAspectFlags::PLANE_1, - Some(2) => flags |= vk::ImageAspectFlags::PLANE_2, - Some(plane) => panic!("Unexpected plane {}", plane), - None => { - if aspects.contains(crate::FormatAspects::COLOR) { - flags |= vk::ImageAspectFlags::COLOR; - } - } + if aspects.contains(crate::FormatAspects::COLOR) { + flags |= vk::ImageAspectFlags::COLOR; } if aspects.contains(crate::FormatAspects::DEPTH) { flags |= vk::ImageAspectFlags::DEPTH; @@ -595,10 +586,9 @@ pub fn map_copy_extent(extent: &crate::CopyExtent) -> vk::Extent3D { pub fn map_subresource_range( range: &wgt::ImageSubresourceRange, format: wgt::TextureFormat, - plane: Option, ) -> vk::ImageSubresourceRange { vk::ImageSubresourceRange { - aspect_mask: map_aspects(crate::FormatAspects::new(format, range.aspect), plane), + aspect_mask: map_aspects(crate::FormatAspects::new(format, range.aspect)), base_mip_level: range.base_mip_level, level_count: range.mip_level_count.unwrap_or(vk::REMAINING_MIP_LEVELS), base_array_layer: range.base_array_layer, @@ -615,7 +605,7 @@ pub(super) fn map_subresource_range_combined_aspect( format: wgt::TextureFormat, private_caps: &super::PrivateCapabilities, ) -> vk::ImageSubresourceRange { - let mut range = map_subresource_range(range, format, None); + let mut range = map_subresource_range(range, format); if !private_caps.texture_s8 && format == wgt::TextureFormat::Stencil8 { range.aspect_mask |= vk::ImageAspectFlags::DEPTH; } @@ -631,7 +621,7 @@ pub fn map_subresource_layers( z: base.origin.z as i32, }; let subresource = vk::ImageSubresourceLayers { - aspect_mask: map_aspects(base.aspect, None), + aspect_mask: map_aspects(base.aspect), mip_level: base.mip_level, base_array_layer: base.array_layer, layer_count: 1, diff --git a/wgpu-hal/src/vulkan/device.rs b/wgpu-hal/src/vulkan/device.rs index d9aba50281..5f7fbac47a 100644 --- a/wgpu-hal/src/vulkan/device.rs +++ b/wgpu-hal/src/vulkan/device.rs @@ -1062,7 +1062,7 @@ impl crate::Device for super::Device { texture: &super::Texture, desc: &crate::TextureViewDescriptor, ) -> Result { - let subresource_range = conv::map_subresource_range(&desc.range, desc.format, desc.plane); + let subresource_range = conv::map_subresource_range(&desc.range, desc.format); let mut vk_info = vk::ImageViewCreateInfo::builder() .flags(vk::ImageViewCreateFlags::empty()) .image(texture.raw) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 56b8ee4d0c..8a722dd6af 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -771,16 +771,7 @@ bitflags::bitflags! { /// - OpenGL const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 54; - /// Allows for creation of textures of format [`TextureFormat::NV12`] - /// - /// Supported platforms: - /// - DX12 - /// - Vulkan - /// - /// This is a native only feature. - const TEXTURE_FORMAT_NV12 = 1 << 55; - - // 55..59 available + // 54..59 available // Shader: @@ -2392,21 +2383,6 @@ pub enum TextureFormat { /// [`Features::DEPTH32FLOAT_STENCIL8`] must be enabled to use this texture format. Depth32FloatStencil8, - /// YUV 4:2:0 chroma subsampled format. - /// - /// Contains two planes: - /// - 0: Single 8 bit channel luminance. - /// - 1: Dual 8 bit channel chrominance at half width and half height. - /// - /// Valid view formats for luminance are [`TextureFormat::R8Unorm`] and [`TextureFormat::R8Uint`]. - /// - /// Valid view formats for chrominance are [`TextureFormat::Rg8Unorm`] and [`TextureFormat::Rg8Uint`]. - /// - /// Width and height must be even. - /// - /// [`Features::TEXTURE_FORMAT_NV12`] must be enabled to use this texture format. - NV12, - // Compressed textures usable with `TEXTURE_COMPRESSION_BC` feature. /// 4x4 block compressed texture. 8 bytes per block (4 bit/px). 4 color + alpha pallet. 5 bit R + 6 bit G + 5 bit B + 1 bit alpha. /// [0, 63] ([0, 1] for alpha) converted to/from float [0, 1] in shader. @@ -2636,7 +2612,6 @@ impl<'de> Deserialize<'de> for TextureFormat { "depth16unorm" => TextureFormat::Depth16Unorm, "depth24plus" => TextureFormat::Depth24Plus, "depth24plus-stencil8" => TextureFormat::Depth24PlusStencil8, - "nv12" => TextureFormat::NV12, "rgb9e5ufloat" => TextureFormat::Rgb9e5Ufloat, "bc1-rgba-unorm" => TextureFormat::Bc1RgbaUnorm, "bc1-rgba-unorm-srgb" => TextureFormat::Bc1RgbaUnormSrgb, @@ -2764,7 +2739,6 @@ impl Serialize for TextureFormat { TextureFormat::Depth32FloatStencil8 => "depth32float-stencil8", TextureFormat::Depth24Plus => "depth24plus", TextureFormat::Depth24PlusStencil8 => "depth24plus-stencil8", - TextureFormat::NV12 => "nv12", TextureFormat::Rgb9e5Ufloat => "rgb9e5ufloat", TextureFormat::Bc1RgbaUnorm => "bc1-rgba-unorm", TextureFormat::Bc1RgbaUnormSrgb => "bc1-rgba-unorm-srgb", @@ -2959,8 +2933,6 @@ impl TextureFormat { | Self::Depth32Float | Self::Depth32FloatStencil8 => (1, 1), - Self::NV12 => (2, 2), - Self::Bc1RgbaUnorm | Self::Bc1RgbaUnormSrgb | Self::Bc2RgbaUnorm @@ -3059,8 +3031,6 @@ impl TextureFormat { Self::Depth32FloatStencil8 => Features::DEPTH32FLOAT_STENCIL8, - Self::NV12 => Features::TEXTURE_FORMAT_NV12, - Self::R16Unorm | Self::R16Snorm | Self::Rg16Unorm @@ -3115,7 +3085,6 @@ impl TextureFormat { TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING; let attachment = basic | TextureUsages::RENDER_ATTACHMENT; let storage = basic | TextureUsages::STORAGE_BINDING; - let binding = TextureUsages::TEXTURE_BINDING; let all_flags = TextureUsages::all(); let rg11b10f = if device_features.contains(Features::RG11B10UFLOAT_RENDERABLE) { attachment @@ -3177,9 +3146,6 @@ impl TextureFormat { Self::Depth32Float => ( msaa, attachment), Self::Depth32FloatStencil8 => ( msaa, attachment), - // We only support sampling nv12 textures until we implement transfer plane data. - Self::NV12 => ( noaa, binding), - Self::R16Unorm => ( msaa, storage), Self::R16Snorm => ( msaa, storage), Self::Rg16Unorm => ( msaa, storage), @@ -3287,8 +3253,6 @@ impl TextureFormat { Some(TextureAspect::StencilOnly) => Some(uint), }, - Self::NV12 => None, - Self::R16Unorm | Self::R16Snorm | Self::Rg16Unorm @@ -3405,8 +3369,6 @@ impl TextureFormat { Some(TextureAspect::StencilOnly) => Some(1), }, - Self::NV12 => None, - Self::Bc1RgbaUnorm | Self::Bc1RgbaUnormSrgb | Self::Bc4RUnorm | Self::Bc4RSnorm => { Some(8) } @@ -3498,8 +3460,6 @@ impl TextureFormat { TextureAspect::DepthOnly | TextureAspect::StencilOnly => 1, }, - Self::NV12 => 3, - Self::Bc4RUnorm | Self::Bc4RSnorm => 1, Self::Bc5RgUnorm | Self::Bc5RgSnorm => 2, Self::Bc6hRgbUfloat | Self::Bc6hRgbFloat => 3, diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index b1ed365a8c..cf1fd7291e 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -1610,7 +1610,6 @@ impl crate::Context for Context { base_array_layer: desc.base_array_layer, array_layer_count: desc.array_layer_count, }, - plane: desc.plane, }; let global = &self.0; let (id, error) = wgc::gfx_select!( diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 19199a0490..5f0d8eb023 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -1301,8 +1301,6 @@ pub struct TextureViewDescriptor<'a> { /// If `Some(count)`, `base_array_layer + count` must be less or equal to the underlying array count. /// If `None`, considered to include the rest of the array layers, but at least 1 in total. pub array_layer_count: Option, - /// The index (plane slice number) of the plane to use in the texture. - pub plane: Option, } static_assertions::assert_impl_all!(TextureViewDescriptor<'_>: Send, Sync);