]> O.S.I.I.S - jp/vkvg.git/commitdiff
Appveyor (#27)
authorj-p <jp_bruyere@hotmail.com>
Thu, 23 Jan 2020 13:04:02 +0000 (14:04 +0100)
committerGitHub <noreply@github.com>
Thu, 23 Jan 2020 13:04:02 +0000 (14:04 +0100)
* replace 'uint' with 'uint32_t' for MSVC
* appveyor: fix win64 compilation.

25 files changed:
.travis.yml
CMakeLists.txt
README.md
appveyor.yml
cmake/FindFontConfig.cmake [deleted file]
cmake/FindGLFW3.cmake
cmake/FindHarfBuzz.cmake
src/cross_os.c
src/cross_os.h
src/vectors.c
src/vkvg_context.c
src/vkvg_context_internal.c
src/vkvg_context_internal.h
src/vkvg_fonts.c
src/vkvg_fonts.h
src/vkvg_internal.h
src/vkvg_surface.c
tests/common/test.c
tests/common/test.h
tests/common/vkengine.c
tests/hlines.c
tests/lines.c
tests/random_cirles.c
tests/random_rects.c
vkh

index 59ec59b24a6c6a29f69844a41c2d78bc5bcbf354..49a9a5e5792af52406c804d0efa432ea4c2a1370 100644 (file)
@@ -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
index a76a54194aa4a8279593b9ecb4273fd719015606..091a146b767d57b96bd7f2238483182f8352eda6 100644 (file)
@@ -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 ()
index 3fc979ba792ec17acff9f15a401bb80eb1e76fac..db051d1bccc6b80cd18bcfb6c34bf236c502f319 100644 (file)
--- a/README.md
+++ b/README.md
@@ -11,6 +11,9 @@
   <a href="https://travis-ci.org/jpbruyere/vkvg">
        <img src="https://travis-ci.org/jpbruyere/vkvg.svg?branch=master">
   </a>
+  <a href="https://ci.appveyor.com/project/jpbruyere/vkvg">
+       <img src="https://ci.appveyor.com/api/projects/status/github/gruntjs/grunt?branch=master&svg=true">
+  </a>
   <img src="https://img.shields.io/github/license/jpbruyere/vkvg.svg?style=flat-square">
   <a href="https://www.paypal.me/GrandTetraSoftware">
        <img src="https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square">
index f6f37b50802468f71bac481b334d30a262de5eee..740d293dc27c6f456edc2c62459d09f1a33c1063 100644 (file)
@@ -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 (file)
index 540aef0..0000000
+++ /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)
index 13bbb8478153c44154acabc2401d6e51eb0eec50..3fc2eeb35f6fc91fbec4304c0f58bb779a8a1a56 100644 (file)
@@ -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
index a3488792ad05dcf5214e656809d3e32c678de11d..c539d970e442bd990590ad53bea6725531575167 100644 (file)
@@ -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()
index ba53b6a9655a2f48a7e0479c8c54225bb9be148d..80456b22ac362d1aa501c4889bb5aa43852b687f 100644 (file)
 #include "cross_os.h"
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
+//#include <unistd.h>
 
 
 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__
index f9932b1daafacf4caee47876f70c4f2effeb3d8a..e11e2fb5af93418a2a7820e87fb14772be9f7052 100644 (file)
@@ -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 <unistd.h>
index b29180b2dd7d0ab6599aae3b2ccb9e586184222e..422b848b6d60ac2a14c8a221f80e965293e21805 100644 (file)
@@ -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));
 }
index b42e4332c8588840f20bb4ccb1d6a8440c92019e..2cdbadcd2a87a3bf7e5583b14ff3576c66ffbeb7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+ * Copyright (c) 2018-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
  *
  * 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);
