mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 19:50:38 +02:00
Merge pull request #15569 from SamGondelman/switch
BUGZ-187: Proper Render Scripting Interface with renderMethod property
This commit is contained in:
commit
ffbe055fa8
6 changed files with 116 additions and 12 deletions
|
@ -193,8 +193,7 @@
|
||||||
#include "scripting/TTSScriptingInterface.h"
|
#include "scripting/TTSScriptingInterface.h"
|
||||||
#include "scripting/KeyboardScriptingInterface.h"
|
#include "scripting/KeyboardScriptingInterface.h"
|
||||||
#include "scripting/PerformanceScriptingInterface.h"
|
#include "scripting/PerformanceScriptingInterface.h"
|
||||||
|
#include "scripting/RenderScriptingInterface.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||||
#include "SpeechRecognizer.h"
|
#include "SpeechRecognizer.h"
|
||||||
|
@ -3328,7 +3327,7 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) {
|
||||||
surfaceContext->setContextProperty("LODManager", DependencyManager::get<LODManager>().data());
|
surfaceContext->setContextProperty("LODManager", DependencyManager::get<LODManager>().data());
|
||||||
surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
surfaceContext->setContextProperty("HMD", DependencyManager::get<HMDScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
surfaceContext->setContextProperty("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("Render", _graphicsEngine.getRenderEngine()->getConfiguration().get());
|
surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance());
|
||||||
surfaceContext->setContextProperty("Workload", _gameWorkload._engine->getConfiguration().get());
|
surfaceContext->setContextProperty("Workload", _gameWorkload._engine->getConfiguration().get());
|
||||||
surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
|
surfaceContext->setContextProperty("Reticle", getApplicationCompositor().getReticleInterface());
|
||||||
surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
surfaceContext->setContextProperty("Snapshot", DependencyManager::get<Snapshot>().data());
|
||||||
|
@ -3443,7 +3442,7 @@ void Application::setupQmlSurface(QQmlContext* surfaceContext, bool setAdditiona
|
||||||
surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
|
surfaceContext->setContextProperty("InputConfiguration", DependencyManager::get<InputConfiguration>().data());
|
||||||
surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
|
surfaceContext->setContextProperty("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
|
surfaceContext->setContextProperty("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
|
||||||
surfaceContext->setContextProperty("Render", AbstractViewStateInterface::instance()->getRenderEngine()->getConfiguration().get());
|
surfaceContext->setContextProperty("Render", RenderScriptingInterface::getInstance());
|
||||||
surfaceContext->setContextProperty("Workload", qApp->getGameWorkload()._engine->getConfiguration().get());
|
surfaceContext->setContextProperty("Workload", qApp->getGameWorkload()._engine->getConfiguration().get());
|
||||||
surfaceContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
surfaceContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
||||||
surfaceContext->setContextProperty("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
|
surfaceContext->setContextProperty("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
|
||||||
|
@ -7397,7 +7396,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
|
||||||
scriptEngine->registerFunction("HMD", "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0);
|
scriptEngine->registerFunction("HMD", "getHUDLookAtPosition3D", HMDScriptingInterface::getHUDLookAtPosition3D, 0);
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
||||||
scriptEngine->registerGlobalObject("Render", _graphicsEngine.getRenderEngine()->getConfiguration().get());
|
scriptEngine->registerGlobalObject("Render", RenderScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Workload", _gameWorkload._engine->getConfiguration().get());
|
scriptEngine->registerGlobalObject("Workload", _gameWorkload._engine->getConfiguration().get());
|
||||||
|
|
||||||
GraphicsScriptingInterface::registerMetaTypes(scriptEngine.data());
|
GraphicsScriptingInterface::registerMetaTypes(scriptEngine.data());
|
||||||
|
|
|
@ -290,7 +290,6 @@ public:
|
||||||
render::EnginePointer getRenderEngine() override { return _graphicsEngine.getRenderEngine(); }
|
render::EnginePointer getRenderEngine() override { return _graphicsEngine.getRenderEngine(); }
|
||||||
gpu::ContextPointer getGPUContext() const { return _graphicsEngine.getGPUContext(); }
|
gpu::ContextPointer getGPUContext() const { return _graphicsEngine.getGPUContext(); }
|
||||||
|
|
||||||
|
|
||||||
const GameWorkload& getGameWorkload() const { return _gameWorkload; }
|
const GameWorkload& getGameWorkload() const { return _gameWorkload; }
|
||||||
|
|
||||||
virtual void pushPostUpdateLambda(void* key, const std::function<void()>& func) override;
|
virtual void pushPostUpdateLambda(void* key, const std::function<void()>& func) override;
|
||||||
|
|
44
interface/src/scripting/RenderScriptingInterface.cpp
Normal file
44
interface/src/scripting/RenderScriptingInterface.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 5/16/19
|
||||||
|
// Copyright 2013-2019 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 "RenderScriptingInterface.h"
|
||||||
|
|
||||||
|
const QString DEFERRED = "deferred";
|
||||||
|
const QString FORWARD = "forward";
|
||||||
|
|
||||||
|
RenderScriptingInterface* RenderScriptingInterface::getInstance() {
|
||||||
|
static RenderScriptingInterface sharedInstance;
|
||||||
|
return &sharedInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderScriptingInterface::RenderScriptingInterface() {
|
||||||
|
setRenderMethod((render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RenderScriptingInterface::getRenderMethod() {
|
||||||
|
return (render::Args::RenderMethod)_renderMethodSetting.get() == render::Args::RenderMethod::DEFERRED ? DEFERRED : FORWARD;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderScriptingInterface::setRenderMethod(const QString& renderMethod) {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "setRenderMethod", Q_ARG(const QString&, renderMethod));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto config = dynamic_cast<task::SwitchConfig*>(qApp->getRenderEngine()->getConfiguration()->getConfig("RenderMainView.DeferredForwardSwitch"));
|
||||||
|
if (config) {
|
||||||
|
if (renderMethod == DEFERRED) {
|
||||||
|
_renderMethodSetting.set(render::Args::RenderMethod::DEFERRED);
|
||||||
|
config->setBranch(render::Args::RenderMethod::DEFERRED);
|
||||||
|
emit config->dirtyEnabled();
|
||||||
|
} else if (renderMethod == FORWARD) {
|
||||||
|
_renderMethodSetting.set(render::Args::RenderMethod::FORWARD);
|
||||||
|
config->setBranch(render::Args::RenderMethod::FORWARD);
|
||||||
|
emit config->dirtyEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
interface/src/scripting/RenderScriptingInterface.h
Normal file
65
interface/src/scripting/RenderScriptingInterface.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 5/16/19
|
||||||
|
// Copyright 2013-2019 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_RenderScriptingInterface_h
|
||||||
|
#define hifi_RenderScriptingInterface_h
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
|
#include "RenderForward.h"
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* The <code>Render</code> API allows you to configure the graphics engine
|
||||||
|
*
|
||||||
|
* @namespace Render
|
||||||
|
*
|
||||||
|
* @hifi-interface
|
||||||
|
* @hifi-client-entity
|
||||||
|
* @hifi-avatar
|
||||||
|
*/
|
||||||
|
class RenderScriptingInterface : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString renderMethod READ getRenderMethod WRITE setRenderMethod)
|
||||||
|
|
||||||
|
public:
|
||||||
|
RenderScriptingInterface();
|
||||||
|
|
||||||
|
static RenderScriptingInterface* getInstance();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**jsdoc
|
||||||
|
* Get a config for a job by name
|
||||||
|
* @function Render.getConfig
|
||||||
|
* @param {string} name - Can be:
|
||||||
|
* - <job_name>. Search for the first job named job_name traversing the the sub graph of task and jobs (from this task as root)
|
||||||
|
* - <parent_name>.[<sub_parent_names>.]<job_name>. Allows you to first look for the parent_name job (from this task as root) and then search from there for the
|
||||||
|
* optional sub_parent_names and finally from there looking for the job_name (assuming every job in the path is found)
|
||||||
|
* @returns {object} The sub job config.
|
||||||
|
*/
|
||||||
|
QObject* getConfig(const QString& name) { return qApp->getRenderEngine()->getConfiguration()->getConfig(name); }
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Gets the current render method
|
||||||
|
* @function Render.getRenderMethod
|
||||||
|
* @returns {string} <code>"deferred"</code> or <code>"forward"</code>
|
||||||
|
*/
|
||||||
|
QString getRenderMethod();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Sets the current render method
|
||||||
|
* @function Render.setRenderMethod
|
||||||
|
* @param {string} renderMethod - <code>"deferred"</code> or <code>"forward"</code>
|
||||||
|
*/
|
||||||
|
void setRenderMethod(const QString& renderMethod);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Setting::Handle<int> _renderMethodSetting { "renderMethod", RENDER_FORWARD ? render::Args::RenderMethod::FORWARD : render::Args::RenderMethod::DEFERRED };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_RenderScriptingInterface_h
|
|
@ -15,8 +15,6 @@
|
||||||
#include "RenderDeferredTask.h"
|
#include "RenderDeferredTask.h"
|
||||||
#include "RenderForwardTask.h"
|
#include "RenderForwardTask.h"
|
||||||
|
|
||||||
#include <RenderForward.h>
|
|
||||||
|
|
||||||
void RenderShadowsAndDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) {
|
void RenderShadowsAndDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) {
|
||||||
task.addJob<SetRenderMethod>("SetRenderMethodTask", render::Args::DEFERRED);
|
task.addJob<SetRenderMethod>("SetRenderMethodTask", render::Args::DEFERRED);
|
||||||
|
|
||||||
|
@ -34,9 +32,9 @@ void RenderShadowsAndDeferredTask::build(JobModel& task, const render::Varying&
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredForwardSwitchJob::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) {
|
void DeferredForwardSwitchJob::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) {
|
||||||
task.addBranch<RenderShadowsAndDeferredTask>("RenderShadowsAndDeferredTask", RENDER_FORWARD ? 1 : 0, input, cullFunctor, tagBits, tagMask);
|
task.addBranch<RenderShadowsAndDeferredTask>("RenderShadowsAndDeferredTask", 0, input, cullFunctor, tagBits, tagMask);
|
||||||
|
|
||||||
task.addBranch<RenderForwardTask>("RenderForwardTask", RENDER_FORWARD ? 0 : 1, input);
|
task.addBranch<RenderForwardTask>("RenderForwardTask", 1, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderViewTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) {
|
void RenderViewTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, uint8_t tagBits, uint8_t tagMask) {
|
||||||
|
|
|
@ -220,7 +220,6 @@ public:
|
||||||
TaskConfig() = default;
|
TaskConfig() = default;
|
||||||
TaskConfig(bool enabled) : JobConfig(enabled) {}
|
TaskConfig(bool enabled) : JobConfig(enabled) {}
|
||||||
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @function Render.getConfig
|
* @function Render.getConfig
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
|
@ -262,7 +261,7 @@ public:
|
||||||
|
|
||||||
class SwitchConfig : public JobConfig {
|
class SwitchConfig : public JobConfig {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool branch READ getBranch WRITE setBranch NOTIFY dirtyEnabled)
|
Q_PROPERTY(int branch READ getBranch WRITE setBranch NOTIFY dirtyEnabled)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint8_t getBranch() const { return _branch; }
|
uint8_t getBranch() const { return _branch; }
|
||||||
|
|
Loading…
Reference in a new issue