Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/*
   Copyright (c) 2014 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   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 the Software without restriction,
   including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _GFX_ENUMS_H
#define _GFX_ENUMS_H

/// no need to include the entire resource header for one define
#ifndef toBit
#define toBit(X) (1 << (X))
#endif

namespace Divide {
    ///State the various attribute locations to use in shaders with VAO/VB's
    enum {
         VERTEX_POSITION_LOCATION    = 0,
         VERTEX_COLOR_LOCATION       = 1,
         VERTEX_NORMAL_LOCATION      = 2,
         VERTEX_TEXCOORD_LOCATION    = 3,
         VERTEX_TANGENT_LOCATION     = 4,
         VERTEX_BITANGENT_LOCATION   = 5,
         VERTEX_BONE_WEIGHT_LOCATION = 6,
         VERTEX_BONE_INDICE_LOCATION = 7
    };

    enum {
        SHADER_BUFFER_LIGHT_NORMAL = 0,
        SHADER_BUFFER_LIGHT_SHADOW = 1,
        SHADER_BUFFER_LIGHT_COLOR  = 2,
        SHADER_BUFFER_LIGHT_PER_NODE = 3,
        SHADER_BUFFER_BONE_TRANSFORMS = 4,
        SHADER_BUFFER_CAM_MATRICES = 5,
    };
};

///Fixed pipeline functionality should be avoided. Both D3D and OGL should have these matrices
enum MATRIX_MODE{
    VIEW_MATRIX = 0,
    VIEW_INV_MATRIX = 1,
    PROJECTION_MATRIX = 2,
    PROJECTION_INV_MATRIX = 3,
    VIEW_PROJECTION_MATRIX = 4,
    VIEW_PROJECTION_INV_MATRIX  = 5, //<ViewProjection matrix's invers: inverse (VIEW_PROJECTION_MATRIX)
    TEXTURE_MATRIX = 6
};

///Compund matrices or sub-matrices
enum EXTENDED_MATRIX{
    WORLD_MATRIX = 0, //<Current model's world matrix. Changed for each render call, mainly
    WV_MATRIX = 1, //<WorldView matrix : ViewMatrix * WorldMatrix (as per OpenGL standards: name is backwards)
    WV_INV_MATRIX = 2, //<WorldViewInverse matrix: (ViewMatrix * WorldMatrix)^-1
    WVP_MATRIX = 4, //<WorldViewProjection matrix: ProjectionMatrix * ViewMatrix * WorldMatrix
    NORMAL_MATRIX = 6, //<Normal matrix - for non-uniform scaled models: top left 3x3 of ((ViewMatrix * WorldMatrix)^-1)^T; for uniform scaled models: top left 3x3 of (ViewMatrix*WorldMatrix)
};

///Using multiple threads for streaming and issuing API specific construction commands to the rendering API will
///cause problems with libraries such as ASSIMP or with the scenegraph. Having 2 rendering contexts with a single
///display list, one for rendering and one for loading seems the best approach (for now)
enum CurrentContext {
    GFX_RENDERING_CONTEXT = 0,
    GFX_LOADING_CONTEXT
};

enum RenderStage {
    DEFERRED_STAGE			   = toBit(1),
    SHADOW_STAGE			   = toBit(2),
    REFLECTION_STAGE		   = toBit(3),
    FINAL_STAGE				   = toBit(4),
    Z_PRE_PASS_STAGE           = toBit(5),
    //Place all stages above this
    INVALID_STAGE		       = toBit(6),
    //Special composite stages go here
    DISPLAY_STAGE              = DEFERRED_STAGE | FINAL_STAGE,
    DEPTH_STAGE                = SHADOW_STAGE | Z_PRE_PASS_STAGE
};

enum ClipPlaneIndex {
    CLIP_PLANE_0 = 0,
    CLIP_PLANE_1 = 1,
    CLIP_PLANE_2 = 2,
    CLIP_PLANE_3 = 3,
    CLIP_PLANE_4 = 4,
    CLIP_PLANE_5 = 5,
    ClipPlaneIndex_PLACEHOLDER = 6,
};

enum PBType {
    PB_TEXTURE_1D,
    PB_TEXTURE_2D,
    PB_TEXTURE_3D
};

enum RenderAPI {
    OpenGL,  ///< 4.x+
    OpenGLES,///< 3.x+
    Direct3D,///< 11.x+
    Mantle,  ///< not supported yet
    None,    ///< not supported yet
    GFX_RENDER_API_PLACEHOLDER
};

enum PrimitiveType {
    API_POINTS      = 0x0000,
    LINES           = 0x0001,
    LINE_LOOP       = 0x0002,
    LINE_STRIP      = 0x0003,
    TRIANGLES       = 0x0004,
    TRIANGLE_STRIP  = 0x0005,
    TRIANGLE_FAN    = 0x0006,
    QUAD_STRIP      = 0x0007,
    POLYGON         = 0x0008,
    PrimitiveType_PLACEHOLDER = 0x009
};

enum RenderDetailLevel{
    DETAIL_LOW = 0,
    DETAIL_MEDIUM = 1,
    DETAIL_HIGH = 2,
    DETAIL_ULTRA = 3
};

/// Specifies how the red, green, blue, and alpha source blending factors are computed.
enum BlendProperty{
   BLEND_PROPERTY_ZERO = 0,
   BLEND_PROPERTY_ONE,
   BLEND_PROPERTY_SRC_COLOR,
   BLEND_PROPERTY_INV_SRC_COLOR,
   /// Transparency is best implemented using blend function (SRC_ALPHA, ONE_MINUS_SRC_ALPHA) with primitives sorted from farthest to nearest.
   BLEND_PROPERTY_SRC_ALPHA,
   BLEND_PROPERTY_INV_SRC_ALPHA,
   BLEND_PROPERTY_DEST_ALPHA,
   BLEND_PROPERTY_INV_DEST_ALPHA,
   BLEND_PROPERTY_DEST_COLOR,
   BLEND_PROPERTY_INV_DEST_COLOR,
   /// Polygon antialiasing is optimized using blend function (SRC_ALPHA_SATURATE, GL_ONE) with polygons sorted from nearest to farthest.
   BLEND_PROPERTY_SRC_ALPHA_SAT,
   ///Place all properties above this.
   BlendProperty_PLACEHOLDER
};

/// Specifies how source and destination colors are combined.
enum BlendOperation {
   /// The ADD equation is useful for antialiasing and transparency, among other things.
   BLEND_OPERATION_ADD = 0,
   BLEND_OPERATION_SUBTRACT,
   BLEND_OPERATION_REV_SUBTRACT,
   /// The MIN and MAX equations are useful for applications that analyze image data
   /// (image thresholding against a constant color, for example).
   BLEND_OPERATION_MIN,
   /// The MIN and MAX equations are useful for applications that analyze image data
   /// (image thresholding against a constant color, for example).
   BLEND_OPERATION_MAX,
   /// Place all properties above this.
   BlendOperation_PLACEHOLDER
};

/// Valid comparison functions for most states
/// YYY = test value using this function
enum ComparisonFunction {
   /// Never passes.
   CMP_FUNC_NEVER = 0,
   /// Passes if the incoming YYY value is less than the stored YYY value.
   CMP_FUNC_LESS,
   /// Passes if the incoming YYY value is equal to the stored YYY value.
   CMP_FUNC_EQUAL,
   /// Passes if the incoming YYY value is less than or equal to the stored YYY value.
   CMP_FUNC_LEQUAL,
   /// Passes if the incoming YYY value is greater than the stored YYY value.
   CMP_FUNC_GREATER,
   /// Passes if the incoming YYY value is not equal to the stored YYY value.
   CMP_FUNC_NEQUAL,
   /// Passes if the incoming YYY value is greater than or equal to the stored YYY value.
   CMP_FUNC_GEQUAL,
   /// Always passes.
   CMP_FUNC_ALWAYS,
   /// Place all properties above this.
   ComparisonFunction_PLACEHOLDER
};

/// Specifies whether front- or back-facing facets are candidates for culling.
enum CullMode {
   CULL_MODE_NONE = 0,
   /// Cull Back facing polygons
   CULL_MODE_CW,
   /// Cull Front facing polygons
   CULL_MODE_CCW,
   /// Cull All polygons
   CULL_MODE_ALL,
    ///Place all properties above this.
   CullMode_PLACEHOLDER
};

/// Available shader stages
enum ShaderType {
    FRAGMENT_SHADER = 0,
    VERTEX_SHADER   = 1,
    GEOMETRY_SHADER = 2,
    TESSELATION_CTRL_SHADER = 3,
    TESSELATION_EVAL_SHADER = 4,
    COMPUTE_SHADER = 5,
    ShaderType_PLACEHOLDER = 6
};

/// Valid front and back stencil test actions
enum StencilOperation {
   /// Keeps the current value.
   STENCIL_OPERATION_KEEP = 0,
   /// Sets the stencil buffer value to 0.
   STENCIL_OPERATION_ZERO,
   /// Sets the stencil buffer value to ref, as specified by StencilFunc.
   STENCIL_OPERATION_REPLACE,
   /// Increments the current stencil buffer value. Clamps to the maximum representable unsigned value.
   STENCIL_OPERATION_INCR,
   ///  Decrements the current stencil buffer value. Clamps to 0.
   STENCIL_OPERATION_DECR,
   /// Bitwise inverts the current stencil buffer value.
   STENCIL_OPERATION_INV,
   /// Increments the current stencil buffer value.
   /// Wraps stencil buffer value to zero when incrementing the maximum representable unsigned value.
   STENCIL_OPERATION_INCR_WRAP,
   /// Decrements the current stencil buffer value.
   /// Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of zero.
   STENCIL_OPERATION_DECR_WRAP,
   /// Place all properties above this.
   StencilOperation_PLACEHOLDER
};

///Defines all available fill modes for primitives
enum FillMode {
   ///Polygon vertices that are marked as the start of a boundary edge are drawn as points.
   FILL_MODE_POINT = 1,
   ///Boundary edges of the polygon are drawn as line segments.
   FILL_MODE_WIREFRAME,
   ///The interior of the polygon is filled.
   FILL_MODE_SOLID,
    ///Place all properties above this.
   FillMode_PLACEHOLDER
};

enum TextureType {
    TEXTURE_1D = 0,
    TEXTURE_2D,
    TEXTURE_3D,
    TEXTURE_CUBE_MAP,
    TEXTURE_2D_ARRAY,
    TEXTURE_CUBE_ARRAY,
    TEXTURE_2D_MS,
    TEXTURE_2D_ARRAY_MS,
    TextureType_PLACEHOLDER
};

enum TextureFilter{
    TEXTURE_FILTER_LINEAR	= 0x0000,
    TEXTURE_FILTER_NEAREST   = 0x0001,
    TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST = 0x0002,
    TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST  = 0x0003,
    TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR  = 0x0004,
    TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR   = 0x0005,
    TextureFilter_PLACEHOLDER            = 0x0006
};

enum TextureWrap {
    /** Texture coordinates outside [0...1] are clamped to the nearest valid value.	 */
    TEXTURE_CLAMP = 0x0,
    TEXTURE_CLAMP_TO_EDGE = 0x1,
    TEXTURE_CLAMP_TO_BORDER = 0x2,
    /** If the texture coordinates for a pixel are outside [0...1] the texture is not applied to that pixel */
    TEXTURE_DECAL = 0x3,
    TEXTURE_REPEAT = 0x4,
    TEXTURE_MIRROR_REPEAT = 0x5,
    TextureWrap_PLACEHOLDER = 0x6
};

