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/glHardwareQuery.h"
#include "Platform/Video/OpenGL/Headers/GLWrapper.h"

namespace Divide {

glHardwareQuery::glHardwareQuery(GFXDevice& context) 
    : glObject(glObjectType::TYPE_QUERY, context),
      _enabled(false),
      _queryID(0)
{
}

glHardwareQuery::~glHardwareQuery()
{
    destroy();
}

void glHardwareQuery::create() {
    destroy();
    glGenQueries(1, &_queryID);
}

void glHardwareQuery::destroy() {
    if (_queryID != 0) {
        glDeleteQueries(1, &_queryID);
    }
    _queryID = 0;
}

glHardwareQueryRing::glHardwareQueryRing(GFXDevice& context, U32 queueLength, U32 id)
    : RingBuffer(queueLength),
      _context(context),
      _id(id),
      _needRefresh(true)
{
    _queries.reserve(queueLength);
    for (U32 i = 0; i < queueLength; ++i) {
        _queries.push_back(std::make_shared<glHardwareQuery>(context));
    }
}

glHardwareQueryRing::~glHardwareQueryRing()
{
    _queries.clear();
}

glHardwareQuery& glHardwareQueryRing::readQuery() {
    return *_queries[queueReadIndex()];
}

glHardwareQuery& glHardwareQueryRing::writeQuery() {
    return *_queries[queueWriteIndex()];
}

void glHardwareQueryRing::initQueries() {
    if (_needRefresh) {
        for (std::shared_ptr<glHardwareQuery>& query : _queries) {
            query->create();
            assert(query->getID() != 0 && "glHardwareQueryRing error: Invalid performance counter query ID!");
            // Initialize an initial time query as it solves certain issues with
            // consecutive queries later
            glBeginQuery(GL_TIME_ELAPSED, query->getID());
            glEndQuery(GL_TIME_ELAPSED);
            // Wait until the results are available
            GLint stopTimerAvailable = 0;
            while (!stopTimerAvailable) {
                glGetQueryObjectiv(query->getID(), GL_QUERY_RESULT_AVAILABLE, &stopTimerAvailable);
            }
        }
        _needRefresh = false;
    }
}

void glHardwareQueryRing::resize(U32 queueLength) {
    RingBuffer::resize(queueLength);
    _queries.resize(0);
    _queries.reserve(queueLength);
    for (U32 i = 0; i < queueLength; ++i) {
        _queries.push_back(std::make_shared<glHardwareQuery>(_context));
    }
    _needRefresh = true;
    initQueries();
}

}; //namespace Divide

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

Diff revisions: vs.
Revision Author Commited Message
909 Diff Diff IonutCava picture IonutCava Thu 29 Jun, 2017 23:57:18 +0000

[Ionut]
- Rework RenderTarget class
— RTAttachment now deal with textures directly
— RT size needs to be specified upfront
- Application class is no longer a Singleton but passed around in the PlatformContext

904 Diff Diff IonutCava picture IonutCava Sun 25 Jun, 2017 21:38:57 +0000

[Ionut]
- Rework the way GPU queries are handled via GenericDrawCommand rendering options.

897 Diff Diff IonutCava picture IonutCava Thu 22 Jun, 2017 18:26:20 +0000

[IonutCava]
- Fix multi-context GL object creation
- Add missing file

895 IonutCava picture IonutCava Wed 21 Jun, 2017 21:10:26 +0000

[IonutCava]
- Reorder and cleanup OpenGL backend a bit.
- Small code cleanup
- Some small profile-guided optimizations