From b73db6c6178a1b76694ad641156c57fa7f7c3ebf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 1 Jul 2021 11:56:44 +0200 Subject: [PATCH] add test options (samples, prefered gpu type) --- FUNDING.yml | 1 + tests/common/test.c | 97 ++++++++++++++++++++++++++++------------- tests/common/vkengine.c | 26 ++++++++--- tests/dashes.c | 74 +++++++++++++++++++------------ tests/fill.c | 2 +- 5 files changed, 134 insertions(+), 66 deletions(-) create mode 100644 FUNDING.yml diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 0000000..253a06e --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1 @@ +custom: "https://www.paypal.me/GrandTetraSoftware" diff --git a/tests/common/test.c b/tests/common/test.c index 0bec4d9..24ddad9 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -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; iproperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) + if (pi->properties.deviceType == preferedPhysicalDeviceType) break; } diff --git a/tests/common/vkengine.c b/tests/common/vkengine.c index d0bdc56..3911014 100644 --- a/tests/common/vkengine.c +++ b/tests/common/vkengine.c @@ -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); diff --git a/tests/dashes.c b/tests/dashes.c index 310d4ae..42a36a1 100644 --- a/tests/dashes.c +++ b/tests/dashes.c @@ -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