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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
/*
   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 _HARDWARE_VIDEO_GFX_DEVICE_H_
#define _HARDWARE_VIDEO_GFX_DEVICE_H_

#include "Hardware/Video/Textures/Headers/Texture.h"
#include "Hardware/Video/OpenGL/Headers/GLWrapper.h"
#include "Hardware/Video/Direct3D/Headers/DXWrapper.h"
#include "Managers/Headers/RenderPassManager.h" ///<For GFX_RENDER_BIN_SIZE
#include "Graphs/Headers/SceneGraphNode.h"
#include "Rendering/Headers/Renderer.h"

enum RenderStage;
enum SceneNodeType;

class Light;
class Camera;
class PostFX;
class Quad3D;
class Object3D;
class ApplicationTimer;
class SceneRenderState;

class GFXDevice;

///Rough around the edges Adapter pattern
DEFINE_SINGLETON_EXT1(GFXDevice,RenderAPIWrapper)
    friend class Frustum; ///< For matrix recovery operations
    typedef Unordered_map<size_t, RenderStateBlock* > RenderStateMap;
    typedef boost::lockfree::spsc_queue<DELEGATE_CBK, boost::lockfree::capacity<15> > LoadQueue;
public:
    struct NodeData2{
        mat4<F32> _matrix1;
        mat4<F32> _matrix2;

        NodeData2()
        {
            _matrix1.zero();
            _matrix2.zero();
        }
    };
    struct NodeData4{
        mat4<F32> _matrix1;
        mat4<F32> _matrix2;
        mat4<F32> _matrix3;
        mat4<F32> _matrix4;
        NodeData4()
        {
            _matrix1.zero();
            _matrix2.zero();
            _matrix3.zero();
            _matrix4.zero();
        }
    };
    enum RenderTarget {
        RENDER_TARGET_SCREEN = 0,
        RENDER_TARGET_ANAGLYPH = 1,
        RENDER_TARGET_DEPTH = 2,
        RENDER_TARGET_DEPTH_RANGES = 3,
        RenderTarget_PLACEHOLDER = 4
    };

    enum SortReservedValues {
        SORT_DEPTH_STAGE = -222,
        SORT_NO_VALUE = -333
    };

    inline void setApi(const RenderAPI& api);

    inline RenderAPI        getApi()        {return _api.getId(); }
    inline GPUVendor        getGPUVendor()  {return _api.getGPUVendor();}

    I8 initHardware(const vec2<U16>& resolution, I32 argc, char **argv);
    void idle();

    inline void      registerKernel(Kernel* const kernel)           {_kernel = kernel;}
    inline void      initDevice(U32 targetFrameRate)                {_api.initDevice(targetFrameRate);}
    inline void      setWindowPos(U16 w, U16 h)               const {_api.setWindowPos(w,h);}
    inline void      exitRenderLoop(bool killCommand = false)       {_api.exitRenderLoop(killCommand);}
           void      closeRenderingApi();
           void      changeResolution(U16 w, U16 h);
    inline void      changeResolution(const vec2<U16>& resolution) {changeResolution(resolution.width, resolution.height);}

    ///Hardware specific shader preps (e.g.: OpenGL: init/deinit GLSL-OPT and GLSW)
    inline bool initShaders()   { return _api.initShaders(); }
    inline bool deInitShaders() { return _api.deInitShaders(); }
    inline void flush();
           void beginFrame();
           void endFrame();
    /// Rendering buffer management
    inline ShaderBuffer*       newSB(const bool unbound = false, const bool persistentMapped = true) const {
        return _api.newSB(unbound, persistentMapped); 
    }
    inline Framebuffer*        getRenderTarget(RenderTarget target)          const { return _renderTarget[target]; }
    inline IMPrimitive*        newIMP()                                      const { return _api.newIMP(); }
    inline Framebuffer*        newFB(bool multisampled = false)              const { return _api.newFB(multisampled); }
    inline VertexBuffer*       newVB()                                       const { return _api.newVB(); }
    inline PixelBuffer*        newPB(const PBType& type = PB_TEXTURE_2D)     const { return _api.newPB(type); }
    inline GenericVertexData*  newGVD(const bool persistentMapped)           const { return _api.newGVD(persistentMapped); }
    inline Texture*            newTextureArray(const bool flipped = false)   const { return _api.newTextureArray(flipped); }
    inline Texture*            newTexture2D(const bool flipped = false)      const { return _api.newTexture2D(flipped); }
    inline Texture*            newTextureCubemap(const bool flipped = false) const { return _api.newTextureCubemap(flipped);}
    inline ShaderProgram*      newShaderProgram(const bool optimise = false) const { return _api.newShaderProgram(optimise); }
    inline Shader*             newShader(const std::string& name, const  ShaderType& type, const bool optimise = false) const {
        return _api.newShader(name,type,optimise); 
    }

    void enableFog(F32 density, const vec3<F32>& color);
    void toggle2D(bool state);
    inline void toggleRasterization(bool state);
    inline void setLineWidth(F32 width) { _previousLineWidth = _currentLineWidth; _currentLineWidth = width; _api.setLineWidth(width); }
    inline void restoreLineWidth()      { setLineWidth(_previousLineWidth); }
    inline void renderInViewport(const vec4<I32>& rect, const DELEGATE_CBK& callback);

    //returns an immediate mode emulation buffer that can be used to construct geometry in a vertex by vertex manner.
    //allowPrimitiveRecycle = do not reuse old primitives and do not delete it after x-frames. (Don't use the primitive zombie feature)
    IMPrimitive* getOrCreatePrimitive(bool allowPrimitiveRecycle = true);

    inline void setInterpolation(const D32 interpolation)       {_interpolationFactor = interpolation; }
    inline D32  getInterpolation()                        const {return _interpolationFactor;} 
    inline void drawDebugAxis(const bool state)                 {_drawDebugAxis = state;}
    inline bool drawDebugAxis()                           const {return _drawDebugAxis;}

    void debugDraw(const SceneRenderState& sceneRenderState);
    void drawBox3D(const vec3<F32>& min,const vec3<F32>& max, const mat4<F32>& globalOffset);
    void drawLines(const vectorImpl<Line >& lines,
                   const mat4<F32>& globalOffset,
                   const vec4<I32>& viewport, //<only for ortho mode
                   const bool inViewport = false,
                   const bool disableDepth = false);
    
    void drawPoints(U32 numPoints, size_t stateHash);
    void drawGUIElement(GUIElement* guiElement);
    void submitRenderCommand(VertexBuffer* const buffer,      const GenericDrawCommand& cmd);
    void submitRenderCommand(VertexBuffer* const buffer,      const vectorImpl<GenericDrawCommand>& cmds);
    void submitRenderCommand(GenericVertexData* const buffer, const GenericDrawCommand& cmd);
    void setBufferData(const GenericDrawCommand& cmd);

    inline const vec2<I32>& getDrawIDs(I64 drawIDIndex) {
        assert(_sgnToDrawIDMap.find(drawIDIndex) != _sgnToDrawIDMap.end());
        return _sgnToDrawIDMap[drawIDIndex];
    }
    ///Sets the current render stage.
    ///@param stage Is used to inform the rendering pipeline what we are rendering. Shadows? reflections? etc
    inline RenderStage setRenderStage(RenderStage stage) { RenderStage prevRenderStage = _renderStage; _renderStage = stage; return prevRenderStage; }
    ///Checks if the current rendering stage is any of the stages defined in renderStageMask
    ///@param renderStageMask Is a bitmask of the stages we whish to check if active
    inline bool isCurrentRenderStage(U8 renderStageMask);

    inline const vec4<I32>& getCurrentViewport()  const  {return _viewport.top(); }

    inline RenderStage  getRenderStage()                 {return _renderStage;}
    inline void         setPrevShaderId(const U32& id)   {_prevShaderId = id;}
    inline U32          getPrevShaderId()                {return _prevShaderId;}
    inline void         setPrevTextureId(const U32& id)  {_prevTextureId = id;}
    inline U32          getPrevTextureId()               {return _prevTextureId;}
           void         closeRenderer();
    inline Renderer*    getRenderer()                         {
        DIVIDE_ASSERT(_renderer != nullptr, "GFXDevice error: Renderer requested but not created!"); 
        return _renderer;
    }
    inline void         setRenderer(Renderer* const renderer) {
        DIVIDE_ASSERT(renderer != nullptr, "GFXDevice error: Tried to create an invalid renderer!"); 
        SAFE_UPDATE(_renderer, renderer);
    }
    /*
    /* Clipping plane management. All the clipping planes are handled by shader programs only!
    */
          void updateClipPlanes();
    /// disable a clip plane by index
    inline void GFXDevice::disableClipPlane(ClipPlaneIndex index) { assert(index != ClipPlaneIndex_PLACEHOLDER); _clippingPlanes[index].active(false); _api.updateClipPlanes(); }
    /// enable a clip plane by index
    inline void GFXDevice::enableClipPlane(ClipPlaneIndex index)  { assert(index != ClipPlaneIndex_PLACEHOLDER); _clippingPlanes[index].active(true);  _api.updateClipPlanes(); }
    /// modify a single clip plane by index
    inline void GFXDevice::setClipPlane(ClipPlaneIndex index, const Plane<F32>& p) { assert(index != ClipPlaneIndex_PLACEHOLDER); _clippingPlanes[index] = p; updateClipPlanes(); }
    /// set a new list of clipping planes. The old one is discarded
    inline void GFXDevice::setClipPlanes(const PlaneList& clipPlanes)  {
        if (clipPlanes != _clippingPlanes) {
            _clippingPlanes = clipPlanes;
            updateClipPlanes();
            _api.updateClipPlanes(); 
        }
    }

    /// clear all clipping planes
    inline void GFXDevice::resetClipPlanes() {
        _clippingPlanes.resize(Config::MAX_CLIP_PLANES, Plane<F32>(0,0,0,0));
        updateClipPlanes();
        _api.updateClipPlanes(); 
    }

    /// get the entire list of clipping planes
    inline const PlaneList& getClippingPlanes()         const {return _clippingPlanes;}
    /// Post Processing state
    inline bool postProcessingEnabled()                 const {return _enablePostProcessing;}
           void postProcessingEnabled(const bool state);
    /// Anaglyph rendering state
    inline bool anaglyphEnabled()                 const {return _enableAnaglyph;}
    inline void anaglyphEnabled(const bool state)       {_enableAnaglyph = state;}
    /// High Dynamic Range rendering
    inline bool hdrEnabled()                 const {return _enableHDR;}
    inline void hdrEnabled(const bool state)       {_enableHDR = state;}
    /// Depth pre-pass
    inline bool isDepthPrePass()                 const { return _isDepthPrePass; }
    inline void isDepthPrePass(const bool state)       { _isDepthPrePass = state;}
    /// 2D rendering enabled
    inline bool is2DRendering()                  const { return _2DRendering; }
    ///Save a screenshot in TGA format
    void Screenshot(char *filename);
    /// Some Scene Node Types are excluded from certain operations (lights triggers, etc)
    inline bool excludeFromStateChange(const SceneNodeType& currentType) {
        return (_stateExclusionMask & currentType) == currentType ? true : false;
    }
    inline void setStateChangeExclusionMask(I32 stateMask) {_stateExclusionMask = stateMask; }
    /// Return or create a new state block using the given descriptor. DO NOT DELETE THE RETURNED STATE BLOCK! GFXDevice handles that!
    size_t getOrCreateStateBlock(const RenderStateBlockDescriptor& descriptor);
    const RenderStateBlockDescriptor& getStateBlockDescriptor(size_t renderStateBlockHash) const;
    ///returs the standard state block
    inline size_t getDefaultStateBlock(bool noDepth = false)      { return noDepth ? _defaultStateNoDepthHash : _defaultStateBlockHash; } 
    /*//Render State Management */

    ///Generate a cubemap from the given position
    ///It renders the entire scene graph (with culling) as default
    ///use the callback param to override the draw function
    void  generateCubeMap(Framebuffer& cubeMap,
                          const vec3<F32>& pos,
                          const DELEGATE_CBK& callback, 
                          const vec2<F32>& zPlanes,
                          const RenderStage& renderStage = REFLECTION_STAGE);

    void getMatrix(const MATRIX_MODE& mode, mat4<F32>& mat);

    inline ShaderProgram* activeShaderProgram()                             const { return _activeShaderProgram; }
    inline void           activeShaderProgram(ShaderProgram* const program)       { _activeShaderProgram = program; }

    inline const mat4<F32>& getMatrix(const MATRIX_MODE& mode)  { getMatrix(mode, _mat4Cache); return _mat4Cache; }
    
    inline U64  getFrameDurationGPU()      const { return _api.getFrameDurationGPU(); }
    inline void togglePreviewDepthBuffer()       { _previewDepthBuffer = !_previewDepthBuffer; }

    inline bool MSAAEnabled() const { return _MSAASamples > 0; }
    inline U8   MSAASamples() const { return _MSAASamples; }
    inline bool FXAAEnabled() const { return _FXAASamples > 0; }
    inline U8   FXAASamples() const { return _FXAASamples; }

    inline void initAA(U8 fxaaSamples, U8 msaaSamples){
        _FXAASamples = fxaaSamples;
        _MSAASamples = msaaSamples;
    }

    RenderDetailLevel generalDetailLevel()                             const { return _generalDetailLevel; }
    void              generalDetailLevel(RenderDetailLevel detailLevel)      { _generalDetailLevel = detailLevel; }
    RenderDetailLevel shadowDetailLevel()                              const { return _shadowDetailLevel; }
    void              shadowDetailLevel(RenderDetailLevel detailLevel)       { _shadowDetailLevel = detailLevel; }

    inline void add2DRenderFunction(const DELEGATE_CBK& callback, U32 callOrder);

    void restoreViewport();
    void setViewport(const vec4<I32>& viewport);

    bool loadInContext(const CurrentContext& context, const DELEGATE_CBK& callback);

    void ConstructHIZ();
    void DownSampleDepthBuffer(vectorImpl<vec2<F32>> &depthRanges);

    void processVisibleNodes(const vectorImpl<SceneGraphNode* >& visibleNodes);

    inline U32  getFrameCount()       const { return FRAME_COUNT; }
    inline I32  getDrawCallCount()    const { return FRAME_DRAW_CALLS_PREV; }
    inline void registerDrawCall()          { FRAME_DRAW_CALLS++; }

    inline LoadQueue& getLoadQueue() { return _loadQueue; }

    inline void setMaxTextureSlots(U32 textureSlots)       { _maxTextureSlots = textureSlots; }
    inline U32  getMaxTextureSlots()                 const { return _maxTextureSlots; }

protected:
    friend class Kernel;
    friend class Application;
    inline void setMousePosition(U16 x, U16 y) const {_api.setMousePosition(x,y);}
    inline void changeResolutionInternal(U16 width, U16 height)       { _api.changeResolutionInternal(width, height); }
    inline void changeViewport(const vec4<I32>& newViewport)    const { _api.changeViewport(newViewport); }
    inline void loadInContextInternal()                               { _api.loadInContextInternal(); }
    inline void drawPoints(U32 numPoints)                             { _api.drawPoints(numPoints); }
           void drawDebugAxis(const SceneRenderState& sceneRenderState);

protected:
    friend class Camera;

    F32* lookAt(const mat4<F32>& viewMatrix, const vec3<F32>& eyePos);
    ///sets an ortho projection, updating any listeners if needed
    F32* setProjection(const vec4<F32>& rect, const vec2<F32>& planes);
    ///sets a perspective projection, updating any listeners if needed
    F32* setProjection(F32 FoV, F32 aspectRatio, const vec2<F32>& planes) ;
    ///sets the view frustum to either the left or right eye position for anaglyph rendering
    void setAnaglyphFrustum(F32 camIOD, const vec2<F32>& zPlanes, F32 aspectRatio, F32 verticalFoV, bool rightFrustum = false);

    void updateViewMatrix(const vec3<F32>& eyePos);
    void updateProjectionMatrix(const vec2<F32>& zPlanes);

