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
#include "Headers/GFXDevice.h"

#include "Utility/Headers/Localization.h"

#include "Platform/Video/OpenGL/Buffers/RenderTarget/Headers/glFramebuffer.h"
#include "Platform/Video/Direct3D/Buffers/RenderTarget/Headers/d3dRenderTarget.h"

#include "Platform/Video/OpenGL/Headers/glIMPrimitive.h"

#include "Platform/Video/OpenGL/Buffers/VertexBuffer/Headers/glVertexArray.h"
#include "Platform/Video/Direct3D/Buffers/VertexBuffer/Headers/d3dVertexBuffer.h"

#include "Platform/Video/OpenGL/Buffers/PixelBuffer/Headers/glPixelBuffer.h"
#include "Platform/Video/Direct3D/Buffers/PixelBuffer/Headers/d3dPixelBuffer.h"

#include "Platform/Video/OpenGL/Buffers/VertexBuffer/Headers/glGenericVertexData.h"
#include "Platform/Video/Direct3D/Buffers/VertexBuffer/Headers/d3dGenericVertexData.h"

#include "Platform/Video/OpenGL/Textures/Headers/glTexture.h"
#include "Platform/Video/Direct3D/Textures/Headers/d3dTexture.h"

#include "Platform/Video/OpenGL/Shaders/Headers/glShaderProgram.h"
#include "Platform/Video/Direct3D/Shaders/Headers/d3dShaderProgram.h"

#include "Platform/Video/OpenGL/Buffers/ShaderBuffer/Headers/glUniformBuffer.h"
#include "Platform/Video/Direct3D/Buffers/ShaderBuffer/Headers/d3dConstantBuffer.h"

namespace Divide {

namespace {
    GFXDevice& refThis(const GFXDevice* device) {
        return const_cast<GFXDevice&>(*device);
    }
};

RenderTarget* GFXDevice::newRT(const stringImpl& name) const {
    std::unique_lock<std::mutex> lk(_gpuObjectArenaMutex);

    RenderTarget* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new framebuffer.
            /// The callee is responsible for it's deletion!
            temp =  new (_gpuObjectArena) glFramebuffer(refThis(this), name);
        } break;
        case RenderAPI::Direct3D: {
            temp = new (_gpuObjectArena) d3dRenderTarget(refThis(this), name);
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    if (temp != nullptr) {
        _gpuObjectArena.DTOR(temp);
    }

    return temp;
}

IMPrimitive* GFXDevice::newIMP() const {
    std::unique_lock<std::mutex> lk(_gpuObjectArenaMutex);

    IMPrimitive* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new IM emulation primitive. The callee is responsible
            /// for it's deletion!
            temp = new (_gpuObjectArena) glIMPrimitive(refThis(this));
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    if (temp != nullptr) {
        _gpuObjectArena.DTOR(temp);
    }

    return temp;
}

VertexBuffer* GFXDevice::newVB() const {
    std::unique_lock<std::mutex> lk(_gpuObjectArenaMutex);

    VertexBuffer* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new vertex array (VAO + VB + IB).
            /// The callee is responsible for it's deletion!
            temp = new (_gpuObjectArena) glVertexArray(refThis(this));
        } break;
        case RenderAPI::Direct3D: {
            temp = new (_gpuObjectArena) d3dVertexBuffer(refThis(this));
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    if (temp != nullptr) {
        _gpuObjectArena.DTOR(temp);
    }

    return temp;
}

PixelBuffer* GFXDevice::newPB(PBType type) const {
    std::unique_lock<std::mutex> lk(_gpuObjectArenaMutex);

    PixelBuffer* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new pixel buffer using the requested format.
            /// The callee is responsible for it's deletion!
            temp = new (_gpuObjectArena) glPixelBuffer(refThis(this), type);
        } break;
        case RenderAPI::Direct3D: {
            temp = new (_gpuObjectArena) d3dPixelBuffer(refThis(this), type);
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    if (temp != nullptr) {
        _gpuObjectArena.DTOR(temp);
    }

    return temp;
}

GenericVertexData* GFXDevice::newGVD(const U32 ringBufferLength) const {
    std::unique_lock<std::mutex> lk(_gpuObjectArenaMutex);

    GenericVertexData* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new generic vertex data object
            /// The callee is responsible for it's deletion!
            temp = new (_gpuObjectArena) glGenericVertexData(refThis(this), ringBufferLength);
        } break;
        case RenderAPI::Direct3D: {
            temp = new (_gpuObjectArena) d3dGenericVertexData(refThis(this), ringBufferLength);
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    if (temp != nullptr) {
        _gpuObjectArena.DTOR(temp);
    }

    return temp;
}

Texture* GFXDevice::newTexture(size_t descriptorHash,
                               const stringImpl& name,
                               const stringImpl& resourceName,
                               const stringImpl& resourceLocation,
                               TextureType type,
                               bool asyncLoad) const {
    // Texture is a resource! Do not use object arena!
    Texture* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new texture. The callee is responsible for it's deletion!
            temp = MemoryManager_NEW glTexture(refThis(this), descriptorHash, name, resourceName, resourceLocation, type, asyncLoad);
        } break;
        case RenderAPI::Direct3D: {
            temp = MemoryManager_NEW d3dTexture(refThis(this), descriptorHash, name, resourceName, resourceLocation, type, asyncLoad);
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    return temp;
}

ShaderProgram* GFXDevice::newShaderProgram(size_t descriptorHash,
                                           const stringImpl& name,
                                           const stringImpl& resourceName,
                                           const stringImpl& resourceLocation,
                                           bool asyncLoad) const {
    // ShaderProgram is a resource! Do not use object arena!
    ShaderProgram* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new shader program.
            /// The callee is responsible for it's deletion!
            temp = MemoryManager_NEW glShaderProgram(refThis(this), descriptorHash, name, resourceName, resourceLocation, asyncLoad);
        } break;
        case RenderAPI::Direct3D: {
            temp = MemoryManager_NEW d3dShaderProgram(refThis(this), descriptorHash, name, resourceName, resourceLocation, asyncLoad);
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    return temp;
}

ShaderBuffer* GFXDevice::newSB(const ShaderBufferParams& params) const {
    std::unique_lock<std::mutex> lk(_gpuObjectArenaMutex);

    ShaderBuffer* temp = nullptr;
    switch (_API_ID) {
        case RenderAPI::OpenGL:
        case RenderAPI::OpenGLES: {
            /// Create and return a new shader buffer. The callee is responsible for it's deletion!
            /// The OpenGL implementation creates either an 'Uniform Buffer Object' if unbound is false
            /// or a 'Shader Storage Block Object' otherwise
            // The shader buffer can also be persistently mapped, if requested
            temp = new (_gpuObjectArena) glUniformBuffer(refThis(this), params);
        } break;
        case RenderAPI::Direct3D: {
            temp = new (_gpuObjectArena) d3dConstantBuffer(refThis(this), params);
        } break;
        default: {
            DIVIDE_UNEXPECTED_CALL(Locale::get(_ID("ERROR_GFX_DEVICE_API")));
        } break;
    };

    if (temp != nullptr) {
        _gpuObjectArena.DTOR(temp);
    }

    return temp;
}

}; // namespace Divide

Commits for Divide-Framework/trunk/Source Code/Platform/Video/GFXDeviceObjects.cpp

Diff revisions: vs.
Revision Author Commited Message
863 Diff Diff IonutCava picture IonutCava Wed 15 Feb, 2017 16:27:26 +0000

[IonutCava]
- Split Resource class into Resource and CachedResource
— CachedResource is the only resource held in a ResourceCache and loaded from a ResourceDescriptor
— CachedResource is mapped by its creation descriptor’s hash value, instead of the resource name
-— Multiple cached resources can now exist with the same name if the have different properties, for example.

830 Diff Diff IonutCava picture IonutCava Wed 25 Jan, 2017 17:29:44 +0000

[IonutCava]
- Add a new Platform element: File
— Move all predefined paths to FileManagement System
- Split MathHelper into MathHelper and StringHelper

829 Diff Diff IonutCava picture IonutCava Tue 24 Jan, 2017 17:28:39 +0000

[IonutCava]
- Separate resourceLocation for resources into resourceLocation and resourceName.
- More XML config loading refactoring

827 Diff Diff IonutCava picture IonutCava Sun 22 Jan, 2017 21:59:36 +0000

[IonutCava]
- ShaderBuffers now decide heuristically if they get persistently mapped or not (depends on size. Current limit is 512Kb for subData calls.
- Separate visible node command generation into 2 steps: onRender and getDrawPackage. onRender allows the creation of parallel tasks that should finish by the time the second call, getDrawPackage reaches the same node
- Update ParticleEmitter to take into account multiple players and increase parallelism at the cost of memory consumption and complexity.
- Add a default bounding box for Players (add extents to SceneTransform nodes)
- All buffers (ShaderBuffer, d3dConstantBuffer, glUniformBuffer, glBufferImpl, glGenericBuffer, etc) use BufferParams for creation.
— Constructor and create calls have been merged together

807 Diff Diff IonutCava picture IonutCava Mon 09 Jan, 2017 17:06:26 +0000

[IonutCava]
- Split PlatformDefines.h into 2. Move data type defines to PlatformDataTypes.h
- Continue to improve velocity map calculation
- Remove “destroy()” calls from most classes. Attempt to move as many classes to the RAII system.

804 Diff Diff IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)
788 Diff Diff IonutCava picture IonutCava Fri 21 Oct, 2016 16:11:37 +0000

[IonutCava]
- Added support for the Arena Allocator by Mamasha Knows (http://www.codeproject.com/Articles/44850/Arena-Allocator-DTOR-and-Embedded-Preallocated-Buf)
— Used for GFX Related objects: Textures, shaders, etc

785 Diff Diff IonutCava picture IonutCava Tue 18 Oct, 2016 16:14:27 +0000

[IonutCava]
- Added better rendering debugging functionality (named render targets. Helps with GPU Profiling tools)
- Limit clip planes to the number of frustum planes (that should be enough and it also simplifies the code)

775 Diff Diff IonutCava picture IonutCava Wed 05 Oct, 2016 15:54:54 +0000

[IonutCava]
- Cleanup RenderTarget <-> RTAttachment relation
- Multisampled render target state is now deduced based on attachments used

734 IonutCava picture IonutCava Tue 21 Jun, 2016 16:28:11 +0000

[IonutCava]
- Added a render target pool:
— All render targets are now allocated (and tracked) by the GFXDevice.
— Allocation routines return a slim RenderTargetHandle object that will be used later on in draw commands.

- Added a refraction render pass that will handle translucent objects that need refracted textures instead of clear transparency
— Both reflective nodes and refractive nodes are not gathered properly at this point

- All API specific objects (buffers, textures, etc) are now initialized in the GFXDevice class (see GFXDeviceObjects.cpp)
— This allowed for the slimming of the RenderAPIWrapper interface

- Improved ENABLE_GPU_VALIDATION macro utilization:
— It enabled shadow map split plane debugging
— It bypasses loading shaders from text cache