mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:57:13 +02:00
shader compilation prototype
This commit is contained in:
parent
20766da624
commit
cbe5814c64
7 changed files with 65 additions and 64 deletions
|
@ -2382,6 +2382,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
checkLoginTimer->start();
|
checkLoginTimer->start();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const QString SPLASH_SKYBOX { "{\"ProceduralEntity\":{ \"version\":2, \"shaderUrl\":\"qrc:///shaders/splashSkybox.frag\" } }" };
|
||||||
|
_splashScreen->parse(SPLASH_SKYBOX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateVerboseLogging() {
|
void Application::updateVerboseLogging() {
|
||||||
|
@ -2862,8 +2865,6 @@ void Application::initializeGL() {
|
||||||
DependencyManager::get<TextureCache>()->setGPUContext(_gpuContext);
|
DependencyManager::get<TextureCache>()->setGPUContext(_gpuContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const QString SPLASH_SKYBOX{ "{\"ProceduralEntity\":{ \"version\":2, \"shaderUrl\":\"qrc:///shaders/splashSkybox.frag\" } }" };
|
|
||||||
|
|
||||||
void Application::initializeDisplayPlugins() {
|
void Application::initializeDisplayPlugins() {
|
||||||
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
auto displayPlugins = PluginManager::getInstance()->getDisplayPlugins();
|
||||||
Setting::Handle<QString> activeDisplayPluginSetting{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME, displayPlugins.at(0)->getName() };
|
Setting::Handle<QString> 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
|
// Submit a default frame to render until the engine starts up
|
||||||
updateRenderArgs(0.0f);
|
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<FramebufferCache>();
|
|
||||||
gpu::FramebufferPointer finalFramebuffer = framebufferCache->getFramebuffer();
|
|
||||||
std::shared_ptr<ProceduralSkybox> procedural = std::make_shared<ProceduralSkybox>();
|
|
||||||
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() {
|
void Application::initializeRenderEngine() {
|
||||||
|
|
|
@ -793,5 +793,7 @@ private:
|
||||||
|
|
||||||
bool _showTrackedObjects { false };
|
bool _showTrackedObjects { false };
|
||||||
bool _prevShowTrackedObjects { false };
|
bool _prevShowTrackedObjects { false };
|
||||||
|
|
||||||
|
std::shared_ptr<ProceduralSkybox> _splashScreen { std::make_shared<ProceduralSkybox>() };
|
||||||
};
|
};
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -62,6 +62,7 @@ void Application::paintGL() {
|
||||||
glm::mat4 HMDSensorPose;
|
glm::mat4 HMDSensorPose;
|
||||||
glm::mat4 eyeToWorld;
|
glm::mat4 eyeToWorld;
|
||||||
glm::mat4 sensorToWorld;
|
glm::mat4 sensorToWorld;
|
||||||
|
ViewFrustum viewFrustum;
|
||||||
|
|
||||||
bool isStereo;
|
bool isStereo;
|
||||||
glm::mat4 stereoEyeOffsets[2];
|
glm::mat4 stereoEyeOffsets[2];
|
||||||
|
@ -84,6 +85,7 @@ void Application::paintGL() {
|
||||||
stereoEyeOffsets[eye] = _appRenderArgs._eyeOffsets[eye];
|
stereoEyeOffsets[eye] = _appRenderArgs._eyeOffsets[eye];
|
||||||
stereoEyeProjections[eye] = _appRenderArgs._eyeProjections[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) {
|
gpu::doInBatch("Application_render::gpuContextReset", _gpuContext, [&](gpu::Batch& batch) {
|
||||||
batch.resetStages();
|
batch.resetStages();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
if (isStereo) {
|
||||||
{
|
renderArgs._context->enableStereo(true);
|
||||||
PROFILE_RANGE(render, "/renderOverlay");
|
renderArgs._context->setStereoProjections(stereoEyeProjections);
|
||||||
PerformanceTimer perfTimer("renderOverlay");
|
renderArgs._context->setStereoViews(stereoEyeOffsets);
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::FramebufferPointer finalFramebuffer;
|
gpu::FramebufferPointer finalFramebuffer;
|
||||||
|
@ -122,17 +115,38 @@ void Application::paintGL() {
|
||||||
finalFramebuffer = framebufferCache->getFramebuffer();
|
finalFramebuffer = framebufferCache->getFramebuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (!displayPlugin->areAllProgramsLoaded()) {
|
||||||
if (isStereo) {
|
gpu::doInBatch("splashFrame", _gpuContext, [&](gpu::Batch& batch) {
|
||||||
renderArgs._context->enableStereo(true);
|
batch.enableStereo(false);
|
||||||
renderArgs._context->setStereoProjections(stereoEyeProjections);
|
batch.setFramebuffer(finalFramebuffer);
|
||||||
renderArgs._context->setStereoViews(stereoEyeOffsets);
|
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();
|
PROFILE_RANGE(render, "/updateCompositor");
|
||||||
renderArgs._blitFramebuffer = finalFramebuffer;
|
getApplicationCompositor().setFrameInfo(_renderFrameCount, eyeToWorld, sensorToWorld);
|
||||||
runRenderFrame(&renderArgs);
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
PROFILE_RANGE(render, "/runRenderFrame");
|
||||||
|
renderArgs._hudOperator = displayPlugin->getHUDOperator();
|
||||||
|
renderArgs._hudTexture = _applicationOverlay.getOverlayTexture();
|
||||||
|
renderArgs._blitFramebuffer = finalFramebuffer;
|
||||||
|
runRenderFrame(&renderArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto frame = _gpuContext->endFrame();
|
auto frame = _gpuContext->endFrame();
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <gpu/Texture.h>
|
#include <gpu/Texture.h>
|
||||||
#include <shaders/Shaders.h>
|
#include <shaders/Shaders.h>
|
||||||
|
#include <gpu/gl/GLShader.h>
|
||||||
#include <gpu/gl/GLShared.h>
|
#include <gpu/gl/GLShared.h>
|
||||||
#include <gpu/gl/GLBackend.h>
|
#include <gpu/gl/GLBackend.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
|
@ -637,6 +638,17 @@ void OpenGLDisplayPlugin::present() {
|
||||||
auto frameId = (uint64_t)presentCount();
|
auto frameId = (uint64_t)presentCount();
|
||||||
PROFILE_RANGE_EX(render, __FUNCTION__, 0xffffff00, frameId)
|
PROFILE_RANGE_EX(render, __FUNCTION__, 0xffffff00, frameId)
|
||||||
uint64_t startPresent = usecTimestampNow();
|
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)
|
PROFILE_RANGE_EX(render, "updateFrameData", 0xff00ff00, frameId)
|
||||||
updateFrameData();
|
updateFrameData();
|
||||||
|
@ -829,6 +841,9 @@ void OpenGLDisplayPlugin::render(std::function<void(gpu::Batch& batch)> f) {
|
||||||
_gpuContext->executeBatch(batch);
|
_gpuContext->executeBatch(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OpenGLDisplayPlugin::OpenGLDisplayPlugin() : DisplayPlugin() {
|
||||||
|
_allProgramsLoaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
OpenGLDisplayPlugin::~OpenGLDisplayPlugin() {
|
OpenGLDisplayPlugin::~OpenGLDisplayPlugin() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ protected:
|
||||||
using Lock = std::unique_lock<Mutex>;
|
using Lock = std::unique_lock<Mutex>;
|
||||||
using Condition = std::condition_variable;
|
using Condition = std::condition_variable;
|
||||||
public:
|
public:
|
||||||
|
OpenGLDisplayPlugin();
|
||||||
~OpenGLDisplayPlugin();
|
~OpenGLDisplayPlugin();
|
||||||
// These must be final to ensure proper ordering of operations
|
// These must be final to ensure proper ordering of operations
|
||||||
// between the main thread and the presentation thread
|
// between the main thread and the presentation thread
|
||||||
|
@ -180,5 +181,7 @@ protected:
|
||||||
// be serialized through this mutex
|
// be serialized through this mutex
|
||||||
mutable Mutex _presentMutex;
|
mutable Mutex _presentMutex;
|
||||||
float _hudAlpha{ 1.0f };
|
float _hudAlpha{ 1.0f };
|
||||||
|
|
||||||
|
size_t _currentLoadingProgramIndex { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ GLShader* GLShader::sync(GLBackend& backend, const Shader& shader, const Shader:
|
||||||
if (object) {
|
if (object) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
PROFILE_RANGE(render, "/GLShader::sync");
|
||||||
// need to have a gpu object?
|
// need to have a gpu object?
|
||||||
if (shader.isProgram()) {
|
if (shader.isProgram()) {
|
||||||
GLShader* tempObject = backend.compileBackendProgram(shader, handler);
|
GLShader* tempObject = backend.compileBackendProgram(shader, handler);
|
||||||
|
|
|
@ -217,6 +217,8 @@ public:
|
||||||
|
|
||||||
static const QString& MENU_PATH();
|
static const QString& MENU_PATH();
|
||||||
|
|
||||||
|
bool areAllProgramsLoaded() { return _allProgramsLoaded; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void recommendedFramebufferSizeChanged(const QSize& size);
|
void recommendedFramebufferSizeChanged(const QSize& size);
|
||||||
void resetSensorsRequested();
|
void resetSensorsRequested();
|
||||||
|
@ -233,6 +235,8 @@ protected:
|
||||||
|
|
||||||
float _renderResolutionScale { 1.0f };
|
float _renderResolutionScale { 1.0f };
|
||||||
|
|
||||||
|
std::atomic<bool> _allProgramsLoaded { true };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex _presentMutex;
|
QMutex _presentMutex;
|
||||||
QWaitCondition _presentCondition;
|
QWaitCondition _presentCondition;
|
||||||
|
|
Loading…
Reference in a new issue