enum GFXImageFormat{
    LUMINANCE = 0,
    LUMINANCE_ALPHA,
    LUMINANCE_ALPHA16F,
    LUMINANCE_ALPHA32F,
    INTENSITY,
    ALPHA,
    RED,
    RED8,
    RED16,
    RED16F,
    RED32,
    RED32F,
    BLUE,
    GREEN,
    RG,
    RG8,
    RG16,
    RG16F,
    RG32,
    RG32F,
    BGR,
    RGB,
    RGB8,
    RGB8I,
    RGB16,
    RGB16F,
    BGRA,
    RGBA,
    RGBA4,
    RGBA8,
    RGBA8I,
    RGBA16F,
    RGBA32F,
    DEPTH_COMPONENT,
    DEPTH_COMPONENT16,
    DEPTH_COMPONENT24,
    DEPTH_COMPONENT32,
    DEPTH_COMPONENT32F,
    IMAGE_FORMAT_PLACEHOLDER
};

enum GFXDataFormat{
    UNSIGNED_BYTE    = 0x0000,
    UNSIGNED_SHORT   = 0x0001,
    UNSIGNED_INT     = 0x0002,
    SIGNED_BYTE      = 0x0003,
    SIGNED_SHORT     = 0x0004,
    SIGNED_INT       = 0x0005,
    FLOAT_16         = 0x0006,
    FLOAT_32         = 0x0008,
    GDF_PLACEHOLDER
};