private:

    GFXDevice();
    ~GFXDevice();
    void previewDepthBuffer();
    void updateViewportInternal(const vec4<I32>& viewport);
    void forceViewportInternal(const vec4<I32>& viewport);
    ///Update the graphics pipeline using the current rendering API with the state block passed
    inline void activateStateBlock(const RenderStateBlock& newBlock, RenderStateBlock* const oldBlock)  const { _api.activateStateBlock(newBlock, oldBlock); }
    inline void drawText(const TextLabel& textLabel, const vec2<I32>& position) { _api.drawText(textLabel, position); }
    ///Sets the current state block to the one passed as a param
    size_t setStateBlock(size_t stateBlockHash);

private:
    Camera*           _cubeCamera;
    Camera*           _2DCamera;
    PostFX&           _postFX;
    ShaderManager&    _shaderManager;
    RenderAPIWrapper& _api;
    RenderStage _renderStage;
    U32  _maxTextureSlots;
    U32  _prevShaderId,  _prevTextureId;
    I32  _stateExclusionMask;
    bool _drawDebugAxis;
    bool _isDepthPrePass;
    bool _viewportUpdate;
    LoadQueue _loadQueue;
    boost::thread *_loaderThread;
    ShaderProgram* _activeShaderProgram;
     
    vectorImpl<Line > _axisLines;
    vectorImpl<Line > _axisLinesTrasnformed;

