@@ -30,192 +30,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3030/*
3131=================================================================================
3232THIS ENTIRE FILE IS BACK END!
33- ^ Not true, EnableAvailableFeatures() right below this isn't .
33+ ^ Not true, The next 5 functions below are frontend .
3434
3535This file deals with applying shaders to surface data in the tess struct.
3636=================================================================================
3737*/
3838
39- static void EnableAvailableFeatures ()
40- {
41- glConfig.realtimeLighting = r_realtimeLighting.Get ();
42-
43- if ( glConfig.realtimeLighting )
44- {
45- if ( !glConfig.uniformBufferObjectAvailable ) {
46- Log::Warn ( " Tiled dynamic light renderer disabled because GL_ARB_uniform_buffer_object is not available." );
47- glConfig.realtimeLighting = false ;
48- }
49-
50- if ( !glConfig.textureIntegerAvailable ) {
51- Log::Warn ( " Tiled dynamic light renderer disabled because GL_EXT_texture_integer is not available." );
52- glConfig.realtimeLighting = false ;
53- }
54-
55- if ( !glConfig.textureFloatAvailable )
56- {
57- Log::Warn ( " Tiled dynamic light renderer disabled because GL_ARB_texture_float is not available." );
58- glConfig.realtimeLighting = false ;
59- }
60-
61- if ( glConfig.max3DTextureSize == 0 )
62- {
63- Log::Warn ( " Tiled dynamic light renderer disabled because of missing 3D texture support." );
64- glConfig.realtimeLighting = false ;
65- }
66-
67- // See below about ALU instructions on ATI R300 and Intel GMA 3.
68- if ( !glConfig.glCoreProfile && glConfig.maxAluInstructions < 128 )
69- {
70- Log::Warn ( " Tiled dynamic light rendered disabled because GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB is too small: %d" , glConfig.maxAluInstructions );
71- glConfig.realtimeLighting = false ;
72- }
73- }
74-
75- if ( glConfig.realtimeLighting ) {
76- // Minimum possible is 16384 / 48 = 341
77- glConfig.maxRealtimeLights =
78- std::min<size_t >( MAX_REF_LIGHTS , glConfig.maxUniformBlockSize / sizeof ( shaderLight_t ) );
79-
80- glConfig.realtimeLightLayers = r_realtimeLightLayers.Get ();
81-
82- if ( glConfig.realtimeLightLayers > glConfig.max3DTextureSize ) {
83- glConfig.realtimeLightLayers = glConfig.max3DTextureSize ;
84- Log::Notice ( " r_realtimeLightLayers exceeds maximum 3D texture size, using %i instead." , glConfig.max3DTextureSize );
85- }
86-
87- Log::Notice ( " Using %i dynamic light layers, %i dynamic lights available per tile, max %d lights" ,
88- glConfig.realtimeLightLayers , glConfig.realtimeLightLayers * 16 , glConfig.maxRealtimeLights );
89- }
90-
91- glConfig.colorGrading = r_colorGrading.Get ();
92-
93- if ( glConfig.colorGrading )
94- {
95- if ( glConfig.max3DTextureSize == 0 )
96- {
97- Log::Warn ( " Color grading disabled because of missing 3D texture support." );
98- glConfig.colorGrading = false ;
99- }
100- }
101-
102- glConfig.deluxeMapping = r_deluxeMapping->integer ;
103- glConfig.normalMapping = r_normalMapping->integer ;
104- glConfig.specularMapping = r_specularMapping->integer ;
105- glConfig.physicalMapping = r_physicalMapping->integer ;
106- glConfig.reliefMapping = r_reliefMapping->integer ;
107-
108- /* ATI R300 and Intel GMA 3 only have 64 ALU instructions, which is not enough for some shader
109- variants. For example the lightMapping shader permutation with macros USE_GRID_LIGHTING and
110- USE_GRID_DELUXE_MAPPING from the medium graphics preset requires 67 ALU.
111- For comparison, ATI R400 and R500 have 512 of them. */
112- if ( !glConfig.glCoreProfile && glConfig.maxAluInstructions < 128 )
113- {
114- static const std::pair<bool *, std::string> aluFeatures[] = {
115- /* Normal mapping, specular mapping and physical mapping does nothing when deluxe mapping
116- is disabled. Hardware that can't do deluxe mapping or normal mapping is not powerful
117- enoough to do relief mapping. */
118- { &glConfig.deluxeMapping , " Deluxe mapping" },
119- { &glConfig.normalMapping , " Normal mapping" },
120- { &glConfig.specularMapping , " Specular mapping" },
121- { &glConfig.physicalMapping , " Physical mapping" },
122- { &glConfig.reliefMapping , " Relief mapping" },
123- };
124-
125- for ( auto & f : aluFeatures )
126- {
127- if ( *f.first )
128- {
129- Log::Warn ( " %s disabled because GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB is too small: %d" , f.second , glConfig.maxAluInstructions );
130- *f.first = false ;
131- }
132- }
133- }
134-
135- // Disable features that require deluxe mapping to be enabled.
136- glConfig.normalMapping = glConfig.deluxeMapping && glConfig.normalMapping ;
137- glConfig.specularMapping = glConfig.deluxeMapping && glConfig.specularMapping ;
138- glConfig.physicalMapping = glConfig.deluxeMapping && glConfig.physicalMapping ;
139-
140- glConfig.bloom = r_bloom.Get ();
141-
142- glConfig.SSAO = r_SSAO.Get () != Util::ordinal ( ssaoMode::DISABLED );
143-
144- static const std::pair<bool *, std::string> ssaoRequiredExtensions[] = {
145- { &glConfig.textureGatherAvailable , " ARB_texture_gather" },
146- { &glConfig.gpuShader4Available , " EXT_gpu_shader4" },
147- };
148-
149- for ( auto & e: ssaoRequiredExtensions )
150- {
151- if ( !*e.first )
152- {
153- Log::Warn ( " SSAO disabled because %s is not available." , e.second );
154- glConfig.SSAO = false ;
155- }
156- }
157-
158- /* Motion blur is enabled by cg_motionblur which is a client cvar so we have to build it in all cases,
159- unless unsupported by the hardware which is the only condition when the engine knows it is not used. */
160- glConfig.motionBlur = true ;
161-
162- // This will be enabled later on by R_BuildCubeMaps()
163- glConfig.reflectionMapping = false ;
164-
165- /* Intel GMA 3 only has 4 tex indirections, which is not enough for some shaders.
166- For example blurX requires 6, contrast requires 5, motionblur requires 5…
167- For comparison, ATI R300, R400 and R500 have 16 of them. We don't need a finer check as early R300
168- hardware with 16 indirections would better not run that code for performance, so disabling the shader
169- by mistake on an hypothetical lower-end hardware only supporting 8 indirections can't do harm. */
170- if ( !glConfig.glCoreProfile && glConfig.maxTexIndirections < 16 )
171- {
172- static const std::pair<bool *, std::string> indirectFeatures[] = {
173- { &glConfig.bloom , " Bloom" },
174- { &glConfig.motionBlur , " Motion blur" },
175- };
176-
177- for ( auto & f : indirectFeatures )
178- {
179- if ( *f.first )
180- {
181- Log::Warn ( " %s disabled because GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB is too small: %d" , f.second , glConfig.maxTexIndirections );
182- *f.first = false ;
183- }
184- }
185- }
186-
187- if ( std::make_pair ( glConfig.glMajor , glConfig.glMinor ) >= std::make_pair ( 3 , 2 ) ) {
188- glConfig.MSAA = r_MSAA.Get ();
189- const int maxSamples = std::min ( glConfig.maxColorTextureSamples , glConfig.maxDepthTextureSamples );
190-
191- if ( glConfig.MSAA > maxSamples ) {
192- Log::Warn ( " MSAA samples %i > %i, setting to %i" , r_MSAA.Get (), maxSamples, maxSamples );
193- glConfig.MSAA = maxSamples;
194- }
195- } else if ( r_MSAA.Get () ) {
196- Log::Warn ( " MSAA unavailable because GL version is lower than required (%i.%i < %i.%i)" , glConfig.glMajor , glConfig.glMinor , 3 , 2 );
197- }
198-
199- glConfig.FXAA = r_FXAA.Get ();
200-
201- if ( glConfig.FXAA && glConfig.MSAA )
202- {
203- Log::Notice ( " FXAA disabled because MSAA is enabled." );
204- glConfig.FXAA = false ;
205- }
206-
207- if ( glConfig.FXAA && !glConfig.samplerObjectsAvailable )
208- {
209- Log::Warn ( " FXAA disabled because ARB_sampler_objects is not available." );
210- glConfig.FXAA = false ;
211- }
212-
213- glConfig.usingMaterialSystem = r_materialSystem.Get () && glConfig.materialSystemAvailable ;
214- glConfig.usingBindlessTextures = glConfig.usingMaterialSystem ||
215- ( r_preferBindlessTextures.Get () && glConfig.bindlessTexturesAvailable );
216- glConfig.usingGeometryCache = glConfig.usingMaterialSystem && glConfig.geometryCacheAvailable ;
217- }
218-
21939// For shaders that require map data for compile-time values
22040void GLSL_InitWorldShaders () {
22141 // make sure the render thread is stopped
@@ -244,10 +64,6 @@ static void GLSL_InitGPUShadersOrError()
24464
24565 gl_shaderManager.InitDriverInfo ();
24666
247- /* It must be done before GenerateBuiltinHeaders() because glConfig.realtimeLighting
248- is read in GenEngineConstants(). */
249- EnableAvailableFeatures ();
250-
25167 gl_shaderManager.GenerateBuiltinHeaders ();
25268
25369 // single texture rendering
0 commit comments