index e1eb2f7f67b0ae783bb49e92735e7c287492f62a..f59aaf906962c84ce88484b8c7122eab16ead4fc 100644 (file)
@@ -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,
index 63f22dca223e543564ac756ba08902100f2af761..4fdc045e281703fb1889aa96eae335e61ebe778e 100644 (file)
@@ -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);
index c993a1e6e1261166e09e60c4ba9a6a3e6dd59786..44a2cdb16c219e600fc30fd6c6e366836a2bf7eb 100644 (file)
@@ -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);
index c5d560b307fa83b08dfd81796014c33c4d15e598..02c1c1492a12bfca6085fef2fe5ce51f0979bb0e 100644 (file)
@@ -29,8 +29,8 @@
 #include <freetype/ftlcdfil.h>
 #endif
 
-#include <hb.h>
-#include <hb-ft.h>
+#include <harfbuzz/hb.h>
+#include <harfbuzz/hb-ft.h>
 
 #include <fontconfig/fontconfig.h>
 
index d94daf311eb2dee9be8313b17036b3aa0b2299aa..a21298ee5557ee1c61dd92fbb7bf71f9a8ff1153 100644 (file)
 #include <stdint.h>
 #include <stdbool.h>
 #include <float.h>
+
+#define _USE_MATH_DEFINES
 #include <math.h>
 
 #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"
 
index 9f8ee171d8a7aee4d6290b38a7292aa877fa5d87..183df2b9783183992a8da4e8b5f955120d7e4edd 100644 (file)
@@ -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);
index ed52bd1bf455ed40e2bf2106563c8414e5c3ba9a..c03de4ced92a366702ddb19799aa268405aa50e3 100644 (file)
@@ -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; i<r->imgCount;i++)
+    for (uint32_t i=0; i<r->imgCount;i++)
         vkvg_surface_destroy (surfaces[i]);
 
     free (surfaces);
index f916c45f53b51cd5079140c9bbb1b10a93a0164b..74c867a9123df1c95e95741912fc110057a27efe 100644 (file)
@@ -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,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> // Windows.h -> WinDef.h defines min() max()
     } 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 <sys/time.h>
-#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 ();
index a33cff48ad76d3f17affc463dbaa4e6dd4534dc3..a090177f69268a44a95e734c3a39de03fda578dc 100644 (file)
@@ -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<layerCount; i++) {
+    for (uint32_t i=0; i<layerCount; i++) {
          printf ("\t - %s\n", availableLayers[i].layerName);
     }
     printf("-----------------\n\n");
+    free (availableLayers);
 }
 
-static VkDebugReportCallbackEXT dbgReport;
-
 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));
 
@@ -104,9 +103,9 @@ vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR
     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++)
+    for (uint32_t i=0;i<enabledExtsCount;i++)
         enabledExts[i] = gflwExts[i];
 #ifdef VKVG_USE_RENDERDOC
     const uint32_t enabledLayersCount = 2;
index 90d04516191580bf803e76dac0253e029ca4cde5..5c2e3f576cbf388707518e0cd25e31947305a30d 100644 (file)
@@ -1,35 +1,35 @@
 #include "test.h"
 
 void test(){
-    vkvg_surface_clear(surf);
-    struct timeval currentTime;
-    gettimeofday(&currentTime, NULL);
-
-    srand((unsigned) currentTime.tv_usec);
-    const float w = 1024.f;
-    const float h = 800.f;
-
-    VkvgContext ctx = vkvg_create(surf);
-    //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
-    vkvg_set_line_width(ctx,1);
-    //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
-
-    for (uint i=0; i<test_size; i++) {
-        randomize_color(ctx);
-        float x1 = w*rand()/RAND_MAX;
-        float y1 = h*rand()/RAND_MAX;
-        float v = 500.f*rand()/RAND_MAX;
-
-        vkvg_move_to (ctx, x1, y1);
-        vkvg_line_to (ctx, x1 + v, y1);
-        vkvg_stroke (ctx);
-    }
-    vkvg_destroy(ctx);
+       vkvg_surface_clear(surf);
+       struct timeval currentTime;
+       gettimeofday(&currentTime, NULL);
+
+       srand((unsigned) currentTime.tv_usec);
+       const float w = 1024.f;
+       const float h = 800.f;
+
+       VkvgContext ctx = vkvg_create(surf);
+       //vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
+       vkvg_set_line_width(ctx,1);
+       //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
+
+       for (uint32_t i=0; i<test_size; i++) {
+               randomize_color(ctx);
+               float x1 = w*rand()/RAND_MAX;
+               float y1 = h*rand()/RAND_MAX;
+               float v = 500.f*rand()/RAND_MAX;
+
+               vkvg_move_to (ctx, x1, y1);
+               vkvg_line_to (ctx, x1 + v, y1);
+               vkvg_stroke (ctx);
+       }
+       vkvg_destroy(ctx);
 }
 
 int main(int argc, char *argv[]) {
 
-    perform_test (test, 1024, 768);
+       perform_test (test, 1024, 768);
 
-    return 0;
+       return 0;
 }
index 4433c6e305d726a05106c6b9489b8173d430c2ea..28927e2862fcb4e3413f30eb7f893e2ba7beb144 100644 (file)
@@ -15,7 +15,7 @@ void test(){
     vkvg_set_line_width (ctx,1);
     //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
 
-    for (uint i=0; i<test_size; i++) {
+    for (uint32_t i=0; i<test_size; i++) {
         randomize_color(ctx);
 
         float x1 = w*rand()/RAND_MAX;
index 27226929c932dd71d17f2d1f3d11c9ee3182dfbb..c98cb02cf2ba11ec7e1edd4d5c2f6a0864a89b2f 100644 (file)
@@ -14,7 +14,7 @@ void test(){
     vkvg_set_line_width(ctx, 1.0f);
     //vkvg_set_line_join(ctx,VKVG_LINE_JOIN_BEVEL);
 
-    for (uint i=0; i<test_size; i++) {
+    for (uint32_t i=0; i<test_size; i++) {
         randomize_color(ctx);
 
         float r = 0.5f*w*rand()/RAND_MAX;
index b30a902bbe5f0a809b348b72de4a10f754ecbab9..c6d2402e801364d3ac8973258bdd5352d10b32f1 100644 (file)
@@ -1,34 +1,34 @@
 #include "test.h"
 
 void test(){
-    struct timeval currentTime;
-    gettimeofday(&currentTime, NULL);
+       struct timeval currentTime;
+       gettimeofday(&currentTime, NULL);
 
-    srand((unsigned) currentTime.tv_usec);
-    const float w = 800.f;
+       srand((unsigned) currentTime.tv_usec);
+       const float w = 800.f;
 
-    vkvg_surface_clear(surf);
+       vkvg_surface_clear(surf);
 
-    VkvgContext ctx = vkvg_create(surf);
-    vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
+       VkvgContext ctx = vkvg_create(surf);
+       vkvg_set_fill_rule(ctx, VKVG_FILL_RULE_EVEN_ODD);
 
-    for (uint i=0; i<test_size; i++) {
-        randomize_color(ctx);
+       for (uint32_t i=0; i<test_size; i++) {
+               randomize_color(ctx);
 
-        float x = truncf(0.5f*w*rand()/RAND_MAX);
-        float y = truncf(0.5f*w*rand()/RAND_MAX);
-        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(0.5f*w*rand()/RAND_MAX);
+               float y = truncf(0.5f*w*rand()/RAND_MAX);
+               float z = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
+               float v = truncf((0.5f*w*rand()/RAND_MAX)+1.f);
 
-        vkvg_rectangle(ctx, x, y, z, v);
-        vkvg_fill(ctx);
-    }
-    vkvg_destroy(ctx);
+               vkvg_rectangle(ctx, x, y, z, v);
+               vkvg_fill(ctx);
+       }
+       vkvg_destroy(ctx);
 }
 
 int main(int argc, char *argv[]) {
 
-    perform_test (test, 800, 600);
+       perform_test (test, 800, 600);
 
-    return 0;
+       return 0;
 }
diff --git a/vkh b/vkh
index 02b846b9d89340ceee42b4de3cf3a498bff726a2..fe84bd171b3ef9ea34ee961859c148c4892e548d 160000 (submodule)
--- a/vkh
+++ b/vkh
@@ -1 +1 @@
-Subproject commit 02b846b9d89340ceee42b4de3cf3a498bff726a2
+Subproject commit fe84bd171b3ef9ea34ee961859c148c4892e548d