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
#include "Headers/RenderStateBlock.h"
#include <boost/functional/hash.hpp>

RenderStateBlockDescriptor::RenderStateBlockDescriptor() : GUIDWrapper(),
                                                           _cachedHash(0),
                                                           _lockHash(false)
{
    setDefaultValues();
}

void RenderStateBlockDescriptor::fromDescriptor(const RenderStateBlockDescriptor& descriptor){
   setBlend(descriptor._blendEnable,descriptor._blendSrc,descriptor._blendDest,descriptor._blendOp);
   setColorWrites(descriptor._colorWrite.b.b0 > 0, descriptor._colorWrite.b.b1 > 0, descriptor._colorWrite.b.b2 > 0, descriptor._colorWrite.b.b3 > 0);
   setCullMode(descriptor._cullMode);
   setZReadWrite(descriptor._zEnable, descriptor._zWriteEnable);

   _zFunc = descriptor._zFunc;
   _zBias = descriptor._zBias;
   _zUnits = descriptor._zUnits;
  
   _stencilEnable = descriptor._stencilEnable;
   _stencilFailOp = descriptor._stencilFailOp;
   _stencilZFailOp = descriptor._stencilZFailOp;
   _stencilPassOp = descriptor._stencilPassOp;
   _stencilFunc = descriptor._stencilFunc;
   _stencilRef = descriptor._stencilRef;
   _stencilMask = descriptor._stencilMask;
   _stencilWriteMask = descriptor._stencilWriteMask;

   _fillMode = descriptor._fillMode;

   clean();
}

void RenderStateBlockDescriptor::flipCullMode(){
    if (_cullMode == CULL_MODE_NONE) _cullMode = CULL_MODE_ALL;
    if (_cullMode == CULL_MODE_ALL)  _cullMode = CULL_MODE_NONE;
    if (_cullMode == CULL_MODE_CW)   _cullMode = CULL_MODE_CCW;
    if (_cullMode == CULL_MODE_CCW)  _cullMode = CULL_MODE_CW;

    clean();
}

void RenderStateBlockDescriptor::setCullMode( CullMode mode ) {
   _cullMode = mode;
   _cullEnabled = _cullMode == CULL_MODE_NONE ? false : true;
   clean();
}

void RenderStateBlockDescriptor::setZEnable(const bool enable){
    _zEnable = enable;

    clean();
}

void RenderStateBlockDescriptor::setZReadWrite( bool read, bool write ) {
   _zEnable = read;
   _zWriteEnable = write;

   clean();
}

void RenderStateBlockDescriptor::setBlend( bool enable, BlendProperty src, BlendProperty dest, BlendOperation op ) {
   _blendEnable = enable;
   _blendSrc = src;
   _blendDest = dest;
   _blendOp = op;

   clean();
}

void RenderStateBlockDescriptor::setColorWrites( bool red, bool green, bool blue, bool alpha ) {
    _colorWrite.b.b0 = red ? 1 : 0;
    _colorWrite.b.b1 = green ? 1 : 0;
    _colorWrite.b.b2 = blue ? 1 : 0;
    _colorWrite.b.b3 = alpha ? 1 : 0;

    clean();
}

void RenderStateBlockDescriptor::setZBias(F32 zBias, F32 zUnits){
    _zBias = zBias;
    _zUnits = zUnits;

    clean();
}

void RenderStateBlockDescriptor::setZFunc(ComparisonFunction zFunc){
    _zFunc = zFunc;

    clean();
}

void RenderStateBlockDescriptor::setFillMode(FillMode mode)  { 
    _fillMode = mode; 

    clean();
}

void RenderStateBlockDescriptor::setStencilReadWriteMask(U32 read, U32 write) {
    _stencilMask = read;
    _stencilWriteMask = write;

    clean();
}

void RenderStateBlockDescriptor::setStencil(bool enable, U32 stencilRef, StencilOperation stencilFailOp, StencilOperation stencilZFailOp, 
                                                                         StencilOperation stencilPassOp, ComparisonFunction stencilFunc) {
    _stencilEnable = enable;
    _stencilRef = stencilRef;
    _stencilFailOp = stencilFailOp;
    _stencilZFailOp = stencilZFailOp;
    _stencilPassOp = stencilPassOp;
    _stencilFunc = stencilFunc;

    clean();
}

void RenderStateBlockDescriptor::setDefaultValues(){
    _lockHash = true;
    setZBias(0.0f, 1.0f);
    setZFunc();
    setColorWrites(true, true, true, true);
    setBlend(false, BLEND_PROPERTY_ONE, BLEND_PROPERTY_ONE, BLEND_OPERATION_ADD);
    setZReadWrite(true, true);
    setCullMode(CULL_MODE_CW);
    setFillMode(FILL_MODE_SOLID);
    setStencilReadWriteMask(0xFFFFFFFF, 0xFFFFFFFF);
    setStencil(false);
    _lockHash = false;

    clean();
}

