mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 23:28:27 +02:00
First stp to add a rendering job to debug and display the workload space
This commit is contained in:
parent
d1b1ae0ea3
commit
cd14fb65f0
6 changed files with 110 additions and 11 deletions
|
@ -2333,7 +2333,7 @@ void Application::initializeGL() {
|
|||
DependencyManager::get<GeometryCache>()->initializeShapePipelines();
|
||||
});
|
||||
|
||||
_gameWorkload.startup();
|
||||
_gameWorkload.startup(_main3DScene);
|
||||
|
||||
_offscreenContext = new OffscreenGLCanvas();
|
||||
_offscreenContext->setObjectName("MainThreadContext");
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
//
|
||||
#include "GameWorkload.h"
|
||||
|
||||
GameWorkloadContext::GameWorkloadContext(const render::ScenePointer& scene) : WorkloadContext(), _scene(scene) {
|
||||
}
|
||||
|
||||
GameWorkloadContext::~GameWorkloadContext() {
|
||||
}
|
||||
|
||||
|
||||
GameWorkload::GameWorkload() {
|
||||
}
|
||||
|
@ -17,8 +23,8 @@ GameWorkload::~GameWorkload() {
|
|||
shutdown();
|
||||
}
|
||||
|
||||
void GameWorkload::startup() {
|
||||
_engine.reset(new workload::Engine());
|
||||
void GameWorkload::startup(const render::ScenePointer& scene) {
|
||||
_engine.reset(new workload::Engine(std::make_shared<GameWorkloadContext>(scene)));
|
||||
|
||||
_engine->addJob<GameSpaceToRender>("SpaceToRender");
|
||||
}
|
||||
|
@ -28,5 +34,79 @@ void GameWorkload::shutdown() {
|
|||
}
|
||||
|
||||
|
||||
void GameSpaceToRender::run(const workload::WorkloadContextPointer& renderContext, Outputs& outputs) {
|
||||
|
||||
|
||||
|
||||
class GameWorkloadRenderItem {
|
||||
public:
|
||||
using Payload = render::Payload<GameWorkloadRenderItem>;
|
||||
using Pointer = Payload::DataPointer;
|
||||
|
||||
GameWorkloadRenderItem() {}
|
||||
~GameWorkloadRenderItem() {}
|
||||
void render(RenderArgs* args) {}
|
||||
|
||||
render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
|
||||
const render::Item::Bound& getBound() { return _bound; }
|
||||
|
||||
void setVisible(bool visible) { _isVisible = visible; }
|
||||
bool isVisible() const { return _isVisible; }
|
||||
|
||||
protected:
|
||||
render::Item::Bound _bound;
|
||||
|
||||
bool _needUpdate{ true };
|
||||
bool _isVisible{ true };
|
||||
};
|
||||
|
||||
namespace render {
|
||||
template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload);
|
||||
template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload);
|
||||
template <> void payloadRender(const GameWorkloadRenderItem::Pointer& payload, RenderArgs* args);
|
||||
}
|
||||
|
||||
namespace render {
|
||||
template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload) {
|
||||
auto builder = ItemKey::Builder().withTypeShape();
|
||||
return builder.build();
|
||||
}
|
||||
template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload) {
|
||||
if (payload) {
|
||||
return payload->getBound();
|
||||
}
|
||||
return Item::Bound();
|
||||
}
|
||||
template <> void payloadRender(const GameWorkloadRenderItem::Pointer& payload, RenderArgs* args) {
|
||||
if (payload) {
|
||||
payload->render(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext, Outputs& outputs) {
|
||||
auto gameWorkloadContext = std::dynamic_pointer_cast<GameWorkloadContext>(runContext);
|
||||
if (!gameWorkloadContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto scene = gameWorkloadContext->_scene;
|
||||
|
||||
// Valid space, let's display its content
|
||||
render::Transaction transaction;
|
||||
if (!render::Item::isValidID(_spaceRenderItemID)) {
|
||||
_spaceRenderItemID = scene->allocateID();
|
||||
auto renderItem = std::make_shared<GameWorkloadRenderItem>();
|
||||
renderItem->editBound().expandedContains(glm::vec3(0.0), 32000.0);
|
||||
transaction.resetItem(_spaceRenderItemID, std::make_shared<GameWorkloadRenderItem::Payload>(std::make_shared<GameWorkloadRenderItem>()));
|
||||
}
|
||||
|
||||
scene->enqueueTransaction(transaction);
|
||||
|
||||
auto space = gameWorkloadContext->_space;
|
||||
if (!space) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -24,6 +24,15 @@ public:
|
|||
void run(const workload::WorkloadContextPointer& renderContext, Outputs& outputs);
|
||||
|
||||
protected:
|
||||
render::ItemID _spaceRenderItemID{ render::Item::INVALID_ITEM_ID };
|
||||
};
|
||||
|
||||
class GameWorkloadContext : public workload::WorkloadContext {
|
||||
public:
|
||||
GameWorkloadContext(const render::ScenePointer& scene);
|
||||
virtual ~GameWorkloadContext();
|
||||
|
||||
render::ScenePointer _scene;
|
||||
};
|
||||
|
||||
class GameWorkload {
|
||||
|
@ -31,11 +40,10 @@ public:
|
|||
GameWorkload();
|
||||
~GameWorkload();
|
||||
|
||||
void startup();
|
||||
void startup(const render::ScenePointer& scene);
|
||||
void shutdown();
|
||||
|
||||
workload::EnginePointer _engine{};
|
||||
|
||||
workload::EnginePointer _engine;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -33,7 +33,7 @@ namespace workload {
|
|||
if (_isEnabled) {
|
||||
std::cout << _message.toStdString() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
WorkloadContext::WorkloadContext() : task::JobContext(trace_workload()) {}
|
||||
|
@ -50,8 +50,8 @@ namespace workload {
|
|||
}
|
||||
};
|
||||
|
||||
Engine::Engine() : Task("Engine", EngineModel::create()),
|
||||
_context(std::make_shared<WorkloadContext>()) {
|
||||
Engine::Engine(const WorkloadContextPointer& context) : Task("Engine", EngineModel::create()),
|
||||
_context(context) {
|
||||
}
|
||||
} // namespace workload
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include <task/Task.h>
|
||||
|
||||
#include "Space.h"
|
||||
|
||||
namespace workload {
|
||||
|
||||
// How to make an Engine under the task::Task<C> paradigm...
|
||||
|
@ -29,6 +31,8 @@ namespace workload {
|
|||
public:
|
||||
WorkloadContext();
|
||||
virtual ~WorkloadContext() {}
|
||||
|
||||
SpacePointer _space;
|
||||
};
|
||||
using WorkloadContextPointer = std::shared_ptr<WorkloadContext>;
|
||||
|
||||
|
@ -56,12 +60,15 @@ namespace workload {
|
|||
// (5) Engine derives from task::Task<C> and will run all the Job<C>'s
|
||||
class Engine : public Task {
|
||||
public:
|
||||
Engine();
|
||||
Engine(const WorkloadContextPointer& context = std::make_shared<WorkloadContext>());
|
||||
~Engine() = default;
|
||||
|
||||
// (6) The Engine's Context is passed to its Jobs when they are run()
|
||||
void run() { assert(_context); Task::run(_context); }
|
||||
|
||||
// Register the Space
|
||||
void registerSpace(const SpacePointer& space) { _context->_space = space; }
|
||||
|
||||
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); }
|
||||
|
|
|
@ -15,9 +15,11 @@
|
|||
#ifndef hifi_workload_Space_h
|
||||
#define hifi_workload_Space_h
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
|
||||
namespace workload {
|
||||
|
||||
class Space {
|
||||
|
@ -77,6 +79,8 @@ private:
|
|||
std::vector<int32_t> _freeIndices;
|
||||
};
|
||||
|
||||
using SpacePointer = std::shared_ptr<Space>;
|
||||
|
||||
} // namespace workload
|
||||
|
||||
#endif // hifi_workload_Space_h
|
||||
|
|
Loading…
Reference in a new issue