11/*
2- * Copyright 2019-2024 Diligent Graphics LLC
2+ * Copyright 2019-2025 Diligent Graphics LLC
33 * Copyright 2015-2019 Egor Yusov
44 *
55 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,10 +44,10 @@ namespace Diligent
4444
4545GLContextState::GLContextState (RenderDeviceGLImpl* pDeviceGL)
4646{
47- const auto & AdapterInfo = pDeviceGL->GetAdapterInfo ();
48- m_Caps.IsFillModeSelectionSupported = AdapterInfo.Features .WireframeFill ;
49- m_Caps.IsProgramPipelineSupported = AdapterInfo.Features .SeparablePrograms ;
50- m_Caps.IsDepthClampSupported = AdapterInfo.Features .DepthClamp ;
47+ const GraphicsAdapterInfo & AdapterInfo = pDeviceGL->GetAdapterInfo ();
48+ m_Caps.IsFillModeSelectionSupported = AdapterInfo.Features .WireframeFill ;
49+ m_Caps.IsProgramPipelineSupported = AdapterInfo.Features .SeparablePrograms ;
50+ m_Caps.IsDepthClampSupported = AdapterInfo.Features .DepthClamp ;
5151
5252 {
5353 m_Caps.MaxCombinedTexUnits = 0 ;
@@ -328,7 +328,7 @@ void GLContextState::GetBoundImage(Uint32 Index,
328328{
329329 if (Index < m_BoundImages.size ())
330330 {
331- const auto & BoundImg = m_BoundImages[Index];
331+ const BoundImageInfo & BoundImg = m_BoundImages[Index];
332332
333333 ImgHandle = BoundImg.GLHandle ;
334334 MipLevel = BoundImg.MipLevel ;
@@ -497,7 +497,7 @@ void GLContextState::SetDepthFunc(COMPARISON_FUNCTION CmpFunc)
497497{
498498 if (m_DSState.m_DepthCmpFunc != CmpFunc)
499499 {
500- auto GlCmpFunc = CompareFuncToGLCompareFunc (CmpFunc);
500+ GLenum GlCmpFunc = CompareFuncToGLCompareFunc (CmpFunc);
501501 glDepthFunc (GlCmpFunc);
502502 DEV_CHECK_GL_ERROR (" Failed to set GL comparison function" );
503503 m_DSState.m_DepthCmpFunc = CmpFunc;
@@ -533,15 +533,15 @@ void GLContextState::SetStencilWriteMask(Uint8 StencilWriteMask)
533533
534534void GLContextState::SetStencilRef (GLenum Face, Int32 Ref)
535535{
536- auto & FaceStencilOp = m_DSState.m_StencilOpState [Face == GL_FRONT ? 0 : 1 ];
537- auto GlStencilFunc = CompareFuncToGLCompareFunc (FaceStencilOp.Func );
536+ DepthStencilGLState::StencilOpState & FaceStencilOp = m_DSState.m_StencilOpState [Face == GL_FRONT ? 0 : 1 ];
537+ GLenum GlStencilFunc = CompareFuncToGLCompareFunc (FaceStencilOp.Func );
538538 glStencilFuncSeparate (Face, GlStencilFunc, Ref, FaceStencilOp.Mask );
539539 DEV_CHECK_GL_ERROR (" Failed to set stencil function" );
540540}
541541
542542void GLContextState::SetStencilFunc (GLenum Face, COMPARISON_FUNCTION Func, Int32 Ref, Uint32 Mask)
543543{
544- auto & FaceStencilOp = m_DSState.m_StencilOpState [Face == GL_FRONT ? 0 : 1 ];
544+ DepthStencilGLState::StencilOpState & FaceStencilOp = m_DSState.m_StencilOpState [Face == GL_FRONT ? 0 : 1 ];
545545 if (FaceStencilOp.Func != Func ||
546546 FaceStencilOp.Ref != Ref ||
547547 FaceStencilOp.Mask != Mask)
@@ -556,14 +556,14 @@ void GLContextState::SetStencilFunc(GLenum Face, COMPARISON_FUNCTION Func, Int32
556556
557557void GLContextState::SetStencilOp (GLenum Face, STENCIL_OP StencilFailOp, STENCIL_OP StencilDepthFailOp, STENCIL_OP StencilPassOp)
558558{
559- auto & FaceStencilOp = m_DSState.m_StencilOpState [Face == GL_FRONT ? 0 : 1 ];
559+ DepthStencilGLState::StencilOpState & FaceStencilOp = m_DSState.m_StencilOpState [Face == GL_FRONT ? 0 : 1 ];
560560 if (FaceStencilOp.StencilFailOp != StencilFailOp ||
561561 FaceStencilOp.StencilDepthFailOp != StencilDepthFailOp ||
562562 FaceStencilOp.StencilPassOp != StencilPassOp)
563563 {
564- auto glsfail = StencilOp2GlStencilOp (StencilFailOp);
565- auto dpfail = StencilOp2GlStencilOp (StencilDepthFailOp);
566- auto dppass = StencilOp2GlStencilOp (StencilPassOp);
564+ GLenum glsfail = StencilOp2GlStencilOp (StencilFailOp);
565+ GLenum dpfail = StencilOp2GlStencilOp (StencilDepthFailOp);
566+ GLenum dppass = StencilOp2GlStencilOp (StencilPassOp);
567567
568568 glStencilOpSeparate (Face, glsfail, dpfail, dppass);
569569 DEV_CHECK_GL_ERROR (" Failed to set stencil operation" );
@@ -582,7 +582,7 @@ void GLContextState::SetFillMode(FILL_MODE FillMode)
582582 {
583583 if (glPolygonMode != nullptr )
584584 {
585- auto PolygonMode = FillMode == FILL_MODE_WIREFRAME ? GL_LINE : GL_FILL;
585+ GLenum PolygonMode = FillMode == FILL_MODE_WIREFRAME ? GL_LINE : GL_FILL;
586586 glPolygonMode (GL_FRONT_AND_BACK, PolygonMode);
587587 DEV_CHECK_GL_ERROR (" Failed to set polygon mode" );
588588 }
@@ -616,7 +616,7 @@ void GLContextState::SetCullMode(CULL_MODE CullMode)
616616 VERIFY (CullMode == CULL_MODE_FRONT || CullMode == CULL_MODE_BACK, " Unexpected cull mode" );
617617 glEnable (GL_CULL_FACE);
618618 DEV_CHECK_GL_ERROR (" Failed to enable face culling" );
619- auto CullFace = CullMode == CULL_MODE_BACK ? GL_BACK : GL_FRONT;
619+ GLenum CullFace = CullMode == CULL_MODE_BACK ? GL_BACK : GL_FRONT;
620620 glCullFace (CullFace);
621621 DEV_CHECK_GL_ERROR (" Failed to set cull face" );
622622 }
@@ -629,7 +629,7 @@ void GLContextState::SetFrontFace(bool FrontCounterClockwise)
629629{
630630 if (m_RSState.FrontCounterClockwise != FrontCounterClockwise)
631631 {
632- auto FrontFace = FrontCounterClockwise ? GL_CCW : GL_CW;
632+ GLenum FrontFace = FrontCounterClockwise ? GL_CCW : GL_CW;
633633 glFrontFace (FrontFace);
634634 DEV_CHECK_GL_ERROR (" Failed to set front face" );
635635 m_RSState.FrontCounterClockwise = FrontCounterClockwise;
@@ -727,7 +727,7 @@ void GLContextState::SetBlendState(const BlendStateDesc& BSDsc, Uint32 SampleMas
727727 {
728728 for (int i = 0 ; i < static_cast <int >(MAX_RENDER_TARGETS); ++i)
729729 {
730- const auto & RT = BSDsc.RenderTargets [i];
730+ const RenderTargetBlendDesc & RT = BSDsc.RenderTargets [i];
731731 if (RT.BlendEnable )
732732 bEnableBlend = true ;
733733
@@ -743,8 +743,8 @@ void GLContextState::SetBlendState(const BlendStateDesc& BSDsc, Uint32 SampleMas
743743 }
744744 else
745745 {
746- const auto & RT0 = BSDsc.RenderTargets [0 ];
747- bEnableBlend = RT0.BlendEnable ;
746+ const RenderTargetBlendDesc & RT0 = BSDsc.RenderTargets [0 ];
747+ bEnableBlend = RT0.BlendEnable ;
748748 SetColorWriteMask (0 , RT0.RenderTargetWriteMask , False);
749749 }
750750
@@ -769,7 +769,7 @@ void GLContextState::SetBlendState(const BlendStateDesc& BSDsc, Uint32 SampleMas
769769 {
770770 for (int i = 0 ; i < static_cast <int >(MAX_RENDER_TARGETS); ++i)
771771 {
772- const auto & RT = BSDsc.RenderTargets [i];
772+ const RenderTargetBlendDesc & RT = BSDsc.RenderTargets [i];
773773
774774 if (i >= m_Caps.MaxDrawBuffers )
775775 {
@@ -783,14 +783,14 @@ void GLContextState::SetBlendState(const BlendStateDesc& BSDsc, Uint32 SampleMas
783783 glEnablei (GL_BLEND, i);
784784 DEV_CHECK_GL_ERROR (" Failed to enable alpha blending" );
785785
786- auto srcFactorRGB = BlendFactor2GLBlend (RT.SrcBlend );
787- auto dstFactorRGB = BlendFactor2GLBlend (RT.DestBlend );
788- auto srcFactorAlpha = BlendFactor2GLBlend (RT.SrcBlendAlpha );
789- auto dstFactorAlpha = BlendFactor2GLBlend (RT.DestBlendAlpha );
786+ GLenum srcFactorRGB = BlendFactor2GLBlend (RT.SrcBlend );
787+ GLenum dstFactorRGB = BlendFactor2GLBlend (RT.DestBlend );
788+ GLenum srcFactorAlpha = BlendFactor2GLBlend (RT.SrcBlendAlpha );
789+ GLenum dstFactorAlpha = BlendFactor2GLBlend (RT.DestBlendAlpha );
790790 glBlendFuncSeparatei (i, srcFactorRGB, dstFactorRGB, srcFactorAlpha, dstFactorAlpha);
791791 DEV_CHECK_GL_ERROR (" Failed to set separate blending factors" );
792- auto modeRGB = BlendOperation2GLBlendOp (RT.BlendOp );
793- auto modeAlpha = BlendOperation2GLBlendOp (RT.BlendOpAlpha );
792+ GLenum modeRGB = BlendOperation2GLBlendOp (RT.BlendOp );
793+ GLenum modeAlpha = BlendOperation2GLBlendOp (RT.BlendOpAlpha );
794794 glBlendEquationSeparatei (i, modeRGB, modeAlpha);
795795 DEV_CHECK_GL_ERROR (" Failed to set separate blending equations" );
796796 }
@@ -803,16 +803,17 @@ void GLContextState::SetBlendState(const BlendStateDesc& BSDsc, Uint32 SampleMas
803803 }
804804 else
805805 {
806- const auto & RT0 = BSDsc.RenderTargets [0 ];
807- auto srcFactorRGB = BlendFactor2GLBlend (RT0.SrcBlend );
808- auto dstFactorRGB = BlendFactor2GLBlend (RT0.DestBlend );
809- auto srcFactorAlpha = BlendFactor2GLBlend (RT0.SrcBlendAlpha );
810- auto dstFactorAlpha = BlendFactor2GLBlend (RT0.DestBlendAlpha );
806+ const RenderTargetBlendDesc& RT0 = BSDsc.RenderTargets [0 ];
807+
808+ GLenum srcFactorRGB = BlendFactor2GLBlend (RT0.SrcBlend );
809+ GLenum dstFactorRGB = BlendFactor2GLBlend (RT0.DestBlend );
810+ GLenum srcFactorAlpha = BlendFactor2GLBlend (RT0.SrcBlendAlpha );
811+ GLenum dstFactorAlpha = BlendFactor2GLBlend (RT0.DestBlendAlpha );
811812 glBlendFuncSeparate (srcFactorRGB, dstFactorRGB, srcFactorAlpha, dstFactorAlpha);
812813 DEV_CHECK_GL_ERROR (" Failed to set blending factors" );
813814
814- auto modeRGB = BlendOperation2GLBlendOp (RT0.BlendOp );
815- auto modeAlpha = BlendOperation2GLBlendOp (RT0.BlendOpAlpha );
815+ GLenum modeRGB = BlendOperation2GLBlendOp (RT0.BlendOp );
816+ GLenum modeAlpha = BlendOperation2GLBlendOp (RT0.BlendOpAlpha );
816817 glBlendEquationSeparate (modeRGB, modeAlpha);
817818 DEV_CHECK_GL_ERROR (" Failed to set blending equations" );
818819 }
0 commit comments