From f1a793cadd972cec7535fb16226ef637cd667217 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Tue, 13 Mar 2018 15:42:22 +0100 Subject: [PATCH] Added source files to project: Common.*, Tests.*, VmaUsage.*. --- src/Common.cpp | 5 +++++ src/Common.h | 29 ++++++++++++++++++++++++ src/Tests.cpp | 7 ++++++ src/Tests.h | 9 ++++++++ src/VmaUsage.cpp | 8 +++++++ src/VmaUsage.h | 39 +++++++++++++++++++++++++++++++++ src/VulkanSample.cpp | 52 ++++++++------------------------------------ 7 files changed, 106 insertions(+), 43 deletions(-) create mode 100644 src/Common.cpp create mode 100644 src/Common.h create mode 100644 src/Tests.cpp create mode 100644 src/Tests.h create mode 100644 src/VmaUsage.cpp create mode 100644 src/VmaUsage.h diff --git a/src/Common.cpp b/src/Common.cpp new file mode 100644 index 0000000..7173895 --- /dev/null +++ b/src/Common.cpp @@ -0,0 +1,5 @@ +#include "Common.h" + +#ifdef _WIN32 + +#endif // #ifdef _WIN32 diff --git a/src/Common.h b/src/Common.h new file mode 100644 index 0000000..95a0929 --- /dev/null +++ b/src/Common.h @@ -0,0 +1,29 @@ +#ifndef COMMON_H_ +#define COMMON_H_ + +#ifdef _WIN32 + +#define MATHFU_COMPILE_WITHOUT_SIMD_SUPPORT +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define ERR_GUARD_VULKAN(Expr) do { VkResult res__ = (Expr); if (res__ < 0) assert(0); } while(0) + +#endif // #ifdef _WIN32 + +#endif diff --git a/src/Tests.cpp b/src/Tests.cpp new file mode 100644 index 0000000..acb73c0 --- /dev/null +++ b/src/Tests.cpp @@ -0,0 +1,7 @@ +#include "Tests.h" +#include "VmaUsage.h" +#include "Common.h" + +#ifdef _WIN32 + +#endif // #ifdef _WIN32 diff --git a/src/Tests.h b/src/Tests.h new file mode 100644 index 0000000..7e9fc4b --- /dev/null +++ b/src/Tests.h @@ -0,0 +1,9 @@ +#ifndef TESTS_H_ +#define TESTS_H_ + +#ifdef _WIN32 + + +#endif // #ifdef _WIN32 + +#endif diff --git a/src/VmaUsage.cpp b/src/VmaUsage.cpp new file mode 100644 index 0000000..2ebf69c --- /dev/null +++ b/src/VmaUsage.cpp @@ -0,0 +1,8 @@ +/* +In exactly one CPP file define macro VMA_IMPLEMENTATION and then include +vk_mem_alloc.h to include definitions of its internal implementation +*/ + +#define VMA_IMPLEMENTATION + +#include "VmaUsage.h" diff --git a/src/VmaUsage.h b/src/VmaUsage.h new file mode 100644 index 0000000..70c8849 --- /dev/null +++ b/src/VmaUsage.h @@ -0,0 +1,39 @@ +#ifndef VMA_USAGE_H_ +#define VMA_USAGE_H_ + +#ifdef _WIN32 + +#define NOMINMAX +#define WIN32_LEAN_AND_MEAN +#include +#define VK_USE_PLATFORM_WIN32_KHR + +#include + +/* +In every place where you want to use Vulkan Memory Allocator, define appropriate +macros if you want to configure the library and then include its header to +include all public interface declarations. Example: +*/ + +//#define VMA_USE_STL_CONTAINERS 1 + +//#define VMA_HEAVY_ASSERT(expr) + +#pragma warning(push, 4) +#pragma warning(disable: 4127) // conditional expression is constant +#pragma warning(disable: 4100) // unreferenced formal parameter +#pragma warning(disable: 4189) // local variable is initialized but not referenced + +#include "vk_mem_alloc.h" + +#pragma warning(pop) + +#else // #ifdef _WIN32 + +#include +#include "vk_mem_alloc.h" + +#endif // #ifdef _WIN32 + +#endif diff --git a/src/VulkanSample.cpp b/src/VulkanSample.cpp index f4a0a28..6bdf418 100644 --- a/src/VulkanSample.cpp +++ b/src/VulkanSample.cpp @@ -20,50 +20,18 @@ // THE SOFTWARE. // -#ifdef WIN32 +#ifdef _WIN32 -#define NOMINMAX -#define WIN32_LEAN_AND_MEAN -#include - -#define VK_USE_PLATFORM_WIN32_KHR -#include - -#pragma warning(push, 4) -#pragma warning(disable: 4127) // warning C4127: conditional expression is constant -#pragma warning(disable: 4100) // warning C4100: '...': unreferenced formal parameter -#pragma warning(disable: 4189) // warning C4189: '...': local variable is initialized but not referenced -#define VMA_IMPLEMENTATION -#include "vk_mem_alloc.h" -#pragma warning(pop) - -#define MATHFU_COMPILE_WITHOUT_SIMD_SUPPORT -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define ERR_GUARD_VULKAN(Expr) do { VkResult res__ = (Expr); if (res__ < 0) assert(0); } while(0) +#include "Tests.h" +#include "VmaUsage.h" +#include "Common.h" static const char* const SHADER_PATH1 = "./"; static const char* const SHADER_PATH2 = "../bin/"; static const wchar_t* const WINDOW_CLASS_NAME = L"VULKAN_MEMORY_ALLOCATOR_SAMPLE"; static const char* const VALIDATION_LAYER_NAME = "VK_LAYER_LUNARG_standard_validation"; -static const char* const APP_TITLE_A = "Vulkan Memory Allocator Sample 1.0"; -static const wchar_t* const APP_TITLE_W = L"Vulkan Memory Allocator Sample 1.0"; +static const char* const APP_TITLE_A = "Vulkan Memory Allocator Sample 2.0"; +static const wchar_t* const APP_TITLE_W = L"Vulkan Memory Allocator Sample 2.0"; static const bool VSYNC = true; static const uint32_t COMMAND_BUFFER_COUNT = 2; @@ -1689,14 +1657,12 @@ int main() return 0; } -#else // #ifdef WIN32 +#else // #ifdef _WIN32 -#define VMA_IMPLEMENTATION -#include "vk_mem_alloc.h" +#include "VmaUsage.h" int main() { } -#endif // #ifdef WIN32 - +#endif // #ifdef _WIN32