diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2020-07-15 13:48:04 +0200 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2020-07-15 13:48:04 +0200 |
| commit | a77dc464f91da554b5952ea965aa4b65cb0a511f (patch) | |
| tree | 62c72758c7298600aa920a1e7b343670ea207086 /tests/common | |
| parent | e6b3bfbe53dbb850414ec7904b9f00e1aacc330d (diff) | |
copy tests from masternewvx-post-transform
Diffstat (limited to 'tests/common')
| -rw-r--r-- | tests/common/test.c | 528 | ||||
| -rw-r--r-- | tests/common/test.h | 115 | ||||
| -rw-r--r-- | tests/common/vkengine.c | 319 | ||||
| -rw-r--r-- | tests/common/vkengine.h | 4 |
4 files changed, 535 insertions, 431 deletions
diff --git a/tests/common/test.c b/tests/common/test.c index b8de624..e210a2b 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -1,299 +1,427 @@ #include "test.h" +#include "string.h" -float panX = 0.f; -float panY = 0.f; +#if defined(_WIN32) || defined(_WIN64) +int gettimeofday(struct timeval * tp, void * tzp) +{ + // FILETIME Jan 1 1970 00:00:00 + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + + SYSTEMTIME nSystemTime; + FILETIME nFileTime; + uint64_t nTime; + + GetSystemTime( &nSystemTime ); + SystemTimeToFileTime( &nSystemTime, &nFileTime ); + nTime = ((uint64_t)nFileTime.dwLowDateTime ) ; + nTime += ((uint64_t)nFileTime.dwHighDateTime) << 32; + + tp->tv_sec = (long) ((nTime - EPOCH) / 10000000L); + tp->tv_usec = (long) (nSystemTime.wMilliseconds * 1000); + return 0; +} +#endif + +float panX = 0.f; +float panY = 0.f; float lastX = 0.f; float lastY = 0.f; -float zoom = 1.0f; +float zoom = 1.0f; bool mouseDown = false; -VkvgDevice device = NULL; -VkvgSurface surf = NULL; +VkvgDevice device = NULL; +VkvgSurface surf = NULL; + +uint32_t test_size = 100; // items drawn in one run, or complexity +uint32_t iterations = 1000;// repeat test n times +uint32_t test_width = 1024; +uint32_t test_height= 768; +bool test_vsync = false; -uint test_size = 100; // items drawn in one run, or complexity -int iterations = 40000; // repeat test n times static bool paused = false; -static VkSampleCountFlags samples = VK_SAMPLE_COUNT_4_BIT; +static VkSampleCountFlags samples = VK_SAMPLE_COUNT_8_BIT; static vk_engine_t* e; static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { - if (action != GLFW_PRESS) - return; - switch (key) { - case GLFW_KEY_SPACE: - paused = !paused; - break; - case GLFW_KEY_ESCAPE : - glfwSetWindowShouldClose(window, GLFW_TRUE); - break; - } + if (action != GLFW_PRESS) + return; + switch (key) { + case GLFW_KEY_SPACE: + paused = !paused; + break; + case GLFW_KEY_ESCAPE : + glfwSetWindowShouldClose(window, GLFW_TRUE); + break; + } } static void char_callback (GLFWwindow* window, uint32_t c){} static void mouse_move_callback(GLFWwindow* window, double x, double y){ - if (mouseDown) { - panX += ((float)x-lastX); - panY += ((float)y-lastY); - } - lastX = (float)x; - lastY = (float)y; + if (mouseDown) { + panX += ((float)x-lastX); + panY += ((float)y-lastY); + } + lastX = (float)x; + lastY = (float)y; } static void scroll_callback(GLFWwindow* window, double x, double y){ - if (y<0.f) - zoom *= 0.5f; - else - zoom *= 2.0f; + if (y<0.f) + zoom *= 0.5f; + else + zoom *= 2.0f; } static void mouse_button_callback(GLFWwindow* window, int but, int state, int modif){ - if (but != GLFW_MOUSE_BUTTON_1) - return; - if (state == GLFW_TRUE) - mouseDown = true; - else - mouseDown = false; + if (but != GLFW_MOUSE_BUTTON_1) + return; + if (state == GLFW_TRUE) + mouseDown = true; + else + mouseDown = false; } double time_diff(struct timeval x , struct timeval y) { - double x_ms , y_ms , diff; + double x_ms , y_ms , diff; - x_ms = (double)x.tv_sec*1000000 + (double)x.tv_usec; - y_ms = (double)y.tv_sec*1000000 + (double)y.tv_usec; + x_ms = (double)x.tv_sec*1000000 + (double)x.tv_usec; + y_ms = (double)y.tv_sec*1000000 + (double)y.tv_usec; - diff = (double)y_ms - (double)x_ms; + diff = (double)y_ms - (double)x_ms; - return diff; + return diff; } void randomize_color (VkvgContext ctx) { - vkvg_set_source_rgba(ctx, - (float)rand()/RAND_MAX, - (float)rand()/RAND_MAX, - (float)rand()/RAND_MAX, - (float)rand()/RAND_MAX - ); - //vkvg_set_source_color(ctx,(uint32_t) rand()); + vkvg_set_source_rgba(ctx, + (float)rand()/RAND_MAX, + (float)rand()/RAND_MAX, + (float)rand()/RAND_MAX, + (float)rand()/RAND_MAX + ); } /* from caskbench */ double get_tick (void) { - struct timeval now; - gettimeofday (&now, NULL); - return (double)now.tv_sec + (double)now.tv_usec / 1000000.0; + struct timeval now; + gettimeofday (&now, NULL); + return (double)now.tv_sec + (double)now.tv_usec / 1000000.0; } double median_run_time (double data[], int n) { - double temp; - int i, j; - for (i = 0; i < n; i++) - for (j = i+1; j < n; j++) - { - if (data[i] > data[j]) - { - temp = data[j]; - data[j] = data[i]; - data[i] = temp; - } - } - if (n % 2 == 0) - return (data[n/2] + data[n/2-1])/2; - else - return data[n/2]; + double temp; + int i, j; + for (i = 0; i < n; i++) + for (j = i+1; j < n; j++) + { + if (data[i] > data[j]) + { + temp = data[j]; + data[j] = data[i]; + data[i] = temp; + } + } + if (n % 2 == 0) + return (data[n/2] + data[n/2-1])/2; + else + return data[n/2]; } double standard_deviation (const double data[], int n, double mean) { - double sum_deviation = 0.0; - for (int i = 0; i < n; ++i) - sum_deviation += (data[i]-mean) * (data[i]-mean); - return sqrt (sum_deviation / n); + double sum_deviation = 0.0; + int i; + for (i = 0; i < n; ++i) + sum_deviation += (data[i]-mean) * (data[i]-mean); + return sqrt (sum_deviation / n); } /***************/ -void init_test (uint width, uint height){ - e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height); - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); - - bool deferredResolve = false; +void init_test (uint32_t width, uint32_t height){ + if (test_vsync) + e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, width, height); + else + e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height); - device = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, samples, deferredResolve); + VkhPresenter r = e->renderer; + vkengine_set_key_callback (e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); - vkvg_device_set_dpy(device, 96, 96); + bool deferredResolve = false; - surf = vkvg_surface_create(device, width, height); - - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height); -} -void run_test_func (void(*testfunc)(void),uint width, uint height) { - bool deferredResolve = false; - VkhPresenter r = e->renderer; + device = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, samples, deferredResolve); - double start_time, stop_time, run_time, run_total, min_run_time = -1, max_run_time; - double run_time_values[iterations]; + vkvg_device_set_dpy(device, 96, 96); - int i = 0; + surf = vkvg_surface_create(device, width, height); - while (!vkengine_should_close (e) && i < iterations) { - glfwPollEvents(); - - start_time = get_tick(); - - if (!paused) - testfunc(); - - if (deferredResolve) - vkvg_multisample_surface_resolve(surf); - if (!vkh_presenter_draw (r)) - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height); - - vkDeviceWaitIdle(e->dev->dev); - - stop_time = get_tick(); - run_time = stop_time - start_time; - run_time_values[i] = run_time; - - if (min_run_time < 0) - min_run_time = run_time; - else - min_run_time = MIN(run_time, min_run_time); - max_run_time = MAX(run_time, max_run_time); - run_total += run_time; - i++; - } - - double avg_run_time = run_total / (double)i; - double med_run_time = median_run_time (run_time_values, i); - double standard_dev = standard_deviation (run_time_values, i, avg_run_time); - double avg_frames_per_second = (1.0 / avg_run_time); - avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; + vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height); +} - printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); +// printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); -} void clear_test () { - vkDeviceWaitIdle(e->dev->dev); + vkDeviceWaitIdle(e->dev->dev); - vkvg_surface_destroy (surf); - vkvg_device_destroy (device); + vkvg_surface_destroy (surf); + vkvg_device_destroy (device); - vkengine_destroy (e); + vkengine_destroy (e); } #ifdef VKVG_TEST_DIRECT_DRAW VkvgSurface* surfaces; #endif -void perform_test (void(*testfunc)(void),uint width, uint height) { - e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height); - VkhPresenter r = e->renderer; - vkengine_set_key_callback (e, key_callback); - vkengine_set_mouse_but_callback(e, mouse_button_callback); - vkengine_set_cursor_pos_callback(e, mouse_move_callback); - vkengine_set_scroll_callback(e, scroll_callback); +void perform_test (void(*testfunc)(void), const char *testName, int argc, char* argv[]) { + //init random gen + struct timeval currentTime; + gettimeofday(¤tTime, NULL); + srand((unsigned) currentTime.tv_usec); + + //dumpLayerExts(); + if (argc > 1) + iterations = atoi (argv[1]); + if (argc > 2) + test_size = atoi (argv[2]); + if (iterations == 0 || test_size == 0) { + printf("usage: test [iterations] [size]\n"); + return; + } - bool deferredResolve = false; + char* whoami; + (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]); - device = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, samples, deferredResolve); + if (test_vsync) + e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_FIFO_KHR, test_width, test_height); + else + e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, test_width, test_height); - vkvg_device_set_dpy(device, 96, 96); + VkhPresenter r = e->renderer; + vkengine_set_key_callback (e, key_callback); + vkengine_set_mouse_but_callback(e, mouse_button_callback); + vkengine_set_cursor_pos_callback(e, mouse_move_callback); + vkengine_set_scroll_callback(e, scroll_callback); + + bool deferredResolve = false; + + device = vkvg_device_create_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, samples, deferredResolve); + + vkvg_device_set_dpy(device, 96, 96); #ifdef VKVG_TEST_DIRECT_DRAW - surfaces = (VkvgSurface*)malloc(r->imgCount * sizeof (VkvgSurface)); - for (uint i=0; i < r->imgCount;i++) - surfaces[i] = vkvg_surface_create_for_VkhImage (device, r->ScBuffers[i]); + surfaces = (VkvgSurface*)malloc(r->imgCount * sizeof (VkvgSurface)); + for (uint32_t i=0; i < r->imgCount;i++) + surfaces[i] = vkvg_surface_create_for_VkhImage (device, r->ScBuffers[i]); #else - surf = vkvg_surface_create(device, width, height); - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); #endif - double start_time = 0, stop_time = 0, run_time = 0, run_total = 0, min_run_time = -1, max_run_time = 0; - double run_time_values[iterations]; + double start_time = 0.0, stop_time = 0.0, run_time = 0.0, run_total = 0.0, min_run_time = -1, max_run_time = 0.0; + double* run_time_values = (double*)malloc(iterations*sizeof(double)); - int i = 0; + uint32_t i = 0; - while (!vkengine_should_close (e) && i < iterations) { - glfwPollEvents(); + vkengine_set_title(e, testName); - start_time = get_tick(); + while (!vkengine_should_close (e) && i < iterations) { + glfwPollEvents(); + + start_time = get_tick(); #ifdef VKVG_TEST_DIRECT_DRAW - if (!vkh_presenter_acquireNextImage(r, NULL, NULL)) { - for (uint i=0; i < r->imgCount;i++) - vkvg_surface_destroy (surfaces[i]); + if (!vkh_presenter_acquireNextImage(r, NULL, NULL)) { + for (uint32_t i=0; i < r->imgCount;i++) + vkvg_surface_destroy (surfaces[i]); - vkh_presenter_create_swapchain (r); + vkh_presenter_create_swapchain (r); - for (uint i=0; i < r->imgCount;i++) - surfaces[i] = vkvg_surface_create_for_VkhImage (device, r->ScBuffers[i]); - }else{ - surf = surfaces[r->currentScBufferIndex]; + for (uint32_t i=0; i < r->imgCount;i++) + surfaces[i] = vkvg_surface_create_for_VkhImage (device, r->ScBuffers[i]); + }else{ + surf = surfaces[r->currentScBufferIndex]; - testfunc(); + testfunc(); - if (deferredResolve) - vkvg_multisample_surface_resolve(surf); + if (deferredResolve) + vkvg_multisample_surface_resolve(surf); - VkPresentInfoKHR present = { .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, - .swapchainCount = 1, - .pSwapchains = &r->swapChain, - .pImageIndices = &r->currentScBufferIndex }; + VkPresentInfoKHR present = { .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, + .swapchainCount = 1, + .pSwapchains = &r->swapChain, + .pImageIndices = &r->currentScBufferIndex }; - vkQueuePresentKHR(r->queue, &present); - } + vkQueuePresentKHR(r->queue, &present); + } #else - if (!paused) - testfunc(); + if (!paused) + testfunc(); - if (deferredResolve) - vkvg_multisample_surface_resolve(surf); - if (!vkh_presenter_draw (r)) - vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), width, height); + if (deferredResolve) + vkvg_multisample_surface_resolve(surf); + if (!vkh_presenter_draw (r)){ + vkh_presenter_get_size (r, &test_width, &test_height); + vkvg_surface_destroy (surf); + surf = vkvg_surface_create(device, test_width, test_height); + vkh_presenter_build_blit_cmd (r, vkvg_surface_get_vk_image(surf), test_width, test_height); + vkDeviceWaitIdle(r->dev->dev); + continue; + } #endif - vkDeviceWaitIdle(e->dev->dev); + if (paused) + continue; + + stop_time = get_tick(); + run_time = stop_time - start_time; + run_time_values[i] = run_time; - if (paused) - continue; + if (min_run_time < 0) + min_run_time = run_time; + else + min_run_time = MIN(run_time, min_run_time); + max_run_time = MAX(run_time, max_run_time); + run_total += run_time; + i++; + } - stop_time = get_tick(); - run_time = stop_time - start_time; - run_time_values[i] = run_time; + double avg_run_time = run_total / (double)i; + double med_run_time = median_run_time (run_time_values, i); + double standard_dev = standard_deviation (run_time_values, i, avg_run_time); + double avg_frames_per_second = (1.0 / avg_run_time); + avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; - if (min_run_time < 0) - min_run_time = run_time; - else - min_run_time = MIN(run_time, min_run_time); - max_run_time = MAX(run_time, max_run_time); - run_total += run_time; - i++; - } + free (run_time_values); - double avg_run_time = run_total / (double)i; - double med_run_time = median_run_time (run_time_values, i); - double standard_dev = standard_deviation (run_time_values, i, avg_run_time); - double avg_frames_per_second = (1.0 / avg_run_time); - avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; - printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + //printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + printf ("| %-15s | %-25s | ",whoami + 5, testName); + printf ("%4d | %4d | %7.2f | %6.5f | %6.5f | %6.5f |\n", + test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); - vkDeviceWaitIdle(e->dev->dev); + //printf ("%s size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", whoami+5, test_size, i, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + + vkDeviceWaitIdle(e->dev->dev); #ifdef VKVG_TEST_DIRECT_DRAW - for (uint i=0; i<r->imgCount;i++) - vkvg_surface_destroy (surfaces[i]); + for (uint32_t i=0; i<r->imgCount;i++) + vkvg_surface_destroy (surfaces[i]); - free (surfaces); + free (surfaces); #else - vkvg_surface_destroy (surf); + vkvg_surface_destroy (surf); #endif - vkvg_device_destroy (device); + vkvg_device_destroy (device); + + vkengine_destroy (e); +} +const int star_points[11][2] = { + { 0, 85 }, + { 75, 75 }, + { 100, 10 }, + { 125, 75 }, + { 200, 85 }, + { 150, 125 }, + { 160, 190 }, + { 100, 150 }, + { 40, 190 }, + { 50, 125 }, + { 0, 85 } +}; + +void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact) { + float w = (float)test_width; + float h = (float)test_height; + + float x, y, z, v, r; - vkengine_destroy (e); + randomize_color (ctx); + + switch (shape) { + case SHAPE_LINE: + x = (float)rand()/RAND_MAX * w; + y = (float)rand()/RAND_MAX * h; + z = (float)rand()/RAND_MAX * w; + v = (float)rand()/RAND_MAX * h; + + vkvg_move_to(ctx, x, y); + vkvg_line_to(ctx, z, v); + vkvg_stroke(ctx); + break; + case SHAPE_RECTANGLE: + z = truncf((sizeFact*w*rand()/RAND_MAX)+1.f); + v = truncf((sizeFact*h*rand()/RAND_MAX)+1.f); + x = truncf((w-z)*rand()/RAND_MAX); + y = truncf((h-v)*rand()/RAND_MAX); + + vkvg_rectangle(ctx, x+1, y+1, z, v); + break; + case SHAPE_ROUNDED_RECTANGLE: + z = truncf((sizeFact*w*rand()/RAND_MAX)+1.f); + v = truncf((sizeFact*h*rand()/RAND_MAX)+1.f); + x = truncf((w-z)*rand()/RAND_MAX); + y = truncf((h-v)*rand()/RAND_MAX); + r = truncf((0.2f*z*rand()/RAND_MAX)+1.f); + + if ((r > v / 2) || (r > z / 2)) + r = MIN(v / 2, z / 2); + + vkvg_move_to(ctx, x, y + r); + vkvg_arc(ctx, x + r, y + r, r, (float)M_PI, (float)-M_PI_2); + vkvg_line_to(ctx, x + z - r, y); + vkvg_arc(ctx, x + z - r, y + r, r, (float)-M_PI_2, 0); + vkvg_line_to(ctx, x + z, y + v - r); + vkvg_arc(ctx, x + z - r, y + v - r, r, 0, (float)M_PI_2); + vkvg_line_to(ctx, x + r, y + v); + vkvg_arc(ctx, x + r, y + v - r, r, (float)M_PI_2, (float)M_PI); + vkvg_line_to(ctx, x, y + r); + vkvg_close_path(ctx); + break; + case SHAPE_CIRCLE: + /*x = truncf((float)w * rnd()/RAND_MAX); + y = truncf((float)h * rnd()/RAND_MAX); + v = truncf((float)w * rnd()/RAND_MAX * 0.2f);*/ + x = (float)rand()/RAND_MAX * w; + y = (float)rand()/RAND_MAX * h; + + r = truncf((sizeFact*MIN(w,h)*rand()/RAND_MAX)+1.f); + + /*float r = 0.5f*w*rand()/RAND_MAX; + float x = truncf(0.5f * w*rand()/RAND_MAX + r); + float y = truncf(0.5f * w*rand()/RAND_MAX + r);*/ + + vkvg_arc(ctx, x, y, r, 0, (float)M_PI * 2.0f); + break; + case SHAPE_TRIANGLE: + case SHAPE_STAR: + x = (float)rand()/RAND_MAX * w; + y = (float)rand()/RAND_MAX * h; + z = (float)rand()/RAND_MAX * sizeFact + 0.15f; //scale + + vkvg_move_to (ctx, x+star_points[0][0]*z, y+star_points[0][1]*z); + for (int s=1; s<11; s++) + vkvg_line_to (ctx, x+star_points[s][0]*z, y+star_points[s][1]*z); + vkvg_close_path (ctx); + break; + case SHAPE_RANDOM: + draw_random_shape(ctx, 1 + rand()%4, sizeFact); + break; + } } + +/*void draw_random_shape (VkvgContext ctx, shape_t shape) { + float w = (float)test_width; + float h = (float)test_height; + randomize_color(ctx); + float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f); + float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f); + float x = truncf((w-z)*rand()/RAND_MAX); + float y = truncf((h-v)*rand()/RAND_MAX); + vkvg_rectangle(ctx, x, y, z, v); +}*/ diff --git a/tests/common/test.h b/tests/common/test.h index f916c45..91b6393 100644 --- a/tests/common/test.h +++ b/tests/common/test.h @@ -1,7 +1,10 @@ #include "vkengine.h" -#include "stdio.h" -#include "stdlib.h" -#include "time.h" +#include <stdio.h> +#include <stdlib.h> +#define _USE_MATH_DEFINES +#include <math.h> +#include <time.h> + #include "vkvg.h" #include "vkh_device.h" @@ -18,64 +21,59 @@ # define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif -#ifdef _WIN32 // MSC_VER - #define WIN32_LEAN_AND_MEAN - #define NOMINMAX - #include <Windows.h> // Windows.h -> WinDef.h defines min() max() - - /* - typedef uint16_t WORD ; - typedef uint32_t DWORD; - - typedef struct _FILETIME { - DWORD dwLowDateTime; - DWORD dwHighDateTime; - } FILETIME; - - typedef struct _SYSTEMTIME { - WORD wYear; - WORD wMonth; - WORD wDayOfWeek; - WORD wDay; - WORD wHour; - WORD wMinute; - WORD wSecond; - WORD wMilliseconds; - } SYSTEMTIME, *PSYSTEMTIME; - */ +#define PERFORM_TEST(testName, argc, argv) perform_test(testName, #testName, argc, argv); +#if defined(_WIN32) || defined(_WIN64) + #define WIN32_LEAN_AND_MEAN + #define NOMINMAX + #include <Windows.h> // Windows.h -> WinDef.h defines min() max() - // *sigh* Microsoft has this in winsock2.h because they are too lazy to put it in the standard location ... !?!? - typedef struct timeval { - long tv_sec; - long tv_usec; - } timeval; + /* + typedef uint16_t WORD ; + typedef uint32_t DWORD; - // *sigh* no gettimeofday on Win32/Win64 - int gettimeofday(struct timeval * tp, struct timezone * tzp) - { - // FILETIME Jan 1 1970 00:00:00 - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + typedef struct _FILETIME { + DWORD dwLowDateTime; + DWORD dwHighDateTime; + } FILETIME; - SYSTEMTIME nSystemTime; - FILETIME nFileTime; - uint64_t nTime; + typedef struct _SYSTEMTIME { + WORD wYear; + WORD wMonth; + WORD wDayOfWeek; + WORD wDay; + WORD wHour; + WORD wMinute; + WORD wSecond; + WORD wMilliseconds; + } SYSTEMTIME, *PSYSTEMTIME; + */ - GetSystemTime( &nSystemTime ); - SystemTimeToFileTime( &nSystemTime, &nFileTime ); - nTime = ((uint64_t)nFileTime.dwLowDateTime ) ; - nTime += ((uint64_t)nFileTime.dwHighDateTime) << 32; + // *sigh* Microsoft has this in winsock2.h because they are too lazy to put it in the standard location ... !?!? + typedef struct timeval { + long tv_sec; + long tv_usec; + } timeval; - tp->tv_sec = (long) ((nTime - EPOCH) / 10000000L); - tp->tv_usec = (long) (nSystemTime.wMilliseconds * 1000); - return 0; - } + // *sigh* no gettimeofday on Win32/Win64 + int gettimeofday(struct timeval * tp, void * tzp); #else - #include <sys/time.h> -#endif // _WIN32 + #include <sys/time.h> +#endif + +typedef enum _shape_t { + SHAPE_LINE, + SHAPE_RECTANGLE, + SHAPE_ROUNDED_RECTANGLE, + SHAPE_CIRCLE, + SHAPE_TRIANGLE, + SHAPE_STAR, + SHAPE_RANDOM, +} shape_t; -extern uint test_size; -extern int iterations; +extern uint32_t test_size; +extern uint32_t iterations; +extern uint32_t test_width; +extern uint32_t test_height; extern float panX; extern float panY; @@ -88,10 +86,11 @@ extern VkvgDevice device; extern VkvgSurface surf; //run test in one step -void perform_test (void(*testfunc)(void),uint width, uint height); -void randomize_color (VkvgContext ctx); +void perform_test (void(*testfunc)(), const char* testName, int argc, char *argv[]); + +void randomize_color (VkvgContext ctx); +void draw_random_shape (VkvgContext ctx, shape_t shape, float sizeFact); //run test in 3 step: init, run, clear. -void init_test (uint width, uint height); -void run_test_func (void(*testfunc)(void),uint width, uint height); +void init_test (uint32_t width, uint32_t height); void clear_test (); diff --git a/tests/common/vkengine.c b/tests/common/vkengine.c index 6e8157e..9aac16b 100644 --- a/tests/common/vkengine.c +++ b/tests/common/vkengine.c @@ -29,261 +29,234 @@ #include "vkh_device.h" bool vkeCheckPhyPropBlitSource (VkEngine e) { - VkFormatProperties formatProps; - vkGetPhysicalDeviceFormatProperties(e->dev->phy, e->renderer->format, &formatProps); - + VkFormatProperties formatProps; + vkGetPhysicalDeviceFormatProperties(e->dev->phy, e->renderer->format, &formatProps); #ifdef VKVG_TILING_OPTIMAL - assert((formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) && "Format cannot be used as transfer source"); + return formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT; #else - assert((formatProps.linearTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) && "Format cannot be used as transfer source"); + return formatProps.linearTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT; #endif } VkSampleCountFlagBits getMaxUsableSampleCount(VkSampleCountFlags counts) { - if (counts & VK_SAMPLE_COUNT_64_BIT) { return VK_SAMPLE_COUNT_64_BIT; } - if (counts & VK_SAMPLE_COUNT_32_BIT) { return VK_SAMPLE_COUNT_32_BIT; } - if (counts & VK_SAMPLE_COUNT_16_BIT) { return VK_SAMPLE_COUNT_16_BIT; } - if (counts & VK_SAMPLE_COUNT_8_BIT) { return VK_SAMPLE_COUNT_8_BIT; } - if (counts & VK_SAMPLE_COUNT_4_BIT) { return VK_SAMPLE_COUNT_4_BIT; } - if (counts & VK_SAMPLE_COUNT_2_BIT) { return VK_SAMPLE_COUNT_2_BIT; } - return VK_SAMPLE_COUNT_1_BIT; + if (counts & VK_SAMPLE_COUNT_64_BIT) { return VK_SAMPLE_COUNT_64_BIT; } + if (counts & VK_SAMPLE_COUNT_32_BIT) { return VK_SAMPLE_COUNT_32_BIT; } + if (counts & VK_SAMPLE_COUNT_16_BIT) { return VK_SAMPLE_COUNT_16_BIT; } + if (counts & VK_SAMPLE_COUNT_8_BIT) { return VK_SAMPLE_COUNT_8_BIT; } + if (counts & VK_SAMPLE_COUNT_4_BIT) { return VK_SAMPLE_COUNT_4_BIT; } + if (counts & VK_SAMPLE_COUNT_2_BIT) { return VK_SAMPLE_COUNT_2_BIT; } + return VK_SAMPLE_COUNT_1_BIT; } void vkengine_dump_Infos (VkEngine e){ - printf("max samples = %d\n", getMaxUsableSampleCount(e->gpu_props.limits.framebufferColorSampleCounts)); - printf("max tex2d size = %d\n", e->gpu_props.limits.maxImageDimension2D); - printf("max tex array layers = %d\n", e->gpu_props.limits.maxImageArrayLayers); - printf("max mem alloc count = %d\n", e->gpu_props.limits.maxMemoryAllocationCount); + printf("max samples = %d\n", getMaxUsableSampleCount(e->gpu_props.limits.framebufferColorSampleCounts)); + printf("max tex2d size = %d\n", e->gpu_props.limits.maxImageDimension2D); + printf("max tex array layers = %d\n", e->gpu_props.limits.maxImageArrayLayers); + printf("max mem alloc count = %d\n", e->gpu_props.limits.maxMemoryAllocationCount); - for (uint32_t i = 0; i < e->memory_properties.memoryHeapCount; i++) { - printf("Mem Heap %d\n", i); - printf("\tflags= %d\n", e->memory_properties.memoryHeaps[i].flags); - printf("\tsize = %lu Mo\n", e->memory_properties.memoryHeaps[i].size/ (uint32_t)(1024*1024)); - } - for (uint32_t i = 0; i < e->memory_properties.memoryTypeCount; i++) { - printf("Mem type %d\n", i); - printf("\theap %d: ", e->memory_properties.memoryTypes[i].heapIndex); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) - printf("VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) - printf("VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) - printf("VK_MEMORY_PROPERTY_HOST_COHERENT_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) - printf("VK_MEMORY_PROPERTY_HOST_CACHED_BIT|"); - if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) - printf("VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT|"); - printf("\n"); - } + for (uint32_t i = 0; i < e->memory_properties.memoryHeapCount; i++) { + printf("Mem Heap %d\n", i); + printf("\tflags= %d\n", e->memory_properties.memoryHeaps[i].flags); + printf("\tsize = %lu Mo\n", (unsigned long)e->memory_properties.memoryHeaps[i].size/ (uint32_t)(1024*1024)); + } + for (uint32_t i = 0; i < e->memory_properties.memoryTypeCount; i++) { + printf("Mem type %d\n", i); + printf("\theap %d: ", e->memory_properties.memoryTypes[i].heapIndex); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) + printf("VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) + printf("VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) + printf("VK_MEMORY_PROPERTY_HOST_COHERENT_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) + printf("VK_MEMORY_PROPERTY_HOST_CACHED_BIT|"); + if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) + printf("VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT|"); + printf("\n"); + } } void vkengine_dump_available_layers () { - uint32_t layerCount; - vkEnumerateInstanceLayerProperties(&layerCount, NULL); + uint32_t layerCount; + vkEnumerateInstanceLayerProperties(&layerCount, NULL); - VkLayerProperties availableLayers [layerCount]; - vkEnumerateInstanceLayerProperties(&layerCount, availableLayers); + VkLayerProperties* availableLayers = (VkLayerProperties*)malloc(layerCount*sizeof(VkLayerProperties)); + vkEnumerateInstanceLayerProperties(&layerCount, availableLayers); - printf("Available Layers:\n"); - printf("-----------------\n"); - for (uint i=0; i<layerCount; i++) { - printf ("\t - %s\n", availableLayers[i].layerName); - } - printf("-----------------\n\n"); + printf("Available Layers:\n"); + printf("-----------------\n"); + for (uint32_t i=0; i<layerCount; i++) { + printf ("\t - %s\n", availableLayers[i].layerName); + } + printf("-----------------\n\n"); + free (availableLayers); } 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)); + vk_engine_t* e = (vk_engine_t*)calloc(1,sizeof(vk_engine_t)); - glfwInit(); - assert (glfwVulkanSupported()==GLFW_TRUE); + glfwInit(); + assert (glfwVulkanSupported()==GLFW_TRUE); - uint32_t enabledExtsCount = 0, phyCount = 0; - const char** gflwExts = glfwGetRequiredInstanceExtensions (&enabledExtsCount); + uint32_t enabledExtsCount = 0, phyCount = 0; + const char** gflwExts = glfwGetRequiredInstanceExtensions (&enabledExtsCount); - const char* enabledExts [enabledExtsCount+1]; + const char* enabledExts [10]; - for (uint i=0;i<enabledExtsCount;i++) - enabledExts[i] = gflwExts[i]; + for (uint32_t i=0;i<enabledExtsCount;i++) + enabledExts[i] = gflwExts[i]; #ifdef VKVG_USE_RENDERDOC - const uint32_t enabledLayersCount = 2; - const char* enabledLayers[] = {"VK_LAYER_KHRONOS_validation", "VK_LAYER_RENDERDOC_Capture"}; + const uint32_t enabledLayersCount = 2; + const char* enabledLayers[] = {"VK_LAYER_KHRONOS_validation", "VK_LAYER_RENDERDOC_Capture"}; #elif defined (VKVG_USE_VALIDATION) - const uint32_t enabledLayersCount = 1; - const char* enabledLayers[] = {"VK_LAYER_KHRONOS_validation"}; + const uint32_t enabledLayersCount = 1; + const char* enabledLayers[] = {"VK_LAYER_KHRONOS_validation"}; #else - const uint32_t enabledLayersCount = 0; - const char* enabledLayers[] = {NULL}; + const uint32_t enabledLayersCount = 0; + const char* enabledLayers[] = {NULL}; #endif #ifdef DEBUG - enabledExts[enabledExtsCount] = "VK_EXT_debug_utils"; - enabledExtsCount++; + enabledExts[enabledExtsCount] = "VK_EXT_debug_utils"; + enabledExtsCount++; #endif - e->app = vkh_app_create("vkvgTest", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); + e->app = vkh_app_create("vkvgTest", enabledLayersCount, enabledLayers, enabledExtsCount, enabledExts); #ifdef DEBUG - vkh_app_enable_debug_messenger(e->app - , VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT - | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT - , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_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); + vkh_app_enable_debug_messenger(e->app + , VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT + | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT + | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT + , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_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); #endif - glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); - glfwWindowHint(GLFW_FLOATING, GLFW_FALSE); - glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); - - e->window = glfwCreateWindow ((int)width, (int)height, "Window Title", NULL, NULL); + glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE); + glfwWindowHint(GLFW_FLOATING, GLFW_FALSE); + glfwWindowHint(GLFW_DECORATED, GLFW_TRUE); - VkSurfaceKHR surf; - VkResult res = glfwCreateWindowSurface(e->app->inst, e->window, NULL, &surf); + e->window = glfwCreateWindow ((int)width, (int)height, "Window Title", NULL, NULL); - VkhPhyInfo* phys = vkh_app_get_phyinfos (e->app, &phyCount, surf); + VkSurfaceKHR surf; + VK_CHECK_RESULT (glfwCreateWindowSurface(e->app->inst, e->window, NULL, &surf)) - VkhPhyInfo pi = NULL; - for (int i=0; i<phyCount; i++){ - pi = phys[i]; - if (pi->properties.deviceType == preferedGPU) - break; - } + VkhPhyInfo* phys = vkh_app_get_phyinfos (e->app, &phyCount, surf); - e->memory_properties = pi->memProps; - e->gpu_props = pi->properties; + VkhPhyInfo pi = 0; + for (uint32_t i=0; i<phyCount; i++){ + pi = phys[i]; + if (pi->properties.deviceType == preferedGPU) + break; + } - uint32_t qCount = 0; - VkDeviceQueueCreateInfo pQueueInfos[3]; - float queue_priorities[] = {0.0}; + e->memory_properties = pi->memProps; + e->gpu_props = pi->properties; - VkDeviceQueueCreateInfo qiG = { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, - .queueCount = 1, - .queueFamilyIndex = pi->gQueue, - .pQueuePriorities = queue_priorities }; - VkDeviceQueueCreateInfo qiC = { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, - .queueCount = 1, - .queueFamilyIndex = pi->cQueue, - .pQueuePriorities = queue_priorities }; - VkDeviceQueueCreateInfo qiT = { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, - .queueCount = 1, - .queueFamilyIndex = pi->tQueue, - .pQueuePriorities = queue_priorities }; + uint32_t qCount = 0; + float qPriorities[] = {0.0}; - if (pi->gQueue == pi->cQueue){ - if(pi->gQueue == pi->tQueue){ - qCount=1; - pQueueInfos[0] = qiG; - }else{ - qCount=2; - pQueueInfos[0] = qiG; - pQueueInfos[1] = qiT; - } - }else{ - if((pi->gQueue == pi->tQueue) || (pi->cQueue==pi->tQueue)){ - qCount=2; - pQueueInfos[0] = qiG; - pQueueInfos[1] = qiC; - }else{ - qCount=3; - pQueueInfos[0] = qiG; - pQueueInfos[1] = qiC; - pQueueInfos[2] = qiT; - } - } + VkDeviceQueueCreateInfo pQueueInfos[] = { {0},{0},{0} }; + if (vkh_phyinfo_create_presentable_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) + qCount++; + /*if (vkh_phyinfo_create_compute_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) + qCount++; + if (vkh_phyinfo_create_transfer_queues (pi, 1, qPriorities, &pQueueInfos[qCount])) + qCount++;*/ - char const * dex [] = {"VK_KHR_swapchain", "VK_KHR_push_descriptor"}; - enabledExtsCount = 2; + char const * dex [] = {"VK_KHR_swapchain", "VK_KHR_push_descriptor"}; + enabledExtsCount = 2; - VkPhysicalDeviceFeatures enabledFeatures = { - .fillModeNonSolid = true, - //.sampleRateShading = true - }; + VkPhysicalDeviceFeatures enabledFeatures = { + .fillModeNonSolid = true, + //.sampleRateShading = true + }; - VkDeviceCreateInfo device_info = { .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, - .queueCreateInfoCount = qCount, - .pQueueCreateInfos = (VkDeviceQueueCreateInfo*)&pQueueInfos, - .enabledExtensionCount = enabledExtsCount, - .ppEnabledExtensionNames = dex, - .pEnabledFeatures = &enabledFeatures - }; + VkDeviceCreateInfo device_info = { .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, + .queueCreateInfoCount = qCount, + .pQueueCreateInfos = (VkDeviceQueueCreateInfo*)&pQueueInfos, + .enabledExtensionCount = enabledExtsCount, + .ppEnabledExtensionNames = dex, + .pEnabledFeatures = &enabledFeatures}; - e->dev = vkh_device_create(e->app, pi, &device_info); + e->dev = vkh_device_create(e->app, pi, &device_info); - e->renderer = vkh_presenter_create - (e->dev, (uint32_t) pi->pQueue, surf, width, height, VK_FORMAT_B8G8R8A8_UNORM, presentMode); + e->renderer = vkh_presenter_create + (e->dev, (uint32_t) pi->pQueue, surf, width, height, VK_FORMAT_B8G8R8A8_UNORM, presentMode); - vkh_app_free_phyinfos (phyCount, phys); + vkh_app_free_phyinfos (phyCount, phys); - vkeCheckPhyPropBlitSource (e); + vkeCheckPhyPropBlitSource (e); - return e; + return e; } void vkengine_destroy (VkEngine e) { - vkDeviceWaitIdle(e->dev->dev); + vkDeviceWaitIdle(e->dev->dev); - VkSurfaceKHR surf = e->renderer->surface; + VkSurfaceKHR surf = e->renderer->surface; - vkh_presenter_destroy (e->renderer); - vkDestroySurfaceKHR (e->app->inst, surf, NULL); + vkh_presenter_destroy (e->renderer); + vkDestroySurfaceKHR (e->app->inst, surf, NULL); - vkh_device_destroy (e->dev); + vkh_device_destroy (e->dev); - glfwDestroyWindow (e->window); - glfwTerminate (); + glfwDestroyWindow (e->window); + glfwTerminate (); - vkh_app_destroy (e->app); + vkh_app_destroy (e->app); - free(e); + free(e); } void vkengine_close (VkEngine e) { - glfwSetWindowShouldClose(e->window, GLFW_TRUE); + glfwSetWindowShouldClose(e->window, GLFW_TRUE); } void vkengine_blitter_run (VkEngine e, VkImage img, uint32_t width, uint32_t height) { - VkhPresenter p = e->renderer; - vkh_presenter_build_blit_cmd (p, img, width, height); + VkhPresenter p = e->renderer; + vkh_presenter_build_blit_cmd (p, img, width, height); - while (!vkengine_should_close (e)) { - glfwPollEvents(); - if (!vkh_presenter_draw (p)) - vkh_presenter_build_blit_cmd (p, img, width, height); - } + while (!vkengine_should_close (e)) { + glfwPollEvents(); + if (!vkh_presenter_draw (p)) + vkh_presenter_build_blit_cmd (p, img, width, height); + } } -inline bool vkengine_should_close (VkEngine e) { - return glfwWindowShouldClose (e->window); +bool vkengine_should_close (VkEngine e) { + return glfwWindowShouldClose (e->window); +} +void vkengine_set_title (VkEngine e, const char* title) { + glfwSetWindowTitle(e->window, title); } - VkDevice vkengine_get_device (VkEngine e){ - return e->dev->dev; + return e->dev->dev; } VkPhysicalDevice vkengine_get_physical_device (VkEngine e){ - return e->dev->phy; + return e->dev->phy; } VkQueue vkengine_get_queue (VkEngine e){ - return e->renderer->queue; + return e->renderer->queue; } uint32_t vkengine_get_queue_fam_idx (VkEngine e){ - return e->renderer->qFam; + return e->renderer->qFam; } void vkengine_set_key_callback (VkEngine e, GLFWkeyfun key_callback){ - glfwSetKeyCallback (e->window, key_callback); + glfwSetKeyCallback (e->window, key_callback); } void vkengine_set_mouse_but_callback (VkEngine e, GLFWmousebuttonfun onMouseBut){ - glfwSetMouseButtonCallback(e->window, onMouseBut); + glfwSetMouseButtonCallback(e->window, onMouseBut); } void vkengine_set_cursor_pos_callback (VkEngine e, GLFWcursorposfun onMouseMove){ - glfwSetCursorPosCallback(e->window, onMouseMove); + glfwSetCursorPosCallback(e->window, onMouseMove); } void vkengine_set_scroll_callback (VkEngine e, GLFWscrollfun onScroll){ - glfwSetScrollCallback(e->window, onScroll); + glfwSetScrollCallback(e->window, onScroll); } void vkengine_set_char_callback (VkEngine e, GLFWcharfun onChar){ - glfwSetCharCallback(e->window, onChar); + glfwSetCharCallback(e->window, onChar); } diff --git a/tests/common/vkengine.h b/tests/common/vkengine.h index 056be08..7c4e229 100644 --- a/tests/common/vkengine.h +++ b/tests/common/vkengine.h @@ -28,10 +28,13 @@ #include <stdbool.h> #include <GLFW/glfw3.h> +#undef APIENTRY + #include <vulkan/vulkan.h> #include "vkh.h" + #define FENCE_TIMEOUT 100000000 typedef struct _vk_engine_t* VkEngine; @@ -51,6 +54,7 @@ void vkengine_destroy (VkEngine e); bool vkengine_should_close (VkEngine e); void vkengine_close (VkEngine e); void vkengine_dump_Infos (VkEngine e); +void vkengine_set_title (VkEngine e, const char* title); VkDevice vkengine_get_device (VkEngine e); VkPhysicalDevice vkengine_get_physical_device(VkEngine e); VkQueue vkengine_get_queue (VkEngine e); |