From a759ac6afbf3d969270bb4c6e7235e9dfd969211 Mon Sep 17 00:00:00 2001 From: j-p Date: Thu, 23 Jan 2020 14:04:02 +0100 Subject: [PATCH] Appveyor (#27) * replace 'uint' with 'uint32_t' for MSVC * appveyor: fix win64 compilation. --- .travis.yml | 4 +- CMakeLists.txt | 75 +++++++++++++++++++-------------- README.md | 3 ++ appveyor.yml | 31 ++++++++++---- cmake/FindFontConfig.cmake | 35 ---------------- cmake/FindGLFW3.cmake | 4 +- cmake/FindHarfBuzz.cmake | 82 +++++++++++++++++++++---------------- src/cross_os.c | 6 +-- src/cross_os.h | 3 +- src/vectors.c | 26 ++++++------ src/vkvg_context.c | 14 +++---- src/vkvg_context_internal.c | 41 ++++++++++--------- src/vkvg_context_internal.h | 2 +- src/vkvg_fonts.c | 16 ++++---- src/vkvg_fonts.h | 4 +- src/vkvg_internal.h | 8 ++++ src/vkvg_surface.c | 8 ++-- tests/common/test.c | 51 +++++++++++++++++------ tests/common/test.h | 41 ++++++------------- tests/common/vkengine.c | 11 +++-- tests/hlines.c | 52 +++++++++++------------ tests/lines.c | 2 +- tests/random_cirles.c | 2 +- tests/random_rects.c | 38 ++++++++--------- vkh | 2 +- 25 files changed, 294 insertions(+), 267 deletions(-) delete mode 100644 cmake/FindFontConfig.cmake diff --git a/.travis.yml b/.travis.yml index 59ec59b..49a9a5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp -dist: xenial +dist: bionic os: - linux @@ -9,7 +9,7 @@ compiler: install: - wget -qO - http://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - - - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.1.106-xenial.list http://packages.lunarg.com/vulkan/1.1.106/lunarg-vulkan-1.1.106-xenial.list + - sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-bionic.list https://packages.lunarg.com/vulkan/lunarg-vulkan-bionic.list - sudo apt -qq update - sudo apt install vulkan-sdk libharfbuzz-dev libfreetype6-dev libfontconfig1-dev # - sudo apt install libglfw3-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index a76a541..091a146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,20 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.9) +CMAKE_MINIMUM_REQUIRED(VERSION 3.14) PROJECT(vkvg VERSION 0.1.1 DESCRIPTION "Vulkan Vector Graphic") INCLUDE(CheckSymbolExists) INCLUDE(CheckIncludeFile) INCLUDE(GNUInstallDirs) +INCLUDE(CMakeDependentOption) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -SET(CMAKE_CXX_FLAGS "-W -Wall -Wno-extra") + +IF (UNIX) + SET(CMAKE_CXX_FLAGS "-Wall -Wno-extra") +ELSEIF(MSVC) + SET(CMAKE_CXX_FLAGS "-W4") +ENDIF() + SET(CMAKE_EXE_LINKER_FLAGS "-lm") IF(NOT CMAKE_BUILD_TYPE) @@ -36,17 +43,14 @@ IF (VKVG_TILING_OPTIMAL) ADD_DEFINITIONS (-DVKVG_TILING_OPTIMAL) ENDIF () -OPTION(VKVG_BUILD_TESTS "build tests with glfw" ON) - set(VULKAN_SDK "$ENV{VULKAN_SDK}" CACHE STRING "LunarG Vulkan SDK path") if (VULKAN_SDK) - set(ENV{VULKAN_SDK} ${VULKAN_SDK}) - SET(vulkanSdkLayerPath "${VULKAN_SDK}/etc/vulkan/explicit_layer.d") - IF (NOT EXISTS "${vulkanSdkLayerPath}") - SET(vulkanSdkLayerPath "${VULKAN_SDK}/etc/explicit_layer.d") - endif () - SET(ENV{VK_LAYER_PATH} "${vulkanSdkLayerPath}") - link_directories("${VULKAN_SDK}/lib") + set(ENV{VULKAN_SDK} ${VULKAN_SDK}) + SET(vulkanSdkLayerPath "${VULKAN_SDK}/etc/vulkan/explicit_layer.d") + IF (NOT EXISTS "${vulkanSdkLayerPath}") + SET(vulkanSdkLayerPath "${VULKAN_SDK}/etc/explicit_layer.d") + endif () + SET(ENV{VK_LAYER_PATH} "${vulkanSdkLayerPath}") endif () if (NOT TARGET vkh_static) @@ -66,13 +70,15 @@ IF (ENABLE_WIRED_FILL) ADD_DEFINITIONS (-DVKVG_WIRED_DEBUG) ENDIF () -#be aware that system libraries have priority on SDK in the finding. FIND_PACKAGE(Vulkan REQUIRED) -FIND_PACKAGE(GLFW3) FIND_PACKAGE(Freetype REQUIRED) -FIND_PACKAGE(FontConfig REQUIRED) +FIND_PACKAGE(Fontconfig REQUIRED) FIND_PACKAGE(HarfBuzz REQUIRED) +FIND_PACKAGE(GLFW3) + +CMAKE_DEPENDENT_OPTION(VKVG_BUILD_TESTS "build tests with glfw" ON "GLFW3_FOUND" OFF) + #Freetype lcd font filtering #CHECK_SYMBOL_EXISTS (FT_CONFIG_OPTION_SUBPIXEL_RENDERING "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/config/ftoption.h" FT_HAS_SUBPIXEL_RENDERING) #IF (FT_HAS_SUBPIXEL_RENDERING) @@ -150,20 +156,20 @@ FUNCTION (setup_lib LibName) PUBLIC_HEADER include/vkvg.h ) TARGET_INCLUDE_DIRECTORIES(${LibName} PRIVATE - ${Vulkan_INCLUDE_DIRS} - ${FREETYPE_INCLUDE_DIRS} - ${HARFBUZZ_INCLUDE_DIRS} - ${FONTCONFIG_INCLUDE_DIRS} + ${Vulkan_INCLUDE_DIRS} + ${FREETYPE_INCLUDE_DIRS} + ${HarfBuzz_INCLUDE_DIRS} + ${Fontconfig_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/vkh/include ${CMAKE_CURRENT_SOURCE_DIR}/vkh/src ) TARGET_LINK_LIBRARIES(${LibName} - ${Vulkan_LIBRARIES} - ${FREETYPE_LIBRARIES} - ${HARFBUZZ_LIBRARIES} - ${FONTCONFIG_LIBRARIES} + ${Vulkan_LIBRARIES} + ${FREETYPE_LIBRARIES} + ${HarfBuzz_LIBRARIES} + ${Fontconfig_LIBRARIES} vkh_static ) INSTALL(TARGETS ${LibName} @@ -183,7 +189,7 @@ setup_lib ("${PROJECT_NAME}_shared") FUNCTION (buildtest TEST_NAME) ADD_EXECUTABLE(test_${TEST_NAME} "tests/${TEST_NAME}.c" ) TARGET_INCLUDE_DIRECTORIES(test_${TEST_NAME} PRIVATE - ${Vulkan_INCLUDE_DIRS} + ${Vulkan_INCLUDE_DIRS} ${GLFW3_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src @@ -196,11 +202,11 @@ FUNCTION (buildtest TEST_NAME) ) ENDFUNCTION (buildtest) -if (GLFW3_FOUND) +if (VKVG_BUILD_TESTS) ADD_LIBRARY("tests_common" STATIC tests/common/vkengine.c tests/common/test.c) TARGET_INCLUDE_DIRECTORIES(tests_common PRIVATE - ${Vulkan_INCLUDE_DIRS} - ${GLFW3_INCLUDE_DIR} + ${Vulkan_INCLUDE_DIRS} + ${GLFW3_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/tests/common @@ -208,8 +214,8 @@ if (GLFW3_FOUND) ${CMAKE_CURRENT_SOURCE_DIR}/vkh/src ) TARGET_LINK_LIBRARIES(tests_common - ${Vulkan_LIBRARIES} - ${GLFW3_LIBRARY} + ${Vulkan_LIBRARIES} + ${GLFW3_LIBRARY} vkh_static vkvg_static ) @@ -236,10 +242,17 @@ if (GLFW3_FOUND) ENDFOREACH() endif () +MESSAGE(STATUS "HarfBuzz_INCLUDE_DIRS = ${HarfBuzz_INCLUDE_DIRS}") + MESSAGE(STATUS "\n\n--------------------------------------------------------------------------") - MESSAGE(STATUS "Build type\t\t= ${CMAKE_BUILD_TYPE}") - MESSAGE(STATUS "VULKAN_SDK\t\t= $ENV{VULKAN_SDK}") - MESSAGE(STATUS "VK_LAYER_PATH\t= $ENV{VK_LAYER_PATH}") +MESSAGE(STATUS "Build type\t\t= ${CMAKE_BUILD_TYPE}") +MESSAGE(STATUS "VULKAN_SDK\t\t= $ENV{VULKAN_SDK}") +MESSAGE(STATUS "VK_LAYER_PATH\t= $ENV{VK_LAYER_PATH}") +IF (VKVG_BUILD_TESTS) +MESSAGE(STATUS "Build tests\t\t= true.") +ELSE () +MESSAGE(STATUS "Build tests\t\t= false.") +ENDIF () IF (ENABLE_VALIDATION) MESSAGE(STATUS "Validation\t\t= enabled.") ELSE () diff --git a/README.md b/README.md index 3fc979b..db051d1 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ + + + diff --git a/appveyor.yml b/appveyor.yml index f6f37b5..740d293 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,24 @@ -version: 1.0.{build} -image: -- Visual Studio 2015 -- Visual Studio 2017 -- Ubuntu -build: - verbosity: minimal +version: 0.1.{build} + +environment: + VCPKG_DEFAULT_TRIPLET: x64-windows + VULKAN_SDK: C:/VulkanSDK/1.1.130.0 + APPVEYOR_SAVE_CACHE_ON_ERROR: true + +install: + - if not exist VulkanSDK.exe curl -L --silent --show-error --output VulkanSDK.exe https://vulkan.lunarg.com/sdk/download/1.1.130.0/windows/VulkanSDK-1.1.130.0-Installer.exe?Human=true && VulkanSDK.exe /S + - vcpkg install freetype harfbuzz fontconfig glfw3 +cache: + - VulkanSDK.exe + - c:\tools\vcpkg\installed\ + - c:\VulkanSDK\ + +before_build: + - git submodule update --init --recursive + - mkdir build + - cd build + - cmake -G "Visual Studio 14 Win64" -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake .. + +build_script: + - msbuild vkvg.sln /p:Configuration=Debug /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" + diff --git a/cmake/FindFontConfig.cmake b/cmake/FindFontConfig.cmake deleted file mode 100644 index 540aef0..0000000 --- a/cmake/FindFontConfig.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# - Find FontConfig library -# Find the FontConfig includes and library -# This module defines -# FONTCONFIG_INCLUDE_DIR, where to find fontconfig.h -# FONTCONFIG_LIBRARIES, libraries to link against to use the FontConfig API. -# FONTCONFIG_FOUND, If false, do not try to use FontConfig. - -#============================================================================= -# Copyright 2012 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of VTK, substitute the full -# License text for the above reference.) - -find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) - -find_library(FONTCONFIG_LIBRARY NAMES fontconfig) - -# handle the QUIETLY and REQUIRED arguments and set FONTCONFIG_FOUND to TRUE if -# all listed variables are TRUE -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(FontConfig DEFAULT_MSG - FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR) - -if(FONTCONFIG_FOUND) - set( FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY} ) -endif() - -mark_as_advanced(FONTCONFIG_INCLUDE_DIR FONTCONFIG_LIBRARY FONTCONFIG_LIBRARIES) diff --git a/cmake/FindGLFW3.cmake b/cmake/FindGLFW3.cmake index 13bbb84..3fc2eeb 100644 --- a/cmake/FindGLFW3.cmake +++ b/cmake/FindGLFW3.cmake @@ -11,7 +11,7 @@ # installation. # # default search dirs -# +# # Cmake file from: https://github.com/daw42/glslcookbook set( _glfw3_HEADER_SEARCH_DIRS @@ -42,7 +42,7 @@ FIND_PATH(GLFW3_INCLUDE_DIR "GLFW/glfw3.h" PATHS ${_glfw3_HEADER_SEARCH_DIRS} ) # Search for the library -FIND_LIBRARY(GLFW3_LIBRARY NAMES glfw3 glfw +FIND_LIBRARY(GLFW3_LIBRARY NAMES glfw3 glfw glfw3dll PATHS ${_glfw3_LIB_SEARCH_DIRS} ) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW3 DEFAULT_MSG diff --git a/cmake/FindHarfBuzz.cmake b/cmake/FindHarfBuzz.cmake index a348879..c539d97 100644 --- a/cmake/FindHarfBuzz.cmake +++ b/cmake/FindHarfBuzz.cmake @@ -1,46 +1,56 @@ -# Copyright (c) 2012, Intel Corporation +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindHarfBuzz +# ------------ +# +# Find the HarfBuzz text shaping engine includes and library. +# +# Imported Targets +# ^^^^^^^^^^^^^^^^ # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# This module defines the following :prop_tgt:`IMPORTED` target: # -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# * Neither the name of Intel Corporation nor the names of its contributors may -# be used to endorse or promote products derived from this software without -# specific prior written permission. +# ``HarfBuzz::HarfBuzz`` +# The Harfbuzz ``harfbuzz`` library, if found # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# Result Variables +# ^^^^^^^^^^^^^^^^ # -# Try to find Harfbuzz include and library directories. +# This module will set the following variables in your project: # -# After successful discovery, this will set for inclusion where needed: -# HARFBUZZ_INCLUDE_DIRS - containg the HarfBuzz headers -# HARFBUZZ_LIBRARIES - containg the HarfBuzz library +# ``HarfBuzz_FOUND`` +# true if the HarfBuzz headers and libraries were found +# ``HarfBuzz_INCLUDE_DIRS`` +# directories containing the Harfbuzz headers. +# ``HarfBuzz_LIBRARIES`` +# the library to link against -INCLUDE(FindPkgConfig) +find_path(HarfBuzz_INCLUDE_DIR + NAMES harfbuzz/hb.h +) +find_library(HarfBuzz_LIBRARY + NAMES harfbuzz libharfbuzz +) -PKG_CHECK_MODULES(PC_HARFBUZZ harfbuzz>=0.9.0) +# set the user variables +set(HarfBuzz_LIBRARIES "${HarfBuzz_LIBRARY}") -FIND_PATH(HARFBUZZ_INCLUDE_DIRS NAMES hb.h - HINTS ${PC_HARFBUZZ_INCLUDE_DIRS} ${PC_HARFBUZZ_INCLUDEDIR} -) -FIND_LIBRARY(HARFBUZZ_LIBRARIES NAMES harfbuzz - HINTS ${PC_HARFBUZZ_LIBRARY_DIRS} ${PC_HARFBUZZ_LIBDIR} -) +set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY}) +set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(HarfBuzz + DEFAULT_MSG + HarfBuzz_LIBRARY HarfBuzz_INCLUDE_DIR) + +mark_as_advanced(HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(HarfBuzz DEFAULT_MSG HARFBUZZ_INCLUDE_DIRS HARFBUZZ_LIBRARIES) +if(HarfBuzz_FOUND AND NOT TARGET HarfBuzz::HarfBuzz) + add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED) + set_target_properties(HarfBuzz::HarfBuzz PROPERTIES + IMPORTED_LOCATION "${HarfBuzz_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIRS}") +endif() diff --git a/src/cross_os.c b/src/cross_os.c index ba53b6a..80456b2 100644 --- a/src/cross_os.c +++ b/src/cross_os.c @@ -22,11 +22,11 @@ #include "cross_os.h" #include #include -#include +//#include int directoryExists (const char* path) { -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) return getenv("HOME"); #elif __APPLE__ #elif __unix__ @@ -36,7 +36,7 @@ int directoryExists (const char* path) { return -1; } const char* getUserDir () { -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) return getenv("HOME"); #elif __APPLE__ #elif __unix__ diff --git a/src/cross_os.h b/src/cross_os.h index f9932b1..e11e2fb 100644 --- a/src/cross_os.h +++ b/src/cross_os.h @@ -23,8 +23,9 @@ #define CROSS_OS_H //cross platform os helpers -#ifdef _WIN32 +#if defined(_WIN32) || defined(_WIN64) #include "windows.h" +#define isnanf _isnanf #elif __APPLE__ #elif __unix__ #include diff --git a/src/vectors.c b/src/vectors.c index b29180b..422b848 100644 --- a/src/vectors.c +++ b/src/vectors.c @@ -41,11 +41,11 @@ vec2 vec2_line_norm(vec2 a, vec2 b) return d; } // compute length of double vector 2d -inline double vec2d_length(vec2d v){ +double vec2d_length(vec2d v){ return sqrt (v.x*v.x + v.y*v.y); } // compute length of float vector 2d -inline float vec2_length(vec2 v){ +float vec2_length(vec2 v){ return sqrtf (v.x*v.x + v.y*v.y); } // normalize float vector @@ -61,39 +61,39 @@ vec2d vec2d_norm(vec2d a) return (vec2d){a.x/m, a.y/m}; } // multiply 2d vector by scalar -inline vec2d vec2d_mult(vec2d a, double m){ +vec2d vec2d_mult(vec2d a, double m){ return (vec2d){a.x*m,a.y*m}; } // multiply 2d vector by scalar -inline vec2 vec2_mult(vec2 a, float m){ +vec2 vec2_mult(vec2 a, float m){ return (vec2){a.x*m,a.y*m}; } // compute perpendicular vector -inline vec2d vec2d_perp (vec2d a){ +vec2d vec2d_perp (vec2d a){ return (vec2d){a.y, -a.x}; } // compute perpendicular vector -inline vec2 vec2_perp (vec2 a){ +vec2 vec2_perp (vec2 a){ return (vec2){a.y, -a.x}; } // convert double precision vector to single precision -inline vec2 vec2d_to_vec2(vec2d vd){ +vec2 vec2d_to_vec2(vec2d vd){ return (vec2){(float)vd.x,(float)vd.y}; } // compute sum of two single precision vectors -inline vec2 vec2_add (vec2 a, vec2 b){ +vec2 vec2_add (vec2 a, vec2 b){ return (vec2){a.x + b.x, a.y + b.y}; } // compute sum of two double precision vectors -inline vec2d vec2d_add (vec2d a, vec2d b){ +vec2d vec2d_add (vec2d a, vec2d b){ return (vec2d){a.x + b.x, a.y + b.y}; } // compute subbstraction of two single precision vectors -inline vec2 vec2_sub (vec2 a, vec2 b){ +vec2 vec2_sub (vec2 a, vec2 b){ return (vec2){a.x - b.x, a.y - b.y}; } // compute subbstraction of two double precision vectors -inline vec2d vec2d_sub (vec2d a, vec2d b){ +vec2d vec2d_sub (vec2d a, vec2d b){ return (vec2d){a.x - b.x, a.y - b.y}; } // test equality of two single precision vectors @@ -109,10 +109,10 @@ void vec2_inv (vec2* v){ v->y = -v->y; } // test if one component of float vector is nan -inline bool vec2_isnan (vec2 v){ +bool vec2_isnan (vec2 v){ return (bool)(isnanf (v.x) || isnanf (v.y)); } // test if one component of double vector is nan -inline bool vec2d_isnan (vec2d v){ +bool vec2d_isnan (vec2d v){ return (bool)(isnan (v.x) || isnan (v.y)); } diff --git a/src/vkvg_context.c b/src/vkvg_context.c index b42e433..2cdbadc 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Jean-Philippe Bruyère + * Copyright (c) 2018-2020 Jean-Philippe Bruyère * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -49,7 +49,7 @@ VkvgContext vkvg_create(VkvgSurface surf) VkvgDevice dev = surf->dev; VkvgContext ctx = (vkvg_context*)calloc(1, sizeof(vkvg_context)); - LOG(LOG_INFO, "CREATE Context: ctx = %lu; surf = %lu\n", (ulong)ctx, (ulong)surf); + LOG(LOG_INFO, "CREATE Context: ctx = %lu; surf = %lu\n", (uint64_t)ctx, (uint64_t)surf); if (ctx==NULL) { dev->status = VKVG_STATUS_NO_MEMORY; @@ -206,7 +206,7 @@ void vkvg_destroy (VkvgContext ctx) _flush_cmd_buff(ctx); _wait_flush_fence(ctx); - LOG(LOG_INFO, "DESTROY Context: ctx = %lu; surf = %lu\n", (ulong)ctx, (ulong)ctx->pSurf); + LOG(LOG_INFO, "DESTROY Context: ctx = %lu; surf = %lu\n", (uint64_t)ctx, (uint64_t)ctx->pSurf); if (ctx->pattern) vkvg_pattern_destroy (ctx->pattern); @@ -588,12 +588,12 @@ void vkvg_stroke_preserve (VkvgContext ctx) v.uv.z = -1; float hw = ctx->lineWidth / 2.0f; - uint i = 0, ptrPath = 0; + uint32_t i = 0, ptrPath = 0; uint32_t lastPathPointIdx, iL, iR; while (ptrPath < ctx->pathPtr){ - uint ptrCurve = 0; + uint32_t ptrCurve = 0; VKVG_IBO_INDEX_TYPE firstIdx = (VKVG_IBO_INDEX_TYPE)(ctx->vertCount - ctx->curVertOffset); i = ctx->pathes[ptrPath]&PATH_ELT_MASK; @@ -734,7 +734,7 @@ void vkvg_paint (VkvgContext ctx){ _check_cmd_buff_state (ctx); _draw_full_screen_quad (ctx, true); } -inline void vkvg_set_source_rgb (VkvgContext ctx, float r, float g, float b) { +void vkvg_set_source_rgb (VkvgContext ctx, float r, float g, float b) { vkvg_set_source_rgba (ctx, r, g, b, 1); } void vkvg_set_source_rgba (VkvgContext ctx, float r, float g, float b, float a) @@ -867,7 +867,7 @@ void vkvg_font_extents (VkvgContext ctx, vkvg_font_extents_t* extents) { } void vkvg_save (VkvgContext ctx){ - LOG(LOG_INFO, "SAVE CONTEXT: ctx = %lu\n", (ulong)ctx); + LOG(LOG_INFO, "SAVE CONTEXT: ctx = %lu\n", (uint64_t)ctx); _flush_cmd_buff (ctx); _wait_flush_fence (ctx); diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index e1eb2f7..f59aaf9 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -87,26 +87,26 @@ void _check_point_array (VkvgContext ctx){ } //when empty, ptr is even, else it's odd //when empty, no current point is defined. -inline bool _current_path_is_empty (VkvgContext ctx) { +bool _current_path_is_empty (VkvgContext ctx) { return ctx->pathPtr % 2 == 0; } //this function expect that current point exists -inline vec2 _get_current_position (VkvgContext ctx) { +vec2 _get_current_position (VkvgContext ctx) { return ctx->points[ctx->pointCount-1]; } //set curve start point and set path has curve bit -inline void _set_curve_start (VkvgContext ctx) { +void _set_curve_start (VkvgContext ctx) { ctx->pathes[ctx->pathPtr+ctx->curvePtr+1] = (ctx->pointCount - 1); ctx->pathes[ctx->pathPtr-1] |= PATH_HAS_CURVES_BIT; } //set curve end point and set path has curve bit -inline void _set_curve_end (VkvgContext ctx) { +void _set_curve_end (VkvgContext ctx) { ctx->pathes[ctx->pathPtr+ctx->curvePtr+2] = (ctx->pointCount - 1)|PATH_IS_CURVE_BIT; ctx->curvePtr+=2; _check_pathes_array(ctx); } //path start pointed at ptrPath has curve bit -inline bool _path_has_curves (VkvgContext ctx, uint ptrPath) { +bool _path_has_curves (VkvgContext ctx, uint32_t ptrPath) { return ctx->pathes[ptrPath] & PATH_HAS_CURVES_BIT; } //this function expect that current path is empty @@ -138,7 +138,7 @@ void _clear_path (VkvgContext ctx){ ctx->curvePtr = 0; _resetMinMax(ctx); } -inline bool _path_is_closed (VkvgContext ctx, uint32_t ptrPath){ +bool _path_is_closed (VkvgContext ctx, uint32_t ptrPath){ return ctx->pathes[ptrPath] & PATH_CLOSED_BIT; } void _resetMinMax (VkvgContext ctx) { @@ -172,7 +172,7 @@ float _normalizeAngle(float a) else return res; } -inline float _get_arc_step (float radius) { +float _get_arc_step (float radius) { return M_PIF/sqrtf(radius)*0.35f; } void _create_gradient_buff (VkvgContext ctx){ @@ -285,10 +285,10 @@ void _create_cmd_buff (VkvgContext ctx){ void _clear_attachment (VkvgContext ctx) { } -inline void _wait_flush_fence (VkvgContext ctx) { +void _wait_flush_fence (VkvgContext ctx) { vkWaitForFences (ctx->pSurf->dev->vkDev, 1, &ctx->flushFence, VK_TRUE, VKVG_FENCE_TIMEOUT); } -inline void _reset_flush_fence (VkvgContext ctx) { +void _reset_flush_fence (VkvgContext ctx) { vkResetFences (ctx->pSurf->dev->vkDev, 1, &ctx->flushFence); } void _wait_and_submit_cmd (VkvgContext ctx){ @@ -393,7 +393,7 @@ void _record_draw_cmd (VkvgContext ctx){ CmdDrawIndexed(ctx->cmd, ctx->indCount - ctx->curIndStart, 1, ctx->curIndStart, (int32_t)ctx->curVertOffset, 0); LOG(LOG_INFO, "RECORD DRAW CMD: ctx = %lu; vertices = %d; indices = %d (vxOff = %d idxStart = %d idxTot = %d )\n", - (ulong)ctx, ctx->vertCount - ctx->curVertOffset, + (uint64_t)ctx, ctx->vertCount - ctx->curVertOffset, ctx->indCount - ctx->curIndStart, ctx->curVertOffset, ctx->curIndStart, ctx->indCount); #ifdef VKVG_WIRED_DEBUG @@ -439,10 +439,6 @@ void _start_cmd_for_render_pass (VkvgContext ctx) { LOG(LOG_INFO, "START RENDER PASS: ctx = %lu\n", ctx); vkh_cmd_begin (ctx->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); -#ifdef DEBUG - vkh_cmd_label_start(ctx->cmd, "ctx render pass", LAB_COLOR_RP); -#endif - if (ctx->pSurf->img->layout == VK_IMAGE_LAYOUT_UNDEFINED){ VkhImage imgMs = ctx->pSurf->imgMS; if (imgMs != NULL) @@ -455,6 +451,10 @@ void _start_cmd_for_render_pass (VkvgContext ctx) { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); } +#ifdef DEBUG + vkh_cmd_label_start(ctx->cmd, "ctx render pass", LAB_COLOR_RP); +#endif + CmdBeginRenderPass (ctx->cmd, &ctx->renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); VkViewport viewport = {0,0,ctx->pSurf->width,ctx->pSurf->height,0,1}; CmdSetViewport(ctx->cmd, 0, 1, &viewport); @@ -487,7 +487,7 @@ void _set_mat_inv_and_vkCmdPush (VkvgContext ctx) { vkvg_matrix_invert (&ctx->pushConsts.matInv); ctx->pushCstDirty = true; } -inline void _update_push_constants (VkvgContext ctx) { +void _update_push_constants (VkvgContext ctx) { CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(push_constants),&ctx->pushConsts); ctx->pushCstDirty = false; @@ -590,7 +590,7 @@ void _update_cur_pattern (VkvgContext ctx, VkvgPattern pat) { ctx->pushConsts.source = bounds; //transform control point with current ctx matrix - vkvg_gradient_t grad = {}; + vkvg_gradient_t grad = {0}; memcpy(&grad, pat->data, sizeof(vkvg_gradient_t)); vkvg_matrix_transform_point(&ctx->pushConsts.mat, &grad.cp[0].x, &grad.cp[0].y); @@ -1021,7 +1021,7 @@ void _poly_fill (VkvgContext ctx){ VKVG_IBO_INDEX_TYPE firstVertIdx = ctx->vertCount; - for (uint i = 0; i < pathPointCount; i++) { + for (uint32_t i = 0; i < pathPointCount; i++) { v.pos = ctx->points [i+firstPtIdx]; ctx->vertexCache[ctx->vertCount] = v; ctx->vertCount++; @@ -1036,7 +1036,7 @@ void _poly_fill (VkvgContext ctx){ } void _fill_ec (VkvgContext ctx){ uint32_t ptrPath = 0;; - Vertex v = {}; + Vertex v = {0}; v.uv.z = -1; while (ptrPath < ctx->pathPtr){ @@ -1051,7 +1051,7 @@ void _fill_ec (VkvgContext ctx){ uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1; uint32_t firstVertIdx = ctx->vertCount-ctx->curVertOffset; - ear_clip_point ecps[pathPointCount]; + ear_clip_point* ecps = (ear_clip_point*)malloc(pathPointCount*sizeof(ear_clip_point)); uint32_t ecps_count = pathPointCount; uint32_t i = 0; @@ -1106,6 +1106,7 @@ void _fill_ec (VkvgContext ctx){ _add_triangle_indices(ctx, ecp_current->next->idx, ecp_current->idx, ecp_current->next->next->idx); ptrPath+=2; + free (ecps); } _record_draw_cmd(ctx); } @@ -1116,7 +1117,7 @@ void _draw_full_screen_quad (VkvgContext ctx, bool useScissor) { if (ctx->xMin < 0 || ctx->yMin < 0) useScissor = false; if (useScissor && ctx->xMin < FLT_MAX) { - VkRect2D r = {ctx->xMin, ctx->yMin, ctx->xMax - ctx->xMin, ctx->yMax - ctx->yMin}; + VkRect2D r = {{ctx->xMin, ctx->yMin}, {ctx->xMax - ctx->xMin, ctx->yMax - ctx->yMin}}; CmdSetScissor(ctx->cmd, 0, 1, &r); } CmdPushConstants(ctx->cmd, ctx->pSurf->dev->pipelineLayout, diff --git a/src/vkvg_context_internal.h b/src/vkvg_context_internal.h index 63f22dc..4fdc045 100644 --- a/src/vkvg_context_internal.h +++ b/src/vkvg_context_internal.h @@ -179,7 +179,7 @@ void _clear_path (VkvgContext ctx); bool _path_is_closed (VkvgContext ctx, uint32_t ptrPath); void _set_curve_start (VkvgContext ctx); void _set_curve_end (VkvgContext ctx); -bool _path_has_curves (VkvgContext ctx, uint ptrPath); +bool _path_has_curves (VkvgContext ctx, uint32_t ptrPath); float _normalizeAngle (float a); float _get_arc_step (float radius); diff --git a/src/vkvg_fonts.c b/src/vkvg_fonts.c index c993a1e..44a2cdb 100644 --- a/src/vkvg_fonts.c +++ b/src/vkvg_fonts.c @@ -201,7 +201,7 @@ void _dump_glyphs (FT_Face face){ FT_Get_Glyph_Name(face,i,gname,256); - printf("glyph: %s (%d,%d;%d), max advance:%d\n", gname, + printf("glyph: %s (%d,%d;%d), max advance:%ld\n", gname, slot->bitmap.width, slot->bitmap.rows, slot->bitmap.pitch, face->size->metrics.max_advance/64); } @@ -217,7 +217,7 @@ void _flush_chars_to_tex (VkvgDevice dev, _vkvg_font_t* f) { vkResetCommandBuffer(cache->cmd,0); vkResetFences (dev->vkDev,1,&cache->uploadFence); - memcpy(cache->buff.allocInfo.pMappedData, cache->hostBuff, (ulong)(f->curLine.height * FONT_PAGE_SIZE * cache->texPixelSize)); + memcpy(cache->buff.allocInfo.pMappedData, cache->hostBuff, (uint64_t)(f->curLine.height * FONT_PAGE_SIZE * cache->texPixelSize)); vkh_cmd_begin (cache->cmd,VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); @@ -257,10 +257,10 @@ _char_ref* _prepare_char (VkvgDevice dev, _vkvg_font_t* f, FT_UInt gindex){ FT_CHECK_RESULT(FT_Load_Glyph(f->face, gindex, FT_LOAD_RENDER)); #endif - FT_GlyphSlot slot = f->face->glyph; - FT_Bitmap bmp = slot->bitmap; - uint8_t* data = dev->fontCache->hostBuff; - uint bmpWidth = bmp.width; //real width in pixel of char bitmap + FT_GlyphSlot slot = f->face->glyph; + FT_Bitmap bmp = slot->bitmap; + uint8_t* data = dev->fontCache->hostBuff; + uint32_t bmpWidth= bmp.width; //real width in pixel of char bitmap #ifdef VKVG_LCD_FONT_FILTER bmpWidth /= 3; @@ -420,7 +420,7 @@ void _font_extents (VkvgContext ctx, vkvg_font_extents_t *extents) { void _text_extents (VkvgContext ctx, const char* text, vkvg_text_extents_t *extents) { _update_current_font (ctx); - vkvg_text_run_t tr = {}; + vkvg_text_run_t tr = {0}; _create_text_run (ctx, text, &tr); *extents = tr.extents; @@ -532,7 +532,7 @@ void _show_texture (vkvg_context* ctx){ void _show_text (VkvgContext ctx, const char* text){ - vkvg_text_run_t tr = {}; + vkvg_text_run_t tr = {0}; _create_text_run (ctx, text, &tr); _show_text_run (ctx, &tr); diff --git a/src/vkvg_fonts.h b/src/vkvg_fonts.h index c5d560b..02c1c14 100644 --- a/src/vkvg_fonts.h +++ b/src/vkvg_fonts.h @@ -29,8 +29,8 @@ #include #endif -#include -#include +#include +#include #include diff --git a/src/vkvg_internal.h b/src/vkvg_internal.h index d94daf3..a21298e 100644 --- a/src/vkvg_internal.h +++ b/src/vkvg_internal.h @@ -28,10 +28,17 @@ #include #include #include + +#define _USE_MATH_DEFINES #include #define M_PIF 3.14159265358979323846f /* float pi */ #define M_PIF_2 1.57079632679489661923f + +/*#ifndef M_2_PI + #define M_2_PI 0.63661977236758134308 // 2/pi +#endif*/ + #define PATH_CLOSED_BIT 0x80000000 /* most significant bit of path elmts is closed/open path state */ #define PATH_HAS_CURVES_BIT 0x40000000 /* 2d most significant bit of path elmts start = true if curve data are present, stored to avoid emiting join in curves */ @@ -44,6 +51,7 @@ #define ROUND_DOWN(v,p) (floorf(v * p) / p) #define EQUF(a, b) (fabsf(a-b)<=FLT_EPSILON) +#include "cross_os.h" #include "vectors.h" #include "cross_mutex.h" diff --git a/src/vkvg_surface.c b/src/vkvg_surface.c index 9f8ee17..183df2b 100644 --- a/src/vkvg_surface.c +++ b/src/vkvg_surface.c @@ -163,7 +163,9 @@ void _create_framebuffer (VkvgSurface surf) { frameBufferCreateInfo.attachmentCount = 2; } VK_CHECK_RESULT(vkCreateFramebuffer(surf->dev->vkDev, &frameBufferCreateInfo, NULL, &surf->fb)); +#ifdef DEBUG vkh_device_set_object_name((VkhDevice)surf->dev, VK_OBJECT_TYPE_FRAMEBUFFER, (uint64_t)surf->fb, "SURF FB"); +#endif } void _init_surface (VkvgSurface surf) { surf->format = FB_COLOR_FORMAT;//force bgra internally @@ -346,14 +348,12 @@ void _svg_set_color (VkvgContext ctx, uint32_t c, float alpha) { } VkvgSurface _svg_load (VkvgDevice dev, NSVGimage* svg) { - NSVGshape* shape; - NSVGpath* path; VkvgSurface surf = (vkvg_surface*)calloc(1,sizeof(vkvg_surface)); surf->dev = dev; - surf->width = (uint)svg->width; - surf->height = (uint)svg->height; + surf->width = (uint32_t)svg->width; + surf->height = (uint32_t)svg->height; surf->new = true; _init_surface (surf); diff --git a/tests/common/test.c b/tests/common/test.c index ed52bd1..c03de4c 100644 --- a/tests/common/test.c +++ b/tests/common/test.c @@ -1,5 +1,27 @@ #include "test.h" +#if defined(_WIN32) || defined(_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); + + 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; @@ -10,7 +32,7 @@ bool mouseDown = false; VkvgDevice device = NULL; VkvgSurface surf = NULL; -uint test_size = 100; // items drawn in one run, or complexity +uint32_t test_size = 100; // items drawn in one run, or complexity int iterations = 10000; // repeat test n times static bool paused = false; @@ -110,7 +132,7 @@ double standard_deviation (const double data[], int n, double mean) } /***************/ -void init_test (uint width, uint height){ +void init_test (uint32_t width, uint32_t 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); @@ -128,12 +150,12 @@ void init_test (uint width, uint 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) { +void run_test_func (void(*testfunc)(void),uint32_t width, uint32_t height) { bool deferredResolve = false; VkhPresenter r = e->renderer; - double start_time, stop_time, run_time, run_total, min_run_time = -1, max_run_time; - double run_time_values[iterations]; + double start_time, stop_time, run_time, run_total = 0.0, min_run_time = -1, max_run_time; + double* run_time_values = (double*)malloc(iterations*sizeof(double)); int i = 0; @@ -171,8 +193,9 @@ void run_test_func (void(*testfunc)(void),uint width, uint height) { 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, iterations, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); + free (run_time_values); + printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, iterations, avg_frames_per_second, avg_run_time, med_run_time, standard_dev); } void clear_test () { vkDeviceWaitIdle(e->dev->dev); @@ -187,7 +210,7 @@ void clear_test () { VkvgSurface* surfaces; #endif -void perform_test (void(*testfunc)(void),uint width, uint height) { +void perform_test (void(*testfunc)(void),uint32_t width, uint32_t height) { //dumpLayerExts(); e = vkengine_create (VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, VK_PRESENT_MODE_MAILBOX_KHR, width, height); @@ -205,7 +228,7 @@ void perform_test (void(*testfunc)(void),uint width, uint height) { #ifdef VKVG_TEST_DIRECT_DRAW surfaces = (VkvgSurface*)malloc(r->imgCount * sizeof (VkvgSurface)); - for (uint i=0; i < r->imgCount;i++) + 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); @@ -213,8 +236,8 @@ void perform_test (void(*testfunc)(void),uint width, uint height) { #endif - double start_time, stop_time, run_time, run_total, min_run_time = -1, max_run_time; - double run_time_values[iterations]; + double start_time, stop_time, run_time, run_total = 0.0, min_run_time = -1, max_run_time; + double* run_time_values = (double*)malloc(iterations*sizeof(double)); int i = 0; @@ -226,12 +249,12 @@ void perform_test (void(*testfunc)(void),uint width, uint height) { #ifdef VKVG_TEST_DIRECT_DRAW if (!vkh_presenter_acquireNextImage(r, NULL, NULL)) { - for (uint i=0; i < r->imgCount;i++) + for (uint32_t i=0; i < r->imgCount;i++) vkvg_surface_destroy (surfaces[i]); vkh_presenter_create_swapchain (r); - for (uint i=0; i < r->imgCount;i++) + 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]; @@ -282,12 +305,14 @@ void perform_test (void(*testfunc)(void),uint width, uint height) { double avg_frames_per_second = (1.0 / avg_run_time); avg_frames_per_second = (avg_frames_per_second<9999) ? avg_frames_per_second:9999; + free (run_time_values); + printf ("size:%d iter:%d avgFps: %f avg: %4.2f%% med: %4.2f%% sd: %4.2f%% \n", test_size, iterations, 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; iimgCount;i++) + for (uint32_t i=0; iimgCount;i++) vkvg_surface_destroy (surfaces[i]); free (surfaces); diff --git a/tests/common/test.h b/tests/common/test.h index f916c45..74c867a 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 +#include +#define _USE_MATH_DEFINES +#include +#include + #include "vkvg.h" #include "vkh_device.h" @@ -18,7 +21,7 @@ # define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif -#ifdef _WIN32 // MSC_VER +#if defined(_WIN32) || defined(_WIN64) #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include // Windows.h -> WinDef.h defines min() max() @@ -51,30 +54,12 @@ } timeval; // *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); - - 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; - } + int gettimeofday(struct timeval * tp, struct timezone * tzp); #else #include -#endif // _WIN32 +#endif -extern uint test_size; +extern uint32_t test_size; extern int iterations; extern float panX; @@ -88,10 +73,10 @@ extern VkvgDevice device; extern VkvgSurface surf; //run test in one step -void perform_test (void(*testfunc)(void),uint width, uint height); +void perform_test (void(*testfunc)(void),uint32_t width, uint32_t height); void randomize_color (VkvgContext ctx); //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 run_test_func (void(*testfunc)(void),uint32_t width, uint32_t height); void clear_test (); diff --git a/tests/common/vkengine.c b/tests/common/vkengine.c index a33cff4..a090177 100644 --- a/tests/common/vkengine.c +++ b/tests/common/vkengine.c @@ -82,19 +82,18 @@ void vkengine_dump_available_layers () { uint32_t layerCount; vkEnumerateInstanceLayerProperties(&layerCount, NULL); - VkLayerProperties availableLayers [layerCount]; + VkLayerProperties* availableLayers = (VkLayerProperties*)malloc(layerCount*sizeof(VkLayerProperties)); vkEnumerateInstanceLayerProperties(&layerCount, availableLayers); printf("Available Layers:\n"); printf("-----------------\n"); - for (uint i=0; i