Merge Clement's PR12700 diffs for early trace start

This commit is contained in:
Simon Walton 2018-04-09 13:21:03 -07:00
parent d8f0cfa89a
commit 9b6306601a
19 changed files with 56 additions and 6 deletions

View file

@ -31,6 +31,8 @@
#include "UserActivityLogger.h"
#include "MainWindow.h"
#include "Profile.h"
#ifdef Q_OS_WIN
extern "C" {
typedef int(__stdcall * CHECKMINSPECPROC) ();
@ -39,7 +41,10 @@ extern "C" {
int main(int argc, const char* argv[]) {
setupHifiApplication(BuildInfo::INTERFACE_NAME);
auto tracer = DependencyManager::set<tracing::Tracer>();
tracer->startTracing();
PROFILE_SYNC_BEGIN(startup, "main startup", "");
#ifdef Q_OS_LINUX
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
#endif
@ -235,7 +240,10 @@ int main(int argc, const char* argv[]) {
argvExtended.push_back("--ignore-gpu-blacklist");
int argcExtended = (int)argvExtended.size();
PROFILE_SYNC_END(startup, "main startup", "");
PROFILE_SYNC_BEGIN(startup, "app full ctor", "");
Application app(argcExtended, const_cast<char**>(argvExtended.data()), startupTime, runningMarkerExisted);
PROFILE_SYNC_END(startup, "app full ctor", "");
#if 0
// If we failed the OpenGLVersion check, log it.
@ -273,6 +281,9 @@ int main(int argc, const char* argv[]) {
qCDebug(interfaceapp, "Created QT Application.");
exitCode = app.exec();
server.close();
tracer->stopTracing();
tracer->serialize(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Traces/trace-startup.json.gz");
}
Application::shutdownPlugins();

View file

@ -129,6 +129,7 @@ void Context::executeFrame(const FramePointer& frame) const {
}
bool Context::makeProgram(Shader& shader, const Shader::BindingSet& bindings, const Shader::CompilationHandler& handler) {
PROFILE_RANGE(app, "makeProgram");
// If we're running in another DLL context, we need to fetch the program callback out of the application
// FIXME find a way to do this without reliance on Qt app properties
if (!_makeProgramCallback) {

View file

@ -75,6 +75,7 @@ Shader::Pointer Shader::createGeometry(const Source& source) {
}
ShaderPointer Shader::createOrReuseProgramShader(Type type, const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader) {
PROFILE_RANGE(app, "createOrReuseProgramShader");
ProgramMapKey key(0);
if (vertexShader && vertexShader->getType() == VERTEX) {

View file

@ -27,6 +27,8 @@
#include "impl/SharedObject.h"
#include "impl/TextureCache.h"
#include "Profile.h"
using namespace hifi::qml;
using namespace hifi::qml::impl;
@ -284,6 +286,7 @@ void OffscreenSurface::loadInternal(const QUrl& qmlSource,
bool createNewContext,
QQuickItem* parent,
const QmlContextObjectCallback& callback) {
PROFILE_RANGE(app, "loadInternal");
if (QThread::currentThread() != thread()) {
qFatal("Called load on a non-surface thread");
}
@ -304,7 +307,11 @@ void OffscreenSurface::loadInternal(const QUrl& qmlSource,
}
auto targetContext = contextForUrl(finalQmlSource, parent, createNewContext);
auto qmlComponent = new QQmlComponent(getSurfaceContext()->engine(), finalQmlSource, QQmlComponent::PreferSynchronous);
QQmlComponent* qmlComponent;
{
PROFILE_RANGE(app, "new QQmlComponent");
qmlComponent = new QQmlComponent(getSurfaceContext()->engine(), finalQmlSource, QQmlComponent::PreferSynchronous);
}
if (qmlComponent->isLoading()) {
connect(qmlComponent, &QQmlComponent::statusChanged, this,
[=](QQmlComponent::Status) { finishQmlLoad(qmlComponent, targetContext, parent, callback); });
@ -318,6 +325,7 @@ void OffscreenSurface::finishQmlLoad(QQmlComponent* qmlComponent,
QQmlContext* qmlContext,
QQuickItem* parent,
const QmlContextObjectCallback& callback) {
PROFILE_RANGE(app, "finishQmlLoad");
disconnect(qmlComponent, &QQmlComponent::statusChanged, this, 0);
if (qmlComponent->isError()) {
for (const auto& error : qmlComponent->errors()) {

View file

@ -105,7 +105,10 @@ void SharedObject::create(OffscreenSurface* surface) {
// Create a QML engine.
auto qmlEngine = acquireEngine(surface);
_qmlContext = new QQmlContext(qmlEngine->rootContext(), qmlEngine);
{
PROFILE_RANGE(startup, "new QQmlContext");
_qmlContext = new QQmlContext(qmlEngine->rootContext(), qmlEngine);
}
surface->onRootContextCreated(_qmlContext);
emit surface->rootContextCreated(_qmlContext);
@ -175,6 +178,7 @@ static size_t globalEngineRefCount{ 0 };
#endif
QQmlEngine* SharedObject::acquireEngine(OffscreenSurface* surface) {
PROFILE_RANGE(startup, "acquireEngine");
Q_ASSERT(QThread::currentThread() == qApp->thread());
QQmlEngine* result = nullptr;

View file

@ -326,6 +326,7 @@ Bloom::Bloom() {
}
void Bloom::configure(const Config& config) {
PROFILE_RANGE(startup, "Bloom::build");
std::string blurName{ "BloomBlurN" };
for (auto i = 0; i < BLOOM_BLUR_LEVEL_COUNT; i++) {

View file

@ -476,6 +476,7 @@ void DrawHighlightTask::configure(const Config& config) {
}
void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs) {
PROFILE_RANGE(startup, "Bloom::build");
const auto items = inputs.getN<Inputs>(0).get<RenderFetchCullSortTask::BucketList>();
const auto sceneFrameBuffer = inputs.getN<Inputs>(1);
const auto primaryFramebuffer = inputs.getN<Inputs>(2);

View file

@ -76,6 +76,7 @@ const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, cons
}
void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
PROFILE_RANGE(startup, "RenderDeferredTask::build");
const auto& items = input.get<Input>();
auto fadeEffect = DependencyManager::get<FadeEffect>();

View file

@ -40,6 +40,7 @@ extern void initForwardPipelines(ShapePlumber& plumber,
extern void initOverlay3DPipelines(render::ShapePlumber& plumber, bool depthTest = false);
void RenderForwardTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
PROFILE_RANGE(startup, "RenderForwardTask::build");
auto items = input.get<Input>();
auto fadeEffect = DependencyManager::get<FadeEffect>();

View file

@ -215,6 +215,7 @@ void RenderShadowMap::run(const render::RenderContextPointer& renderContext, con
void RenderShadowTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cameraCullFunctor, uint8_t tagBits, uint8_t tagMask) {
::CullFunctor shadowCullFunctor = [this](const RenderArgs* args, const AABox& bounds) {
PROFILE_RANGE(startup, "RenderShadowTask::build");
return _cullFunctor(args, bounds);
};

View file

@ -17,6 +17,7 @@
void RenderViewTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, bool isDeferred, uint8_t tagBits, uint8_t tagMask) {
// auto items = input.get<Input>();
PROFILE_RANGE(startup, "RenderViewTask::build");
// Warning : the cull functor passed to the shadow pass should only be testing for LOD culling. If frustum culling
// is performed, then casters not in the view frustum will be removed, which is not what we wish.
task.addJob<RenderShadowTask>("RenderShadowTask", cullFunctor, tagBits, tagMask);

View file

@ -19,6 +19,7 @@
#include "DeferredLightingEffect.h"
void UpdateSceneTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
PROFILE_RANGE(startup, "UpdateSceneTask::build");
task.addJob<LightStageSetup>("LightStageSetup");
task.addJob<BackgroundStageSetup>("BackgroundStageSetup");
task.addJob<HazeStageSetup>("HazeStageSetup");

View file

@ -42,6 +42,7 @@ protected:
const Selection::Name ZoneRendererTask::ZONES_SELECTION { "RankedZones" };
void ZoneRendererTask::build(JobModel& task, const Varying& input, Varying& ouput) {
PROFILE_RANGE(startup, "ZoneRendererTask::build");
// Filter out the sorted list of zones
const auto zoneItems = task.addJob<render::SelectSortItems>("FilterZones", input, ZONES_SELECTION.c_str());

View file

@ -20,6 +20,7 @@ using namespace render;
void RenderFetchCullSortTask::build(JobModel& task, const Varying& input, Varying& output, CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) {
cullFunctor = cullFunctor ? cullFunctor : [](const RenderArgs*, const AABox&){ return true; };
PROFILE_RANGE(startup, "RenderFetchCullSortTask::build");
// CPU jobs:
// Fetch and cull the items from the scene
const ItemFilter filter = ItemFilter::Builder::visibleWorldItems().withoutLayered().withTagBits(tagBits, tagMask);

View file

@ -134,9 +134,12 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
locations->lightClusterFrustumBufferUnit = -1;
}
auto gpuPipeline = gpu::Pipeline::create(program, state);
auto shapePipeline = std::make_shared<Pipeline>(gpuPipeline, locations, batchSetter, itemSetter);
addPipelineHelper(filter, key, 0, shapePipeline);
{
PROFILE_RANGE(app, "Pipeline::create");
auto gpuPipeline = gpu::Pipeline::create(program, state);
auto shapePipeline = std::make_shared<Pipeline>(gpuPipeline, locations, batchSetter, itemSetter);
addPipelineHelper(filter, key, 0, shapePipeline);
}
}
const ShapePipelinePointer ShapePlumber::pickPipeline(RenderArgs* args, const Key& key) const {

View file

@ -27,6 +27,7 @@ Q_LOGGING_CATEGORY(trace_simulation_animation, "trace.simulation.animation")
Q_LOGGING_CATEGORY(trace_simulation_animation_detail, "trace.simulation.animation.detail")
Q_LOGGING_CATEGORY(trace_simulation_physics, "trace.simulation.physics")
Q_LOGGING_CATEGORY(trace_simulation_physics_detail, "trace.simulation.physics.detail")
Q_LOGGING_CATEGORY(trace_startup, "trace.startup")
Q_LOGGING_CATEGORY(trace_workload, "trace.workload")
#if defined(NSIGHT_FOUND)

View file

@ -32,6 +32,7 @@ Q_DECLARE_LOGGING_CATEGORY(trace_simulation_animation)
Q_DECLARE_LOGGING_CATEGORY(trace_simulation_animation_detail)
Q_DECLARE_LOGGING_CATEGORY(trace_simulation_physics)
Q_DECLARE_LOGGING_CATEGORY(trace_simulation_physics_detail)
Q_DECLARE_LOGGING_CATEGORY(trace_startup)
Q_DECLARE_LOGGING_CATEGORY(trace_workload)
class Duration {

View file

@ -256,6 +256,15 @@ void OffscreenQmlSurface::initializeEngine(QQmlEngine* engine) {
#if !defined(Q_OS_ANDROID)
rootContext->setContextProperty("FileTypeProfile", new FileTypeProfile(rootContext));
rootContext->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(rootContext));
{
PROFILE_RANGE(startup, "FileTypeProfile");
rootContext->setContextProperty("FileTypeProfile", new FileTypeProfile(rootContext));
}
{
PROFILE_RANGE(startup, "HFWebEngineProfile");
rootContext->setContextProperty("HFWebEngineProfile", new HFWebEngineProfile(rootContext));
}
#endif
rootContext->setContextProperty("Paths", DependencyManager::get<PathUtils>().data());
rootContext->setContextProperty("Tablet", DependencyManager::get<TabletScriptingInterface>().data());

View file

@ -12,6 +12,7 @@
#include <PathUtils.h>
#include "OffscreenQmlSurface.h"
#include "Profile.h"
OffscreenQmlSurfaceCache::OffscreenQmlSurfaceCache() {
}
@ -38,6 +39,7 @@ void OffscreenQmlSurfaceCache::reserve(const QString& rootSource, int count) {
}
void OffscreenQmlSurfaceCache::release(const QString& rootSource, const QSharedPointer<OffscreenQmlSurface>& surface) {
PROFILE_RANGE(app, "buildSurface");
surface->pause();
_cache[rootSource].push_back(surface);
}