From cbe5814c64347ecfdcf8ca1770d6fabfccf6e924 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 16 Nov 2018 14:53:53 -0800 Subject: [PATCH 1/5] shader compilation prototype --- interface/src/Application.cpp | 44 +------------- interface/src/Application.h | 2 + interface/src/Application_render.cpp | 60 ++++++++++++------- .../display-plugins/OpenGLDisplayPlugin.cpp | 15 +++++ .../src/display-plugins/OpenGLDisplayPlugin.h | 3 + .../gpu-gl-common/src/gpu/gl/GLShader.cpp | 1 + libraries/plugins/src/plugins/DisplayPlugin.h | 4 ++ 7 files changed, 65 insertions(+), 64 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 969a05a792..6d13305af7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2382,6 +2382,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo checkLoginTimer->start(); } #endif + + const QString SPLASH_SKYBOX { "{\"ProceduralEntity\":{ \"version\":2, \"shaderUrl\":\"qrc:///shaders/splashSkybox.frag\" } }" }; + _splashScreen->parse(SPLASH_SKYBOX); } void Application::updateVerboseLogging() { @@ -2862,8 +2865,6 @@ void Application::initializeGL() { DependencyManager::get()->setGPUContext(_gpuContext); } -static const QString SPLASH_SKYBOX{ "{\"ProceduralEntity\":{ \"version\":2, \"shaderUrl\":\"qrc:///shaders/splashSkybox.frag\" } }" }; - void Application::initializeDisplayPlugins() { auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins(); Setting::Handle activeDisplayPluginSetting{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME, displayPlugins.at(0)->getName() }; @@ -2899,45 +2900,6 @@ void Application::initializeDisplayPlugins() { // Submit a default frame to render until the engine starts up updateRenderArgs(0.0f); - -#define ENABLE_SPLASH_FRAME 0 -#if ENABLE_SPLASH_FRAME - { - QMutexLocker viewLocker(&_renderArgsMutex); - - if (_appRenderArgs._isStereo) { - _gpuContext->enableStereo(true); - _gpuContext->setStereoProjections(_appRenderArgs._eyeProjections); - _gpuContext->setStereoViews(_appRenderArgs._eyeOffsets); - } - - // Frame resources - auto framebufferCache = DependencyManager::get(); - gpu::FramebufferPointer finalFramebuffer = framebufferCache->getFramebuffer(); - std::shared_ptr procedural = std::make_shared(); - procedural->parse(SPLASH_SKYBOX); - - _gpuContext->beginFrame(_appRenderArgs._view, _appRenderArgs._headPose); - gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) { - batch.resetStages(); - batch.enableStereo(false); - batch.setFramebuffer(finalFramebuffer); - batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, { 0, 0, 0, 1 }); - batch.enableSkybox(true); - batch.enableStereo(_appRenderArgs._isStereo); - batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); - procedural->render(batch, _appRenderArgs._renderArgs.getViewFrustum()); - }); - auto frame = _gpuContext->endFrame(); - frame->frameIndex = 0; - frame->framebuffer = finalFramebuffer; - frame->pose = _appRenderArgs._headPose; - frame->framebufferRecycler = [framebufferCache, procedural](const gpu::FramebufferPointer& framebuffer) { - framebufferCache->releaseFramebuffer(framebuffer); - }; - _displayPlugin->submitFrame(frame); - } -#endif } void Application::initializeRenderEngine() { diff --git a/interface/src/Application.h b/interface/src/Application.h index 9b8aac425a..fb1c916c36 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -793,5 +793,7 @@ private: bool _showTrackedObjects { false }; bool _prevShowTrackedObjects { false }; + + std::shared_ptr _splashScreen { std::make_shared() }; }; #endif // hifi_Application_h diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index a87caeb9a8..47cde80ab3 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -62,6 +62,7 @@ void Application::paintGL() { glm::mat4 HMDSensorPose; glm::mat4 eyeToWorld; glm::mat4 sensorToWorld; + ViewFrustum viewFrustum; bool isStereo; glm::mat4 stereoEyeOffsets[2]; @@ -84,6 +85,7 @@ void Application::paintGL() { stereoEyeOffsets[eye] = _appRenderArgs._eyeOffsets[eye]; stereoEyeProjections[eye] = _appRenderArgs._eyeProjections[eye]; }); + viewFrustum = _appRenderArgs._renderArgs.getViewFrustum(); } { @@ -94,21 +96,12 @@ void Application::paintGL() { gpu::doInBatch("Application_render::gpuContextReset", _gpuContext, [&](gpu::Batch& batch) { batch.resetStages(); }); - } - - { - PROFILE_RANGE(render, "/renderOverlay"); - PerformanceTimer perfTimer("renderOverlay"); - // NOTE: There is no batch associated with this renderArgs - // the ApplicationOverlay class assumes it's viewport is setup to be the device size - renderArgs._viewport = glm::ivec4(0, 0, getDeviceSize()); - _applicationOverlay.renderOverlay(&renderArgs); - } - - { - PROFILE_RANGE(render, "/updateCompositor"); - getApplicationCompositor().setFrameInfo(_renderFrameCount, eyeToWorld, sensorToWorld); + if (isStereo) { + renderArgs._context->enableStereo(true); + renderArgs._context->setStereoProjections(stereoEyeProjections); + renderArgs._context->setStereoViews(stereoEyeOffsets); + } } gpu::FramebufferPointer finalFramebuffer; @@ -122,17 +115,38 @@ void Application::paintGL() { finalFramebuffer = framebufferCache->getFramebuffer(); } - { - if (isStereo) { - renderArgs._context->enableStereo(true); - renderArgs._context->setStereoProjections(stereoEyeProjections); - renderArgs._context->setStereoViews(stereoEyeOffsets); + if (!displayPlugin->areAllProgramsLoaded()) { + gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) { + batch.enableStereo(false); + batch.setFramebuffer(finalFramebuffer); + batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, { 0, 0, 0, 1 }); + batch.enableSkybox(true); + batch.enableStereo(isStereo); + batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); + _splashScreen->render(batch, viewFrustum); + }); + } else { + { + PROFILE_RANGE(render, "/renderOverlay"); + PerformanceTimer perfTimer("renderOverlay"); + // NOTE: There is no batch associated with this renderArgs + // the ApplicationOverlay class assumes it's viewport is setup to be the device size + renderArgs._viewport = glm::ivec4(0, 0, getDeviceSize()); + _applicationOverlay.renderOverlay(&renderArgs); } - renderArgs._hudOperator = displayPlugin->getHUDOperator(); - renderArgs._hudTexture = _applicationOverlay.getOverlayTexture(); - renderArgs._blitFramebuffer = finalFramebuffer; - runRenderFrame(&renderArgs); + { + PROFILE_RANGE(render, "/updateCompositor"); + getApplicationCompositor().setFrameInfo(_renderFrameCount, eyeToWorld, sensorToWorld); + } + + { + PROFILE_RANGE(render, "/runRenderFrame"); + renderArgs._hudOperator = displayPlugin->getHUDOperator(); + renderArgs._hudTexture = _applicationOverlay.getOverlayTexture(); + renderArgs._blitFramebuffer = finalFramebuffer; + runRenderFrame(&renderArgs); + } } auto frame = _gpuContext->endFrame(); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 190d4d4104..f562efbe22 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -637,6 +638,17 @@ void OpenGLDisplayPlugin::present() { auto frameId = (uint64_t)presentCount(); PROFILE_RANGE_EX(render, __FUNCTION__, 0xffffff00, frameId) uint64_t startPresent = usecTimestampNow(); + + if (!_allProgramsLoaded) { + const auto& programIDs = shader::allPrograms(); + if (_currentLoadingProgramIndex < programIDs.size()) { + auto shader = gpu::Shader::createProgram(programIDs.at(_currentLoadingProgramIndex++)); + gpu::gl::GLShader::sync(*getGLBackend(), *shader); + } else { + _allProgramsLoaded = true; + } + } + { PROFILE_RANGE_EX(render, "updateFrameData", 0xff00ff00, frameId) updateFrameData(); @@ -829,6 +841,9 @@ void OpenGLDisplayPlugin::render(std::function f) { _gpuContext->executeBatch(batch); } +OpenGLDisplayPlugin::OpenGLDisplayPlugin() : DisplayPlugin() { + _allProgramsLoaded = false; +} OpenGLDisplayPlugin::~OpenGLDisplayPlugin() { } diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h index 1cc060161b..1e3983d366 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h @@ -38,6 +38,7 @@ protected: using Lock = std::unique_lock; using Condition = std::condition_variable; public: + OpenGLDisplayPlugin(); ~OpenGLDisplayPlugin(); // These must be final to ensure proper ordering of operations // between the main thread and the presentation thread @@ -180,5 +181,7 @@ protected: // be serialized through this mutex mutable Mutex _presentMutex; float _hudAlpha{ 1.0f }; + + size_t _currentLoadingProgramIndex { 0 }; }; diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLShader.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLShader.cpp index 44d2bd6ca0..cf123a3f66 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLShader.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLShader.cpp @@ -37,6 +37,7 @@ GLShader* GLShader::sync(GLBackend& backend, const Shader& shader, const Shader: if (object) { return object; } + PROFILE_RANGE(render, "/GLShader::sync"); // need to have a gpu object? if (shader.isProgram()) { GLShader* tempObject = backend.compileBackendProgram(shader, handler); diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index ad49ceafe6..e925309042 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -217,6 +217,8 @@ public: static const QString& MENU_PATH(); + bool areAllProgramsLoaded() { return _allProgramsLoaded; } + signals: void recommendedFramebufferSizeChanged(const QSize& size); void resetSensorsRequested(); @@ -233,6 +235,8 @@ protected: float _renderResolutionScale { 1.0f }; + std::atomic _allProgramsLoaded { true }; + private: QMutex _presentMutex; QWaitCondition _presentCondition; From 0fccb4c73c048a381b2024bc31eeeebee8750786 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 16 Nov 2018 18:30:30 -0800 Subject: [PATCH 2/5] move to batch, try to use static --- interface/src/Application_render.cpp | 2 -- .../display-plugins/OpenGLDisplayPlugin.cpp | 23 +++++++++++-------- .../src/display-plugins/OpenGLDisplayPlugin.h | 6 +++-- .../gpu-gl-common/src/gpu/gl/GLBackend.cpp | 7 ++++++ .../gpu-gl-common/src/gpu/gl/GLBackend.h | 2 ++ libraries/gpu/src/gpu/Batch.cpp | 6 +++++ libraries/gpu/src/gpu/Batch.h | 4 ++++ libraries/plugins/src/plugins/DisplayPlugin.h | 4 +--- 8 files changed, 37 insertions(+), 17 deletions(-) diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index 47cde80ab3..8d9cdc980a 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -117,9 +117,7 @@ void Application::paintGL() { if (!displayPlugin->areAllProgramsLoaded()) { gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) { - batch.enableStereo(false); batch.setFramebuffer(finalFramebuffer); - batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, { 0, 0, 0, 1 }); batch.enableSkybox(true); batch.enableStereo(isStereo); batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index f562efbe22..45e0bbc2a6 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -634,18 +633,26 @@ void OpenGLDisplayPlugin::internalPresent() { _presentRate.increment(); } +std::atomic OpenGLDisplayPlugin::_allProgramsLoaded { false }; +unsigned int OpenGLDisplayPlugin::_currentLoadingProgramIndex { 0 }; + +bool OpenGLDisplayPlugin::areAllProgramsLoaded() const { + return OpenGLDisplayPlugin::_allProgramsLoaded.load(); +} + void OpenGLDisplayPlugin::present() { auto frameId = (uint64_t)presentCount(); PROFILE_RANGE_EX(render, __FUNCTION__, 0xffffff00, frameId) uint64_t startPresent = usecTimestampNow(); - if (!_allProgramsLoaded) { + if (!OpenGLDisplayPlugin::_allProgramsLoaded.load()) { const auto& programIDs = shader::allPrograms(); - if (_currentLoadingProgramIndex < programIDs.size()) { - auto shader = gpu::Shader::createProgram(programIDs.at(_currentLoadingProgramIndex++)); - gpu::gl::GLShader::sync(*getGLBackend(), *shader); + if (OpenGLDisplayPlugin::_currentLoadingProgramIndex < programIDs.size()) { + gpu::doInBatch("createAndSyncProgram", _gpuContext, [&programIDs](gpu::Batch& batch) { + batch.createAndSyncProgram(programIDs.at(OpenGLDisplayPlugin::_currentLoadingProgramIndex++)); + }); } else { - _allProgramsLoaded = true; + OpenGLDisplayPlugin::_allProgramsLoaded.store(true); } } @@ -841,10 +848,6 @@ void OpenGLDisplayPlugin::render(std::function f) { _gpuContext->executeBatch(batch); } -OpenGLDisplayPlugin::OpenGLDisplayPlugin() : DisplayPlugin() { - _allProgramsLoaded = false; -} - OpenGLDisplayPlugin::~OpenGLDisplayPlugin() { } diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h index 1e3983d366..acb12aa69a 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h @@ -38,7 +38,6 @@ protected: using Lock = std::unique_lock; using Condition = std::condition_variable; public: - OpenGLDisplayPlugin(); ~OpenGLDisplayPlugin(); // These must be final to ensure proper ordering of operations // between the main thread and the presentation thread @@ -84,6 +83,8 @@ public: void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override; + bool areAllProgramsLoaded() const override; + protected: friend class PresentThread; @@ -182,6 +183,7 @@ protected: mutable Mutex _presentMutex; float _hudAlpha{ 1.0f }; - size_t _currentLoadingProgramIndex { 0 }; + static std::atomic _allProgramsLoaded; + static unsigned int _currentLoadingProgramIndex; }; diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index c1ce05c18b..415c5135d9 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -102,6 +102,8 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = (&::gpu::gl::GLBackend::do_pushProfileRange), (&::gpu::gl::GLBackend::do_popProfileRange), + + (&::gpu::gl::GLBackend::do_createAndSyncProgram), }; #define GL_GET_INTEGER(NAME) glGetIntegerv(GL_##NAME, &const_cast(NAME)); @@ -706,6 +708,11 @@ void GLBackend::do_glColor4f(const Batch& batch, size_t paramOffset) { (void)CHECK_GL_ERROR(); } +void GLBackend::do_createAndSyncProgram(const Batch& batch, size_t paramOffset) { + auto shader = gpu::Shader::createProgram(batch._params[paramOffset + 0]._uint); + gpu::gl::GLShader::sync(*this, *shader); +} + void GLBackend::releaseBuffer(GLuint id, Size size) const { Lock lock(_trashMutex); _currentFrameTrash.buffersTrash.push_back({ id, size }); diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 37dde5b08e..0a2c1b92ff 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -380,6 +380,8 @@ public: virtual void do_setStateBlendFactor(const Batch& batch, size_t paramOffset) final; virtual void do_setStateScissorRect(const Batch& batch, size_t paramOffset) final; + virtual void do_createAndSyncProgram(const Batch& batch, size_t paramOffset) final; + virtual GLuint getFramebufferID(const FramebufferPointer& framebuffer) = 0; virtual GLuint getTextureID(const TexturePointer& texture) final; virtual GLuint getBufferID(const Buffer& buffer) = 0; diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index e3ea210ecb..43c1c69287 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -760,3 +760,9 @@ void Batch::flush() { buffer->flush(); } } + +void Batch::createAndSyncProgram(unsigned int programID) { + ADD_COMMAND(createAndSyncProgram); + + _params.emplace_back(programID); +} \ No newline at end of file diff --git a/libraries/gpu/src/gpu/Batch.h b/libraries/gpu/src/gpu/Batch.h index 96a45d3111..aff6cf5ddd 100644 --- a/libraries/gpu/src/gpu/Batch.h +++ b/libraries/gpu/src/gpu/Batch.h @@ -289,6 +289,8 @@ public: void _glColor4f(float red, float green, float blue, float alpha); + void createAndSyncProgram(unsigned int programID); + // Maybe useful but shoudln't be public. Please convince me otherwise // Well porting to gles i need it... void runLambda(std::function f); @@ -368,6 +370,8 @@ public: COMMAND_pushProfileRange, COMMAND_popProfileRange, + COMMAND_createAndSyncProgram, + NUM_COMMANDS, }; typedef std::vector Commands; diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index e925309042..e9fbd71689 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -217,7 +217,7 @@ public: static const QString& MENU_PATH(); - bool areAllProgramsLoaded() { return _allProgramsLoaded; } + virtual bool areAllProgramsLoaded() const { return true; } signals: void recommendedFramebufferSizeChanged(const QSize& size); @@ -235,8 +235,6 @@ protected: float _renderResolutionScale { 1.0f }; - std::atomic _allProgramsLoaded { true }; - private: QMutex _presentMutex; QWaitCondition _presentCondition; From 372f4390e8f5c9cca94da1fbee648ee75f051cfb Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 19 Nov 2018 19:14:07 -0500 Subject: [PATCH 3/5] replicate default skybox --- interface/resources/shaders/splashSkybox.frag | 71 ++++++++----------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/interface/resources/shaders/splashSkybox.frag b/interface/resources/shaders/splashSkybox.frag index 38c89b4d26..244dad3356 100644 --- a/interface/resources/shaders/splashSkybox.frag +++ b/interface/resources/shaders/splashSkybox.frag @@ -1,47 +1,32 @@ -const vec3 COLOR = vec3(0x00, 0xD8, 0x02) / vec3(0xFF); -const float CUTOFF = 0.65; -const float NOISE_MULT = 8.0; -const float NOISE_POWER = 1.0; +// Replicate the default skybox texture -float noise4D(vec4 p) { - return fract(sin(dot(p ,vec4(12.9898,78.233,126.7235, 593.2241))) * 43758.5453); -} - -float worley4D(vec4 p) { - float r = 3.0; - vec4 f = floor(p); - vec4 x = fract(p); - for(int i = -1; i<=1; i++) - { - for(int j = -1; j<=1; j++) - { - for(int k = -1; k<=1; k++) - { - for (int l = -1; l <= 1; l++) { - vec4 q = vec4(float(i),float(j),float(k), float(l)); - vec4 v = q + vec4(noise4D((q+f)*1.11), noise4D((q+f)*1.14), noise4D((q+f)*1.17), noise4D((q+f)*1.20)) - x; - float d = dot(v, v); - r = min(r, d); - } - } - } - } - return sqrt(r); -} - - -vec3 mainColor(vec3 direction) { - float n = worley4D(vec4(direction * NOISE_MULT, iGlobalTime / 3.0)); - n = 1.0 - n; - n = pow(n, NOISE_POWER); - if (n < CUTOFF) { - return vec3(0.0); - } - - n = (n - CUTOFF) / (1.0 - CUTOFF); - return COLOR * (1.0 - n); -} +const int NUM_COLORS = 5; +const vec3 WHITISH = vec3(0.471, 0.725, 0.825); +const vec3 GREENISH = vec3(0.157, 0.529, 0.588); +const vec3 COLORS[NUM_COLORS] = vec3[]( + GREENISH, + GREENISH, + WHITISH, + WHITISH, + vec3(0.6, 0.275, 0.706) // purple +); +const float PI = 3.14159265359; +const vec3 BLACK = vec3(0.0); +const vec3 SPACE_BLUE = vec3(0.0, 0.118, 0.392); +const float HORIZONTAL_OFFSET = 3.75; vec3 getSkyboxColor() { - return mainColor(normalize(_normal)); + vec2 horizontal = vec2(_normal.x, _normal.z); + horizontal = normalize(horizontal); + float theta = atan(horizontal.y, horizontal.x); + theta = 0.5 * (theta / PI + 1.0); + float index = theta * NUM_COLORS; + index = mod(index + HORIZONTAL_OFFSET, NUM_COLORS); + int index1 = int(index) % NUM_COLORS; + int index2 = (index1 + 1) % NUM_COLORS; + vec3 horizonColor = mix(COLORS[index1], COLORS[index2], index - index1); + horizonColor = mix(horizonColor, SPACE_BLUE, smoothstep(0.0, 0.08, _normal.y)); + horizonColor = mix(horizonColor, BLACK, smoothstep(0.04, 0.15, _normal.y)); + horizonColor = mix(BLACK, horizonColor, smoothstep(-0.01, 0.0, _normal.y)); + return pow(horizonColor, vec3(0.4545));; } From 1f354f813c2553566913e1c514dafb749278a438 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 27 Nov 2018 14:38:02 -0800 Subject: [PATCH 4/5] rework shader pre-compilation --- interface/src/Application.cpp | 7 ++++ interface/src/Application.h | 2 ++ interface/src/Application_render.cpp | 2 +- .../display-plugins/OpenGLDisplayPlugin.cpp | 21 ++---------- .../src/display-plugins/OpenGLDisplayPlugin.h | 5 --- .../gpu-gl-common/src/gpu/gl/GLBackend.cpp | 11 +++---- .../gpu-gl-common/src/gpu/gl/GLBackend.h | 4 +-- libraries/gpu/src/gpu/Batch.cpp | 6 ---- libraries/gpu/src/gpu/Batch.h | 4 --- libraries/gpu/src/gpu/Context.cpp | 33 +++++++++++++++++++ libraries/gpu/src/gpu/Context.h | 21 ++++++++++++ libraries/gpu/src/gpu/null/NullBackend.h | 2 ++ libraries/plugins/src/plugins/DisplayPlugin.h | 2 -- 13 files changed, 75 insertions(+), 45 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6d13305af7..8e311e5487 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2862,6 +2862,13 @@ void Application::initializeGL() { _glWidget->makeCurrent(); _gpuContext = std::make_shared(); + static std::once_flag once; + std::call_once(once, [&] { + _gpuContext->pushProgramsToSync(shader::allPrograms(), [this] { + _programsCompiled.store(true); + }, 1); + }); + DependencyManager::get()->setGPUContext(_gpuContext); } diff --git a/interface/src/Application.h b/interface/src/Application.h index fb1c916c36..c234cd757c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -795,5 +795,7 @@ private: bool _prevShowTrackedObjects { false }; std::shared_ptr _splashScreen { std::make_shared() }; + std::atomic _programsCompiled { false }; + }; #endif // hifi_Application_h diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp index 8d9cdc980a..046cd3b617 100644 --- a/interface/src/Application_render.cpp +++ b/interface/src/Application_render.cpp @@ -115,7 +115,7 @@ void Application::paintGL() { finalFramebuffer = framebufferCache->getFramebuffer(); } - if (!displayPlugin->areAllProgramsLoaded()) { + if (!_programsCompiled.load()) { gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) { batch.setFramebuffer(finalFramebuffer); batch.enableSkybox(true); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 45e0bbc2a6..aafc1a28a5 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -525,6 +525,9 @@ void OpenGLDisplayPlugin::updateFrameData() { if (_newFrameQueue.size() > 1) { _droppedFrameRate.increment(_newFrameQueue.size() - 1); } + + _gpuContext->processProgramsToSync(); + while (!_newFrameQueue.empty()) { _currentFrame = _newFrameQueue.front(); _newFrameQueue.pop(); @@ -633,29 +636,11 @@ void OpenGLDisplayPlugin::internalPresent() { _presentRate.increment(); } -std::atomic OpenGLDisplayPlugin::_allProgramsLoaded { false }; -unsigned int OpenGLDisplayPlugin::_currentLoadingProgramIndex { 0 }; - -bool OpenGLDisplayPlugin::areAllProgramsLoaded() const { - return OpenGLDisplayPlugin::_allProgramsLoaded.load(); -} - void OpenGLDisplayPlugin::present() { auto frameId = (uint64_t)presentCount(); PROFILE_RANGE_EX(render, __FUNCTION__, 0xffffff00, frameId) uint64_t startPresent = usecTimestampNow(); - if (!OpenGLDisplayPlugin::_allProgramsLoaded.load()) { - const auto& programIDs = shader::allPrograms(); - if (OpenGLDisplayPlugin::_currentLoadingProgramIndex < programIDs.size()) { - gpu::doInBatch("createAndSyncProgram", _gpuContext, [&programIDs](gpu::Batch& batch) { - batch.createAndSyncProgram(programIDs.at(OpenGLDisplayPlugin::_currentLoadingProgramIndex++)); - }); - } else { - OpenGLDisplayPlugin::_allProgramsLoaded.store(true); - } - } - { PROFILE_RANGE_EX(render, "updateFrameData", 0xff00ff00, frameId) updateFrameData(); diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h index acb12aa69a..1cc060161b 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.h @@ -83,8 +83,6 @@ public: void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override; - bool areAllProgramsLoaded() const override; - protected: friend class PresentThread; @@ -182,8 +180,5 @@ protected: // be serialized through this mutex mutable Mutex _presentMutex; float _hudAlpha{ 1.0f }; - - static std::atomic _allProgramsLoaded; - static unsigned int _currentLoadingProgramIndex; }; diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index 415c5135d9..295b9becb8 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -102,8 +102,6 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] = (&::gpu::gl::GLBackend::do_pushProfileRange), (&::gpu::gl::GLBackend::do_popProfileRange), - - (&::gpu::gl::GLBackend::do_createAndSyncProgram), }; #define GL_GET_INTEGER(NAME) glGetIntegerv(GL_##NAME, &const_cast(NAME)); @@ -708,11 +706,6 @@ void GLBackend::do_glColor4f(const Batch& batch, size_t paramOffset) { (void)CHECK_GL_ERROR(); } -void GLBackend::do_createAndSyncProgram(const Batch& batch, size_t paramOffset) { - auto shader = gpu::Shader::createProgram(batch._params[paramOffset + 0]._uint); - gpu::gl::GLShader::sync(*this, *shader); -} - void GLBackend::releaseBuffer(GLuint id, Size size) const { Lock lock(_trashMutex); _currentFrameTrash.buffersTrash.push_back({ id, size }); @@ -866,3 +859,7 @@ void GLBackend::setCameraCorrection(const Mat4& correction, const Mat4& prevRend _pipeline._cameraCorrectionBuffer._buffer->setSubData(0, _transform._correction); _pipeline._cameraCorrectionBuffer._buffer->flush(); } + +void GLBackend::syncProgram(const gpu::ShaderPointer& program) { + gpu::gl::GLShader::sync(*this, *program); +} \ No newline at end of file diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 0a2c1b92ff..07f7df9277 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -249,6 +249,8 @@ public: // Let's try to avoid to do that as much as possible! void syncCache() final override; + void syncProgram(const gpu::ShaderPointer& program) override; + // This is the ugly "download the pixels to sysmem for taking a snapshot" // Just avoid using it, it's ugly and will break performances virtual void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, @@ -380,8 +382,6 @@ public: virtual void do_setStateBlendFactor(const Batch& batch, size_t paramOffset) final; virtual void do_setStateScissorRect(const Batch& batch, size_t paramOffset) final; - virtual void do_createAndSyncProgram(const Batch& batch, size_t paramOffset) final; - virtual GLuint getFramebufferID(const FramebufferPointer& framebuffer) = 0; virtual GLuint getTextureID(const TexturePointer& texture) final; virtual GLuint getBufferID(const Buffer& buffer) = 0; diff --git a/libraries/gpu/src/gpu/Batch.cpp b/libraries/gpu/src/gpu/Batch.cpp index 43c1c69287..a9b062a285 100644 --- a/libraries/gpu/src/gpu/Batch.cpp +++ b/libraries/gpu/src/gpu/Batch.cpp @@ -759,10 +759,4 @@ void Batch::flush() { } buffer->flush(); } -} - -void Batch::createAndSyncProgram(unsigned int programID) { - ADD_COMMAND(createAndSyncProgram); - - _params.emplace_back(programID); } \ No newline at end of file diff --git a/libraries/gpu/src/gpu/Batch.h b/libraries/gpu/src/gpu/Batch.h index aff6cf5ddd..96a45d3111 100644 --- a/libraries/gpu/src/gpu/Batch.h +++ b/libraries/gpu/src/gpu/Batch.h @@ -289,8 +289,6 @@ public: void _glColor4f(float red, float green, float blue, float alpha); - void createAndSyncProgram(unsigned int programID); - // Maybe useful but shoudln't be public. Please convince me otherwise // Well porting to gles i need it... void runLambda(std::function f); @@ -370,8 +368,6 @@ public: COMMAND_pushProfileRange, COMMAND_popProfileRange, - COMMAND_createAndSyncProgram, - NUM_COMMANDS, }; typedef std::vector Commands; diff --git a/libraries/gpu/src/gpu/Context.cpp b/libraries/gpu/src/gpu/Context.cpp index dd0d510509..be55e5ba87 100644 --- a/libraries/gpu/src/gpu/Context.cpp +++ b/libraries/gpu/src/gpu/Context.cpp @@ -335,6 +335,39 @@ Size Context::getTextureResourceIdealGPUMemSize() { return Backend::textureResourceIdealGPUMemSize.getValue(); } +void Context::pushProgramsToSync(const std::vector& programIDs, std::function callback, size_t rate) { + std::vector programs; + for (auto programID : programIDs) { + programs.push_back(gpu::Shader::createProgram(programID)); + } + pushProgramsToSync(programs, callback, rate); +} + +void Context::pushProgramsToSync(const std::vector& programs, std::function callback, size_t rate) { + Lock lock(_programsToSyncMutex); + _programsToSyncQueue.emplace(programs, callback, rate == 0 ? programs.size() : rate); +} + +void Context::processProgramsToSync() { + Lock lock(_programsToSyncMutex); + if (!_programsToSyncQueue.empty()) { + ProgramsToSync programsToSync = _programsToSyncQueue.front(); + int numSynced = 0; + while (_nextProgramToSyncIndex < programsToSync.programs.size() && numSynced < programsToSync.rate) { + auto nextProgram = programsToSync.programs.at(_nextProgramToSyncIndex); + _backend->syncProgram(nextProgram); + _syncedPrograms.push_back(nextProgram); + _nextProgramToSyncIndex++; + numSynced++; + } + + if (_nextProgramToSyncIndex == programsToSync.programs.size()) { + programsToSync.callback(); + _nextProgramToSyncIndex = 0; + _programsToSyncQueue.pop(); + } + } +} BatchPointer Context::acquireBatch(const char* name) { Batch* rawBatch = nullptr; diff --git a/libraries/gpu/src/gpu/Context.h b/libraries/gpu/src/gpu/Context.h index 011f980957..3fb90fd2e9 100644 --- a/libraries/gpu/src/gpu/Context.h +++ b/libraries/gpu/src/gpu/Context.h @@ -13,6 +13,7 @@ #include #include +#include #include @@ -61,6 +62,7 @@ public: virtual void render(const Batch& batch) = 0; virtual void syncCache() = 0; + virtual void syncProgram(const gpu::ShaderPointer& program) = 0; virtual void recycle() const = 0; virtual void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage) = 0; @@ -245,6 +247,20 @@ public: static Size getTextureResourcePopulatedGPUMemSize(); static Size getTextureResourceIdealGPUMemSize(); + struct ProgramsToSync { + ProgramsToSync(const std::vector& programs, std::function callback, size_t rate) : + programs(programs), callback(callback), rate(rate) {} + + std::vector programs; + std::function callback; + size_t rate; + }; + + void pushProgramsToSync(const std::vector& programIDs, std::function callback, size_t rate = 0); + void pushProgramsToSync(const std::vector& programs, std::function callback, size_t rate = 0); + + void processProgramsToSync(); + protected: Context(const Context& context); @@ -256,6 +272,11 @@ protected: RangeTimerPointer _frameRangeTimer; StereoState _stereo; + std::mutex _programsToSyncMutex; + std::queue _programsToSyncQueue; + gpu::Shaders _syncedPrograms; + size_t _nextProgramToSyncIndex { 0 }; + // Sampled at the end of every frame, the stats of all the counters mutable ContextStats _frameStats; diff --git a/libraries/gpu/src/gpu/null/NullBackend.h b/libraries/gpu/src/gpu/null/NullBackend.h index e227b631c7..f934bcf619 100644 --- a/libraries/gpu/src/gpu/null/NullBackend.h +++ b/libraries/gpu/src/gpu/null/NullBackend.h @@ -43,6 +43,8 @@ public: // Let's try to avoid to do that as much as possible! void syncCache() final { } + void syncProgram(const gpu::ShaderPointer& program) final {} + // This is the ugly "download the pixels to sysmem for taking a snapshot" // Just avoid using it, it's ugly and will break performances virtual void downloadFramebuffer(const FramebufferPointer& srcFramebuffer, const Vec4i& region, QImage& destImage) final { } diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index e9fbd71689..ad49ceafe6 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -217,8 +217,6 @@ public: static const QString& MENU_PATH(); - virtual bool areAllProgramsLoaded() const { return true; } - signals: void recommendedFramebufferSizeChanged(const QSize& size); void resetSensorsRequested(); From 92117d602c30146b88bcddc2b61a6ae17060c9ea Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 5 Dec 2018 11:20:18 -0800 Subject: [PATCH 5/5] remove cruft --- interface/src/Application_render.cpp | 240 ---------------------- interface/src/graphics/GraphicsEngine.cpp | 4 + 2 files changed, 4 insertions(+), 240 deletions(-) delete mode 100644 interface/src/Application_render.cpp diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp deleted file mode 100644 index ea672e3510..0000000000 --- a/interface/src/Application_render.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// -// Application_render.cpp -// interface/src -// -// Copyright 2013 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 "Application.h" -#include - -#include -#include -#include -#include -#include "ui/Stats.h" -#include "Util.h" - -//void Application::paintGL() { -// // Some plugins process message events, allowing paintGL to be called reentrantly. -// -// _renderFrameCount++; -// // SG: Moved into the RenderEventHandler -// //_lastTimeRendered.start(); -// -// auto lastPaintBegin = usecTimestampNow(); -// PROFILE_RANGE_EX(render, __FUNCTION__, 0xff0000ff, (uint64_t)_renderFrameCount); -// PerformanceTimer perfTimer("paintGL"); -// -// if (nullptr == _displayPlugin) { -// return; -// } -// -// DisplayPluginPointer displayPlugin; -// { -// PROFILE_RANGE(render, "/getActiveDisplayPlugin"); -// displayPlugin = getActiveDisplayPlugin(); -// } -// -// { -// PROFILE_RANGE(render, "/pluginBeginFrameRender"); -// // If a display plugin loses it's underlying support, it -// // needs to be able to signal us to not use it -// if (!displayPlugin->beginFrameRender(_renderFrameCount)) { -// QMetaObject::invokeMethod(this, "updateDisplayMode"); -// return; -// } -// } -// -// RenderArgs renderArgs; -// glm::mat4 HMDSensorPose; -// glm::mat4 eyeToWorld; -// glm::mat4 sensorToWorld; -// ViewFrustum viewFrustum; -// -// bool isStereo; -// glm::mat4 stereoEyeOffsets[2]; -// glm::mat4 stereoEyeProjections[2]; -// -// { -// QMutexLocker viewLocker(&_renderArgsMutex); -// renderArgs = _appRenderArgs._renderArgs; -// -// // don't render if there is no context. -// if (!_appRenderArgs._renderArgs._context) { -// return; -// } -// -// HMDSensorPose = _appRenderArgs._headPose; -// eyeToWorld = _appRenderArgs._eyeToWorld; -// sensorToWorld = _appRenderArgs._sensorToWorld; -// isStereo = _appRenderArgs._isStereo; -// for_each_eye([&](Eye eye) { -// stereoEyeOffsets[eye] = _appRenderArgs._eyeOffsets[eye]; -// stereoEyeProjections[eye] = _appRenderArgs._eyeProjections[eye]; -// }); -// viewFrustum = _appRenderArgs._renderArgs.getViewFrustum(); -// } -// -// { -// PROFILE_RANGE(render, "/gpuContextReset"); -// _graphicsEngine.getGPUContext()->beginFrame(_appRenderArgs._view, HMDSensorPose); -// // Reset the gpu::Context Stages -// // Back to the default framebuffer; -// gpu::doInBatch("Application_render::gpuContextReset", _graphicsEngine.getGPUContext(), [&](gpu::Batch& batch) { -// batch.resetStages(); -// }); -// -// if (isStereo) { -// renderArgs._context->enableStereo(true); -// renderArgs._context->setStereoProjections(stereoEyeProjections); -// renderArgs._context->setStereoViews(stereoEyeOffsets); -// } -// } -// -// gpu::FramebufferPointer finalFramebuffer; -// QSize finalFramebufferSize; -// { -// PROFILE_RANGE(render, "/getOutputFramebuffer"); -// // Primary rendering pass -// auto framebufferCache = DependencyManager::get(); -// finalFramebufferSize = framebufferCache->getFrameBufferSize(); -// // Final framebuffer that will be handed to the display-plugin -// finalFramebuffer = framebufferCache->getFramebuffer(); -// } -// -// if (!_programsCompiled.load()) { -// gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) { -// batch.setFramebuffer(finalFramebuffer); -// batch.enableSkybox(true); -// batch.enableStereo(isStereo); -// batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); -// _splashScreen->render(batch, viewFrustum); -// }); -// } else { -// { -// PROFILE_RANGE(render, "/renderOverlay"); -// PerformanceTimer perfTimer("renderOverlay"); -// // NOTE: There is no batch associated with this renderArgs -// // the ApplicationOverlay class assumes it's viewport is setup to be the device size -// renderArgs._viewport = glm::ivec4(0, 0, getDeviceSize()); -// _applicationOverlay.renderOverlay(&renderArgs); -// } -// -// { -// PROFILE_RANGE(render, "/updateCompositor"); -// getApplicationCompositor().setFrameInfo(_renderFrameCount, eyeToWorld, sensorToWorld); -// } -// -// { -// PROFILE_RANGE(render, "/runRenderFrame"); -// renderArgs._hudOperator = displayPlugin->getHUDOperator(); -// renderArgs._hudTexture = _applicationOverlay.getOverlayTexture(); -// renderArgs._blitFramebuffer = finalFramebuffer; -// runRenderFrame(&renderArgs); -// } -// } -// -// auto frame = _graphicsEngine.getGPUContext()->endFrame(); -// frame->frameIndex = _renderFrameCount; -// frame->framebuffer = finalFramebuffer; -// frame->framebufferRecycler = [](const gpu::FramebufferPointer& framebuffer) { -// auto frameBufferCache = DependencyManager::get(); -// if (frameBufferCache) { -// frameBufferCache->releaseFramebuffer(framebuffer); -// } -// }; -// // deliver final scene rendering commands to the display plugin -// { -// PROFILE_RANGE(render, "/pluginOutput"); -// PerformanceTimer perfTimer("pluginOutput"); -// _renderLoopCounter.increment(); -// displayPlugin->submitFrame(frame); -// } -// -// // Reset the framebuffer and stereo state -// renderArgs._blitFramebuffer.reset(); -// renderArgs._context->enableStereo(false); -// -//#if !defined(DISABLE_QML) -// { -// auto stats = Stats::getInstance(); -// if (stats) { -// stats->setRenderDetails(renderArgs._details); -// } -// } -//#endif -// -// uint64_t lastPaintDuration = usecTimestampNow() - lastPaintBegin; -// _frameTimingsScriptingInterface.addValue(lastPaintDuration); -//} - -// WorldBox Render Data & rendering functions -// -//class WorldBoxRenderData { -//public: -// typedef render::Payload Payload; -// typedef Payload::DataPointer Pointer; -// -// int _val = 0; -// static render::ItemID _item; // unique WorldBoxRenderData -//}; -// -//render::ItemID WorldBoxRenderData::_item{ render::Item::INVALID_ITEM_ID }; -// -//namespace render { -// template <> const ItemKey payloadGetKey(const WorldBoxRenderData::Pointer& stuff) { return ItemKey::Builder::opaqueShape().withTagBits(ItemKey::TAG_BITS_0 | ItemKey::TAG_BITS_1); } -// template <> const Item::Bound payloadGetBound(const WorldBoxRenderData::Pointer& stuff) { return Item::Bound(); } -// template <> void payloadRender(const WorldBoxRenderData::Pointer& stuff, RenderArgs* args) { -// if (Menu::getInstance()->isOptionChecked(MenuOption::WorldAxes)) { -// PerformanceTimer perfTimer("worldBox"); -// -// auto& batch = *args->_batch; -// DependencyManager::get()->bindSimpleProgram(batch); -// renderWorldBox(args, batch); -// } -// } -//} -// -//void Application::runRenderFrame(RenderArgs* renderArgs) { -// PROFILE_RANGE(render, __FUNCTION__); -// PerformanceTimer perfTimer("display"); -// PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::runRenderFrame()"); -// -// // The pending changes collecting the changes here -// render::Transaction transaction; -// -// if (DependencyManager::get()->shouldRenderEntities()) { -// // render models... -// PerformanceTimer perfTimer("entities"); -// PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), -// "Application::runRenderFrame() ... entities..."); -// -// RenderArgs::DebugFlags renderDebugFlags = RenderArgs::RENDER_DEBUG_NONE; -// -// renderArgs->_debugFlags = renderDebugFlags; -// } -// -// // Make sure the WorldBox is in the scene -// // For the record, this one RenderItem is the first one we created and added to the scene. -// // We could move that code elsewhere but you know... -// if (!render::Item::isValidID(WorldBoxRenderData::_item)) { -// auto worldBoxRenderData = std::make_shared(); -// auto worldBoxRenderPayload = std::make_shared(worldBoxRenderData); -// -// WorldBoxRenderData::_item = _main3DScene->allocateID(); -// -// transaction.resetItem(WorldBoxRenderData::_item, worldBoxRenderPayload); -// _main3DScene->enqueueTransaction(transaction); -// } -// -// { -// PerformanceTimer perfTimer("EngineRun"); -// _renderEngine->getRenderContext()->args = renderArgs; -// _renderEngine->run(); -// } -//} - diff --git a/interface/src/graphics/GraphicsEngine.cpp b/interface/src/graphics/GraphicsEngine.cpp index b7a5e89d35..36bf3a1b97 100644 --- a/interface/src/graphics/GraphicsEngine.cpp +++ b/interface/src/graphics/GraphicsEngine.cpp @@ -56,6 +56,10 @@ void GraphicsEngine::initializeGPU(GLWidget* glwidget) { glwidget->makeCurrent(); _gpuContext = std::make_shared(); + _gpuContext->pushProgramsToSync(shader::allPrograms(), [this] { + _programsCompiled.store(true); + }, 1); + DependencyManager::get()->setGPUContext(_gpuContext); }