Mesa (main): freedreno: Move generated device table to .h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 6 19:21:23 UTC 2021


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Sat Jul 31 09:54:35 2021 -0700

freedreno: Move generated device table to .h

We only need it in a single .c file, so we can make the device table
static.  Also rename the struct for device table entries, as I want
to re-use the name 'fd_dev_id'

Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12159>

---

 src/freedreno/common/freedreno_dev_info.c | 24 ++++++++++++++++--------
 src/freedreno/common/freedreno_dev_info.h |  6 ------
 src/freedreno/common/freedreno_devices.py |  3 +--
 src/freedreno/common/meson.build          |  8 ++++----
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/freedreno/common/freedreno_dev_info.c b/src/freedreno/common/freedreno_dev_info.c
index 4334cb9570c..3f964aaf695 100644
--- a/src/freedreno/common/freedreno_dev_info.c
+++ b/src/freedreno/common/freedreno_dev_info.c
@@ -25,15 +25,23 @@
 #include "freedreno_dev_info.h"
 #include "util/macros.h"
 
-extern const struct fd_dev_id fd_dev_ids[];
-extern const unsigned fd_dev_ids_count;
+/**
+ * Table entry for a single GPU version
+ */
+struct fd_dev_rec {
+   uint32_t gpu_id;
+   const char *name;
+   const struct fd_dev_info *info;
+};
+
+#include "freedreno_devices.h"
 
 const struct fd_dev_info *
 fd_dev_info(uint32_t gpu_id)
 {
-   for (int i = 0; i < fd_dev_ids_count; i++) {
-      if (gpu_id == fd_dev_ids[i].gpu_id) {
-         return fd_dev_ids[i].info;
+   for (int i = 0; i < ARRAY_SIZE(fd_dev_recs); i++) {
+      if (gpu_id == fd_dev_recs[i].gpu_id) {
+         return fd_dev_recs[i].info;
       }
    }
    return NULL;
@@ -42,9 +50,9 @@ fd_dev_info(uint32_t gpu_id)
 const char *
 fd_dev_name(uint32_t gpu_id)
 {
-   for (int i = 0; i < fd_dev_ids_count; i++) {
-      if (gpu_id == fd_dev_ids[i].gpu_id) {
-         return fd_dev_ids[i].name;
+   for (int i = 0; i < ARRAY_SIZE(fd_dev_recs); i++) {
+      if (gpu_id == fd_dev_recs[i].gpu_id) {
+         return fd_dev_recs[i].name;
       }
    }
    return NULL;
diff --git a/src/freedreno/common/freedreno_dev_info.h b/src/freedreno/common/freedreno_dev_info.h
index c61506dc672..6a01b879791 100644
--- a/src/freedreno/common/freedreno_dev_info.h
+++ b/src/freedreno/common/freedreno_dev_info.h
@@ -105,12 +105,6 @@ struct fd_dev_info {
    };
 };
 
-struct fd_dev_id {
-   uint32_t gpu_id;
-   const char *name;
-   const struct fd_dev_info *info;
-};
-
 /* per CCU GMEM amount reserved for depth cache for direct rendering */
 #define A6XX_CCU_DEPTH_SIZE (64 * 1024)
 /* per CCU GMEM amount reserved for color cache used by GMEM resolves
diff --git a/src/freedreno/common/freedreno_devices.py b/src/freedreno/common/freedreno_devices.py
index 7f24b44a96e..826a6dc3183 100644
--- a/src/freedreno/common/freedreno_devices.py
+++ b/src/freedreno/common/freedreno_devices.py
@@ -326,12 +326,11 @@ template = """\
 static const struct fd_dev_info __info${s.info_index(info)} = ${str(info)};
 %endfor
 
-const struct fd_dev_id fd_dev_ids[] = {
+static const struct fd_dev_rec fd_dev_recs[] = {
 %for id, info in s.gpus.items():
    { ${id.gpu_id}, "${id.name}", &__info${s.info_index(info)} },
 %endfor
 };
-const unsigned fd_dev_ids_count = ${len(s.gpus)};
 """
 
 print(Template(template).render(s=s))
diff --git a/src/freedreno/common/meson.build b/src/freedreno/common/meson.build
index 30a7f955baf..05d66679663 100644
--- a/src/freedreno/common/meson.build
+++ b/src/freedreno/common/meson.build
@@ -18,10 +18,10 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-freedreno_devices_c = custom_target(
-  'freedreno_devices.c',
+freedreno_devices_h = custom_target(
+  'freedreno_devices.h',
   input: 'freedreno_devices.py',
-  output: 'freedreno_devices.c',
+  output: 'freedreno_devices.h',
   command: [prog_python, '@INPUT@'],
   capture: true,
 )
@@ -36,7 +36,7 @@ libfreedreno_common = static_library(
     'freedreno_uuid.c',
     'freedreno_uuid.h',
     'freedreno_guardband.h',
-    freedreno_devices_c,
+    freedreno_devices_h,
     sha1_h,
   ],
   include_directories : [inc_freedreno, inc_include, inc_src, inc_gallium],



More information about the mesa-commit mailing list