enum GPUVendor {
    GPU_VENDOR_NVIDIA = 0,
    GPU_VENDOR_AMD,
    GPU_VENDOR_INTEL,
    GPU_VENDOR_OTHER,
    GPU_VENDOR_PLACEHOLDER
};

#endif

Commits for Divide-Framework/trunk/Source Code/Hardware/Video/Headers/RenderAPIEnums.h

Diff revisions: vs.
Revision Author Commited Message
280 Diff Diff IonutCava picture IonutCava Sat 28 Jun, 2014 19:11:37 +0000

[Ionut] [[BR]]
- Improve ClipPlane management (bunch equations into the matrix shader buffer) [[BR]]
- Immediate mode emulation primitives set their own state based on specified hash instead of relying on state functions to be defined [[BR]]
- updateStates() function is now called right before the actual draw call to facilitate future batching work [[BR]]
- added tracked bool values (similar to those in ShaderInfo) to SGN class to fix selection bug. [[BR]]
— will probably create a “stateTracker” class to allow multiple classes to use tracked variables without all of the code duplication [[BR]]

278 Diff Diff IonutCava picture IonutCava Thu 19 Jun, 2014 18:09:59 +0000

[Ionut][[BR]]
- Preliminary work on generic shader function selection infrastructure [[BR]]

273 Diff Diff IonutCava picture IonutCava Wed 11 Jun, 2014 20:34:00 +0000

[Ionut] [[BR]]
- Improved batching part2: [[BR]]
— Moved all bone transformation matrices upload from uniform functions in SceneNode to Shader Storage Buffers in AnimationController class with updates controlled by SceneGraphNode’s AnimationComponent [[BR]]
-— No double-buffering or efficient mapping of data yet. Just raw buffer updates [[BR]]
— Replaced all RenderStateBlock* pointers with I64 hash values [[BR]]
-— Will be used later in draw commands as per-shader state hash [[BR]]
— Moved getShaderProgram from Material to Material::ShaderInfo [[BR]]
-— Improved redundant uniform checks [[BR]]
— Improved texture unit changing in case of redundant texture bind case (i.e. skip changing the texture unit) [[BR]]
[[BR]]
- Improved float and double comparison functions using algorithms described in http://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/ [[BR]]
- Added a new utility function, DIVIDE_ASSERT, to more easily bind an assert check with a specific message [[BR]]
- Added missing files from Forward+ renderer’s initial code [[BR]]

272 Diff Diff IonutCava picture IonutCava Wed 11 Jun, 2014 11:30:51 +0000

[Ionut] [[BR]]
- Added initial code for Forward+ rendering (grid based light culling) [[BR]]
- Simplified Light class [[BR]]
- Moved more light uniform data to ShaderBuffers [[BR]]
- Double buffered grass rendering [[BR]]
- Added a better attribute interface to GenericVertexData [[BR]]
- Fixed screenshot capture [[BR]]
- Fixed texture double-bind checks [[BR]]

265 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 19:47:56 +0000

[Ionut] [[BR]]
- reworked uniform buffer binding [[BR]]
- modified framebuffer mipmap update [[BR]]

264 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 13:04:38 +0000

[Ionut] [[BR]]
- New camera system: [[BR]]
— Stack based (push/pop active camera) [[BR]]
— Per camera frustum [[BR]]
— Per camera projection [[BR]]
— Shadow mapping now uses the new camera system (each light has a shadow camera) [[BR]]
[[BR]]
- New terrain, water and vegetation system: [[BR]]
— Direct import of terrain from L3DT both as 8-bit grayscale and 16-bit raw formats [[BR]]
— Multiple alpha maps for texture splatting support [[BR]]
— Per texture detail map support [[BR]]
— Transform feedback based visibility culling for vegetation [[BR]]
— Alpha-map based vegetation placing on terrain [[BR]]
— Water now uses a refraction map instead of alpha blending for better refraction effects [[BR]]
[[BR]]
- SceneGraph improvements: [[BR]]
— Better bounding box updates from child to parent [[BR]]
— Better onDraw / postDraw implementation [[BR]]
[[BR]]
- Performance improvements: [[BR]]
— Batch 2D rendering tasks together as much as possible[[BR]]
— Improve renderStateBlock hash generation for better sorting [[BR]]
— Move most state related gfx changes from API implementation to the GFXDevice class [[BR]]
— Move viewport stack to the GFXDevice class [[BR]]
— Added various performance counters (frame duration with round-robin query system, draw call count, etc) [[BR]]
— Fixed and improved clip plane management [[BR]]
— Delete client-side texture data after GPU upload [[BR]]
[[BR]]
- New features: [[BR]]
— Added callback support to the Task class so that a specific task may call a function in the main thread upon completion [[BR]]
— Added mouse-wheel zoom support to Orbit/ThirdPerson cameras [[BR]]
— Added 2D Texture Array support (e.g. used for terrain textures) [[BR]]

