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

#include "Headers/ProfileTimer.h"
#include "Headers/ApplicationTimer.h"
#include "Core/Headers/Console.h"

namespace Divide {
namespace Time {

namespace {
    std::array<ProfileTimer, Config::Profile::MAX_PROFILE_TIMERS> g_profileTimers;
    std::array<bool, Config::Profile::MAX_PROFILE_TIMERS> g_profileTimersState;

    bool g_timersInit = false;
};

ScopedTimer::ScopedTimer(ProfileTimer& timer) 
    : _timer(timer)
{
    _timer.start();
}

ScopedTimer::~ScopedTimer()
{
    _timer.stop();
}

ProfileTimer::ProfileTimer()
    : _timer(0UL),
      _timerAverage(0UL),
      _timerCounter(0),
      _globalIndex(0),
      _parent(Config::Profile::MAX_PROFILE_TIMERS + 1)
{
}

ProfileTimer::~ProfileTimer()
{
}

void ProfileTimer::start() {
    if (Config::Profile::ENABLE_FUNCTION_PROFILING) {
        _timer = ElapsedMicroseconds(true);
    }
}

void ProfileTimer::stop() {
    if (Config::Profile::ENABLE_FUNCTION_PROFILING) {
        _timerAverage += ElapsedMicroseconds(true) - _timer;
        _timerCounter++;
    }
}

void ProfileTimer::reset() {
    _timerAverage = 0;
    _timerCounter = 0;
}

void ProfileTimer::addChildTimer(ProfileTimer& child) {
    U32 childID = child._globalIndex;
    // must not have a parent
    assert(child._parent > Config::Profile::MAX_PROFILE_TIMERS);
    // must be unique child
    assert(std::find_if(std::cbegin(_children),
                        std::cend(_children),
                        [childID](U32 entry) {
                            return entry == childID;
                        }) == std::cend(_children));

    _children.push_back(childID);
    child._parent = _globalIndex;
}

stringImpl ProfileTimer::print(U32 level) const {
    if (Config::Profile::ENABLE_FUNCTION_PROFILING) {
        stringImpl ret(Util::StringFormat("[ %s ] : [ %5.3f ms]",
                                          _name.c_str(),
                                          MicrosecondsToMilliseconds<F32>(get())));
        for (U32 child : _children) {
            ret.append("\n    " + g_profileTimers[child].print(level + 1));
        }

        for (U32 i = 0; i < level; ++i) {
            ret.insert(0, "    ");
        }

        return ret;
    }

    return "";
}

U64 ProfileTimer::overhead() {
    ProfileTimer test;
    test.start();
    test.stop();
    return test.get();
}

stringImpl ProfileTimer::printAll() {
    stringImpl ret(Util::StringFormat("Profiler overhead: [%d us]\n", overhead()));

    for (ProfileTimer& entry : g_profileTimers) {
        if (!g_profileTimersState[entry._globalIndex] ||
                entry._parent < Config::Profile::MAX_PROFILE_TIMERS ||
                    entry._timerCounter == 0) {
            continue;
        }
        ret.append(entry.print());
        ret.append("\n");
        entry.reset();
    }

    return ret;
}

ProfileTimer& ProfileTimer::getNewTimer(const char* timerName) {
    if (!g_timersInit) {
        g_profileTimersState.fill(false);

        U32 index = 0;
        for (ProfileTimer& entry : g_profileTimers) {
            entry._globalIndex = index++;
        }
        g_timersInit = true;
    }

    for (ProfileTimer& entry : g_profileTimers) {
        if (!g_profileTimersState[entry._globalIndex]) {
            entry.reset();
            entry._name = timerName;
            g_profileTimersState[entry._globalIndex] = true;
            return entry;
        }
    }

    DIVIDE_UNEXPECTED_CALL("Reached max profile timer count!");
    return g_profileTimers[0];
}

void ProfileTimer::removeTimer(ProfileTimer& timer) {
    g_profileTimersState[timer._globalIndex] = false;
}

};  // namespace Time
};  // namespace Divide

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

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

712 Diff Diff IonutCava picture IonutCava Tue 24 May, 2016 16:18:37 +0000

[IonutCava]
- Added the concept of “buffer” to be used by GenericVertexData and ShaderBuffer without caring if it’s persistent or not.
— Persistent buffers handle their own locking instead of relying on the parent class
- HiZ occlusion culling fixes and optimizations

695 Diff Diff IonutCava picture IonutCava Sun 08 May, 2016 22:45:32 +0000

[IonutCava]
- Better separation of rigid body based physics and standard transform system

693 IonutCava picture IonutCava Thu 28 Apr, 2016 16:19:35 +0000

[IonutCava]
- Cleanup Time and Profiling code