@@ -56,9 +56,11 @@ GLShader_fxaa *gl_fxaaShader = nullptr;
5656GLShader_motionblur *gl_motionblurShader = nullptr ;
5757GLShader_ssao *gl_ssaoShader = nullptr ;
5858
59- GLShader_depthtile1 *gl_depthtile1Shader = nullptr ;
60- GLShader_depthtile2 *gl_depthtile2Shader = nullptr ;
61- GLShader_lighttile *gl_lighttileShader = nullptr ;
59+ GLShader_depthtile1* gl_depthtile1Shader = nullptr ;
60+ GLShader_depthtile2* gl_depthtile2Shader = nullptr ;
61+ GLShader_lighttile* gl_lighttileShader = nullptr ;
62+ GLShader_luminanceReduction* gl_luminanceReductionShader = nullptr ;
63+ GLShader_clearFrameData* gl_clearFrameDataShader = nullptr ;
6264
6365GLShader_generic *gl_genericShader = nullptr ;
6466GLShader_genericMaterial *gl_genericShaderMaterial = nullptr ;
@@ -83,6 +85,7 @@ GLShader_skybox *gl_skyboxShader = nullptr;
8385GLShader_skyboxMaterial *gl_skyboxShaderMaterial = nullptr ;
8486GLShader_debugShadowMap *gl_debugShadowMapShader = nullptr ;
8587GLShaderManager gl_shaderManager;
88+ GLBuffer luminanceBuffer ( " luminance" , Util::ordinal( BufferBind::LUMINANCE ), GL_MAP_WRITE_BIT, GL_MAP_INVALIDATE_RANGE_BIT );
8689
8790namespace // Implementation details
8891{
@@ -432,6 +435,9 @@ static const std::vector<addedExtension_t> fragmentVertexAddedExtensions = {
432435 where the core variables have different names. */
433436 { glConfig2.shaderDrawParametersAvailable , -1 , " ARB_shader_draw_parameters" },
434437 { glConfig2.SSBOAvailable , 430 , " ARB_shader_storage_buffer_object" },
438+ { glConfig2.shadingLanguage420PackAvailable , 420 , " ARB_shading_language_420pack" },
439+ { glConfig2.explicitUniformLocationAvailable , 430 , " ARB_explicit_uniform_location" },
440+ { glConfig2.shaderAtomicCountersAvailable , 420 , " ARB_shader_atomic_counters" },
435441 /* Even though these are part of the GL_KHR_shader_subgroup extension, we need to enable
436442 the individual extensions for each feature.
437443 GL_KHR_shader_subgroup itself can't be used in the shader. */
@@ -579,6 +585,10 @@ static std::string GenVertexHeader() {
579585 AddDefine ( str, " BIND_LIGHTMAP_DATA" , Util::ordinal ( BufferBind::LIGHTMAP_DATA ) );
580586 }
581587
588+ if ( glConfig2.adaptiveExposureAvailable ) {
589+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
590+ }
591+
582592 return str;
583593}
584594
@@ -619,6 +629,10 @@ static std::string GenFragmentHeader() {
619629 AddDefine ( str, " BIND_LIGHTMAP_DATA" , Util::ordinal ( BufferBind::LIGHTMAP_DATA ) );
620630 }
621631
632+ if ( glConfig2.adaptiveExposureAvailable ) {
633+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
634+ }
635+
622636 return str;
623637}
624638
@@ -644,6 +658,11 @@ static std::string GenComputeHeader() {
644658 AddDefine ( str, " BIND_DEBUG" , Util::ordinal ( BufferBind::DEBUG ) );
645659 }
646660
661+ if ( glConfig2.adaptiveExposureAvailable ) {
662+ AddDefine ( str, " BIND_LUMINANCE" , Util::ordinal ( BufferBind::LUMINANCE ) );
663+ AddDefine ( str, " BIND_LUMINANCE_STORAGE" , Util::ordinal ( BufferBind::LUMINANCE_STORAGE ) );
664+ }
665+
647666 if ( glConfig2.usingBindlessTextures ) {
648667 str += " layout(bindless_image) uniform;\n " ;
649668 }
@@ -2805,6 +2824,23 @@ void GLShader_shadowFill::SetShaderProgramUniforms( ShaderProgramDescriptor *sha
28052824 glUniform1i ( glGetUniformLocation ( shaderProgram->id , " u_ColorMap" ), 0 );
28062825}
28072826
2827+ GLShader_luminanceReduction::GLShader_luminanceReduction ( GLShaderManager* manager ) :
2828+ GLShader( " luminanceReduction" ,
2829+ false , " luminanceReduction" ),
2830+ u_ViewWidth( this ),
2831+ u_ViewHeight( this ),
2832+ u_TonemapParms2( this ) {
2833+ }
2834+
2835+ void GLShader_luminanceReduction::SetShaderProgramUniforms ( ShaderProgramDescriptor* shaderProgram ) {
2836+ glUniform1i ( glGetUniformLocation ( shaderProgram->id , " initialRenderImage" ), 0 );
2837+ }
2838+
2839+ GLShader_clearFrameData::GLShader_clearFrameData ( GLShaderManager* manager ) :
2840+ GLShader( " clearFrameData" ,
2841+ false , " clearFrameData" ) {
2842+ }
2843+
28082844GLShader_reflection::GLShader_reflection ():
28092845 GLShader( " reflection" , ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT,
28102846 false , " reflection_CB" , " reflection_CB" ),
@@ -3061,11 +3097,13 @@ GLShader_cameraEffects::GLShader_cameraEffects() :
30613097 u_CurrentMap( this ),
30623098 u_GlobalLightFactor( this ),
30633099 u_ColorModulate( this ),
3100+ u_ViewWidth( this ),
3101+ u_ViewHeight( this ),
30643102 u_Tonemap( this ),
3103+ u_TonemapAdaptiveExposure( this ),
30653104 u_TonemapParms( this ),
30663105 u_TonemapExposure( this ),
3067- u_InverseGamma( this )
3068- {
3106+ u_InverseGamma( this ) {
30693107}
30703108
30713109void GLShader_cameraEffects::SetShaderProgramUniforms ( ShaderProgramDescriptor *shaderProgram )
0 commit comments