-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathEveryCullingCore.h
166 lines (122 loc) · 3.6 KB
/
EveryCullingCore.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#pragma once
#include <assert.h>
#include <stddef.h>
#include "DataType/Math/SIMD_Core.h"
#if defined(__GNUC__) || defined( __clang__)
# define FORCE_INLINE inline __attribute__ ((always_inline))
# define NEVER_INLINE __attribute__ ((noinline))
# define RESTRICT __restrict
# define VLA_ARRAY_ON_STACK(type__, varname__, size__) type__ varname__[size__];
#elif defined(_MSC_VER)
# define FORCE_INLINE __forceinline
# define NEVER_INLINE __declspec(noinline)
# define RESTRICT __restrict
# define VLA_ARRAY_ON_STACK(type__, varname__, size__) type__ *varname__ = (type__*)_alloca(size__ * sizeof(type__))
#endif
#define CACHE_LINE_SIZE 64
///////////////////////////////////////////////////////////////////////////////////////
//Math
#ifndef MAX
#define MAX(A, B) ((A > B) ? A : B)
#endif
#ifndef MAX3
#define MAX3(A, B, C) MAX(A, MAX(B, C))
#endif
#ifndef MIN
#define MIN(A, B) ((A < B) ? A : B)
#endif
#ifndef MIN3
#define MIN3(A, B) MIN(A, MIN(B, C))
#endif
#ifndef ABS
#define ABS(x) ( ((x)<0)?-(x):(x) )
#endif
///////////////////////////////////////////////////////////////////////////////////////
#if defined(_DEBUG)
#define DEBUG_CULLING
#endif
#if defined(_DEBUG) || true
#define PROFILING_CULLING
#endif
///////////////////////////////////////////////////////////////////////////////////////
//Graphics API
//Use Your
#ifndef CULLING_OPENGL
#define CULLING_OPENGL
//#include "" Put Your Opengl Header!!
#endif
#ifndef CULLING_DIRECTX
//#define CULLING_DIRECTX
//#include "" Put Your DIRECTX Header!!
#endif
#ifdef CULLING_OPENGL
#define NDC_RANGE MINUS_ONE_TO_POSITIVE_ONE
#elif DIRECTX
#define NDC_RANGE ZERO_TO_POSITIVE_ONE
#endif
///////////////////////////////////////////////////////////////////////////////////////
//EntityBlock
#ifndef INITIAL_ENTITY_BLOCK_COUNT
#define INITIAL_ENTITY_BLOCK_COUNT 10
#endif
#ifndef INITIAL_ENTITY_BLOCK_RESERVED_SIZE
#define INITIAL_ENTITY_BLOCK_RESERVED_SIZE 512
#endif
#ifndef MAX_CAMERA_COUNT
#define MAX_CAMERA_COUNT 3
#endif
///////////////////////////////////////////////////////////////////////////////////////
//ViewFrustum Culling
#ifndef BOUNDING_SPHRE_RADIUS_MARGIN
#define BOUNDING_SPHRE_RADIUS_MARGIN 0.1f
#endif
///////////////////////////////////////////////////////////////////////////////////////
//Masked SW Occlusion Culling
//HAAM16
#ifndef QUICK_MASK
#define QUICK_MASK 1
#endif
#ifndef FETCH_OBJECT_SORT_FROM_DOOMS_ENGINE_IN_BIN_TRIANGLE_STAGE
#define FETCH_OBJECT_SORT_FROM_DOOMS_ENGINE_IN_BIN_TRIANGLE_STAGE 1
#endif
#define BACK_FACE_WINDING BACK_FACE_CCW
#if NDC_RANGE == MINUS_ONE_TO_POSITIVE_ONE
#define MIN_DEPTH_VALUE -1.0f
#define MAX_DEPTH_VALUE 1.0f
#elif NDC_RANGE == ZERO_TO_POSITIVE_ONE
#define MIN_DEPTH_VALUE 0.0f
#define MAX_DEPTH_VALUE 1.0f
#endif
#ifndef TILE_WIDTH
#define TILE_WIDTH 32
#endif
#ifndef TILE_HEIGHT
#define TILE_HEIGHT 8
#endif
#ifndef SUB_TILE_WIDTH
#define SUB_TILE_WIDTH 8
#endif
#ifndef SUB_TILE_HEIGHT
#define SUB_TILE_HEIGHT 4
#endif
#ifndef BIN_TRIANGLE_CAPACITY_PER_TILE_PER_OBJECT
#define BIN_TRIANGLE_CAPACITY_PER_TILE_PER_OBJECT 32
#endif
#ifndef MAX_OCCLUDER_COUNT
#define MAX_OCCLUDER_COUNT 10
#endif
// Screen Space Bounding Sphere Culling
#ifndef ENABLE_SCREEN_SAPCE_BOUDING_SPHERE_CULLING
//#define ENABLE_SCREEN_SAPCE_BOUDING_SPHERE_CULLING
#endif
// Distance Culling
#ifndef DEFAULT_DESIRED_MAX_DRAW_DISTANCE
#define DEFAULT_DESIRED_MAX_DRAW_DISTANCE 6000.0f
#endif
// Query Occlusion
#if !defined(ENABLE_QUERY_OCCLUSION) && defined(CULLING_OPENGL)
//#define ENABLE_QUERY_OCCLUSION
#endif
#ifndef IS_ALIGNED_ASSERT
#define IS_ALIGNED_ASSERT(ADDRESS, ALIGNMENT) (assert(ADDRESS % ALIGNMENT == 0))
#endif