From 5b2e78da45ad4259441cf1dc755fbe3749f11223 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 2 Jul 2024 20:02:35 +0200 Subject: [PATCH] cleanup adapter usages within the `Device` --- wgpu-core/src/device/global.rs | 4 ++-- wgpu-core/src/device/resource.rs | 22 +++++++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index e0a711b448..0d4cc4fe91 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -482,7 +482,7 @@ impl Global { trace.add(trace::Action::CreateTexture(fid.id(), desc.clone())); } - let texture = match device.create_texture(&device.adapter, desc) { + let texture = match device.create_texture(desc) { Ok(texture) => texture, Err(error) => break 'error error, }; @@ -1603,7 +1603,7 @@ impl Global { cache, }; - let pipeline = match device.create_render_pipeline(&device.adapter, desc) { + let pipeline = match device.create_render_pipeline(desc) { Ok(pair) => pair, Err(e) => break 'error e, }; diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 0e566c5d73..eb43202bca 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -737,7 +737,7 @@ impl Device { desc: &resource::TextureDescriptor, ) -> Result>, resource::CreateTextureError> { let format_features = self - .describe_format_features(&self.adapter, desc.format) + .describe_format_features(desc.format) .map_err(|error| resource::CreateTextureError::MissingFeatures(desc.format, error))?; let texture = Texture::new( @@ -793,7 +793,6 @@ impl Device { pub(crate) fn create_texture( self: &Arc, - adapter: &Adapter, desc: &resource::TextureDescriptor, ) -> Result>, resource::CreateTextureError> { use resource::{CreateTextureError, TextureDimensionError}; @@ -885,7 +884,7 @@ impl Device { } let format_features = self - .describe_format_features(adapter, desc.format) + .describe_format_features(desc.format) .map_err(|error| CreateTextureError::MissingFeatures(desc.format, error))?; if desc.sample_count > 1 { @@ -932,7 +931,7 @@ impl Device { .guaranteed_format_features(self.features) .flags .supported_sample_counts(), - adapter + self.adapter .get_texture_format_features(desc.format) .flags .supported_sample_counts(), @@ -2850,7 +2849,6 @@ impl Device { pub(crate) fn create_render_pipeline( self: &Arc, - adapter: &Adapter, desc: pipeline::ResolvedRenderPipelineDescriptor, ) -> Result>, pipeline::CreateRenderPipelineError> { use wgt::TextureFormatFeatureFlags as Tfff; @@ -3019,7 +3017,7 @@ impl Device { )); } - let format_features = self.describe_format_features(adapter, cs.format)?; + let format_features = self.describe_format_features(cs.format)?; if !format_features .allowed_usages .contains(wgt::TextureUsages::RENDER_ATTACHMENT) @@ -3058,7 +3056,7 @@ impl Device { .guaranteed_format_features(self.features) .flags .supported_sample_counts(), - adapter + self.adapter .get_texture_format_features(cs.format) .flags .supported_sample_counts(), @@ -3106,7 +3104,7 @@ impl Device { if let Some(ds) = depth_stencil_state { target_specified = true; let error = 'error: { - let format_features = self.describe_format_features(adapter, ds.format)?; + let format_features = self.describe_format_features(ds.format)?; if !format_features .allowed_usages .contains(wgt::TextureUsages::RENDER_ATTACHMENT) @@ -3137,7 +3135,7 @@ impl Device { .guaranteed_format_features(self.features) .flags .supported_sample_counts(), - adapter + self.adapter .get_texture_format_features(ds.format) .flags .supported_sample_counts(), @@ -3530,12 +3528,11 @@ impl Device { pub(crate) fn get_texture_format_features( &self, - adapter: &Adapter, format: TextureFormat, ) -> wgt::TextureFormatFeatures { // Variant of adapter.get_texture_format_features that takes device features into account use wgt::TextureFormatFeatureFlags as tfsc; - let mut format_features = adapter.get_texture_format_features(format); + let mut format_features = self.adapter.get_texture_format_features(format); if (format == TextureFormat::R32Float || format == TextureFormat::Rg32Float || format == TextureFormat::Rgba32Float) @@ -3548,7 +3545,6 @@ impl Device { pub(crate) fn describe_format_features( &self, - adapter: &Adapter, format: TextureFormat, ) -> Result { self.require_features(format.required_features())?; @@ -3564,7 +3560,7 @@ impl Device { .contains(wgt::DownlevelFlags::WEBGPU_TEXTURE_FORMAT_SUPPORT); if using_device_features || downlevel { - Ok(self.get_texture_format_features(adapter, format)) + Ok(self.get_texture_format_features(format)) } else { Ok(format.guaranteed_format_features(self.features)) }