From 8923055e91552a5b1ee7e6695697617cc4b449aa Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Thu, 27 Sep 2018 00:15:34 -0700 Subject: [PATCH] Exploring the bad peroformances --- .../gpu-gl/src/gpu/gl45/GL45BackendBuffer.cpp | 7 ++++--- libraries/gpu/src/gpu/Batch.cpp | 3 +++ libraries/gpu/src/gpu/Context.cpp | 3 +++ libraries/gpu/src/gpu/Frame.cpp | 2 ++ libraries/render-utils/src/Model.cpp | 15 +++------------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendBuffer.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendBuffer.cpp index cb0591c31c..62e763e488 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendBuffer.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendBuffer.cpp @@ -61,9 +61,10 @@ GLBuffer* GL45Backend::syncGPUObject(const Buffer& buffer) { bool GL45Backend::bindResourceBuffer(uint32_t slot, const BufferPointer& buffer) { - GLBuffer* object = syncGPUObject((*buffer)); - if (object) { - glBindBufferBase(GL_SHADER_STORAGE_BUFFER, slot, object->_id); + // GLBuffer* object = syncGPUObject((*buffer)); + auto bo = getBufferIDUnsynced((*buffer)); + if (bo) { + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, slot, bo); (void)CHECK_GL_ERROR(); diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index f8337fdb91..26222a2cc0 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -685,6 +685,8 @@ void Batch::_glColor4f(float red, float green, float blue, float alpha) { } void Batch::finishFrame(BufferUpdates& updates) { + PROFILE_RANGE(render_gpu, __FUNCTION__); + for (auto& mapItem : _namedData) { auto& name = mapItem.first; auto& instance = mapItem.second; @@ -713,6 +715,7 @@ void Batch::finishFrame(BufferUpdates& updates) { } void Batch::flush() { + PROFILE_RANGE(render_gpu, __FUNCTION__); for (auto& mapItem : _namedData) { auto& name = mapItem.first; auto& instance = mapItem.second; diff --git a/libraries/gpu/src/gpu/Context.cpp b/libraries/gpu/src/gpu/Context.cpp index 5783b7f59e..dd0d510509 100644 --- a/libraries/gpu/src/gpu/Context.cpp +++ b/libraries/gpu/src/gpu/Context.cpp @@ -84,6 +84,7 @@ void Context::appendFrameBatch(const BatchPointer& batch) { } FramePointer Context::endFrame() { + PROFILE_RANGE(render_gpu, __FUNCTION__); assert(_frameActive); auto result = _currentFrame; _currentFrame.reset(); @@ -101,10 +102,12 @@ void Context::executeBatch(Batch& batch) const { } void Context::recycle() const { + PROFILE_RANGE(render_gpu, __FUNCTION__); _backend->recycle(); } void Context::consumeFrameUpdates(const FramePointer& frame) const { + PROFILE_RANGE(render_gpu, __FUNCTION__); frame->preRender(); } diff --git a/libraries/gpu/src/gpu/Frame.cpp b/libraries/gpu/src/gpu/Frame.cpp index f1001d97d2..9d8bc7e973 100644 --- a/libraries/gpu/src/gpu/Frame.cpp +++ b/libraries/gpu/src/gpu/Frame.cpp @@ -25,12 +25,14 @@ Frame::~Frame() { } void Frame::finish() { + PROFILE_RANGE(render_gpu, __FUNCTION__); for (const auto& batch : batches) { batch->finishFrame(bufferUpdates); } } void Frame::preRender() { + PROFILE_RANGE(render_gpu, __FUNCTION__); for (auto& update : bufferUpdates) { update.apply(); } diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 02ba4fd4fe..e36a7d58ff 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -1669,15 +1669,6 @@ void Blender::run() { currentBlendshapeOffset.tangentOffsetAndSpare += glm::vec4(blendshape.tangents.at(j) * normalCoefficient, 0.0f); } } -/*#if FBX_PACK_NORMALS - glm::uint32 finalNormal; - glm::uint32 finalTangent; - buffer_helpers::packNormalAndTangent(normal, tangent, finalNormal, finalTangent); -#else - const auto& finalNormal = normal; - const auto& finalTangent = tangent; -#endif*/ - } }); } @@ -1697,6 +1688,7 @@ bool Model::maybeStartBlender() { } void Model::setBlendedVertices(int blendNumber, const QVector& blendshapeOffsets) { + PROFILE_RANGE(render, __FUNCTION__); if (!isLoaded() || blendNumber < _appliedBlendNumber || !_blendshapeBuffersInitialized) { return; } @@ -1712,7 +1704,7 @@ void Model::setBlendedVertices(int blendNumber, const QVector& } const auto blendshapeOffsetSize = meshBlendshapeOffsets->second.size() * sizeof(BlendshapeOffset); - buffer->second->setData(blendshapeOffsetSize, (gpu::Byte*) blendshapeOffsets.constData() + index * sizeof(BlendshapeOffset)); + buffer->second->setSubData(0, blendshapeOffsetSize, (gpu::Byte*) blendshapeOffsets.constData() + index * sizeof(BlendshapeOffset)); index += meshBlendshapeOffsets->second.size(); } @@ -1728,11 +1720,10 @@ void Model::initializeBlendshapes(const FBXMesh& mesh, int index) { } // Mesh has blendshape, let s allocate the local buffer if not done yet if (_blendshapeBuffers.find(index) == _blendshapeBuffers.end()) { - _blendshapeBuffers[index] = std::make_shared(); QVector blendshapeOffset; blendshapeOffset.fill(BlendshapeOffset(), 3 * mesh.vertices.size()); const auto blendshapeOffsetsSize = blendshapeOffset.size() * sizeof(BlendshapeOffset); - _blendshapeBuffers[index]->setData(blendshapeOffsetsSize, (const gpu::Byte*) blendshapeOffset.constData()); + _blendshapeBuffers[index] = std::make_shared(blendshapeOffsetsSize, (const gpu::Byte*) blendshapeOffset.constData(), blendshapeOffsetsSize); _blendshapeOffsets[index] = blendshapeOffset; } }