mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:17:28 +02:00
Merge branch 'workload' of https://github.com/highfidelity/hifi into workload
This commit is contained in:
commit
974ba6762d
6 changed files with 78 additions and 52 deletions
|
@ -204,14 +204,13 @@ endif()
|
||||||
|
|
||||||
# link required hifi libraries
|
# link required hifi libraries
|
||||||
link_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
|
pointers
|
||||||
recording fbx networking model-networking entities avatars trackers
|
recording fbx networking model-networking entities avatars trackers
|
||||||
audio audio-client animation script-engine physics
|
audio audio-client animation script-engine physics
|
||||||
render-utils entities-renderer avatars-renderer ui qml auto-updater midi
|
render-utils entities-renderer avatars-renderer ui qml auto-updater midi
|
||||||
controllers plugins image trackers
|
controllers plugins image trackers
|
||||||
ui-plugins display-plugins input-plugins
|
ui-plugins display-plugins input-plugins
|
||||||
workload
|
|
||||||
${PLATFORM_GL_BACKEND}
|
${PLATFORM_GL_BACKEND}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
24
libraries/workload/src/workload/ClassificationTracker.cpp
Normal file
24
libraries/workload/src/workload/ClassificationTracker.cpp
Normal 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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
45
libraries/workload/src/workload/ClassificationTracker.h
Normal file
45
libraries/workload/src/workload/ClassificationTracker.h
Normal 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
|
|
@ -16,37 +16,19 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
namespace workload {
|
#include "ClassificationTracker.h"
|
||||||
|
|
||||||
// the "real Job"
|
namespace workload {
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WorkloadContext::WorkloadContext(const SpacePointer& space) : task::JobContext(trace_workload()), _space(space) {}
|
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.
|
class EngineBuilder {
|
||||||
// It must implement build() which is called by EngineModel::create().
|
|
||||||
class HelloWorldBuilder {
|
|
||||||
public:
|
public:
|
||||||
using JobModel = Task::Model<EngineModel>;
|
using JobModel = Task::Model<EngineModel>;
|
||||||
void build(EngineModel& model, const Varying& in, Varying& out) {
|
void build(EngineModel& model, const Varying& in, Varying& out) {
|
||||||
model.addJob<HelloWorld>("helloWorld");
|
auto classifications = model.addJob<ClassificationTracker>("classificationTracker");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,6 @@
|
||||||
|
|
||||||
namespace workload {
|
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 {
|
class WorkloadContext : public task::JobContext {
|
||||||
public:
|
public:
|
||||||
WorkloadContext(const SpacePointer& space);
|
WorkloadContext(const SpacePointer& space);
|
||||||
|
@ -34,40 +31,18 @@ namespace workload {
|
||||||
|
|
||||||
SpacePointer _space;
|
SpacePointer _space;
|
||||||
};
|
};
|
||||||
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
|
|
||||||
|
|
||||||
// (2) Apply a macro which will create local aliases (via "using") for example:
|
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
|
||||||
// using Task = task::Task<C>;
|
|
||||||
Task_DeclareTypeAliases(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 {
|
class Engine : public Task {
|
||||||
public:
|
public:
|
||||||
Engine(const WorkloadContextPointer& context = std::make_shared<WorkloadContext>());
|
Engine(const WorkloadContextPointer& context);
|
||||||
~Engine() = default;
|
~Engine() = default;
|
||||||
|
|
||||||
// (6) The Engine's Context is passed to its Jobs when they are run()
|
|
||||||
void run() { assert(_context); run(_context); }
|
void run() { assert(_context); run(_context); }
|
||||||
|
|
||||||
protected:
|
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); }
|
void run(const WorkloadContextPointer& context) override { assert(_context); Task::run(_context); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -87,6 +87,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
using SpacePointer = std::shared_ptr<Space>;
|
using SpacePointer = std::shared_ptr<Space>;
|
||||||
|
using Classifications = std::vector<Space::Change>;
|
||||||
|
|
||||||
} // namespace workload
|
} // namespace workload
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue