Skip to content

Commit

Permalink
Now gpuTime keeps a cumulative count of the rendering time.
Browse files Browse the repository at this point in the history
Also, previous time is stored in `prevGpuTime`, so that the rendering
time of a frame can be computed.
  • Loading branch information
Erkaman committed Jul 6, 2016
1 parent ca5fc5e commit 8e10cbb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion example/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ function createStatsWidget () {
var drawCall
var str
var textCursor = [TEXT_START[0], TEXT_START[1]]
var diff
for (var i = 0; i < drawCalls.length; i++) {
drawCall = drawCalls[i]
str = drawCall[1] + ' : ' + Math.round(100.0 * drawCall[0].stats.gpuTime) / 100.0 + 'ms'
diff = drawCall[0].stats.gpuTime - drawCall[0].stats.prevGpuTime
str = drawCall[1] + ' : ' + Math.round(100.0 * diff) / 100.0 + 'ms'

context.fillText(str, textCursor[0] * pr, textCursor[1] * pr)
textCursor[1] += TEXT_SIZE + TEXT_SPACING
Expand Down
3 changes: 2 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,8 @@ module.exports = function reglCore (
draw(
env.cond(stats, '.iCollect>=0')
.then(
stats, '.gpuTime=(1.0/(1000.0 * 1000.0) )*',
stats, '.prevGpuTime=', stats, '.gpuTime;',
stats, '.gpuTime+=(1.0/(1000.0 * 1000.0) )*',
EXT_DISJOINT_TIMER_QUERY, '.getQueryObjectEXT(',
stats, '.', '_queries[', stats, '.iCollect', '],', // query
EXT_DISJOINT_TIMER_QUERY, '.QUERY_RESULT_EXT);'
Expand Down
3 changes: 2 additions & 1 deletion regl.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ module.exports = function wrapREGL () {
var opts = separateDynamic(flattenNestedOptions(options))

var stats = {
gpuTime: -1.0
gpuTime: 0.0,
prevGpuTime: 0.0
}
if (extensions.ext_disjoint_timer_query) {
// FIXME: destroy these two queries somewhere.
Expand Down

0 comments on commit 8e10cbb

Please sign in to comment.