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
#include "Headers/glGenericBuffer.h"
#include "Platform/Video/OpenGL/Buffers/Headers/glBufferImpl.h"

namespace Divide {
glGenericBuffer::glGenericBuffer(const BufferParams& params)
    : _elementCount(params._elementCount),
      _elementSize(params._elementSizeInBytes),
      _elementCountBindOffset(0),
      _ringSizeFactor(params._ringSizeFactor)
{
    size_t bufferSize = _elementCount * _elementSize;
    size_t totalSize = bufferSize * _ringSizeFactor;
    
    BufferImplParams implParams;
    implParams._dataSizeInBytes = totalSize;
    implParams._frequency = params._frequency;
    implParams._target = params._usage;
    implParams._name = params._name;
    if (_ringSizeFactor == 1) {
        implParams._initialData = params._data;
    }

    _buffer = MemoryManager_NEW glBufferImpl(implParams);

    // Create sizeFactor copies of the data and store them in the buffer
    if (params._data != nullptr && _ringSizeFactor > 1) {
        for (U8 i = 0; i < _ringSizeFactor; ++i) {
            _buffer->updateData(i * bufferSize, bufferSize, params._data);
        }
    }
}

glGenericBuffer::~glGenericBuffer()
{
    MemoryManager::DELETE(_buffer);
}

GLuint glGenericBuffer::bufferHandle() const {
    return _buffer->bufferID();
}

void glGenericBuffer::updateData(GLuint elementCount,
                                 GLuint elementOffset,
                                 GLuint ringWriteOffset,
                                 const bufferPtr data)
{
    // Calculate the size of the data that needs updating
    size_t dataCurrentSize = elementCount * _elementSize;
    // Calculate the offset in the buffer in bytes from which to start writing
    size_t offset = elementOffset * _elementSize;

    if (_ringSizeFactor > 1) {
        offset += _elementCount * _elementSize * ringWriteOffset;
    }

    _buffer->updateData(offset, dataCurrentSize, data);
}

void glGenericBuffer::readData(GLuint elementCount,
                               GLuint elementOffset,
                               GLuint ringReadOffset,
                               bufferPtr dataOut) 
{
    // Calculate the size of the data that needs updating
    size_t dataCurrentSize = elementCount * _elementSize;
    // Calculate the offset in the buffer in bytes from which to start writing
    size_t offset = elementOffset * _elementSize;

    if (_ringSizeFactor > 1) {
        offset += _elementCount * _elementSize * ringReadOffset;
    }

    _buffer->readData(offset, dataCurrentSize, dataOut);
}

void glGenericBuffer::lockData(GLuint elementCount,
                               GLuint elementOffset,
                               GLuint ringReadOffset)
{
    size_t range = elementCount * _elementSize;
    size_t offset = 0;

    if (_ringSizeFactor > 1) {
        offset += _elementCount * _elementSize * ringReadOffset;
    }

    _buffer->lockRange(offset, range);
}

GLintptr glGenericBuffer::getBindOffset(GLuint ringReadOffset)
{
    GLintptr ret = static_cast<GLintptr>(_elementCountBindOffset * _elementSize);

    if (_ringSizeFactor > 1) {
        ret += _elementCount * _elementSize * ringReadOffset;
    }

    return ret;
}

void glGenericBuffer::setBindOffset(GLuint elementCountOffset) {
    _elementCountBindOffset = elementCountOffset;
}

}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Platform/Video/OpenGL/Buffers/glGenericBuffer.cpp

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

780 IonutCava picture IonutCava Tue 11 Oct, 2016 16:15:24 +0000

[IonutCava]
- AtomicCounter in glUniformBuffer is now based on a glGenericBuffer implementation
- GFXDevice <-> Camera relation cleaned up a bit
- Added a readback system for glGenericBuffer
- Fixed a bug with Z_PRE_PASS stage culling