Exploring the bad peroformances

This commit is contained in:
Sam Gateau 2018-09-27 00:15:34 -07:00
parent 301d6c4de8
commit 8923055e91
5 changed files with 15 additions and 15 deletions

View file

@ -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();

View file

@ -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;

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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<BlendshapeOffset>& blendshapeOffsets) {
PROFILE_RANGE(render, __FUNCTION__);
if (!isLoaded() || blendNumber < _appliedBlendNumber || !_blendshapeBuffersInitialized) {
return;
}
@ -1712,7 +1704,7 @@ void Model::setBlendedVertices(int blendNumber, const QVector<BlendshapeOffset>&
}
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<gpu::Buffer>();
QVector<BlendshapeOffset> 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<gpu::Buffer>(blendshapeOffsetsSize, (const gpu::Byte*) blendshapeOffset.constData(), blendshapeOffsetsSize);
_blendshapeOffsets[index] = blendshapeOffset;
}
}