Module: Mesa
Branch: main
Commit: d5693a590e078e2d42d6a4ff6f992a48f1b98019
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5693a590e078e2d42d6a4ff6f992a48f1b98019

Author: Faith Ekstrand <faith.ekstr...@collabora.com>
Date:   Wed Nov 22 14:40:56 2023 -0600

nak: Drop the PrmtSelection stuff

It's just a very fancy and verbose way to build an immediate.  I don't
think it's really gaining us all that much, especially when the
semantics are documented in the PTX docs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26348>

---

 src/nouveau/compiler/nak_from_nir.rs | 23 +--------
 src/nouveau/compiler/nak_ir.rs       | 95 ------------------------------------
 2 files changed, 1 insertion(+), 117 deletions(-)

diff --git a/src/nouveau/compiler/nak_from_nir.rs 
b/src/nouveau/compiler/nak_from_nir.rs
index f48860e6a00..7e7653dad56 100644
--- a/src/nouveau/compiler/nak_from_nir.rs
+++ b/src/nouveau/compiler/nak_from_nir.rs
@@ -811,31 +811,10 @@ impl<'a> ShaderFromNir<'a> {
                     high: false,
                 });
 
-                let dst = b.alloc_ssa(RegFile::GPR, 1);
-
-                let selection = PrmtSelectionEval::from([
-                    PrmtSelection {
-                        src: PrmtSrc::Byte5,
-                        sign_extend: false,
-                    },
-                    PrmtSelection {
-                        src: PrmtSrc::Byte4,
-                        sign_extend: false,
-                    },
-                    PrmtSelection {
-                        src: PrmtSrc::Byte1,
-                        sign_extend: false,
-                    },
-                    PrmtSelection {
-                        src: PrmtSrc::Byte0,
-                        sign_extend: false,
-                    },
-                ]);
-
                 b.push_op(OpPrmt {
                     dst: dst.into(),
                     srcs: [low.into(), high.into()],
-                    selection: selection.inner().into(),
+                    selection: 0x5410.into(),
                 });
                 dst
             }
diff --git a/src/nouveau/compiler/nak_ir.rs b/src/nouveau/compiler/nak_ir.rs
index 781aa9649ab..966f42202bb 100644
--- a/src/nouveau/compiler/nak_ir.rs
+++ b/src/nouveau/compiler/nak_ir.rs
@@ -2726,101 +2726,6 @@ impl DisplayOp for OpMov {
 }
 impl_display_for_op!(OpMov);
 
-#[derive(Copy, Clone, Debug)]
-pub enum PrmtSrc {
-    Byte0 = 0,
-    Byte1 = 1,
-    Byte2 = 2,
-    Byte3 = 3,
-    Byte4 = 4,
-    Byte5 = 5,
-    Byte6 = 6,
-    Byte7 = 7,
-}
-
-impl TryFrom<u32> for PrmtSrc {
-    type Error = String;
-
-    fn try_from(value: u32) -> Result<Self, Self::Error> {
-        match value {
-            0 => Ok(Self::Byte0),
-            1 => Ok(Self::Byte1),
-            2 => Ok(Self::Byte2),
-            3 => Ok(Self::Byte3),
-            4 => Ok(Self::Byte4),
-            5 => Ok(Self::Byte5),
-            6 => Ok(Self::Byte6),
-            7 => Ok(Self::Byte7),
-            _ => Err(format!("Invalid value {}", value)),
-        }
-    }
-}
-
-#[derive(Copy, Clone, Debug)]
-pub struct PrmtSelection {
-    pub src: PrmtSrc,
-    pub sign_extend: bool,
-}
-
-impl From<PrmtSelectionEval> for [PrmtSelection; 4] {
-    fn from(value: PrmtSelectionEval) -> Self {
-        let sel0 = value.0 & 0x7;
-        let sel1 = (value.0 & 0x70) >> 4;
-        let sel2 = (value.0 & 0x700) >> 8;
-        let sel3 = (value.0 & 0x7000) >> 12;
-
-        let sign0 = value.0 & 0x8;
-        let sign1 = value.0 & 0x80;
-        let sign2 = value.0 & 0x800;
-        let sign3 = value.0 & 0x8000;
-
-        [
-            PrmtSelection {
-                src: sel3.try_into().unwrap(),
-                sign_extend: sign3 != 0,
-            },
-            PrmtSelection {
-                src: sel2.try_into().unwrap(),
-                sign_extend: sign2 != 0,
-            },
-            PrmtSelection {
-                src: sel1.try_into().unwrap(),
-                sign_extend: sign1 != 0,
-            },
-            PrmtSelection {
-                src: sel0.try_into().unwrap(),
-                sign_extend: sign0 != 0,
-            },
-        ]
-    }
-}
-
-#[derive(Copy, Clone, Debug)]
-pub struct PrmtSelectionEval(u32);
-
-impl PrmtSelectionEval {
-    pub fn inner(&self) -> u32 {
-        self.0
-    }
-}
-
-impl From<[PrmtSelection; 4]> for PrmtSelectionEval {
-    fn from(selections: [PrmtSelection; 4]) -> Self {
-        let mut selection = 0;
-
-        for v in selections {
-            let src = if v.sign_extend {
-                v.src as u32 | 0x8
-            } else {
-                v.src as u32
-            };
-            selection = selection << 4 | src;
-        }
-
-        Self(selection)
-    }
-}
-
 #[repr(C)]
 #[derive(SrcsAsSlice, DstsAsSlice)]
 /// Permutes `srcs` into `dst` using `selection`.

Reply via email to