diff --git a/interface/src/Application_Assets.cpp b/interface/src/Application_Assets.cpp index d810fc7aee0..a807e918907 100644 --- a/interface/src/Application_Assets.cpp +++ b/interface/src/Application_Assets.cpp @@ -483,7 +483,7 @@ bool Application::importSVOFromURL(const QString& urlString) { bool Application::importFromZIP(const QString& filePath) { qDebug() << "A zip file has been dropped in: " << filePath; - qApp->getFileDownloadInterface()->runUnzip(filePath, QUrl(), true, true, false); + qApp->getFileDownloadInterface()->runUnzip(filePath, QUrl(), true, true); return true; } diff --git a/interface/src/Application_Setup.cpp b/interface/src/Application_Setup.cpp index edd3a8f1b8e..c62a9e0130e 100644 --- a/interface/src/Application_Setup.cpp +++ b/interface/src/Application_Setup.cpp @@ -91,6 +91,7 @@ #include #include #include +#include #include #include #include diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index 8cf5b937243..5d0d337cda7 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -1748,9 +1748,8 @@ ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const Sha if (!std::get<2>(key)) { _pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), std::get<2>(key), wireframe)] = std::make_shared(pipeline, nullptr, nullptr, nullptr); } else { - const auto& fadeEffect = DependencyManager::get(); _pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), std::get<2>(key), wireframe)] = std::make_shared(pipeline, nullptr, - fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); + FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter()); } } } diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index c50e2ee1ad9..400de6cf723 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -171,7 +171,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene _dpi = entity->getDpi(); _color = entity->getColor(); _alpha = entity->getAlpha(); - _wantsKeyboardFocus = entity->wantsKeyboardFocus(); + _wantsKeyboardFocus = entity->getWantsKeyboardFocus(); _pulseProperties = entity->getPulseProperties(); if (_contentType == ContentType::NoContent) { diff --git a/libraries/entities/src/EntityItem.h.in b/libraries/entities/src/EntityItem.h.in index 837c84714c5..07f9fa4ffb9 100644 --- a/libraries/entities/src/EntityItem.h.in +++ b/libraries/entities/src/EntityItem.h.in @@ -397,7 +397,6 @@ public: QUuid getOwningAvatarIDForProperties() const; virtual bool wantsHandControllerPointerEvents() const { return false; } - virtual bool wantsKeyboardFocus() const { return false; } virtual void setProxyWindow(QWindow* proxyWindow) {} virtual QObject* getEventHandler() { return nullptr; } diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.cpp b/libraries/render-utils/src/AmbientOcclusionEffect.cpp index 5e7c584e330..ab1acc3c91c 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.cpp +++ b/libraries/render-utils/src/AmbientOcclusionEffect.cpp @@ -842,6 +842,8 @@ void AmbientOcclusionEffect::run(const render::RenderContextPointer& renderConte config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage()); } +gpu::PipelinePointer DebugAmbientOcclusion::_debugPipeline; + void DebugAmbientOcclusion::configure(const Config& config) { _showCursorPixel = config.showCursorPixel; @@ -851,7 +853,7 @@ void DebugAmbientOcclusion::configure(const Config& config) { } } -const gpu::PipelinePointer& DebugAmbientOcclusion::getDebugPipeline() { +gpu::PipelinePointer& DebugAmbientOcclusion::getDebugPipeline() { if (!_debugPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_debugOcclusion); gpu::StatePointer state = std::make_shared(); diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.h b/libraries/render-utils/src/AmbientOcclusionEffect.h index 3c49dba3d46..9debb203ec8 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.h +++ b/libraries/render-utils/src/AmbientOcclusionEffect.h @@ -283,9 +283,9 @@ class DebugAmbientOcclusion { }; gpu::StructBuffer _parametersBuffer; - const gpu::PipelinePointer& getDebugPipeline(); + static gpu::PipelinePointer& getDebugPipeline(); - gpu::PipelinePointer _debugPipeline; + static gpu::PipelinePointer _debugPipeline; bool _showCursorPixel { false }; }; diff --git a/libraries/render-utils/src/AntialiasingEffect.cpp b/libraries/render-utils/src/AntialiasingEffect.cpp index ac0eed9417b..599c28ceca6 100644 --- a/libraries/render-utils/src/AntialiasingEffect.cpp +++ b/libraries/render-utils/src/AntialiasingEffect.cpp @@ -40,6 +40,9 @@ namespace gr { #if !ANTIALIASING_USE_TAA +gpu::PipelinePointer Antialiasing::_antialiasingPipeline; +gpu::PipelinePointer Antialiasing::_blendPipeline; + Antialiasing::Antialiasing() { _geometryId = DependencyManager::get()->allocateID(); } @@ -144,6 +147,10 @@ void AntialiasingConfig::setAAMode(int mode) { emit dirty(); } +gpu::PipelinePointer Antialiasing::_antialiasingPipeline; +gpu::PipelinePointer Antialiasing::_blendPipeline; +gpu::PipelinePointer Antialiasing::_debugBlendPipeline; + Antialiasing::Antialiasing(bool isSharpenEnabled) : _isSharpenEnabled{ isSharpenEnabled } { } @@ -154,7 +161,7 @@ Antialiasing::~Antialiasing() { _antialiasingTextures[1].reset(); } -const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(const render::RenderContextPointer& renderContext) { +gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline() { if (!_antialiasingPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::taa); @@ -169,7 +176,7 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(const render:: return _antialiasingPipeline; } -const gpu::PipelinePointer& Antialiasing::getBlendPipeline() { +gpu::PipelinePointer& Antialiasing::getBlendPipeline() { if (!_blendPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::fxaa_blend); gpu::StatePointer state = std::make_shared(); @@ -180,7 +187,7 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() { return _blendPipeline; } -const gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() { +gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() { if (!_debugBlendPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::taa_blend); gpu::StatePointer state = std::make_shared(); @@ -260,7 +267,6 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const batch.setViewportTransform(args->_viewport); // TAA step - getAntialiasingPipeline(renderContext); batch.setResourceFramebufferSwapChainTexture(ru::Texture::TaaHistory, _antialiasingBuffers, 0); batch.setResourceTexture(ru::Texture::TaaSource, sourceBuffer->getRenderBuffer(0)); batch.setResourceTexture(ru::Texture::TaaVelocity, velocityBuffer->getVelocityTexture()); @@ -269,9 +275,9 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const batch.setUniformBuffer(ru::Buffer::TaaParams, _params); batch.setUniformBuffer(ru::Buffer::DeferredFrameTransform, deferredFrameTransform->getFrameTransformBuffer()); - + batch.setFramebufferSwapChain(_antialiasingBuffers, 1); - batch.setPipeline(getAntialiasingPipeline(renderContext)); + batch.setPipeline(getAntialiasingPipeline()); batch.draw(gpu::TRIANGLE_STRIP, 4); // Blend step diff --git a/libraries/render-utils/src/AntialiasingEffect.h b/libraries/render-utils/src/AntialiasingEffect.h index 540810bbc3e..8273959c149 100644 --- a/libraries/render-utils/src/AntialiasingEffect.h +++ b/libraries/render-utils/src/AntialiasingEffect.h @@ -213,18 +213,18 @@ class Antialiasing { void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); - const gpu::PipelinePointer& getAntialiasingPipeline(const render::RenderContextPointer& renderContext); - const gpu::PipelinePointer& getBlendPipeline(); - const gpu::PipelinePointer& getDebugBlendPipeline(); + static gpu::PipelinePointer& getAntialiasingPipeline(); + static gpu::PipelinePointer& getBlendPipeline(); + static gpu::PipelinePointer& getDebugBlendPipeline(); private: gpu::FramebufferSwapChainPointer _antialiasingBuffers; gpu::TexturePointer _antialiasingTextures[2]; gpu::BufferPointer _blendParamsBuffer; - gpu::PipelinePointer _antialiasingPipeline; - gpu::PipelinePointer _blendPipeline; - gpu::PipelinePointer _debugBlendPipeline; + static gpu::PipelinePointer _antialiasingPipeline; + static gpu::PipelinePointer _blendPipeline; + static gpu::PipelinePointer _debugBlendPipeline; TAAParamsBuffer _params; AntialiasingConfig::Mode _mode{ AntialiasingConfig::TAA }; @@ -251,8 +251,8 @@ class Antialiasing { void configure(const Config& config) {} void run(const render::RenderContextPointer& renderContext, const gpu::FramebufferPointer& sourceBuffer); - const gpu::PipelinePointer& getAntialiasingPipeline(); - const gpu::PipelinePointer& getBlendPipeline(); + static gpu::PipelinePointer& getAntialiasingPipeline(); + static gpu::PipelinePointer& getBlendPipeline(); private: gpu::FramebufferPointer _antialiasingBuffer; @@ -260,8 +260,8 @@ class Antialiasing { gpu::TexturePointer _antialiasingTexture; gpu::BufferPointer _paramsBuffer; - gpu::PipelinePointer _antialiasingPipeline; - gpu::PipelinePointer _blendPipeline; + static gpu::PipelinePointer _antialiasingPipeline; + static gpu::PipelinePointer _blendPipeline; int _geometryId { 0 }; }; #endif diff --git a/libraries/render-utils/src/BloomEffect.cpp b/libraries/render-utils/src/BloomEffect.cpp index 5cb2f060210..d27403440cc 100644 --- a/libraries/render-utils/src/BloomEffect.cpp +++ b/libraries/render-utils/src/BloomEffect.cpp @@ -19,6 +19,11 @@ #define BLOOM_BLUR_LEVEL_COUNT 3 +gpu::PipelinePointer BloomThreshold::_pipeline; +gpu::PipelinePointer BloomApply::_pipeline; +gpu::PipelinePointer BloomDraw::_pipeline; +gpu::PipelinePointer DebugBloom::_pipeline; + BloomThreshold::BloomThreshold(unsigned int downsamplingFactor) { assert(downsamplingFactor > 0); _parameters.edit()._sampleCount = downsamplingFactor; diff --git a/libraries/render-utils/src/BloomEffect.h b/libraries/render-utils/src/BloomEffect.h index 47558affd98..a6c7bb79915 100644 --- a/libraries/render-utils/src/BloomEffect.h +++ b/libraries/render-utils/src/BloomEffect.h @@ -43,8 +43,8 @@ class BloomThreshold { #include "BloomThreshold.shared.slh" + static gpu::PipelinePointer _pipeline; gpu::FramebufferPointer _outputBuffer; - gpu::PipelinePointer _pipeline; gpu::StructBuffer _parameters; }; @@ -68,7 +68,7 @@ class BloomApply { #include "BloomApply.shared.slh" - gpu::PipelinePointer _pipeline; + static gpu::PipelinePointer _pipeline; gpu::StructBuffer _parameters; }; @@ -83,7 +83,7 @@ class BloomDraw { private: - gpu::PipelinePointer _pipeline; + static gpu::PipelinePointer _pipeline; }; class DebugBloomConfig : public render::Job::Config { @@ -125,7 +125,7 @@ class DebugBloom { void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); private: - gpu::PipelinePointer _pipeline; + static gpu::PipelinePointer _pipeline; gpu::BufferPointer _params; DebugBloomConfig::Mode _mode; }; diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index 01a9c055cc4..06f948601f2 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -250,6 +250,9 @@ static std::string getFileContent(const std::string& fileName, const std::string return defaultContent; } +DebugDeferredBuffer::StandardPipelines DebugDeferredBuffer::_pipelines; +DebugDeferredBuffer::CustomPipelines DebugDeferredBuffer::_customPipelines; + #include // TODO REMOVE: Temporary until UI DebugDeferredBuffer::DebugDeferredBuffer() { // TODO REMOVE: Temporary until UI @@ -334,7 +337,7 @@ std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, const std::strin return std::string(); } -bool DebugDeferredBuffer::pipelineNeedsUpdate(Mode mode, const std::string& customFile) const { +bool DebugDeferredBuffer::pipelineNeedsUpdate(Mode mode, const std::string& customFile) { if (mode != CustomMode) { return !_pipelines[mode]; } @@ -351,7 +354,7 @@ bool DebugDeferredBuffer::pipelineNeedsUpdate(Mode mode, const std::string& cust return true; } -const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, const std::string& customFile) { +gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, const std::string& customFile) { if (pipelineNeedsUpdate(mode, customFile)) { static_assert(shader::render_utils::program::debug_deferred_buffer != 0, "Validate debug deferred program"); diff --git a/libraries/render-utils/src/DebugDeferredBuffer.h b/libraries/render-utils/src/DebugDeferredBuffer.h index 5ff3ab28c99..fd49bd2826e 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.h +++ b/libraries/render-utils/src/DebugDeferredBuffer.h @@ -107,18 +107,18 @@ class DebugDeferredBuffer { struct CustomPipeline { gpu::PipelinePointer pipeline; - mutable QFileInfo info; + QFileInfo info; }; using StandardPipelines = std::array; using CustomPipelines = std::unordered_map; - bool pipelineNeedsUpdate(Mode mode, const std::string& customFile = std::string()) const; - const gpu::PipelinePointer& getPipeline(Mode mode, const std::string& customFile = std::string()); - std::string getShaderSourceCode(Mode mode, const std::string& customFile = std::string()); + static bool pipelineNeedsUpdate(Mode mode, const std::string& customFile = std::string()); + static gpu::PipelinePointer& getPipeline(Mode mode, const std::string& customFile = std::string()); + static std::string getShaderSourceCode(Mode mode, const std::string& customFile = std::string()); ParametersBuffer _parameters; - StandardPipelines _pipelines; - CustomPipelines _customPipelines; + static StandardPipelines _pipelines; + static CustomPipelines _customPipelines; int _geometryId{ 0 }; }; diff --git a/libraries/render-utils/src/FadeEffect.cpp b/libraries/render-utils/src/FadeEffect.cpp index 402865da4ce..902b8fbab10 100644 --- a/libraries/render-utils/src/FadeEffect.cpp +++ b/libraries/render-utils/src/FadeEffect.cpp @@ -17,33 +17,36 @@ #include "render-utils/ShaderConstants.h" #include +gpu::TexturePointer FadeEffect::_maskMap; + FadeEffect::FadeEffect() { - auto texturePath = PathUtils::resourcesPath() + "images/fadeMask.png"; - _maskMap = DependencyManager::get()->getImageTexture(texturePath, image::TextureUsage::STRICT_TEXTURE); + std::once_flag once; + std::call_once(once, [] { + auto texturePath = PathUtils::resourcesPath() + "images/fadeMask.png"; + _maskMap = DependencyManager::get()->getImageTexture(texturePath, image::TextureUsage::STRICT_TEXTURE); + }); } -void FadeEffect::build(render::Task::TaskConcept& task, const task::Varying& editableItems) { +void FadeEffect::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs) { auto editedFadeCategory = task.addJob("Fade"); - auto& fadeJob = task._jobs.back(); - _configurations = fadeJob.get().getConfigurationBuffer(); - const auto fadeEditInput = FadeEditJob::Input(editableItems, editedFadeCategory).asVarying(); + const auto fadeEditInput = FadeEditJob::Input(inputs, editedFadeCategory).asVarying(); task.addJob("FadeEdit", fadeEditInput); } -render::ShapePipeline::BatchSetter FadeEffect::getBatchSetter() const { - return [this](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args*) { +render::ShapePipeline::BatchSetter FadeEffect::getBatchSetter() { + return [](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args*) { batch.setResourceTexture(render_utils::slot::texture::FadeMask, _maskMap); - batch.setUniformBuffer(render_utils::slot::buffer::FadeParameters, _configurations); + batch.setUniformBuffer(render_utils::slot::buffer::FadeParameters, FadeJob::getConfigurationBuffer()); }; } -render::ShapePipeline::ItemSetter FadeEffect::getItemUniformSetter() const { +render::ShapePipeline::ItemSetter FadeEffect::getItemUniformSetter() { return [](const render::ShapePipeline& shapePipeline, render::Args* args, const render::Item& item) { if (!render::TransitionStage::isIndexInvalid(item.getTransitionId())) { const auto& scene = args->_scene; const auto& batch = args->_batch; - auto transitionStage = scene->getStage(render::TransitionStage::getName()); + auto transitionStage = scene->getStage(); auto& transitionState = transitionStage->getTransition(item.getTransitionId()); if (transitionState.paramsBuffer._size != sizeof(gpu::StructBuffer)) { @@ -71,39 +74,3 @@ render::ShapePipeline::ItemSetter FadeEffect::getItemUniformSetter() const { } }; } - -render::ShapePipeline::ItemSetter FadeEffect::getItemStoredSetter() { - return [this](const render::ShapePipeline& shapePipeline, render::Args* args, const render::Item& item) { - if (!render::TransitionStage::isIndexInvalid(item.getTransitionId())) { - auto scene = args->_scene; - auto transitionStage = scene->getStage(render::TransitionStage::getName()); - auto& transitionState = transitionStage->getTransition(item.getTransitionId()); - const auto fadeCategory = FadeJob::transitionToCategory[transitionState.eventType]; - - _lastCategory = fadeCategory; - _lastThreshold = transitionState.threshold; - _lastNoiseOffset = transitionState.noiseOffset; - _lastBaseOffset = transitionState.baseOffset; - _lastBaseInvSize = transitionState.baseInvSize; - } - }; -} - -void FadeEffect::packToAttributes(const int category, const float threshold, const glm::vec3& noiseOffset, - const glm::vec3& baseOffset, const glm::vec3& baseInvSize, - glm::vec4& packedData1, glm::vec4& packedData2, glm::vec4& packedData3) { - packedData1.x = noiseOffset.x; - packedData1.y = noiseOffset.y; - packedData1.z = noiseOffset.z; - packedData1.w = (float)(category+0.1f); // GLSL hack so that casting back from float to int in fragment shader returns the correct value. - - packedData2.x = baseOffset.x; - packedData2.y = baseOffset.y; - packedData2.z = baseOffset.z; - packedData2.w = threshold; - - packedData3.x = baseInvSize.x; - packedData3.y = baseInvSize.y; - packedData3.z = baseInvSize.z; - packedData3.w = 0.f; -} diff --git a/libraries/render-utils/src/FadeEffect.h b/libraries/render-utils/src/FadeEffect.h index e4a7debd1ec..d5aab4e1f58 100644 --- a/libraries/render-utils/src/FadeEffect.h +++ b/libraries/render-utils/src/FadeEffect.h @@ -11,44 +11,22 @@ #ifndef hifi_render_utils_FadeEffect_h #define hifi_render_utils_FadeEffect_h -#include #include -class FadeEffect : public Dependency { - SINGLETON_DEPENDENCY; - +class FadeEffect { public: + using Input = render::ItemBounds; + using JobModel = render::Task::ModelI; - void build(render::Task::TaskConcept& task, const task::Varying& editableItems); - - render::ShapePipeline::BatchSetter getBatchSetter() const; - render::ShapePipeline::ItemSetter getItemUniformSetter() const; - render::ShapePipeline::ItemSetter getItemStoredSetter(); + FadeEffect(); - int getLastCategory() const { return _lastCategory; } - float getLastThreshold() const { return _lastThreshold; } - const glm::vec3& getLastNoiseOffset() const { return _lastNoiseOffset; } - const glm::vec3& getLastBaseOffset() const { return _lastBaseOffset; } - const glm::vec3& getLastBaseInvSize() const { return _lastBaseInvSize; } + void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs); - static void packToAttributes(const int category, const float threshold, const glm::vec3& noiseOffset, - const glm::vec3& baseOffset, const glm::vec3& baseInvSize, - glm::vec4& packedData1, glm::vec4& packedData2, glm::vec4& packedData3); + static render::ShapePipeline::BatchSetter getBatchSetter(); + static render::ShapePipeline::ItemSetter getItemUniformSetter(); private: - - gpu::BufferView _configurations; - gpu::TexturePointer _maskMap; - - // The last fade set through the stored item setter - int _lastCategory { 0 }; - float _lastThreshold { 0.f }; - glm::vec3 _lastNoiseOffset { 0.f, 0.f, 0.f }; - glm::vec3 _lastBaseOffset { 0.f, 0.f, 0.f }; - glm::vec3 _lastBaseInvSize { 1.f, 1.f, 1.f }; - - explicit FadeEffect(); - virtual ~FadeEffect() { } - + static gpu::TexturePointer _maskMap; }; + #endif // hifi_render_utils_FadeEffect_h diff --git a/libraries/render-utils/src/FadeEffectJobs.cpp b/libraries/render-utils/src/FadeEffectJobs.cpp index 6f6205060a3..23abc186831 100644 --- a/libraries/render-utils/src/FadeEffectJobs.cpp +++ b/libraries/render-utils/src/FadeEffectJobs.cpp @@ -531,6 +531,8 @@ void FadeConfig::load(const QString& configFilePath) { } } +FadeJob::FadeConfigurationBuffer FadeJob::_configurations; + FadeJob::FadeJob() { _previousTime = usecTimestampNow(); } @@ -558,15 +560,15 @@ void FadeJob::configure(const Config& config) { void FadeJob::run(const render::RenderContextPointer& renderContext, FadeJob::Output& output) { Config* jobConfig = static_cast(renderContext->jobConfig.get()); + output = (FadeCategory)jobConfig->editedCategory; + auto scene = renderContext->args->_scene; - auto transitionStage = scene->getStage(render::TransitionStage::getName()); + auto transitionStage = scene->getStage(); uint64_t now = usecTimestampNow(); const double deltaTime = (int64_t(now) - int64_t(_previousTime)) / double(USECS_PER_SECOND); render::Transaction transaction; bool isFirstItem = true; bool hasTransaction = false; - - output = (FadeCategory) jobConfig->editedCategory; // And now update fade effect for (auto transitionId : *transitionStage) { diff --git a/libraries/render-utils/src/FadeEffectJobs.h b/libraries/render-utils/src/FadeEffectJobs.h index 08b49c8d2de..fcd55b76ac8 100644 --- a/libraries/render-utils/src/FadeEffectJobs.h +++ b/libraries/render-utils/src/FadeEffectJobs.h @@ -207,7 +207,7 @@ class FadeJob { void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, FadeJob::Output& output); - gpu::BufferView getConfigurationBuffer() const { return _configurations; } + static gpu::BufferView getConfigurationBuffer() { return _configurations; } private: @@ -219,7 +219,7 @@ class FadeJob { }; using FadeConfigurationBuffer = gpu::StructBuffer; - FadeConfigurationBuffer _configurations; + static FadeConfigurationBuffer _configurations; float _thresholdScale[FADE_CATEGORY_COUNT]; uint64_t _previousTime{ 0 }; diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 4d4f9c06803..808bae7b9d2 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -725,9 +725,8 @@ render::ShapePipelinePointer GeometryCache::getShapePipeline(bool textured, bool render::ShapePipelinePointer GeometryCache::getFadingShapePipeline(bool textured, bool transparent, bool unlit, bool depthBias, bool forward, graphics::MaterialKey::CullFaceMode cullFaceMode) { - auto fadeEffect = DependencyManager::get(); - auto fadeBatchSetter = fadeEffect->getBatchSetter(); - auto fadeItemSetter = fadeEffect->getItemUniformSetter(); + auto fadeBatchSetter = FadeEffect::getBatchSetter(); + auto fadeItemSetter = FadeEffect::getItemUniformSetter(); return std::make_shared(getSimplePipeline(textured, transparent, unlit, depthBias, true, true, forward, cullFaceMode), nullptr, [fadeBatchSetter, fadeItemSetter](const render::ShapePipeline& shapePipeline, gpu::Batch& batch, render::Args* args) { batch.setResourceTexture(gr::Texture::MaterialAlbedo, DependencyManager::get()->getWhiteTexture()); diff --git a/libraries/render-utils/src/HighlightEffect.cpp b/libraries/render-utils/src/HighlightEffect.cpp index 754c99c425c..2525427b612 100644 --- a/libraries/render-utils/src/HighlightEffect.cpp +++ b/libraries/render-utils/src/HighlightEffect.cpp @@ -156,7 +156,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c _boundsBuffer = std::make_shared(sizeof(render::ItemBound)); } - auto highlightStage = renderContext->_scene->getStage(render::HighlightStage::getName()); + auto highlightStage = renderContext->_scene->getStage(); auto highlightId = _sharedParameters->_highlightIds[_highlightPassIndex]; if (!inShapes.empty() && !render::HighlightStage::isIndexInvalid(highlightId)) { @@ -244,7 +244,7 @@ void DrawHighlight::run(const render::RenderContextPointer& renderContext, const if (sceneDepthBuffer) { auto args = renderContext->args; - auto highlightStage = renderContext->_scene->getStage(render::HighlightStage::getName()); + auto highlightStage = renderContext->_scene->getStage(); auto highlightId = _sharedParameters->_highlightIds[_highlightPassIndex]; if (!render::HighlightStage::isIndexInvalid(highlightId)) { auto& highlight = highlightStage->getHighlight(highlightId); @@ -311,6 +311,8 @@ const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightSt return style.isFilled() ? _pipelineFilled : _pipeline; } +gpu::PipelinePointer DebugHighlight::_depthPipeline; + DebugHighlight::DebugHighlight() { _geometryDepthId = DependencyManager::get()->allocateID(); } @@ -396,7 +398,7 @@ void DebugHighlight::initializePipelines() { _depthPipeline = gpu::Pipeline::create(program, state); } -const gpu::PipelinePointer& DebugHighlight::getDepthPipeline() { +gpu::PipelinePointer& DebugHighlight::getDepthPipeline() { if (!_depthPipeline) { initializePipelines(); } @@ -406,7 +408,7 @@ const gpu::PipelinePointer& DebugHighlight::getDepthPipeline() { void SelectionToHighlight::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) { auto scene = renderContext->_scene; - auto highlightStage = scene->getStage(render::HighlightStage::getName()); + auto highlightStage = scene->getStage(); auto outlines = inputs.get0(); auto framebuffer = inputs.get1(); @@ -479,8 +481,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren std::call_once(once, [] { auto state = std::make_shared(); state->setColorWriteMask(false, false, false, false); - auto fadeEffect = DependencyManager::get(); - initZPassPipelines(*shapePlumber, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); + initZPassPipelines(*shapePlumber, state, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter()); }); auto sharedParameters = std::make_shared(); @@ -568,7 +569,7 @@ void AppendNonMetaOutlines::run(const render::RenderContextPointer& renderContex void HighlightCleanup::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) { auto scene = renderContext->_scene; - auto highlightStage = scene->getStage(render::HighlightStage::getName()); + auto highlightStage = scene->getStage(); for (auto index : inputs.get0()) { std::string selectionName = highlightStage->getHighlight(index)._selectionName; diff --git a/libraries/render-utils/src/HighlightEffect.h b/libraries/render-utils/src/HighlightEffect.h index a55ecdf46d0..ee9bcf42679 100644 --- a/libraries/render-utils/src/HighlightEffect.h +++ b/libraries/render-utils/src/HighlightEffect.h @@ -186,12 +186,12 @@ class DebugHighlight { private: - gpu::PipelinePointer _depthPipeline; + static gpu::PipelinePointer _depthPipeline; int _geometryDepthId{ 0 }; bool _isDisplayEnabled{ false }; - const gpu::PipelinePointer& getDepthPipeline(); - void initializePipelines(); + static gpu::PipelinePointer& getDepthPipeline(); + static void initializePipelines(); }; class DrawHighlightTask { diff --git a/libraries/render-utils/src/LightClusters.cpp b/libraries/render-utils/src/LightClusters.cpp index 3dc826d56c8..3425e087833 100644 --- a/libraries/render-utils/src/LightClusters.cpp +++ b/libraries/render-utils/src/LightClusters.cpp @@ -575,10 +575,9 @@ void LightClusteringPass::run(const render::RenderContextPointer& renderContext, config->setNumClusteredLightReferences(clusteringStats.z); } -DebugLightClusters::DebugLightClusters() { - -} - +gpu::PipelinePointer DebugLightClusters::_drawClusterGrid; +gpu::PipelinePointer DebugLightClusters::_drawClusterFromDepth; +gpu::PipelinePointer DebugLightClusters::_drawClusterContent; void DebugLightClusters::configure(const Config& config) { doDrawGrid = config.doDrawGrid; @@ -587,7 +586,7 @@ void DebugLightClusters::configure(const Config& config) { } -const gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() { +gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() { if (!_drawClusterGrid) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::lightClusters_drawGrid); auto state = std::make_shared(); @@ -603,7 +602,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() { return _drawClusterGrid; } -const gpu::PipelinePointer DebugLightClusters::getDrawClusterFromDepthPipeline() { +gpu::PipelinePointer DebugLightClusters::getDrawClusterFromDepthPipeline() { if (!_drawClusterFromDepth) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::lightClusters_drawClusterFromDepth); auto state = std::make_shared(); @@ -617,7 +616,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterFromDepthPipeline() return _drawClusterFromDepth; } -const gpu::PipelinePointer DebugLightClusters::getDrawClusterContentPipeline() { +gpu::PipelinePointer DebugLightClusters::getDrawClusterContentPipeline() { if (!_drawClusterContent) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::lightClusters_drawClusterContent); auto state = std::make_shared(); diff --git a/libraries/render-utils/src/LightClusters.h b/libraries/render-utils/src/LightClusters.h index 60978e76e89..6192105914f 100644 --- a/libraries/render-utils/src/LightClusters.h +++ b/libraries/render-utils/src/LightClusters.h @@ -217,23 +217,25 @@ class DebugLightClusters { using Config = DebugLightClustersConfig; using JobModel = render::Job::ModelI; - DebugLightClusters(); + DebugLightClusters() {} void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); protected: + static gpu::PipelinePointer _drawClusterGrid; + static gpu::PipelinePointer _drawClusterFromDepth; + static gpu::PipelinePointer _drawClusterContent; gpu::BufferPointer _gridBuffer; - gpu::PipelinePointer _drawClusterGrid; - gpu::PipelinePointer _drawClusterFromDepth; - gpu::PipelinePointer _drawClusterContent; - const gpu::PipelinePointer getDrawClusterGridPipeline(); - const gpu::PipelinePointer getDrawClusterFromDepthPipeline(); - const gpu::PipelinePointer getDrawClusterContentPipeline(); + bool doDrawGrid { false }; bool doDrawClusterFromDepth { false }; bool doDrawContent { false }; + + static gpu::PipelinePointer getDrawClusterGridPipeline(); + static gpu::PipelinePointer getDrawClusterFromDepthPipeline(); + static gpu::PipelinePointer getDrawClusterContentPipeline(); }; #endif diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 1055a4256d0..c79ac875511 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -357,9 +357,8 @@ class DrawMirrorTask { state->setDepthTest(true, true, gpu::LESS_EQUAL); PrepareStencil::testMaskDrawShape(*state); - auto fadeEffect = DependencyManager::get(); - initMirrorPipelines(*_forwardPipelines, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter(), true); - initMirrorPipelines(*_deferredPipelines, state, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter(), false); + initMirrorPipelines(*_forwardPipelines, state, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter(), true); + initMirrorPipelines(*_deferredPipelines, state, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter(), false); }); } diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index b8bc9a542b8..270bbb85492 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -101,12 +101,11 @@ void RenderDeferredTask::configure(const Config& config) { } void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, render::CullFunctor cullFunctor, size_t depth) { - static auto fadeEffect = DependencyManager::get(); // Prepare the ShapePipelines static ShapePlumberPointer shapePlumber = std::make_shared(); static std::once_flag once; std::call_once(once, [] { - initDeferredPipelines(*shapePlumber, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); + initDeferredPipelines(*shapePlumber, FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter()); }); const auto& inputs = input.get(); @@ -146,7 +145,9 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren // Shadow Stage Frame const auto shadowFrame = shadowTaskOutputs[1]; - fadeEffect->build(task, opaques); + if (depth == 0) { + task.addJob("FadeEffect", opaques); + } const auto jitter = task.addJob("JitterCam"); @@ -256,7 +257,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto toneMappedBuffer = task.addJob("ToneMapping", toneMappingInputs); // Debugging task is happening in the "over" layer after tone mapping and just before HUD - { // Debug the bounds of the rendered items, still look at the zbuffer + if (depth == 0) { // Debug the bounds of the rendered items, still look at the zbuffer const auto extraDebugBuffers = RenderDeferredTaskDebug::ExtraBuffers(linearDepthTarget, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, ambientOcclusionUniforms, scatteringResource, velocityBuffer); const auto debugInputs = RenderDeferredTaskDebug::Input(fetchedItems, shadowTaskOutputs, lightingStageInputs, lightClusters, prepareDeferredOutputs, extraDebugBuffers, deferredFrameTransform, jitter, lightingModel).asVarying(); diff --git a/libraries/render-utils/src/RenderForwardTask.cpp b/libraries/render-utils/src/RenderForwardTask.cpp index cba6f4920f9..74cdf1b0449 100644 --- a/libraries/render-utils/src/RenderForwardTask.cpp +++ b/libraries/render-utils/src/RenderForwardTask.cpp @@ -26,7 +26,6 @@ #include "render-utils/ShaderConstants.h" #include "StencilMaskPass.h" #include "ZoneRenderer.h" -#include "FadeEffect.h" #include "ToneMapAndResampleTask.h" #include "BackgroundStage.h" #include "FramebufferCache.h" @@ -72,7 +71,6 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend task.addJob("SetRenderMethodTask", render::Args::FORWARD); // Prepare the ShapePipelines - auto fadeEffect = DependencyManager::get(); static ShapePlumberPointer shapePlumber = std::make_shared(); static std::once_flag once; std::call_once(once, [] { @@ -112,9 +110,6 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend const auto& zones = lightingStageInputs[1]; - // First job, alter faded - fadeEffect->build(task, opaques); - // GPU jobs: Start preparing the main framebuffer const auto scaledPrimaryFramebuffer = task.addJob("PreparePrimaryBufferForward"); @@ -161,8 +156,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend task.addJob("DrawInFrontOpaque", inFrontOpaquesInputs, true); task.addJob("DrawInFrontTransparent", inFrontTransparentsInputs, false); - { // Debug the bounds of the rendered items, still look at the zbuffer - + if (depth == 0) { // Debug the bounds of the rendered items, still look at the zbuffer task.addJob("DrawMetaBounds", metas); task.addJob("DrawBounds", opaques); task.addJob("DrawTransparentBounds", transparents); diff --git a/libraries/render-utils/src/RenderShadowTask.cpp b/libraries/render-utils/src/RenderShadowTask.cpp index d6c50bc6fb2..992de467ec7 100644 --- a/libraries/render-utils/src/RenderShadowTask.cpp +++ b/libraries/render-utils/src/RenderShadowTask.cpp @@ -50,8 +50,7 @@ void RenderShadowTask::build(JobModel& task, const render::Varying& input, rende static ShapePlumberPointer shapePlumber = std::make_shared(); static std::once_flag once; std::call_once(once, [] { - auto fadeEffect = DependencyManager::get(); - initZPassPipelines(*shapePlumber, std::make_shared(), fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); + initZPassPipelines(*shapePlumber, std::make_shared(), FadeEffect::getBatchSetter(), FadeEffect::getItemUniformSetter()); }); const auto setupOutput = task.addJob("ShadowSetup", input); diff --git a/libraries/render-utils/src/StencilMaskPass.cpp b/libraries/render-utils/src/StencilMaskPass.cpp index 7c89e6b6011..59dbd1c0dca 100644 --- a/libraries/render-utils/src/StencilMaskPass.cpp +++ b/libraries/render-utils/src/StencilMaskPass.cpp @@ -17,6 +17,10 @@ using namespace render; +gpu::PipelinePointer PrepareStencil::_meshStencilPipeline; +gpu::PipelinePointer PrepareStencil::_paintStencilPipeline; +graphics::MeshPointer PrepareStencil::_mesh; + void PrepareStencil::configure(const Config& config) { _maskMode = config.maskMode; } diff --git a/libraries/render-utils/src/StencilMaskPass.h b/libraries/render-utils/src/StencilMaskPass.h index bca2ef17a58..ed1487d4b0d 100644 --- a/libraries/render-utils/src/StencilMaskPass.h +++ b/libraries/render-utils/src/StencilMaskPass.h @@ -59,14 +59,14 @@ class PrepareStencil { static void testMaskDrawShapeNoAA(gpu::State& state); private: - gpu::PipelinePointer _meshStencilPipeline; - gpu::PipelinePointer getMeshStencilPipeline(); + static gpu::PipelinePointer _meshStencilPipeline; + static gpu::PipelinePointer getMeshStencilPipeline(); - gpu::PipelinePointer _paintStencilPipeline; - gpu::PipelinePointer getPaintStencilPipeline(); + static gpu::PipelinePointer _paintStencilPipeline; + static gpu::PipelinePointer getPaintStencilPipeline(); - graphics::MeshPointer _mesh; - graphics::MeshPointer getMesh(); + static graphics::MeshPointer _mesh; + static graphics::MeshPointer getMesh(); StencilMaskMode _maskMode { StencilMaskMode::NONE }; }; diff --git a/libraries/render-utils/src/SubsurfaceScattering.cpp b/libraries/render-utils/src/SubsurfaceScattering.cpp index b5f8916ef6c..9f1cf8421a4 100644 --- a/libraries/render-utils/src/SubsurfaceScattering.cpp +++ b/libraries/render-utils/src/SubsurfaceScattering.cpp @@ -411,8 +411,8 @@ gpu::TexturePointer SubsurfaceScatteringResource::generateScatteringSpecularBeck return beckmannMap; } -DebugSubsurfaceScattering::DebugSubsurfaceScattering() { -} +gpu::PipelinePointer DebugSubsurfaceScattering::_scatteringPipeline; +gpu::PipelinePointer DebugSubsurfaceScattering::_showLUTPipeline; void DebugSubsurfaceScattering::configure(const Config& config) { @@ -427,8 +427,6 @@ void DebugSubsurfaceScattering::configure(const Config& config) { _debugParams->setSubData(0, _debugCursorTexcoord); } - - gpu::PipelinePointer DebugSubsurfaceScattering::getScatteringPipeline() { if (!_scatteringPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::subsurfaceScattering_drawScattering); @@ -440,8 +438,6 @@ gpu::PipelinePointer DebugSubsurfaceScattering::getScatteringPipeline() { return _scatteringPipeline; } -gpu::PipelinePointer _showLUTPipeline; - gpu::PipelinePointer DebugSubsurfaceScattering::getShowLUTPipeline() { if (!_showLUTPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::drawUnitQuatTextureOpaque); @@ -452,14 +448,12 @@ gpu::PipelinePointer DebugSubsurfaceScattering::getShowLUTPipeline() { return _showLUTPipeline; } - void DebugSubsurfaceScattering::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) { assert(renderContext->args); assert(renderContext->args->hasViewFrustum()); RenderArgs* args = renderContext->args; - auto& frameTransform = inputs.get0(); auto& deferredFramebuffer = inputs.get1(); @@ -477,8 +471,6 @@ void DebugSubsurfaceScattering::run(const render::RenderContextPointer& renderCo auto scatteringTable = scatteringResource->getScatteringTable(); auto scatteringSpecular = scatteringResource->getScatteringSpecular(); - - auto lightStage = renderContext->_scene->getStage(); assert(lightStage); // const auto light = DependencyManager::get()->getLightStage()->getLight(0); @@ -491,7 +483,6 @@ void DebugSubsurfaceScattering::run(const render::RenderContextPointer& renderCo gpu::doInBatch("DebugSubsurfaceScattering::run", args->_context, [=](gpu::Batch& batch) { batch.enableStereo(false); - auto viewportSize = std::min(args->_viewport.z, args->_viewport.w) >> 1; auto offsetViewport = viewportSize * 0.1; diff --git a/libraries/render-utils/src/SubsurfaceScattering.h b/libraries/render-utils/src/SubsurfaceScattering.h index e0073d23e89..ac013fe7889 100644 --- a/libraries/render-utils/src/SubsurfaceScattering.h +++ b/libraries/render-utils/src/SubsurfaceScattering.h @@ -167,18 +167,19 @@ class DebugSubsurfaceScattering { using Config = DebugSubsurfaceScatteringConfig; using JobModel = render::Job::ModelI; - DebugSubsurfaceScattering(); + DebugSubsurfaceScattering() {} void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs); private: - gpu::PipelinePointer _scatteringPipeline; - gpu::PipelinePointer getScatteringPipeline(); + static gpu::PipelinePointer _scatteringPipeline; + static gpu::PipelinePointer getScatteringPipeline(); + + static gpu::PipelinePointer _showLUTPipeline; + static gpu::PipelinePointer getShowLUTPipeline(); - gpu::PipelinePointer _showLUTPipeline; - gpu::PipelinePointer getShowLUTPipeline(); gpu::BufferPointer _debugParams; bool _showProfile{ false }; bool _showLUT{ false }; diff --git a/libraries/render-utils/src/SurfaceGeometryPass.cpp b/libraries/render-utils/src/SurfaceGeometryPass.cpp index 1572e8987f2..40753a17940 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.cpp +++ b/libraries/render-utils/src/SurfaceGeometryPass.cpp @@ -137,9 +137,8 @@ gpu::TexturePointer LinearDepthFramebuffer::getHalfNormalTexture() { return _halfNormalTexture; } - -LinearDepthPass::LinearDepthPass() { -} +gpu::PipelinePointer LinearDepthPass::_linearDepthPipeline; +gpu::PipelinePointer LinearDepthPass::_downsamplePipeline; void LinearDepthPass::configure(const Config& config) { } @@ -179,8 +178,8 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con outputs.edit3() = halfLinearDepthTexture; outputs.edit4() = halfNormalTexture; - auto linearDepthPipeline = getLinearDepthPipeline(renderContext); - auto downsamplePipeline = getDownsamplePipeline(renderContext); + auto linearDepthPipeline = getLinearDepthPipeline(); + auto downsamplePipeline = getDownsamplePipeline(); auto depthViewport = args->_viewport; auto halfViewport = depthViewport >> 1; @@ -222,8 +221,7 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage()); } - -const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline(const render::RenderContextPointer& renderContext) { +const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline() { gpu::ShaderPointer program; if (!_linearDepthPipeline) { program = gpu::Shader::createProgram(shader::render_utils::program::surfaceGeometry_makeLinearDepth); @@ -243,8 +241,7 @@ const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline(const render return _linearDepthPipeline; } - -const gpu::PipelinePointer& LinearDepthPass::getDownsamplePipeline(const render::RenderContextPointer& renderContext) { +const gpu::PipelinePointer& LinearDepthPass::getDownsamplePipeline() { if (!_downsamplePipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::surfaceGeometry_downsampleDepthNormal); @@ -366,6 +363,8 @@ void SurfaceGeometryFramebuffer::setResolutionLevel(int resolutionLevel) { } } +gpu::PipelinePointer SurfaceGeometryPass::_curvaturePipeline; + SurfaceGeometryPass::SurfaceGeometryPass() : _diffusePass(false) { @@ -454,7 +453,7 @@ void SurfaceGeometryPass::run(const render::RenderContextPointer& renderContext, outputs.edit2() = curvatureFramebuffer; outputs.edit3() = lowCurvatureFramebuffer; - auto curvaturePipeline = getCurvaturePipeline(renderContext); + auto curvaturePipeline = getCurvaturePipeline(); auto diffuseVPipeline = _diffusePass.getBlurVPipeline(); auto diffuseHPipeline = _diffusePass.getBlurHPipeline(); @@ -532,7 +531,7 @@ void SurfaceGeometryPass::run(const render::RenderContextPointer& renderContext, config->setGPUBatchRunTime(_gpuTimer->getGPUAverage(), _gpuTimer->getBatchAverage()); } -const gpu::PipelinePointer& SurfaceGeometryPass::getCurvaturePipeline(const render::RenderContextPointer& renderContext) { +const gpu::PipelinePointer& SurfaceGeometryPass::getCurvaturePipeline() { if (!_curvaturePipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::surfaceGeometry_makeCurvature); diff --git a/libraries/render-utils/src/SurfaceGeometryPass.h b/libraries/render-utils/src/SurfaceGeometryPass.h index 6ea03fbda5d..33a64d6081b 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.h +++ b/libraries/render-utils/src/SurfaceGeometryPass.h @@ -73,21 +73,19 @@ class LinearDepthPass { using Config = LinearDepthPassConfig; using JobModel = render::Job::ModelIO; - LinearDepthPass(); + LinearDepthPass() {} void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs); private: - typedef gpu::BufferView UniformBufferView; - LinearDepthFramebufferPointer _linearDepthFramebuffer; - const gpu::PipelinePointer& getLinearDepthPipeline(const render::RenderContextPointer& renderContext); - gpu::PipelinePointer _linearDepthPipeline; + static const gpu::PipelinePointer& getLinearDepthPipeline(); + static gpu::PipelinePointer _linearDepthPipeline; - const gpu::PipelinePointer& getDownsamplePipeline(const render::RenderContextPointer& renderContext); - gpu::PipelinePointer _downsamplePipeline; + static const gpu::PipelinePointer& getDownsamplePipeline(); + static gpu::PipelinePointer _downsamplePipeline; gpu::RangeTimerPointer _gpuTimer; }; @@ -194,15 +192,13 @@ class SurfaceGeometryPass { }; gpu::BufferView _parametersBuffer; - SurfaceGeometryFramebufferPointer _surfaceGeometryFramebuffer; - const gpu::PipelinePointer& getCurvaturePipeline(const render::RenderContextPointer& renderContext); + static const gpu::PipelinePointer& getCurvaturePipeline(); - gpu::PipelinePointer _curvaturePipeline; - - render::BlurGaussianDepthAware _diffusePass; + static gpu::PipelinePointer _curvaturePipeline; + render::BlurGaussianDepthAware _diffusePass; gpu::RangeTimerPointer _gpuTimer; }; diff --git a/libraries/render-utils/src/ToneMapAndResampleTask.h b/libraries/render-utils/src/ToneMapAndResampleTask.h index 50a35b2fe4f..0fc564307ef 100644 --- a/libraries/render-utils/src/ToneMapAndResampleTask.h +++ b/libraries/render-utils/src/ToneMapAndResampleTask.h @@ -67,7 +67,6 @@ class ToneMapAndResample { gpu::FramebufferPointer _destinationFrameBuffer; private: - gpu::PipelinePointer _blitLightBuffer; float _exposure { 0.0f }; bool _debug { false }; diff --git a/libraries/render-utils/src/VelocityBufferPass.cpp b/libraries/render-utils/src/VelocityBufferPass.cpp index 9437ead3b25..36735a78324 100644 --- a/libraries/render-utils/src/VelocityBufferPass.cpp +++ b/libraries/render-utils/src/VelocityBufferPass.cpp @@ -81,8 +81,7 @@ gpu::TexturePointer VelocityFramebuffer::getVelocityTexture() { return _velocityTexture; } -VelocityBufferPass::VelocityBufferPass() { -} +gpu::PipelinePointer VelocityBufferPass::_cameraMotionPipeline; void VelocityBufferPass::configure(const Config& config) { } @@ -114,7 +113,7 @@ void VelocityBufferPass::run(const render::RenderContextPointer& renderContext, outputs.edit1() = velocityFBO; outputs.edit2() = velocityTexture; - auto cameraMotionPipeline = getCameraMotionPipeline(renderContext); + auto cameraMotionPipeline = getCameraMotionPipeline(); auto fullViewport = args->_viewport; @@ -144,7 +143,7 @@ void VelocityBufferPass::run(const render::RenderContextPointer& renderContext, } -const gpu::PipelinePointer& VelocityBufferPass::getCameraMotionPipeline(const render::RenderContextPointer& renderContext) { +const gpu::PipelinePointer& VelocityBufferPass::getCameraMotionPipeline() { if (!_cameraMotionPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::velocityBuffer_cameraMotion); gpu::StatePointer state = std::make_shared(); diff --git a/libraries/render-utils/src/VelocityBufferPass.h b/libraries/render-utils/src/VelocityBufferPass.h index 50b994f6db1..a94b772ec83 100644 --- a/libraries/render-utils/src/VelocityBufferPass.h +++ b/libraries/render-utils/src/VelocityBufferPass.h @@ -69,7 +69,7 @@ class VelocityBufferPass { using Config = VelocityBufferPassConfig; using JobModel = render::Job::ModelIO; - VelocityBufferPass(); + VelocityBufferPass() {} void configure(const Config& config); void run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs); @@ -79,8 +79,8 @@ class VelocityBufferPass { VelocityFramebufferPointer _velocityFramebuffer; - const gpu::PipelinePointer& getCameraMotionPipeline(const render::RenderContextPointer& renderContext); - gpu::PipelinePointer _cameraMotionPipeline; + static const gpu::PipelinePointer& getCameraMotionPipeline(); + static gpu::PipelinePointer _cameraMotionPipeline; gpu::RangeTimerPointer _gpuTimer; }; diff --git a/libraries/render-utils/src/ZoneRenderer.cpp b/libraries/render-utils/src/ZoneRenderer.cpp index d9c0de99347..a8fb349e4d4 100644 --- a/libraries/render-utils/src/ZoneRenderer.cpp +++ b/libraries/render-utils/src/ZoneRenderer.cpp @@ -93,6 +93,10 @@ void SetupZones::run(const RenderContextPointer& context, const Input& input) { ambientOcclusionStage->_currentFrame.pushAmbientOcclusion(INVALID_INDEX); } +gpu::PipelinePointer DebugZoneLighting::_keyLightPipeline; +gpu::PipelinePointer DebugZoneLighting::_ambientPipeline; +gpu::PipelinePointer DebugZoneLighting::_backgroundPipeline; + const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() { if (!_keyLightPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::zone_drawKeyLight); diff --git a/libraries/render-utils/src/ZoneRenderer.h b/libraries/render-utils/src/ZoneRenderer.h index 6eeee1293a7..e67353f7471 100644 --- a/libraries/render-utils/src/ZoneRenderer.h +++ b/libraries/render-utils/src/ZoneRenderer.h @@ -83,13 +83,13 @@ class DebugZoneLighting { protected: - gpu::PipelinePointer _keyLightPipeline; - gpu::PipelinePointer _ambientPipeline; - gpu::PipelinePointer _backgroundPipeline; + static gpu::PipelinePointer _keyLightPipeline; + static gpu::PipelinePointer _ambientPipeline; + static gpu::PipelinePointer _backgroundPipeline; - const gpu::PipelinePointer& getKeyLightPipeline(); - const gpu::PipelinePointer& getAmbientPipeline(); - const gpu::PipelinePointer& getBackgroundPipeline(); + static const gpu::PipelinePointer& getKeyLightPipeline(); + static const gpu::PipelinePointer& getAmbientPipeline(); + static const gpu::PipelinePointer& getBackgroundPipeline(); }; diff --git a/libraries/render/src/render/BlurTask.cpp b/libraries/render/src/render/BlurTask.cpp index 97445e48df7..2edb69e711d 100644 --- a/libraries/render/src/render/BlurTask.cpp +++ b/libraries/render/src/render/BlurTask.cpp @@ -195,6 +195,9 @@ bool BlurInOutResource::updateResources(const gpu::FramebufferPointer& sourceFra return true; } +gpu::PipelinePointer BlurGaussian::_blurVPipeline; +gpu::PipelinePointer BlurGaussian::_blurHPipeline; + BlurGaussian::BlurGaussian() { _parameters = std::make_shared(); } @@ -294,7 +297,8 @@ void BlurGaussian::run(const RenderContextPointer& renderContext, const Inputs& }); } - +gpu::PipelinePointer BlurGaussianDepthAware::_blurVPipeline; +gpu::PipelinePointer BlurGaussianDepthAware::_blurHPipeline; BlurGaussianDepthAware::BlurGaussianDepthAware(bool generateOutputFramebuffer, const BlurParamsPointer& params) : _inOutResources(generateOutputFramebuffer, 1U), diff --git a/libraries/render/src/render/BlurTask.h b/libraries/render/src/render/BlurTask.h index cb11570f5c3..06ea4f075ff 100644 --- a/libraries/render/src/render/BlurTask.h +++ b/libraries/render/src/render/BlurTask.h @@ -129,11 +129,11 @@ class BlurGaussian { BlurParamsPointer _parameters; - gpu::PipelinePointer _blurVPipeline; - gpu::PipelinePointer _blurHPipeline; + static gpu::PipelinePointer _blurVPipeline; + static gpu::PipelinePointer _blurHPipeline; - gpu::PipelinePointer getBlurVPipeline(); - gpu::PipelinePointer getBlurHPipeline(); + static gpu::PipelinePointer getBlurVPipeline(); + static gpu::PipelinePointer getBlurHPipeline(); BlurInOutResource _inOutResources; }; @@ -163,12 +163,12 @@ class BlurGaussianDepthAware { const BlurParamsPointer& getParameters() const { return _parameters; } - gpu::PipelinePointer getBlurVPipeline(); - gpu::PipelinePointer getBlurHPipeline(); + static gpu::PipelinePointer getBlurVPipeline(); + static gpu::PipelinePointer getBlurHPipeline(); protected: - gpu::PipelinePointer _blurVPipeline; - gpu::PipelinePointer _blurHPipeline; + static gpu::PipelinePointer _blurVPipeline; + static gpu::PipelinePointer _blurHPipeline; BlurInOutResource _inOutResources; BlurParamsPointer _parameters; diff --git a/libraries/render/src/render/DrawSceneOctree.cpp b/libraries/render/src/render/DrawSceneOctree.cpp index 44d54c3c289..1b52de14291 100644 --- a/libraries/render/src/render/DrawSceneOctree.cpp +++ b/libraries/render/src/render/DrawSceneOctree.cpp @@ -24,6 +24,18 @@ using namespace render; +gpu::PipelinePointer DrawSceneOctree::_drawCellBoundsPipeline; +gpu::PipelinePointer DrawSceneOctree::_drawLODReticlePipeline; +gpu::PipelinePointer DrawSceneOctree::_drawItemBoundPipeline; +gpu::Stream::FormatPointer DrawSceneOctree::_cellBoundsFormat = std::make_shared(); + +DrawSceneOctree::DrawSceneOctree() { + std::once_flag once; + std::call_once(once, [] { + _cellBoundsFormat->setAttribute(0, 0, gpu::Element(gpu::VEC4, gpu::INT32, gpu::XYZW), 0, gpu::Stream::PER_INSTANCE); + }); +} + const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() { if (!_drawCellBoundsPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawCellBounds); @@ -36,9 +48,6 @@ const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() { // Good to go add the brand new pipeline _drawCellBoundsPipeline = gpu::Pipeline::create(program, state); - _cellBoundsFormat = std::make_shared(); - _cellBoundsFormat->setAttribute(0, 0, gpu::Element(gpu::VEC4, gpu::INT32, gpu::XYZW), 0, gpu::Stream::PER_INSTANCE); - _cellBoundsBuffer = std::make_shared(); } return _drawCellBoundsPipeline; } @@ -62,7 +71,6 @@ void DrawSceneOctree::configure(const Config& config) { _showEmptyCells = config.showEmptyCells; } - void DrawSceneOctree::run(const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& inSelection) { assert(renderContext->args); assert(renderContext->args->hasViewFrustum()); @@ -132,6 +140,8 @@ void DrawSceneOctree::run(const RenderContextPointer& renderContext, const ItemS }); } +gpu::PipelinePointer DrawItemSelection::_drawItemBoundPipeline; + const gpu::PipelinePointer DrawItemSelection::getDrawItemBoundPipeline() { if (!_drawItemBoundPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds); diff --git a/libraries/render/src/render/DrawSceneOctree.h b/libraries/render/src/render/DrawSceneOctree.h index 0c7441404ae..d6359264f24 100644 --- a/libraries/render/src/render/DrawSceneOctree.h +++ b/libraries/render/src/render/DrawSceneOctree.h @@ -50,11 +50,11 @@ namespace render { }; class DrawSceneOctree { - gpu::PipelinePointer _drawCellBoundsPipeline; - gpu::PipelinePointer _drawLODReticlePipeline; - gpu::PipelinePointer _drawItemBoundPipeline; - gpu::BufferPointer _cellBoundsBuffer; - gpu::Stream::FormatPointer _cellBoundsFormat; + static gpu::PipelinePointer _drawCellBoundsPipeline; + static gpu::PipelinePointer _drawLODReticlePipeline; + static gpu::PipelinePointer _drawItemBoundPipeline; + static gpu::Stream::FormatPointer _cellBoundsFormat; + gpu::BufferPointer _cellBoundsBuffer { std::make_shared() }; bool _showVisibleCells; // initialized by Config bool _showEmptyCells; // initialized by Config @@ -63,14 +63,14 @@ namespace render { using Config = DrawSceneOctreeConfig; using JobModel = Job::ModelI; - DrawSceneOctree() {} + DrawSceneOctree(); void configure(const Config& config); void run(const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& selection); - const gpu::PipelinePointer getDrawCellBoundsPipeline(); - const gpu::PipelinePointer getDrawLODReticlePipeline(); - const gpu::PipelinePointer getDrawItemBoundPipeline(); + static const gpu::PipelinePointer getDrawCellBoundsPipeline(); + static const gpu::PipelinePointer getDrawLODReticlePipeline(); + static const gpu::PipelinePointer getDrawItemBoundPipeline(); }; @@ -105,7 +105,7 @@ namespace render { }; class DrawItemSelection { - gpu::PipelinePointer _drawItemBoundPipeline; + static gpu::PipelinePointer _drawItemBoundPipeline; gpu::BufferPointer _boundsBufferInside; gpu::BufferPointer _boundsBufferInsideSubcell; gpu::BufferPointer _boundsBufferPartial; @@ -125,7 +125,7 @@ namespace render { void configure(const Config& config); void run(const RenderContextPointer& renderContext, const ItemSpatialTree::ItemSelection& selection); - const gpu::PipelinePointer getDrawItemBoundPipeline(); + static const gpu::PipelinePointer getDrawItemBoundPipeline(); }; } diff --git a/libraries/render/src/render/DrawStatus.cpp b/libraries/render/src/render/DrawStatus.cpp index d010929e7a1..925cffdae13 100644 --- a/libraries/render/src/render/DrawStatus.cpp +++ b/libraries/render/src/render/DrawStatus.cpp @@ -32,6 +32,10 @@ void DrawStatusConfig::dirtyHelper() { emit dirty(); } +gpu::PipelinePointer DrawStatus::_drawItemBoundsPipeline; +gpu::PipelinePointer DrawStatus::_drawItemStatusPipeline; +gpu::Stream::FormatPointer DrawStatus::_vertexFormat; + const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() { if (!_drawItemBoundsPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds); @@ -149,7 +153,7 @@ void DrawStatus::run(const RenderContextPointer& renderContext, const Input& inp // We have a transition. Show this icon. status.setScale(1.0f); // Is this a valid transition ID according to FadeJob? - auto transitionStage = scene->getStage(TransitionStage::getName()); + auto transitionStage = scene->getStage(); if (transitionStage) { if (transitionStage->isTransitionUsed(transitionID)) { // Valid, active transition diff --git a/libraries/render/src/render/DrawStatus.h b/libraries/render/src/render/DrawStatus.h index 8f61af1f958..82bd50d4799 100644 --- a/libraries/render/src/render/DrawStatus.h +++ b/libraries/render/src/render/DrawStatus.h @@ -52,8 +52,8 @@ namespace render { void configure(const Config& config); void run(const RenderContextPointer& renderContext, const Input& input); - const gpu::PipelinePointer getDrawItemBoundsPipeline(); - const gpu::PipelinePointer getDrawItemStatusPipeline(); + static const gpu::PipelinePointer getDrawItemBoundsPipeline(); + static const gpu::PipelinePointer getDrawItemStatusPipeline(); void setStatusIconMap(const gpu::TexturePointer& map); const gpu::TexturePointer getStatusIconMap() const; @@ -63,13 +63,12 @@ namespace render { bool _showNetwork { false }; // initialized by Config bool _showFade { false }; // initialized by Config - gpu::Stream::FormatPointer _drawItemFormat; - gpu::PipelinePointer _drawItemBoundsPipeline; - gpu::PipelinePointer _drawItemStatusPipeline; + static gpu::PipelinePointer _drawItemBoundsPipeline; + static gpu::PipelinePointer _drawItemStatusPipeline; + static gpu::Stream::FormatPointer _vertexFormat; gpu::BufferPointer _boundsBuffer; gpu::BufferPointer _instanceBuffer; - gpu::Stream::FormatPointer _vertexFormat; gpu::TexturePointer _statusIconMap; }; } diff --git a/libraries/render/src/render/DrawTask.cpp b/libraries/render/src/render/DrawTask.cpp index 68a87ca53cf..3684f790e36 100644 --- a/libraries/render/src/render/DrawTask.cpp +++ b/libraries/render/src/render/DrawTask.cpp @@ -155,6 +155,8 @@ void DrawLight::run(const RenderContextPointer& renderContext, const ItemBounds& config->setNumDrawn((int)inLights.size()); } +gpu::PipelinePointer DrawBounds::_boundsPipeline; + const gpu::PipelinePointer DrawBounds::getPipeline() { if (!_boundsPipeline) { gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds); diff --git a/libraries/render/src/render/DrawTask.h b/libraries/render/src/render/DrawTask.h index 1ef4b8caf17..5ac5edd5f9e 100644 --- a/libraries/render/src/render/DrawTask.h +++ b/libraries/render/src/render/DrawTask.h @@ -63,8 +63,8 @@ class DrawBounds { const Inputs& items); private: - const gpu::PipelinePointer getPipeline(); - gpu::PipelinePointer _boundsPipeline; + static const gpu::PipelinePointer getPipeline(); + static gpu::PipelinePointer _boundsPipeline; gpu::BufferPointer _drawBuffer; gpu::BufferPointer _paramsBuffer; }; diff --git a/libraries/render/src/render/Scene.cpp b/libraries/render/src/render/Scene.cpp index 58707bf4dbe..a9bb2a58560 100644 --- a/libraries/render/src/render/Scene.cpp +++ b/libraries/render/src/render/Scene.cpp @@ -382,7 +382,7 @@ void Scene::updateItems(const Transaction::Updates& transactions) { } void Scene::resetTransitionItems(const Transaction::TransitionResets& transactions) { - auto transitionStage = getStage(TransitionStage::getName()); + auto transitionStage = getStage(); if (!transitionStage) { return; @@ -425,7 +425,7 @@ void Scene::removeTransitionItems(const Transaction::TransitionRemoves& transact } void Scene::queryTransitionItems(const Transaction::TransitionQueries& transactions) { - auto transitionStage = getStage(TransitionStage::getName()); + auto transitionStage = getStage(); if (!transitionStage) { return; @@ -467,7 +467,7 @@ void Scene::resetTransitionFinishedOperator(const Transaction::TransitionFinishe } void Scene::resetHighlights(const Transaction::HighlightResets& transactions) { - auto outlineStage = getStage(HighlightStage::getName()); + auto outlineStage = getStage(); if (outlineStage) { for (auto& transaction : transactions) { const auto& selectionName = std::get<0>(transaction); @@ -484,7 +484,7 @@ void Scene::resetHighlights(const Transaction::HighlightResets& transactions) { } void Scene::removeHighlights(const Transaction::HighlightRemoves& transactions) { - auto outlineStage = getStage(HighlightStage::getName()); + auto outlineStage = getStage(); if (outlineStage) { for (auto& selectionName : transactions) { auto outlineId = outlineStage->getHighlightIdBySelection(selectionName); @@ -497,7 +497,7 @@ void Scene::removeHighlights(const Transaction::HighlightRemoves& transactions) } void Scene::queryHighlights(const Transaction::HighlightQueries& transactions) { - auto outlineStage = getStage(HighlightStage::getName()); + auto outlineStage = getStage(); if (outlineStage) { for (auto& transaction : transactions) { const auto& selectionName = std::get<0>(transaction); @@ -551,7 +551,7 @@ void Scene::setItemTransition(ItemID itemId, Index transitionId) { } void Scene::removeItemTransition(ItemID itemId) { - auto transitionStage = getStage(TransitionStage::getName()); + auto transitionStage = getStage(); if (!transitionStage) { return; } diff --git a/libraries/task/src/task/Task.h b/libraries/task/src/task/Task.h index e51261e83b2..9347fcab13b 100644 --- a/libraries/task/src/task/Task.h +++ b/libraries/task/src/task/Task.h @@ -332,7 +332,7 @@ class Task : public Job { void run(const ContextPointer& jobContext) override { auto config = std::static_pointer_cast(Concept::_config); if (config->isEnabled()) { - for (auto job : TaskConcept::_jobs) { + for (auto& job : TaskConcept::_jobs) { job.run(jobContext); if (jobContext->taskFlow.doAbortTask()) { jobContext->taskFlow.reset(); diff --git a/scripts/developer/utilities/lib/jet/jet.js b/scripts/developer/utilities/lib/jet/jet.js index 4c3188a5cf2..0be9d01e7ef 100644 --- a/scripts/developer/utilities/lib/jet/jet.js +++ b/scripts/developer/utilities/lib/jet/jet.js @@ -100,7 +100,6 @@ function job_print_functor(printout, showProps, showInOuts, maxDepth) { } } if (showInOuts) { - printout("jsdkfkjdskflj") var inouts = job_inoutKeys(job); for (var p=0; p < inouts.length;p++) { var prop = job[inouts[p]]