mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Trying to get the gpu timer to work correctly
This commit is contained in:
parent
d69be5e4d2
commit
89ec547161
6 changed files with 38 additions and 13 deletions
|
@ -18,7 +18,7 @@ void GLBackend::do_beginQuery(Batch& batch, size_t paramOffset) {
|
|||
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
||||
GLQuery* glquery = syncGPUObject(*query);
|
||||
if (glquery) {
|
||||
glBeginQuery(GL_TIME_ELAPSED, glquery->_qo);
|
||||
glQueryCounter(glquery->_beginqo, GL_TIMESTAMP);
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ void GLBackend::do_endQuery(Batch& batch, size_t paramOffset) {
|
|||
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
||||
GLQuery* glquery = syncGPUObject(*query);
|
||||
if (glquery) {
|
||||
glEndQuery(GL_TIME_ELAPSED);
|
||||
glQueryCounter(glquery->_endqo, GL_TIMESTAMP);
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,12 @@ void GLBackend::do_getQuery(Batch& batch, size_t paramOffset) {
|
|||
auto query = batch._queries.get(batch._params[paramOffset]._uint);
|
||||
GLQuery* glquery = syncGPUObject(*query);
|
||||
if (glquery) {
|
||||
glGetQueryObjectui64v(glquery->_qo, GL_QUERY_RESULT_AVAILABLE, &glquery->_result);
|
||||
glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT_AVAILABLE, &glquery->_result);
|
||||
if (glquery->_result == GL_TRUE) {
|
||||
glGetQueryObjectui64v(glquery->_qo, GL_QUERY_RESULT, &glquery->_result);
|
||||
GLuint64 start, end;
|
||||
glGetQueryObjectui64v(glquery->_beginqo, GL_QUERY_RESULT, &start);
|
||||
glGetQueryObjectui64v(glquery->_endqo, GL_QUERY_RESULT, &end);
|
||||
glquery->_result = end - start;
|
||||
query->triggerReturnHandler(glquery->_result);
|
||||
}
|
||||
(void)CHECK_GL_ERROR();
|
||||
|
|
|
@ -41,15 +41,21 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
return object->_qo;
|
||||
return object->_endqo;
|
||||
}
|
||||
|
||||
const GLuint& _qo { _id };
|
||||
const GLuint& _endqo = { _id };
|
||||
const GLuint _beginqo = { 0 };
|
||||
GLuint64 _result { (GLuint64)-1 };
|
||||
|
||||
protected:
|
||||
GLQuery(const Query& query, GLuint id) : Parent(query, id) {}
|
||||
~GLQuery() { if (_id) { glDeleteQueries(1, &_id); } }
|
||||
GLQuery(const Query& query, GLuint endId, GLuint beginId) : Parent(query, endId), _beginqo(beginId){}
|
||||
~GLQuery() {
|
||||
if (_id) {
|
||||
GLuint ids[2] = { _endqo, _beginqo };
|
||||
glDeleteQueries(2, ids);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} }
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
}
|
||||
|
||||
GL41Query(const Query& query)
|
||||
: Parent(query, allocateQuery()) { }
|
||||
: Parent(query, allocateQuery(), allocateQuery()) { }
|
||||
};
|
||||
|
||||
gl::GLQuery* GL41Backend::syncGPUObject(const Query& query) {
|
||||
|
|
|
@ -19,12 +19,12 @@ class GL45Query : public gpu::gl::GLQuery {
|
|||
public:
|
||||
static GLuint allocateQuery() {
|
||||
GLuint result;
|
||||
glCreateQueries(GL_TIME_ELAPSED, 1, &result);
|
||||
glCreateQueries(GL_TIMESTAMP, 1, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
GL45Query(const Query& query)
|
||||
: Parent(query, allocateQuery()) { }
|
||||
: Parent(query, allocateQuery(), allocateQuery()){}
|
||||
};
|
||||
|
||||
gl::GLQuery* GL45Backend::syncGPUObject(const Query& query) {
|
||||
|
|
|
@ -25,7 +25,7 @@ Query::~Query()
|
|||
}
|
||||
|
||||
double Query::getElapsedTime() const {
|
||||
return ((double) _queryResult) * 0.000001;
|
||||
return ((double)_queryResult) / 1000000.0;
|
||||
}
|
||||
|
||||
void Query::triggerReturnHandler(uint64_t queryResult) {
|
||||
|
|
|
@ -241,7 +241,23 @@ Item {
|
|||
color: "#E2334D"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
PlotPerf {
|
||||
title: "Timing"
|
||||
height: parent.evalEvenHeight()
|
||||
object: parent.drawOpaqueConfig
|
||||
valueUnit: "ms"
|
||||
valueScale: 1
|
||||
valueNumDigits: "4"
|
||||
plots: [
|
||||
{
|
||||
object: Render.getConfig("RenderDeferredTask"),
|
||||
prop: "gpuTime",
|
||||
label: "RenderFrameGPU",
|
||||
color: "#00FFFF"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue