mirror of
https://github.com/overte-org/overte.git
synced 2025-07-08 13:40:20 +02:00
restructured gamma correction so snapshots look correct
This commit is contained in:
parent
a66bd04810
commit
250d18d7df
6 changed files with 129 additions and 128 deletions
|
@ -109,11 +109,25 @@ bool Basic2DWindowOpenGLDisplayPlugin::internalActivate() {
|
||||||
return Parent::internalActivate();
|
return Parent::internalActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpu::PipelinePointer Basic2DWindowOpenGLDisplayPlugin::getRenderTexturePipeline() {
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
return _linearToSRGBPipeline;
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifndef USE_GLES
|
||||||
|
return _SRGBToLinearPipeline;
|
||||||
|
#else
|
||||||
|
return _drawTexturePipeline;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer Basic2DWindowOpenGLDisplayPlugin::getCompositeScenePipeline() {
|
gpu::PipelinePointer Basic2DWindowOpenGLDisplayPlugin::getCompositeScenePipeline() {
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
return _linearToSRGBPipeline;
|
return _linearToSRGBPipeline;
|
||||||
#else
|
#else
|
||||||
return _SRGBToLinearPipeline;
|
return _drawTexturePipeline;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
|
|
||||||
virtual void pluginUpdate() override {};
|
virtual void pluginUpdate() override {};
|
||||||
|
|
||||||
|
virtual gpu::PipelinePointer getRenderTexturePipeline() override;
|
||||||
virtual gpu::PipelinePointer getCompositeScenePipeline() override;
|
virtual gpu::PipelinePointer getCompositeScenePipeline() override;
|
||||||
virtual gpu::Element getCompositeFBColorSpace() override;
|
virtual gpu::Element getCompositeFBColorSpace() override;
|
||||||
|
|
||||||
|
|
|
@ -59,19 +59,14 @@ class PresentThread : public QThread, public Dependency {
|
||||||
using Lock = std::unique_lock<Mutex>;
|
using Lock = std::unique_lock<Mutex>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PresentThread() {
|
PresentThread() {
|
||||||
connect(qApp, &QCoreApplication::aboutToQuit, [this] {
|
connect(qApp, &QCoreApplication::aboutToQuit, [this] { shutdown(); });
|
||||||
shutdown();
|
|
||||||
});
|
|
||||||
setObjectName("Present");
|
setObjectName("Present");
|
||||||
|
|
||||||
_refreshRateController = std::make_shared<RefreshRateController>();
|
_refreshRateController = std::make_shared<RefreshRateController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
~PresentThread() {
|
~PresentThread() { shutdown(); }
|
||||||
shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto getRefreshRateController() { return _refreshRateController; }
|
auto getRefreshRateController() { return _refreshRateController; }
|
||||||
|
|
||||||
|
@ -87,7 +82,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void setNewDisplayPlugin(OpenGLDisplayPlugin* plugin) {
|
void setNewDisplayPlugin(OpenGLDisplayPlugin* plugin) {
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
|
@ -104,7 +98,6 @@ public:
|
||||||
_context->moveToThread(this);
|
_context->moveToThread(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void run() override {
|
virtual void run() override {
|
||||||
PROFILE_SET_THREAD_NAME("Present Thread");
|
PROFILE_SET_THREAD_NAME("Present Thread");
|
||||||
|
|
||||||
|
@ -120,8 +113,7 @@ public:
|
||||||
CHECK_GL_ERROR();
|
CHECK_GL_ERROR();
|
||||||
while (!_shutdown) {
|
while (!_shutdown) {
|
||||||
if (_pendingOtherThreadOperation) {
|
if (_pendingOtherThreadOperation) {
|
||||||
PROFILE_RANGE(render, "MainThreadOp")
|
PROFILE_RANGE(render, "MainThreadOp") {
|
||||||
{
|
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
_context->doneCurrent();
|
_context->doneCurrent();
|
||||||
// Move the context to the main thread
|
// Move the context to the main thread
|
||||||
|
@ -131,7 +123,6 @@ public:
|
||||||
_condition.notify_one();
|
_condition.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Main thread does it's thing while we wait on the lock to release
|
// Main thread does it's thing while we wait on the lock to release
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
|
@ -235,7 +226,6 @@ public:
|
||||||
_condition.notify_one();
|
_condition.notify_one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void makeCurrent();
|
void makeCurrent();
|
||||||
void doneCurrent();
|
void doneCurrent();
|
||||||
|
@ -245,7 +235,6 @@ private:
|
||||||
// Used to allow the main thread to perform context operations
|
// Used to allow the main thread to perform context operations
|
||||||
Condition _condition;
|
Condition _condition;
|
||||||
|
|
||||||
|
|
||||||
QThread* _targetOperationThread{ nullptr };
|
QThread* _targetOperationThread{ nullptr };
|
||||||
bool _pendingOtherThreadOperation{ false };
|
bool _pendingOtherThreadOperation{ false };
|
||||||
bool _finishedOtherThreadOperation{ false };
|
bool _finishedOtherThreadOperation{ false };
|
||||||
|
@ -302,7 +291,6 @@ bool OpenGLDisplayPlugin::activate() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This should not return until the new context has been customized
|
// This should not return until the new context has been customized
|
||||||
// and the old context (if any) has been uncustomized
|
// and the old context (if any) has been uncustomized
|
||||||
presentThread->setNewDisplayPlugin(this);
|
presentThread->setNewDisplayPlugin(this);
|
||||||
|
@ -368,11 +356,8 @@ void OpenGLDisplayPlugin::customizeContext() {
|
||||||
image = image.convertToFormat(QImage::Format_ARGB32);
|
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||||
}
|
}
|
||||||
if ((image.width() > 0) && (image.height() > 0)) {
|
if ((image.width() > 0) && (image.height() > 0)) {
|
||||||
|
cursorData.texture = gpu::Texture::createStrict(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA), image.width(),
|
||||||
cursorData.texture = gpu::Texture::createStrict(
|
image.height(), gpu::Texture::MAX_NUM_MIPS,
|
||||||
gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA),
|
|
||||||
image.width(), image.height(),
|
|
||||||
gpu::Texture::MAX_NUM_MIPS,
|
|
||||||
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR));
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR));
|
||||||
cursorData.texture->setSource("cursor texture");
|
cursorData.texture->setSource("cursor texture");
|
||||||
auto usage = gpu::Texture::Usage::Builder().withColor().withAlpha();
|
auto usage = gpu::Texture::Usage::Builder().withColor().withAlpha();
|
||||||
|
@ -384,14 +369,11 @@ void OpenGLDisplayPlugin::customizeContext() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_drawTexturePipeline) {
|
if (!_linearToSRGBPipeline) {
|
||||||
gpu::StatePointer blendState = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer blendState = gpu::StatePointer(new gpu::State());
|
||||||
blendState->setDepthTest(gpu::State::DepthTest(false));
|
blendState->setDepthTest(gpu::State::DepthTest(false));
|
||||||
blendState->setBlendFunction(true,
|
blendState->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD,
|
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||||
gpu::State::INV_SRC_ALPHA,
|
|
||||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD,
|
|
||||||
gpu::State::ONE);
|
|
||||||
|
|
||||||
gpu::StatePointer scissorState = gpu::StatePointer(new gpu::State());
|
gpu::StatePointer scissorState = gpu::StatePointer(new gpu::State());
|
||||||
scissorState->setDepthTest(gpu::State::DepthTest(false));
|
scissorState->setDepthTest(gpu::State::DepthTest(false));
|
||||||
|
@ -409,20 +391,17 @@ void OpenGLDisplayPlugin::customizeContext() {
|
||||||
|
|
||||||
_cursorPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTransformedTexture), blendState);
|
_cursorPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(DrawTransformedTexture), blendState);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCompositeFramebuffer();
|
updateCompositeFramebuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::uncustomizeContext() {
|
void OpenGLDisplayPlugin::uncustomizeContext() {
|
||||||
|
|
||||||
_drawTexturePipeline.reset();
|
_drawTexturePipeline.reset();
|
||||||
_linearToSRGBPipeline.reset();
|
_linearToSRGBPipeline.reset();
|
||||||
_SRGBToLinearPipeline.reset();
|
_SRGBToLinearPipeline.reset();
|
||||||
|
_cursorPipeline.reset();
|
||||||
_hudPipeline.reset();
|
_hudPipeline.reset();
|
||||||
_mirrorHUDPipeline.reset();
|
_mirrorHUDPipeline.reset();
|
||||||
_cursorPipeline.reset();
|
|
||||||
_compositeFramebuffer.reset();
|
_compositeFramebuffer.reset();
|
||||||
|
|
||||||
withPresentThreadLock([&] {
|
withPresentThreadLock([&] {
|
||||||
_currentFrame.reset();
|
_currentFrame.reset();
|
||||||
_lastFrame = nullptr;
|
_lastFrame = nullptr;
|
||||||
|
@ -433,7 +412,6 @@ void OpenGLDisplayPlugin::uncustomizeContext() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Pressing Alt (and Meta) key alone activates the menubar because its style inherits the
|
// Pressing Alt (and Meta) key alone activates the menubar because its style inherits the
|
||||||
// SHMenuBarAltKeyNavigation from QWindowsStyle. This makes it impossible for a scripts to
|
// SHMenuBarAltKeyNavigation from QWindowsStyle. This makes it impossible for a scripts to
|
||||||
// receive keyPress events for the Alt (and Meta) key in a reliable manner.
|
// receive keyPress events for the Alt (and Meta) key in a reliable manner.
|
||||||
|
@ -477,9 +455,7 @@ bool OpenGLDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::submitFrame(const gpu::FramePointer& newFrame) {
|
void OpenGLDisplayPlugin::submitFrame(const gpu::FramePointer& newFrame) {
|
||||||
withNonPresentThreadLock([&] {
|
withNonPresentThreadLock([&] { _newFrameQueue.push(newFrame); });
|
||||||
_newFrameQueue.push(newFrame);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::captureFrame(const std::string& filename) const {
|
void OpenGLDisplayPlugin::captureFrame(const std::string& filename) const {
|
||||||
|
@ -514,11 +490,18 @@ void OpenGLDisplayPlugin::captureFrame(const std::string& filename) const {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer& texture, const glm::ivec4& viewport, const glm::ivec4& scissor) {
|
void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch,
|
||||||
|
const gpu::TexturePointer& texture,
|
||||||
|
const glm::ivec4& viewport,
|
||||||
|
const glm::ivec4& scissor) {
|
||||||
renderFromTexture(batch, texture, viewport, scissor, nullptr);
|
renderFromTexture(batch, texture, viewport, scissor, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer& texture, const glm::ivec4& viewport, const glm::ivec4& scissor, const gpu::FramebufferPointer& copyFbo /*=gpu::FramebufferPointer()*/) {
|
void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch,
|
||||||
|
const gpu::TexturePointer& texture,
|
||||||
|
const glm::ivec4& viewport,
|
||||||
|
const glm::ivec4& scissor,
|
||||||
|
const gpu::FramebufferPointer& copyFbo /*=gpu::FramebufferPointer()*/) {
|
||||||
auto fbo = gpu::FramebufferPointer();
|
auto fbo = gpu::FramebufferPointer();
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.resetViewTransform();
|
batch.resetViewTransform();
|
||||||
|
@ -528,7 +511,7 @@ void OpenGLDisplayPlugin::renderFromTexture(gpu::Batch& batch, const gpu::Textur
|
||||||
batch.setViewportTransform(viewport);
|
batch.setViewportTransform(viewport);
|
||||||
batch.setResourceTexture(0, texture);
|
batch.setResourceTexture(0, texture);
|
||||||
|
|
||||||
batch.setPipeline(_drawTexturePipeline);
|
batch.setPipeline(getRenderTexturePipeline());
|
||||||
|
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
if (copyFbo) {
|
if (copyFbo) {
|
||||||
|
@ -589,14 +572,11 @@ std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> OpenGL
|
||||||
auto hudStereo = isStereo();
|
auto hudStereo = isStereo();
|
||||||
auto hudCompositeFramebufferSize = _compositeFramebuffer->getSize();
|
auto hudCompositeFramebufferSize = _compositeFramebuffer->getSize();
|
||||||
std::array<glm::ivec4, 2> hudEyeViewports;
|
std::array<glm::ivec4, 2> hudEyeViewports;
|
||||||
for_each_eye([&](Eye eye) {
|
for_each_eye([&](Eye eye) { hudEyeViewports[eye] = eyeViewport(eye); });
|
||||||
hudEyeViewports[eye] = eyeViewport(eye);
|
|
||||||
});
|
|
||||||
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture, bool mirror) {
|
return [=](gpu::Batch& batch, const gpu::TexturePointer& hudTexture, bool mirror) {
|
||||||
auto pipeline = mirror ? hudMirrorPipeline : hudPipeline;
|
if (hudPipeline && hudTexture) {
|
||||||
if (pipeline && hudTexture) {
|
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
batch.setPipeline(pipeline);
|
batch.setPipeline(mirror ? hudMirrorPipeline : hudPipeline);
|
||||||
batch.setResourceTexture(0, hudTexture);
|
batch.setResourceTexture(0, hudTexture);
|
||||||
if (hudStereo) {
|
if (hudStereo) {
|
||||||
for_each_eye([&](Eye eye) {
|
for_each_eye([&](Eye eye) {
|
||||||
|
@ -635,11 +615,6 @@ void OpenGLDisplayPlugin::compositePointer() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overridden by Basic2DWindowDisplayPlugin and OculusDisplayPlugin
|
|
||||||
gpu::PipelinePointer OpenGLDisplayPlugin::getCompositeScenePipeline() {
|
|
||||||
return _drawTexturePipeline;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::compositeScene() {
|
void OpenGLDisplayPlugin::compositeScene() {
|
||||||
render([&](gpu::Batch& batch) {
|
render([&](gpu::Batch& batch) {
|
||||||
batch.enableStereo(false);
|
batch.enableStereo(false);
|
||||||
|
@ -683,7 +658,8 @@ void OpenGLDisplayPlugin::internalPresent() {
|
||||||
// Note: _displayTexture must currently be the same size as the display.
|
// Note: _displayTexture must currently be the same size as the display.
|
||||||
uvec2 dims = _displayTexture ? uvec2(_displayTexture->getDimensions()) : getSurfacePixels();
|
uvec2 dims = _displayTexture ? uvec2(_displayTexture->getDimensions()) : getSurfacePixels();
|
||||||
auto viewport = ivec4(uvec2(0), dims);
|
auto viewport = ivec4(uvec2(0), dims);
|
||||||
renderFromTexture(batch, _displayTexture ? _displayTexture : _compositeFramebuffer->getRenderBuffer(0), viewport, viewport);
|
renderFromTexture(batch, _displayTexture ? _displayTexture : _compositeFramebuffer->getRenderBuffer(0), viewport,
|
||||||
|
viewport);
|
||||||
});
|
});
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
_presentRate.increment();
|
_presentRate.increment();
|
||||||
|
@ -781,7 +757,6 @@ float OpenGLDisplayPlugin::renderRate() const {
|
||||||
return _renderRate.rate();
|
return _renderRate.rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::swapBuffers() {
|
void OpenGLDisplayPlugin::swapBuffers() {
|
||||||
static auto context = _container->getPrimaryWidget()->context();
|
static auto context = _container->getPrimaryWidget()->context();
|
||||||
context->swapBuffers();
|
context->swapBuffers();
|
||||||
|
@ -869,9 +844,7 @@ void OpenGLDisplayPlugin::assertIsPresentThread() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenGLDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
bool OpenGLDisplayPlugin::beginFrameRender(uint32_t frameIndex) {
|
||||||
withNonPresentThreadLock([&] {
|
withNonPresentThreadLock([&] { _compositeHUDAlpha = _hudAlpha; });
|
||||||
_compositeHUDAlpha = _hudAlpha;
|
|
||||||
});
|
|
||||||
return Parent::beginFrameRender(frameIndex);
|
return Parent::beginFrameRender(frameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -909,21 +882,19 @@ void OpenGLDisplayPlugin::render(std::function<void(gpu::Batch& batch)> f) {
|
||||||
OpenGLDisplayPlugin::~OpenGLDisplayPlugin() {
|
OpenGLDisplayPlugin::~OpenGLDisplayPlugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Added this to allow desktop composite framebuffer to be RGBA while mobile is SRGBA
|
|
||||||
// Overridden by Basic2DWindowDisplayPlugin
|
|
||||||
// FIXME: Eventually it would be ideal to have both framebuffers be of the same type
|
|
||||||
gpu::Element OpenGLDisplayPlugin::getCompositeFBColorSpace() {
|
|
||||||
return gpu::Element::COLOR_RGBA_32;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
|
void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
|
||||||
auto renderSize = glm::uvec2(getRecommendedRenderSize());
|
auto renderSize = glm::uvec2(getRecommendedRenderSize());
|
||||||
if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) {
|
if (!_compositeFramebuffer || _compositeFramebuffer->getSize() != renderSize) {
|
||||||
_compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", getCompositeFBColorSpace(), renderSize.x, renderSize.y));
|
_compositeFramebuffer =
|
||||||
|
gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", gpu::Element::COLOR_RGBA_32,
|
||||||
|
renderSize.x, renderSize.y));
|
||||||
|
// _compositeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("OpenGLDisplayPlugin::composite", gpu::Element::COLOR_SRGBA_32, renderSize.x, renderSize.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer networkTexture, QOpenGLFramebufferObject* target, GLsync* fenceSync) {
|
void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer networkTexture,
|
||||||
|
QOpenGLFramebufferObject* target,
|
||||||
|
GLsync* fenceSync) {
|
||||||
#if !defined(USE_GLES)
|
#if !defined(USE_GLES)
|
||||||
auto glBackend = const_cast<OpenGLDisplayPlugin&>(*this).getGLBackend();
|
auto glBackend = const_cast<OpenGLDisplayPlugin&>(*this).getGLBackend();
|
||||||
withOtherThreadContext([&] {
|
withOtherThreadContext([&] {
|
||||||
|
@ -950,7 +921,6 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
||||||
// maintain aspect ratio, filling the width first if possible. If that makes the height too
|
// maintain aspect ratio, filling the width first if possible. If that makes the height too
|
||||||
// much, fill height instead. TODO: only do this when texture changes
|
// much, fill height instead. TODO: only do this when texture changes
|
||||||
GLint newX = 0;
|
GLint newX = 0;
|
||||||
|
@ -966,7 +936,8 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
|
||||||
newY = (target->height() - newHeight) / 2;
|
newY = (target->height() - newHeight) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBlitNamedFramebuffer(fbo[0], fbo[1], 0, 0, texWidth, texHeight, newX, newY, newX + newWidth, newY + newHeight, GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
glBlitNamedFramebuffer(fbo[0], fbo[1], 0, 0, texWidth, texHeight, newX, newY, newX + newWidth, newY + newHeight,
|
||||||
|
GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
|
||||||
// don't delete the textures!
|
// don't delete the textures!
|
||||||
glDeleteFramebuffers(2, fbo);
|
glDeleteFramebuffers(2, fbo);
|
||||||
|
@ -975,3 +946,14 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpu::PipelinePointer OpenGLDisplayPlugin::getRenderTexturePipeline() {
|
||||||
|
return _drawTexturePipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpu::PipelinePointer OpenGLDisplayPlugin::getCompositeScenePipeline() {
|
||||||
|
return _drawTexturePipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpu::Element OpenGLDisplayPlugin::getCompositeFBColorSpace() {
|
||||||
|
return gpu::Element::COLOR_RGBA_32;
|
||||||
|
}
|
||||||
|
|
|
@ -23,11 +23,9 @@
|
||||||
|
|
||||||
#include <gpu/Batch.h>
|
#include <gpu/Batch.h>
|
||||||
|
|
||||||
namespace gpu {
|
namespace gpu { namespace gl {
|
||||||
namespace gl {
|
|
||||||
class GLBackend;
|
class GLBackend;
|
||||||
}
|
}} // namespace gpu::gl
|
||||||
}
|
|
||||||
|
|
||||||
class RefreshRateController;
|
class RefreshRateController;
|
||||||
|
|
||||||
|
@ -35,10 +33,12 @@ class OpenGLDisplayPlugin : public DisplayPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(float hudAlpha MEMBER _hudAlpha)
|
Q_PROPERTY(float hudAlpha MEMBER _hudAlpha)
|
||||||
using Parent = DisplayPlugin;
|
using Parent = DisplayPlugin;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using Mutex = std::mutex;
|
using Mutex = std::mutex;
|
||||||
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();
|
||||||
// These must be final to ensure proper ordering of operations
|
// These must be final to ensure proper ordering of operations
|
||||||
|
@ -55,13 +55,9 @@ public:
|
||||||
void captureFrame(const std::string& outputName) const override;
|
void captureFrame(const std::string& outputName) const override;
|
||||||
void submitFrame(const gpu::FramePointer& newFrame) override;
|
void submitFrame(const gpu::FramePointer& newFrame) override;
|
||||||
|
|
||||||
glm::uvec2 getRecommendedRenderSize() const override {
|
glm::uvec2 getRecommendedRenderSize() const override { return getSurfacePixels(); }
|
||||||
return getSurfacePixels();
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::uvec2 getRecommendedUiSize() const override {
|
glm::uvec2 getRecommendedUiSize() const override { return getSurfaceSize(); }
|
||||||
return getSurfaceSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool setDisplayTexture(const QString& name) override;
|
virtual bool setDisplayTexture(const QString& name) override;
|
||||||
virtual bool onDisplayTextureReset() { return false; };
|
virtual bool onDisplayTextureReset() { return false; };
|
||||||
|
@ -84,9 +80,9 @@ public:
|
||||||
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
|
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
|
||||||
int getRequiredThreadCount() const override { return 3; }
|
int getRequiredThreadCount() const override { return 3; }
|
||||||
|
|
||||||
void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target, GLsync* fenceSync) override;
|
void copyTextureToQuickFramebuffer(NetworkTexturePointer source,
|
||||||
|
QOpenGLFramebufferObject* target,
|
||||||
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator() override;
|
GLsync* fenceSync) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class PresentThread;
|
friend class PresentThread;
|
||||||
|
@ -104,12 +100,10 @@ protected:
|
||||||
virtual QThread::Priority getPresentPriority() { return QThread::HighPriority; }
|
virtual QThread::Priority getPresentPriority() { return QThread::HighPriority; }
|
||||||
virtual void compositeLayers();
|
virtual void compositeLayers();
|
||||||
virtual void compositeScene();
|
virtual void compositeScene();
|
||||||
|
virtual std::function<void(gpu::Batch&, const gpu::TexturePointer&, bool mirror)> getHUDOperator();
|
||||||
virtual void compositePointer();
|
virtual void compositePointer();
|
||||||
virtual void compositeExtra(){};
|
virtual void compositeExtra(){};
|
||||||
|
|
||||||
virtual gpu::PipelinePointer getCompositeScenePipeline();
|
|
||||||
virtual gpu::Element getCompositeFBColorSpace();
|
|
||||||
|
|
||||||
// These functions must only be called on the presentation thread
|
// These functions must only be called on the presentation thread
|
||||||
virtual void customizeContext();
|
virtual void customizeContext();
|
||||||
virtual void uncustomizeContext();
|
virtual void uncustomizeContext();
|
||||||
|
@ -125,8 +119,15 @@ protected:
|
||||||
// Plugin specific functionality to send the composed scene to the output window or device
|
// Plugin specific functionality to send the composed scene to the output window or device
|
||||||
virtual void internalPresent();
|
virtual void internalPresent();
|
||||||
|
|
||||||
void renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer& texture, const glm::ivec4& viewport, const glm::ivec4& scissor, const gpu::FramebufferPointer& fbo);
|
void renderFromTexture(gpu::Batch& batch,
|
||||||
void renderFromTexture(gpu::Batch& batch, const gpu::TexturePointer& texture, const glm::ivec4& viewport, const glm::ivec4& scissor);
|
const gpu::TexturePointer& texture,
|
||||||
|
const glm::ivec4& viewport,
|
||||||
|
const glm::ivec4& scissor,
|
||||||
|
const gpu::FramebufferPointer& fbo);
|
||||||
|
void renderFromTexture(gpu::Batch& batch,
|
||||||
|
const gpu::TexturePointer& texture,
|
||||||
|
const glm::ivec4& viewport,
|
||||||
|
const glm::ivec4& scissor);
|
||||||
virtual void updateFrameData();
|
virtual void updateFrameData();
|
||||||
virtual glm::mat4 getViewCorrection() { return glm::mat4(); }
|
virtual glm::mat4 getViewCorrection() { return glm::mat4(); }
|
||||||
|
|
||||||
|
@ -157,10 +158,13 @@ protected:
|
||||||
gpu::PipelinePointer _linearToSRGBPipeline;
|
gpu::PipelinePointer _linearToSRGBPipeline;
|
||||||
gpu::PipelinePointer _SRGBToLinearPipeline;
|
gpu::PipelinePointer _SRGBToLinearPipeline;
|
||||||
gpu::PipelinePointer _cursorPipeline;
|
gpu::PipelinePointer _cursorPipeline;
|
||||||
|
|
||||||
gpu::TexturePointer _displayTexture{};
|
gpu::TexturePointer _displayTexture{};
|
||||||
float _compositeHUDAlpha{ 1.0f };
|
float _compositeHUDAlpha{ 1.0f };
|
||||||
|
|
||||||
|
virtual gpu::PipelinePointer getRenderTexturePipeline();
|
||||||
|
virtual gpu::PipelinePointer getCompositeScenePipeline();
|
||||||
|
virtual gpu::Element getCompositeFBColorSpace();
|
||||||
|
|
||||||
struct CursorData {
|
struct CursorData {
|
||||||
QImage image;
|
QImage image;
|
||||||
vec2 hotSpot;
|
vec2 hotSpot;
|
||||||
|
@ -198,4 +202,3 @@ protected:
|
||||||
QImage getScreenshot(float aspectRatio);
|
QImage getScreenshot(float aspectRatio);
|
||||||
QImage getSecondaryCameraScreenshot();
|
QImage getSecondaryCameraScreenshot();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ void OculusDisplayPlugin::hmdPresent() {
|
||||||
batch.setStateScissorRect(ivec4(uvec2(), _outputFramebuffer->getSize()));
|
batch.setStateScissorRect(ivec4(uvec2(), _outputFramebuffer->getSize()));
|
||||||
batch.resetViewTransform();
|
batch.resetViewTransform();
|
||||||
batch.setProjectionTransform(mat4());
|
batch.setProjectionTransform(mat4());
|
||||||
|
//batch.setPipeline(_drawTexturePipeline);
|
||||||
batch.setPipeline(_drawTexturePipeline);
|
batch.setPipeline(_drawTexturePipeline);
|
||||||
batch.setResourceTexture(0, _compositeFramebuffer->getRenderBuffer(0));
|
batch.setResourceTexture(0, _compositeFramebuffer->getRenderBuffer(0));
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
|
|
@ -24,6 +24,8 @@ public:
|
||||||
|
|
||||||
virtual QJsonObject getHardwareStats() const;
|
virtual QJsonObject getHardwareStats() const;
|
||||||
|
|
||||||
|
virtual gpu::PipelinePointer getCompositeScenePipeline() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QThread::Priority getPresentPriority() override { return QThread::TimeCriticalPriority; }
|
QThread::Priority getPresentPriority() override { return QThread::TimeCriticalPriority; }
|
||||||
|
|
||||||
|
@ -34,8 +36,6 @@ protected:
|
||||||
void uncustomizeContext() override;
|
void uncustomizeContext() override;
|
||||||
void cycleDebugOutput() override;
|
void cycleDebugOutput() override;
|
||||||
|
|
||||||
virtual gpu::PipelinePointer getCompositeScenePipeline() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char* NAME;
|
static const char* NAME;
|
||||||
ovrTextureSwapChain _textureSwapChain;
|
ovrTextureSwapChain _textureSwapChain;
|
||||||
|
|
Loading…
Reference in a new issue