void RenderStateBlockDescriptor::clean(){
    if (_lockHash) return;

    _cachedHash = 0;
    boost::hash_combine(_cachedHash, _colorWrite.i);
    boost::hash_combine(_cachedHash, _blendEnable);
    boost::hash_combine(_cachedHash, _blendSrc);
    boost::hash_combine(_cachedHash, _blendDest);
    boost::hash_combine(_cachedHash, _blendOp);
    boost::hash_combine(_cachedHash, _cullMode);
    boost::hash_combine(_cachedHash, _cullEnabled);
    boost::hash_combine(_cachedHash, _zEnable);
    boost::hash_combine(_cachedHash, _zWriteEnable);
    boost::hash_combine(_cachedHash, _zFunc);
    boost::hash_combine(_cachedHash, _zBias);
    boost::hash_combine(_cachedHash, _zUnits);
    boost::hash_combine(_cachedHash, _stencilEnable);
    boost::hash_combine(_cachedHash, _stencilRef);
    boost::hash_combine(_cachedHash, _stencilMask);
    boost::hash_combine(_cachedHash, _stencilWriteMask);
    boost::hash_combine(_cachedHash, _stencilFailOp);
    boost::hash_combine(_cachedHash, _stencilZFailOp);
    boost::hash_combine(_cachedHash, _stencilPassOp);
    boost::hash_combine(_cachedHash, _stencilFunc);
    boost::hash_combine(_cachedHash, _fillMode);
}

Commits for Divide-Framework/trunk/Source Code/Hardware/Video/RenderStateBlock.cpp

Diff revisions: vs.
Revision Author Commited Message
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]]

268 Diff Diff IonutCava picture IonutCava Wed 04 Jun, 2014 10:20:27 +0000

[IonutCava] [[BR]]
- Terrain and vegetation updates: [[BR]]
— Use standard phong lighting model [[BR]]
— Separate grass patches per chunk [[BR]]
— Reduce number of required texture bind points for terrain by adding both textures and normal maps in a single texture array [[BR]]
— Draw terrain with 2 drawcalls (using glMultiDrawElements twice, once for LoD == 0 and once for LoD > 0) [[BR]]
[[BR]]
- Buffer management updates: [[BR]]
— Unified buffer binding system [[BR]]
— Made Uniform buffer objects visible to all classes and moved lightUBO to LightManager, matricesUBO to GFXDevice etc [[BR]]
— Added initial support for Shader Buffer Objects [[BR]]
— Moved viewport management to GFXDevice class [[BR]]
[[BR]]
- Rendering improvements: [[BR]]
— Added Hi-Z occlusion culling to instanceCull shader (using Hi-Z depth buffer constructed in GFXDevice class) [[BR]]
— Resolved issues with shadow maps overriding texture bind locations [[[BR]]
— Improved shader and shader program loading [[BR]]
— Improved material transparency support [[BR]]
— Added buffer lock manager class from “Approaching Zero Driver Overhead in OpenGL (Presented by NVIDIA)” speech at GDC14 [[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]]

262 Diff Diff k1ngp1n picture k1ngp1n Tue 06 May, 2014 21:04:00 +0000

[Ionut] [[BR]]
- Some AI refactoring (basic AIEntity <-> AESOP interoperability) [[BR]]
- Some render batch sorting code refactored and fixed (wasn’t properly sorted in FINAL_STAGE) [[BR]]
- Simplified RenderStateBlockDescriptor and deferred hash value calculation [[BR]]
- Basic draw call count implementation [[BR]]
- Renamed some classes [[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]]

221 Diff Diff k1ngp1n picture k1ngp1n Wed 08 Jan, 2014 18:50:02 +0000

[Ionut] [[BR]]
- Merged branch “Shadows And Animations” back into trunk [[BR]]
- Added DoxygenGUI project file [[BR]]

  • Buggy *
185 Diff Diff k1ngp1n picture k1ngp1n Sat 23 Nov, 2013 19:18:16 +0000

[Ionut] [[BR]]
- More AI <-> NavMesh/Crowd integration [[BR]]
- Fixed object selection [[BR]]
— Every SceneGraphNode that has the “_isSelectable” flag set to true can now be selected with the mouse and highlighted with increased ambient [[BR]]
- Various performance optimizations [[BR]]
- Slight shadow offset modification to reduce peter-panning [[BR]]
- Added a debug-only profiling (ProfileTimer) class (unused for now) [[BR]]

171 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 18:15:06 +0000

-Replaced all tabs with spaces [[BR]]

152 k1ngp1n picture k1ngp1n Thu 20 Jun, 2013 14:23:31 +0000

[Ionut] [[BR]]
- New rendering pipeline (experimental and unstable): [[BR]]
— OpenGL 3.x clean context (glLight commands are still used for now, but UBO support is there, but not used yet) [[BR]]
— Custom matrix stacks and UBO based shader data (UBOs cause some link errors on some nVidia cards)[[BR]]
— Multi-threaded texture loading and shader compilation (mt shader compilation disabled for now. needs more tests) [[BR]]
— VAO rendering is self contained (no more enable/disable calls before a draw request) [[BR]]
— Render instance class used for rendering information [[BR]]
[[BR]]
- New unique ID generation base class: GUIDWrapper. Each class that derives from this, gets an application wide unique id on construction [[BR]]
- Added base code for an in-game editor using CEGUI [[BR]]
- Replaced some mutex locks with lockless data structures or atomic data [[BR]]
- CEGUI 0.8.2, FTGL-GL3 and GLIM 0.4 modified to support GLEW_MX if defined [[BR]]
- Dropped VS2008 support [[BR]]
- Networking library, server framework and ReCast files are now projects inside the Divide Framework solution [[BR]]
- New console command “setFov” that modifies the horizontal FoV value in realtime [[BR]]
- New console command “recompileShader” that reparses shader files, recompiles shaders and relinks shader programs who’s names match or contain the argument string [[BR]]
- New debug utility: axis angle drawn in corner of the screen if needed [[BR]]
- More ‘const’-s pasted around the code, more loop performance tweaks (allocations before a loop, tighter loops, etc), more utility member functions added to various classes [[BR]]