diff --git a/examples/utilities/render/stats.qml b/examples/utilities/render/stats.qml index 6326910220..0e51cb8834 100644 --- a/examples/utilities/render/stats.qml +++ b/examples/utilities/render/stats.qml @@ -122,13 +122,13 @@ Item { plots: [ { prop: "frameTriangleCount", - label: "Frame", - color: "#E2334D" + label: "Triangles", + color: "#1AC567" }, { prop: "frameTriangleRate", label: "rate", - color: "#1AC567", + color: "#E2334D", scale: 0.001, unit: "MT/s" } @@ -140,15 +140,20 @@ Item { object: stats.config trigger: stats.config["frameDrawcallCount"] plots: [ + { + prop: "frameAPIDrawcallCount", + label: "API Drawcalls", + color: "#00B4EF" + }, { prop: "frameDrawcallCount", - label: "Frame", - color: "#E2334D" + label: "GPU Drawcalls", + color: "#1AC567" }, { prop: "frameDrawcallRate", label: "rate", - color: "#1AC567", + color: "#E2334D", scale: 0.001, unit: "K/s" } diff --git a/libraries/gpu/src/gpu/Context.h b/libraries/gpu/src/gpu/Context.h index b898bddef9..7f442895a5 100644 --- a/libraries/gpu/src/gpu/Context.h +++ b/libraries/gpu/src/gpu/Context.h @@ -35,6 +35,7 @@ public: int _RSNumTextureBounded = 0; + int _DSNumAPIDrawcalls = 0; int _DSNumDrawcalls = 0; int _DSNumTriangles = 0; diff --git a/libraries/gpu/src/gpu/GLBackend.cpp b/libraries/gpu/src/gpu/GLBackend.cpp index e847ad1a42..b5b6437ed8 100644 --- a/libraries/gpu/src/gpu/GLBackend.cpp +++ b/libraries/gpu/src/gpu/GLBackend.cpp @@ -326,6 +326,7 @@ void GLBackend::do_draw(Batch& batch, size_t paramOffset) { glDrawArrays(mode, startVertex, numVertices); _stats._DSNumTriangles += numVertices / 3; _stats._DSNumDrawcalls++; + _stats._DSNumAPIDrawcalls++; (void)CHECK_GL_ERROR(); } @@ -344,6 +345,7 @@ void GLBackend::do_drawIndexed(Batch& batch, size_t paramOffset) { glDrawElements(mode, numIndices, glType, indexBufferByteOffset); _stats._DSNumTriangles += numIndices / 3; _stats._DSNumDrawcalls++; + _stats._DSNumAPIDrawcalls++; (void) CHECK_GL_ERROR(); } @@ -358,6 +360,7 @@ void GLBackend::do_drawInstanced(Batch& batch, size_t paramOffset) { glDrawArraysInstancedARB(mode, startVertex, numVertices, numInstances); _stats._DSNumTriangles += (numInstances * numVertices) / 3; _stats._DSNumDrawcalls += numInstances; + _stats._DSNumAPIDrawcalls++; (void) CHECK_GL_ERROR(); } @@ -383,6 +386,7 @@ void GLBackend::do_drawIndexedInstanced(Batch& batch, size_t paramOffset) { #endif _stats._DSNumTriangles += (numInstances * numIndices) / 3; _stats._DSNumDrawcalls += numInstances; + _stats._DSNumAPIDrawcalls++; (void)CHECK_GL_ERROR(); } @@ -395,6 +399,8 @@ void GLBackend::do_multiDrawIndirect(Batch& batch, size_t paramOffset) { glMultiDrawArraysIndirect(mode, reinterpret_cast(_input._indirectBufferOffset), commandCount, (GLsizei)_input._indirectBufferStride); _stats._DSNumDrawcalls += commandCount; + _stats._DSNumAPIDrawcalls++; + #else // FIXME implement the slow path #endif @@ -410,7 +416,7 @@ void GLBackend::do_multiDrawIndexedIndirect(Batch& batch, size_t paramOffset) { glMultiDrawElementsIndirect(mode, indexType, reinterpret_cast(_input._indirectBufferOffset), commandCount, (GLsizei)_input._indirectBufferStride); _stats._DSNumDrawcalls += commandCount; - + _stats._DSNumAPIDrawcalls++; #else // FIXME implement the slow path #endif diff --git a/libraries/render/src/render/EngineStats.cpp b/libraries/render/src/render/EngineStats.cpp index ee96e0cd86..794f278fcf 100644 --- a/libraries/render/src/render/EngineStats.cpp +++ b/libraries/render/src/render/EngineStats.cpp @@ -36,6 +36,7 @@ void EngineStats::run(const SceneContextPointer& sceneContext, const RenderConte gpu::ContextStats gpuStats(_gpuStats); renderContext->args->_context->getStats(_gpuStats); + config->frameAPIDrawcallCount = _gpuStats._DSNumAPIDrawcalls - gpuStats._DSNumAPIDrawcalls; config->frameDrawcallCount = _gpuStats._DSNumDrawcalls - gpuStats._DSNumDrawcalls; config->frameDrawcallRate = config->frameDrawcallCount * frequency; diff --git a/libraries/render/src/render/EngineStats.h b/libraries/render/src/render/EngineStats.h index 478d94855e..4a57724644 100644 --- a/libraries/render/src/render/EngineStats.h +++ b/libraries/render/src/render/EngineStats.h @@ -34,6 +34,7 @@ namespace render { Q_PROPERTY(qint64 textureCPUMemoryUsage MEMBER textureCPUMemoryUsage NOTIFY dirty) Q_PROPERTY(qint64 textureGPUMemoryUsage MEMBER textureGPUMemoryUsage NOTIFY dirty) + Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY dirty) Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY dirty) Q_PROPERTY(quint32 frameDrawcallRate MEMBER frameDrawcallRate NOTIFY dirty) @@ -57,6 +58,7 @@ namespace render { qint64 textureCPUMemoryUsage{ 0 }; qint64 textureGPUMemoryUsage{ 0 }; + quint32 frameAPIDrawcallCount{ 0 }; quint32 frameDrawcallCount{ 0 }; quint32 frameDrawcallRate{ 0 };