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

#include "RenderAPIEnums.h"
#include "Core/Math/Headers/MathClasses.h"

namespace Divide {

class Kernel;
class Light;
class SubMesh;

class Material;
class Object3D;
class TextLabel;
class Transform;
class GUIElement;
class SceneRenderState;
enum ErrorCode;

template<typename T> class Plane;
typedef vectorImpl<Plane<F32> > PlaneList;
class SceneGraph;

class ShaderProgram;
class GenericVertexData;
class VertexDataInterface;

typedef struct {
    // Video resolution
    I32 Width, Height;
    // Red bits per pixel
    I32 RedBits;
    // Green bits per pixel
    I32 GreenBits;
    // Blue bits per pixel
    I32 BlueBits;
} VideoModes;
//FWD DECLARE CLASSES

struct IndirectDrawCommand {
    IndirectDrawCommand() : count(0), instanceCount(1), firstIndex(0), baseVertex(0), baseInstance(0) {}
    U32  count;
    U32  instanceCount;
    U32  firstIndex;
    U32  baseVertex;
    U32  baseInstance;
};

struct GenericDrawCommand {
private:
    U8     _queryID;
    U8     _lodIndex;
    bool   _drawToBuffer;
    bool   _renderWireframe;
    size_t _stateHash;
    PrimitiveType _type;
    IndirectDrawCommand _cmd;
    ShaderProgram*      _shaderProgram;
    VertexDataInterface*  _sourceBuffer;

public:
    inline void LoD(U8 lod)                 { _lodIndex = lod; }
    inline void queryID(U8 queryID)         { _queryID = queryID; }
    inline void stateHash(size_t hashValue) { _stateHash = hashValue; }
    inline void drawToBuffer(bool state)    { _drawToBuffer = state; }
    inline void renderWireframe(bool state) { _renderWireframe = state; }
    inline void instanceCount(U32 count)    { _cmd.instanceCount = count; }
    inline void firstIndex(U32 index)       { _cmd.firstIndex = index; }
    inline void indexCount(U32 count)       { _cmd.count = count; }
    inline void baseInstance(U32 value)     { _cmd.baseInstance = value; }
    inline void drawID(I32 drawID)          { baseInstance(drawID); }
    inline void shaderProgram(ShaderProgram* const program) { _shaderProgram = program; }
    inline void sourceBuffer(VertexDataInterface* const sourceBuffer) { _sourceBuffer = sourceBuffer; }
    inline void primitiveType(PrimitiveType type) { _type = type;  }

    inline U8 LoD()               const { return _lodIndex; }
    inline U8 queryID()           const { return _queryID; }
    inline size_t stateHash()     const { return _stateHash; }
    inline bool drawToBuffer()    const { return _drawToBuffer; }
    inline bool renderWireframe() const { return _renderWireframe; }
    inline U32 instanceCount()    const { return _cmd.instanceCount; }
    inline U32 indexCount()       const { return _cmd.count; }
    inline I32 drawID()           const { return _cmd.baseInstance; }
    
    inline const IndirectDrawCommand& cmd()    const { return _cmd; }
    inline ShaderProgram* shaderProgram()      const { return _shaderProgram; }
    inline VertexDataInterface* sourceBuffer() const { return _sourceBuffer; }
    inline PrimitiveType  primitiveType()      const { return _type; }

    GenericDrawCommand() : GenericDrawCommand(TRIANGLE_STRIP, 0, 0)
    {
    }

    GenericDrawCommand(const PrimitiveType& type, U32 firstIndex, U32 count, U32 instanceCount = 1) : _type(type),
                                                                                                      _lodIndex(0),
                                                                                                      _stateHash(0),
                                                                                                      _queryID(0),
                                                                                                      _drawToBuffer(false),
                                                                                                      _renderWireframe(false),
                                                                                                      _shaderProgram(nullptr),
                                                                                                      _sourceBuffer(nullptr)
    {
        _cmd.count = count;
        _cmd.firstIndex = firstIndex;
        _cmd.instanceCount = instanceCount;
    }

