]> O.S.I.I.S - jp/vkvg.git/commitdiff
add test options (samples, prefered gpu type)
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 1 Jul 2021 09:56:44 +0000 (11:56 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 1 Jul 2021 09:56:44 +0000 (11:56 +0200)
FUNDING.yml [new file with mode: 0644]
tests/common/test.c
tests/common/vkengine.c
tests/dashes.c
tests/fill.c

diff --git a/FUNDING.yml b/FUNDING.yml
new file mode 100644 (file)
index 0000000..253a06e
--- /dev/null
@@ -0,0 +1 @@
+custom: "https://www.paypal.me/GrandTetraSoftware"
index 0bec4d94aea0a3027f0cf1dcd280f1bbc00ef6e4..24ddad9ff3fe0eeb57b69d0713abc92729fbe1c9 100644 (file)
@@ -169,12 +169,19 @@ void clear_test () {
 #ifdef VKVG_TEST_DIRECT_DRAW
 VkvgSurface* surfaces;
 #endif
-_print_usage_and_exit () {
+void _print_usage_and_exit () {
        printf("\nUsage: test [options]\n\n");
        printf("\t-i iterations:\tSpecify the repeat count for the test.\n");
        printf("\t-s size:\tWhen applicable, specify the size of the test.\n");
-       printf("\t-w width:\tOutput surface width.\n");
-       printf("\t-h height:\tOutput surface height.\n");
+       printf("\t-x width:\tOutput surface width.\n");
+       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-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");
@@ -184,32 +191,13 @@ _print_usage_and_exit () {
        exit(-1);
 }
 void _parse_args (int argc, char* argv[]) {
+       bool printTestDetailsAndExit = false;
        for (int i = 1; i < argc; i++) {
-               if (strcmp (argv[i], "-help\0") == 0)
+               if (strcmp (argv[i], "-h\0") == 0)
                        _print_usage_and_exit ();
-               if (strcmp (argv[i], "-p\0") == 0) {
-                       #ifdef DEBUG
-                       printf("Debug build\n");
-                       #else
-                       printf("Release build\n");
-                       #endif
-                       #ifdef VKVG_USE_RENDERDOC
-                       printf("Render doc enabled\n");
-                       #endif
-                       #ifdef VKVG_USE_VALIDATION
-                       printf("Validation enabled\n");
-                       #endif
-                       printf("surf dims:\t%d x %d\n", test_width, test_height);
-                       printf("Samples:\t%d\n", samples);
-                       #ifdef VKVG_TEST_OFFSCREEN
-                       printf("Offscreen:\ttrue\n");
-                       #else
-                       printf("Offscreen:\ttrue\n");
-                       #endif
-                       printf("\n");
-                       exit(0);        
-               }
-               if (strcmp (argv[i], "-vsync\0") == 0)
+               if (strcmp (argv[i], "-p\0") == 0)
+                       printTestDetailsAndExit = true;
+               else if (strcmp (argv[i], "-vsync\0") == 0)
                        test_vsync = true;              
                else if (strcmp (argv[i], "-q\0") == 0)
                        quiet = true;
@@ -217,11 +205,11 @@ void _parse_args (int argc, char* argv[]) {
                        if (argc -1 < ++i)
                                _print_usage_and_exit();
                        iterations = atoi (argv[i]);
-               }else if (strcmp (argv[i], "-w\0") == 0) {
+               }else if (strcmp (argv[i], "-x\0") == 0) {
                        if (argc -1 < ++i)
                                _print_usage_and_exit();
                        test_width = atoi (argv[i]);
-               }else if (strcmp (argv[i], "-h\0") == 0) {
+               }else if (strcmp (argv[i], "-y\0") == 0) {
                        if (argc -1 < ++i)
                                _print_usage_and_exit();
                        test_height = atoi (argv[i]);
@@ -233,6 +221,55 @@ void _parse_args (int argc, char* argv[]) {
                        if (argc -1 < ++i)
                                _print_usage_and_exit();
                        test_size = atoi (argv[i]);                     
+               }else if (strcmp (argv[i], "-S\0") == 0) {
+                       if (argc -1 < ++i)
+                               _print_usage_and_exit();
+                       samples = (VkSampleCountFlags)atoi (argv[i]);
+               }else if (strcmp (argv[i], "-g\0") == 0) {
+                       if (argc -1 < ++i)
+                               _print_usage_and_exit();
+                       preferedPhysicalDeviceType = (VkPhysicalDeviceType)atoi (argv[i]);
+               }
+               if (printTestDetailsAndExit) {
+                       #ifdef DEBUG
+                       printf("Debug build\n");
+                       #else
+                       printf("Release build\n");
+                       #endif
+                       #ifdef VKVG_USE_RENDERDOC
+                       printf("Render doc enabled\n");
+                       #endif
+                       #ifdef VKVG_USE_VALIDATION
+                       printf("Validation enabled\n");
+                       #endif
+                       printf("surf dims:\t%d x %d\n", test_width, test_height);
+                       printf("Samples:\t%d\n", samples);
+                       printf("Gpu type:\t");
+                       switch (preferedPhysicalDeviceType) {
+                       case VK_PHYSICAL_DEVICE_TYPE_OTHER:
+                               printf("Other\n");
+                               break;
+                       case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
+                               printf("Integrated\n");
+                               break;
+                       case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
+                               printf("Discrete\n");
+                               break;
+                       case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
+                               printf("Virtual\n");
+                               break;
+                       case VK_PHYSICAL_DEVICE_TYPE_CPU:
+                               printf("CPU\n");
+                               break;
+                       }
+
+                       #ifdef VKVG_TEST_OFFSCREEN
+                       printf("Offscreen:\ttrue\n");
+                       #else
+                       printf("Offscreen:\tfalse\n");
+                       #endif
+                       printf("\n");
+                       exit(0);
                }
        }
 }
@@ -334,7 +371,7 @@ void perform_test_offscreen (void(*testfunc)(void), const char *testName, int ar
        VkhPhyInfo pi = 0;
        for (uint32_t i=0; i<phyCount; i++){
                pi = phys[i];
-               if (pi->properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU)
+               if (pi->properties.deviceType == preferedPhysicalDeviceType)
                        break;
        }
 
index d0bdc563715912856d5db1afc785535850609ceb..39110143cc6b02065cce01c1f5b955cf1d9c2fce 100644 (file)
@@ -67,6 +67,8 @@ void vkengine_dump_Infos (VkEngine e){
        }
 }
 
+
+
 void vkengine_dump_available_layers () {
        uint32_t layerCount;
        vkEnumerateInstanceLayerProperties(&layerCount, NULL);
@@ -110,7 +112,8 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
        enabledExts[enabledExtsCount] = "VK_EXT_debug_utils";
        enabledExtsCount++;
 #endif
-
+       /*enabledExts[enabledExtsCount] = "VK_KHR_get_physical_device_properties2";
+       enabledExtsCount++;*/
 
        e->app = vkh_app_create("vkvgTest", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts);
 #if defined(DEBUG) && defined (VKVG_DBG_UTILS)
@@ -119,7 +122,7 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
                                                                   //| VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT
                                                                   //| VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT
                                                                   , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT
-                                                                  //cma| VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
+                                                                  //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
                                                                   //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
                                                                   //| VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT
                                                                   , NULL);
@@ -144,8 +147,10 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
                        break;
        }
 
-       e->memory_properties = pi->memProps;
-       e->gpu_props = pi->properties;
+       if (pi) {
+               e->memory_properties = pi->memProps;
+               e->gpu_props = pi->properties;
+       }
 
        uint32_t qCount = 0;
        float qPriorities[] = {0.0};
@@ -158,8 +163,15 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
        if (vkh_phyinfo_create_transfer_queues          (pi, 1, qPriorities, &pQueueInfos[qCount]))
                qCount++;*/
 
-       char const * dex [] = {"VK_KHR_swapchain"};
-       enabledExtsCount = 1;
+       enabledExtsCount=0;
+
+       enabledExts[enabledExtsCount] = "VK_KHR_swapchain";
+       enabledExtsCount++;
+
+       if (vkh_phyinfo_try_get_extension_properties(pi, "VK_EXT_blend_operation_advanced", NULL)) {
+               enabledExts[enabledExtsCount] = "VK_EXT_blend_operation_advanced";
+               enabledExtsCount++;
+       }
 
        VkPhysicalDeviceFeatures enabledFeatures = {
                .fillModeNonSolid = true,
@@ -170,7 +182,7 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
                                                                           .queueCreateInfoCount = qCount,
                                                                           .pQueueCreateInfos = (VkDeviceQueueCreateInfo*)&pQueueInfos,
                                                                           .enabledExtensionCount = enabledExtsCount,
-                                                                          .ppEnabledExtensionNames = dex,
+                                                                          .ppEnabledExtensionNames = enabledExts,
                                                                           .pEnabledFeatures = &enabledFeatures};
 
        e->dev = vkh_device_create(e->app, pi, &device_info);
index 310d4ae0a34320f05e2d7d16255670f4bccecceb..42a36a12e0d39f5b73cc78748b4e60e12b1d42c6 100644 (file)
@@ -1,19 +1,22 @@
 #include "test.h"
 
 void test(){
-       dash_offset += 0.1f;
+       dash_offset += 0.2f;
 
        VkvgContext ctx = vkvg_create(surf);
        vkvg_clear(ctx);
+       vkvg_set_source_rgb(ctx, 1, 1, 1);
+       vkvg_paint(ctx);
        //const float dashes[] = {160.0f, 80};
-       float dashes[] = {700.0f, 30};
-       //const float dashes[] = {50, 40};
+       //float dashes[] = {7.0f, 3};
+       float dashes[] = {100, 20, 20, 20};
        vkvg_set_line_cap(ctx, VKVG_LINE_CAP_ROUND);
-       vkvg_set_dash(ctx, dashes, 2, dash_offset);
-       vkvg_set_line_width(ctx, 20);
+       vkvg_set_line_join(ctx, VKVG_LINE_JOIN_ROUND);
+       vkvg_set_dash(ctx, dashes, 4, dash_offset);
+       vkvg_set_line_width(ctx, 4);
        vkvg_set_source_rgb(ctx, 0, 0, 1);
 
-       vkvg_move_to (ctx, 150, 50);
+       vkvg_move_to (ctx, 50, 50);
        vkvg_rel_line_to (ctx, 500, 0);
        vkvg_rel_line_to (ctx, 0, 200);
        vkvg_rel_line_to (ctx, 200, 0);
@@ -23,12 +26,12 @@ void test(){
        vkvg_stroke (ctx);
 
        dashes[0] = 0;
-       dashes[1] = 30;
+       dashes[1] = 20;
        vkvg_set_dash(ctx, dashes, 2, dash_offset);
 
        vkvg_set_source_rgb(ctx, 0, 1, 0);
 
-       vkvg_move_to (ctx, 200, 100);
+       vkvg_move_to (ctx, 100, 100);
        vkvg_rel_line_to (ctx, 400, 0);
        vkvg_rel_line_to (ctx, 0, 200);
        vkvg_rel_line_to (ctx, 200, 0);
@@ -37,6 +40,19 @@ void test(){
        vkvg_close_path(ctx);
        vkvg_stroke (ctx);
 
+       dashes[0] = 80;
+       dashes[1] = 20;
+
+       vkvg_set_line_width(ctx, 10);
+       vkvg_set_source_rgb(ctx, 1, 0, 0);
+
+       vkvg_set_dash(ctx, dashes, 2, dash_offset);
+
+       vkvg_rectangle(ctx, 200,300,200,200);
+       /*vkvg_move_to(ctx, 200,300);
+       vkvg_rel_line_to(ctx,200,0);*/
+       vkvg_stroke (ctx);
+
        vkvg_destroy(ctx);
 }
 
@@ -60,22 +76,22 @@ void _long_curve () {
 
 }
 void _long_path() {
-    float w = (float)test_width-10;
-    float h = (float)test_height-10;
-
-    VkvgContext ctx = _initCtx();
-
-    randomize_color(ctx);
-    float x1 = w*rndf();
-    float y1 = h*rndf();
-    vkvg_move_to (ctx, x1, y1);
-    for (uint32_t i=0; i<test_size; i++) {
-        x1 = w*rndf();
-        y1 = h*rndf();
-        vkvg_line_to (ctx, x1, y1);
-    }
-    vkvg_stroke (ctx);
-    vkvg_destroy(ctx);
+       float w = (float)test_width-10;
+       float h = (float)test_height-10;
+
+       VkvgContext ctx = _initCtx();
+
+       randomize_color(ctx);
+       float x1 = w*rndf();
+       float y1 = h*rndf();
+       vkvg_move_to (ctx, x1, y1);
+       for (uint32_t i=0; i<test_size; i++) {
+               x1 = w*rndf();
+               y1 = h*rndf();
+               vkvg_line_to (ctx, x1, y1);
+       }
+       vkvg_stroke (ctx);
+       vkvg_destroy(ctx);
 }
 
 void path () {
@@ -90,11 +106,13 @@ int main(int argc, char *argv[]) {
        //PERFORM_TEST(test, argc, argv);
        //vkvg_log_level = VKVG_LOG_ERR|VKVG_LOG_DEBUG|VKVG_LOG_INFO|VKVG_LOG_INFO_PATH|VKVG_LOG_DBG_ARRAYS|VKVG_LOG_FULL;
        dashes_count = 2;
-       dashes[0] = 2;
-       dashes[1] = 3;
-       line_width = 2;
+       dashes[0] = 0;
+       dashes[1] = 10;
+       line_width = 4;
+       //test_size = 50;
        line_cap = VKVG_LINE_CAP_ROUND;
+       PERFORM_TEST(test, argc, argv);
        PERFORM_TEST(path, argc, argv);
-       //PERFORM_TEST(curve, argc, argv);
+       PERFORM_TEST(curve, argc, argv);
        return 0;
 }
index 71f4e0a50291de0cea060de3337262e2b411a2ed..c2ab672808b77a39dab244da079b41f93c7488fb 100644 (file)
@@ -15,7 +15,7 @@ void test(){
        vkvg_rel_line_to(ctx,-190,-50);
        vkvg_close_path(ctx);
 
-       vkvg_stroke(ctx);
+       vkvg_fill(ctx);
 
        vkvg_destroy(ctx);
 }