]> O.S.I.I.S - jp/vkvg.git/commitdiff
default gpu selection=prefered,discreet,integrated,phy index0,test help message
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 20 Nov 2021 23:59:32 +0000 (00:59 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 20 Nov 2021 23:59:32 +0000 (00:59 +0100)
tests/common/rnd.c
tests/common/rnd.h
tests/common/test.c
tests/common/vkengine.c
tests/common/vkengine.h
vkh

index 6fd3895e2c88b06a436a9b2792ab66b532e78e7d..410a1edc8bff40143e8b8c9bd36305d37abf9191 100644 (file)
@@ -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
index b04c2e8eb9d075382654a5238cb205577ee81a60..abf280c92e078fe4efb5c179ca29bed85538be43 100644 (file)
@@ -1,2 +1 @@
 float rndf();
-float rndf_reset();
\ No newline at end of file
index 584f0d3e5a0333641ab74adee054124b50fb3a50..4fbc818cfa1502f746a5e921c6ea59f7921ba6aa 100644 (file)
@@ -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; i<phyCount; i++){
-               pi = phys[i];
-               if (pi->properties.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);
index 39110143cc6b02065cce01c1f5b955cf1d9c2fce..d06ed874dccf457a32fab4205d1cb721bcfa1a98 100644 (file)
@@ -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; i<phyCount; i++){
+               if (phys[i]->properties.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; i<phyCount; i++){
-               pi = phys[i];
-               if (pi->properties.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;
index 7c4e2298e3e3524ee67d257ad2060fcf2c5717cc..9e8b93a50cafd6ef10a91a86752910256627682a 100644 (file)
@@ -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 ffa9619b5368639c1c765152509d5c7e97876c63..97cdc0fb23b33356cc1d4c1be8973891d7661ac5 160000 (submodule)
--- a/vkh
+++ b/vkh
@@ -1 +1 @@
-Subproject commit ffa9619b5368639c1c765152509d5c7e97876c63
+Subproject commit 97cdc0fb23b33356cc1d4c1be8973891d7661ac5