From 1c31cec31e10382b151adb218ee46babd496069e Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 18 Oct 2024 14:24:59 +0200 Subject: [PATCH] ac: rename ac_surface_test_common -> ac_fake_hw_db MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The next commit will reuse the radeon_info when AMD_FORCE_FAMILY is used. Reviewed-by: Marek Olšák Reviewed-by: Samuel Pitoiset Part-of: --- ..._surface_test_common.h => ac_fake_hw_db.h} | 49 +++++++++++-------- src/amd/common/ac_surface_meta_address_test.c | 23 +++++---- src/amd/common/ac_surface_modifier_test.c | 10 ++-- 3 files changed, 47 insertions(+), 35 deletions(-) rename src/amd/common/{ac_surface_test_common.h => ac_fake_hw_db.h} (84%) diff --git a/src/amd/common/ac_surface_test_common.h b/src/amd/common/ac_fake_hw_db.h similarity index 84% rename from src/amd/common/ac_surface_test_common.h rename to src/amd/common/ac_fake_hw_db.h index 902bad7a809..b09b6adfcee 100644 --- a/src/amd/common/ac_surface_test_common.h +++ b/src/amd/common/ac_fake_hw_db.h @@ -12,6 +12,15 @@ #include "amdgfxregs.h" #include "addrlib/src/amdgpu_asic_addr.h" +#ifdef _WIN32 +#define AMDGPU_FAMILY_VI 130 +#define AMDGPU_FAMILY_AI 141 +#define AMDGPU_FAMILY_RV 142 +#define AMDGPU_FAMILY_NV 143 +#else +#include "amdgpu_drm.h" +#endif + typedef void (*gpu_init_func)(struct radeon_info *info); static void init_vega10(struct radeon_info *info) @@ -149,7 +158,7 @@ static void init_gfx12(struct radeon_info *info) info->gb_addr_config = 0; /* Other fields are set by test cases. */ } -struct testcase { +struct ac_fake_hw { const char *name; gpu_init_func init; int banks_or_pkrs; @@ -158,7 +167,7 @@ struct testcase { int rb_per_se; }; -static struct testcase testcases[] = { +static struct ac_fake_hw ac_fake_hw_db[] = { {"vega10", init_vega10, 4, 2, 2, 2}, {"vega10_diff_bank", init_vega10, 3, 2, 2, 2}, {"vega10_diff_rb", init_vega10, 4, 2, 2, 0}, @@ -189,44 +198,42 @@ static struct testcase testcases[] = { {"gfx12_16pipe", init_gfx12, 4, 4}, }; -static struct radeon_info get_radeon_info(struct testcase *testcase) +static void get_radeon_info(struct radeon_info *info, struct ac_fake_hw *hw) { - struct radeon_info info = { - .drm_major = 3, - .drm_minor = 30, - }; + if (info->drm_major != 3) { + info->drm_major = 3; + info->drm_minor = 30; + } - testcase->init(&info); + hw->init(info); - switch(info.gfx_level) { + switch(info->gfx_level) { case GFX9: - info.gb_addr_config = (info.gb_addr_config & + info->gb_addr_config = (info->gb_addr_config & C_0098F8_NUM_PIPES & C_0098F8_NUM_BANKS & C_0098F8_NUM_SHADER_ENGINES_GFX9 & C_0098F8_NUM_RB_PER_SE) | - S_0098F8_NUM_PIPES(testcase->pipes) | - S_0098F8_NUM_BANKS(testcase->banks_or_pkrs) | - S_0098F8_NUM_SHADER_ENGINES_GFX9(testcase->se) | - S_0098F8_NUM_RB_PER_SE(testcase->rb_per_se); + S_0098F8_NUM_PIPES(hw->pipes) | + S_0098F8_NUM_BANKS(hw->banks_or_pkrs) | + S_0098F8_NUM_SHADER_ENGINES_GFX9(hw->se) | + S_0098F8_NUM_RB_PER_SE(hw->rb_per_se); break; case GFX10: case GFX10_3: case GFX11: case GFX12: - info.gb_addr_config = (info.gb_addr_config & + info->gb_addr_config = (info->gb_addr_config & C_0098F8_NUM_PIPES & C_0098F8_NUM_PKRS) | - S_0098F8_NUM_PIPES(testcase->pipes) | - S_0098F8_NUM_PKRS(testcase->banks_or_pkrs); + S_0098F8_NUM_PIPES(hw->pipes) | + S_0098F8_NUM_PKRS(hw->banks_or_pkrs); /* 1 packer implies 1 RB except gfx10 where the field is ignored. */ - info.max_render_backends = info.gfx_level == GFX10 || testcase->banks_or_pkrs ? 2 : 1; + info->max_render_backends = info->gfx_level == GFX10 || hw->banks_or_pkrs ? 2 : 1; break; default: - unreachable("Unhandled generation"); + break; } - - return info; } #endif diff --git a/src/amd/common/ac_surface_meta_address_test.c b/src/amd/common/ac_surface_meta_address_test.c index 69fc4f55c95..0c0c022f17a 100644 --- a/src/amd/common/ac_surface_meta_address_test.c +++ b/src/amd/common/ac_surface_meta_address_test.c @@ -25,7 +25,7 @@ #include "util/mesa-sha1.h" #include "addrlib/inc/addrinterface.h" -#include "ac_surface_test_common.h" +#include "ac_fake_hw_db.h" /* * The main goal of this test is to validate that our dcc/htile addressing @@ -708,34 +708,37 @@ int main(int argc, char **argv) puts("Specify --full to run the full test."); puts("DCC:"); - for (unsigned i = 0; i < ARRAY_SIZE(testcases); ++i) { - struct radeon_info info = get_radeon_info(&testcases[i]); + for (unsigned i = 0; i < ARRAY_SIZE(ac_fake_hw_db); ++i) { + struct radeon_info info = { .drm_major = 0 }; + get_radeon_info(&info, &ac_fake_hw_db[i]); if (info.gfx_level >= GFX12) continue; - run_dcc_address_test(testcases[i].name, &info, full); + run_dcc_address_test(ac_fake_hw_db[i].name, &info, full); } puts("HTILE:"); - for (unsigned i = 0; i < ARRAY_SIZE(testcases); ++i) { - struct radeon_info info = get_radeon_info(&testcases[i]); + for (unsigned i = 0; i < ARRAY_SIZE(ac_fake_hw_db); ++i) { + struct radeon_info info = { .drm_major = 0 }; + get_radeon_info(&info, &ac_fake_hw_db[i]); /* Only GFX10+ is currently supported. GFX12 doesn't have HTILE. */ if (info.gfx_level < GFX10 || info.gfx_level >= GFX12) continue; - run_htile_address_test(testcases[i].name, &info, full); + run_htile_address_test(ac_fake_hw_db[i].name, &info, full); } puts("CMASK:"); - for (unsigned i = 0; i < ARRAY_SIZE(testcases); ++i) { - struct radeon_info info = get_radeon_info(&testcases[i]); + for (unsigned i = 0; i < ARRAY_SIZE(ac_fake_hw_db); ++i) { + struct radeon_info info = { .drm_major = 0 }; + get_radeon_info(&info, &ac_fake_hw_db[i]); if (info.gfx_level >= GFX11) continue; - run_cmask_address_test(testcases[i].name, &info, full); + run_cmask_address_test(ac_fake_hw_db[i].name, &info, full); } return 0; diff --git a/src/amd/common/ac_surface_modifier_test.c b/src/amd/common/ac_surface_modifier_test.c index e41043e2222..a2146d8c15f 100644 --- a/src/amd/common/ac_surface_modifier_test.c +++ b/src/amd/common/ac_surface_modifier_test.c @@ -17,7 +17,7 @@ #include "util/mesa-sha1.h" #include "addrlib/inc/addrinterface.h" -#include "ac_surface_test_common.h" +#include "ac_fake_hw_db.h" /* * The main goal of this test is making sure that we do @@ -463,10 +463,12 @@ int main() struct u_vector test_entries; u_vector_init_pow2(&test_entries, 64, sizeof(struct test_entry)); - for (unsigned i = 0; i < ARRAY_SIZE(testcases); ++i) { - struct radeon_info info = get_radeon_info(&testcases[i]); + for (unsigned i = 0; i < ARRAY_SIZE(ac_fake_hw_db); ++i) { + struct radeon_info info = { .drm_major = 0 }; - run_modifier_test(&test_entries, testcases[i].name, &info); + get_radeon_info(&info, &ac_fake_hw_db[i]); + + run_modifier_test(&test_entries, ac_fake_hw_db[i].name, &info); } qsort(u_vector_tail(&test_entries),