Repository: gfx-rs/wgpu (language: rust)

Issue:
`copy_texture_to_texture` doesn't validate matching MSAA count
Mismatch leads to all sort of wonky errors depending on backend/drivers/etc.!

Should add a unit test for this and related errors.

Via @vl4dimir who generously provided a repro case here:
https://github.com/vl4dimir/dissolve-wgpu/tree/wgpu-22


Discussion / hints:

Fix patch:
diff --git a/wgpu-core/src/command/transfer.rs b/wgpu-core/src/command/transfer.rs
index 1113e9b3eb..550e7295b7 100644
--- a/wgpu-core/src/command/transfer.rs
+++ b/wgpu-core/src/command/transfer.rs
@@ -145,6 +145,13 @@ pub enum TransferError {
     MissingDownlevelFlags(#[from] MissingDownlevelFlags),
     #[error("Source texture sample count must be 1, got {sample_count}")]
     InvalidSampleCount { sample_count: u32 },
+    #[error(
+        "Source sample count ({src_sample_count:?}) and destination sample count ({dst_sample_count:?}) are not equal"
+    )]
+    SampleCountNotEqual {
+        src_sample_count: u32,
+        dst_sample_count: u32,
+    },
     #[error("Requested mip level {requested} does no exist (count: {count})")]
     InvalidMipLevel { requested: u32, count: u32 },
 }
@@ -1101,6 +1108,14 @@ impl Global {
             return Err(TransferError::CopyDstMissingAspects.into());
         }
 
+        if src_texture.desc.sample_count != dst_texture.desc.sample_count {
+            return Err(TransferError::SampleCountNotEqual {
+                src_sample_count: src_texture.desc.sample_count,
+                dst_sample_count: dst_texture.desc.sample_count,
+            }
+            .into());
+        }
+
         // Handle texture init *before* dealing with barrier transitions so we
         // have an easier time inserting "immediate-inits" that may be required
         // by prior discards in rare cases.


Test patch: