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
#include "stdafx.h"

#include "Headers/ByteBuffer.h"

#include "Core/Headers/Console.h"
#include "Core/Headers/StringHelper.h"

#include "Utility/Headers/Localization.h"

#include "Platform/File/Headers/FileManagement.h"

namespace Divide {

ByteBufferException::ByteBufferException(bool add, size_t pos, size_t esize, size_t size)
  : _add(add), _pos(pos), _esize(esize), _size(size)
{
    printPosError();
}

void ByteBufferException::printPosError() const {

    Console::errorfn(Locale::get(_ID("BYTE_BUFFER_ERROR")),
                     (_add ? "append" : "read"), 
                     _pos,
                     _esize,
                     _size);
}

ByteBuffer::ByteBuffer() : ByteBuffer(DEFAULT_SIZE)
{
}

// constructor
ByteBuffer::ByteBuffer(size_t res) : _rpos(0), _wpos(0)
{
    _storage.reserve(res);
}

// copy constructor
ByteBuffer::ByteBuffer(const ByteBuffer &buf)
    : _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage)
{
}

ByteBuffer& ByteBuffer::operator=(const ByteBuffer &buf) {
    _rpos = buf._rpos;
    _wpos = buf._rpos;
    _storage = buf._storage;

    return *this;
}

void ByteBuffer::clear() {
    _storage.clear();
    _rpos = _wpos = 0;
}

void ByteBuffer::append(const Byte *src, size_t cnt) {
    if (src != nullptr && cnt > 0) {
        if (_storage.size() < _wpos + cnt) {
            _storage.resize(_wpos + cnt);
        }

        memcpy(&_storage[_wpos], src, cnt);
        _wpos += cnt;
    }
}


bool ByteBuffer::dumpToFile(const stringImpl& fileName) {
    if (!_storage.empty() && _storage.back() != BUFFER_FORMAT_VERSION) {
        append(BUFFER_FORMAT_VERSION);
    }

    return writeFile(fileName, _storage.data(), _storage.size(), FileType::BINARY);
}

bool ByteBuffer::loadFromFile(const stringImpl& fileName) {
    clear();
    if (readFile(fileName, _storage, FileType::BINARY)) {
        return _storage.back() == BUFFER_FORMAT_VERSION;
    }

    return false;
}

};  // namespace Divide

Commits for Divide-Framework/trunk/Source Code/Core/ByteBuffer.cpp

Diff revisions: vs.
Revision Author Commited Message
893 Diff Diff IonutCava picture IonutCava Sun 18 Jun, 2017 17:33:07 +0000

[Ionut]
- Initial implementation of a PipelineStateObject (holds shader program, rasterizer state, etc)
- Rework PCH implementation a bit because VS2017 no longer has a /ZM option

890 Diff Diff IonutCava picture IonutCava Sun 14 May, 2017 20:54:59 +0000

[Ionut]
- Add pre-compiled header support
- Initial code for per-stage tessellation computation

879 Diff Diff IonutCava picture IonutCava Sun 19 Mar, 2017 19:29:46 +0000

[IonutCava]
- GLSL updates:
— Interface block correction to support tessellation shaders automatically
— Fixed line counting issues with the preprocessor

855 Diff Diff IonutCava picture IonutCava Thu 09 Feb, 2017 17:21:35 +0000

[IonutCava]
- Cleanup and optimize ByteBuffer class (native support for vector and array read/writes)
- Cleanup file read/write functions
- Promote ByteBuffer class from a platform specific feature to a core feature

832 Diff Diff IonutCava picture IonutCava Thu 26 Jan, 2017 17:23:11 +0000

[IonutCava]
- More path related work
- Initial code to centralize file I/O (does not compile yet)

671 Diff Diff IonutCava picture IonutCava Fri 08 Apr, 2016 16:26:49 +0000

[Ionut]
- Custom memory allocation system part 1:
— Add http://www.codeproject.com/Articles/1089905/A-Custom-STL-std-allocator-Replacement-Improves-Pe
— Add custom allocators to strings and vectors
— Add custom allocators to a few test classes
— No support for aligned memory yet, so vec4<F32> and mat4<F32> vectors use the old allocation system
- Replace more std::async call with our custom task system

540 Diff Diff IonutCava picture IonutCava Wed 28 Oct, 2015 19:06:28 +0000

[IonutCava]
- Remove the “Platform” folder from the Platform project as the name is redundant. Move files one level up

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.

513 Diff Diff IonutCava picture IonutCava Mon 21 Sep, 2015 16:04:28 +0000

[IonutCava]
- Some code cleanup

512 IonutCava picture IonutCava Fri 04 Sep, 2015 10:23:54 +0000

[IonutCava]
- Small correction to vertex buffer compression