mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:57:18 +02:00
Moving the stage objects under the scene umbrella and creating a cear task to update the scene elements
This commit is contained in:
parent
2919607f86
commit
9ae2861ee6
10 changed files with 140 additions and 14 deletions
|
@ -111,10 +111,7 @@
|
||||||
#include <plugins/SteamClientPlugin.h>
|
#include <plugins/SteamClientPlugin.h>
|
||||||
#include <RecordingScriptingInterface.h>
|
#include <RecordingScriptingInterface.h>
|
||||||
#include <RenderableWebEntityItem.h>
|
#include <RenderableWebEntityItem.h>
|
||||||
#include <RenderShadowTask.h>
|
#include <UpdateSceneTask.h>
|
||||||
#include <render/RenderFetchCullSortTask.h>
|
|
||||||
#include <RenderDeferredTask.h>
|
|
||||||
#include <RenderForwardTask.h>
|
|
||||||
#include <RenderViewTask.h>
|
#include <RenderViewTask.h>
|
||||||
#include <SecondaryCamera.h>
|
#include <SecondaryCamera.h>
|
||||||
#include <ResourceCache.h>
|
#include <ResourceCache.h>
|
||||||
|
@ -1902,6 +1899,7 @@ void Application::initializeGL() {
|
||||||
render::CullFunctor cullFunctor = LODManager::shouldRender;
|
render::CullFunctor cullFunctor = LODManager::shouldRender;
|
||||||
static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
|
static const QString RENDER_FORWARD = "HIFI_RENDER_FORWARD";
|
||||||
bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
|
bool isDeferred = !QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
|
||||||
|
_renderEngine->addJob<UpdateSceneTask>("UpdateScene");
|
||||||
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraFrame", cullFunctor);
|
_renderEngine->addJob<SecondaryCameraRenderTask>("SecondaryCameraFrame", cullFunctor);
|
||||||
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
|
_renderEngine->addJob<RenderViewTask>("RenderMainView", cullFunctor, isDeferred);
|
||||||
_renderEngine->load();
|
_renderEngine->load();
|
||||||
|
|
|
@ -137,4 +137,15 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BackgroundStageSetup::BackgroundStageSetup() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void BackgroundStageSetup::run(const render::RenderContextPointer& renderContext) {
|
||||||
|
auto stage = renderContext->_scene->getStage("BACKGROUND_STAGE");
|
||||||
|
if (!stage) {
|
||||||
|
renderContext->_scene->resetStage("BACKGROUND_STAGE", std::make_shared<BackgroundStage>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,13 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <render/IndexedContainer.h>
|
#include <render/IndexedContainer.h>
|
||||||
|
#include <render/Stage.h>
|
||||||
|
|
||||||
#include "LightingModel.h"
|
#include "LightingModel.h"
|
||||||
|
|
||||||
|
|
||||||
// Background stage to set up background-related rendering tasks
|
// Background stage to set up background-related rendering tasks
|
||||||
class BackgroundStage {
|
class BackgroundStage : public render::Stage {
|
||||||
public:
|
public:
|
||||||
using Index = render::indexed_container::Index;
|
using Index = render::indexed_container::Index;
|
||||||
static const Index INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
static const Index INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
||||||
|
@ -66,6 +67,15 @@ public:
|
||||||
};
|
};
|
||||||
using BackgroundStagePointer = std::shared_ptr<BackgroundStage>;
|
using BackgroundStagePointer = std::shared_ptr<BackgroundStage>;
|
||||||
|
|
||||||
|
class BackgroundStageSetup {
|
||||||
|
public:
|
||||||
|
using JobModel = render::Job::Model<BackgroundStageSetup>;
|
||||||
|
|
||||||
|
BackgroundStageSetup();
|
||||||
|
void run(const render::RenderContextPointer& renderContext);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
|
||||||
class DrawBackgroundStage {
|
class DrawBackgroundStage {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -165,3 +165,13 @@ void LightStage::updateLightArrayBuffer(Index lightId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LightStageSetup::LightStageSetup() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightStageSetup::run(const render::RenderContextPointer& renderContext) {
|
||||||
|
auto stage = renderContext->_scene->getStage("LIGHT_STAGE");
|
||||||
|
if (!stage) {
|
||||||
|
renderContext->_scene->resetStage("LIGHT_STAGE", std::make_shared<LightStage>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,16 +14,19 @@
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include <gpu/Framebuffer.h>
|
||||||
|
|
||||||
|
#include <model/Light.h>
|
||||||
|
|
||||||
#include <render/IndexedContainer.h>
|
#include <render/IndexedContainer.h>
|
||||||
|
#include <render/Stage.h>
|
||||||
#include "gpu/Framebuffer.h"
|
#include <render/Engine.h>
|
||||||
|
|
||||||
#include "model/Light.h"
|
|
||||||
|
|
||||||
class ViewFrustum;
|
class ViewFrustum;
|
||||||
|
|
||||||
// Light stage to set up light-related rendering tasks
|
// Light stage to set up light-related rendering tasks
|
||||||
class LightStage {
|
class LightStage : public render::Stage {
|
||||||
public:
|
public:
|
||||||
using Index = render::indexed_container::Index;
|
using Index = render::indexed_container::Index;
|
||||||
static const Index INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
static const Index INVALID_INDEX { render::indexed_container::INVALID_INDEX };
|
||||||
|
@ -149,5 +152,15 @@ using LightStagePointer = std::shared_ptr<LightStage>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class LightStageSetup {
|
||||||
|
public:
|
||||||
|
using JobModel = render::Job::Model<LightStageSetup>;
|
||||||
|
|
||||||
|
LightStageSetup();
|
||||||
|
void run(const render::RenderContextPointer& renderContext);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
24
libraries/render-utils/src/UpdateSceneTask.cpp
Normal file
24
libraries/render-utils/src/UpdateSceneTask.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// UpdateSceneTask.cpp
|
||||||
|
// render-utils/src/
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 6/21/2017.
|
||||||
|
// Copyright 2017 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 "UpdateSceneTask.h"
|
||||||
|
|
||||||
|
#include <render/SceneTask.h>
|
||||||
|
#include "LightStage.h"
|
||||||
|
#include "BackgroundStage.h"
|
||||||
|
|
||||||
|
void UpdateSceneTask::build(JobModel& task, const render::Varying& input, render::Varying& output) {
|
||||||
|
|
||||||
|
task.addJob<render::PerformSceneTransaction>("PerformSceneTransaction");
|
||||||
|
|
||||||
|
task.addJob<LightStageSetup>("LightStageSetup");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
30
libraries/render-utils/src/UpdateSceneTask.h
Normal file
30
libraries/render-utils/src/UpdateSceneTask.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
//
|
||||||
|
// UpdateSceneTask.h
|
||||||
|
// render-utils/src/
|
||||||
|
//
|
||||||
|
// Created by Sam Gateau on 6/21/2017.
|
||||||
|
// Copyright 2017 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
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
#ifndef hifi_UpdateSceneTask_h
|
||||||
|
#define hifi_UpdateSceneTask_h
|
||||||
|
|
||||||
|
#include <render/Engine.h>
|
||||||
|
#include <render/RenderFetchCullSortTask.h>
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateSceneTask {
|
||||||
|
public:
|
||||||
|
using JobModel = render::Task::Model<UpdateSceneTask>;
|
||||||
|
|
||||||
|
UpdateSceneTask() {}
|
||||||
|
|
||||||
|
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // hifi_UpdateSceneTask_h
|
|
@ -33,7 +33,6 @@ public:
|
||||||
|
|
||||||
void build(JobModel& task, const Varying& in, Varying& out) {
|
void build(JobModel& task, const Varying& in, Varying& out) {
|
||||||
task.addJob<EngineStats>("Stats");
|
task.addJob<EngineStats>("Stats");
|
||||||
task.addJob<PerformSceneTransaction>("PerformSceneTransaction");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -237,3 +237,26 @@ void Scene::resetSelections(const Selections& selections) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Access a particular Stage (empty if doesn't exist)
|
||||||
|
// Thread safe
|
||||||
|
StagePointer Scene::getStage(const Stage::Name& name) const {
|
||||||
|
std::unique_lock<std::mutex> lock(_stagesMutex);
|
||||||
|
auto found = _stages.find(name);
|
||||||
|
if (found == _stages.end()) {
|
||||||
|
return StagePointer();
|
||||||
|
} else {
|
||||||
|
return (*found).second;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Scene::resetStage(const Stage::Name& name, const StagePointer& stage) {
|
||||||
|
std::unique_lock<std::mutex> lock(_stagesMutex);
|
||||||
|
auto found = _stages.find(name);
|
||||||
|
if (found == _stages.end()) {
|
||||||
|
_stages.insert(StageMap::value_type(name, stage));
|
||||||
|
} else {
|
||||||
|
(*found).second = stage;
|
||||||
|
}
|
||||||
|
}
|
|
@ -111,6 +111,14 @@ public:
|
||||||
// Access non-spatialized items (overlays, backgrounds)
|
// Access non-spatialized items (overlays, backgrounds)
|
||||||
const ItemIDSet& getNonspatialSet() const { return _masterNonspatialSet; }
|
const ItemIDSet& getNonspatialSet() const { return _masterNonspatialSet; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Access a particular Stage (empty if doesn't exist)
|
||||||
|
// Thread safe
|
||||||
|
StagePointer getStage(const Stage::Name& name) const;
|
||||||
|
void resetStage(const Stage::Name& name, const StagePointer& stage);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Thread safe elements that can be accessed from anywhere
|
// Thread safe elements that can be accessed from anywhere
|
||||||
std::atomic<unsigned int> _IDAllocator{ 1 }; // first valid itemID will be One
|
std::atomic<unsigned int> _IDAllocator{ 1 }; // first valid itemID will be One
|
||||||
|
@ -139,11 +147,11 @@ protected:
|
||||||
// void appendToSelection(const Selection& selection);
|
// void appendToSelection(const Selection& selection);
|
||||||
// void mergeWithSelection(const Selection& selection);
|
// void mergeWithSelection(const Selection& selection);
|
||||||
|
|
||||||
// The Stages
|
// The Stage map
|
||||||
|
mutable std::mutex _stagesMutex; // mutable so it can be used in the thread safe getStage const method
|
||||||
StageMap _stages;
|
StageMap _stages;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
friend class Engine;
|
friend class Engine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue