@@ -30,188 +30,11 @@ 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.
3433
3534This file deals with applying shaders to surface data in the tess struct.
3635=================================================================================
3736*/
3837
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- glConfig.realtimeLightLayers = r_realtimeLightLayers.Get ();
77-
78- if ( glConfig.realtimeLightLayers > glConfig.max3DTextureSize ) {
79- glConfig.realtimeLightLayers = glConfig.max3DTextureSize ;
80- Log::Notice ( " r_realtimeLightLayers exceeds maximum 3D texture size, using %i instead." , glConfig.max3DTextureSize );
81- }
82-
83- Log::Notice ( " Using %i dynamic light layers, %i dynamic lights available per tile" , glConfig.realtimeLightLayers ,
84- glConfig.realtimeLightLayers * 16 );
85- }
86-
87- glConfig.colorGrading = r_colorGrading.Get ();
88-
89- if ( glConfig.colorGrading )
90- {
91- if ( glConfig.max3DTextureSize == 0 )
92- {
93- Log::Warn ( " Color grading disabled because of missing 3D texture support." );
94- glConfig.colorGrading = false ;
95- }
96- }
97-
98- glConfig.deluxeMapping = r_deluxeMapping->integer ;
99- glConfig.normalMapping = r_normalMapping->integer ;
100- glConfig.specularMapping = r_specularMapping->integer ;
101- glConfig.physicalMapping = r_physicalMapping->integer ;
102- glConfig.reliefMapping = r_reliefMapping->integer ;
103-
104- /* ATI R300 and Intel GMA 3 only have 64 ALU instructions, which is not enough for some shader
105- variants. For example the lightMapping shader permutation with macros USE_GRID_LIGHTING and
106- USE_GRID_DELUXE_MAPPING from the medium graphics preset requires 67 ALU.
107- For comparison, ATI R400 and R500 have 512 of them. */
108- if ( !glConfig.glCoreProfile && glConfig.maxAluInstructions < 128 )
109- {
110- static const std::pair<bool *, std::string> aluFeatures[] = {
111- /* Normal mapping, specular mapping and physical mapping does nothing when deluxe mapping
112- is disabled. Hardware that can't do deluxe mapping or normal mapping is not powerful
113- enoough to do relief mapping. */
114- { &glConfig.deluxeMapping , " Deluxe mapping" },
115- { &glConfig.normalMapping , " Normal mapping" },
116- { &glConfig.specularMapping , " Specular mapping" },
117- { &glConfig.physicalMapping , " Physical mapping" },
118- { &glConfig.reliefMapping , " Relief mapping" },
119- };
120-
121- for ( auto & f : aluFeatures )
122- {
123- if ( *f.first )
124- {
125- Log::Warn ( " %s disabled because GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB is too small: %d" , f.second , glConfig.maxAluInstructions );
126- *f.first = false ;
127- }
128- }
129- }
130-
131- // Disable features that require deluxe mapping to be enabled.
132- glConfig.normalMapping = glConfig.deluxeMapping && glConfig.normalMapping ;
133- glConfig.specularMapping = glConfig.deluxeMapping && glConfig.specularMapping ;
134- glConfig.physicalMapping = glConfig.deluxeMapping && glConfig.physicalMapping ;
135-
136- glConfig.bloom = r_bloom.Get ();
137-
138- glConfig.SSAO = r_SSAO.Get () != Util::ordinal ( ssaoMode::DISABLED );
139-
140- static const std::pair<bool *, std::string> ssaoRequiredExtensions[] = {
141- { &glConfig.textureGatherAvailable , " ARB_texture_gather" },
142- { &glConfig.gpuShader4Available , " EXT_gpu_shader4" },
143- };
144-
145- for ( auto & e: ssaoRequiredExtensions )
146- {
147- if ( !*e.first )
148- {
149- Log::Warn ( " SSAO disabled because %s is not available." , e.second );
150- glConfig.SSAO = false ;
151- }
152- }
153-
154- /* Motion blur is enabled by cg_motionblur which is a client cvar so we have to build it in all cases,
155- unless unsupported by the hardware which is the only condition when the engine knows it is not used. */
156- glConfig.motionBlur = true ;
157-
158- // This will be enabled later on by R_BuildCubeMaps()
159- glConfig.reflectionMapping = false ;
160-
161- /* Intel GMA 3 only has 4 tex indirections, which is not enough for some shaders.
162- For example blurX requires 6, contrast requires 5, motionblur requires 5…
163- For comparison, ATI R300, R400 and R500 have 16 of them. We don't need a finer check as early R300
164- hardware with 16 indirections would better not run that code for performance, so disabling the shader
165- by mistake on an hypothetical lower-end hardware only supporting 8 indirections can't do harm. */
166- if ( !glConfig.glCoreProfile && glConfig.maxTexIndirections < 16 )
167- {
168- static const std::pair<bool *, std::string> indirectFeatures[] = {
169- { &glConfig.bloom , " Bloom" },
170- { &glConfig.motionBlur , " Motion blur" },
171- };
172-
173- for ( auto & f : indirectFeatures )
174- {
175- if ( *f.first )
176- {
177- Log::Warn ( " %s disabled because GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB is too small: %d" , f.second , glConfig.maxTexIndirections );
178- *f.first = false ;
179- }
180- }
181- }
182-
183- if ( std::make_pair ( glConfig.glMajor , glConfig.glMinor ) >= std::make_pair ( 3 , 2 ) ) {
184- glConfig.MSAA = r_MSAA.Get ();
185- const int maxSamples = std::min ( glConfig.maxColorTextureSamples , glConfig.maxDepthTextureSamples );
186-
187- if ( glConfig.MSAA > maxSamples ) {
188- Log::Warn ( " MSAA samples %i > %i, setting to %i" , r_MSAA.Get (), maxSamples, maxSamples );
189- glConfig.MSAA = maxSamples;
190- }
191- } else if ( r_MSAA.Get () ) {
192- Log::Warn ( " MSAA unavailable because GL version is lower than required (%i.%i < %i.%i)" , glConfig.glMajor , glConfig.glMinor , 3 , 2 );
193- }
194-
195- glConfig.FXAA = r_FXAA.Get ();
196-
197- if ( glConfig.FXAA && glConfig.MSAA )
198- {
199- Log::Notice ( " FXAA disabled because MSAA is enabled." );
200- glConfig.FXAA = false ;
201- }
202-
203- if ( glConfig.FXAA && !glConfig.samplerObjectsAvailable )
204- {
205- Log::Warn ( " FXAA disabled because ARB_sampler_objects is not available." );
206- glConfig.FXAA = false ;
207- }
208-
209- glConfig.usingMaterialSystem = r_materialSystem.Get () && glConfig.materialSystemAvailable ;
210- glConfig.usingBindlessTextures = glConfig.usingMaterialSystem ||
211- ( r_preferBindlessTextures.Get () && glConfig.bindlessTexturesAvailable );
212- glConfig.usingGeometryCache = glConfig.usingMaterialSystem && glConfig.geometryCacheAvailable ;
213- }
214-
21538// For shaders that require map data for compile-time values
21639void GLSL_InitWorldShaders () {
21740 // make sure the render thread is stopped
@@ -240,10 +63,6 @@ static void GLSL_InitGPUShadersOrError()
24063
24164 gl_shaderManager.InitDriverInfo ();
24265
243- /* It must be done before GenerateBuiltinHeaders() because glConfig.realtimeLighting
244- is read in GenEngineConstants(). */
245- EnableAvailableFeatures ();
246-
24766 gl_shaderManager.GenerateBuiltinHeaders ();
24867
24968 // single texture rendering
0 commit comments