Merge branch 'workload' of https://github.com/highfidelity/hifi into workload

This commit is contained in:
samcake 2018-02-22 10:58:44 -08:00
commit 974ba6762d
6 changed files with 78 additions and 52 deletions

View file

@ -204,14 +204,13 @@ endif()
# link required hifi libraries
link_hifi_libraries(
shared task octree ktx gpu gl procedural graphics render
shared workload task octree ktx gpu gl procedural graphics render
pointers
recording fbx networking model-networking entities avatars trackers
audio audio-client animation script-engine physics
render-utils entities-renderer avatars-renderer ui qml auto-updater midi
controllers plugins image trackers
ui-plugins display-plugins input-plugins
workload
${PLATFORM_GL_BACKEND}
)

View file

@ -0,0 +1,24 @@
//
// ClassificationTracker.cpp
// libraries/workload/src/workload
//
// Created by Andrew Meadows 2018.02.21
// Copyright 2018 High Fidelity, Inc.
//
// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards
// Simple plane class.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "ClassificationTracker.h"
using namespace workload;
void ClassificationTracker::configure(const Config& config) {
}
void ClassificationTracker::run(const workload::WorkloadContextPointer& renderContext, Outputs& outputs) {
}

View file

@ -0,0 +1,45 @@
//
// ClassificationTracker.h
// libraries/workload/src/workload
//
// Created by Andrew Meadows 2018.02.21
// Copyright 2018 High Fidelity, Inc.
//
// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards
// Simple plane class.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_workload_ClassificationTracker_h
#define hifi_workload_ClassificationTracker_h
#include "Space.h"
#include "Engine.h"
namespace workload {
class ClassificationTrackerConfig : public Job::Config {
Q_OBJECT
public:
ClassificationTrackerConfig() : Job::Config(true) {}
};
class ClassificationTracker {
public:
using Config = ClassificationTrackerConfig;
using Outputs = Classifications;
using JobModel = workload::Job::ModelO<ClassificationTracker, Outputs, Config>;
ClassificationTracker() {}
void configure(const Config& config);
void run(const workload::WorkloadContextPointer& renderContext, Outputs& outputs);
protected:
};
} // namespace workload
#endif // hifi_workload_ClassificationTracker_h

View file

@ -16,37 +16,19 @@
#include <iostream>
namespace workload {
#include "ClassificationTracker.h"
// the "real Job"
class HelloWorld {
QString _message;
bool _isEnabled { true };
public:
using JobModel = Job::Model<HelloWorld, HelloWorldConfig>;
HelloWorld() {}
void configure(const HelloWorldConfig& configuration) {
_isEnabled = configuration.isEnabled();
_message = configuration.getMessage();
}
void run(const WorkloadContextPointer& context) {
if (_isEnabled) {
std::cout << _message.toStdString() << std::endl;
}
}
};
namespace workload {
WorkloadContext::WorkloadContext(const SpacePointer& space) : task::JobContext(trace_workload()), _space(space) {}
using EngineModel = Task::Model<class HelloWorldBuilder>;
using EngineModel = Task::Model<class EngineBuilder>;
// the 'Builder' is the 'Data' on which the EngineModel templatizes.
// It must implement build() which is called by EngineModel::create().
class HelloWorldBuilder {
class EngineBuilder {
public:
using JobModel = Task::Model<EngineModel>;
void build(EngineModel& model, const Varying& in, Varying& out) {
model.addJob<HelloWorld>("helloWorld");
auto classifications = model.addJob<ClassificationTracker>("classificationTracker");
}
};

View file

@ -24,9 +24,6 @@
namespace workload {
// How to make an Engine under the task::Task<C> paradigm...
// (1) Derive class C from task::JobContext
class WorkloadContext : public task::JobContext {
public:
WorkloadContext(const SpacePointer& space);
@ -34,40 +31,18 @@ namespace workload {
SpacePointer _space;
};
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
// (2) Apply a macro which will create local aliases (via "using") for example:
// using Task = task::Task<C>;
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
Task_DeclareTypeAliases(WorkloadContext)
// (3) You'll need a 'real Job' but it will need a Config for exposing settings to JS,
// and you should do that here:
class HelloWorldConfig : public Job::Config {
Q_OBJECT
Q_PROPERTY(QString message READ getMessage WRITE setMessage)
QString _message {"Hello World."};
public:
HelloWorldConfig() : Job::Config(true) {}
QString getMessage() const { return _message; }
void setMessage(const QString& msg) { _message = msg; }
};
// (4) In cpp file the 'real Job' will need a 'builder'. The 'builder' is the 'Data' argument
// for the Model template.
// Data must implement Data::build().
// Data::build() is called when the Model is added (in Engine ctor) as the first child job of the Engine
// (5) Engine derives from task::Task<C> and will run all the Job<C>'s
class Engine : public Task {
public:
Engine(const WorkloadContextPointer& context = std::make_shared<WorkloadContext>());
Engine(const WorkloadContextPointer& context);
~Engine() = default;
// (6) The Engine's Context is passed to its Jobs when they are run()
void run() { assert(_context); run(_context); }
protected:
// (6) Again, the Engine's Context is passed to its Jobs when they are run()
void run(const WorkloadContextPointer& context) override { assert(_context); Task::run(_context); }
private:

View file

@ -87,6 +87,7 @@ private:
};
using SpacePointer = std::shared_ptr<Space>;
using Classifications = std::vector<Space::Change>;
} // namespace workload