Skip to content

Commit f1a793c

Browse files
Added source files to project: Common.*, Tests.*, VmaUsage.*.
1 parent ba335cf commit f1a793c

File tree

7 files changed

+107
-44
lines changed

7 files changed

+107
-44
lines changed

src/Common.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "Common.h"
2+
3+
#ifdef _WIN32
4+
5+
#endif // #ifdef _WIN32

src/Common.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef COMMON_H_
2+
#define COMMON_H_
3+
4+
#ifdef _WIN32
5+
6+
#define MATHFU_COMPILE_WITHOUT_SIMD_SUPPORT
7+
#include <mathfu/glsl_mappings.h>
8+
#include <mathfu/constants.h>
9+
10+
#include <fstream>
11+
#include <vector>
12+
#include <string>
13+
#include <memory>
14+
#include <algorithm>
15+
#include <numeric>
16+
#include <array>
17+
#include <type_traits>
18+
#include <utility>
19+
20+
#include <cmath>
21+
#include <cassert>
22+
#include <cstdlib>
23+
#include <cstdio>
24+
25+
#define ERR_GUARD_VULKAN(Expr) do { VkResult res__ = (Expr); if (res__ < 0) assert(0); } while(0)
26+
27+
#endif // #ifdef _WIN32
28+
29+
#endif

src/Tests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "Tests.h"
2+
#include "VmaUsage.h"
3+
#include "Common.h"
4+
5+
#ifdef _WIN32
6+
7+
#endif // #ifdef _WIN32

src/Tests.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef TESTS_H_
2+
#define TESTS_H_
3+
4+
#ifdef _WIN32
5+
6+
7+
#endif // #ifdef _WIN32
8+
9+
#endif

src/VmaUsage.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
In exactly one CPP file define macro VMA_IMPLEMENTATION and then include
3+
vk_mem_alloc.h to include definitions of its internal implementation
4+
*/
5+
6+
#define VMA_IMPLEMENTATION
7+
8+
#include "VmaUsage.h"

src/VmaUsage.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#ifndef VMA_USAGE_H_
2+
#define VMA_USAGE_H_
3+
4+
#ifdef _WIN32
5+
6+
#define NOMINMAX
7+
#define WIN32_LEAN_AND_MEAN
8+
#include <Windows.h>
9+
#define VK_USE_PLATFORM_WIN32_KHR
10+
11+
#include <vulkan/vulkan.h>
12+
13+
/*
14+
In every place where you want to use Vulkan Memory Allocator, define appropriate
15+
macros if you want to configure the library and then include its header to
16+
include all public interface declarations. Example:
17+
*/
18+
19+
//#define VMA_USE_STL_CONTAINERS 1
20+
21+
//#define VMA_HEAVY_ASSERT(expr)
22+
23+
#pragma warning(push, 4)
24+
#pragma warning(disable: 4127) // conditional expression is constant
25+
#pragma warning(disable: 4100) // unreferenced formal parameter
26+
#pragma warning(disable: 4189) // local variable is initialized but not referenced
27+
28+
#include "vk_mem_alloc.h"
29+
30+
#pragma warning(pop)
31+
32+
#else // #ifdef _WIN32
33+
34+
#include <vulkan/vulkan.h>
35+
#include "vk_mem_alloc.h"
36+
37+
#endif // #ifdef _WIN32
38+
39+
#endif

src/VulkanSample.cpp

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,18 @@
2020
// THE SOFTWARE.
2121
//
2222

23-
#ifdef WIN32
24-
25-
#define NOMINMAX
26-
#define WIN32_LEAN_AND_MEAN
27-
#include <Windows.h>
28-
29-
#define VK_USE_PLATFORM_WIN32_KHR
30-
#include <vulkan/vulkan.h>
31-
32-
#pragma warning(push, 4)
33-
#pragma warning(disable: 4127) // warning C4127: conditional expression is constant
34-
#pragma warning(disable: 4100) // warning C4100: '...': unreferenced formal parameter
35-
#pragma warning(disable: 4189) // warning C4189: '...': local variable is initialized but not referenced
36-
#define VMA_IMPLEMENTATION
37-
#include "vk_mem_alloc.h"
38-
#pragma warning(pop)
39-
40-
#define MATHFU_COMPILE_WITHOUT_SIMD_SUPPORT
41-
#include <mathfu/glsl_mappings.h>
42-
#include <mathfu/constants.h>
43-
44-
#include <fstream>
45-
#include <vector>
46-
#include <string>
47-
#include <memory>
48-
#include <algorithm>
49-
#include <numeric>
50-
#include <array>
51-
#include <type_traits>
52-
#include <utility>
53-
54-
#include <cmath>
55-
#include <cassert>
56-
#include <cstdlib>
57-
#include <cstdio>
58-
59-
#define ERR_GUARD_VULKAN(Expr) do { VkResult res__ = (Expr); if (res__ < 0) assert(0); } while(0)
23+
#ifdef _WIN32
24+
25+
#include "Tests.h"
26+
#include "VmaUsage.h"
27+
#include "Common.h"
6028

6129
static const char* const SHADER_PATH1 = "./";
6230
static const char* const SHADER_PATH2 = "../bin/";
6331
static const wchar_t* const WINDOW_CLASS_NAME = L"VULKAN_MEMORY_ALLOCATOR_SAMPLE";
6432
static const char* const VALIDATION_LAYER_NAME = "VK_LAYER_LUNARG_standard_validation";
65-
static const char* const APP_TITLE_A = "Vulkan Memory Allocator Sample 1.0";
66-
static const wchar_t* const APP_TITLE_W = L"Vulkan Memory Allocator Sample 1.0";
33+
static const char* const APP_TITLE_A = "Vulkan Memory Allocator Sample 2.0";
34+
static const wchar_t* const APP_TITLE_W = L"Vulkan Memory Allocator Sample 2.0";
6735

6836
static const bool VSYNC = true;
6937
static const uint32_t COMMAND_BUFFER_COUNT = 2;
@@ -1689,14 +1657,12 @@ int main()
16891657
return 0;
16901658
}
16911659

1692-
#else // #ifdef WIN32
1660+
#else // #ifdef _WIN32
16931661

1694-
#define VMA_IMPLEMENTATION
1695-
#include "vk_mem_alloc.h"
1662+
#include "VmaUsage.h"
16961663

16971664
int main()
16981665
{
16991666
}
17001667

1701-
#endif // #ifdef WIN32
1702-
1668+
#endif // #ifdef _WIN32

0 commit comments

Comments
 (0)