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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
#include "Headers/glFramebuffer.h"
#include "Hardware/Video/OpenGL/Headers/glResources.h"
#include "Hardware/Video/OpenGL/Textures/Headers/glSamplerObject.h"

#include "core.h"
#include "Core/Headers/ParamHandler.h"
#include "Core/Resources/Headers/ResourceCache.h"
#include "Hardware/Video/Headers/GFXDevice.h"

namespace Divide {

bool glFramebuffer::_bufferBound = false;
bool glFramebuffer::_viewportChanged = false;

namespace {
    const char* getAttachmentName(TextureDescriptor::AttachmentType type) {
        switch(type) {
            case TextureDescriptor::Depth  : return "Depth"; 
            case TextureDescriptor::Color0 : return "Color0";
            case TextureDescriptor::Color1 : return "Color1";
            case TextureDescriptor::Color2 : return "Color2";
            case TextureDescriptor::Color3 : return "Color3";
        }
        return "ERROR_TYPE";
    }

    U8 getAttachmentSlot(TextureDescriptor::AttachmentType type) {
         switch(type) {
            case TextureDescriptor::Depth  : return 4; 
            case TextureDescriptor::Color0 : return 0;
            case TextureDescriptor::Color1 : return 1;
            case TextureDescriptor::Color2 : return 2;
            case TextureDescriptor::Color3 : return 3;
         }
        return 255;
    }

    TextureDescriptor::AttachmentType getAttachmentType(U8 slot) {
         switch(slot) {
            case 4 : return TextureDescriptor::Depth; 
            case 0 : return TextureDescriptor::Color0;
            case 1 : return TextureDescriptor::Color1;
            case 2 : return TextureDescriptor::Color2;
            case 3 : return TextureDescriptor::Color3;
         }
        return TextureDescriptor::AttachmentType_PLACEHOLDER;
    }
};

glFramebuffer::glFramebuffer(glFramebuffer* resolveBuffer) : Framebuffer(resolveBuffer != nullptr),
                                                             _resolveBuffer(resolveBuffer),
                                                             _hasDepth(false),
                                                             _hasColor(false),
                                                             _resolved(false),
                                                             _isLayeredDepth(false)
{
    for (U8 i = 0; i < TextureDescriptor::AttachmentType_PLACEHOLDER; ++i) {
        _mipMapLevel[i].set(0);
        _attOffset[i]   = 0;
    }
}

glFramebuffer::~glFramebuffer()
{
    SAFE_DELETE(_resolveBuffer);
    Destroy();
}

void glFramebuffer::InitAttachment(TextureDescriptor::AttachmentType type, const TextureDescriptor& texDescriptor) {
    //If it changed
    if (!_attachmentDirty[type]) {
        return;
    }

    DIVIDE_ASSERT(_width != 0 && _height != 0, "glFramebuffer error: Invalid frame buffer dimensions!");
    
    if (type != TextureDescriptor::Depth) {
        _hasColor = true;
    } else {
        _hasDepth = true;
    }

    U8 slot = getAttachmentSlot(type);

    TextureType currentType = texDescriptor._type;

    if (_multisampled){
        if (currentType == TEXTURE_2D) {
            currentType = TEXTURE_2D_MS;
        }
        if (currentType == TEXTURE_2D_ARRAY) {
            currentType = TEXTURE_2D_ARRAY_MS;
        }
    } else {
        if (currentType == TEXTURE_2D_MS) {
            currentType = TEXTURE_2D;
        }
        if (currentType == TEXTURE_2D_ARRAY_MS) {
            currentType = TEXTURE_2D_ARRAY;
        }
    }
    
    bool isLayeredTexture = (currentType == TEXTURE_2D_ARRAY || currentType == TEXTURE_2D_ARRAY_MS || currentType == TEXTURE_CUBE_ARRAY || currentType == TEXTURE_3D);

    SamplerDescriptor sampler = texDescriptor.getSampler();
    if (_multisampled) {
        sampler.toggleMipMaps(false);
    }

    RemoveResource(_attachmentTexture[slot]);
    
    std::string attachmentName("Framebuffer_Att_");
    attachmentName.append(getAttachmentName(type));
    attachmentName.append(Util::toString(getGUID()));
    ResourceDescriptor textureAttachment(attachmentName);
    textureAttachment.setThreadedLoading(false);
    textureAttachment.setPropertyDescriptor(sampler);
    textureAttachment.setEnumValue(currentType);
    _attachmentTexture[slot] = CreateResource<Texture>(textureAttachment);
    
    Texture* tex = _attachmentTexture[slot];
    tex->setNumLayers(texDescriptor._layerCount);
    _mipMapLevel[slot].set(texDescriptor._mipMinLevel,
                           texDescriptor._mipMaxLevel > 0 ? texDescriptor._mipMaxLevel : 1 + (I16)floorf(log2f(fmaxf((F32)_width, (F32)_height))));
    
    tex->loadData(isLayeredTexture ? 0 : GLUtil::GL_ENUM_TABLE::glTextureTypeTable[currentType], NULL, vec2<U16>(_width, _height), _mipMapLevel[slot], texDescriptor._internalFormat, texDescriptor._internalFormat);
    tex->refreshMipMaps();
    tex->Bind(0); 

               
    //Attach to frame buffer
    if (type == TextureDescriptor::Depth) {
        glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tex->getHandle(), 0);
        _isLayeredDepth = isLayeredTexture;
    } else {
        GLint offset = 0;
        if (slot > getAttachmentSlot(TextureDescriptor::Color0)) {
            offset = _attOffset[slot - 1];
        }
        if (texDescriptor.isCubeTexture() && !_layeredRendering) {
            for (GLuint i = 0; i < 6; ++i) {
                GLenum attachPoint = GL_COLOR_ATTACHMENT0 + i + offset;
                glFramebufferTexture2D(GL_FRAMEBUFFER, attachPoint, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, tex->getHandle(), 0);
                _colorBuffers.push_back(attachPoint);
            }
            _attOffset[slot] = _attOffset[slot - 1] + 6;
        } else if (texDescriptor._layerCount > 1 && !_layeredRendering) {
            for (GLuint i = 0; i < texDescriptor._layerCount; ++i) {
                GLenum attachPoint = GL_COLOR_ATTACHMENT0 + i + offset;
                glFramebufferTextureLayer(GL_FRAMEBUFFER, attachPoint, tex->getHandle(), 0, i);
                _colorBuffers.push_back(attachPoint);
            }
            _attOffset[slot] = _attOffset[slot - 1] + texDescriptor._layerCount;
        } else { // if we require layered rendering, or have a non-layered / non-cubemap texture, attach it to a single binding point
            glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + slot, tex->getHandle(), 0);
            _colorBuffers.push_back(GL_COLOR_ATTACHMENT0 + slot);
        }
    }
}

void glFramebuffer::AddDepthBuffer() {
    TextureDescriptor desc = _attachment[TextureDescriptor::Color0];
    TextureType texType = desc._type;

    if (texType == TEXTURE_2D_ARRAY) {
        texType = TEXTURE_2D;
    }
    if (texType == TEXTURE_2D_ARRAY_MS) {
        texType = TEXTURE_2D_MS;
    }
    if (texType == TEXTURE_CUBE_ARRAY) {
        texType = TEXTURE_CUBE_MAP;
    }

    GFXDataFormat dataType = desc._dataType;
    bool fpDepth = (dataType == FLOAT_16 || dataType == FLOAT_32);
    SamplerDescriptor screenSampler;
    screenSampler.setFilters(TEXTURE_FILTER_NEAREST, TEXTURE_FILTER_NEAREST);
    screenSampler.setWrapMode(desc.getSampler().wrapU(), desc.getSampler().wrapV(), desc.getSampler().wrapW());
    screenSampler.toggleMipMaps(false);
    TextureDescriptor depthDescriptor(texType,
                                      fpDepth ? DEPTH_COMPONENT32F : DEPTH_COMPONENT,
                                      fpDepth ? dataType : UNSIGNED_INT);
        
    screenSampler._useRefCompare = true; //< Use compare function
    screenSampler._cmpFunc = CMP_FUNC_LEQUAL; //< Use less or equal
    depthDescriptor.setSampler(screenSampler);
    _attachmentDirty[TextureDescriptor::Depth] = true;
    _attachment[TextureDescriptor::Depth] = depthDescriptor;
    InitAttachment(TextureDescriptor::Depth, depthDescriptor);

    _hasDepth = true;
}

bool glFramebuffer::Create(GLushort width, GLushort height) {
    _hasDepth = false;
    _hasColor = false;
    _resolved = false;
    _isLayeredDepth = false;

    if (_resolveBuffer) {
        _resolveBuffer->_useDepthBuffer = _useDepthBuffer;
        _resolveBuffer->_disableColorWrites = _disableColorWrites;
        _resolveBuffer->_layeredRendering = _layeredRendering;
        _resolveBuffer->_clearColor.set(_clearColor);
        for (U8 i = 0; i < TextureDescriptor::AttachmentType_PLACEHOLDER; ++i) {
            if(_attachmentDirty[i] && !_resolveBuffer->AddAttachment(_attachment[i], (TextureDescriptor::AttachmentType)i)) {
                 return false;
            }
        }
        _resolveBuffer->Create(width, height);
    }

    _clearBufferMask = 0;

    if (_framebufferHandle <= 0) {
        glGenFramebuffers(1, &_framebufferHandle);
    }

    if (Config::Profile::USE_2x2_TEXTURES) {
        _width = _height = 2;
    } else {
        _width = width;
        _height = height;
    }

    GL_API::setActiveFB(_framebufferHandle, Framebuffer::FB_READ_WRITE);

    _colorBuffers.resize(0);

    //For every attachment, be it a color or depth attachment ...
    for (U8 i = 0; i < TextureDescriptor::AttachmentType_PLACEHOLDER; ++i) {
        InitAttachment((TextureDescriptor::AttachmentType)i, _attachment[i]);
    }
    //If we either specify a depth texture or request a depth buffer ...
    if (_useDepthBuffer && !_hasDepth) {
        AddDepthBuffer();
    }
    //If color writes are disabled, draw only depth info
    if (_disableColorWrites) {
        glDrawBuffer(GL_NONE);
        glReadBuffer(GL_NONE);
        _hasColor = false;
    } else {
        if (!_colorBuffers.empty()) {
            glDrawBuffers((GLsizei)_colorBuffers.size(), _colorBuffers.data());
        }
    }

    if (_hasColor) {
        _clearBufferMask = _clearBufferMask | GL_COLOR_BUFFER_BIT;
    }

    if (_hasDepth) {
        _clearBufferMask = _clearBufferMask | GL_DEPTH_BUFFER_BIT;
    }

    checkStatus();

    GL_API::clearColor( _clearColor );

    glClear(_clearBufferMask);

    GL_API::setActiveFB(0, Framebuffer::FB_READ_WRITE);

    return true;
}

void glFramebuffer::Destroy() {
    
    for (U8 i = 0; i < TextureDescriptor::AttachmentType_PLACEHOLDER; ++i) {
        RemoveResource(_attachmentTexture[i]);
    }

    if (_framebufferHandle > 0) {
        glDeleteFramebuffers(1, &_framebufferHandle);
        _framebufferHandle = 0;
    }

    _width = _height = 0;

    if (_resolveBuffer) {
        _resolveBuffer->Destroy();
    }
}

void glFramebuffer::resolve() {
    if (_resolveBuffer && !_resolved) {
        _resolveBuffer->BlitFrom(this, TextureDescriptor::Color0, _hasColor, _hasDepth);
        _resolved = true;
    }
}

void glFramebuffer::BlitFrom(Framebuffer* inputFB, TextureDescriptor::AttachmentType slot, bool blitColor, bool blitDepth) {
    if (!blitColor && !blitDepth) {
        return;
    }

    glFramebuffer* input = dynamic_cast<glFramebuffer*>(inputFB);
    
    // prevent stack overflow
    if (_resolveBuffer && (inputFB->getGUID() != _resolveBuffer->getGUID())) {
        input->resolve();
    }

    GLuint previousFB = GL_API::getActiveFB(Framebuffer::FB_READ_WRITE);
    GL_API::setActiveFB(input->_framebufferHandle, Framebuffer::FB_READ_ONLY);
    GL_API::setActiveFB(this->_framebufferHandle,  Framebuffer::FB_WRITE_ONLY);

    if (blitColor && _hasColor) {
        for (U8 i = 0; i < this->_colorBuffers.size(); ++i) {
            glDrawBuffer(this->_colorBuffers[i]);
            glReadBuffer(input->_colorBuffers[i]);
            glBlitFramebuffer(0, 0, input->_width, input->_height, 0, 0, this->_width, this->_height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
            GFX_DEVICE.registerDrawCall();
        }
    }

    if (blitDepth && _hasDepth) {
        glBlitFramebuffer(0, 0, input->_width, input->_height, 0, 0, this->_width, this->_height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
        GFX_DEVICE.registerDrawCall();
    }

    GL_API::setActiveFB(previousFB, Framebuffer::FB_READ_WRITE);
}

void glFramebuffer::Bind(GLubyte unit, TextureDescriptor::AttachmentType slot) {
    if (_resolveBuffer) {
        resolve();
        _resolveBuffer->Bind(unit, slot);
    } else {
        _attachmentTexture[slot]->Bind(unit);
    }
}

void glFramebuffer::Begin(const FramebufferTarget& drawPolicy) {
    DIVIDE_ASSERT(_framebufferHandle != 0, "glFramebuffer error: Tried to bind and invalid framebuffer!");
    DIVIDE_ASSERT(!glFramebuffer::_bufferBound, "glFramebuffer error: Begin() called without a call to the previous bound buffer's End()");

    if (drawPolicy._changeViewport) {
        GFX_DEVICE.setViewport(vec4<GLint>(0, 0, _width, _height));
        _viewportChanged = true;
    }

    GL_API::setActiveFB(_framebufferHandle, Framebuffer::FB_WRITE_ONLY);
    // this is checked so it isn't called twice on the GPU
    GL_API::clearColor( _clearColor );
    if (_clearBuffersState && drawPolicy._clearBuffersOnBind) {
        glClear(_clearBufferMask);
        GFX_DEVICE.registerDrawCall();
    }

    if (!drawPolicy._depthOnly && !drawPolicy._colorOnly) {
        for (U8 i = 0; i < TextureDescriptor::AttachmentType_PLACEHOLDER; ++i) {
            if (_attachmentTexture[i]) {
                _attachmentTexture[i]->refreshMipMaps();
            }
        }
    } else if(drawPolicy._depthOnly) {
        _attachmentTexture[TextureDescriptor::Depth]->refreshMipMaps();
    } else {
        for(U8 i = 0; i < TextureDescriptor::AttachmentType_PLACEHOLDER - 1; ++i) {
            if (_attachmentTexture[i]) {
                _attachmentTexture[i]->refreshMipMaps();
            }
        }
    }

    if (_resolveBuffer) {
        _resolved = false;
    }

    glFramebuffer::_bufferBound = true;
}

void glFramebuffer::End() {
    DIVIDE_ASSERT(glFramebuffer::_bufferBound, "glFramebuffer error: End() called without a previous call to Begin()");

    GL_API::setActiveFB(0, Framebuffer::FB_READ_WRITE);
    if (_viewportChanged) {
        GFX_DEVICE.restoreViewport();
        _viewportChanged = false;
    }
    resolve();

    glFramebuffer::_bufferBound = false;
}

void glFramebuffer::DrawToLayer(TextureDescriptor::AttachmentType slot, U8 layer, bool includeDepth) {
    GLuint textureType = GLUtil::GL_ENUM_TABLE::glTextureTypeTable[_attachmentTexture[slot]->getTextureType()];
    // only for array textures (it's better to simply ignore the command if the format isn't supported (debugging reasons)
    if (textureType != GL_TEXTURE_2D_ARRAY && 
        textureType != GL_TEXTURE_CUBE_MAP_ARRAY && 
        textureType != GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
        return;
    }

    bool useDepthLayer = (_hasDepth && includeDepth) || (_hasDepth && slot == TextureDescriptor::Depth);
    bool useColorLayer = (_hasColor && slot < TextureDescriptor::Depth);

    if (useDepthLayer && _isLayeredDepth) {
        glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _attachmentTexture[TextureDescriptor::Depth]->getHandle(), 0, layer);
    }

    if (useColorLayer) {
        GLint offset = slot > TextureDescriptor::Color0 ? _attOffset[slot - 1] : 0;
        glDrawBuffer(_colorBuffers[layer + offset]);
    }

    _attachmentTexture[slot]->refreshMipMaps();

    if (_clearBuffersState) {
        if (useDepthLayer) {
            useColorLayer ? glClear(_clearBufferMask) : glClear(GL_DEPTH_BUFFER_BIT);
        } else {
            if (useColorLayer) {
                glClear(GL_COLOR_BUFFER_BIT);
            }
        }
        GFX_DEVICE.registerDrawCall();
    }
}

void glFramebuffer::SetMipLevel(GLushort mipLevel,  GLushort mipMaxLevel, GLushort writeLevel, TextureDescriptor::AttachmentType slot) {
    GLuint textureType = GLUtil::GL_ENUM_TABLE::glTextureTypeTable[_attachmentTexture[slot]->getTextureType()];
    // Only 2D texture support for now
    DIVIDE_ASSERT(textureType == GL_TEXTURE_2D, "glFramebuffer error: Changing mip level is only available for 2D textures!");
    _attachmentTexture[slot]->setMipMapRange(mipLevel, mipLevel);
    glFramebufferTexture(GL_FRAMEBUFFER,
                         slot == TextureDescriptor::Depth ? GL_DEPTH_ATTACHMENT : _colorBuffers[slot],
                         _attachmentTexture[slot]->getHandle(),
                         writeLevel);
}

void glFramebuffer::ResetMipLevel(TextureDescriptor::AttachmentType slot) {
    SetMipLevel(_mipMapLevel[slot].x, _mipMapLevel[slot].y, 0, slot);
}

void glFramebuffer::ReadData(const vec4<U16>& rect, GFXImageFormat imageFormat, GFXDataFormat dataType, void* outData) {
    if (_resolveBuffer) {
        resolve();
        _resolveBuffer->ReadData(rect, imageFormat, dataType, outData);
    } else {
        GL_API::setActiveFB(_framebufferHandle, Framebuffer::FB_READ_ONLY);
        glReadPixels(rect.x, rect.y, rect.z, rect.w, GLUtil::GL_ENUM_TABLE::glImageFormatTable[imageFormat], 
                                                     GLUtil::GL_ENUM_TABLE::glDataFormat[dataType], outData);
    }
}

bool glFramebuffer::checkStatus() const {
    // check FB status
    switch(glCheckFramebufferStatus(GL_FRAMEBUFFER)) {
        case GL_FRAMEBUFFER_COMPLETE : {
            return true;
        }
        case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT : {
            ERROR_FN(Locale::get("ERROR_FB_ATTACHMENT_INCOMPLETE"));
            return false;
        }
        case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT : {
            ERROR_FN(Locale::get("ERROR_FB_NO_IMAGE"));
            return false;
        }
        case 0x8CD9 /*GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS*/ : {
            ERROR_FN(Locale::get("ERROR_FB_DIMENSIONS"));
            return false;
                                                  }
        case 0x8CDA /*GL_FRAMEBUFFER_INCOMPLETE_FORMATS*/ : {
            ERROR_FN(Locale::get("ERROR_FB_FORMAT"));
            return false;
        }
        case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER : {
            ERROR_FN(Locale::get("ERROR_FB_INCOMPLETE_DRAW_BUFFER"));
            return false;
        }
        case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER : {
            ERROR_FN(Locale::get("ERROR_FB_INCOMPLETE_READ_BUFFER"));
            return false;
        }
        case GL_FRAMEBUFFER_UNSUPPORTED : {
            ERROR_FN(Locale::get("ERROR_FB_UNSUPPORTED"));
            return false;
        }
        case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE : {
            ERROR_FN(Locale::get("ERROR_FB_INCOMPLETE_MULTISAMPLE"));
            return false;
        }
        case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS : {
            ERROR_FN(Locale::get("ERROR_FB_INCOMPLETE_LAYER_TARGETS"));
            return false;
        }
        default : {
            ERROR_FN(Locale::get("ERROR_UNKNOWN"));
            return false;
        }
    };
}

}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Hardware/Video/OpenGL/Buffers/FrameBuffer/glFrameBuffer.cpp

