From f7ec05a70caa00216527755efa44c948b0f40e04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sun, 21 Nov 2021 00:59:32 +0100 Subject: [PATCH] default gpu selection=prefered,discreet,integrated,phy index0,test help message --- tests/common/rnd.c | 9 +++------ tests/common/rnd.h | 1 - tests/common/test.c | 38 ++++++++++++++++++-------------------- tests/common/vkengine.c | 21 ++++++++++++++------- tests/common/vkengine.h | 1 + vkh | 2 +- 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/tests/common/rnd.c b/tests/common/rnd.c index 6fd3895..410a1ed 100644 --- a/tests/common/rnd.c +++ b/tests/common/rnd.c @@ -1,5 +1,4 @@ -static int _rnd_count = 10000; -static int _cur_rnd = 0; +static int _rnd_count = 9999; static float _rnd[] = { 0.39540747, 0.841546, 0.52073574, 0.80399257, 0.95868486, 0.46164507, 0.5644759, 0.50258803, 0.1953517, 0.40522006, 0.7953865, 0.7795385, 0.6009604, 0.03921096, 0.56872225, 0.93369347, 0.7019503, 0.5392296, 0.2671585, 0.87286836, 0.28110227, @@ -1003,10 +1002,8 @@ static float _rnd[] = { 0.39540747, 0.4205718, 0.2910258, 0.67623764, 0.69533557, 0.33236894, 0.17955771, 0.25711736, 0.5261945, 0.48835787}; float rndf() { + static int _cur_rnd = 0; if (_cur_rnd > _rnd_count) _cur_rnd = 0; - return _rnd[_cur_rnd++]; + return _rnd[_cur_rnd++]; } -float rndf_reset() { - _cur_rnd = 0; -} \ No newline at end of file diff --git a/tests/common/rnd.h b/tests/common/rnd.h index b04c2e8..abf280c 100644 --- a/tests/common/rnd.h +++ b/tests/common/rnd.h @@ -1,2 +1 @@ float rndf(); -float rndf_reset(); \ No newline at end of file diff --git a/tests/common/test.c b/tests/common/test.c index 584f0d3..4fbc818 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -177,16 +177,16 @@ void _print_usage_and_exit () { printf("\t-y height:\tOutput surface height.\n"); printf("\t-S num samples:\tOutput surface filter, default is 1.\n"); printf("\t-g gpu_type:\tSet prefered GPU type:\n"); - printf("\t\t\t\t- 0: Other\n"); - printf("\t\t\t\t- 1: Integrated\n"); - printf("\t\t\t\t- 2: Discrete\n"); - printf("\t\t\t\t- 3: Virtual\n"); - printf("\t\t\t\t- 4: Cpu\n"); + printf("\t\t\t - 0: Other\n"); + printf("\t\t\t - 1: Integrated (second choice)\n"); + printf("\t\t\t - 2: Discrete (first choice)\n"); + printf("\t\t\t - 3: Virtual\n"); + printf("\t\t\t - 4: Cpu\n"); printf("\t-n index:\tRun only a single test, zero based index.\n"); - printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests\n"); - printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs\n"); - printf("\t-vsync:\t\tEnable VSync, disabled by default\n"); - printf("\t-h:\t\t\tthis help message.\n"); + printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests.\n"); + printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs.\n"); + printf("\t-vsync:\t\tEnable VSync, disabled by default.\n"); + printf("\t-h:\t\tThis help message.\n"); printf("\n"); exit(-1); } @@ -369,11 +369,10 @@ void perform_test_offscreen (void(*testfunc)(void), const char *testName, int ar bool deferredResolve = false; VkhPhyInfo* phys = vkh_app_get_phyinfos (app, &phyCount, VK_NULL_HANDLE); VkhPhyInfo pi = 0; - for (uint32_t i=0; iproperties.deviceType == preferedPhysicalDeviceType) - break; - } + if (!vkengine_try_get_phyinfo(phys, phyCount, preferedPhysicalDeviceType, &pi)) + if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, &pi)) + if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) + pi = phys[0]; uint32_t qCount = 0; float qPriorities[] = {0.0}; @@ -517,8 +516,10 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char* vkQueuePresentKHR(r->queue, &present); } #else - if (!paused) - testfunc(); + if (paused) + continue; + + testfunc(); if (deferredResolve) vkvg_multisample_surface_resolve(surf); @@ -532,9 +533,6 @@ void perform_test (void(*testfunc)(void), const char *testName, int argc, char* } #endif - if (paused) - continue; - stop_time = get_tick(); run_time = stop_time - start_time; run_time_values[i] = run_time; @@ -578,7 +576,7 @@ vkvg_line_join_t line_join = VKVG_LINE_JOIN_MITER; float dashes[] = {20.0f, 10.0f}; uint32_t dashes_count= 0; float dash_offset = 0; -float line_width = 10.f; +float line_width = 2.f; VkvgContext _initCtx() { VkvgContext ctx = vkvg_create(surf); diff --git a/tests/common/vkengine.c b/tests/common/vkengine.c index 3911014..d06ed87 100644 --- a/tests/common/vkengine.c +++ b/tests/common/vkengine.c @@ -84,7 +84,15 @@ void vkengine_dump_available_layers () { printf("-----------------\n\n"); free (availableLayers); } - +bool vkengine_try_get_phyinfo (VkhPhyInfo* phys, uint32_t phyCount, VkPhysicalDeviceType gpuType, VkhPhyInfo* phy) { + for (uint32_t i=0; iproperties.deviceType == gpuType) { + *phy = phys[i]; + return true; + } + } + return false; +} vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height) { vk_engine_t* e = (vk_engine_t*)calloc(1,sizeof(vk_engine_t)); @@ -106,7 +114,7 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR const char* enabledLayers[] = {"VK_LAYER_KHRONOS_validation"}; #else const uint32_t enabledLayersCount = 0; - const char* enabledLayers[] = {NULL}; + const char** enabledLayers = NULL; #endif #if defined(DEBUG) && defined (VKVG_DBG_UTILS) enabledExts[enabledExtsCount] = "VK_EXT_debug_utils"; @@ -141,11 +149,10 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR VkhPhyInfo* phys = vkh_app_get_phyinfos (e->app, &phyCount, surf); VkhPhyInfo pi = 0; - for (uint32_t i=0; iproperties.deviceType == preferedGPU) - break; - } + if (!vkengine_try_get_phyinfo(phys, phyCount, preferedGPU, &pi)) + if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, &pi)) + if (!vkengine_try_get_phyinfo(phys, phyCount, VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU, &pi)) + pi = phys[0]; if (pi) { e->memory_properties = pi->memProps; diff --git a/tests/common/vkengine.h b/tests/common/vkengine.h index 7c4e229..9e8b93a 100644 --- a/tests/common/vkengine.h +++ b/tests/common/vkengine.h @@ -50,6 +50,7 @@ typedef struct _vk_engine_t { vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height); void vkengine_dump_available_layers (); +bool vkengine_try_get_phyinfo (VkhPhyInfo* phys, uint32_t phyCount, VkPhysicalDeviceType gpuType, VkhPhyInfo* phy); void vkengine_destroy (VkEngine e); bool vkengine_should_close (VkEngine e); void vkengine_close (VkEngine e); diff --git a/vkh b/vkh index ffa9619..97cdc0f 160000 --- a/vkh +++ b/vkh @@ -1 +1 @@ -Subproject commit ffa9619b5368639c1c765152509d5c7e97876c63 +Subproject commit 97cdc0fb23b33356cc1d4c1be8973891d7661ac5 -- 2.47.3