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@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12159>
This commit is contained in:
Rob Clark 2021-07-31 09:54:35 -07:00 committed by Marge Bot
parent 2f665e52e1
commit 7a11cc42e7
4 changed files with 21 additions and 20 deletions

View File

@ -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;

View File

@ -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

View File

@ -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))

View File

@ -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],