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
/*
   Copyright (c) 2016 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 _CORE_PARAM_HANDLER_INL_
#define _CORE_PARAM_HANDLER_INL_

namespace Divide {

inline void ParamHandler::setDebugOutput(bool logState) {
    _logState = logState;
}

template <typename T>
inline bool ParamHandler::isParam(ULL paramID) const {
    ReadLock r_lock(_mutex);
    return _params.find(paramID) != std::cend(_params);
}

template <typename T>
inline bool ParamHandler::isParam(const char* param) const {
    return isParam<T>(_ID_RT(param));
}

template <typename T>
inline T ParamHandler::getParam(const char* name, T defaultValue) const {
    STUBBED("Please don't use strings directly for indexing with the ParamHandler");
    return getParam<T>(_ID_RT(name));
}

template <typename T>
inline T ParamHandler::getParam(ULL nameID, T defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamMap::const_iterator it = _params.find(nameID);
    if (it != std::cend(_params)) {
        bool success = false;
        const T& ret = it->second.constant_cast<T>(success);
#ifdef _DEBUG
        if (!success) {
            Console::errorfn(Locale::get(_ID("ERROR_PARAM_CAST")), nameID);
            DIVIDE_ASSERT(success,
                          "ParamHandler error: Can't cast requested param to "
                          "specified type!");
        }
#endif

        return ret;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), nameID);
    return defaultValue;  // integers will be 0, string will be empty, etc;
}

template <typename T>
inline void ParamHandler::setParam(const char* name, const T& value) {
    STUBBED("Please don't use strings directly for indexing with the ParamHandler");
    setParam<T>(_ID_RT(name), value);
}

template <typename T>
inline void ParamHandler::setParam(ULL nameID, const T& value) {
    WriteLock w_lock(_mutex);
    ParamMap::iterator it = _params.find(nameID);
    if (it == std::end(_params)) {
        DIVIDE_ASSERT(hashAlg::emplace(_params, nameID, cdiggins::any(value)).second,
                      "ParamHandler error: can't add specified value to map!");
    } else {
        it->second = cdiggins::any(value);
    }
}

template <typename T>
inline void ParamHandler::delParam(const char* name) {
    delParam<T>(_ID_RT(name));
}

template <typename T>
inline void ParamHandler::delParam(ULL nameID) {
    if (isParam<T>(nameID)) {
        WriteLock w_lock(_mutex);
        _params.erase(nameID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), nameID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), nameID);
    }
}

template <>
inline stringImpl ParamHandler::getParam(ULL paramID, stringImpl defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamStringMap::const_iterator it = _paramsStr.find(paramID);
    if (it != std::cend(_paramsStr)) {
        return it->second;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), paramID);
    return defaultValue;
}

template <>
inline void ParamHandler::setParam(ULL paramID, const stringImpl& value) {
    WriteLock w_lock(_mutex);
    ParamStringMap::iterator it = _paramsStr.find(paramID);
    if (it == std::end(_paramsStr)) {
        DIVIDE_ASSERT(hashAlg::emplace(_paramsStr, paramID, value).second,
                      "ParamHandler error: can't add specified value to map!");
    } else {
        it->second = value;
    }
}

#if defined(USE_CUSTOM_MEMORY_ALLOCATORS)
template <>
inline std::string ParamHandler::getParam(ULL paramID, std::string defaultValue) const {
    return getParam<stringImpl>(paramID, defaultValue.c_str()).c_str();
}
template <>
inline void ParamHandler::setParam(ULL paramID, const std::string& value) {
    setParam<stringImpl>(paramID, value.c_str());
}

#endif

template <>
inline bool ParamHandler::isParam<stringImpl>(ULL paramID) const {
    ReadLock r_lock(_mutex);
    return _paramsStr.find(paramID) != std::cend(_paramsStr);
}


template <>
inline void ParamHandler::delParam<stringImpl>(ULL paramID) {
    if (isParam<stringImpl>(paramID)) {
        WriteLock w_lock(_mutex);
        _paramsStr.erase(paramID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), paramID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), paramID);
    }
}

template <>
inline bool ParamHandler::getParam(ULL paramID, bool defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamBoolMap::const_iterator it = _paramBool.find(paramID);
    if (it != std::cend(_paramBool)) {
        return it->second;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), paramID);
    return defaultValue;
}

template <>
inline void ParamHandler::setParam(ULL paramID, const bool& value) {
    WriteLock w_lock(_mutex);
    ParamBoolMap::iterator it = _paramBool.find(paramID);
    if (it == std::end(_paramBool)) {
        DIVIDE_ASSERT(hashAlg::emplace(_paramBool, paramID, value).second,
                      "ParamHandler error: can't add specified value to map!");
    } else {
        it->second = value;
    }
}

template <>
inline bool ParamHandler::isParam<bool>(ULL paramID) const {
    ReadLock r_lock(_mutex);
    return _paramBool.find(paramID) != std::cend(_paramBool);
}

template <>
inline void ParamHandler::delParam<bool>(ULL paramID) {
    if (isParam<bool>(paramID)) {
        WriteLock w_lock(_mutex);
        _paramBool.erase(paramID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), paramID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), paramID);
    }
}

template <>
inline F32 ParamHandler::getParam(ULL paramID, F32 defaultValue) const {
    ReadLock r_lock(_mutex);
    ParamFloatMap::const_iterator it = _paramsFloat.find(paramID);
    if (it != std::cend(_paramsFloat)) {
        return it->second;
    }

    Console::errorfn(Locale::get(_ID("ERROR_PARAM_GET")), paramID);
    return defaultValue;
}

template <>
inline void ParamHandler::setParam(ULL paramID, const F32& value) {
    WriteLock w_lock(_mutex);
    ParamFloatMap::iterator it = _paramsFloat.find(paramID);
    if (it == std::end(_paramsFloat)) {
        DIVIDE_ASSERT(hashAlg::emplace(_paramsFloat, paramID, value).second,
                      "ParamHandler error: can't add specified value to map!");
    } else {
        it->second = value;
    }
}

template <>
inline bool ParamHandler::isParam<F32>(ULL paramID) const {
    ReadLock r_lock(_mutex);
    return _paramsFloat.find(paramID) != std::cend(_paramsFloat);
}

template <>
inline void ParamHandler::delParam<F32>(ULL paramID) {
    if (isParam<F32>(paramID)) {
        WriteLock w_lock(_mutex);
        _paramsFloat.erase(paramID);
        if (_logState) {
            Console::printfn(Locale::get(_ID("PARAM_REMOVE")), paramID);
        }
    } else {
        Console::errorfn(Locale::get(_ID("ERROR_PARAM_REMOVE")), paramID);
    }
}

};  // namespace Divide

#endif  //_CORE_PARAM_HANDLER_INL_

Commits for Divide-Framework/trunk/Source Code/Core/Headers/ParamHandler.inl

Diff revisions: vs.
Revision Author Commited Message
727 Diff Diff IonutCava picture IonutCava Tue 14 Jun, 2016 16:01:38 +0000

[IonutCava]
- Remove node and cmd buffers from GFXDevice and add them as a new BufferData struct to RenderPass class.
— Each render pass holds its own buffers
- Improvements / fixes to the CSM code
- Added a global toggle to enable/disable custom memory allocators

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

667 Diff Diff IonutCava picture IonutCava Fri 01 Apr, 2016 16:12:16 +0000

[IonutCava]
- replaced more strings with _ID equivalent
- streamlined shader include preprocessing
- improved intersection test performance for the Octree system at the cost of some memory

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

619 Diff Diff IonutCava picture IonutCava Fri 08 Jan, 2016 16:23:28 +0000

[IonutCava]
- Memory allocation optimizations
- Large VBO allocation system
- More terrain fixes
- Temporarily disable water and vegetation systems

577 Diff Diff IonutCava picture IonutCava Fri 20 Nov, 2015 15:59:10 +0000

[IonutCava]
- Replace all string indexed maps with unsigned long long indexed maps and add both compile time and runtime hashing functions to convert strings to the proper indices
— Balancing the calls between _ID and _ID_RT can reduce map lookup overhead, especially with ParamHandler and Locale::get

466 Diff Diff IonutCava picture IonutCava Fri 05 Jun, 2015 15:07:17 +0000

[Ionut]
- Moved EASTL, SimpleINI and Threadpool libraries from Dependencies repo to engine repo
- Disabled EASTL string and vector support as they are really out of date and missing required features.
— EASTL hash map is still usable

453 Diff Diff IonutCava picture IonutCava Sun 31 May, 2015 15:24:10 +0000

[Ionut]
- More linux port work

393 Diff Diff IonutCava picture IonutCava Tue 31 Mar, 2015 16:10:48 +0000

[Ionut]
- Experimental async command generation code. Functional, but improvements require performance profiling to ensure that the overhead cost is minimal.
- Simplified Singleton base class for improved performance (thanks to C++11 static initialization guarantee in a multi-threaded environment)
- Added separate alignment checking for UBOs and SSBOs
- Fixed a type on config.h affecting release builds

350 IonutCava picture IonutCava Tue 10 Feb, 2015 16:25:39 +0000

[Ionut]
- Simplified some Util-namespace level functions by using STL algorithms where possible
- Formatted the entire codebase using clang-format with the following style: "{BasedOnStyle: Google, IndentWidth: 4}"
- Attempted to make ProfileTimer thread-safe (temp fix until std::chrono works properly in Visual Studio)