Skip to content

Commit

Permalink
Merge pull request overte-org#1105 from HifiExperiments/colorspace
Browse files Browse the repository at this point in the history
add a setting to workaround the GLES colorspace conversion issue
  • Loading branch information
daleglass authored Aug 17, 2024
2 parents 228d451 + f987bbc commit fb81ad6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
8 changes: 8 additions & 0 deletions interface/src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "avatar/AvatarManager.h"
#include "avatar/AvatarPackager.h"
#include "AvatarBookmarks.h"
#include <display-plugins/OpenGLDisplayPlugin.h>
#include "DomainAccountManager.h"
#include "MainWindow.h"
#include "render/DrawStatus.h"
Expand Down Expand Up @@ -549,6 +550,13 @@ Menu::Menu() {
drawStatusConfig, SLOT(setShowFade(bool)));
}

{
action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ExtraLinearTosRGBConversion, 0, OpenGLDisplayPlugin::getExtraLinearToSRGBConversion());
connect(action, &QAction::triggered, [action] {
OpenGLDisplayPlugin::setExtraLinearToSRGBConversion(action->isChecked());
});
}

// Developer > Assets >>>
// Menu item is not currently needed but code should be kept in case it proves useful again at some stage.
//#define WANT_ASSET_MIGRATION
Expand Down
3 changes: 2 additions & 1 deletion interface/src/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ namespace MenuOption {
const QString ComputeBlendshapes = "Compute Blendshapes";
const QString HighlightTransitions = "Highlight Transitions";
const QString MaterialProceduralShaders = "Enable Procedural Materials";
}
const QString ExtraLinearTosRGBConversion = "Extra Linear to sRGB Conversion";
}

#endif // hifi_Menu_h

Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ bool Basic2DWindowOpenGLDisplayPlugin::internalActivate() {
return Parent::internalActivate();
}

gpu::PipelinePointer Basic2DWindowOpenGLDisplayPlugin::getRenderTexturePipeline() {
#if defined(Q_OS_ANDROID)
return _linearToSRGBPipeline;
#else
return _drawTexturePipeline;
#endif
}

void Basic2DWindowOpenGLDisplayPlugin::compositeExtra() {
#if defined(Q_OS_ANDROID)
auto& virtualPadManager = VirtualPad::Manager::instance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class Basic2DWindowOpenGLDisplayPlugin : public OpenGLDisplayPlugin {

virtual void pluginUpdate() override {};

virtual gpu::PipelinePointer getRenderTexturePipeline() override;

protected:
mutable bool _isThrottled = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <gl/GLEscrow.h>
#include <gl/Context.h>
#include <gl/OffscreenGLCanvas.h>
#include <gl/GLHelpers.h>

#include <gpu/Texture.h>
#include <gpu/FrameIO.h>
Expand All @@ -57,6 +58,8 @@ using namespace shader::gpu::program;

extern QThread* RENDER_THREAD;

Setting::Handle<bool> OpenGLDisplayPlugin::_extraLinearToSRGBConversionSetting("extraLinearToSRGBConversion", false);

class PresentThread : public QThread, public Dependency {
using Mutex = std::mutex;
using Condition = std::condition_variable;
Expand Down Expand Up @@ -956,5 +959,16 @@ void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer ne
}

gpu::PipelinePointer OpenGLDisplayPlugin::getRenderTexturePipeline() {
return _drawTexturePipeline;
#ifdef USE_GLES
if (!_extraLinearToSRGBConversionSetting.isSet()) {
const gl::ContextInfo &contextInfo = gl::ContextInfo::get();
_extraLinearToSRGBConversionSetting.set(std::find(contextInfo.extensions.cbegin(), contextInfo.extensions.cend(), "GL_EXT_framebuffer_sRGB") == contextInfo.extensions.cend());
}
#endif

if (getExtraLinearToSRGBConversion()) {
return _linearToSRGBPipeline;
} else {
return _drawTexturePipeline;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <QtGui/QImage>

#include <GLMHelpers.h>
#include <SettingHandle.h>
#include <SimpleMovingAverage.h>
#include <shared/RateCounter.h>

Expand Down Expand Up @@ -86,6 +87,9 @@ class OpenGLDisplayPlugin : public DisplayPlugin {
QOpenGLFramebufferObject* target,
GLsync* fenceSync) override;

static void setExtraLinearToSRGBConversion(bool value) { _extraLinearToSRGBConversionSetting.set(value); }
static bool getExtraLinearToSRGBConversion() { return _extraLinearToSRGBConversionSetting.get(); };

protected:
friend class PresentThread;

Expand Down Expand Up @@ -201,4 +205,7 @@ class OpenGLDisplayPlugin : public DisplayPlugin {

QImage getScreenshot(float aspectRatio);
QImage getSecondaryCameraScreenshot();

private:
static Setting::Handle<bool> _extraLinearToSRGBConversionSetting;
};

0 comments on commit fb81ad6

Please sign in to comment.