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
/*
   Copyright (c) 2016 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 _GENERIC_VERTEX_DATA_H
#define _GENERIC_VERTEX_DATA_H

#include "config.h"

#include "VertexDataInterface.h"

/// This class is used to upload generic VB data to the GPU that can be rendered
/// directly or instanced.
/// Use this class to create precise VB data with specific usage (such as
/// particle systems)
/// Use IMPrimitive for on-the-fly geometry creation

namespace Divide {

class NOINITVTABLE GenericVertexData : public VertexDataInterface,
                                       public RingBuffer {
   public:
    struct AttributeDescriptor {
        AttributeDescriptor()
            : _index(0),
              _divisor(0),
              _parentBuffer(0),
              _componentsPerElement(0),
              _elementCountOffset(0),
              _wasSet(false),
              _dirty(false),
              _normalized(false),
              _type(GFXDataFormat::UNSIGNED_INT)
        {
        }

        void set(U32 bufferIndex, U32 instanceDivisor, U32 componentsPerElement,
                 bool normalized, U32 elementCountOffset, GFXDataFormat dataType) {
            this->bufferIndex(bufferIndex);
            this->instanceDivisor(instanceDivisor);
            this->componentsPerElement(componentsPerElement);
            this->normalized(normalized);
            this->offset(elementCountOffset);
            this->dataType(dataType);
        }

        inline void attribIndex(U32 index) {
            _index = index;
            _dirty = true;
            _wasSet = false;
        }

        inline void offset(U32 elementCountOffset) {
            _elementCountOffset = elementCountOffset;
            _dirty = true;
        }

        inline void bufferIndex(U32 bufferIndex) {
            _parentBuffer = bufferIndex;
            _dirty = true;
            _wasSet = false;
        }

        inline void instanceDivisor(U32 instanceDivisor) {
            _divisor = instanceDivisor;
            _dirty = true;
        }

        inline void componentsPerElement(U32 componentsPerElement) {
            _componentsPerElement = componentsPerElement;
            _dirty = true;
        }

        inline void normalized(bool normalized) {
            _normalized = normalized;
            _dirty = true;
        }

        inline void dataType(GFXDataFormat type) {
            _type = type;
            _dirty = true;
        }

        inline void wasSet(bool wasSet) { 
            _wasSet = wasSet;
            if (!_wasSet) {
                _dirty = true;
            }
        }

        inline void clean() { _dirty = false; }

        inline U32 attribIndex() const { return _index; }
        inline U32 offset() const { return _elementCountOffset; }
        inline U32 bufferIndex() const { return _parentBuffer; }
        inline U32 instanceDivisor() const { return _divisor; }
        inline U32 componentsPerElement() const {
            return _componentsPerElement;
        }
        inline bool normalized() const { return _normalized; }
        inline GFXDataFormat dataType() const { return _type; }
        inline bool wasSet() const { return _wasSet; }
        inline bool dirty() const { return _dirty; }

       protected:
        U32 _index;
        U32 _divisor;
        U32 _parentBuffer;
        U32 _componentsPerElement;
        U32 _elementCountOffset;
        bool _wasSet;
        bool _dirty;
        bool _normalized;
        size_t _stride;
        GFXDataFormat _type;
    };

    GenericVertexData(GFXDevice& context, const U32 ringBufferLength)
        : VertexDataInterface(context),
          RingBuffer(ringBufferLength)
    {
        _doubleBufferedQuery = true;
    }

    virtual ~GenericVertexData()
    {
        _attributeMapDraw.clear();
        _attributeMapFdbk.clear();
    }

    virtual void setIndexBuffer(U32 indicesCount, bool dynamic, bool stream) = 0;
    virtual void updateIndexBuffer(const vectorImpl<U32>& indices) = 0;
    virtual void create(U8 numBuffers = 1, U8 numQueries = 1) = 0;
    virtual void setFeedbackBuffer(U32 buffer, U32 bindPoint) = 0;

    virtual void draw(const GenericDrawCommand& command,
                      bool useCmdBuffer = false) = 0;

    /// When reading and writing to the same buffer, we use a round-robin
    /// approach and
    /// offset the reading and writing to multiple copies of the data
    virtual void setBuffer(U32 buffer, U32 elementCount, size_t elementSize,
                           bool useRingBuffer, void* data, bool dynamic, bool stream,
                           bool persistentMapped = false) = 0;

    virtual void updateBuffer(U32 buffer, U32 elementCount,
                              U32 elementCountOffset, void* data) = 0;

    virtual void bindFeedbackBufferRange(U32 buffer, U32 elementCountOffset,
                                         size_t elementCount) = 0;

    virtual U32 getFeedbackPrimitiveCount(U8 queryID) = 0;

    virtual void incQueryQueue() = 0;

    inline void toggleDoubleBufferedQueries(const bool state) {
        _doubleBufferedQuery = state;
    }

    inline AttributeDescriptor& getDrawAttribDescriptor(U32 attribIndex) {
        AttributeDescriptor& desc = _attributeMapDraw[attribIndex];
        desc.attribIndex(attribIndex);
        return desc;
    }

    inline AttributeDescriptor& getFdbkAttribDescriptor(U32 attribIndex) {
        AttributeDescriptor& desc = _attributeMapFdbk[attribIndex];
        desc.attribIndex(attribIndex);
        return desc;
    }

   protected:
    typedef hashMapImpl<U32, AttributeDescriptor> attributeMap;
    bool _doubleBufferedQuery;
    vectorImpl<U32> _feedbackBuffers;
    attributeMap _attributeMapDraw;
    attributeMap _attributeMapFdbk;
};

};  // namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Platform/Video/Buffers/VertexBuffer/Headers/GenericVertexData.h

Diff revisions: vs.
Revision Author Commited Message
712 Diff Diff IonutCava picture IonutCava Tue 24 May, 2016 16:18:37 +0000

[IonutCava]
- Added the concept of “buffer” to be used by GenericVertexData and ShaderBuffer without caring if it’s persistent or not.
— Persistent buffers handle their own locking instead of relying on the parent class
- HiZ occlusion culling fixes and optimizations

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

631 Diff Diff IonutCava picture IonutCava Sun 24 Jan, 2016 20:28:21 +0000

[IonutCava]
- Fix and optimize particle rendering system
- Temporarily disable Z_PRE_PASS system for testing
- Improve thread pool destruction system a bit
- Fix texture loading when used as fb attachment
- Forward+ renderer now takes the entire light buffer (no need to split up by light type)
- Start work on occlusion culling fixes:
— ToDo: Take into account batching system
— Fix gl_DrawIDARB usage

629 Diff Diff IonutCava picture IonutCava Thu 21 Jan, 2016 17:08:04 +0000

[IonutCava]
- New environment mapping system:
— Use previous frame’s list of nodes sorted front to back
— Update reflection for each if they meet the necessary criteria
- Cleanup particle system classes
- Cleanup GenericVertexData class
- Improve argument forwarding to frustum culling tasks

628 Diff Diff IonutCava picture IonutCava Wed 20 Jan, 2016 17:17:53 +0000

[IonutCava]
- Reworked GenericVertexData ring-buffering system and changed vertex attributes to the vertex format system
— Might be buggy
- Disabled bump-mapping for low-LoD level entities
- Removed a forgotten test line in BRDF shader that prevented lighting calculations to occur properly (an early return)
- Updated auto-reflection system for high shininess materials
- Converted a lot of ‘to_xyz’ calls to ‘to_const_xyz’ calls where appropriate to reduce runtime cost (‘to_const_xyz’ is evaluated at compile time)

591 Diff Diff IonutCava picture IonutCava Wed 02 Dec, 2015 17:17:23 +0000

[IonutCava]
- More work on the ForwardPlus renderer
- Singleton cleanup
- First steps for reducing scope of GFXDevice class

553 Diff Diff IonutCava picture IonutCava Sun 08 Nov, 2015 21:48:10 +0000

[IonutCava]
- Improve VBO allocation system
- Disable mipmap generation for blur FBO in CascadedShadowMaps
- Code cleanup

518 Diff Diff IonutCava picture IonutCava Sun 04 Oct, 2015 20:08:56 +0000

[IonutCava]
- New asset loading system and new asset formats (DVDGeom – geometry and material data. DVDAnim – animation data):
— Separate ASSIMP importing process (including animations) from Mesh/SubMesh/Material creation:
— Interface ASSIMP with the rest of the framework via a “ImportData” structure.
— Allow saving/loading from file of the entire ImportData and animation data entries via serialization.
— Allow serialization of VertexBuffers and update animation system’s serialization structure as well
— Base all serialization/deserialization processes on the ByteBuffer class with support for loading/saving to files
— If DVDGeom and DVDAnim files are not found, fall back to ASSIMP to load the data and save them for later use
-— Loading times reduce in half if data is already present.
-— Multi-threaded asset loading is now possible.
-— Other (non-ASSIMP) importing libraries can now be used.
-— DVDGeom and DVDAnim files can be shared/moved but not edited (they hold binary data for smaller memory usage)
- OpenGL/Direct3D usage is a compile time toggle (for now) for performance reasons.

491 Diff Diff IonutCava picture IonutCava Thu 13 Aug, 2015 22:33:40 +0000

[Ionut]
- Updates and fixes to the particle system
- Added proper flags to the WarScene

483 IonutCava picture IonutCava Sat 08 Aug, 2015 19:31:24 +0000

[Ionut]
- Removed OcclusionQueryHelper in preparation for a new occlusion system
— New method will use compute shaders and modify the command buffer directly setting primCount to 0 for occluded objects (No CPU roundtrip)
- Cleaned up the GenericDrawCommand system (usage and format)