@@ -48,6 +48,7 @@ GLContextState::GLContextState(RenderDeviceGLImpl* pDeviceGL)
4848 m_Caps.IsFillModeSelectionSupported = AdapterInfo.Features .WireframeFill ;
4949 m_Caps.IsProgramPipelineSupported = AdapterInfo.Features .SeparablePrograms ;
5050 m_Caps.IsDepthClampSupported = AdapterInfo.Features .DepthClamp ;
51+ m_Caps.IsFramebufferSRGBSupported = pDeviceGL->GetGLCaps ().FramebufferSRGB ;
5152
5253 {
5354 m_Caps.MaxCombinedTexUnits = 0 ;
@@ -109,13 +110,14 @@ void GLContextState::Invalidate()
109110 m_BoundUniformBuffers.clear ();
110111 m_BoundStorageBlocks.clear ();
111112
112- m_DSState = DepthStencilGLState () ;
113- m_RSState = RasterizerGLState () ;
113+ m_DSState = DepthStencilGLState{} ;
114+ m_RSState = RasterizerGLState{} ;
114115
115116 for (Uint32 rt = 0 ; rt < _countof (m_ColorWriteMasks); ++rt)
116117 m_ColorWriteMasks[rt] = 0xFF ;
117118
118- m_bIndexedWriteMasks = EnableStateHelper ();
119+ m_bIndexedWriteMasks = EnableStateHelper{};
120+ m_bFramebufferSRGB = EnableStateHelper{};
119121
120122 m_iActiveTexture = -1 ;
121123 m_NumPatchVertices = -1 ;
@@ -177,7 +179,7 @@ void GLContextState::BindVAO(const GLVertexArrayObj& VAO)
177179 }
178180}
179181
180- void GLContextState::BindFBO (const GLFrameBufferObj& FBO)
182+ void GLContextState::BindFBO (const GLFrameBufferObj& FBO, bool DoEnableFramebufferSRGB )
181183{
182184 GLuint FBOHandle = 0 ;
183185 if (UpdateBoundObject (m_FBOId, FBO, FBOHandle))
@@ -193,6 +195,8 @@ void GLContextState::BindFBO(const GLFrameBufferObj& FBO)
193195 DEV_CHECK_GL_ERROR (" Failed to bind FBO as draw framebuffer" );
194196 glBindFramebuffer (GL_READ_FRAMEBUFFER, FBOHandle);
195197 DEV_CHECK_GL_ERROR (" Failed to bind FBO as read framebuffer" );
198+
199+ EnableFramebufferSRGB (DoEnableFramebufferSRGB);
196200 }
197201}
198202
@@ -906,6 +910,27 @@ void GLContextState::GetColorWriteMask(Uint32 RTIndex, Uint32& WriteMask, Bool&
906910 bIsIndexed = m_bIndexedWriteMasks;
907911}
908912
913+ void GLContextState::EnableFramebufferSRGB (Bool bEnable)
914+ {
915+ if (!m_Caps.IsFramebufferSRGBSupported )
916+ return ;
917+
918+ if (m_bFramebufferSRGB != bEnable)
919+ {
920+ if (bEnable)
921+ {
922+ glEnable (GL_FRAMEBUFFER_SRGB);
923+ DEV_CHECK_GL_ERROR (" Failed to enable framebuffer sRGB" );
924+ }
925+ else
926+ {
927+ glDisable (GL_FRAMEBUFFER_SRGB);
928+ DEV_CHECK_GL_ERROR (" Failed to disable framebuffer sRGB" );
929+ }
930+ m_bFramebufferSRGB = bEnable;
931+ }
932+ }
933+
909934void GLContextState::SetNumPatchVertices (Int32 NumVertices)
910935{
911936#if GL_ARB_tessellation_shader
0 commit comments