From 7a11cc42e7fd89ba4ac69d39b0e1fe0ffbf29f81 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 31 Jul 2021 09:54:35 -0700 Subject: [PATCH] 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 Part-of: --- 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 4334cb9..3f964aa 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 c61506d..6a01b87 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 7f24b44..826a6dc 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 30a7f95..05d6667 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], -- 2.7.4