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
/*
   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 _GL_GENERIC_VERTEX_DATA_H
#define _GL_GENERIC_VERTEX_DATA_H

#include "Hardware/Video/Buffers/VertexBuffer/Headers/GenericVertexData.h"

#include "Core/Math/Headers/MathHelper.h"
#include "Hardware/Video/OpenGL/Headers/GLWrapper.h"
#include "Hardware/Video/OpenGL/Buffers/Headers/glBufferLockManager.h"

namespace Divide {

class glGenericVertexData : public GenericVertexData {
    enum GVDUsage {
        GVD_USAGE_DRAW  = 0,
        GVD_USAGE_FDBCK = 1,
        GVD_USAGE_PLACEHOLDER = 2
    };

public:
    glGenericVertexData(bool persistentMapped);
    ~glGenericVertexData();

    void Create(U8 numBuffers = 1, U8 numQueries = 1);
    U32  GetFeedbackPrimitiveCount(U8 queryID);

    void SetBuffer(U32 buffer, 
                   U32 elementCount, 
                   size_t elementSize, 
                   U8 sizeFactor, 
                   void* data, 
                   bool dynamic, 
                   bool stream, 
                   bool persistentMapped = false);

    void UpdateBuffer(U32 buffer, 
                      U32 elementCount, 
                      U32 elementCountOffset, 
                      void* data, 
                      bool invalidateRange = false);

    void BindFeedbackBufferRange(U32 buffer, 
                                 U32 elementCountOffset, 
                                 size_t elementCount);

    inline void SetFeedbackBuffer(U32 buffer, U32 bindPoint) {
        if (!isFeedbackBuffer(buffer)){
            _feedbackBuffers.push_back(_bufferObjects[buffer]);
            _fdbkBindPoints.push_back(bindPoint);
        }

        GL_API::setActiveTransformFeedback(_transformFeedback);
        glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, bindPoint, _bufferObjects[buffer]);
    }

protected:
    friend class GFXDevice;
    void Draw(const GenericDrawCommand& command, bool skipBind = false);

protected:
    void SetAttributes(bool feedbackPass);
    void SetAttributeInternal(AttributeDescriptor& descriptor);

    inline bool isFeedbackBuffer(U32 index){
        for (U32 handle : _feedbackBuffers)
            if (handle == _bufferObjects[index])
               return true;

        return false;
    }

    inline U32 getBindPoint(U32 bufferHandle){
        for(U8 i = 0; i < _feedbackBuffers.size(); ++i){
            if(_feedbackBuffers[i] == bufferHandle)
                return _fdbkBindPoints[i];
        }
        return _fdbkBindPoints[0];
    }

    /// Just before we render the frame
    bool frameStarted(const FrameEvent& evt);

private:
    GLuint   _transformFeedback;
    GLuint   _numQueries;
    GLuint   _vertexArray[GVD_USAGE_PLACEHOLDER];
    bool*    _bufferSet;
    bool*    _bufferPersistent;
    GLuint*  _elementCount;
    GLuint*  _sizeFactor;
    size_t*  _readOffset;
    size_t*  _elementSize;
    void**   _bufferPersistentData;
    GLuint*  _prevResult;
    GLuint*  _feedbackQueries[2];
    bool*    _resultAvailable[2];
    GLuint   _currentWriteQuery;
    GLuint   _currentReadQuery;
    size_t*  _startDestOffset;
    vectorImpl<U32 > _fdbkBindPoints;
    glBufferLockManager* _lockManager;
};

}; //namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Hardware/Video/OpenGL/Buffers/VertexBuffer/Headers/glGenericVertexData.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)

330 Diff Diff IonutCava picture IonutCava Fri 10 Oct, 2014 17:19:11 +0000

[Ionut]
- New rendering algorithm :
— Perform second pass for visible nodes gathering all render commands and uploading them to an indirect draw buffer
— Render geometry with indirect draw commands
— Removed per-node range binding of the node buffer. Instead, bind the entire buffer once and index data in shaders
— Use “baseInstance” parameter from IndirectDrawCommand as a node buffer index
— Prefer DSA extensions for updating buffer data where applicable
- Moved all rendering specific code from SceneGraphNode to a new RenderingComponent
- Optimized “toString” utility function

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)

302 Diff Diff IonutCava picture IonutCava Wed 06 Aug, 2014 22:09:55 +0000

[Ionut]
- GenericVertexData buffer size (for read/write buffering) is now configurable instead of a fixed 3x and also applies to non-persistently mapped buffers
- Moved OpenGL enum tables to Divide::GLUtil::GL_ENUM_TABLE
- More code cleanups (glResources, glError, glVertexArray, glGenericVertexData, glIMPrimitive)

293 Diff Diff k1ngp1n picture k1ngp1n Tue 29 Jul, 2014 20:01:28 +0000

[Ionut]
- Code cleanup and comments in GLFWWrapper (for starters. more to follow)
- Reworked main loop logic (no more delegates and rendering api querying)
- Replaced all GLvoid with regular void
- replaced all boost::this_thread::sleep (deprecated calls) with boost::this_thread::sleep_for

292 Diff Diff k1ngp1n picture k1ngp1n Mon 28 Jul, 2014 20:23:56 +0000

[Ionut]
- More nVidia compatibility issues (including the ability to disable persistent mapped buffer altogether. Thanks nsight ....)
- Cross-platform compatibility fixes for types (custom types now mirror types in stdint.h and are now typdefed instead of defined)
- Removed redundant files

288 Diff Diff IonutCava picture IonutCava Wed 23 Jul, 2014 20:34:25 +0000

[Ionut]
- Added a common interface to GenericVertexData and VertexBuffer
- Removed deferred deletion of FrameListeners from FrameListenerManager. It complicated the code with no added benefit
- Added proper FrameListener unregister calls

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

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

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