Diff revisions: vs.
Revision Author Commited Message
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)

301 Diff Diff IonutCava picture IonutCava Tue 05 Aug, 2014 20:55:30 +0000

[Ionut]
- Code cleanups and comments (ShaderManager, ShaderProgram, Texture)
- Fixed some singleton destruction order between ResourceCache and ShaderManager to properly unload remaining shader programs

298 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Aug, 2014 17:46:29 +0000

[Ionut]
- Final nVidia compatibility commit

296 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Aug, 2014 14:54:21 +0000

[Ionut]
- nVidia compatibility fixes (GUI, shadows, post-processing)
- Texture bind slots are now part of ShaderProgram class
- Renamed ForwardRenderer class to ForwardPlusRenderer and moved ligh grid creation to it
- More code cleanups and comments

295 Diff Diff k1ngp1n picture k1ngp1n Fri 01 Aug, 2014 20:10:44 +0000

[Ionut]
- If a shader fails to bind, skip draw call. A shader will fail to bind if it wasn’t linked properly, as well
- Moved ShaderManager to the Hardware project due to its tight coupling
- More code cleanup and comments:
— OpenGL wrapper code : GLWrapper.h, GLWrapper.cpp, GLStates.cpp, glShaderProgram.cpp
- Cleaned up Shader.cpp
- Binary shader dump also saves binary format in .fmt file for each binary shader
- Renamed immediate mode primitive files

291 Diff Diff k1ngp1n picture k1ngp1n Sun 27 Jul, 2014 19:27:53 +0000

[Ionut]
- nVidia compatibility fixes
- PhysX compatibility fixes

290 Diff Diff IonutCava picture IonutCava Sun 27 Jul, 2014 14:54:01 +0000

[Ionut]
- Small change to the resource loading thread
- Fixed array texture loading in framebuffer
- Temporarily disabled shadows (caused an assert)
- Fixed double close call for LightManager
- Removed unused options from config.xml

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