mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 09:43:51 +02:00
Proposing a more flexible design for the engine
This commit is contained in:
parent
ff7fcd10e7
commit
fd752a07c1
9 changed files with 117 additions and 68 deletions
|
@ -11,13 +11,14 @@
|
||||||
#include "GameWorkloadRenderer.h"
|
#include "GameWorkloadRenderer.h"
|
||||||
#include <ViewFrustum.h>
|
#include <ViewFrustum.h>
|
||||||
#include <workload/RegionTracker.h>
|
#include <workload/RegionTracker.h>
|
||||||
|
#include <workload/SpaceClassifier.h>
|
||||||
|
|
||||||
#include "PhysicsBoundary.h"
|
#include "PhysicsBoundary.h"
|
||||||
|
|
||||||
GameWorkloadContext::GameWorkloadContext(const workload::SpacePointer& space,
|
GameWorkloadContext::GameWorkloadContext(const workload::SpacePointer& space,
|
||||||
const render::ScenePointer& scene,
|
const render::ScenePointer& scene,
|
||||||
const PhysicalEntitySimulationPointer& simulation)
|
const PhysicalEntitySimulationPointer& simulation): WorkloadContext(space),
|
||||||
: WorkloadContext(space), _scene(scene), _simulation(simulation)
|
_scene(scene), _simulation(simulation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +26,9 @@ GameWorkloadContext::~GameWorkloadContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GameWorkload::GameWorkload() {
|
GameWorkload::GameWorkload() :
|
||||||
|
_engine(std::make_shared<workload::Engine>(std::make_shared<workload::Task>(workload::SpaceClassifierTask::JobModel::create("Engine"))))
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GameWorkload::~GameWorkload() {
|
GameWorkload::~GameWorkload() {
|
||||||
|
@ -37,11 +40,11 @@ void GameWorkload::startup(const workload::SpacePointer& space,
|
||||||
const PhysicalEntitySimulationPointer& simulation) {
|
const PhysicalEntitySimulationPointer& simulation) {
|
||||||
_engine->reset(std::make_shared<GameWorkloadContext>(space, scene, simulation));
|
_engine->reset(std::make_shared<GameWorkloadContext>(space, scene, simulation));
|
||||||
|
|
||||||
auto output = _engine->getOutput();
|
auto output = _engine->_task->getOutput();
|
||||||
_engine->addJob<GameSpaceToRender>("SpaceToRender");
|
_engine->_task->addJob<GameSpaceToRender>("SpaceToRender");
|
||||||
|
|
||||||
const auto regionChanges = _engine->getOutput();
|
const auto regionChanges = _engine->_task->getOutput();
|
||||||
_engine->addJob<PhysicsBoundary>("PhysicsBoundary", regionChanges);
|
_engine->_task->addJob<PhysicsBoundary>("PhysicsBoundary", regionChanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWorkload::shutdown() {
|
void GameWorkload::shutdown() {
|
||||||
|
@ -52,6 +55,9 @@ void GameWorkload::updateViews(const ViewFrustum& frustum, const glm::vec3& head
|
||||||
workload::Views views;
|
workload::Views views;
|
||||||
views.emplace_back(workload::View::evalFromFrustum(frustum, headPosition - frustum.getPosition()));
|
views.emplace_back(workload::View::evalFromFrustum(frustum, headPosition - frustum.getPosition()));
|
||||||
views.emplace_back(workload::View::evalFromFrustum(frustum));
|
views.emplace_back(workload::View::evalFromFrustum(frustum));
|
||||||
_engine->feedInput(views);
|
_engine->_task->feedInput(views);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameWorkload::updateSimulationTiming(const workload::Timings& timings) {
|
||||||
|
// _engine->_task->feedInput(timings);
|
||||||
|
}
|
||||||
|
|
|
@ -38,8 +38,9 @@ public:
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
void updateViews(const ViewFrustum& frustum, const glm::vec3& headPosition);
|
void updateViews(const ViewFrustum& frustum, const glm::vec3& headPosition);
|
||||||
|
void updateSimulationTimings(const workload::Timings& timings);
|
||||||
|
|
||||||
workload::EnginePointer _engine { std::make_shared<workload::Engine>() };
|
workload::EnginePointer _engine;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GameWorkload_h
|
#endif // hifi_GameWorkload_h
|
||||||
|
|
|
@ -13,43 +13,11 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "ViewTask.h"
|
|
||||||
#include "RegionTracker.h"
|
|
||||||
#include "RegionState.h"
|
|
||||||
|
|
||||||
namespace workload {
|
namespace workload {
|
||||||
WorkloadContext::WorkloadContext(const SpacePointer& space) : task::JobContext(trace_workload()), _space(space) {}
|
WorkloadContext::WorkloadContext(const SpacePointer& space) : task::JobContext(trace_workload()), _space(space) {}
|
||||||
|
|
||||||
class EngineBuilder {
|
|
||||||
public:
|
|
||||||
using Inputs = Views;
|
|
||||||
using Outputs = RegionTracker::Outputs;
|
|
||||||
using JobModel = Task::ModelIO<EngineBuilder, Inputs, Outputs>;
|
|
||||||
void build(JobModel& model, const Varying& in, Varying& out) {
|
|
||||||
model.addJob<SetupViews>("setupViews", in);
|
|
||||||
model.addJob<PerformSpaceTransaction>("updateSpace");
|
|
||||||
const auto regionTrackerOut = model.addJob<RegionTracker>("regionTracker");
|
|
||||||
const auto regionChanges = regionTrackerOut.getN<RegionTracker::Outputs>(1);
|
|
||||||
model.addJob<RegionState>("regionState", regionChanges);
|
|
||||||
out = regionTrackerOut;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Engine::Engine() : Task(EngineBuilder::JobModel::create("Engine")),
|
|
||||||
_context(nullptr) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Engine::reset(const WorkloadContextPointer& context) {
|
void Engine::reset(const WorkloadContextPointer& context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerformSpaceTransaction::configure(const Config& config) {
|
|
||||||
|
|
||||||
}
|
|
||||||
void PerformSpaceTransaction::run(const WorkloadContextPointer& context) {
|
|
||||||
context->_space->enqueueFrame();
|
|
||||||
context->_space->processTransactionQueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace workload
|
} // namespace workload
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "Space.h"
|
#include "Space.h"
|
||||||
|
|
||||||
namespace workload {
|
namespace workload {
|
||||||
|
|
||||||
class WorkloadContext : public task::JobContext {
|
class WorkloadContext : public task::JobContext {
|
||||||
public:
|
public:
|
||||||
WorkloadContext(const SpacePointer& space);
|
WorkloadContext(const SpacePointer& space);
|
||||||
|
@ -35,41 +34,26 @@ namespace workload {
|
||||||
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
|
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
|
||||||
Task_DeclareTypeAliases(WorkloadContext)
|
Task_DeclareTypeAliases(WorkloadContext)
|
||||||
|
|
||||||
class Engine : public Task {
|
class Engine {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine(const std::shared_ptr<Task>& task) : _task(task), _context(nullptr) {
|
||||||
|
}
|
||||||
~Engine() = default;
|
~Engine() = default;
|
||||||
|
|
||||||
void reset(const WorkloadContextPointer& context);
|
void reset(const WorkloadContextPointer& context);
|
||||||
|
|
||||||
void run() { if (_context) { run(_context); } }
|
void run() { if (_context) { _task->run(_context); } }
|
||||||
|
|
||||||
|
std::shared_ptr<TaskConfig> getConfiguration() { return _task->getConfiguration(); }
|
||||||
|
|
||||||
|
std::shared_ptr<Task> _task;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run(const WorkloadContextPointer& context) override { assert(_context); Task::run(_context); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WorkloadContextPointer _context;
|
WorkloadContextPointer _context;
|
||||||
};
|
};
|
||||||
using EnginePointer = std::shared_ptr<Engine>;
|
using EnginePointer = std::shared_ptr<Engine>;
|
||||||
|
|
||||||
class PerformSpaceTransactionConfig : public Job::Config {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
signals :
|
|
||||||
void dirty();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
class PerformSpaceTransaction {
|
|
||||||
public:
|
|
||||||
using Config = PerformSpaceTransactionConfig;
|
|
||||||
using JobModel = Job::Model<PerformSpaceTransaction, Config>;
|
|
||||||
|
|
||||||
void configure(const Config& config);
|
|
||||||
void run(const WorkloadContextPointer& context);
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
} // namespace workload
|
} // namespace workload
|
||||||
|
|
||||||
#endif // hifi_workload_Space_h
|
#endif // hifi_workload_Space_h
|
||||||
|
|
|
@ -39,7 +39,6 @@ namespace workload {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace workload
|
} // namespace workload
|
||||||
|
|
||||||
#endif // hifi_workload_RegionTracker_h
|
#endif // hifi_workload_RegionTracker_h
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
using SpacePointer = std::shared_ptr<Space>;
|
using SpacePointer = std::shared_ptr<Space>;
|
||||||
using Changes = std::vector<Space::Change>;
|
using Changes = std::vector<Space::Change>;
|
||||||
using IndexVectors = std::vector<IndexVector>;
|
using IndexVectors = std::vector<IndexVector>;
|
||||||
|
using Timings = std::vector<float>;
|
||||||
|
|
||||||
} // namespace workload
|
} // namespace workload
|
||||||
|
|
||||||
|
|
34
libraries/workload/src/workload/SpaceClassifier.cpp
Normal file
34
libraries/workload/src/workload/SpaceClassifier.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
//
|
||||||
|
// SpaceClassifier.cpp
|
||||||
|
// libraries/workload/src/workload
|
||||||
|
//
|
||||||
|
// Created by Andrew Meadows 2018.02.21
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
#include "SpaceClassifier.h"
|
||||||
|
|
||||||
|
#include "ViewTask.h"
|
||||||
|
#include "RegionState.h"
|
||||||
|
|
||||||
|
using namespace workload;
|
||||||
|
|
||||||
|
void PerformSpaceTransaction::configure(const Config& config) {
|
||||||
|
|
||||||
|
}
|
||||||
|
void PerformSpaceTransaction::run(const WorkloadContextPointer& context) {
|
||||||
|
context->_space->enqueueFrame();
|
||||||
|
context->_space->processTransactionQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpaceClassifierTask::build(JobModel& model, const Varying& in, Varying& out) {
|
||||||
|
model.addJob<SetupViews>("setupViews", in);
|
||||||
|
model.addJob<PerformSpaceTransaction>("updateSpace");
|
||||||
|
const auto regionTrackerOut = model.addJob<RegionTracker>("regionTracker");
|
||||||
|
const auto regionChanges = regionTrackerOut.getN<RegionTracker::Outputs>(1);
|
||||||
|
model.addJob<RegionState>("regionState", regionChanges);
|
||||||
|
out = regionTrackerOut;
|
||||||
|
}
|
||||||
|
|
47
libraries/workload/src/workload/SpaceClassifier.h
Normal file
47
libraries/workload/src/workload/SpaceClassifier.h
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// SpaceClassifier.h
|
||||||
|
// libraries/workload/src/workload
|
||||||
|
//
|
||||||
|
// Created by Andrew Meadows 2018.02.21
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// 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_SpaceClassifier_h
|
||||||
|
#define hifi_workload_SpaceClassifier_h
|
||||||
|
|
||||||
|
#include "ViewTask.h"
|
||||||
|
#include "RegionTracker.h"
|
||||||
|
|
||||||
|
namespace workload {
|
||||||
|
class SpaceClassifierTask {
|
||||||
|
public:
|
||||||
|
using Inputs = Views;
|
||||||
|
using Outputs = RegionTracker::Outputs;
|
||||||
|
using JobModel = Task::ModelIO<SpaceClassifierTask, Inputs, Outputs>;
|
||||||
|
void build(JobModel& model, const Varying& in, Varying& out);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PerformSpaceTransactionConfig : public Job::Config {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
signals :
|
||||||
|
void dirty();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
|
||||||
|
class PerformSpaceTransaction {
|
||||||
|
public:
|
||||||
|
using Config = PerformSpaceTransactionConfig;
|
||||||
|
using JobModel = Job::Model<PerformSpaceTransaction, Config>;
|
||||||
|
|
||||||
|
void configure(const Config& config);
|
||||||
|
void run(const WorkloadContextPointer& context);
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
} // namespace workload
|
||||||
|
|
||||||
|
#endif // hifi_workload_SpaceClassifier_h
|
|
@ -170,8 +170,17 @@ Rectangle {
|
||||||
}
|
}
|
||||||
Separator {}
|
Separator {}
|
||||||
HifiControls.Label {
|
HifiControls.Label {
|
||||||
text: "Numbers: R2= " + Workload.getConfig("regionState")["numR2"];
|
text: "Numbers:";
|
||||||
}
|
}
|
||||||
|
HifiControls.Label {
|
||||||
|
text: "R1= " + Workload.getConfig("regionState")["numR1"];
|
||||||
|
}
|
||||||
|
HifiControls.Label {
|
||||||
|
text: "R2= " + Workload.getConfig("regionState")["numR2"];
|
||||||
|
}
|
||||||
|
HifiControls.Label {
|
||||||
|
text: "R3= " + Workload.getConfig("regionState")["numR3"];
|
||||||
|
}
|
||||||
Separator {}
|
Separator {}
|
||||||
HifiControls.Label {
|
HifiControls.Label {
|
||||||
text: "Display"
|
text: "Display"
|
||||||
|
|
Loading…
Reference in a new issue