260 Diff Diff k1ngp1n picture k1ngp1n Sat 03 May, 2014 19:33:41 +0000

[Ionut] [[BR]]
- More work on CSM. Reverted back to VSM to allow easier blurring and filtering [[BR]]
- Rewrote FrameBuffer classes to fix MSAA and memory leaks that occurred on resize (double creation of textures) [[BR]]
— Removed FBType. FrameBuffer types depend only on attachment types and if it’s MSAA enabled or not [[BR]]
- Rewrote RenderState classes to be API agnostic [[BR]]
- Bug fixes in math classes [[BR]]
- Changed “resolution change” logic [[BR]]
- Simplified some options in config.xml [[BR]]
- Improved per-light shadow options [[BR]]

259 Diff Diff k1ngp1n picture k1ngp1n Sun 27 Apr, 2014 18:24:52 +0000

[Ionut][[BR]]
- Implemented Exponential Stable Cascaded Shadow Maps for directional lights (still buggy, but basically working) [[BR]]
— CSM settings (resolution, number of splits, etc) are part of the scene render state [[BR]]
- SGN can skip rendering for the current frame if they are not ready (e.g. OnDraw can now return false or materials can fail to bind) [[BR]]
- Frustum class is now using the Plane class [[BR]]
- Removed Math SIMD implementation as the compiler generated code will always be faster and safer [[BR]]
- Added a “STUBBED” macro for outputing to the error stream of important messages (instead of using #pragma message) [[BR]]
- Added “freeze time” logic to pause/resume updates with or without freezing the GUI too [[BR]]
- Added “processGUI” method the every Scene class to separate time-sensitive GUI updates from game logic loop [[BR]]
- GLSL <-> Vertex Buffer bind locations are automatically set for every vertex shader [[BR]]
- Added basic support for compute shaders [[BR]]
- Removed most OS define checks to make porting to a new platform easier [[BR]]
- Texture transparency check per-pixel is now using OpenMP [[BR]]
- Texture samplers can now set a border color for CLAMP_TO_BORDER wrap mode [[BR]]
- Removed “Object” suffix from GFX Classes (pixel buffer, vertex buffer, frame buffer, etc) [[BR]]
- Stop processing scene input when application looses focus [[BR]]
- SceneGraphNode class is now responsible for updating SGNComponents on draw and calling its _node’s OnDraw method [[BR]]
- UBOs can now list all of the active uniforms inside a block with info such as type and offset [[BR]]
- Removed deprecated ‘GLCheck’ macro [[BR]]
- A lot of bug fixes and performance improvements in various places [[BR]]

256 Diff Diff k1ngp1n picture k1ngp1n Fri 11 Apr, 2014 17:23:24 +0000

[Ionut] [[BR]]
- Performance optimizations: [[BR]]
— Call SceneGraph::Update only once per frame (instead of once per draw call, as it was stupidly done now) [[BR]]
— Improve Shader programs' uniform system to allow better caching systems [[BR]]
— Use better caching system for Shader programs [[BR]]
— Use LOD for particle emitters (reduce count with distance for now) [[BR]]
- Every TrackedObject gets a GUID now [[BR]]
- Cleanup in SceneGraphNode class and SceneNode class (with derived classes as well) [[BR]]
- Some const-correctness fixes [[BR]]

248 k1ngp1n picture k1ngp1n Mon 24 Feb, 2014 22:35:21 +0000

[Ionut][[BR]]
- Added a GenericVertexData class that can be used to fill VBOs with generic data and upload it to the GPU (and render it, either direct or instanced) [[BR]]
- Added a basic (soft) particle system [[BR]]
- Reworked memory allocation logging [[BR]]
- Improved transparency detection for textures on load [[BR]]