    inline void set(const GenericDrawCommand& base) {
        _cmd = base._cmd;
        _queryID = base._queryID;
        _lodIndex = base._lodIndex;
        _drawToBuffer = base._drawToBuffer;
        _renderWireframe = base._renderWireframe;
        _stateHash = base._stateHash;
        _type = base._type;
        _shaderProgram = base._shaderProgram;
        _sourceBuffer = base._sourceBuffer;
    }
};

enum ShaderType;
class Shader;
class Texture;
class IMPrimitive;
class PixelBuffer;
class Framebuffer;
class VertexBuffer;
class ShaderBuffer;
class ShaderProgram;
class RenderStateBlock;
class RenderStateBlockDescriptor;

///Renderer Programming Interface
class RenderAPIWrapper {
public: //RenderAPIWrapper global

protected:
	friend class GFXDevice;

    RenderAPIWrapper()
    {
    }

	virtual ~RenderAPIWrapper()
	{
	}

    /*Application display frame*/
    /// Clear buffers, set default states, etc
    virtual void beginFrame() = 0;
    /// Clear shaders, restore active texture units, etc
    virtual void endFrame() = 0;
    /// Change the window's position
    virtual void setWindowPos(U16 w, U16 h) const = 0;
    /// Platform specific cursor manipulation. 
    /// Set's the cursor's location to the specified X and Y relative to the edge of the window
    virtual void setCursorPosition(U16 x, U16 y) const = 0;
    virtual IMPrimitive*        newIMP() const = 0;
    virtual Framebuffer*        newFB(bool multisampled) const = 0;
    virtual VertexBuffer*       newVB() const = 0;
    virtual ShaderBuffer*       newSB(const bool unbound = false, const bool persistentMapped = true) const = 0;
    virtual GenericVertexData*  newGVD(const bool persistentMapped = false) const = 0;
    virtual PixelBuffer*        newPB(const PBType& type = PB_TEXTURE_2D) const = 0;
    virtual Texture*            newTextureArray(const bool flipped = false) const = 0;
    virtual Texture*            newTexture2D(const bool flipped = false) const = 0;
    virtual Texture*            newTextureCubemap(const bool flipped = false) const = 0;
    virtual ShaderProgram*      newShaderProgram(const bool optimise = false) const = 0;
    virtual Shader*             newShader(const stringImpl& name,const ShaderType& type,const bool optimise = false) const = 0;
    virtual bool                initShaders() = 0;
    virtual bool                deInitShaders() = 0;

    virtual ErrorCode initRenderingApi(const vec2<U16>& resolution, I32 argc, char **argv) = 0;
    virtual void      closeRenderingApi() = 0;

    virtual void toggleRasterization(bool state) = 0;
    virtual void setLineWidth(F32 width) = 0;
    virtual void drawText(const TextLabel& textLabel, const vec2<I32>& position) = 0;

    virtual void updateClipPlanes() = 0;
    virtual U64 getFrameDurationGPU() = 0;
    virtual void activateStateBlock(const RenderStateBlock& newBlock, RenderStateBlock* const oldBlock) const = 0;

    virtual void drawPoints(U32 numPoints) = 0;

protected:
    ///Change the resolution and reshape all graphics data
    virtual void changeResolutionInternal(U16 w, U16 h) = 0;
    virtual void changeViewport(const vec4<I32>& newViewport) const = 0;
    virtual void createLoaderThread() = 0;
    virtual void uploadDrawCommands(const vectorImpl<IndirectDrawCommand>& drawCommands) const = 0;
};

}; //namespace Divide

#endif

Commits for Divide-Framework/trunk/Source Code/Hardware/Video/Headers/RenderAPIWrapper.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

323 Diff Diff IonutCava picture IonutCava Thu 11 Sep, 2014 20:58:50 +0000

[Ionut]
- Reworked GFXDevice API initialization system
- Added a separate map for boolean values in ParamHandler
- More cleanups in GFXDevice class
- Fixed an infinite loop issue in Task class

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash 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)

314 Diff Diff IonutCava picture IonutCava Sun 24 Aug, 2014 19:54:33 +0000

[Ionut]
- More AI work
- Added some needed audio dlls

307 Diff Diff IonutCava picture IonutCava Tue 12 Aug, 2014 19:45:12 +0000

[Ionut]
- More editor work:
— Per object skeleton rendering, bounding box rendering and shadow map toggling
— Full screen depth preview toggle
— Text entry based transforms

303 Diff Diff IonutCava picture IonutCava Sat 09 Aug, 2014 19:12:32 +0000

[Ionut]
- Fixed mouse movement (change resolution callback properly informs inputInterface of the new window’s width and height)
- Fixed immediate mode emulation rendering (destroyed index buffers for some reason)
- Added axis gizmos for Scene / Scene + Selected Object / Scene + All object cycled via the F5 key in debug

302 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)