Skip to content

Commit

Permalink
[GL3+] sRGB RenderTextures were forced to always on
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Sep 19, 2020
1 parent d2ca463 commit 40dcea7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace Ogre
bool mAllClearColoursSetAndIdentical;
bool mAnyColourLoadActionsSetToClear;
bool mHasRenderWindow;
bool mHasSRGB;

GL3PlusFrameBufferDescMap::iterator mSharedFboItor;

Expand Down
17 changes: 16 additions & 1 deletion RenderSystems/GL3Plus/src/OgreGL3PlusRenderPassDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace Ogre
mAllClearColoursSetAndIdentical( false ),
mAnyColourLoadActionsSetToClear( false ),
mHasRenderWindow( false ),
mHasSRGB( false ),
mSharedFboItor( renderSystem->_getFrameBufferDescMap().end() ),
mRenderSystem( renderSystem )
{
Expand Down Expand Up @@ -207,6 +208,7 @@ namespace Ogre
}

bool needsMsaaResolveFbo = false;
mHasSRGB = false;

//Attach colour entries
for( size_t i=0; i<mNumColourEntries; ++i )
Expand All @@ -218,6 +220,9 @@ namespace Ogre
"GL3PlusRenderPassDescriptor::updateColourFbo" );
}

if( PixelFormatGpuUtils::isSRgb( mColour[i].texture->getPixelFormat() ) )
mHasSRGB |= true;

if( !mHasRenderWindow && mColour[i].texture->getPixelFormat() != PFG_NULL )
{
assert( dynamic_cast<GL3PlusTextureGpu*>( mColour[i].texture ) );
Expand Down Expand Up @@ -487,7 +492,17 @@ namespace Ogre
OCGE( glDrawBuffers( mNumColourEntries, colourBuffs ) );
}

OCGE( glEnable( GL_FRAMEBUFFER_SRGB ) );
if( entriesToFlush & RenderPassDescriptor::Colour )
{
if( mHasSRGB )
{
OCGE( glEnable( GL_FRAMEBUFFER_SRGB ) );
}
else
{
OCGE( glDisable( GL_FRAMEBUFFER_SRGB ) );
}
}

const RenderSystemCapabilities *capabilities = mRenderSystem->getCapabilities();
const bool isTiler = capabilities->hasCapability( RSC_IS_TILER );
Expand Down

0 comments on commit 40dcea7

Please sign in to comment.