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
/*
   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

namespace Divide {

///State the various attribute locations to use in shaders with VAO/VB's
enum AttribLocation {
    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 ShaderBufferLocation {
    SHADER_BUFFER_GPU_BLOCK       = 0,
    SHADER_BUFFER_LIGHT_NORMAL    = 1,
    SHADER_BUFFER_LIGHT_SHADOW    = 2,
    SHADER_BUFFER_NODE_INFO       = 3,
    SHADER_BUFFER_BONE_TRANSFORMS = 4
};

///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
};

///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			   = 1 << (1),
    SHADOW_STAGE			   = 1 << (2),
    REFLECTION_STAGE		   = 1 << (3),
    FINAL_STAGE				   = 1 << (4),
    Z_PRE_PASS_STAGE           = 1 << (5),
    //Place all stages above this
    INVALID_STAGE		       = 1 << (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,
	SRGB8,
    RGB8I,
    RGB16,
    RGB16F,
    BGRA,
    RGBA,
    RGBA4,
    RGBA8,
	SRGBA8,
    RGBA8I,
    RGBA16F,
    RGBA32F,
    DEPTH_COMPONENT,
    DEPTH_COMPONENT16,
    DEPTH_COMPONENT24,
    DEPTH_COMPONENT32,
    DEPTH_COMPONENT32F,
    GFXImageFormat_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
};

}; //namespace Divide

#endif

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

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

324 Diff Diff IonutCava picture IonutCava Sun 14 Sep, 2014 14:01:39 +0000

[Ionut]
- New memory management system (no custom allocators in this commit)
— Memory tracer to detect memory leaks on shutdown (from: https://www.relisoft.com/book/tech/9new.html)
— SAFE_DELETE_XYZ are now inline template functions not macros
— ASSERTION system now supports logging and message boxes and continue on error configurable for each build type
— Fixed a lot of memory leaks detected by the new system (some still remain)

- Added SRGB support (part 1)
— Albedo textures are loaded as SRGB (make sure resources are SRGB)
— Shaders output gamma corrected colors
— Moved terrain textures back to 2 array system (albedo and normal maps, albedo maps using a SRGB sampler)

- Sky is now loaded via the ResourceCache system
- Added include safeguards in shader atoms

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

287 Diff Diff IonutCava picture IonutCava Tue 22 Jul, 2014 16:11:05 +0000

[Ionut]
- Unified matrix transforms and node info and made it a vertex-shader only buffer
- World matrix queries have to be issued from the SceneGraphNode instead of the SGN’s Transform class to allow future interpolation algorithms to be more easily implemented
- Moved all lighting calculations per pixel to save varying and register space (caused compilation issues both on nVidia and AMD)
- Stored GPU buffer info (view, projection, viewport etc) into a special struct to avoid multiple redundant buffer uploads and to remove redundant client side matrix caches
- Some work on shader buffer locking system
- Cleaned up MathClasses.h and Transform.h
- Updated ASSIMP to 3.1.1

286 Diff Diff IonutCava picture IonutCava Fri 18 Jul, 2014 16:32:03 +0000

[Ionut] [[BR]]

    • very buggy commit ** [[BR]]

- New rendering pipeline: [[BR]]
— Bumped OpenGL version to 4.4 [[BR]]
— Command based rendering. GFXDevice dispatches rendering commands to their respective buffers [[BR]]
— State changing is exclusively controlled by the GFXDevice class [[BR]]
— Material properties and transform matrices are stored in shader storage buffers that are updated after culling and uploaded once per RenderPass. Objects use drawIDs to index data in shaders [[BR]]
— Removed all custom matrices and other, per shader, bind data [[BR]]
— Removed per node light data. Light culling and shader buffers will replace the old light management system [[BR]]
— Framebuffers now use the Texture class for attachments [[BR]]
— Sampler objects now work like RenderStateBlocks. GL_API handles them and stores them in a hash indexed map [[BR]]
— Removed “prepareMaterial” calls. Pre-draw material setup is now only limited to texture binding [[BR]]
— Moved immediate mode emulation and primitive rendering from API level to GFXDevice level [[BR]]
— Framebuffer rendering must be completed with a call to end() to ensure proper MSAA resolve (asserts, otherwise) [[BR]]
- Fixed hash code generation for RenderStateBlock (and now, glSamplerObject) using boost::hash_combine [[BR]]
- Temporarily disabled XML caching for materials [[BR]]

285 Diff Diff IonutCava picture IonutCava Wed 02 Jul, 2014 18:33:25 +0000

[Ionut][[BR]]
- Per SGN shader data implementation part 1.75 / 2 [[BR]]
— Upload node data into a SSBO in one single call [[BR]]
- Re-factored LightManager to upload light info and shadow info in single upload calls [[BR]]
- Improved GUIConsole load performance by using a boost::circular_buffer for initial messages [[BR]]

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 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]]