protected:
    Renderer* _renderer;
    /* Rendering buffers*/
    Framebuffer* _renderTarget[RenderTarget_PLACEHOLDER];
    /*State management */
    RenderStateMap _stateBlockMap;
    bool _stateBlockByDescription;
    size_t _currentStateBlockHash;
    size_t _newStateBlockHash;
    size_t _defaultStateBlockHash;
    size_t _defaultStateNoDepthHash; //<The default render state buth with depth testing disabled
    size_t _state2DRenderingHash;    //<Special render state for 2D rendering
    size_t _stateDepthOnlyRenderingHash;
    mat4<F32> _textureMatrix;
    mat4<F32> _viewMatrix;
    mat4<F32> _projectionMatrix;
    mat4<F32> _viewProjectionMatrix;
    ///The interpolation factor between the current and the last frame
    D32       _interpolationFactor;
    ///Line width management 
    F32 _previousLineWidth, _currentLineWidth;
    ///Pointer to current kernel
    Kernel*   _kernel;
    PlaneList _clippingPlanes;
    bool      _enablePostProcessing;
    bool      _enableAnaglyph;
    bool      _enableHDR;
    bool      _2DRendering;
    bool      _rasterizationEnabled;
   
    // number of draw calls (rough estimate)
    I32 FRAME_DRAW_CALLS;
    U32 FRAME_DRAW_CALLS_PREV;
    U32 FRAME_COUNT;
    ///shader used to preview the depth buffer
    ShaderProgram* _previewDepthMapShader;
    ShaderProgram* _HIZConstructProgram;
    ShaderProgram* _depthRangesConstructProgram;
    bool    _previewDepthBuffer;
    ///getMatrix cache
    mat4<F32> _mat4Cache;
    ///Default camera's cached zPlanes
    vec2<F32> _cachedSceneZPlanes;
    ///Current zPlanes
    vec2<F32> _cachedZPlanes;
    /// AA system
    U8        _MSAASamples;
    U8        _FXAASamples;
    /// Quality settings
    RenderDetailLevel _generalDetailLevel;
    RenderDetailLevel _shadowDetailLevel;

    vectorImpl<std::pair<U32, DELEGATE_CBK> > _2dRenderQueue;

    //Immediate mode emulation
    ShaderProgram*             _imShader;     //<The shader used to render VB data
    vectorImpl<IMPrimitive* >  _imInterfaces; //<The interface that coverts IM calls to VB data

    ///Current viewport stack
    typedef std::stack<vec4<I32>, vectorImpl<vec4<I32> > > viewportStack;
    viewportStack _viewport;

    vectorImpl<NodeData2 > _matricesData;
    vectorImpl<NodeData4 > _materialData;
    Unordered_map<I64, vec2<I32> > _sgnToDrawIDMap;

    ShaderBuffer*  _gfxDataBuffer;
    ShaderBuffer*  _nodeMaterialsBuffer;
    ShaderBuffer*  _nodeMatricesBuffer;
  
    GenericDrawCommand _defaultDrawCmd;

