From db2a6aaf6d9fc7d841d836dfd59bfeb2cee10c27 Mon Sep 17 00:00:00 2001
From: Erik Abair <erik.abair@gmail.com>
Date: Mon, 11 Oct 2021 13:23:16 -0700
Subject: [PATCH] nv2a: Skip input decode if MAC and ILU are both NOP.

---
 hw/xbox/nv2a/vsh.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/xbox/nv2a/vsh.c b/hw/xbox/nv2a/vsh.c
index 555ad88cd8..4b1e7908de 100644
--- a/hw/xbox/nv2a/vsh.c
+++ b/hw/xbox/nv2a/vsh.c
@@ -447,6 +447,14 @@ static MString* decode_token(const uint32_t *shader_token)
 {
     MString *ret;
 
+    /* See what MAC opcode is written to (if not masked away): */
+    VshMAC mac = vsh_get_field(shader_token, FLD_MAC);
+    /* See if a ILU opcode is present too: */
+    VshILU ilu = vsh_get_field(shader_token, FLD_ILU);
+    if (mac == MAC_NOP && ilu == ILU_NOP) {
+        return mstring_new();
+    }
+
     /* Since it's potentially used twice, decode input C once: */
     MString *input_c =
         decode_opcode_input(shader_token,
@@ -455,8 +463,6 @@ static MString* decode_token(const uint32_t *shader_token)
                             (vsh_get_field(shader_token, FLD_C_R_HIGH) << 2)
                                 | vsh_get_field(shader_token, FLD_C_R_LOW));
 
-    /* See what MAC opcode is written to (if not masked away): */
-    VshMAC mac = vsh_get_field(shader_token, FLD_MAC);
     if (mac != MAC_NOP) {
         MString *inputs_mac = mstring_new();
         if (mac_opcode_params[mac].A) {
@@ -495,8 +501,6 @@ static MString* decode_token(const uint32_t *shader_token)
         ret = mstring_new();
     }
 
-    /* See if a ILU opcode is present too: */
-    VshILU ilu = vsh_get_field(shader_token, FLD_ILU);
     if (ilu != ILU_NOP) {
         MString *inputs_c = mstring_from_str(", ");
         mstring_append(inputs_c, mstring_get_str(input_c));