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

#include "Headers/GFXState.h"
#include "Headers/GFXDevice.h"

namespace Divide {

GPUState::GPUState()
{
    _loaderThread = nullptr;
    _loadingThreadAvailable = false;
    // Atomic boolean use to signal the loading thread to stop
    _closeLoadingThread = false;
    _loadQueueDataReady = false;
}

GPUState::~GPUState()
{
    stopLoaderThread();
}

bool GPUState::startLoaderThread(const DELEGATE_CBK<>& loadingFunction) {
    DIVIDE_ASSERT(_loaderThread == nullptr,
                  "GPUState::startLoaderThread error: double init detected!");

    if (Config::USE_GPU_THREADED_LOADING) {
        _loaderThread.reset(new std::thread(loadingFunction));
    }

    return true;
}

bool GPUState::stopLoaderThread() {
    if (_loaderThread.get()) {
        if (Config::USE_GPU_THREADED_LOADING) {
            DIVIDE_ASSERT(_loaderThread != nullptr,
                          "GPUState::stopLoaderThread error: stop called without "
                          "calling start first!");
            closeLoadingThread(true);
            {
                std::unique_lock<std::mutex> lk(_loadQueueMutex);
                _loadQueueDataReady = true;
                _loadQueueCV.notify_one();
            }
            while (loadingThreadAvailable()) {
                std::this_thread::sleep_for(std::chrono::milliseconds(10));
            }
            _loaderThread->join();
            _loaderThread.reset(nullptr);
        }
        return true;
    }

    return false;
}

void GPUState::addToLoadQueue(const DELEGATE_CBK<>& callback) {
#ifdef _DEBUG
    U32 retryCount = 0;
    static const U32 retyLimit = 3;
#endif
    while (!_loadQueue.push(callback)) {
        std::this_thread::sleep_for(std::chrono::milliseconds(10));
#ifdef _DEBUG
        assert(++retryCount < retyLimit);
#endif
    }
    std::unique_lock<std::mutex> lk(_loadQueueMutex);
    _loadQueueDataReady = true;
    _loadQueueCV.notify_one();
}

void GPUState::consumeOneFromQueue() {
    std::unique_lock<std::mutex> lk(_loadQueueMutex);
    _loadQueueCV.wait(lk, [this] {return _loadQueueDataReady; });
    // Try to pull a new element from the queue and process it
    while (!_closeLoadingThread && _loadQueue.consume_one(
        [](DELEGATE_CBK<>& cbk) {
            cbk();
        }))
    {
    }
    _loadQueueDataReady = false;
    lk.unlock();
    _loadQueueCV.notify_one();
}

void GPUState::registerDisplayMode(U8 displayIndex, const GPUVideoMode& mode) {
    if (displayIndex >= _supportedDislpayModes.size()) {
        _supportedDislpayModes.push_back(vectorImpl<GPUVideoMode>());
    }

    vectorImpl<GPUVideoMode>& displayModes = _supportedDislpayModes[displayIndex];

    // this is terribly slow, but should only be called a couple of times and
    // only on video hardware init
    for (GPUVideoMode& crtMode : displayModes) {
        if (crtMode._resolution == mode._resolution &&
            crtMode._bitDepth == mode._bitDepth) {
            U8 crtRefresh = mode._refreshRate.front();
            if (std::find_if(std::begin(crtMode._refreshRate),
                std::end(crtMode._refreshRate),
                [&crtRefresh](U8 refresh)
                -> bool { return refresh == crtRefresh; }) == std::end(crtMode._refreshRate)){
                crtMode._refreshRate.push_back(crtRefresh);
            }
            return;
        }
    }

    displayModes.push_back(mode);
}

};  // namespace Divide

Commits for Divide-Framework/trunk/Source Code/Platform/Video/GFXState.cpp

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

604 Diff Diff IonutCava picture IonutCava Sun 13 Dec, 2015 19:04:57 +0000

[IonutCava]
- New post processing system:
— Simplified operators
— PostFX is always enabled. Individual operators are toggles on or off
— Fixed Bloom and adaptive exposure
- Reworked texture creation and resizing
— Saved TextureDescriptor as part of the texture state

542 Diff Diff IonutCava picture IonutCava Thu 29 Oct, 2015 23:44:59 +0000

[IonutCava]
- Improved multi-threaded culling
- Increased nodeBuffer size to avoid different render stages to override each-other’s data and wait for locks
- Added a indirect command buffer per render stage

516 Diff Diff IonutCava picture IonutCava Tue 29 Sep, 2015 18:21:34 +0000

[IonutCava]
- Fixed VBO partitioning system
- Replaced some DELEGATE_BIND calls with lambda expressions
- Some multithreaded rendering work (still not functional)

515 Diff Diff IonutCava picture IonutCava Tue 29 Sep, 2015 15:51:13 +0000

[IonutCava]
- Fix a few bugs related to geometry loading and glVertexArray offsets
— Also, optimise DVDConverter a bit
- Add a conditional toggle for texture state flushing (thus allowing us to avoid generating mipmaps for shadowmaps before the blur step and again after it)
- Add an option in config.h to disable/enable multi-context resource loading
- Added SFINAE type checks to ResourceCache class

449 Diff Diff IonutCava picture IonutCava Tue 26 May, 2015 22:42:37 +0000

[Ionut]
- More work on windowing system

404 Diff Diff IonutCava picture IonutCava Sun 19 Apr, 2015 20:37:32 +0000

[Ionut]
- Threading work regarding texture loading (W.I.P.)
- Animation system cleanup (W.I.P.)
- ShaderManager shutdown cleanup improvements

401 Diff Diff IonutCava picture IonutCava Thu 16 Apr, 2015 15:55:47 +0000

[Ionut]
- Hacked together a DSA wrapper that enables the switch between OGL4.4 + GL_EXT_direct_state_access and OGL4.5 + GL_ARB_direct_state_access (some texture issues need debugging)
- Fixed a hardware state check on init
- Multithreaded hw resource loading now uses a conditional variable to check for new load commands instead of checking every 20ms reducing the load on a CPU core significantly

371 Diff Diff IonutCava picture IonutCava Sat 14 Mar, 2015 21:18:52 +0000

[Ionut]
- More updates to the DSA style OpenGL API implementation

353 IonutCava picture IonutCava Tue 17 Feb, 2015 17:08:27 +0000

[Ionut]
- Compatibility updates for Boost 1.57 (some warnings still exist for now)
- Fixed some non-conforming code
- Added ALL OF THE MISSING FILES FROM THE LAST 15 commits ...........