END_SINGLETON

#include "GFXDevice-Inl.h"

#endif

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

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

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

284 Diff Diff IonutCava picture IonutCava Tue 01 Jul, 2014 20:54:08 +0000

[Ionut][[BR]]
- Per SGN shader data implementation part 1 / 2 [[BR]]
— Gather node info and transforms into custom struct for visible nodes and store them in a GFXDevice local vector [[BR]]
- Removed “prepareDepthMaterial” and added depthPass flag to “prepareMaterial” [[BR]]

283 Diff Diff IonutCava picture IonutCava Tue 01 Jul, 2014 18:16:16 +0000

[Ionut][[BR]]
- Upload Viewport, camera position and zPlanes data to the gpu using the _matricesBuffer instead of ShaderProgram’s “uploadNodeMatrices” method [[BR]]
- Removed most matrices constructed with the worldMatrix (worldView, worldViewProjection, etc) to allow better batching of transforms. [[BR]]
— Both changes will allow the elimination of the “uploadNodeMatrices” and “setLoD” methods [[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]]

279 Diff Diff IonutCava picture IonutCava Sat 28 Jun, 2014 16:20:46 +0000

[Ionut][[BR]]
- Unified draw command system into GenericDrawCommand [[BR]]
- Fixed double VB creation in Object3D [[BR]]
- Reworked triangle data computation (now Object3D’s responsibility) [[BR]]
- VertexArrays can now render using the primitive type specified in the draw command instead of the fixed type specified at creation [[BR]]
- Optimized terrain shader [[BR]]

275 Diff Diff IonutCava picture IonutCava Fri 13 Jun, 2014 15:11:02 +0000

[Ionut [[BR]]
- Removed all GLM dependencies (great library, but my math class can handle all of my requirements now) [[BR]]
- Moved view/projection/texture matrix management to GFXDevice class (from API specific classes) [[BR]]

274 Diff Diff IonutCava picture IonutCava Fri 13 Jun, 2014 12:56:03 +0000

[Ionut] [[BR]]
- Simplified buffer based rendering (VertexBuffer & GenericVertexData are now exclusively command based) [[BR]]
- Update bone buffer to persistent mapped-SSBO system with double-buffering [[BR]]
- Simplified sky rendering and (finally) reduced the sun’s radius [[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]]