mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Merge pull request #12806 from samcake/workload
Workload: Splitting the creation of the Workload engine from the setup
This commit is contained in:
commit
f26255a936
7 changed files with 37 additions and 23 deletions
|
@ -35,7 +35,7 @@ GameWorkload::~GameWorkload() {
|
||||||
void GameWorkload::startup(const workload::SpacePointer& space,
|
void GameWorkload::startup(const workload::SpacePointer& space,
|
||||||
const render::ScenePointer& scene,
|
const render::ScenePointer& scene,
|
||||||
const PhysicalEntitySimulationPointer& simulation) {
|
const PhysicalEntitySimulationPointer& simulation) {
|
||||||
_engine.reset(new workload::Engine(std::make_shared<GameWorkloadContext>(space, scene, simulation)));
|
_engine->reset(std::make_shared<GameWorkloadContext>(space, scene, simulation));
|
||||||
|
|
||||||
auto output = _engine->getOutput();
|
auto output = _engine->getOutput();
|
||||||
_engine->addJob<GameSpaceToRender>("SpaceToRender");
|
_engine->addJob<GameSpaceToRender>("SpaceToRender");
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
|
|
||||||
void updateViews(const ViewFrustum& frustum);
|
void updateViews(const ViewFrustum& frustum);
|
||||||
|
|
||||||
workload::EnginePointer _engine;
|
workload::EnginePointer _engine { std::make_shared<workload::Engine>() };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GameWorkload_h
|
#endif // hifi_GameWorkload_h
|
||||||
|
|
|
@ -45,21 +45,22 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const workload::WorkloadContextPointer& context, const Inputs& inputs) {
|
void run(const workload::WorkloadContextPointer& context, const Inputs& inputs) {
|
||||||
|
const auto& regionChanges = inputs.get1();
|
||||||
auto space = context->_space;
|
auto space = context->_space;
|
||||||
if (!space) {
|
if (!space) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t listSize = (uint32_t)inputs.size();
|
uint32_t listSize = (uint32_t)regionChanges.size();
|
||||||
uint32_t totalTransitions = 0;
|
uint32_t totalTransitions = 0;
|
||||||
for (uint32_t i = 0; i < listSize; ++i) {
|
for (uint32_t i = 0; i < listSize; ++i) {
|
||||||
totalTransitions += (uint32_t)inputs[i].size();
|
totalTransitions += (uint32_t)regionChanges[i].size();
|
||||||
}
|
}
|
||||||
// we're interested in things entering/leaving R3
|
// we're interested in things entering/leaving R3
|
||||||
uint32_t regionIndex = workload::Region::R3;
|
uint32_t regionIndex = workload::Region::R3;
|
||||||
uint32_t exitIndex = 2 * regionIndex;
|
uint32_t exitIndex = 2 * regionIndex;
|
||||||
uint32_t numExits = (uint32_t)inputs[exitIndex].size();
|
uint32_t numExits = (uint32_t)regionChanges[exitIndex].size();
|
||||||
for (uint32_t i = 0; i < numExits; ++i) {
|
for (uint32_t i = 0; i < numExits; ++i) {
|
||||||
int32_t proxyID = inputs[exitIndex][i];
|
int32_t proxyID = regionChanges[exitIndex][i];
|
||||||
void* owner = space->getOwner(proxyID).get();
|
void* owner = space->getOwner(proxyID).get();
|
||||||
if (owner) {
|
if (owner) {
|
||||||
EntityItem* entity = static_cast<EntityItem*>(owner);
|
EntityItem* entity = static_cast<EntityItem*>(owner);
|
||||||
|
@ -71,9 +72,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t enterIndex = exitIndex + 1;
|
uint32_t enterIndex = exitIndex + 1;
|
||||||
uint32_t numEntries = (uint32_t)inputs[enterIndex].size();
|
uint32_t numEntries = (uint32_t)regionChanges[enterIndex].size();
|
||||||
for (uint32_t i = 0; i < numEntries; ++i) {
|
for (uint32_t i = 0; i < numEntries; ++i) {
|
||||||
int32_t proxyID = inputs[enterIndex][i];
|
int32_t proxyID = regionChanges[enterIndex][i];
|
||||||
void* owner = space->getOwner(proxyID).get();
|
void* owner = space->getOwner(proxyID).get();
|
||||||
if (owner) {
|
if (owner) {
|
||||||
EntityItem* entity = static_cast<EntityItem*>(owner);
|
EntityItem* entity = static_cast<EntityItem*>(owner);
|
||||||
|
|
|
@ -28,16 +28,20 @@ namespace workload {
|
||||||
void build(JobModel& model, const Varying& in, Varying& out) {
|
void build(JobModel& model, const Varying& in, Varying& out) {
|
||||||
model.addJob<SetupViews>("setupViews", in);
|
model.addJob<SetupViews>("setupViews", in);
|
||||||
model.addJob<PerformSpaceTransaction>("updateSpace");
|
model.addJob<PerformSpaceTransaction>("updateSpace");
|
||||||
const auto regionChanges = model.addJob<RegionTracker>("regionTracker");
|
const auto regionTrackerOut = model.addJob<RegionTracker>("regionTracker");
|
||||||
|
const auto regionChanges = regionTrackerOut.getN<RegionTracker::Outputs>(1);
|
||||||
model.addJob<RegionState>("regionState", regionChanges);
|
model.addJob<RegionState>("regionState", regionChanges);
|
||||||
out = regionChanges;
|
out = regionTrackerOut;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine::Engine(const WorkloadContextPointer& context) : Task("Engine", EngineBuilder::JobModel::create()),
|
Engine::Engine() : Task("Engine", EngineBuilder::JobModel::create()),
|
||||||
_context(context) {
|
_context(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::reset(const WorkloadContextPointer& context) {
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
void PerformSpaceTransaction::configure(const Config& config) {
|
void PerformSpaceTransaction::configure(const Config& config) {
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,12 @@ namespace workload {
|
||||||
|
|
||||||
class Engine : public Task {
|
class Engine : public Task {
|
||||||
public:
|
public:
|
||||||
Engine(const WorkloadContextPointer& context);
|
Engine();
|
||||||
~Engine() = default;
|
~Engine() = default;
|
||||||
|
|
||||||
void run() { assert(_context); run(_context); }
|
void reset(const WorkloadContextPointer& context);
|
||||||
|
|
||||||
|
void run() { if (_context) { run(_context); } }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run(const WorkloadContextPointer& context) override { assert(_context); Task::run(_context); }
|
void run(const WorkloadContextPointer& context) override { assert(_context); Task::run(_context); }
|
||||||
|
|
|
@ -21,22 +21,29 @@ void RegionTracker::configure(const Config& config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionTracker::run(const WorkloadContextPointer& context, Outputs& outputs) {
|
void RegionTracker::run(const WorkloadContextPointer& context, Outputs& outputs) {
|
||||||
outputs.clear();
|
auto& outChanges = outputs.edit0();
|
||||||
|
auto& outRegionChanges = outputs.edit1();
|
||||||
|
|
||||||
|
|
||||||
|
outChanges.clear();
|
||||||
|
outRegionChanges.clear();
|
||||||
|
|
||||||
auto space = context->_space;
|
auto space = context->_space;
|
||||||
if (space) {
|
if (space) {
|
||||||
Changes changes;
|
//Changes changes;
|
||||||
space->categorizeAndGetChanges(changes);
|
space->categorizeAndGetChanges(outChanges);
|
||||||
|
|
||||||
// use exit/enter lists for each region less than Region::UNKNOWN
|
// use exit/enter lists for each region less than Region::UNKNOWN
|
||||||
outputs.resize(2 * (workload::Region::NUM_CLASSIFICATIONS - 1));
|
outRegionChanges.resize(2 * (workload::Region::NUM_CLASSIFICATIONS - 1));
|
||||||
for (uint32_t i = 0; i < changes.size(); ++i) {
|
for (uint32_t i = 0; i < outChanges.size(); ++i) {
|
||||||
Space::Change& change = changes[i];
|
Space::Change& change = outChanges[i];
|
||||||
if (change.prevRegion < Region::UNKNOWN) {
|
if (change.prevRegion < Region::UNKNOWN) {
|
||||||
// EXIT list index = 2 * regionIndex
|
// EXIT list index = 2 * regionIndex
|
||||||
outputs[2 * change.prevRegion].push_back(change.proxyId);
|
outRegionChanges[2 * change.prevRegion].push_back(change.proxyId);
|
||||||
}
|
}
|
||||||
if (change.region < Region::UNKNOWN) {
|
if (change.region < Region::UNKNOWN) {
|
||||||
// ENTER list index = 2 * regionIndex + 1
|
// ENTER list index = 2 * regionIndex + 1
|
||||||
outputs[2 * change.region + 1].push_back(change.proxyId);
|
outRegionChanges[2 * change.region + 1].push_back(change.proxyId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace workload {
|
||||||
class RegionTracker {
|
class RegionTracker {
|
||||||
public:
|
public:
|
||||||
using Config = RegionTrackerConfig;
|
using Config = RegionTrackerConfig;
|
||||||
using Outputs = IndexVectors;
|
using Outputs = VaryingSet2<Changes, IndexVectors>;
|
||||||
using JobModel = workload::Job::ModelO<RegionTracker, Outputs, Config>;
|
using JobModel = workload::Job::ModelO<RegionTracker, Outputs, Config>;
|
||||||
|
|
||||||
RegionTracker() {}
|
RegionTracker() {}
|
||||||
|
|
Loading…
Reference in a new issue