Mesa (main): turnip: if-checks autotune debug macros

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 8 13:20:11 UTC 2022


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

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Thu May 26 14:14:54 2022 -0700

turnip: if-checks autotune debug macros

This avoids bitrot while the compiler can easily optimize away those
checks.

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

---

 src/freedreno/vulkan/tu_autotune.c | 48 ++++++++++++++++++--------------------
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/freedreno/vulkan/tu_autotune.c b/src/freedreno/vulkan/tu_autotune.c
index 4476e50b7a7..57ebd11cda3 100644
--- a/src/freedreno/vulkan/tu_autotune.c
+++ b/src/freedreno/vulkan/tu_autotune.c
@@ -355,9 +355,8 @@ tu_autotune_on_submit(struct tu_device *dev,
       queue_pending_results(at, cmdbuf);
    }
 
-#if TU_AUTOTUNE_DEBUG_LOG != 0
-   mesa_logi("Total history entries: %u", at->ht->entries);
-#endif
+   if (TU_AUTOTUNE_DEBUG_LOG)
+      mesa_logi("Total history entries: %u", at->ht->entries);
 
    /* Cleanup old entries from history table. The assumption
     * here is that application doesn't hold many old unsubmitted
@@ -369,9 +368,8 @@ tu_autotune_on_submit(struct tu_device *dev,
           (new_fence - history->last_fence) <= MAX_HISTORY_LIFETIME)
          continue;
 
-#if TU_AUTOTUNE_DEBUG_LOG != 0
-      mesa_logi("Removed old history entry %016"PRIx64"", history->key);
-#endif
+      if (TU_AUTOTUNE_DEBUG_LOG)
+         mesa_logi("Removed old history entry %016"PRIx64"", history->key);
 
       u_rwlock_wrlock(&at->ht_lock);
       _mesa_hash_table_remove_key(at->ht, &history->key);
@@ -416,18 +414,18 @@ tu_autotune_init(struct tu_autotune *at, struct tu_device *dev)
 void
 tu_autotune_fini(struct tu_autotune *at, struct tu_device *dev)
 {
-#if TU_AUTOTUNE_LOG_AT_FINISH != 0
-   while (!list_is_empty(&at->pending_results)) {
-      process_results(at);
-   }
+   if (TU_AUTOTUNE_LOG_AT_FINISH) {
+      while (!list_is_empty(&at->pending_results)) {
+         process_results(at);
+      }
 
-   hash_table_foreach(at->ht, entry) {
-      struct tu_renderpass_history *history = entry->data;
+      hash_table_foreach(at->ht, entry) {
+         struct tu_renderpass_history *history = entry->data;
 
-      mesa_logi("%016"PRIx64" \tavg_passed=%u results=%u",
-                history->key, history->avg_samples, history->num_results);
+         mesa_logi("%016"PRIx64" \tavg_passed=%u results=%u",
+                   history->key, history->avg_samples, history->num_results);
+      }
    }
-#endif
 
    tu_autotune_free_results(dev, &at->pending_results);
 
@@ -553,10 +551,10 @@ tu_autotune_use_bypass(struct tu_autotune *at,
        * a clear plus draws that touch no or few samples
        */
       if (avg_samples < 500) {
-#if TU_AUTOTUNE_DEBUG_LOG != 0
-         mesa_logi("%016"PRIx64":%u\t avg_samples=%u selecting sysmem",
-            renderpass_key, cmd_buffer->state.drawcall_count, avg_samples);
-#endif
+         if (TU_AUTOTUNE_DEBUG_LOG) {
+            mesa_logi("%016"PRIx64":%u\t avg_samples=%u selecting sysmem",
+               renderpass_key, cmd_buffer->state.drawcall_count, avg_samples);
+         }
          return true;
       }
 
@@ -570,12 +568,12 @@ tu_autotune_use_bypass(struct tu_autotune *at,
 
       bool select_sysmem = single_draw_cost < 6000.0;
 
-#if TU_AUTOTUNE_DEBUG_LOG != 0
-      mesa_logi("%016"PRIx64":%u\t avg_samples=%u, "
-          "sample_cost=%f, single_draw_cost=%f selecting %s",
-          renderpass_key, cmd_buffer->state.drawcall_count, avg_samples,
-          sample_cost, single_draw_cost, select_sysmem ? "sysmem" : "gmem");
-#endif
+      if (TU_AUTOTUNE_DEBUG_LOG) {
+         mesa_logi("%016"PRIx64":%u\t avg_samples=%u, "
+             "sample_cost=%f, single_draw_cost=%f selecting %s",
+             renderpass_key, cmd_buffer->state.drawcall_count, avg_samples,
+             sample_cost, single_draw_cost, select_sysmem ? "sysmem" : "gmem");
+      }
 
       return select_sysmem;
    }



More information about the mesa-commit mailing list