From c64d1ab9e457cea53e036fbfd85221746d34f1e3 Mon Sep 17 00:00:00 2001 From: VReaperV Date: Wed, 13 Aug 2025 18:37:17 +0300 Subject: [PATCH] Split glconfig_t/glconfig2_t into WindowConfig/GLConfig Move the stuff actually used by cgame (window and display sizes and display aspect) to `WindowConfig`. Merge the rest with `glconfig2_t` into `GLConfig`. `glconfig_t` used as a proxy until 0.56. --- src/engine/client/cl_avi.cpp | 4 +- src/engine/client/cl_cgame.cpp | 20 +- src/engine/client/cl_console.cpp | 28 +- src/engine/client/cl_main.cpp | 6 +- src/engine/client/cl_scrn.cpp | 4 +- src/engine/client/client.h | 4 +- src/engine/null/null_renderer.cpp | 9 +- src/engine/renderer/GLMemory.h | 2 +- src/engine/renderer/GLUtils.h | 4 +- src/engine/renderer/InternalImage.cpp | 2 +- src/engine/renderer/Material.cpp | 10 +- src/engine/renderer/gl_shader.cpp | 152 +++++------ src/engine/renderer/gl_shader.h | 16 +- src/engine/renderer/tr_animation.cpp | 2 +- src/engine/renderer/tr_backend.cpp | 68 ++--- src/engine/renderer/tr_bsp.cpp | 34 +-- src/engine/renderer/tr_cmds.cpp | 6 +- src/engine/renderer/tr_fbo.cpp | 30 +- src/engine/renderer/tr_image.cpp | 64 ++--- src/engine/renderer/tr_init.cpp | 110 ++++---- src/engine/renderer/tr_local.h | 2 +- src/engine/renderer/tr_main.cpp | 12 +- src/engine/renderer/tr_model.cpp | 5 +- src/engine/renderer/tr_model_iqm.cpp | 4 +- src/engine/renderer/tr_model_skel.cpp | 2 +- src/engine/renderer/tr_public.h | 27 +- src/engine/renderer/tr_scene.cpp | 10 +- src/engine/renderer/tr_shade.cpp | 174 ++++++------ src/engine/renderer/tr_shader.cpp | 28 +- src/engine/renderer/tr_surface.cpp | 4 +- src/engine/renderer/tr_vbo.cpp | 64 ++--- src/engine/sys/sdl_glimp.cpp | 376 +++++++++++++------------- 32 files changed, 660 insertions(+), 623 deletions(-) diff --git a/src/engine/client/cl_avi.cpp b/src/engine/client/cl_avi.cpp index 17566a6ddc..e33ccb7755 100644 --- a/src/engine/client/cl_avi.cpp +++ b/src/engine/client/cl_avi.cpp @@ -355,8 +355,8 @@ bool CL_OpenAVIForWriting( const char *fileName ) afd.frameRate = cl_aviFrameRate->integer; afd.framePeriod = ( int )( 1000000.0f / afd.frameRate ); - afd.width = cls.glconfig.vidWidth; - afd.height = cls.glconfig.vidHeight; + afd.width = cls.windowConfig.vidWidth; + afd.height = cls.windowConfig.vidHeight; if ( cl_aviMotionJpeg->integer ) { diff --git a/src/engine/client/cl_cgame.cpp b/src/engine/client/cl_cgame.cpp index b5d30a389f..e0b52af2c5 100644 --- a/src/engine/client/cl_cgame.cpp +++ b/src/engine/client/cl_cgame.cpp @@ -974,7 +974,15 @@ void CGameVM::CGameStaticInit() void CGameVM::CGameInit(int serverMessageNum, int clientNum) { - this->SendMsg(serverMessageNum, clientNum, cls.glconfig, cl.gameState); + glconfig_t glConfig; + memset( &glConfig, 0, sizeof( glconfig_t ) ); + glConfig.displayAspect = cls.windowConfig.displayAspect; + glConfig.displayWidth = cls.windowConfig.displayWidth; + glConfig.displayHeight = cls.windowConfig.displayHeight; + glConfig.vidWidth = cls.windowConfig.vidWidth; + glConfig.vidHeight = cls.windowConfig.vidHeight; + + this->SendMsg(serverMessageNum, clientNum, glConfig, cl.gameState); NetcodeTable psTable; size_t psSize; this->SendMsg(psTable, psSize); @@ -1038,7 +1046,15 @@ void CGameVM::CGameTextInputEvent(int c) void CGameVM::CGameRocketInit() { - this->SendMsg(cls.glconfig); + glconfig_t glConfig; + memset( &glConfig, 0, sizeof( glconfig_t ) ); + glConfig.displayAspect = cls.windowConfig.displayAspect; + glConfig.displayWidth = cls.windowConfig.displayWidth; + glConfig.displayHeight = cls.windowConfig.displayHeight; + glConfig.vidWidth = cls.windowConfig.vidWidth; + glConfig.vidHeight = cls.windowConfig.vidHeight; + + this->SendMsg( glConfig ); } void CGameVM::CGameRocketFrame() diff --git a/src/engine/client/cl_console.cpp b/src/engine/client/cl_console.cpp index 8c2535c25c..319595b6c3 100644 --- a/src/engine/client/cl_console.cpp +++ b/src/engine/client/cl_console.cpp @@ -298,9 +298,9 @@ bool Con_CheckResize() bool ret = true; - if ( cls.glconfig.vidWidth ) + if ( cls.windowConfig.vidWidth ) { - int consoleVidWidth = cls.glconfig.vidWidth - 2 * (consoleState.margin.sides + consoleState.padding.sides ); + int consoleVidWidth = cls.windowConfig.vidWidth - 2 * (consoleState.margin.sides + consoleState.padding.sides ); textWidthInChars = consoleVidWidth / SCR_ConsoleFontUnicharWidth( 'W' ); } else @@ -483,7 +483,7 @@ bool CL_InternalConsolePrint( const char *text ) } //Video hasn't been initialized - if ( ! cls.glconfig.vidWidth ) { + if ( ! cls.windowConfig.vidWidth ) { return false; } @@ -586,7 +586,7 @@ Draws the background of the console (on the virtual 640x480 resolution) */ void Con_DrawBackground() { - const int consoleWidth = cls.glconfig.vidWidth - 2 * consoleState.margin.sides; + const int consoleWidth = cls.windowConfig.vidWidth - 2 * consoleState.margin.sides; // draw the background Color::Color color ( @@ -617,7 +617,7 @@ void Con_DrawBackground() consoleState.border.sides, consoleState.height + consoleState.border.bottom, borderColor ); //right border - SCR_FillRect( cls.glconfig.vidWidth - consoleState.margin.sides, consoleState.margin.top - consoleState.border.top, + SCR_FillRect( cls.windowConfig.vidWidth - consoleState.margin.sides, consoleState.margin.top - consoleState.border.top, consoleState.border.sides, consoleState.border.top + consoleState.height, borderColor ); //bottom border @@ -670,7 +670,7 @@ void Con_DrawRightFloatingTextLine( const int linePosition, const Color::Color& + charHeight; i = strlen( text ); - currentWidthLocation = cls.glconfig.vidWidth + currentWidthLocation = cls.windowConfig.vidWidth - SCR_ConsoleFontStringWidth( text, i ) - consoleState.margin.sides - consoleState.padding.sides; @@ -727,7 +727,7 @@ void Con_DrawConsoleScrollbackIndicator( int lineDrawPosition ) void Con_DrawConsoleScrollbar() { const int freeConsoleHeight = consoleState.height - consoleState.padding.top - consoleState.padding.bottom; - const float scrollBarX = cls.glconfig.vidWidth - consoleState.margin.sides - consoleState.padding.sides - 2 * consoleState.border.sides; + const float scrollBarX = cls.windowConfig.vidWidth - consoleState.margin.sides - consoleState.padding.sides - 2 * consoleState.border.sides; const float scrollBarY = consoleState.margin.top + consoleState.border.top + consoleState.padding.top + freeConsoleHeight * 0.10f; const float scrollBarLength = freeConsoleHeight * 0.80f; const float scrollBarWidth = consoleState.border.sides * 2; @@ -783,7 +783,7 @@ void Con_DrawScrollbackMarkerline( int lineDrawPosition ) SCR_FillRect( consoleState.margin.sides + consoleState.border.sides + consoleState.padding.sides/2, lineDrawPosition + SCR_ConsoleFontCharVPadding(), - cls.glconfig.vidWidth - 2 * consoleState.margin.sides - 2 * consoleState.border.sides - consoleState.padding.sides/2 - scrollBarImpliedPadding, + cls.windowConfig.vidWidth - 2 * consoleState.margin.sides - 2 * consoleState.border.sides - consoleState.padding.sides/2 - scrollBarImpliedPadding, 1, color ); } @@ -933,7 +933,7 @@ void Con_DrawAnimatedConsole() //clip about text and content to the console contentClipping [ 0 ] = consoleState.margin.sides + consoleState.border.sides; //x contentClipping [ 1 ] = consoleState.margin.top + consoleState.border.top; //y - contentClipping [ 2 ] = cls.glconfig.vidWidth - consoleState.margin.sides - consoleState.border.sides; //x-end + contentClipping [ 2 ] = cls.windowConfig.vidWidth - consoleState.margin.sides - consoleState.border.sides; //x-end contentClipping [ 3 ] = consoleState.margin.top + consoleState.border.top + consoleState.height ; //y-end re.SetClipRegion( contentClipping ); @@ -1019,7 +1019,7 @@ void Con_UpdateConsoleState() /* * calculate current console height */ - consoleState.height = con_height->integer * 0.01f * (cls.glconfig.vidHeight + consoleState.height = con_height->integer * 0.01f * (cls.windowConfig.vidHeight - consoleState.margin.top - consoleState.margin.bottom - consoleState.border.top - consoleState.border.bottom ); @@ -1038,9 +1038,9 @@ void Con_UpdateConsoleState() consoleState.height *= consoleState.currentAnimationFraction; } - if ( consoleState.height > cls.glconfig.vidHeight ) + if ( consoleState.height > cls.windowConfig.vidHeight ) { - consoleState.height = cls.glconfig.vidHeight; + consoleState.height = cls.windowConfig.vidHeight; } /* @@ -1082,7 +1082,7 @@ void Con_RunAnimatedConsole() Con_UpdateConsoleState( ); //recalculate } - consoleVidWidth = cls.glconfig.vidWidth - 2 * (consoleState.margin.sides + consoleState.padding.sides ); + consoleVidWidth = cls.windowConfig.vidWidth - 2 * (consoleState.margin.sides + consoleState.padding.sides ); if( 2 * con_horizontalPadding->value >= consoleVidWidth ) { @@ -1214,7 +1214,7 @@ class GraphicalTarget : public Log::Target { } //Video hasn't been initialized - if ( ! cls.glconfig.vidWidth ) { + if ( ! cls.windowConfig.vidWidth ) { return false; } diff --git a/src/engine/client/cl_main.cpp b/src/engine/client/cl_main.cpp index da9a91d9d2..d781aee3b3 100644 --- a/src/engine/client/cl_main.cpp +++ b/src/engine/client/cl_main.cpp @@ -2100,7 +2100,7 @@ bool CL_InitRenderer() fileHandle_t f; // this sets up the renderer and calls R_Init - if ( !re.BeginRegistration( &cls.glconfig, &cls.glconfig2 ) ) + if ( !re.BeginRegistration( &cls.windowConfig ) ) { return false; } @@ -2126,7 +2126,7 @@ bool CL_InitRenderer() else { // This gets 12px on 1920×1080 screen, which is libRocket default for 1em - int fontScale = std::min(cls.glconfig.vidWidth, cls.glconfig.vidHeight) / 90; + int fontScale = std::min(cls.windowConfig.vidWidth, cls.windowConfig.vidHeight) / 90; // fontScale / 12px gets 1px on 1920×1080 screen cls.consoleFont = re.RegisterFont( cl_consoleFont->string, cl_consoleFontSize->integer * fontScale / 12 ); @@ -2145,7 +2145,7 @@ bool CL_InitRenderer() cls.whiteShader = re.RegisterShader( "white", RSF_NOMIP ); - g_console_field_width = cls.glconfig.vidWidth / SMALLCHAR_WIDTH - 2; + g_console_field_width = cls.windowConfig.vidWidth / SMALLCHAR_WIDTH - 2; g_consoleField.SetWidth(g_console_field_width); return true; diff --git a/src/engine/client/cl_scrn.cpp b/src/engine/client/cl_scrn.cpp index 4b4035315d..6456b23b47 100644 --- a/src/engine/client/cl_scrn.cpp +++ b/src/engine/client/cl_scrn.cpp @@ -52,8 +52,8 @@ void SCR_AdjustFrom640( float *x, float *y, float *w, float *h ) float yscale; // scale for screen sizes - xscale = cls.glconfig.vidWidth / 640.0; - yscale = cls.glconfig.vidHeight / 480.0; + xscale = cls.windowConfig.vidWidth / 640.0; + yscale = cls.windowConfig.vidHeight / 480.0; if ( x ) { diff --git a/src/engine/client/client.h b/src/engine/client/client.h index f53156e89f..4b058448f7 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -312,8 +312,8 @@ struct clientStatic_t char updateInfoString[ MAX_INFO_STRING ]; // rendering info - glconfig_t glconfig; - glconfig2_t glconfig2; + WindowConfig windowConfig; + GLConfig glConfig; qhandle_t charSetShader; qhandle_t whiteShader; bool useLegacyConsoleFont; diff --git a/src/engine/null/null_renderer.cpp b/src/engine/null/null_renderer.cpp index a05a96b335..69d69e4e66 100644 --- a/src/engine/null/null_renderer.cpp +++ b/src/engine/null/null_renderer.cpp @@ -180,12 +180,11 @@ const char *RE_ShaderNameFromHandle( qhandle_t ) return ""; } -bool RE_BeginRegistration( glconfig_t *config, glconfig2_t *glconfig2 ) +bool RE_BeginRegistration( WindowConfig* windowCfg ) { - *config = glconfig_t{}; - config->vidWidth = 640; - config->vidHeight = 480; - *glconfig2 = glconfig2_t{}; + *windowCfg = WindowConfig{}; + windowCfg->vidWidth = 640; + windowCfg->vidHeight = 480; return true; } diff --git a/src/engine/renderer/GLMemory.h b/src/engine/renderer/GLMemory.h index 4878ddf3ef..9bead8c93a 100644 --- a/src/engine/renderer/GLMemory.h +++ b/src/engine/renderer/GLMemory.h @@ -236,7 +236,7 @@ class GLVAO { vboAttributeLayout_t& attr = attrs[spec->attrIndex]; ASSERT_NQ( spec->numComponents, 0U ); attr.componentType = spec->componentStorageType; - if ( attr.componentType == GL_HALF_FLOAT && !glConfig2.halfFloatVertexAvailable ) { + if ( attr.componentType == GL_HALF_FLOAT && !glConfig.halfFloatVertexAvailable ) { attr.componentType = GL_FLOAT; } attr.numComponents = spec->numComponents; diff --git a/src/engine/renderer/GLUtils.h b/src/engine/renderer/GLUtils.h index 0e37a3c003..0a9818b46c 100644 --- a/src/engine/renderer/GLUtils.h +++ b/src/engine/renderer/GLUtils.h @@ -31,8 +31,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_public.h" #include "tr_types.h" -extern glconfig_t glConfig; // outside of TR since it shouldn't be cleared during ref re-init -extern glconfig2_t glConfig2; +extern WindowConfig windowConfig; // outside of TR since it shouldn't be cleared during ref re-init +extern GLConfig glConfig; void GL_CheckErrors_( const char *filename, int line ); diff --git a/src/engine/renderer/InternalImage.cpp b/src/engine/renderer/InternalImage.cpp index 0332a5e279..a388c3cc29 100644 --- a/src/engine/renderer/InternalImage.cpp +++ b/src/engine/renderer/InternalImage.cpp @@ -114,7 +114,7 @@ int R_GetImageCustomScalingStep( const image_t *image, const imageParams_t &imag // Scale down the image size according to the screen size. if ( image->bits & IF_FITSCREEN ) { - int largerSide = std::max( glConfig.vidWidth, glConfig.vidHeight ); + int largerSide = std::max( windowConfig.vidWidth, windowConfig.vidHeight ); if ( scaledDimension > largerSide ) { diff --git a/src/engine/renderer/Material.cpp b/src/engine/renderer/Material.cpp index f031ba6fab..ee24c59751 100644 --- a/src/engine/renderer/Material.cpp +++ b/src/engine/renderer/Material.cpp @@ -502,7 +502,7 @@ void MaterialSystem::GenerateWorldCommandBuffer( std::vector& s Log::Debug( "Generating world command buffer" ); // TexBundles - if ( glConfig2.maxUniformBlockSize >= MIN_MATERIAL_UBO_SIZE ) { + if ( glConfig.maxUniformBlockSize >= MIN_MATERIAL_UBO_SIZE ) { texDataBufferType = GL_UNIFORM_BUFFER; texDataBindingPoint = BufferBind::TEX_DATA; } else { @@ -813,7 +813,7 @@ void BindShaderLightMapping( Material* material ) { gl_lightMappingShaderMaterial->SetReliefMapping( material->enableReliefMapping ); /* Reflective specular setting is different here than in ProcessMaterialLightMapping(), because we don't have cubemaps built yet at this point, but for the purposes of the material ordering there's no difference */ - gl_lightMappingShaderMaterial->SetReflectiveSpecular( glConfig2.reflectionMapping && material->enableSpecularMapping && !( tr.refdef.rdflags & RDF_NOCUBEMAP ) ); + gl_lightMappingShaderMaterial->SetReflectiveSpecular( glConfig.reflectionMapping && material->enableSpecularMapping && !( tr.refdef.rdflags & RDF_NOCUBEMAP ) ); gl_lightMappingShaderMaterial->SetPhysicalShading( material->enablePhysicalMapping ); // Bind shader program. @@ -836,7 +836,7 @@ void BindShaderLightMapping( Material* material ) { gl_lightMappingShaderMaterial->SetUniform_LightGrid2Bindless( GL_BindToTMU( BIND_LIGHTGRID2, tr.lightGrid2Image ) ); } - if ( glConfig2.realtimeLighting ) { + if ( glConfig.realtimeLighting ) { // bind u_LightTiles gl_lightMappingShaderMaterial->SetUniform_LightTilesBindless( GL_BindToTMU( BIND_LIGHTTILES, tr.lighttileRenderImage ) @@ -852,7 +852,7 @@ void BindShaderLightMapping( Material* material ) { gl_lightMappingShaderMaterial->SetUniform_Time( backEnd.refdef.floatTime - backEnd.currentEntity->e.shaderTime ); // TODO: Move this to a per-entity buffer - if ( glConfig2.reflectionMapping && !( tr.refdef.rdflags & RDF_NOCUBEMAP ) ) { + if ( glConfig.reflectionMapping && !( tr.refdef.rdflags & RDF_NOCUBEMAP ) ) { bool isWorldEntity = backEnd.currentEntity == &tr.worldEntity; vec3_t position; @@ -1466,7 +1466,7 @@ void MaterialSystem::AddStageTextures( MaterialSurface* surface, shader_t* shade } surface->texDataDynamic[stage] = dynamic; - if ( glConfig2.realtimeLighting ) { + if ( glConfig.realtimeLighting ) { material->AddTexture( tr.lighttileRenderImage->texture ); } } diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index 652b2e6db0..28f1c1c64d 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -286,7 +286,7 @@ void GLShaderManager::UpdateShaderProgramUniformLocations( GLShader* shader, Sha uniform->UpdateShaderProgramUniformLocation( shaderProgram ); } - if( glConfig2.uniformBufferObjectAvailable && !glConfig2.shadingLanguage420PackAvailable ) { + if( glConfig.uniformBufferObjectAvailable && !glConfig.shadingLanguage420PackAvailable ) { // create buffer for storing uniform block indexes shaderProgram->uniformBlockIndexes = ( GLuint* ) Z_Malloc( sizeof( GLuint ) * numUniformBlocks ); @@ -414,57 +414,57 @@ struct addedExtension_t { // Fragment and vertex version declaration. static const std::vector fragmentVertexAddedExtensions = { - { glConfig2.gpuShader4Available, 130, "EXT_gpu_shader4" }, - { glConfig2.gpuShader5Available, 400, "ARB_gpu_shader5" }, - { glConfig2.shadingLanguage420PackAvailable, 420, "ARB_shading_language_420pack" }, - { glConfig2.textureFloatAvailable, 0, "ARB_texture_float" }, - { glConfig2.textureGatherAvailable, 400, "ARB_texture_gather" }, - { glConfig2.textureIntegerAvailable, 0, "EXT_texture_integer" }, - { glConfig2.textureRGAvailable, 0, "ARB_texture_rg" }, - { glConfig2.uniformBufferObjectAvailable, 140, "ARB_uniform_buffer_object" }, - { glConfig2.usingBindlessTextures, -1, "ARB_bindless_texture" }, + { glConfig.gpuShader4Available, 130, "EXT_gpu_shader4" }, + { glConfig.gpuShader5Available, 400, "ARB_gpu_shader5" }, + { glConfig.shadingLanguage420PackAvailable, 420, "ARB_shading_language_420pack" }, + { glConfig.textureFloatAvailable, 0, "ARB_texture_float" }, + { glConfig.textureGatherAvailable, 400, "ARB_texture_gather" }, + { glConfig.textureIntegerAvailable, 0, "EXT_texture_integer" }, + { glConfig.textureRGAvailable, 0, "ARB_texture_rg" }, + { glConfig.uniformBufferObjectAvailable, 140, "ARB_uniform_buffer_object" }, + { glConfig.usingBindlessTextures, -1, "ARB_bindless_texture" }, /* ARB_shader_draw_parameters set to -1, because we might get a 4.6 GL context, where the core variables have different names. */ - { glConfig2.shaderDrawParametersAvailable, -1, "ARB_shader_draw_parameters" }, - { glConfig2.SSBOAvailable, 430, "ARB_shader_storage_buffer_object" }, + { glConfig.shaderDrawParametersAvailable, -1, "ARB_shader_draw_parameters" }, + { glConfig.SSBOAvailable, 430, "ARB_shader_storage_buffer_object" }, /* Even though these are part of the GL_KHR_shader_subgroup extension, we need to enable the individual extensions for each feature. GL_KHR_shader_subgroup itself can't be used in the shader. */ - { glConfig2.shaderSubgroupBasicAvailable, -1, "KHR_shader_subgroup_basic" }, - { glConfig2.shaderSubgroupVoteAvailable, -1, "KHR_shader_subgroup_vote" }, - { glConfig2.shaderSubgroupArithmeticAvailable, -1, "KHR_shader_subgroup_arithmetic" }, - { glConfig2.shaderSubgroupBallotAvailable, -1, "KHR_shader_subgroup_ballot" }, - { glConfig2.shaderSubgroupShuffleAvailable, -1, "KHR_shader_subgroup_shuffle" }, - { glConfig2.shaderSubgroupShuffleRelativeAvailable, -1, "KHR_shader_subgroup_shuffle_relative" }, - { glConfig2.shaderSubgroupQuadAvailable, -1, "KHR_shader_subgroup_quad" }, + { glConfig.shaderSubgroupBasicAvailable, -1, "KHR_shader_subgroup_basic" }, + { glConfig.shaderSubgroupVoteAvailable, -1, "KHR_shader_subgroup_vote" }, + { glConfig.shaderSubgroupArithmeticAvailable, -1, "KHR_shader_subgroup_arithmetic" }, + { glConfig.shaderSubgroupBallotAvailable, -1, "KHR_shader_subgroup_ballot" }, + { glConfig.shaderSubgroupShuffleAvailable, -1, "KHR_shader_subgroup_shuffle" }, + { glConfig.shaderSubgroupShuffleRelativeAvailable, -1, "KHR_shader_subgroup_shuffle_relative" }, + { glConfig.shaderSubgroupQuadAvailable, -1, "KHR_shader_subgroup_quad" }, }; // Compute version declaration, this has to be separate from other shader stages, // because some things are unique to vertex/fragment or compute shaders. static const std::vector computeAddedExtensions = { - { glConfig2.computeShaderAvailable, 430, "ARB_compute_shader" }, - { glConfig2.gpuShader4Available, 130, "EXT_gpu_shader4" }, - { glConfig2.gpuShader5Available, 400, "ARB_gpu_shader5" }, - { glConfig2.uniformBufferObjectAvailable, 140, "ARB_uniform_buffer_object" }, - { glConfig2.SSBOAvailable, 430, "ARB_shader_storage_buffer_object" }, - { glConfig2.shadingLanguage420PackAvailable, 420, "ARB_shading_language_420pack" }, - { glConfig2.explicitUniformLocationAvailable, 430, "ARB_explicit_uniform_location" }, - { glConfig2.shaderImageLoadStoreAvailable, 420, "ARB_shader_image_load_store" }, - { glConfig2.shaderAtomicCountersAvailable, 420, "ARB_shader_atomic_counters" }, + { glConfig.computeShaderAvailable, 430, "ARB_compute_shader" }, + { glConfig.gpuShader4Available, 130, "EXT_gpu_shader4" }, + { glConfig.gpuShader5Available, 400, "ARB_gpu_shader5" }, + { glConfig.uniformBufferObjectAvailable, 140, "ARB_uniform_buffer_object" }, + { glConfig.SSBOAvailable, 430, "ARB_shader_storage_buffer_object" }, + { glConfig.shadingLanguage420PackAvailable, 420, "ARB_shading_language_420pack" }, + { glConfig.explicitUniformLocationAvailable, 430, "ARB_explicit_uniform_location" }, + { glConfig.shaderImageLoadStoreAvailable, 420, "ARB_shader_image_load_store" }, + { glConfig.shaderAtomicCountersAvailable, 420, "ARB_shader_atomic_counters" }, /* ARB_shader_atomic_counter_ops set to -1, because we might get a 4.6 GL context, where the core functions have different names. */ - { glConfig2.shaderAtomicCounterOpsAvailable, -1, "ARB_shader_atomic_counter_ops" }, - { glConfig2.usingBindlessTextures, -1, "ARB_bindless_texture" }, + { glConfig.shaderAtomicCounterOpsAvailable, -1, "ARB_shader_atomic_counter_ops" }, + { glConfig.usingBindlessTextures, -1, "ARB_bindless_texture" }, /* Even though these are part of the GL_KHR_shader_subgroup extension, we need to enable the individual extensions for each feature. GL_KHR_shader_subgroup itself can't be used in the shader. */ - { glConfig2.shaderSubgroupBasicAvailable, -1, "KHR_shader_subgroup_basic" }, - { glConfig2.shaderSubgroupVoteAvailable, -1, "KHR_shader_subgroup_vote" }, - { glConfig2.shaderSubgroupArithmeticAvailable, -1, "KHR_shader_subgroup_arithmetic" }, - { glConfig2.shaderSubgroupBallotAvailable, -1, "KHR_shader_subgroup_ballot" }, - { glConfig2.shaderSubgroupShuffleAvailable, -1, "KHR_shader_subgroup_shuffle" }, - { glConfig2.shaderSubgroupShuffleRelativeAvailable, -1, "KHR_shader_subgroup_shuffle_relative" }, - { glConfig2.shaderSubgroupQuadAvailable, -1, "KHR_shader_subgroup_quad" }, + { glConfig.shaderSubgroupBasicAvailable, -1, "KHR_shader_subgroup_basic" }, + { glConfig.shaderSubgroupVoteAvailable, -1, "KHR_shader_subgroup_vote" }, + { glConfig.shaderSubgroupArithmeticAvailable, -1, "KHR_shader_subgroup_arithmetic" }, + { glConfig.shaderSubgroupBallotAvailable, -1, "KHR_shader_subgroup_ballot" }, + { glConfig.shaderSubgroupShuffleAvailable, -1, "KHR_shader_subgroup_shuffle" }, + { glConfig.shaderSubgroupShuffleRelativeAvailable, -1, "KHR_shader_subgroup_shuffle_relative" }, + { glConfig.shaderSubgroupQuadAvailable, -1, "KHR_shader_subgroup_quad" }, }; static void addExtension( std::string& str, bool available, int minGlslVersion, const std::string& name ) { @@ -472,7 +472,7 @@ static void addExtension( std::string& str, bool available, int minGlslVersion, return; } - if ( ( glConfig2.shadingLanguageVersion < minGlslVersion ) || ( minGlslVersion == -1 ) ) { + if ( ( glConfig.shadingLanguageVersion < minGlslVersion ) || ( minGlslVersion == -1 ) ) { str += Str::Format( "#extension GL_%s : require\n", name ); } @@ -499,8 +499,8 @@ static void AddConst( std::string& str, const std::string& name, float v1, float static std::string GenVersionDeclaration( const std::vector &addedExtensions ) { // Declare version. std::string str = Str::Format( "#version %d %s\n\n", - glConfig2.shadingLanguageVersion, - glConfig2.shadingLanguageVersion >= 150 ? ( glConfig2.glCoreProfile ? "core" : "compatibility" ) : "" ); + glConfig.shadingLanguageVersion, + glConfig.shadingLanguageVersion >= 150 ? ( glConfig.glCoreProfile ? "core" : "compatibility" ) : "" ); // Add supported GLSL extensions. for ( const auto& addedExtension : addedExtensions ) { @@ -522,11 +522,11 @@ static std::string GenCompatHeader() { std::string str; // definition of functions missing in early GLSL - if( glConfig2.shadingLanguageVersion <= 120 ) { + if( glConfig.shadingLanguageVersion <= 120 ) { str += "float smoothstep(float edge0, float edge1, float x) { float t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0); return t * t * (3.0 - 2.0 * t); }\n"; } - if ( !glConfig2.gpuShader5Available && glConfig2.gpuShader4Available ) + if ( !glConfig.gpuShader5Available && glConfig.gpuShader4Available ) { str += R"(vec4 unpackUnorm4x8( uint value ) @@ -543,7 +543,7 @@ R"(vec4 unpackUnorm4x8( uint value ) /* Driver bug: Adrenaline/OGLP drivers fail to recognise the ARB function versions when they return a 4.6 context and the shaders get #version 460 core, so add #define's for them here */ - if ( glConfig2.driverVendor == glDriverVendor_t::ATI && glConfig2.shaderAtomicCounterOpsAvailable ) { + if ( glConfig.driverVendor == glDriverVendor_t::ATI && glConfig.shaderAtomicCounterOpsAvailable ) { str += "#define atomicCounterAddARB atomicCounterAdd\n"; str += "#define atomicCounterSubtractARB atomicCounterSubtract\n"; str += "#define atomicCounterMinARB atomicCounterMin\n"; @@ -562,7 +562,7 @@ static std::string GenVertexHeader() { std::string str; // Vertex shader compatibility defines - if( glConfig2.shadingLanguageVersion > 120 ) { + if( glConfig.shadingLanguageVersion > 120 ) { str = "#define IN in\n" "#define OUT(mode) mode out\n" "#define textureCube texture\n" @@ -574,14 +574,14 @@ static std::string GenVertexHeader() { "#define OUT(mode) varying\n"; } - if ( glConfig2.shaderDrawParametersAvailable ) { + if ( glConfig.shaderDrawParametersAvailable ) { str += "OUT(flat) int in_drawID;\n"; str += "OUT(flat) int in_baseInstance;\n"; str += "#define drawID gl_DrawIDARB\n"; str += "#define baseInstance gl_BaseInstanceARB\n\n"; } - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { AddDefine( str, "BIND_MATERIALS", BufferBind::MATERIALS ); AddDefine( str, "BIND_TEX_DATA", BufferBind::TEX_DATA ); AddDefine( str, "BIND_TEX_DATA_STORAGE", BufferBind::TEX_DATA_STORAGE ); @@ -595,14 +595,14 @@ static std::string GenFragmentHeader() { std::string str; // Fragment shader compatibility defines - if( glConfig2.shadingLanguageVersion > 120 ) { + if( glConfig.shadingLanguageVersion > 120 ) { str = "#define IN(mode) mode in\n" "#define DECLARE_OUTPUT(type) out type outputColor;\n" "#define textureCube texture\n" "#define texture2D texture\n" "#define texture2DProj textureProj\n" "#define texture3D texture\n"; - } else if( glConfig2.gpuShader4Available) { + } else if( glConfig.gpuShader4Available) { str = "#define IN(mode) varying\n" "#define DECLARE_OUTPUT(type) varying out type outputColor;\n"; } else { @@ -611,22 +611,22 @@ static std::string GenFragmentHeader() { "#define DECLARE_OUTPUT(type) /* empty*/\n"; } - if ( glConfig2.usingBindlessTextures ) { + if ( glConfig.usingBindlessTextures ) { str += "layout(bindless_sampler) uniform;\n"; } - if ( glConfig2.shaderDrawParametersAvailable ) { + if ( glConfig.shaderDrawParametersAvailable ) { str += "IN(flat) int in_drawID;\n"; str += "IN(flat) int in_baseInstance;\n"; str += "#define drawID in_drawID\n"; str += "#define baseInstance in_baseInstance\n\n"; } - if ( glConfig2.shadingLanguage420PackAvailable ) { + if ( glConfig.shadingLanguage420PackAvailable ) { AddDefine( str, "BIND_LIGHTS", BufferBind::LIGHTS ); } - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { AddDefine( str, "BIND_MATERIALS", BufferBind::MATERIALS ); AddDefine( str, "BIND_TEX_DATA", BufferBind::TEX_DATA ); AddDefine( str, "BIND_TEX_DATA_STORAGE", BufferBind::TEX_DATA_STORAGE ); @@ -640,7 +640,7 @@ static std::string GenComputeHeader() { std::string str; // Compute shader compatibility defines - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { AddDefine( str, "MAX_VIEWS", MAX_VIEWS ); AddDefine( str, "MAX_FRAMES", MAX_FRAMES ); AddDefine( str, "MAX_VIEWFRAMES", MAX_VIEWFRAMES ); @@ -680,14 +680,14 @@ static std::string GenEngineConstants() { AddDefine( str, "M_PI", static_cast< float >( M_PI ) ); AddDefine( str, "MAX_REF_LIGHTS", MAX_REF_LIGHTS ); - AddDefine( str, "NUM_LIGHT_LAYERS", glConfig2.realtimeLightLayers ); + AddDefine( str, "NUM_LIGHT_LAYERS", glConfig.realtimeLightLayers ); AddDefine( str, "TILE_SIZE", TILE_SIZE ); - AddDefine( str, "r_FBufSize", glConfig.vidWidth, glConfig.vidHeight ); + AddDefine( str, "r_FBufSize", windowConfig.vidWidth, windowConfig.vidHeight ); AddDefine( str, "r_tileStep", glState.tileStep[0], glState.tileStep[1] ); - if ( glConfig2.realtimeLighting ) + if ( glConfig.realtimeLighting ) { AddDefine( str, "r_realtimeLighting", 1 ); } @@ -736,10 +736,10 @@ static std::string GenEngineConstants() { AddDefine( str, "r_profilerRenderSubGroups", 1 ); } - if ( glConfig2.vboVertexSkinningAvailable ) + if ( glConfig.vboVertexSkinningAvailable ) { AddDefine( str, "r_vertexSkinning", 1 ); - AddConst( str, "MAX_GLSL_BONES", glConfig2.maxVertexSkinningBones ); + AddConst( str, "MAX_GLSL_BONES", glConfig.maxVertexSkinningBones ); } else { @@ -765,7 +765,7 @@ static std::string GenEngineConstants() { AddDefine( str, "r_showLightTiles", 1 ); } - if ( glConfig2.normalMapping ) + if ( glConfig.normalMapping ) { AddDefine( str, "r_normalMapping", 1 ); } @@ -775,12 +775,12 @@ static std::string GenEngineConstants() { AddDefine( str, "r_liquidMapping", 1 ); } - if ( glConfig2.specularMapping ) + if ( glConfig.specularMapping ) { AddDefine( str, "r_specularMapping", 1 ); } - if ( glConfig2.physicalMapping ) + if ( glConfig.physicalMapping ) { AddDefine( str, "r_physicalMapping", 1 ); } @@ -790,7 +790,7 @@ static std::string GenEngineConstants() { AddDefine( str, "r_glowMapping", 1 ); } - if ( glConfig2.colorGrading ) + if ( glConfig.colorGrading ) { AddDefine( str, "r_colorGrading", 1 ); } @@ -870,30 +870,30 @@ static bool IsUnusedPermutation( const char *compileMacros ) { if ( strcmp( token, "USE_DELUXE_MAPPING" ) == 0 ) { - if ( !glConfig2.deluxeMapping ) return true; + if ( !glConfig.deluxeMapping ) return true; } else if ( strcmp( token, "USE_GRID_DELUXE_MAPPING" ) == 0 ) { - if ( !glConfig2.deluxeMapping ) return true; + if ( !glConfig.deluxeMapping ) return true; } else if ( strcmp( token, "USE_PHYSICAL_MAPPING" ) == 0 ) { - if ( !glConfig2.physicalMapping ) return true; + if ( !glConfig.physicalMapping ) return true; } else if ( strcmp( token, "USE_REFLECTIVE_SPECULAR" ) == 0 ) { /* FIXME: add to the following test: && r_physicalMapping->integer == 0 when reflective specular is implemented for physical mapping too see https://github.com/DaemonEngine/Daemon/issues/355 */ - if ( !glConfig2.specularMapping ) return true; + if ( !glConfig.specularMapping ) return true; } else if ( strcmp( token, "USE_RELIEF_MAPPING" ) == 0 ) { - if ( !glConfig2.reliefMapping ) return true; + if ( !glConfig.reliefMapping ) return true; } else if ( strcmp( token, "USE_HEIGHTMAP_IN_NORMALMAP" ) == 0 ) { - if ( !glConfig2.reliefMapping && !glConfig2.normalMapping ) return true; + if ( !glConfig.reliefMapping && !glConfig.normalMapping ) return true; } } @@ -969,7 +969,7 @@ void GLShaderManager::BuildShaderProgram( ShaderProgramDescriptor* descriptor ) BindAttribLocations( program ); - if ( glConfig2.getProgramBinaryAvailable ) { + if ( glConfig.getProgramBinaryAvailable ) { glProgramParameteri( program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE ); } @@ -1347,7 +1347,7 @@ void GLShaderManager::InitShader( GLShader* shader ) { ShaderDescriptor* desc = FindShader( shader->_name, shaderType.mainText, shaderType.GLType, shaderType.headers, uniqueMacros, compileMacros, true ); - if ( desc && glConfig2.usingMaterialSystem && shader->_useMaterialSystem ) { + if ( desc && glConfig.usingMaterialSystem && shader->_useMaterialSystem ) { desc->shaderSource = ShaderPostProcess( shader, desc->shaderSource, shaderType.offset ); } @@ -1369,7 +1369,7 @@ bool GLShaderManager::LoadShaderBinary( const std::vector& shaders, } // Don't even try if the necessary functions aren't available - if ( !glConfig2.getProgramBinaryAvailable ) { + if ( !glConfig.getProgramBinaryAvailable ) { return false; } @@ -1456,7 +1456,7 @@ void GLShaderManager::SaveShaderBinary( ShaderProgramDescriptor* descriptor ) { } // Don't even try if the necessary functions aren't available - if( !glConfig2.getProgramBinaryAvailable ) { + if( !glConfig.getProgramBinaryAvailable ) { return; } @@ -1584,7 +1584,7 @@ std::string GLShaderManager::ShaderPostProcess( GLShader *shader, const std::str return shaderText; } - std::string texBuf = glConfig2.maxUniformBlockSize >= MIN_MATERIAL_UBO_SIZE ? + std::string texBuf = glConfig.maxUniformBlockSize >= MIN_MATERIAL_UBO_SIZE ? "layout(std140, binding = " + std::to_string( BufferBind::TEX_DATA ) + ") uniform texDataUBO {\n" @@ -1767,7 +1767,7 @@ std::vector GLShaderManager::ParseInfoLog( const // Info-log is entirely implementation dependent, so different vendors will report it differently while ( std::getline( infoLogTextStream, line, '\n' ) ) { - switch ( glConfig2.driverVendor ) { + switch ( glConfig.driverVendor ) { case glDriverVendor_t::NVIDIA: { // Format: (): @@ -1925,7 +1925,7 @@ void GLShaderManager::LinkProgram( GLuint program ) const #ifdef GL_ARB_get_program_binary // Apparently, this is necessary to get the binary program via glGetProgramBinary - if( glConfig2.getProgramBinaryAvailable ) + if( glConfig.getProgramBinaryAvailable ) { glProgramParameteri( program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE ); } @@ -1982,7 +1982,7 @@ bool GLCompileMacro_USE_VERTEX_SKINNING::HasConflictingMacros( size_t permutatio bool GLCompileMacro_USE_VERTEX_SKINNING::MissesRequiredMacros( size_t /*permutation*/, const std::vector< GLCompileMacro * > &/*macros*/ ) const { - return !glConfig2.vboVertexSkinningAvailable; + return !glConfig.vboVertexSkinningAvailable; } bool GLCompileMacro_USE_VERTEX_ANIMATION::HasConflictingMacros( size_t permutation, const std::vector< GLCompileMacro * > ¯os ) const diff --git a/src/engine/renderer/gl_shader.h b/src/engine/renderer/gl_shader.h index 8aeef648fd..ffaefc504b 100644 --- a/src/engine/renderer/gl_shader.h +++ b/src/engine/renderer/gl_shader.h @@ -488,8 +488,8 @@ class GLShaderManager { class GLUniformSampler : protected GLUniform { protected: GLUniformSampler( GLShader* shader, const char* name, const char* type ) : - GLUniform( shader, name, type, glConfig2.bindlessTexturesAvailable ? 2 : 1, - glConfig2.bindlessTexturesAvailable ? 2 : 1, true, 0, true ) { + GLUniform( shader, name, type, glConfig.bindlessTexturesAvailable ? 2 : 1, + glConfig.bindlessTexturesAvailable ? 2 : 1, true, 0, true ) { } inline GLint GetLocation() { @@ -514,13 +514,13 @@ class GLUniformSampler : protected GLUniform { void SetValueBindless( GLint64 value ) { currentValueBindless = value; - if ( glConfig2.usingBindlessTextures && ( !_shader->UseMaterialSystem() || _global ) ) { + if ( glConfig.usingBindlessTextures && ( !_shader->UseMaterialSystem() || _global ) ) { glUniformHandleui64ARB( GetLocation(), currentValueBindless ); } } uint32_t* WriteToBuffer( uint32_t* buffer ) override { - if ( glConfig2.usingBindlessTextures ) { + if ( glConfig.usingBindlessTextures ) { memcpy( buffer, ¤tValueBindless, sizeof( GLuint64 ) ); } else { memcpy( buffer, ¤tValue, sizeof( GLint ) ); @@ -1149,7 +1149,7 @@ class GLUniformBlock } void SetBuffer( GLuint buffer ) { - if ( glConfig2.shadingLanguage420PackAvailable ) { + if ( glConfig.shadingLanguage420PackAvailable ) { return; } @@ -2195,7 +2195,7 @@ class u_Color_Uint : template void SetUniform_Color( Shader* shader, const Color::Color& color ) { - if( glConfig2.gpuShader4Available ) + if( glConfig.gpuShader4Available ) { shader->SetUniform_Color_Uint( color ); } @@ -2234,7 +2234,7 @@ class u_ColorGlobal_Uint : template void SetUniform_ColorGlobal( Shader* shader, const Color::Color& color ) { - if( glConfig2.gpuShader4Available ) + if( glConfig.gpuShader4Available ) { shader->SetUniform_ColorGlobal_Uint( color ); } @@ -2915,7 +2915,7 @@ template void SetUniform_ColorModulateColorGen( const bool vertexOverbright = false, const bool useMapLightFactor = false ) { - if( glConfig2.gpuShader4Available ) + if( glConfig.gpuShader4Available ) { shader->SetUniform_ColorModulateColorGen_Uint( colorGen, alphaGen, vertexOverbright, useMapLightFactor ); } diff --git a/src/engine/renderer/tr_animation.cpp b/src/engine/renderer/tr_animation.cpp index 617a233c3a..ea4e57160a 100644 --- a/src/engine/renderer/tr_animation.cpp +++ b/src/engine/renderer/tr_animation.cpp @@ -680,7 +680,7 @@ void R_AddMD5Surfaces( trRefEntity_t *ent ) fogNum = R_FogWorldBox( ent->worldBounds ); if ( !r_vboModels.Get() || !model->numVBOSurfaces || - ( !glConfig2.vboVertexSkinningAvailable && ent->e.skeleton.type == refSkeletonType_t::SK_ABSOLUTE ) ) + ( !glConfig.vboVertexSkinningAvailable && ent->e.skeleton.type == refSkeletonType_t::SK_ABSOLUTE ) ) { shader_t *shader; diff --git a/src/engine/renderer/tr_backend.cpp b/src/engine/renderer/tr_backend.cpp index eb9392daa6..31f8a80dab 100644 --- a/src/engine/renderer/tr_backend.cpp +++ b/src/engine/renderer/tr_backend.cpp @@ -59,7 +59,7 @@ void GL_Bind( image_t *image ) texnum = tr.blackImage->texnum; } - if ( glConfig2.usingBindlessTextures ) { + if ( glConfig.usingBindlessTextures ) { tr.textureManager.BindReservedTexture( image->type, texnum ); return; } @@ -158,7 +158,7 @@ void GL_SelectTexture( int unit ) return; } - if ( unit >= 0 && unit < glConfig2.maxTextureUnits ) + if ( unit >= 0 && unit < glConfig.maxTextureUnits ) { glActiveTexture( GL_TEXTURE0 + unit ); } @@ -178,13 +178,13 @@ GLuint64 GL_BindToTMU( int unit, image_t *image ) image = tr.defaultImage; } - if ( glConfig2.usingBindlessTextures ) { + if ( glConfig.usingBindlessTextures ) { return tr.textureManager.BindTexture( 0, image->texture ); } int texnum = image->texnum; - if ( unit < 0 || unit >= glConfig2.maxTextureUnits ) + if ( unit < 0 || unit >= glConfig.maxTextureUnits ) { Sys::Drop( "GL_BindToTMU: unit %i is out of range\n", unit ); } @@ -625,7 +625,7 @@ static void GL_VertexAttribPointers( uint32_t attribBits, const bool settingUpVA GLIMP_LOGCOMMENT( "--- GL_VertexAttribPointers( %s ) ---", glState.currentVBO->name ); - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { attribBits |= ATTR_BONE_FACTORS; } @@ -680,7 +680,7 @@ void GL_VertexAttribsState( uint32_t stateBits, const bool settingUpVAO ) return; } - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { stateBits |= ATTR_BONE_FACTORS; } @@ -896,10 +896,10 @@ static void RB_SetGL2D() backEnd.projection2D = true; // set 2D virtual screen size - GL_Viewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); - GL_Scissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + GL_Viewport( 0, 0, windowConfig.vidWidth, windowConfig.vidHeight ); + GL_Scissor( 0, 0, windowConfig.vidWidth, windowConfig.vidHeight ); - MatrixOrthogonalProjection( proj, 0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1 ); + MatrixOrthogonalProjection( proj, 0, windowConfig.vidWidth, windowConfig.vidHeight, 0, 0, 1 ); // zero the z coordinate so it's never near/far clipped proj[ 2 ] = proj[ 6 ] = proj[ 10 ] = proj[ 14 ] = 0; @@ -1234,8 +1234,8 @@ static void RenderDepthTiles() gl_depthtile1Shader->BindProgram( 0 ); vec3_t zParams; - zParams[ 0 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_x * 0.5f) ) / glConfig.vidWidth; - zParams[ 1 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_y * 0.5f) ) / glConfig.vidHeight; + zParams[ 0 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_x * 0.5f) ) / windowConfig.vidWidth; + zParams[ 1 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_y * 0.5f) ) / windowConfig.vidHeight; zParams[ 2 ] = backEnd.viewParms.zFar; gl_depthtile1Shader->SetUniform_zFar( zParams ); @@ -1273,7 +1273,7 @@ static void RenderDepthTiles() void RB_RenderPostDepthLightTile() { - if ( !glConfig2.realtimeLighting ) + if ( !glConfig.realtimeLighting ) { return; } @@ -1311,7 +1311,7 @@ void RB_RenderPostDepthLightTile() R_BindVBO( tr.lighttileVBO ); - for( int layer = 0; layer < glConfig2.realtimeLightLayers; layer++ ) { + for( int layer = 0; layer < glConfig.realtimeLightLayers; layer++ ) { R_AttachFBOTexture3D( tr.lighttileRenderImage->texnum, 0, layer ); gl_lighttileShader->SetUniform_lightLayer( layer ); @@ -1320,7 +1320,7 @@ void RB_RenderPostDepthLightTile() tess.numVertexes = tr.lighttileVBO->vertexesNum; GL_VertexAttribsState( ATTR_POSITION | ATTR_TEXCOORD ); - if( !glConfig2.glCoreProfile ) + if( !glConfig.glCoreProfile ) glEnable( GL_POINT_SPRITE ); glEnable( GL_PROGRAM_POINT_SIZE ); @@ -1328,7 +1328,7 @@ void RB_RenderPostDepthLightTile() Tess_DrawArrays( GL_POINTS ); glDisable( GL_PROGRAM_POINT_SIZE ); - if( !glConfig2.glCoreProfile ) + if( !glConfig.glCoreProfile ) glDisable( GL_POINT_SPRITE ); } @@ -1414,7 +1414,7 @@ void RB_RenderGlobalFog() void RB_RenderBloom() { if ( ( backEnd.refdef.rdflags & ( RDF_NOWORLDMODEL | RDF_NOBLOOM ) ) - || !glConfig2.bloom || backEnd.viewParms.portalLevel > 0 ) { + || !glConfig.bloom || backEnd.viewParms.portalLevel > 0 ) { return; } @@ -1500,7 +1500,7 @@ void RB_RenderBloom() void RB_RenderMotionBlur() { - if ( !glConfig2.motionBlur || ( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) + if ( !glConfig.motionBlur || ( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) || backEnd.viewParms.portalLevel > 0 ) { return; @@ -1533,7 +1533,7 @@ void RB_RenderMotionBlur() void RB_RenderSSAO() { - if ( !glConfig2.ssao ) + if ( !glConfig.ssao ) { return; } @@ -1547,7 +1547,7 @@ void RB_RenderSSAO() GLIMP_LOGCOMMENT( "--- RB_RenderSSAO ---" ); // Assume depth is dirty since we just rendered depth pass and everything opaque - if ( glConfig2.textureBarrierAvailable ) + if ( glConfig.textureBarrierAvailable ) { glTextureBarrier(); backEnd.dirtyDepthBuffer = false; @@ -1556,7 +1556,7 @@ void RB_RenderSSAO() GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO ); GL_Cull( cullType_t::CT_TWO_SIDED ); - if ( glConfig2.ssao && r_ssao.Get() == Util::ordinal( ssaoMode::SHOW ) ) { + if ( glConfig.ssao && r_ssao.Get() == Util::ordinal( ssaoMode::SHOW ) ) { // clear the screen to show only SSAO GL_ClearColor( 1.0, 1.0, 1.0, 1.0 ); glClear( GL_COLOR_BUFFER_BIT ); @@ -1565,8 +1565,8 @@ void RB_RenderSSAO() gl_ssaoShader->BindProgram( 0 ); vec3_t zParams; - zParams[ 0 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_x * 0.5f ) ) / glConfig.vidWidth; - zParams[ 1 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_y * 0.5f ) ) / glConfig.vidHeight; + zParams[ 0 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_x * 0.5f ) ) / windowConfig.vidWidth; + zParams[ 1 ] = 2.0f * tanf( DEG2RAD( backEnd.refdef.fov_y * 0.5f ) ) / windowConfig.vidHeight; zParams[ 2 ] = backEnd.viewParms.zFar; gl_ssaoShader->SetUniform_zFar( zParams ); @@ -1669,7 +1669,7 @@ void RB_CameraPostFX() { gl_cameraEffectsShader->SetUniform_SRGB( tr.worldLinearizeTexture ); - const bool tonemap = r_toneMapping.Get() && r_highPrecisionRendering.Get() && glConfig2.textureFloatAvailable; + const bool tonemap = r_toneMapping.Get() && r_highPrecisionRendering.Get() && glConfig.textureFloatAvailable; if ( tonemap ) { vec4_t tonemapParms { r_toneMappingContrast.Get(), r_toneMappingHighlightsCompressionSpeed.Get() }; ComputeTonemapParams( tonemapParms[0], tonemapParms[1], r_toneMappingHDRMax.Get(), @@ -1686,7 +1686,7 @@ void RB_CameraPostFX() { GL_BindToTMU( 0, tr.currentRenderImage[backEnd.currentMainFBO] ) ); - if ( glConfig2.colorGrading ) { + if ( glConfig.colorGrading ) { gl_cameraEffectsShader->SetUniform_ColorMap3DBindless( GL_BindToTMU( 3, tr.colorGradeImage ) ); } @@ -1997,7 +1997,7 @@ static void RB_RenderDebugUtils() } // GLSL shader isn't built when reflection mapping is disabled. - if ( r_showCubeProbes.Get() && glConfig2.reflectionMapping && + if ( r_showCubeProbes.Get() && glConfig.reflectionMapping && !( backEnd.refdef.rdflags & ( RDF_NOWORLDMODEL | RDF_NOCUBEMAP ) ) ) { static const vec3_t mins = { -8, -8, -8 }; @@ -2674,7 +2674,7 @@ static void RB_RenderView( bool depthPass ) GL_CheckErrors(); if( depthPass ) { - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.RenderMaterials( shaderSort_t::SS_DEPTH, shaderSort_t::SS_DEPTH, backEnd.viewParms.viewID ); } RB_RenderDrawSurfaces( shaderSort_t::SS_DEPTH, shaderSort_t::SS_DEPTH, DRAWSURFACES_ALL ); @@ -2691,7 +2691,7 @@ static void RB_RenderView( bool depthPass ) tr.refdef.blurVec[2] != 0.0f ) { // draw everything that is not the gun - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.RenderMaterials( shaderSort_t::SS_ENVIRONMENT_FOG, shaderSort_t::SS_OPAQUE, backEnd.viewParms.viewID ); } RB_RenderDrawSurfaces( shaderSort_t::SS_ENVIRONMENT_FOG, shaderSort_t::SS_OPAQUE, DRAWSURFACES_ALL_FAR ); @@ -2704,7 +2704,7 @@ static void RB_RenderView( bool depthPass ) else { // draw everything that is opaque - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.RenderMaterials( shaderSort_t::SS_ENVIRONMENT_FOG, shaderSort_t::SS_OPAQUE, backEnd.viewParms.viewID ); } RB_RenderDrawSurfaces( shaderSort_t::SS_ENVIRONMENT_FOG, shaderSort_t::SS_OPAQUE, DRAWSURFACES_ALL ); @@ -2716,7 +2716,7 @@ static void RB_RenderView( bool depthPass ) RB_RenderGlobalFog(); // draw everything that is translucent - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.RenderMaterials( shaderSort_t::SS_ENVIRONMENT_NOFOG, shaderSort_t::SS_POST_PROCESS, backEnd.viewParms.viewID ); // HACK: assume surfaces with depth fade don't use the material system @@ -2761,7 +2761,7 @@ This is done so various debugging facilities will work properly */ static void RB_RenderPostProcess() { - if ( glConfig2.usingMaterialSystem && !r_materialSystemSkip.Get() ) { + if ( glConfig.usingMaterialSystem && !r_materialSystemSkip.Get() ) { // Dispatch the cull compute shaders for queued once we're done with post-processing // We'll only use the results from those shaders in the next frame so we don't block the pipeline materialSystem.CullSurfaces(); @@ -2826,7 +2826,7 @@ void RE_UploadCinematic( int cols, int rows, const byte *data, int client, bool glTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, Color::Black.ToArray() ); // Getting bindless handle makes the texture immutable, so generate it again because we used glTexParameter* - if ( glConfig2.usingBindlessTextures ) { + if ( glConfig.usingBindlessTextures ) { tr.cinematicImage[ client ]->texture->GenBindlessHandle(); } } @@ -3328,7 +3328,7 @@ RB_SetupLights const RenderCommand *SetupLightsCommand::ExecuteSelf( ) const { int numLights; - GLenum bufferTarget = glConfig2.uniformBufferObjectAvailable ? GL_UNIFORM_BUFFER : GL_PIXEL_UNPACK_BUFFER; + GLenum bufferTarget = glConfig.uniformBufferObjectAvailable ? GL_UNIFORM_BUFFER : GL_PIXEL_UNPACK_BUFFER; GLIMP_LOGCOMMENT( "--- SetupLightsCommand::ExecuteSelf ---" ); @@ -3682,8 +3682,8 @@ void RB_ShowImages() } */ - w = glConfig.vidWidth / 20; - h = glConfig.vidHeight / 15; + w = windowConfig.vidWidth / 20; + h = windowConfig.vidHeight / 15; x = i % 20 * w; y = i / 20 * h; diff --git a/src/engine/renderer/tr_bsp.cpp b/src/engine/renderer/tr_bsp.cpp index 95c9b39f01..e2d4592eab 100644 --- a/src/engine/renderer/tr_bsp.cpp +++ b/src/engine/renderer/tr_bsp.cpp @@ -2635,7 +2635,7 @@ static void R_CreateWorldVBO() { // HACK: portals: don't use VBO because when adding a portal we have to read back the verts CPU-side // Autosprite: don't use VBO because verts are rewritten each time based on view origin if ( surface->shader->isPortal || surface->shader->autoSpriteMode != 0 ) { - if( glConfig2.usingMaterialSystem ) { + if( glConfig.usingMaterialSystem ) { materialSystem.autospriteSurfaces.push_back( surface ); } @@ -2645,7 +2645,7 @@ static void R_CreateWorldVBO() { continue; } - if ( glConfig2.usingMaterialSystem && surface->shader->isSky ) { + if ( glConfig.usingMaterialSystem && surface->shader->isSky ) { if ( std::find( materialSystem.skyShaders.begin(), materialSystem.skyShaders.end(), surface->shader ) == materialSystem.skyShaders.end() ) { materialSystem.skyShaders.emplace_back( surface->shader ); @@ -2713,7 +2713,7 @@ static void R_CreateWorldVBO() { } portal++; - if( glConfig2.usingMaterialSystem ) { + if( glConfig.usingMaterialSystem ) { MaterialSurface srf{}; srf.shader = surface->shader; @@ -2761,7 +2761,7 @@ static void R_CreateWorldVBO() { int numIndices; MergeDuplicateVertices( rendererSurfaces, numSurfaces, vboVerts, numVertsInitial, vboIdxs, 3 * numTriangles, numVerts, numIndices ); - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { OptimiseMapGeometryMaterial( &s_worldData, rendererSurfaces, numSurfaces, vboVerts, numVerts, vboIdxs, numIndices ); } @@ -3415,11 +3415,11 @@ R_LoadLightGrid */ void R_LoadLightGrid( lump_t *l ) { - if ( glConfig2.max3DTextureSize == 0 ) + if ( glConfig.max3DTextureSize == 0 ) { Log::Warn( "Grid lighting disabled because of missing 3D texture support." ); - if ( glConfig2.deluxeMapping ) + if ( glConfig.deluxeMapping ) { Log::Warn( "Grid deluxe mapping disabled because of missing 3D texture support." ); } @@ -3827,7 +3827,7 @@ void R_LoadEntities( lump_t *l, std::string &externalEntities ) { Log::Debug("map features directional light mapping" ); // This will be disabled if the engine fails to load the lightmaps. - tr.worldDeluxeMapping = glConfig2.deluxeMapping; + tr.worldDeluxeMapping = glConfig.deluxeMapping; continue; } @@ -3850,7 +3850,7 @@ void R_LoadEntities( lump_t *l, std::string &externalEntities ) { Log::Debug("map features directional light mapping" ); // This will be disabled if the engine fails to load the lightmaps. - tr.worldDeluxeMapping = glConfig2.deluxeMapping; + tr.worldDeluxeMapping = glConfig.deluxeMapping; } bool sRGBtex = false; @@ -4235,14 +4235,14 @@ void R_BuildCubeMaps() return; } - if ( !glConfig2.reflectionMappingAvailable ) { + if ( !glConfig.reflectionMappingAvailable ) { Log::Notice( "Unable to build reflection cubemaps due to incorrect graphics settings" ); return; } const int cubeMapSize = r_cubeProbeSize.Get(); - if ( cubeMapSize > glConfig2.maxCubeMapTextureSize ) { - Log::Warn( "Cube probe size exceeds max cubemap texture size (%i/%i)", cubeMapSize, glConfig2.maxCubeMapTextureSize ); + if ( cubeMapSize > glConfig.maxCubeMapTextureSize ) { + Log::Warn( "Cube probe size exceeds max cubemap texture size (%i/%i)", cubeMapSize, glConfig.maxCubeMapTextureSize ); return; } @@ -4258,7 +4258,7 @@ void R_BuildCubeMaps() tr.cubeProbes.push_back( defaultCubeProbe ); if ( r_autoBuildCubeMaps.Get() == Util::ordinal( cubeProbesAutoBuildMode::CACHED ) && R_LoadCubeMaps() ) { - glConfig2.reflectionMapping = true; + glConfig.reflectionMapping = true; return; } @@ -4467,7 +4467,7 @@ void R_BuildCubeMaps() int msecUnused1; int msecUnused2; // Material system writes culled surfaces for the next frame, so we need to render twice with it to cull correctly - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { tr.refdef.pixelTarget = nullptr; RE_BeginFrame(); @@ -4544,7 +4544,7 @@ void R_BuildCubeMaps() // turn pixel targets off tr.refdef.pixelTarget = nullptr; - glConfig2.reflectionMapping = true; + glConfig.reflectionMapping = true; const int endTime = ri.Milliseconds(); Log::Notice( "Cubemap probes pre-rendering time of %d cubes = %5.2f seconds", tr.cubeProbes.size(), @@ -4612,7 +4612,7 @@ static void SetWorldLight() { tr.modelLight = lightMode_t::GRID; } - if ( glConfig2.deluxeMapping ) { + if ( glConfig.deluxeMapping ) { // Enable deluxe mapping emulation if light direction grid is there. if ( tr.lightGrid2Image ) { // Game model surfaces use grid lighting, they don't have vertex light colors. @@ -4716,7 +4716,7 @@ void RE_LoadWorldMap( const char *name ) ( ( int * ) header ) [ j ] = LittleLong( ( ( int * ) header ) [ j ] ); } - if ( glConfig2.reflectionMappingAvailable ) { + if ( glConfig.reflectionMappingAvailable ) { // TODO: Take into account potential shader changes headerString = Str::Format( "%i %i %i %i %i", header->lumps[LUMP_PLANES].filelen, header->lumps[LUMP_NODES].filelen, header->lumps[LUMP_LEAFS].filelen, header->lumps[LUMP_BRUSHES].filelen, header->lumps[LUMP_SURFACES].filelen ); @@ -4790,7 +4790,7 @@ void RE_LoadWorldMap( const char *name ) tr.loadingMap = ""; GLSL_InitWorldShaders(); - if ( glConfig2.reflectionMappingAvailable ) { + if ( glConfig.reflectionMappingAvailable ) { tr.cubeProbeSpacing = r_cubeProbeSpacing.Get(); vec3_t worldSize; diff --git a/src/engine/renderer/tr_cmds.cpp b/src/engine/renderer/tr_cmds.cpp index d97badb484..0dd9c83371 100644 --- a/src/engine/renderer/tr_cmds.cpp +++ b/src/engine/renderer/tr_cmds.cpp @@ -224,7 +224,7 @@ R_AddSetupLightsCmd */ void R_AddSetupLightsCmd() { - if ( !glConfig2.realtimeLighting ) + if ( !glConfig.realtimeLighting ) { return; } @@ -381,7 +381,7 @@ void RE_SetColorGrading( int slot, qhandle_t hShader ) shader_t *shader = R_GetShaderByHandle( hShader ); image_t *image; - if ( !glConfig2.colorGrading ) + if ( !glConfig.colorGrading ) { return; } @@ -636,7 +636,7 @@ void RE_ScissorEnable( bool enable ) // scissor disable sets scissor to full screen // scissor enable is a no-op if( !enable ) { - RE_ScissorSet( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + RE_ScissorSet( 0, 0, windowConfig.vidWidth, windowConfig.vidHeight ); } } diff --git a/src/engine/renderer/tr_fbo.cpp b/src/engine/renderer/tr_fbo.cpp index 82e057c18e..cc7b42b37d 100644 --- a/src/engine/renderer/tr_fbo.cpp +++ b/src/engine/renderer/tr_fbo.cpp @@ -104,12 +104,12 @@ FBO_t *R_CreateFBO( const char *name, int width, int height ) Sys::Drop( "R_CreateFBO: \"%s\" is too long", name ); } - if ( width <= 0 || width > glConfig2.maxRenderbufferSize ) + if ( width <= 0 || width > glConfig.maxRenderbufferSize ) { Sys::Drop( "R_CreateFBO: bad width %i", width ); } - if ( height <= 0 || height > glConfig2.maxRenderbufferSize ) + if ( height <= 0 || height > glConfig.maxRenderbufferSize ) { Sys::Drop( "R_CreateFBO: bad height %i", height ); } @@ -141,7 +141,7 @@ void R_CreateFBOColorBuffer( FBO_t *fbo, int format, int index ) { bool absent; - if ( index < 0 || index >= glConfig2.maxColorAttachments ) + if ( index < 0 || index >= glConfig.maxColorAttachments ) { Log::Warn("R_CreateFBOColorBuffer: invalid attachment index %i", index ); return; @@ -288,7 +288,7 @@ R_AttachFBOTexture1D */ void R_AttachFBOTexture1D( int texId, int index ) { - if ( index < 0 || index >= glConfig2.maxColorAttachments ) + if ( index < 0 || index >= glConfig.maxColorAttachments ) { Log::Warn("R_AttachFBOTexture1D: invalid attachment index %i", index ); return; @@ -310,7 +310,7 @@ void R_AttachFBOTexture2D( int target, int texId, int index ) return; } - if ( index < 0 || index >= glConfig2.maxColorAttachments ) + if ( index < 0 || index >= glConfig.maxColorAttachments ) { Log::Warn("R_AttachFBOTexture2D: invalid attachment index %i", index ); return; @@ -326,7 +326,7 @@ R_AttachFBOTexture3D */ void R_AttachFBOTexture3D( int texId, int index, int zOffset ) { - if ( index < 0 || index >= glConfig2.maxColorAttachments ) + if ( index < 0 || index >= glConfig.maxColorAttachments ) { Log::Warn("R_AttachFBOTexture3D: invalid attachment index %i", index ); return; @@ -415,8 +415,8 @@ void R_InitFBOs() // make sure the render thread is stopped R_SyncRenderThread(); - width = glConfig.vidWidth; - height = glConfig.vidHeight; + width = windowConfig.vidWidth; + height = windowConfig.vidHeight; tr.mainFBO[0] = R_CreateFBO( "_main[0]", width, height ); R_BindFBO( tr.mainFBO[0] ); @@ -430,7 +430,7 @@ void R_InitFBOs() R_AttachFBOTexturePackedDepthStencil( tr.currentDepthImage->texnum ); R_CheckFBO( tr.mainFBO[1] ); - if ( glConfig2.realtimeLighting ) + if ( glConfig.realtimeLighting ) { /* It's only required to create frame buffers only used by the tiled dynamic lighting renderer when this feature is enabled. */ @@ -452,8 +452,8 @@ void R_InitFBOs() } { - width = glConfig.vidWidth; - height = glConfig.vidHeight; + width = windowConfig.vidWidth; + height = windowConfig.vidHeight; // portalRender FBO for portals, mirrors, water, cameras et cetera tr.portalRenderFBO = R_CreateFBO( "_portalRender", width, height ); @@ -464,10 +464,10 @@ void R_InitFBOs() R_CheckFBO( tr.portalRenderFBO ); } - if ( glConfig2.bloom ) + if ( glConfig.bloom ) { - width = glConfig.vidWidth * 0.25f; - height = glConfig.vidHeight * 0.25f; + width = windowConfig.vidWidth * 0.25f; + height = windowConfig.vidHeight * 0.25f; tr.contrastRenderFBO = R_CreateFBO( "_contrastRender", width, height ); R_BindFBO( tr.contrastRenderFBO ); @@ -510,7 +510,7 @@ void R_ShutdownFBOs() { fbo = tr.fbos[ i ]; - for ( j = 0; j < glConfig2.maxColorAttachments; j++ ) + for ( j = 0; j < glConfig.maxColorAttachments; j++ ) { if ( fbo->colorBuffers[ j ] ) { diff --git a/src/engine/renderer/tr_image.cpp b/src/engine/renderer/tr_image.cpp index 38aacc23cb..a22a0d9890 100644 --- a/src/engine/renderer/tr_image.cpp +++ b/src/engine/renderer/tr_image.cpp @@ -115,7 +115,7 @@ void GL_TextureMode( const char *string ) gl_filter_min = modes[ i ].minimize; gl_filter_max = modes[ i ].maximize; - if ( glConfig2.usingBindlessTextures && !tr.images.empty() ) + if ( glConfig.usingBindlessTextures && !tr.images.empty() ) { Log::Notice( "Changing filter type of existing bindless textures requires a restart" ); return; @@ -133,9 +133,9 @@ void GL_TextureMode( const char *string ) glTexParameterf( image->type, GL_TEXTURE_MAG_FILTER, gl_filter_max ); // set texture anisotropy - if ( glConfig2.textureAnisotropyAvailable ) + if ( glConfig.textureAnisotropyAvailable ) { - glTexParameterf( image->type, GL_TEXTURE_MAX_ANISOTROPY_EXT, glConfig2.textureAnisotropy ); + glTexParameterf( image->type, GL_TEXTURE_MAX_ANISOTROPY_EXT, glConfig.textureAnisotropy ); } } } @@ -880,7 +880,7 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int // deal with a half mip resampling if ( image->type == GL_TEXTURE_CUBE_MAP ) { - while ( scaledWidth > glConfig2.maxCubeMapTextureSize || scaledHeight > glConfig2.maxCubeMapTextureSize ) + while ( scaledWidth > glConfig.maxCubeMapTextureSize || scaledHeight > glConfig.maxCubeMapTextureSize ) { scaledWidth >>= 1; scaledHeight >>= 1; @@ -935,7 +935,7 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int } else if ( image->bits & ( IF_RGBA16F | IF_RGBA32F | IF_TWOCOMP16F | IF_TWOCOMP32F | IF_ONECOMP16F | IF_ONECOMP32F ) ) { - if( !glConfig2.textureFloatAvailable ) { + if( !glConfig.textureFloatAvailable ) { Log::Warn("floating point image '%s' cannot be loaded", image->name ); internalFormat = GL_RGBA8; } @@ -949,28 +949,28 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int } else if ( image->bits & IF_TWOCOMP16F ) { - internalFormat = glConfig2.textureRGAvailable ? + internalFormat = glConfig.textureRGAvailable ? GL_RG16F : GL_LUMINANCE_ALPHA16F_ARB; } else if ( image->bits & IF_TWOCOMP32F ) { - internalFormat = glConfig2.textureRGAvailable ? + internalFormat = glConfig.textureRGAvailable ? GL_RG32F : GL_LUMINANCE_ALPHA32F_ARB; } else if ( image->bits & IF_ONECOMP16F ) { - internalFormat = glConfig2.textureRGAvailable ? + internalFormat = glConfig.textureRGAvailable ? GL_R16F : GL_ALPHA16F_ARB; } else if ( image->bits & IF_ONECOMP32F ) { - internalFormat = glConfig2.textureRGAvailable ? + internalFormat = glConfig.textureRGAvailable ? GL_R32F : GL_ALPHA32F_ARB; } } else if ( image->bits & ( IF_RGBA32UI ) ) { - if( !glConfig2.textureIntegerAvailable ) { + if( !glConfig.textureIntegerAvailable ) { Log::Warn( "integer image '%s' cannot be loaded", image->name ); } internalFormat = GL_RGBA32UI; @@ -999,7 +999,7 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int blockSize = 16; } else if ( image->bits & IF_BC4 ) { - if( !glConfig2.textureCompressionRGTCAvailable ) { + if( !glConfig.textureCompressionRGTCAvailable ) { format = GL_NONE; internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; blockSize = 8; @@ -1015,7 +1015,7 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int } } else if ( image->bits & IF_BC5 ) { - if( !glConfig2.textureCompressionRGTCAvailable ) { + if( !glConfig.textureCompressionRGTCAvailable ) { format = GL_NONE; internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; blockSize = 16; @@ -1222,9 +1222,9 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int case filterType_t::FT_DEFAULT: // set texture anisotropy - if ( glConfig2.textureAnisotropyAvailable ) + if ( glConfig.textureAnisotropyAvailable ) { - glTexParameterf( image->type, GL_TEXTURE_MAX_ANISOTROPY_EXT, glConfig2.textureAnisotropy ); + glTexParameterf( image->type, GL_TEXTURE_MAX_ANISOTROPY_EXT, glConfig.textureAnisotropy ); } glTexParameterf( image->type, GL_TEXTURE_MIN_FILTER, gl_filter_min ); @@ -2484,13 +2484,13 @@ static void R_CreateDefaultImage() static void R_CreateContrastRenderFBOImage() { - if ( !glConfig2.bloom) + if ( !glConfig.bloom) { return; } - const int width = glConfig.vidWidth * 0.25f; - const int height = glConfig.vidHeight * 0.25f; + const int width = windowConfig.vidWidth * 0.25f; + const int height = windowConfig.vidHeight * 0.25f; imageParams_t imageParams = {}; imageParams.bits = IF_NOPICMIP; @@ -2502,13 +2502,13 @@ static void R_CreateContrastRenderFBOImage() static void R_CreateBloomRenderFBOImages() { - if ( !glConfig2.bloom) + if ( !glConfig.bloom) { return; } - const int width = glConfig.vidWidth * 0.25f; - const int height = glConfig.vidHeight * 0.25f; + const int width = windowConfig.vidWidth * 0.25f; + const int height = windowConfig.vidHeight * 0.25f; for ( int i = 0; i < 2; i++ ) { @@ -2525,15 +2525,15 @@ static void R_CreateCurrentRenderImage() { int width, height; - width = glConfig.vidWidth; - height = glConfig.vidHeight; + width = windowConfig.vidWidth; + height = windowConfig.vidHeight; imageParams_t imageParams = {}; imageParams.bits = IF_NOPICMIP; if ( r_highPrecisionRendering.Get() ) { - if ( !glConfig2.textureFloatAvailable ) + if ( !glConfig.textureFloatAvailable ) { Log::Warn( "High-precision current render disabled because RGBA16F framebuffer is not available" ); } @@ -2562,23 +2562,23 @@ static void R_CreateCurrentRenderImage() tr.currentDepthImage = R_CreateImage( "_currentDepth", nullptr, width, height, 1, imageParams ); - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.GenerateDepthImages( width, height, imageParams ); } } static void R_CreateDepthRenderImage() { - if ( !glConfig2.realtimeLighting ) + if ( !glConfig.realtimeLighting ) { return; } - ASSERT( glConfig2.textureFloatAvailable ); + ASSERT( glConfig.textureFloatAvailable ); { - int width = glConfig.vidWidth; - int height = glConfig.vidHeight; + int width = windowConfig.vidWidth; + int height = windowConfig.vidHeight; int w = (width + TILE_SIZE_STEP1 - 1) >> TILE_SHIFT_STEP1; int h = (height + TILE_SIZE_STEP1 - 1) >> TILE_SHIFT_STEP1; @@ -2601,7 +2601,7 @@ static void R_CreateDepthRenderImage() imageParams.bits = IF_NOPICMIP | IF_RGBA32UI; - tr.lighttileRenderImage = R_Create3DImage( "_lighttileRender", nullptr, w, h, glConfig2.realtimeLightLayers, imageParams ); + tr.lighttileRenderImage = R_Create3DImage( "_lighttileRender", nullptr, w, h, glConfig.realtimeLightLayers, imageParams ); } } @@ -2609,8 +2609,8 @@ static void R_CreatePortalRenderImage() { int width, height; - width = glConfig.vidWidth; - height = glConfig.vidHeight; + width = windowConfig.vidWidth; + height = windowConfig.vidHeight; imageParams_t imageParams = {}; imageParams.bits = IF_NOPICMIP; @@ -2675,7 +2675,7 @@ static void R_CreateWhiteCubeImage() static void R_CreateColorGradeImage() { - if ( !glConfig2.colorGrading ) + if ( !glConfig.colorGrading ) { return; } diff --git a/src/engine/renderer/tr_init.cpp b/src/engine/renderer/tr_init.cpp index 84ebca0a37..d79bf183f8 100644 --- a/src/engine/renderer/tr_init.cpp +++ b/src/engine/renderer/tr_init.cpp @@ -38,8 +38,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA } #endif - glconfig_t glConfig; - glconfig2_t glConfig2; + WindowConfig windowConfig; + GLConfig glConfig; glstate_t glState; @@ -331,15 +331,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // - r_(color|depth|stencil)bits // - if ( glConfig.vidWidth == 0 ) + if ( windowConfig.vidWidth == 0 ) { if ( !GLimp_Init() ) { return false; } - glState.tileStep[ 0 ] = TILE_SIZE * ( 1.0f / glConfig.vidWidth ); - glState.tileStep[ 1 ] = TILE_SIZE * ( 1.0f / glConfig.vidHeight ); + glState.tileStep[ 0 ] = TILE_SIZE * ( 1.0f / windowConfig.vidWidth ); + glState.tileStep[ 1 ] = TILE_SIZE * ( 1.0f / windowConfig.vidHeight ); GL_CheckErrors(); @@ -373,7 +373,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA GLSL_InitGPUShaders(); } - if ( glConfig2.glCoreProfile ) { + if ( glConfig.glCoreProfile ) { glGenVertexArrays( 1, &backEnd.defaultVAO ); GL_BindVAO( backEnd.defaultVAO ); } @@ -678,8 +678,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA cmd->x = 0; cmd->y = 0; - cmd->width = glConfig.vidWidth; - cmd->height = glConfig.vidHeight; + cmd->width = windowConfig.vidWidth; + cmd->height = windowConfig.vidHeight; Q_strncpyz(cmd->fileName, path.c_str(), sizeof(cmd->fileName)); cmd->format = format; @@ -833,7 +833,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p GL_CheckErrors(); - tr.currenttextures.resize( glConfig2.maxTextureUnits ); + tr.currenttextures.resize( glConfig.maxTextureUnits ); GL_TextureMode( r_textureMode.Get().c_str() ); r_textureMode.GetModifiedValue(); @@ -910,71 +910,71 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p }; Log::Notice( "%sOpenGL hardware vendor: %s", - Color::ToString( Util::ordinal(glConfig2.hardwareVendor) ? Color::Green : Color::Yellow ), - GetGLHardwareVendorName( glConfig2.hardwareVendor ) ); + Color::ToString( Util::ordinal(glConfig.hardwareVendor) ? Color::Green : Color::Yellow ), + GetGLHardwareVendorName( glConfig.hardwareVendor ) ); Log::Notice( "%sOpenGL driver vendor: %s", - Color::ToString( Util::ordinal(glConfig2.driverVendor) ? Color::Green : Color::Yellow ), - GetGLDriverVendorName( glConfig2.driverVendor ) ); + Color::ToString( Util::ordinal(glConfig.driverVendor) ? Color::Green : Color::Yellow ), + GetGLDriverVendorName( glConfig.driverVendor ) ); Log::Notice("GL_VENDOR: %s", glConfig.vendor_string ); Log::Notice("GL_RENDERER: %s", glConfig.renderer_string ); Log::Notice("GL_VERSION: %s", glConfig.version_string ); - Log::Debug("GL_EXTENSIONS: %s", glConfig2.glExtensionsString ); + Log::Debug("GL_EXTENSIONS: %s", glConfig.glExtensionsString ); Log::Notice("GL_MAX_TEXTURE_SIZE: %d", glConfig.maxTextureSize ); - Log::Notice("GL_MAX_3D_TEXTURE_SIZE: %d", glConfig2.max3DTextureSize ); - Log::Notice("GL_MAX_CUBE_MAP_TEXTURE_SIZE: %d", glConfig2.maxCubeMapTextureSize ); - Log::Notice("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: %d", glConfig2.maxTextureUnits ); + Log::Notice("GL_MAX_3D_TEXTURE_SIZE: %d", glConfig.max3DTextureSize ); + Log::Notice("GL_MAX_CUBE_MAP_TEXTURE_SIZE: %d", glConfig.maxCubeMapTextureSize ); + Log::Notice("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: %d", glConfig.maxTextureUnits ); - Log::Notice("GL_SHADING_LANGUAGE_VERSION: %s", glConfig2.shadingLanguageVersionString ); + Log::Notice("GL_SHADING_LANGUAGE_VERSION: %s", glConfig.shadingLanguageVersionString ); - Log::Notice("GL_MAX_VERTEX_UNIFORM_COMPONENTS %d", glConfig2.maxVertexUniforms ); - Log::Notice("GL_MAX_VERTEX_ATTRIBS %d", glConfig2.maxVertexAttribs ); + Log::Notice("GL_MAX_VERTEX_UNIFORM_COMPONENTS %d", glConfig.maxVertexUniforms ); + Log::Notice("GL_MAX_VERTEX_ATTRIBS %d", glConfig.maxVertexAttribs ); - if ( !glConfig2.glCoreProfile ) + if ( !glConfig.glCoreProfile ) { - Log::Notice( "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: %d", glConfig2.maxAluInstructions ); - Log::Notice( "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: %d", glConfig2.maxTexIndirections ); + Log::Notice( "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: %d", glConfig.maxAluInstructions ); + Log::Notice( "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: %d", glConfig.maxTexIndirections ); } - if ( glConfig2.drawBuffersAvailable ) + if ( glConfig.drawBuffersAvailable ) { - Log::Notice("GL_MAX_DRAW_BUFFERS: %d", glConfig2.maxDrawBuffers ); + Log::Notice("GL_MAX_DRAW_BUFFERS: %d", glConfig.maxDrawBuffers ); } - if ( glConfig2.textureAnisotropyAvailable ) + if ( glConfig.textureAnisotropyAvailable ) { - Log::Notice("GL_TEXTURE_MAX_ANISOTROPY_EXT: %f", glConfig2.maxTextureAnisotropy ); + Log::Notice("GL_TEXTURE_MAX_ANISOTROPY_EXT: %f", glConfig.maxTextureAnisotropy ); } - Log::Notice("GL_MAX_RENDERBUFFER_SIZE: %d", glConfig2.maxRenderbufferSize ); - Log::Notice("GL_MAX_COLOR_ATTACHMENTS: %d", glConfig2.maxColorAttachments ); + Log::Notice("GL_MAX_RENDERBUFFER_SIZE: %d", glConfig.maxRenderbufferSize ); + Log::Notice("GL_MAX_COLOR_ATTACHMENTS: %d", glConfig.maxColorAttachments ); Log::Notice("PIXELFORMAT: color(%d-bits)", glConfig.colorBits ); Log::Notice("MODE: %d, %d x %d %s", r_mode->integer, - glConfig.vidWidth, glConfig.vidHeight, + windowConfig.vidWidth, windowConfig.vidHeight, fsstrings[ +r_fullscreen.Get() ] ); if ( !!r_glExtendedValidation->integer ) { Log::Notice("Using OpenGL version %d.%d, requested: %d.%d, highest: %d.%d", - glConfig2.glMajor, glConfig2.glMinor, glConfig2.glRequestedMajor, glConfig2.glRequestedMinor, - glConfig2.glHighestMajor, glConfig2.glHighestMinor ); + glConfig.glMajor, glConfig.glMinor, glConfig.glRequestedMajor, glConfig.glRequestedMinor, + glConfig.glHighestMajor, glConfig.glHighestMinor ); } else { - Log::Notice("Using OpenGL version %d.%d, requested: %d.%d", glConfig2.glMajor, glConfig2.glMinor, glConfig2.glRequestedMajor, glConfig2.glRequestedMinor ); + Log::Notice("Using OpenGL version %d.%d, requested: %d.%d", glConfig.glMajor, glConfig.glMinor, glConfig.glRequestedMajor, glConfig.glRequestedMinor ); } - if ( std::make_pair( glConfig2.glMajor, glConfig2.glMinor ) >= std::make_pair( 3, 2 ) ) + if ( std::make_pair( glConfig.glMajor, glConfig.glMinor ) >= std::make_pair( 3, 2 ) ) { /* See https://www.khronos.org/opengl/wiki/OpenGL_Context for information about core, compatibility and forward context. */ - if ( glConfig2.glCoreProfile ) + if ( glConfig.glCoreProfile ) { Log::Notice("%sUsing an OpenGL core profile.", Color::ToString( Color::Green ) ); } @@ -984,7 +984,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p } } - if ( glConfig2.glForwardCompatibleContext ) + if ( glConfig.glForwardCompatibleContext ) { Log::Notice("OpenGL context is forward compatible."); } @@ -993,17 +993,17 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p Log::Notice("OpenGL context is not forward compatible."); } - if ( glConfig2.glEnabledExtensionsString.length() != 0 ) + if ( glConfig.glEnabledExtensionsString.length() != 0 ) { - Log::Notice("%sUsing OpenGL extensions: %s", Color::ToString( Color::Green ), glConfig2.glEnabledExtensionsString ); + Log::Notice("%sUsing OpenGL extensions: %s", Color::ToString( Color::Green ), glConfig.glEnabledExtensionsString ); } - if ( glConfig2.glMissingExtensionsString.length() != 0 ) + if ( glConfig.glMissingExtensionsString.length() != 0 ) { - Log::Notice("%sMissing OpenGL extensions: %s", Color::ToString( Color::Red ), glConfig2.glMissingExtensionsString ); + Log::Notice("%sMissing OpenGL extensions: %s", Color::ToString( Color::Red ), glConfig.glMissingExtensionsString ); } - if ( glConfig2.halfFloatVertexAvailable ) + if ( glConfig.halfFloatVertexAvailable ) { Log::Notice("%sUsing half-float vertex format.", Color::ToString( Color::Green )); } @@ -1022,19 +1022,19 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p Log::Notice("%sUsing S3TC (DXTC) texture compression.", Color::ToString( Color::Green ) ); } - if ( glConfig2.vboVertexSkinningAvailable ) + if ( glConfig.vboVertexSkinningAvailable ) { /* Mesa drivers usually support 256 bones, Nvidia proprietary drivers usually support 233 bones, OpenGL 2.1 hardware usually supports no more than 41 bones which may not be enough to use hardware acceleration on models from games like Unvanquished. */ - if ( glConfig2.maxVertexSkinningBones < 233 ) + if ( glConfig.maxVertexSkinningBones < 233 ) { - Log::Notice("%sUsing GPU vertex skinning with max %i bones in a single pass, some models may not be hardware accelerated.", Color::ToString( Color::Red ), glConfig2.maxVertexSkinningBones ); + Log::Notice("%sUsing GPU vertex skinning with max %i bones in a single pass, some models may not be hardware accelerated.", Color::ToString( Color::Red ), glConfig.maxVertexSkinningBones ); } else { - Log::Notice("%sUsing GPU vertex skinning with max %i bones in a single pass, models are hardware accelerated.", Color::ToString( Color::Green ), glConfig2.maxVertexSkinningBones ); + Log::Notice("%sUsing GPU vertex skinning with max %i bones in a single pass, models are hardware accelerated.", Color::ToString( Color::Green ), glConfig.maxVertexSkinningBones ); } } else @@ -1096,7 +1096,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p } } - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { /* GLSL shaders linked to materials will be invalidated by glsl_restart, so we need to reset them here */ materialSystem.GLSLRestart(); @@ -1370,25 +1370,25 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p } if ( r_reflectionMapping.Get() ) { - glConfig2.reflectionMappingAvailable = true; + glConfig.reflectionMappingAvailable = true; if ( !r_normalMapping->integer ) { - glConfig2.reflectionMappingAvailable = false; + glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections without normal mapping, make sure you enable r_normalMapping" ); } if ( !r_deluxeMapping->integer ) { - glConfig2.reflectionMappingAvailable = false; + glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections without deluxe mapping, make sure you enable r_deluxeMapping" ); } if ( !r_specularMapping->integer ) { - glConfig2.reflectionMappingAvailable = false; + glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections without specular mapping, make sure you enable r_specularMapping" ); } if ( r_physicalMapping->integer ) { - glConfig2.reflectionMappingAvailable = false; + glConfig.reflectionMappingAvailable = false; Log::Warn( "Unable to use static reflections with physical mapping, make sure you disable r_physicalMapping" ); } } @@ -1463,7 +1463,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p R_DoneFreeType(); - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.Free(); } @@ -1471,7 +1471,7 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p if ( destroyWindow ) { GLSL_ShutdownGPUShaders(); - if( glConfig2.glCoreProfile ) { + if( glConfig.glCoreProfile ) { glBindVertexArray( 0 ); glDeleteVertexArrays( 1, &backEnd.defaultVAO ); } @@ -1526,13 +1526,13 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p GLSL_FinishGPUShaders(); } - if ( glConfig2.shadingLanguage420PackAvailable ) { + if ( glConfig.shadingLanguage420PackAvailable ) { gl_shaderManager.BindBuffers(); } /* TODO: Move this into a loading step and don't render it to the screen For now though do it here to avoid the ugly square rendering appearing on top of the loading screen */ - if ( glConfig2.reflectionMappingAvailable ) { + if ( glConfig.reflectionMappingAvailable ) { switch ( r_autoBuildCubeMaps.Get() ) { case Util::ordinal( cubeProbesAutoBuildMode::CACHED ): case Util::ordinal( cubeProbesAutoBuildMode::ALWAYS ): diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index 040873c843..7105b243eb 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -2935,7 +2935,7 @@ void GL_CompressedTexSubImage3D( GLenum target, GLint level, GLint xOffset, GLin void RE_UploadCinematic( int cols, int rows, const byte *data, int client, bool dirty ); void RE_BeginFrame(); - bool RE_BeginRegistration( glconfig_t *glconfig, glconfig2_t *glconfig2 ); + bool RE_BeginRegistration( WindowConfig* windowCfg ); void RE_LoadWorldMap( const char *mapname ); void RE_SetWorldVisData( const byte *vis ); qhandle_t RE_RegisterModel( const char *name ); diff --git a/src/engine/renderer/tr_main.cpp b/src/engine/renderer/tr_main.cpp index 29dc338808..7638d47d1e 100644 --- a/src/engine/renderer/tr_main.cpp +++ b/src/engine/renderer/tr_main.cpp @@ -737,7 +737,7 @@ static void SetFarClip() vec3_t v; float distance; - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { VectorCopy( materialSystem.worldViewBounds[0], tr.viewParms.visBounds[0] ); VectorCopy( materialSystem.worldViewBounds[1], tr.viewParms.visBounds[1] ); } @@ -847,7 +847,7 @@ static void R_SetupUnprojection() MatrixInverse( unprojectMatrix ); MatrixMultiplyTranslation( unprojectMatrix, -1.0, -1.0, -1.0 ); - MatrixMultiplyScale( unprojectMatrix, 2.0f / glConfig.vidWidth, 2.0f / glConfig.vidHeight, 2.0 ); + MatrixMultiplyScale( unprojectMatrix, 2.0f / windowConfig.vidWidth, 2.0f / windowConfig.vidHeight, 2.0 ); } /* @@ -1474,7 +1474,7 @@ static void R_SetupPortalFrustum( const viewParms_t& oldParms, const orientation MatrixCopy(oldParms.projectionMatrix, invProjViewPortMatrix); MatrixInverse(invProjViewPortMatrix); MatrixMultiplyTranslation(invProjViewPortMatrix, -1.0, -1.0, -1.0); - MatrixMultiplyScale(invProjViewPortMatrix, 2.0f / glConfig.vidWidth, 2.0f / glConfig.vidHeight, 2.0); + MatrixMultiplyScale(invProjViewPortMatrix, 2.0f / windowConfig.vidWidth, 2.0f / windowConfig.vidHeight, 2.0); frustum_t& frustum = newParms.portalFrustum; MatrixTransformPoint(invProjViewPortMatrix, sbottomleft, bottomleft); @@ -1746,7 +1746,7 @@ static void R_SortDrawSurfs() int sort; // it is possible for some views to not have any surfaces - if ( !glConfig2.usingMaterialSystem && tr.viewParms.numDrawSurfs < 1 ) + if ( !glConfig.usingMaterialSystem && tr.viewParms.numDrawSurfs < 1 ) { // we still need to add it for hyperspace cases R_AddDrawViewCmd( false ); @@ -1793,7 +1793,7 @@ static void R_SortDrawSurfs() // check for any pass through drawing, which // may cause another view to be rendered first // Material system does its own handling of portal surfaces - if ( glConfig2.usingMaterialSystem && !r_materialSystemSkip.Get() ) { + if ( glConfig.usingMaterialSystem && !r_materialSystemSkip.Get() ) { if ( tr.viewParms.portalLevel == 0 ) { materialSystem.AddPortalSurfaces(); currentView = 0; @@ -2056,7 +2056,7 @@ void R_RenderView( viewParms_t *parms ) R_SetupFrustum(); - if ( glConfig2.usingMaterialSystem && !r_materialSystemSkip.Get() ) { + if ( glConfig.usingMaterialSystem && !r_materialSystemSkip.Get() ) { tr.viewParms.viewID = tr.viewCount; materialSystem.QueueSurfaceCull( tr.viewCount, tr.viewParms.pvsOrigin, (frustum_t*) tr.viewParms.frustum ); materialSystem.AddAutospriteSurfaces(); diff --git a/src/engine/renderer/tr_model.cpp b/src/engine/renderer/tr_model.cpp index c0bb2d21b7..1e615b833d 100644 --- a/src/engine/renderer/tr_model.cpp +++ b/src/engine/renderer/tr_model.cpp @@ -255,15 +255,14 @@ qhandle_t RE_RegisterModel( const char *name ) /* ** RE_BeginRegistration */ -bool RE_BeginRegistration( glconfig_t *glconfigOut, glconfig2_t *glconfig2Out ) +bool RE_BeginRegistration( WindowConfig* windowCfg ) { if ( !R_Init() ) { return false; } - *glconfigOut = glConfig; - *glconfig2Out = glConfig2; + *windowCfg = windowConfig; R_SyncRenderThread(); diff --git a/src/engine/renderer/tr_model_iqm.cpp b/src/engine/renderer/tr_model_iqm.cpp index 5fdc97e7e4..938b3d5089 100644 --- a/src/engine/renderer/tr_model_iqm.cpp +++ b/src/engine/renderer/tr_model_iqm.cpp @@ -818,8 +818,8 @@ bool R_LoadIQModel( model_t *mod, const void *buffer, int filesize, } // convert data where necessary and create VBO - if( r_vboModels.Get() && glConfig2.vboVertexSkinningAvailable - && IQModel->num_joints <= glConfig2.maxVertexSkinningBones ) { + if( r_vboModels.Get() && glConfig.vboVertexSkinningAvailable + && IQModel->num_joints <= glConfig.maxVertexSkinningBones ) { uint16_t *boneFactorBuf = (uint16_t*)ri.Hunk_AllocateTempMemory( IQModel->num_vertexes * ( 4 * sizeof(uint16_t) ) ); diff --git a/src/engine/renderer/tr_model_skel.cpp b/src/engine/renderer/tr_model_skel.cpp index fce07e3e8e..b663828565 100644 --- a/src/engine/renderer/tr_model_skel.cpp +++ b/src/engine/renderer/tr_model_skel.cpp @@ -54,7 +54,7 @@ bool R_AddTriangleToVBOTriangleList( if ( !boneReferences[ boneIndex ] ) { // the bone isn't yet and we have to test if we can give the mesh this bone at all - if ( ( *numBoneReferences + numNewReferences ) >= glConfig2.maxVertexSkinningBones ) + if ( ( *numBoneReferences + numNewReferences ) >= glConfig.maxVertexSkinningBones ) { return false; } diff --git a/src/engine/renderer/tr_public.h b/src/engine/renderer/tr_public.h index b879c3fe7a..8f4e7606a3 100644 --- a/src/engine/renderer/tr_public.h +++ b/src/engine/renderer/tr_public.h @@ -47,8 +47,25 @@ extern Cvar::Modified> r_fullscreen; // Note: some of these (particularly ones dealing with GL extensions) are only updated on // an explicit vid_restart - see GLimp_InitExtensions(). Others are updated on every map change // - see EnableAvailableFeatures(). -struct glconfig2_t +struct GLConfig { + char renderer_string[MAX_STRING_CHARS]; + char vendor_string[MAX_STRING_CHARS]; + char version_string[MAX_STRING_CHARS]; + + int maxTextureSize; // queried from GL + + int colorBits; + + glDriverType_t driverType; + glHardwareType_t hardwareType; + + textureCompression_t textureCompression; + + int displayIndex; + + bool smpActive; // dual processor + bool textureCompressionRGTCAvailable; int glHighestMajor; @@ -153,6 +170,12 @@ struct glconfig2_t bool motionBlur; }; +struct WindowConfig { + float displayAspect; + int displayWidth, displayHeight; // the entire monitor (the one indicated by displayIndex) + int vidWidth, vidHeight; // what the game is using +}; + // // these are the functions exported by the refresh module // @@ -173,7 +196,7 @@ struct refexport_t // and height, which can be used by the client to intelligently // size display elements. Returns false if the renderer couldn't // be initialized. - bool( *BeginRegistration )( glconfig_t *config, glconfig2_t *glconfig2 ); + bool( *BeginRegistration )( WindowConfig* windowCfg ); qhandle_t ( *RegisterModel )( const char *name ); //qhandle_t (*RegisterModelAllLODs) (const char *name); qhandle_t ( *RegisterSkin )( const char *name ); diff --git a/src/engine/renderer/tr_scene.cpp b/src/engine/renderer/tr_scene.cpp index 931c7d8e48..e14632ef18 100644 --- a/src/engine/renderer/tr_scene.cpp +++ b/src/engine/renderer/tr_scene.cpp @@ -287,7 +287,7 @@ void RE_AddDynamicLightToSceneET( const vec3_t org, float radius, float intensit { refLight_t *light; - if ( !glConfig2.realtimeLighting || !r_drawDynamicLights.Get() ) + if ( !glConfig.realtimeLighting || !r_drawDynamicLights.Get() ) { return; } @@ -457,7 +457,7 @@ static void RE_RenderCubeProbeFace( const refdef_t* originalRefdef ) { } } - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { // Material system writes culled surfaces for the next frame, so we need to render twice with it to cull correctly R_SyncRenderThread(); RE_RenderScene( &refdef ); @@ -591,7 +591,7 @@ void RE_RenderScene( const refdef_t *fd ) if( fd->rdflags & RDF_NOCUBEMAP ) { parms.viewportY = tr.refdef.height - ( tr.refdef.y + tr.refdef.height ); } else { - parms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.refdef.height ); + parms.viewportY = windowConfig.vidHeight - ( tr.refdef.y + tr.refdef.height ); } } else @@ -629,7 +629,7 @@ void RE_RenderScene( const refdef_t *fd ) R_AddClearBufferCmd(); R_AddSetupLightsCmd(); - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.StartFrame(); } @@ -646,7 +646,7 @@ void RE_RenderScene( const refdef_t *fd ) tr.frontEndMsec += ri.Milliseconds() - startTime; - if ( ( r_showCubeProbeFace.Get() >= 0 ) && glConfig2.reflectionMapping + if ( ( r_showCubeProbeFace.Get() >= 0 ) && glConfig.reflectionMapping && !( fd->rdflags & RDF_NOCUBEMAP ) ) { RE_RenderCubeProbeFace( fd ); } diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp index 2727bafee2..2cc7ab40e3 100644 --- a/src/engine/renderer/tr_shade.cpp +++ b/src/engine/renderer/tr_shade.cpp @@ -38,108 +38,108 @@ This file deals with applying shaders to surface data in the tess struct. static void EnableAvailableFeatures() { - glConfig2.realtimeLighting = r_realtimeLighting.Get(); + glConfig.realtimeLighting = r_realtimeLighting.Get(); - if ( glConfig2.realtimeLighting ) + if ( glConfig.realtimeLighting ) { - if ( !glConfig2.uniformBufferObjectAvailable ) { + if ( !glConfig.uniformBufferObjectAvailable ) { Log::Warn( "Tiled dynamic light renderer disabled because GL_ARB_uniform_buffer_object is not available." ); - glConfig2.realtimeLighting = false; + glConfig.realtimeLighting = false; } - if ( !glConfig2.textureIntegerAvailable ) { + if ( !glConfig.textureIntegerAvailable ) { Log::Warn( "Tiled dynamic light renderer disabled because GL_EXT_texture_integer is not available." ); - glConfig2.realtimeLighting = false; + glConfig.realtimeLighting = false; } - if ( !glConfig2.textureFloatAvailable ) + if ( !glConfig.textureFloatAvailable ) { Log::Warn( "Tiled dynamic light renderer disabled because GL_ARB_texture_float is not available." ); - glConfig2.realtimeLighting = false; + glConfig.realtimeLighting = false; } - if ( glConfig2.max3DTextureSize == 0 ) + if ( glConfig.max3DTextureSize == 0 ) { Log::Warn( "Tiled dynamic light renderer disabled because of missing 3D texture support." ); - glConfig2.realtimeLighting = false; + glConfig.realtimeLighting = false; } // See below about ALU instructions on ATI R300 and Intel GMA 3. - if ( !glConfig2.glCoreProfile && glConfig2.maxAluInstructions < 128 ) + if ( !glConfig.glCoreProfile && glConfig.maxAluInstructions < 128 ) { - Log::Warn( "Tiled dynamic light rendered disabled because GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB is too small: %d", glConfig2.maxAluInstructions ); - glConfig2.realtimeLighting = false; + Log::Warn( "Tiled dynamic light rendered disabled because GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB is too small: %d", glConfig.maxAluInstructions ); + glConfig.realtimeLighting = false; } } - if ( glConfig2.realtimeLighting ) { - glConfig2.realtimeLightLayers = r_realtimeLightLayers.Get(); + if ( glConfig.realtimeLighting ) { + glConfig.realtimeLightLayers = r_realtimeLightLayers.Get(); - if ( glConfig2.realtimeLightLayers > glConfig2.max3DTextureSize ) { - glConfig2.realtimeLightLayers = glConfig2.max3DTextureSize; - Log::Notice( "r_realtimeLightLayers exceeds maximum 3D texture size, using %i instead.", glConfig2.max3DTextureSize ); + if ( glConfig.realtimeLightLayers > glConfig.max3DTextureSize ) { + glConfig.realtimeLightLayers = glConfig.max3DTextureSize; + Log::Notice( "r_realtimeLightLayers exceeds maximum 3D texture size, using %i instead.", glConfig.max3DTextureSize ); } - Log::Notice( "Using %i dynamic light layers, %i dynamic lights available per tile", glConfig2.realtimeLightLayers, - glConfig2.realtimeLightLayers * 16 ); + Log::Notice( "Using %i dynamic light layers, %i dynamic lights available per tile", glConfig.realtimeLightLayers, + glConfig.realtimeLightLayers * 16 ); } - glConfig2.colorGrading = r_colorGrading.Get(); + glConfig.colorGrading = r_colorGrading.Get(); - if ( glConfig2.colorGrading ) + if ( glConfig.colorGrading ) { - if ( glConfig2.max3DTextureSize == 0 ) + if ( glConfig.max3DTextureSize == 0 ) { Log::Warn( "Color grading disabled because of missing 3D texture support." ); - glConfig2.colorGrading = false; + glConfig.colorGrading = false; } } - glConfig2.deluxeMapping = r_deluxeMapping->integer; - glConfig2.normalMapping = r_normalMapping->integer; - glConfig2.specularMapping = r_specularMapping->integer; - glConfig2.physicalMapping = r_physicalMapping->integer; - glConfig2.reliefMapping = r_reliefMapping->integer; + glConfig.deluxeMapping = r_deluxeMapping->integer; + glConfig.normalMapping = r_normalMapping->integer; + glConfig.specularMapping = r_specularMapping->integer; + glConfig.physicalMapping = r_physicalMapping->integer; + glConfig.reliefMapping = r_reliefMapping->integer; /* ATI R300 and Intel GMA 3 only have 64 ALU instructions, which is not enough for some shader variants. For example the lightMapping shader permutation with macros USE_GRID_LIGHTING and USE_GRID_DELUXE_MAPPING from the medium graphics preset requires 67 ALU. For comparison, ATI R400 and R500 have 512 of them. */ - if ( !glConfig2.glCoreProfile && glConfig2.maxAluInstructions < 128 ) + if ( !glConfig.glCoreProfile && glConfig.maxAluInstructions < 128 ) { static const std::pair aluFeatures[] = { /* Normal mapping, specular mapping and physical mapping does nothing when deluxe mapping is disabled. Hardware that can't do deluxe mapping or normal mapping is not powerful enoough to do relief mapping. */ - { &glConfig2.deluxeMapping, "Deluxe mapping" }, - { &glConfig2.normalMapping, "Normal mapping" }, - { &glConfig2.specularMapping, "Specular mapping" }, - { &glConfig2.physicalMapping, "Physical mapping" }, - { &glConfig2.reliefMapping, "Relief mapping" }, + { &glConfig.deluxeMapping, "Deluxe mapping" }, + { &glConfig.normalMapping, "Normal mapping" }, + { &glConfig.specularMapping, "Specular mapping" }, + { &glConfig.physicalMapping, "Physical mapping" }, + { &glConfig.reliefMapping, "Relief mapping" }, }; for ( auto& f : aluFeatures ) { if ( *f.first ) { - Log::Warn( "%s disabled because GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB is too small: %d", f.second, glConfig2.maxAluInstructions ); + Log::Warn( "%s disabled because GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB is too small: %d", f.second, glConfig.maxAluInstructions ); *f.first = false; } } } // Disable features that require deluxe mapping to be enabled. - glConfig2.normalMapping = glConfig2.deluxeMapping && glConfig2.normalMapping; - glConfig2.specularMapping = glConfig2.deluxeMapping && glConfig2.specularMapping; - glConfig2.physicalMapping = glConfig2.deluxeMapping && glConfig2.physicalMapping; + glConfig.normalMapping = glConfig.deluxeMapping && glConfig.normalMapping; + glConfig.specularMapping = glConfig.deluxeMapping && glConfig.specularMapping; + glConfig.physicalMapping = glConfig.deluxeMapping && glConfig.physicalMapping; - glConfig2.bloom = r_bloom.Get(); + glConfig.bloom = r_bloom.Get(); - glConfig2.ssao = r_ssao.Get() != Util::ordinal( ssaoMode::DISABLED ); + glConfig.ssao = r_ssao.Get() != Util::ordinal( ssaoMode::DISABLED ); static const std::pair ssaoRequiredExtensions[] = { - { &glConfig2.textureGatherAvailable, "ARB_texture_gather" }, - { &glConfig2.gpuShader4Available, "EXT_gpu_shader4" }, + { &glConfig.textureGatherAvailable, "ARB_texture_gather" }, + { &glConfig.gpuShader4Available, "EXT_gpu_shader4" }, }; for ( auto& e: ssaoRequiredExtensions ) @@ -147,43 +147,43 @@ static void EnableAvailableFeatures() if ( !*e.first ) { Log::Warn( "SSAO disabled because %s is not available.", e.second ); - glConfig2.ssao = false; + glConfig.ssao = false; } } /* Motion blur is enabled by cg_motionblur which is a client cvar so we have to build it in all cases, unless unsupported by the hardware which is the only condition when the engine knows it is not used. */ - glConfig2.motionBlur = true; + glConfig.motionBlur = true; // This will be enabled later on by R_BuildCubeMaps() - glConfig2.reflectionMapping = false; + glConfig.reflectionMapping = false; /* Intel GMA 3 only has 4 tex indirections, which is not enough for some shaders. For example blurX requires 6, contrast requires 5, motionblur requires 5… For comparison, ATI R300, R400 and R500 have 16 of them. We don't need a finer check as early R300 hardware with 16 indirections would better not run that code for performance, so disabling the shader by mistake on an hypothetical lower-end hardware only supporting 8 indirections can't do harm. */ - if ( !glConfig2.glCoreProfile && glConfig2.maxTexIndirections < 16 ) + if ( !glConfig.glCoreProfile && glConfig.maxTexIndirections < 16 ) { static const std::pair indirectFeatures[] = { - { &glConfig2.bloom, "Bloom" }, - { &glConfig2.motionBlur, "Motion blur" }, + { &glConfig.bloom, "Bloom" }, + { &glConfig.motionBlur, "Motion blur" }, }; for ( auto& f : indirectFeatures ) { if ( *f.first ) { - Log::Warn( "%s disabled because GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB is too small: %d", f.second, glConfig2.maxTexIndirections ); + Log::Warn( "%s disabled because GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB is too small: %d", f.second, glConfig.maxTexIndirections ); *f.first = false; } } } - glConfig2.usingMaterialSystem = r_materialSystem.Get() && glConfig2.materialSystemAvailable; - glConfig2.usingBindlessTextures = glConfig2.usingMaterialSystem || - ( r_preferBindlessTextures.Get() && glConfig2.bindlessTexturesAvailable ); - glConfig2.usingGeometryCache = glConfig2.usingMaterialSystem && glConfig2.geometryCacheAvailable; + glConfig.usingMaterialSystem = r_materialSystem.Get() && glConfig.materialSystemAvailable; + glConfig.usingBindlessTextures = glConfig.usingMaterialSystem || + ( r_preferBindlessTextures.Get() && glConfig.bindlessTexturesAvailable ); + glConfig.usingGeometryCache = glConfig.usingMaterialSystem && glConfig.geometryCacheAvailable; } // For shaders that require map data for compile-time values @@ -196,7 +196,7 @@ void GLSL_InitWorldShaders() { gl_shaderManager.GenerateWorldHeaders(); // Material system shaders that are always loaded if material system is available - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { gl_cullShader->MarkProgramForBuilding( 0 ); } @@ -212,7 +212,7 @@ static void GLSL_InitGPUShadersOrError() gl_shaderManager.InitDriverInfo(); - /* It must be done before GenerateBuiltinHeaders() because glConfig2.realtimeLighting + /* It must be done before GenerateBuiltinHeaders() because glConfig.realtimeLighting is read in GenEngineConstants(). */ EnableAvailableFeatures(); @@ -225,7 +225,7 @@ static void GLSL_InitGPUShadersOrError() gl_shaderManager.LoadShader( gl_lightMappingShader ); // Material system shaders that are always loaded if material system is available - if ( glConfig2.usingMaterialSystem ) + if ( glConfig.usingMaterialSystem ) { gl_shaderManager.LoadShader( gl_genericShaderMaterial ); gl_shaderManager.LoadShader( gl_lightMappingShaderMaterial ); @@ -247,7 +247,7 @@ static void GLSL_InitGPUShadersOrError() GLSL_InitWorldShaders(); } - if ( glConfig2.realtimeLighting ) + if ( glConfig.realtimeLighting ) { gl_shaderManager.LoadShader( gl_depthtile1Shader ); gl_shaderManager.LoadShader( gl_depthtile2Shader ); @@ -258,12 +258,12 @@ static void GLSL_InitGPUShadersOrError() gl_lighttileShader->MarkProgramForBuilding( 0 ); } - if ( glConfig2.reflectionMappingAvailable ) + if ( glConfig.reflectionMappingAvailable ) { // bumped cubemap reflection for abitrary polygons ( EMBM ) gl_shaderManager.LoadShader( gl_reflectionShader ); - if ( glConfig2.usingMaterialSystem ) + if ( glConfig.usingMaterialSystem ) { gl_shaderManager.LoadShader( gl_reflectionShaderMaterial ); } @@ -276,7 +276,7 @@ static void GLSL_InitGPUShadersOrError() gl_skyboxShader->MarkProgramForBuilding( 0 ); - if ( glConfig2.usingMaterialSystem ) + if ( glConfig.usingMaterialSystem ) { gl_shaderManager.LoadShader( gl_skyboxShaderMaterial ); @@ -289,7 +289,7 @@ static void GLSL_InitGPUShadersOrError() // Q3A volumetric fog gl_shaderManager.LoadShader( gl_fogQuake3Shader ); - if ( glConfig2.usingMaterialSystem ) + if ( glConfig.usingMaterialSystem ) { gl_shaderManager.LoadShader( gl_fogQuake3ShaderMaterial ); } @@ -305,20 +305,20 @@ static void GLSL_InitGPUShadersOrError() // heatHaze post process effect gl_shaderManager.LoadShader( gl_heatHazeShader ); - if ( glConfig2.usingMaterialSystem ) + if ( glConfig.usingMaterialSystem ) { gl_shaderManager.LoadShader( gl_heatHazeShaderMaterial ); } } - if ( glConfig2.bloom ) + if ( glConfig.bloom ) { // screen post process effect gl_shaderManager.LoadShader( gl_screenShader ); gl_screenShader->MarkProgramForBuilding( 0 ); - if ( glConfig2.usingMaterialSystem ) + if ( glConfig.usingMaterialSystem ) { gl_shaderManager.LoadShader( gl_screenShaderMaterial ); @@ -341,7 +341,7 @@ static void GLSL_InitGPUShadersOrError() gl_cameraEffectsShader->MarkProgramForBuilding( 0 ); - if ( glConfig2.bloom ) + if ( glConfig.bloom ) { // gaussian blur gl_shaderManager.LoadShader( gl_blurShader ); @@ -353,20 +353,20 @@ static void GLSL_InitGPUShadersOrError() { gl_shaderManager.LoadShader( gl_liquidShader ); - if ( glConfig2.usingMaterialSystem ) + if ( glConfig.usingMaterialSystem ) { gl_shaderManager.LoadShader( gl_liquidShaderMaterial ); } } - if ( glConfig2.motionBlur ) + if ( glConfig.motionBlur ) { gl_shaderManager.LoadShader( gl_motionblurShader ); gl_motionblurShader->MarkProgramForBuilding( 0 ); } - if ( glConfig2.ssao ) + if ( glConfig.ssao ) { gl_shaderManager.LoadShader( gl_ssaoShader ); @@ -626,7 +626,7 @@ static void DrawTris() GLIMP_LOGCOMMENT( "--- DrawTris ---" ); - gl_genericShader->SetVertexSkinning( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ); + gl_genericShader->SetVertexSkinning( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ); gl_genericShader->SetVertexAnimation( tess.vboVertexAnimation ); gl_genericShader->SetTCGenEnvironment( false ); gl_genericShader->SetTCGenLightmap( false ); @@ -664,7 +664,7 @@ static void DrawTris() gl_genericShader->SetUniform_ModelMatrix( backEnd.orientation.transformMatrix ); gl_genericShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] ); - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { gl_genericShader->SetUniform_Bones( tess.numBones, tess.bones ); } @@ -783,7 +783,7 @@ void ProcessShaderNOP( const shaderStage_t* ) { } void ProcessShaderGeneric3D( const shaderStage_t* pStage ) { - gl_genericShader->SetVertexSkinning( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ); + gl_genericShader->SetVertexSkinning( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ); gl_genericShader->SetVertexAnimation( tess.vboVertexAnimation ); gl_genericShader->SetTCGenEnvironment( pStage->tcGen_Environment ); gl_genericShader->SetTCGenLightmap( pStage->tcGen_Lightmap ); @@ -801,10 +801,10 @@ void ProcessShaderLightMapping( const shaderStage_t* pStage ) { // Not implemented yet in PBR code. bool enableReflectiveSpecular = - pStage->enableSpecularMapping && glConfig2.reflectionMapping + pStage->enableSpecularMapping && glConfig.reflectionMapping && !( tr.refdef.rdflags & RDF_NOCUBEMAP ); - gl_lightMappingShader->SetVertexSkinning( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ); + gl_lightMappingShader->SetVertexSkinning( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ); gl_lightMappingShader->SetVertexAnimation( tess.vboVertexAnimation ); gl_lightMappingShader->SetBspSurface( tess.bspSurface ); @@ -828,12 +828,12 @@ void ProcessShaderReflection( const shaderStage_t* pStage ) { gl_reflectionShader->SetReliefMapping( pStage->enableReliefMapping ); - gl_reflectionShader->SetVertexSkinning( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ); + gl_reflectionShader->SetVertexSkinning( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ); gl_reflectionShader->SetVertexAnimation( tess.vboVertexAnimation ); } void ProcessShaderHeatHaze( const shaderStage_t* ) { - gl_heatHazeShader->SetVertexSkinning( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ); + gl_heatHazeShader->SetVertexSkinning( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ); gl_heatHazeShader->SetVertexAnimation( tess.vboVertexAnimation ); } @@ -852,7 +852,7 @@ void ProcessShaderLiquid( const shaderStage_t* pStage ) { } void ProcessShaderFog( const shaderStage_t* ) { - gl_fogQuake3Shader->SetVertexSkinning( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ); + gl_fogQuake3Shader->SetVertexSkinning( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ); gl_fogQuake3Shader->SetVertexAnimation( tess.vboVertexAnimation ); } @@ -874,7 +874,7 @@ void Render_generic3D( shaderStage_t *pStage ) bool hasDepthFade = pStage->hasDepthFade; bool needDepthMap = pStage->hasDepthFade; - if ( needDepthMap && backEnd.dirtyDepthBuffer && glConfig2.textureBarrierAvailable ) + if ( needDepthMap && backEnd.dirtyDepthBuffer && glConfig.textureBarrierAvailable ) { // Flush depth buffer to make sure it is available for reading in the depth fade // GLSL - prevents https://github.com/DaemonEngine/Daemon/issues/1676 @@ -912,7 +912,7 @@ void Render_generic3D( shaderStage_t *pStage ) gl_genericShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] ); // u_Bones - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { gl_genericShader->SetUniform_Bones( tess.numBones, tess.bones ); } @@ -1021,7 +1021,7 @@ void Render_lightMapping( shaderStage_t *pStage ) // Not implemented yet in PBR code. bool enableReflectiveSpecular = - pStage->enableSpecularMapping && glConfig2.reflectionMapping + pStage->enableSpecularMapping && glConfig.reflectionMapping && !( tr.refdef.rdflags & RDF_NOCUBEMAP ); GL_State( stateBits ); @@ -1042,7 +1042,7 @@ void Render_lightMapping( shaderStage_t *pStage ) { VectorCopy( backEnd.viewParms.orientation.origin, viewOrigin ); // in world space - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { gl_lightMappingShader->SetUniform_Bones( tess.numBones, tess.bones ); } @@ -1061,7 +1061,7 @@ void Render_lightMapping( shaderStage_t *pStage ) gl_lightMappingShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] ); - if ( glConfig2.realtimeLighting ) + if ( glConfig.realtimeLighting ) { gl_lightMappingShader->SetUniform_numLights( tr.refdef.numLights ); @@ -1263,7 +1263,7 @@ void Render_reflection_CB( shaderStage_t *pStage ) gl_reflectionShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] ); // u_Bones - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { gl_reflectionShader->SetUniform_Bones( tess.numBones, tess.bones ); } @@ -1433,7 +1433,7 @@ void Render_heatHaze( shaderStage_t *pStage ) gl_heatHazeShader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] ); // u_Bones - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { gl_heatHazeShader->SetUniform_Bones( tess.numBones, tess.bones ); } @@ -1649,7 +1649,7 @@ void Render_fog( shaderStage_t* pStage ) gl_fogQuake3Shader->SetUniform_ModelViewProjectionMatrix( glState.modelViewProjectionMatrix[ glState.stackIndex ] ); // u_Bones - if ( glConfig2.vboVertexSkinningAvailable && tess.vboVertexSkinning ) + if ( glConfig.vboVertexSkinningAvailable && tess.vboVertexSkinning ) { gl_fogQuake3Shader->SetUniform_Bones( tess.numBones, tess.bones ); } @@ -2043,8 +2043,8 @@ void Tess_Clear() tess.numVertexes = 0; // TODO: stop constantly binding VBOs we aren't going to use! - bool usingMapBufferRange = ( !glConfig2.bufferStorageAvailable || !glConfig2.syncAvailable ) - && glConfig2.mapBufferRangeAvailable; + bool usingMapBufferRange = ( !glConfig.bufferStorageAvailable || !glConfig.syncAvailable ) + && glConfig.mapBufferRangeAvailable; if ( tess.verts != nullptr && tess.verts != tess.vertsBuffer && usingMapBufferRange ) { R_BindVBO( tess.vbo ); diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index ca80f24564..b83345760d 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -1424,12 +1424,12 @@ static bool LoadMap( shaderStage_t *stage, const char *buffer, stageType_t type, const char *token = COM_ParseExt2( &buffer_p, false ); // NOTE: Normal map can ship height map in alpha channel. - if ( ( type == stageType_t::ST_NORMALMAP && !glConfig2.normalMapping && !glConfig2.reliefMapping ) - || ( type == stageType_t::ST_HEIGHTMAP && !glConfig2.reliefMapping ) - || ( type == stageType_t::ST_SPECULARMAP && !glConfig2.specularMapping ) - || ( type == stageType_t::ST_PHYSICALMAP && !glConfig2.physicalMapping ) + if ( ( type == stageType_t::ST_NORMALMAP && !glConfig.normalMapping && !glConfig.reliefMapping ) + || ( type == stageType_t::ST_HEIGHTMAP && !glConfig.reliefMapping ) + || ( type == stageType_t::ST_SPECULARMAP && !glConfig.specularMapping ) + || ( type == stageType_t::ST_PHYSICALMAP && !glConfig.physicalMapping ) || ( type == stageType_t::ST_GLOWMAP && !r_glowMapping->integer ) - || ( type == stageType_t::ST_REFLECTIONMAP && !glConfig2.reflectionMappingAvailable ) ) + || ( type == stageType_t::ST_REFLECTIONMAP && !glConfig.reflectionMappingAvailable ) ) { return true; } @@ -5198,7 +5198,7 @@ static void FinishStages() case stageType_t::ST_REFLECTIONMAP: case stageType_t::ST_COLLAPSE_REFLECTIONMAP: - stage->active = glConfig2.reflectionMappingAvailable; + stage->active = glConfig.reflectionMappingAvailable; break; case stageType_t::ST_LIGHTMAP: @@ -5241,22 +5241,22 @@ static void FinishStages() stage->hasHeightMapInNormalMap = stage->hasHeightMapInNormalMap && hasNormalMap; // Available features. - stage->enableNormalMapping = glConfig2.normalMapping && hasNormalMap; - stage->enableDeluxeMapping = glConfig2.deluxeMapping && ( hasNormalMap || hasMaterialMap ); + stage->enableNormalMapping = glConfig.normalMapping && hasNormalMap; + stage->enableDeluxeMapping = glConfig.deluxeMapping && ( hasNormalMap || hasMaterialMap ); - stage->enableReliefMapping = glConfig2.reliefMapping && !shader.disableReliefMapping + stage->enableReliefMapping = glConfig.reliefMapping && !shader.disableReliefMapping && ( hasHeightMap || stage->hasHeightMapInNormalMap ); stage->enableGlowMapping = r_glowMapping->integer && hasGlowMap; if ( stage->collapseType == collapseType_t::COLLAPSE_PBR ) { - stage->enablePhysicalMapping = glConfig2.physicalMapping && hasMaterialMap; + stage->enablePhysicalMapping = glConfig.physicalMapping && hasMaterialMap; stage->enableSpecularMapping = false; } else { - stage->enableSpecularMapping = glConfig2.specularMapping && hasMaterialMap; + stage->enableSpecularMapping = glConfig.specularMapping && hasMaterialMap; stage->enablePhysicalMapping = false; } @@ -5285,7 +5285,7 @@ static void FinishStages() { // If specular mapping is enabled always use the specular mapping // shader to avoid costly GLSL shader switching. - if ( glConfig2.specularMapping ) + if ( glConfig.specularMapping ) { stage->enableSpecularMapping = true; stage->bundle[ TB_MATERIALMAP ].image[ 0 ] = tr.blackImage; @@ -5868,7 +5868,7 @@ static shader_t *FinishShader() { ret->depthShader = nullptr; - if ( glConfig2.usingMaterialSystem && !tr.worldLoaded ) { + if ( glConfig.usingMaterialSystem && !tr.worldLoaded ) { uint8_t maxStages = ret->lastStage - ret->stages; // Add 1 for potential fog stages @@ -5926,7 +5926,7 @@ static shader_t *FinishShader() ret->depthShader = nullptr; } - if ( glConfig2.usingMaterialSystem && !tr.worldLoaded ) { + if ( glConfig.usingMaterialSystem && !tr.worldLoaded ) { uint8_t maxStages = ret->lastStage - ret->stages; // Add 1 for potential depth stages diff --git a/src/engine/renderer/tr_surface.cpp b/src/engine/renderer/tr_surface.cpp index 35f73ddf3a..93e10131d3 100644 --- a/src/engine/renderer/tr_surface.cpp +++ b/src/engine/renderer/tr_surface.cpp @@ -531,7 +531,7 @@ void Tess_AddCubeWithNormals( const vec3_t position, const vec3_t minSize, const void Tess_InstantScreenSpaceQuad() { GLIMP_LOGCOMMENT( "--- Tess_InstantScreenSpaceQuad ---" ); - if ( glConfig2.gpuShader4Available ) + if ( glConfig.gpuShader4Available ) { tr.skipVBO = true; Tess_Begin( Tess_StageIteratorDummy, nullptr, true, -1, 0 ); @@ -1191,7 +1191,7 @@ void Tess_SurfaceIQM( srfIQModel_t *surf ) { returns early and then save CPU time. This test is false when r_vboModels is disabled, or when - glConfig2.vboVertexSkinningAvailable is false because related + glConfig.vboVertexSkinningAvailable is false because related OpenGL extensions are unsupported, or the model has too much bones for the hardware, or r_vboVertexSkinning is disabled. diff --git a/src/engine/renderer/tr_vbo.cpp b/src/engine/renderer/tr_vbo.cpp index a6d63f15df..f1dc3c3e88 100644 --- a/src/engine/renderer/tr_vbo.cpp +++ b/src/engine/renderer/tr_vbo.cpp @@ -187,8 +187,8 @@ VBO_t *R_CreateDynamicVBO( const char *name, int numVertexes, uint32_t stateBits R_BindVBO( vbo ); - if( glConfig2.mapBufferRangeAvailable && glConfig2.bufferStorageAvailable && - glConfig2.syncAvailable ) { + if( glConfig.mapBufferRangeAvailable && glConfig.bufferStorageAvailable && + glConfig.syncAvailable ) { R_InitRingbuffer( GL_ARRAY_BUFFER, sizeof( shaderVertex_t ), numVertexes, &tess.vertexRB ); } else { glBufferData( GL_ARRAY_BUFFER, vbo->vertexesSize, nullptr, vbo->usage ); @@ -316,7 +316,7 @@ VBO_t *R_CreateStaticVBO( ASSERT_NQ( spec->numComponents, 0U ); vbo->attribBits |= 1 << spec->attrIndex; attrib.componentType = spec->componentStorageType; - if ( attrib.componentType == GL_HALF_FLOAT && !glConfig2.halfFloatVertexAvailable ) + if ( attrib.componentType == GL_HALF_FLOAT && !glConfig.halfFloatVertexAvailable ) { attrib.componentType = GL_FLOAT; } @@ -354,7 +354,7 @@ VBO_t *R_CreateStaticVBO( } } - if( glConfig2.bufferStorageAvailable ) { + if( glConfig.bufferStorageAvailable ) { glBufferStorage( GL_ARRAY_BUFFER, vbo->vertexesSize, interleavedData, 0 ); } else { glBufferData( GL_ARRAY_BUFFER, vbo->vertexesSize, interleavedData, vbo->usage ); @@ -389,8 +389,8 @@ IBO_t *R_CreateDynamicIBO( const char *name, int numIndexes ) glGenBuffers( 1, &ibo->indexesVBO ); R_BindIBO( ibo ); - if( glConfig2.mapBufferRangeAvailable && glConfig2.bufferStorageAvailable && - glConfig2.syncAvailable ) { + if( glConfig.mapBufferRangeAvailable && glConfig.bufferStorageAvailable && + glConfig.syncAvailable ) { R_InitRingbuffer( GL_ELEMENT_ARRAY_BUFFER, sizeof( glIndex_t ), numIndexes, &tess.indexRB ); } else { glBufferData( GL_ELEMENT_ARRAY_BUFFER, ibo->indexesSize, nullptr, GL_DYNAMIC_DRAW ); @@ -432,7 +432,7 @@ IBO_t *R_CreateStaticIBO( const char *name, glIndex_t *indexes, int numIndexes ) R_BindIBO( ibo ); - if( glConfig2.bufferStorageAvailable ) { + if( glConfig.bufferStorageAvailable ) { glBufferStorage( GL_ELEMENT_ARRAY_BUFFER, ibo->indexesSize, indexes, 0 ); } else { glBufferData( GL_ELEMENT_ARRAY_BUFFER, ibo->indexesSize, indexes, GL_STATIC_DRAW ); @@ -645,7 +645,7 @@ static void R_InitGenericVBOs() { static void R_InitTileVBO() { - if ( !glConfig2.realtimeLighting ) + if ( !glConfig.realtimeLighting ) { return; } @@ -690,12 +690,12 @@ const int indexCapacity = DYN_BUFFER_SIZE / sizeof( glIndex_t ); static void R_InitLightUBO() { - if ( !glConfig2.realtimeLighting ) + if ( !glConfig.realtimeLighting ) { return; } - if( glConfig2.uniformBufferObjectAvailable ) { + if( glConfig.uniformBufferObjectAvailable ) { glGenBuffers( 1, &tr.dlightUBO ); glBindBuffer( GL_UNIFORM_BUFFER, tr.dlightUBO ); glBufferData( GL_UNIFORM_BUFFER, MAX_REF_LIGHTS * sizeof( shaderLight_t ), nullptr, GL_DYNAMIC_DRAW ); @@ -719,7 +719,7 @@ void R_InitVBOs() tess.vertsBuffer = ( shaderVertex_t * ) Com_Allocate_Aligned( 64, SHADER_MAX_VERTEXES * sizeof( shaderVertex_t ) ); tess.indexesBuffer = ( glIndex_t * ) Com_Allocate_Aligned( 64, SHADER_MAX_INDEXES * sizeof( glIndex_t ) ); - if( glConfig2.mapBufferRangeAvailable ) { + if( glConfig.mapBufferRangeAvailable ) { tess.vbo = R_CreateDynamicVBO( "tessVertexArray_VBO", vertexCapacity, attribs, vboLayout_t::VBO_LAYOUT_STATIC ); tess.ibo = R_CreateDynamicIBO( "tessVertexArray_IBO", indexCapacity ); @@ -748,15 +748,15 @@ void R_InitVBOs() R_InitLightUBO(); - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.InitGLBuffers(); } - if ( glConfig2.usingGeometryCache ) { + if ( glConfig.usingGeometryCache ) { geometryCache.InitGLBuffers(); } - if ( glConfig2.directStateAccessAvailable && glConfig2.uniformBufferObjectAvailable ) { + if ( glConfig.directStateAccessAvailable && glConfig.uniformBufferObjectAvailable ) { stagingBuffer.InitGLBuffer(); } @@ -772,10 +772,10 @@ void R_ShutdownVBOs() { Log::Debug("------- R_ShutdownVBOs -------" ); - if( !glConfig2.mapBufferRangeAvailable ) { + if( !glConfig.mapBufferRangeAvailable ) { // nothing - } else if( glConfig2.bufferStorageAvailable && - glConfig2.syncAvailable ) { + } else if( glConfig.bufferStorageAvailable && + glConfig.syncAvailable ) { R_BindVBO( tess.vbo ); R_ShutdownRingbuffer( GL_ARRAY_BUFFER, &tess.vertexRB ); R_BindIBO( tess.ibo ); @@ -820,20 +820,20 @@ void R_ShutdownVBOs() Com_Free_Aligned( tess.vertsBuffer ); Com_Free_Aligned( tess.indexesBuffer ); - if( glConfig2.realtimeLighting ) { + if( glConfig.realtimeLighting ) { glDeleteBuffers( 1, &tr.dlightUBO ); tr.dlightUBO = 0; } - if ( glConfig2.usingMaterialSystem ) { + if ( glConfig.usingMaterialSystem ) { materialSystem.FreeGLBuffers(); } - if ( glConfig2.usingGeometryCache ) { + if ( glConfig.usingGeometryCache ) { geometryCache.FreeGLBuffers(); } - if ( glConfig2.directStateAccessAvailable && glConfig2.uniformBufferObjectAvailable ) { + if ( glConfig.directStateAccessAvailable && glConfig.uniformBufferObjectAvailable ) { stagingBuffer.FreeGLBuffer(); } @@ -850,7 +850,7 @@ Must be called before writing to tess.verts or tess.indexes ============== */ void Tess_MapVBOs( bool forceCPU ) { - if( forceCPU || !glConfig2.mapBufferRangeAvailable ) { + if( forceCPU || !glConfig.mapBufferRangeAvailable ) { // use host buffers tess.verts = tess.vertsBuffer; tess.indexes = tess.indexesBuffer; @@ -861,8 +861,8 @@ void Tess_MapVBOs( bool forceCPU ) { if( tess.verts == nullptr ) { R_BindVBO( tess.vbo ); - if( glConfig2.bufferStorageAvailable && - glConfig2.syncAvailable ) { + if( glConfig.bufferStorageAvailable && + glConfig.syncAvailable ) { GLsizei segmentEnd = (tess.vertexRB.activeSegment + 1) * tess.vertexRB.segmentElements; if( tess.vertsWritten + SHADER_MAX_VERTEXES > (unsigned) segmentEnd ) { tess.vertsWritten = R_RotateRingbuffer( &tess.vertexRB ); @@ -885,8 +885,8 @@ void Tess_MapVBOs( bool forceCPU ) { if( tess.indexes == nullptr ) { R_BindIBO( tess.ibo ); - if( glConfig2.bufferStorageAvailable && - glConfig2.syncAvailable ) { + if( glConfig.bufferStorageAvailable && + glConfig.syncAvailable ) { GLsizei segmentEnd = (tess.indexRB.activeSegment + 1) * tess.indexRB.segmentElements; if( tess.indexesWritten + SHADER_MAX_INDEXES > (unsigned) segmentEnd ) { tess.indexesWritten = R_RotateRingbuffer( &tess.indexRB ); @@ -930,13 +930,13 @@ void Tess_UpdateVBOs() GLIMP_LOGCOMMENT( "glBufferSubData( vbo = '%s', numVertexes = %i )", tess.vbo->name, tess.numVertexes ); - if( !glConfig2.mapBufferRangeAvailable ) { + if( !glConfig.mapBufferRangeAvailable ) { R_BindVBO( tess.vbo ); glBufferSubData( GL_ARRAY_BUFFER, 0, size, tess.verts ); } else { R_BindVBO( tess.vbo ); - if( glConfig2.bufferStorageAvailable && - glConfig2.syncAvailable ) { + if( glConfig.bufferStorageAvailable && + glConfig.syncAvailable ) { GLsizei offset = tess.vertexBase * sizeof( shaderVertex_t ); glFlushMappedBufferRange( GL_ARRAY_BUFFER, @@ -960,15 +960,15 @@ void Tess_UpdateVBOs() { GLsizei size = tess.numIndexes * sizeof( glIndex_t ); - if( !glConfig2.mapBufferRangeAvailable ) { + if( !glConfig.mapBufferRangeAvailable ) { R_BindIBO( tess.ibo ); glBufferSubData( GL_ELEMENT_ARRAY_BUFFER, 0, size, tess.indexes ); } else { R_BindIBO( tess.ibo ); - if( glConfig2.bufferStorageAvailable && - glConfig2.syncAvailable ) { + if( glConfig.bufferStorageAvailable && + glConfig.syncAvailable ) { GLsizei offset = tess.indexBase * sizeof( glIndex_t ); glFlushMappedBufferRange( GL_ELEMENT_ARRAY_BUFFER, diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp index 501de885f1..1598640b68 100644 --- a/src/engine/sys/sdl_glimp.cpp +++ b/src/engine/sys/sdl_glimp.cpp @@ -630,8 +630,8 @@ static int GLimp_CompareModes( const void *a, const void *b ) float aspectB = ( float ) modeB->w / ( float ) modeB->h; int areaA = modeA->w * modeA->h; int areaB = modeB->w * modeB->h; - float aspectDiffA = fabsf( aspectA - glConfig.displayAspect ); - float aspectDiffB = fabsf( aspectB - glConfig.displayAspect ); + float aspectDiffA = fabsf( aspectA - windowConfig.displayAspect ); + float aspectDiffB = fabsf( aspectB - windowConfig.displayAspect ); float aspectDiffsDiff = aspectDiffA - aspectDiffB; if ( aspectDiffsDiff > ASPECT_EPSILON ) @@ -864,7 +864,7 @@ static bool GLimp_CreateWindow( bool fullscreen, bool bordered, const glConfigur y = SDL_WINDOWPOS_UNDEFINED_DISPLAY( r_displayIndex->integer ); } - window = SDL_CreateWindow( CLIENT_WINDOW_TITLE, x, y, glConfig.vidWidth, glConfig.vidHeight, flags ); + window = SDL_CreateWindow( CLIENT_WINDOW_TITLE, x, y, windowConfig.vidWidth, windowConfig.vidHeight, flags ); if ( window ) { @@ -879,7 +879,7 @@ static bool GLimp_CreateWindow( bool fullscreen, bool bordered, const glConfigur else { logger.Warn( "SDL %d×%d %s%swindow not created", - glConfig.vidWidth, glConfig.vidHeight, + windowConfig.vidWidth, windowConfig.vidHeight, windowType ? windowType : "", windowType ? " ": "" ); logger.Warn("SDL_CreateWindow failed: %s", SDL_GetError() ); @@ -966,12 +966,12 @@ static bool GLimp_RecreateWindowWhenChange( const bool fullscreen, const bool bo /* We don't care if comparing default values is wrong when the window isn't created yet as the first thing we do is to overwrite them. */ - || glConfig.vidWidth != currentWidth - || glConfig.vidHeight != currentHeight + || windowConfig.vidWidth != currentWidth + || windowConfig.vidHeight != currentHeight || configuration != currentConfiguration ) { - currentWidth = glConfig.vidWidth; - currentHeight = glConfig.vidHeight; + currentWidth = windowConfig.vidWidth; + currentHeight = windowConfig.vidHeight; currentConfiguration = configuration; GLimp_DestroyWindowIfExists(); @@ -1028,43 +1028,43 @@ static rserr_t GLimp_SetModeAndResolution( const int mode ) if ( SDL_GetDesktopDisplayMode( r_displayIndex->integer, &desktopMode ) == 0 ) { - glConfig.displayAspect = ( float ) desktopMode.w / ( float ) desktopMode.h; - logger.Notice( "Display aspect: %.3f", glConfig.displayAspect ); + windowConfig.displayAspect = ( float ) desktopMode.w / ( float ) desktopMode.h; + logger.Notice( "Display aspect: %.3f", windowConfig.displayAspect ); } else { memset( &desktopMode, 0, sizeof( SDL_DisplayMode ) ); - glConfig.displayAspect = 1.333f; - logger.Warn("Cannot determine display aspect, assuming %.3f: %s", glConfig.displayAspect, SDL_GetError() ); + windowConfig.displayAspect = 1.333f; + logger.Warn("Cannot determine display aspect, assuming %.3f: %s", windowConfig.displayAspect, SDL_GetError() ); } - glConfig.displayWidth = desktopMode.w; - glConfig.displayHeight = desktopMode.h; + windowConfig.displayWidth = desktopMode.w; + windowConfig.displayHeight = desktopMode.h; if ( mode == -2 ) { // use desktop video resolution if ( desktopMode.h > 0 ) { - glConfig.vidWidth = desktopMode.w; - glConfig.vidHeight = desktopMode.h; + windowConfig.vidWidth = desktopMode.w; + windowConfig.vidHeight = desktopMode.h; } else { - glConfig.vidWidth = 640; - glConfig.vidHeight = 480; - logger.Warn("Cannot determine display resolution, assuming %dx%d", glConfig.vidWidth, glConfig.vidHeight ); + windowConfig.vidWidth = 640; + windowConfig.vidHeight = 480; + logger.Warn("Cannot determine display resolution, assuming %dx%d", windowConfig.vidWidth, windowConfig.vidHeight ); } - logger.Notice("Display resolution: %dx%d", glConfig.vidWidth, glConfig.vidHeight); + logger.Notice("Display resolution: %dx%d", windowConfig.vidWidth, windowConfig.vidHeight); } - else if ( !R_GetModeInfo( &glConfig.vidWidth, &glConfig.vidHeight, mode ) ) + else if ( !R_GetModeInfo( &windowConfig.vidWidth, &windowConfig.vidHeight, mode ) ) { logger.Notice("Invalid mode %d", mode ); return rserr_t::RSERR_INVALID_MODE; } - logger.Notice("...setting mode %d: %d×%d", mode, glConfig.vidWidth, glConfig.vidHeight ); + logger.Notice("...setting mode %d: %d×%d", mode, windowConfig.vidWidth, windowConfig.vidHeight ); return rserr_t::RSERR_OK; } @@ -1310,11 +1310,11 @@ static bool CreateWindowAndContext( static void GLimp_RegisterConfiguration( const glConfiguration& highestConfiguration, const glConfiguration &requestedConfiguration ) { - glConfig2.glHighestMajor = highestConfiguration.major; - glConfig2.glHighestMinor = highestConfiguration.minor; + glConfig.glHighestMajor = highestConfiguration.major; + glConfig.glHighestMinor = highestConfiguration.minor; - glConfig2.glRequestedMajor = requestedConfiguration.major; - glConfig2.glRequestedMinor = requestedConfiguration.minor; + glConfig.glRequestedMajor = requestedConfiguration.major; + glConfig.glRequestedMinor = requestedConfiguration.minor; SetSwapInterval( r_swapInterval.Get() ); r_swapInterval.GetModifiedValue(); // clear modified flag @@ -1336,14 +1336,14 @@ static void GLimp_RegisterConfiguration( const glConfiguration& highestConfigura if ( glGetError() != GL_NO_ERROR ) { - glConfig2.glCoreProfile = false; + glConfig.glCoreProfile = false; } else { - glConfig2.glCoreProfile = ( profileBit == GL_CONTEXT_CORE_PROFILE_BIT ); + glConfig.glCoreProfile = ( profileBit == GL_CONTEXT_CORE_PROFILE_BIT ); } - glProfile providedProfile = glConfig2.glCoreProfile ? glProfile::CORE : glProfile::COMPATIBILITY ; + glProfile providedProfile = glConfig.glCoreProfile ? glProfile::CORE : glProfile::COMPATIBILITY ; const char *providedProfileName = GLimp_getProfileName( providedProfile ); if ( providedProfile != requestedConfiguration.profile ) @@ -1385,20 +1385,20 @@ static void GLimp_RegisterConfiguration( const glConfiguration& highestConfigura Sys::Error( "Indecipherable GL_VERSION" ); } - glConfig2.glMajor = GLmajor; - glConfig2.glMinor = GLminor; + glConfig.glMajor = GLmajor; + glConfig.glMinor = GLminor; } // CONTEXT_FLAGS and forward compatibility were added in OpenGL 3.0 - if ( glConfig2.glMajor >= 3 ) + if ( glConfig.glMajor >= 3 ) { // Check if context is forward compatible. int contextFlags; glGetIntegerv( GL_CONTEXT_FLAGS, &contextFlags ); - glConfig2.glForwardCompatibleContext = contextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; + glConfig.glForwardCompatibleContext = contextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT; - if ( glConfig2.glForwardCompatibleContext ) + if ( glConfig.glForwardCompatibleContext ) { logger.Debug( "Provided OpenGL context is forward compatible." ); } @@ -1409,7 +1409,7 @@ static void GLimp_RegisterConfiguration( const glConfiguration& highestConfigura } else { - glConfig2.glForwardCompatibleContext = false; + glConfig.glForwardCompatibleContext = false; } // Get our config strings. @@ -1444,23 +1444,23 @@ static void GLimp_DrawWindow() static rserr_t GLimp_CheckOpenGLVersion( const glConfiguration &requestedConfiguration ) { - if ( glConfig2.glMajor != requestedConfiguration.major - || glConfig2.glMinor != requestedConfiguration.minor ) + if ( glConfig.glMajor != requestedConfiguration.major + || glConfig.glMinor != requestedConfiguration.minor ) { logger.Warn( "Provided OpenGL %d.%d is not the same as requested %d.%d version", - glConfig2.glMajor, - glConfig2.glMinor, + glConfig.glMajor, + glConfig.glMinor, requestedConfiguration.major, requestedConfiguration.minor ); } else { logger.Debug( "Provided OpenGL %d.%d version.", - glConfig2.glMajor, - glConfig2.glMinor ); + glConfig.glMajor, + glConfig.glMinor ); } - if ( glConfig2.glMajor < 2 || ( glConfig2.glMajor == 2 && glConfig2.glMinor < 1 ) ) + if ( glConfig.glMajor < 2 || ( glConfig.glMajor == 2 && glConfig.glMinor < 1 ) ) { GLimp_DestroyWindowIfExists(); @@ -1508,8 +1508,8 @@ static bool IsSdlVideoRestartNeeded() return false; } - if ( glConfig2.driverVendor == glDriverVendor_t::MESA - && glConfig2.hardwareVendor == glHardwareVendor_t::ATI ) + if ( glConfig.driverVendor == glDriverVendor_t::MESA + && glConfig.hardwareVendor == glHardwareVendor_t::ATI ) { bool foundRv600 = false; @@ -1586,8 +1586,8 @@ static rserr_t GLimp_SetMode( const int mode, const bool fullscreen, const bool // HACK: We want to set the current value, not the latched value Cvar::ClearFlags("r_customwidth", CVAR_LATCH); Cvar::ClearFlags("r_customheight", CVAR_LATCH); - Cvar_Set( "r_customwidth", va("%d", glConfig.vidWidth ) ); - Cvar_Set( "r_customheight", va("%d", glConfig.vidHeight ) ); + Cvar_Set( "r_customwidth", va("%d", windowConfig.vidWidth ) ); + Cvar_Set( "r_customheight", va("%d", windowConfig.vidHeight ) ); Cvar::AddFlags("r_customwidth", CVAR_LATCH); Cvar::AddFlags("r_customheight", CVAR_LATCH); @@ -1610,8 +1610,8 @@ static rserr_t GLimp_SetMode( const int mode, const bool fullscreen, const bool if ( err == rserr_t::RSERR_OLD_GL ) { // Used by error message. - glConfig2.glMajor = bestValidatedConfiguration.major; - glConfig2.glMinor = bestValidatedConfiguration.minor; + glConfig.glMajor = bestValidatedConfiguration.major; + glConfig.glMinor = bestValidatedConfiguration.minor; } GLimp_DestroyWindowIfExists(); @@ -1796,7 +1796,7 @@ static rserr_t GLimp_StartDriverAndSetMode( int mode, bool fullscreen, bool bord break; case rserr_t::RSERR_OLD_GL: - Sys::Error( "OpenGL %d.%d is too old.\n\n%s", glConfig2.glMajor, glConfig2.glMinor, glRequirements ); + Sys::Error( "OpenGL %d.%d is too old.\n\n%s", glConfig.glMajor, glConfig.glMinor, glRequirements ); // Sys:Error calls OSExit() so the break and the return is unreachable. break; @@ -1925,7 +1925,7 @@ enum { static bool LoadExt( int flags, bool hasExt, const char* name, bool test = true ) { - if ( hasExt || ( flags & ExtFlag_CORE && glConfig2.glCoreProfile) ) + if ( hasExt || ( flags & ExtFlag_CORE && glConfig.glCoreProfile) ) { if ( test ) { @@ -1938,13 +1938,13 @@ static bool LoadExt( int flags, bool hasExt, const char* name, bool test = true logger.WithoutSuppression().Notice( "...using optional extension GL_%s.", name ); } - if ( glConfig2.glEnabledExtensionsString.length() != 0 ) + if ( glConfig.glEnabledExtensionsString.length() != 0 ) { - glConfig2.glEnabledExtensionsString += " "; + glConfig.glEnabledExtensionsString += " "; } - glConfig2.glEnabledExtensionsString += "GL_"; - glConfig2.glEnabledExtensionsString += name; + glConfig.glEnabledExtensionsString += "GL_"; + glConfig.glEnabledExtensionsString += name; return true; } @@ -1966,13 +1966,13 @@ static bool LoadExt( int flags, bool hasExt, const char* name, bool test = true { logger.WithoutSuppression().Notice( "...missing optional extension GL_%s.", name ); - if ( glConfig2.glMissingExtensionsString.length() != 0 ) + if ( glConfig.glMissingExtensionsString.length() != 0 ) { - glConfig2.glMissingExtensionsString += " "; + glConfig.glMissingExtensionsString += " "; } - glConfig2.glMissingExtensionsString += "GL_"; - glConfig2.glMissingExtensionsString += name; + glConfig.glMissingExtensionsString += "GL_"; + glConfig.glMissingExtensionsString += name; } } return false; @@ -2022,8 +2022,8 @@ static void GLimp_InitExtensions() Cvar::Latch( r_khr_debug ); Cvar::Latch( r_khr_shader_subgroup ); - glConfig2.glEnabledExtensionsString = std::string(); - glConfig2.glMissingExtensionsString = std::string(); + glConfig.glEnabledExtensionsString = std::string(); + glConfig.glMissingExtensionsString = std::string(); if ( LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_debug_output, r_khr_debug.Get() && r_glDebugProfile.Get() ) ) @@ -2034,42 +2034,42 @@ static void GLimp_InitExtensions() /* On OpenGL Core profile the ARB_fragment_program extension doesn't exist and the related getter functions return 0. We can assume OpenGL 3 Core hardware is featureful enough to not care about those limits. */ - if ( !glConfig2.glCoreProfile ) + if ( !glConfig.glCoreProfile ) { if ( LOAD_EXTENSION( ExtFlag_REQUIRED, ARB_fragment_program ) ) { - glGetProgramivARB( GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, &glConfig2.maxAluInstructions ); - glGetProgramivARB( GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, &glConfig2.maxTexIndirections ); + glGetProgramivARB( GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, &glConfig.maxAluInstructions ); + glGetProgramivARB( GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, &glConfig.maxTexIndirections ); } } // GLSL - Q_strncpyz( glConfig2.shadingLanguageVersionString, ( char * ) glGetString( GL_SHADING_LANGUAGE_VERSION_ARB ), - sizeof( glConfig2.shadingLanguageVersionString ) ); + Q_strncpyz( glConfig.shadingLanguageVersionString, ( char * ) glGetString( GL_SHADING_LANGUAGE_VERSION_ARB ), + sizeof( glConfig.shadingLanguageVersionString ) ); int majorVersion, minorVersion; - if ( sscanf( glConfig2.shadingLanguageVersionString, "%i.%i", &majorVersion, &minorVersion ) != 2 ) + if ( sscanf( glConfig.shadingLanguageVersionString, "%i.%i", &majorVersion, &minorVersion ) != 2 ) { logger.Warn("unrecognized shading language version string format" ); } - glConfig2.shadingLanguageVersion = majorVersion * 100 + minorVersion; + glConfig.shadingLanguageVersion = majorVersion * 100 + minorVersion; - logger.Notice("...using shading language version %i", glConfig2.shadingLanguageVersion ); + logger.Notice("...using shading language version %i", glConfig.shadingLanguageVersion ); // OpenGL driver constants. - glGetIntegerv( GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &glConfig2.maxTextureUnits ); + glGetIntegerv( GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &glConfig.maxTextureUnits ); glGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.maxTextureSize ); - glGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig2.max3DTextureSize ); - glGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig2.maxCubeMapTextureSize ); + glGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig.max3DTextureSize ); + glGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.maxCubeMapTextureSize ); // Stubbed or broken drivers may report garbage. - if ( glConfig2.maxTextureUnits < 0 ) + if ( glConfig.maxTextureUnits < 0 ) { - Log::Warn( "Bad GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS value: %d", glConfig2.maxTextureUnits ); - glConfig2.maxTextureUnits = 0; + Log::Warn( "Bad GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS value: %d", glConfig.maxTextureUnits ); + glConfig.maxTextureUnits = 0; } if ( glConfig.maxTextureSize < 0 ) @@ -2078,36 +2078,36 @@ static void GLimp_InitExtensions() glConfig.maxTextureSize = 0; } - if ( glConfig2.max3DTextureSize < 0 ) + if ( glConfig.max3DTextureSize < 0 ) { - Log::Warn( "Bad GL_MAX_3D_TEXTURE_SIZE value: %d", glConfig2.max3DTextureSize ); - glConfig2.max3DTextureSize = 0; + Log::Warn( "Bad GL_MAX_3D_TEXTURE_SIZE value: %d", glConfig.max3DTextureSize ); + glConfig.max3DTextureSize = 0; } - if ( glConfig2.maxCubeMapTextureSize < 0 ) + if ( glConfig.maxCubeMapTextureSize < 0 ) { - Log::Warn( "Bad GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB value: %d", glConfig2.maxCubeMapTextureSize ); - glConfig2.maxCubeMapTextureSize = 0; + Log::Warn( "Bad GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB value: %d", glConfig.maxCubeMapTextureSize ); + glConfig.maxCubeMapTextureSize = 0; } logger.Notice( "...using up to %d texture size.", glConfig.maxTextureSize ); - logger.Notice( "...using up to %d 3D texture size.", glConfig2.max3DTextureSize ); - logger.Notice( "...using up to %d cube map texture size.", glConfig2.maxCubeMapTextureSize ); - logger.Notice( "...using up to %d texture units.", glConfig2.maxTextureUnits ); + logger.Notice( "...using up to %d 3D texture size.", glConfig.max3DTextureSize ); + logger.Notice( "...using up to %d cube map texture size.", glConfig.maxCubeMapTextureSize ); + logger.Notice( "...using up to %d texture units.", glConfig.maxTextureUnits ); // Texture formats and compression. // made required in OpenGL 3.0 - glConfig2.textureHalfFloatAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_half_float_pixel, r_arb_half_float_pixel.Get() ); + glConfig.textureHalfFloatAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_half_float_pixel, r_arb_half_float_pixel.Get() ); // made required in OpenGL 3.0 - glConfig2.textureFloatAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_texture_float, r_ext_texture_float.Get() ); + glConfig.textureFloatAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_texture_float, r_ext_texture_float.Get() ); bool gpuShader4Enabled = r_ext_gpu_shader4.Get(); if ( gpuShader4Enabled && SILENTLY_CHECK_EXTENSION( EXT_gpu_shader4 ) - && glConfig2.shadingLanguageVersion <= 120 + && glConfig.shadingLanguageVersion <= 120 && workaround_glExtension_glsl120_disableGpuShader4.Get() ) { // EXT_gpu_shader4 behaves slightly differently when running on GLSL 1.20. @@ -2117,18 +2117,18 @@ static void GLimp_InitExtensions() } // made required in OpenGL 3.0 - glConfig2.gpuShader4Available = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, EXT_gpu_shader4, gpuShader4Enabled ); + glConfig.gpuShader4Available = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, EXT_gpu_shader4, gpuShader4Enabled ); // made required in OpenGL 4.0 - glConfig2.gpuShader5Available = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_gpu_shader5, r_arb_gpu_shader5.Get() ); + glConfig.gpuShader5Available = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_gpu_shader5, r_arb_gpu_shader5.Get() ); // made required in OpenGL 3.0 // GL_EXT_texture_integer can be used in shaders only if GL_EXT_gpu_shader4 is also available - glConfig2.textureIntegerAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, EXT_texture_integer, r_ext_texture_integer.Get() ) - && glConfig2.gpuShader4Available; + glConfig.textureIntegerAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, EXT_texture_integer, r_ext_texture_integer.Get() ) + && glConfig.gpuShader4Available; // made required in OpenGL 3.0 - glConfig2.textureRGAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_texture_rg, r_ext_texture_rg.Get() ); + glConfig.textureRGAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_texture_rg, r_ext_texture_rg.Get() ); { bool textureGatherEnabled = r_arb_texture_gather.Get(); @@ -2154,7 +2154,7 @@ static void GLimp_InitExtensions() need for such extension and the related shader code useless. */ if ( workaround_glDriver_nvidia_v340_disableTextureGather.Get() ) { - if ( glConfig2.driverVendor == glDriverVendor_t::NVIDIA + if ( glConfig.driverVendor == glDriverVendor_t::NVIDIA && Q_stristr( glConfig.version_string, " NVIDIA 340." ) ) { // No need for WithoutSuppression for something which can only be printed once per renderer restart. @@ -2164,11 +2164,11 @@ static void GLimp_InitExtensions() } // made required in OpenGL 4.0 - glConfig2.textureGatherAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_texture_gather, textureGatherEnabled ); + glConfig.textureGatherAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_texture_gather, textureGatherEnabled ); } if ( workaround_glHardware_intel_useFirstProvokinVertex.Get() - && glConfig2.hardwareVendor == glHardwareVendor_t::INTEL ) + && glConfig.hardwareVendor == glHardwareVendor_t::INTEL ) { if ( LOAD_EXTENSION( ExtFlag_NONE, ARB_provoking_vertex ) ) { @@ -2196,18 +2196,18 @@ static void GLimp_InitExtensions() } // made required in OpenGL 3.0 - glConfig2.textureCompressionRGTCAvailable = LOAD_EXTENSION( ExtFlag_CORE, ARB_texture_compression_rgtc ); + glConfig.textureCompressionRGTCAvailable = LOAD_EXTENSION( ExtFlag_CORE, ARB_texture_compression_rgtc ); // Texture - others - glConfig2.textureAnisotropyAvailable = false; - glConfig2.textureAnisotropy = 0.0f; + glConfig.textureAnisotropyAvailable = false; + glConfig.textureAnisotropy = 0.0f; if ( LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, EXT_texture_filter_anisotropic, r_ext_texture_filter_anisotropic.Get() > 0 ) ) { - glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig2.maxTextureAnisotropy ); - glConfig2.textureAnisotropyAvailable = true; + glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.maxTextureAnisotropy ); + glConfig.textureAnisotropyAvailable = true; // Bound texture anisotropy. - glConfig2.textureAnisotropy = std::max( std::min( r_ext_texture_filter_anisotropic.Get(), glConfig2.maxTextureAnisotropy ), 1.0f ); + glConfig.textureAnisotropy = std::max( std::min( r_ext_texture_filter_anisotropic.Get(), glConfig.maxTextureAnisotropy ), 1.0f ); } // VAO and VBO @@ -2227,9 +2227,9 @@ static void GLimp_InitExtensions() { bool halfFloatVertexEnabled = r_arb_half_float_vertex.Get(); - if ( halfFloatVertexEnabled && glConfig2.driverVendor == glDriverVendor_t::MESA ) + if ( halfFloatVertexEnabled && glConfig.driverVendor == glDriverVendor_t::MESA ) { - if ( glConfig2.hardwareVendor == glHardwareVendor_t::ATI ) + if ( glConfig.hardwareVendor == glHardwareVendor_t::ATI ) { bool foundRv300 = false; @@ -2256,7 +2256,7 @@ static void GLimp_InitExtensions() if ( !foundRv300 ) { if ( glConfig.hardwareType == glHardwareType_t::GLHW_R300 - && glConfig2.maxAluInstructions == 64 ) + && glConfig.maxAluInstructions == 64 ) { cardName = "unknown ATI RV3xx"; foundRv300 = true; @@ -2269,7 +2269,7 @@ static void GLimp_InitExtensions() halfFloatVertexEnabled = false; } } - else if ( glConfig2.hardwareVendor == glHardwareVendor_t::BROADCOM ) + else if ( glConfig.hardwareVendor == glHardwareVendor_t::BROADCOM ) { bool foundVc4 = Str::IsPrefix( "VC4 ", glConfig.renderer_string ); @@ -2282,7 +2282,7 @@ static void GLimp_InitExtensions() } // made required in OpenGL 3.0 - glConfig2.halfFloatVertexAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_half_float_vertex, halfFloatVertexEnabled ); + glConfig.halfFloatVertexAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_half_float_vertex, halfFloatVertexEnabled ); if ( !halfFloatVertexEnabled ) { @@ -2324,15 +2324,15 @@ static void GLimp_InitExtensions() glFboSetExt(); } - glGetIntegerv( GL_MAX_RENDERBUFFER_SIZE, &glConfig2.maxRenderbufferSize ); - glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS, &glConfig2.maxColorAttachments ); + glGetIntegerv( GL_MAX_RENDERBUFFER_SIZE, &glConfig.maxRenderbufferSize ); + glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS, &glConfig.maxColorAttachments ); // made required in OpenGL 2.0 - glConfig2.drawBuffersAvailable = false; + glConfig.drawBuffersAvailable = false; if ( r_ext_draw_buffers.Get() ) { - glGetIntegerv( GL_MAX_DRAW_BUFFERS, &glConfig2.maxDrawBuffers ); - glConfig2.drawBuffersAvailable = true; + glGetIntegerv( GL_MAX_DRAW_BUFFERS, &glConfig.maxDrawBuffers ); + glConfig.drawBuffersAvailable = true; } { @@ -2346,25 +2346,25 @@ static void GLimp_InitExtensions() logger.Notice("...no program binary formats"); } - glConfig2.getProgramBinaryAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_get_program_binary, formats > 0 ); + glConfig.getProgramBinaryAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_get_program_binary, formats > 0 ); } - glConfig2.bufferStorageAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_buffer_storage, r_arb_buffer_storage.Get() ); + glConfig.bufferStorageAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_buffer_storage, r_arb_buffer_storage.Get() ); // made required since OpenGL 3.1 - glConfig2.uniformBufferObjectAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_uniform_buffer_object, r_arb_uniform_buffer_object.Get() ); + glConfig.uniformBufferObjectAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_uniform_buffer_object, r_arb_uniform_buffer_object.Get() ); // made required in OpenGL 3.0 - glConfig2.mapBufferRangeAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_map_buffer_range, r_arb_map_buffer_range.Get() ); + glConfig.mapBufferRangeAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_map_buffer_range, r_arb_map_buffer_range.Get() ); // made required in OpenGL 3.2 - glConfig2.syncAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_sync, r_arb_sync.Get() ); + glConfig.syncAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_CORE, ARB_sync, r_arb_sync.Get() ); // made required in OpenGL 4.5 - glConfig2.textureBarrierAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_texture_barrier, r_arb_texture_barrier.Get() ); + glConfig.textureBarrierAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_texture_barrier, r_arb_texture_barrier.Get() ); // made required in OpenGL 4.3 - glConfig2.computeShaderAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_compute_shader, r_arb_compute_shader.Get() ); + glConfig.computeShaderAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_compute_shader, r_arb_compute_shader.Get() ); { bool bindlessTextureEnabled = r_arb_bindless_texture.Get(); @@ -2379,7 +2379,7 @@ static void GLimp_InitExtensions() - https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30315 - https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30338 - https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/932 */ - if ( glConfig2.driverVendor == glDriverVendor_t::MESA ) + if ( glConfig.driverVendor == glDriverVendor_t::MESA ) { const char *str1 = "Mesa 24."; @@ -2436,7 +2436,7 @@ static void GLimp_InitExtensions() } // AMD proprietary drivers are known to have buggy bindless texture implementation. - else if ( glConfig2.hardwareVendor == glHardwareVendor_t::ATI ) + else if ( glConfig.hardwareVendor == glHardwareVendor_t::ATI ) { // AMD proprietary driver for macOS does not implement bindless texture. // Other systems like FreeBSD don't have AMD proprietary drivers. @@ -2480,14 +2480,14 @@ static void GLimp_InitExtensions() } // not required by any OpenGL version - glConfig2.bindlessTexturesAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_bindless_texture, bindlessTextureEnabled ); + glConfig.bindlessTexturesAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_bindless_texture, bindlessTextureEnabled ); } bool shaderDrawParametersEnabled = r_arb_shader_draw_parameters.Get(); if ( shaderDrawParametersEnabled && SILENTLY_CHECK_EXTENSION( ARB_shader_draw_parameters ) - && glConfig2.shadingLanguageVersion <= 120 + && glConfig.shadingLanguageVersion <= 120 && workaround_glExtension_glsl120_disableShaderDrawParameters.Get() ) { logger.Warn( "Found ARB_shader_draw_parameters with incompatible GLSL 1.20, disabling ARB_shader_draw_parameters." ); @@ -2495,92 +2495,92 @@ static void GLimp_InitExtensions() } // made required in OpenGL 4.6 - glConfig2.shaderDrawParametersAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_draw_parameters, shaderDrawParametersEnabled ); + glConfig.shaderDrawParametersAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_draw_parameters, shaderDrawParametersEnabled ); // made required in OpenGL 4.3 - glConfig2.SSBOAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_storage_buffer_object, r_arb_shader_storage_buffer_object.Get() ); + glConfig.SSBOAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_storage_buffer_object, r_arb_shader_storage_buffer_object.Get() ); // made required in OpenGL 4.0 - glConfig2.multiDrawIndirectAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_multi_draw_indirect, r_arb_multi_draw_indirect.Get() ); + glConfig.multiDrawIndirectAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_multi_draw_indirect, r_arb_multi_draw_indirect.Get() ); // made required in OpenGL 4.2 - glConfig2.shadingLanguage420PackAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shading_language_420pack, r_arb_shading_language_420pack.Get() ); + glConfig.shadingLanguage420PackAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shading_language_420pack, r_arb_shading_language_420pack.Get() ); // made required in OpenGL 4.3 - glConfig2.explicitUniformLocationAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_explicit_uniform_location, r_arb_explicit_uniform_location.Get() ); + glConfig.explicitUniformLocationAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_explicit_uniform_location, r_arb_explicit_uniform_location.Get() ); // made required in OpenGL 4.2 - glConfig2.shaderImageLoadStoreAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_image_load_store, r_arb_shader_image_load_store.Get() ); + glConfig.shaderImageLoadStoreAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_image_load_store, r_arb_shader_image_load_store.Get() ); // made required in OpenGL 4.2 - glConfig2.shaderAtomicCountersAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_atomic_counters, r_arb_shader_atomic_counters.Get() ); + glConfig.shaderAtomicCountersAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_atomic_counters, r_arb_shader_atomic_counters.Get() ); // made required in OpenGL 4.6 - glConfig2.shaderAtomicCounterOpsAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_atomic_counter_ops, r_arb_shader_atomic_counter_ops.Get() ); + glConfig.shaderAtomicCounterOpsAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_shader_atomic_counter_ops, r_arb_shader_atomic_counter_ops.Get() ); // made required in OpenGL 4.6 - glConfig2.indirectParametersAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_indirect_parameters, r_arb_indirect_parameters.Get() ); + glConfig.indirectParametersAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_indirect_parameters, r_arb_indirect_parameters.Get() ); // made required in OpenGL 4.5 - glConfig2.directStateAccessAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_direct_state_access, r_arb_direct_state_access.Get() ); + glConfig.directStateAccessAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_direct_state_access, r_arb_direct_state_access.Get() ); // made required in OpenGL 4.3 - glConfig2.vertexAttribBindingAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_vertex_attrib_binding, r_arb_vertex_attrib_binding.Get() ); - - glConfig2.geometryCacheAvailable = glConfig2.vertexAttribBindingAvailable && glConfig2.directStateAccessAvailable; - - glConfig2.materialSystemAvailable = - glConfig2.bindlessTexturesAvailable - && glConfig2.computeShaderAvailable - && glConfig2.directStateAccessAvailable - && glConfig2.explicitUniformLocationAvailable - && glConfig2.geometryCacheAvailable - && glConfig2.gpuShader4Available - && glConfig2.indirectParametersAvailable - && glConfig2.multiDrawIndirectAvailable - && glConfig2.shaderAtomicCountersAvailable - && glConfig2.shaderDrawParametersAvailable - && glConfig2.shaderImageLoadStoreAvailable - && glConfig2.shadingLanguage420PackAvailable - && glConfig2.SSBOAvailable - && glConfig2.uniformBufferObjectAvailable; + glConfig.vertexAttribBindingAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, ARB_vertex_attrib_binding, r_arb_vertex_attrib_binding.Get() ); + + glConfig.geometryCacheAvailable = glConfig.vertexAttribBindingAvailable && glConfig.directStateAccessAvailable; + + glConfig.materialSystemAvailable = + glConfig.bindlessTexturesAvailable + && glConfig.computeShaderAvailable + && glConfig.directStateAccessAvailable + && glConfig.explicitUniformLocationAvailable + && glConfig.geometryCacheAvailable + && glConfig.gpuShader4Available + && glConfig.indirectParametersAvailable + && glConfig.multiDrawIndirectAvailable + && glConfig.shaderAtomicCountersAvailable + && glConfig.shaderDrawParametersAvailable + && glConfig.shaderImageLoadStoreAvailable + && glConfig.shadingLanguage420PackAvailable + && glConfig.SSBOAvailable + && glConfig.uniformBufferObjectAvailable; // This requires GLEW 2.2+, so skip if it's a lower version #if defined(GLEW_KHR_shader_subgroup) // not required by any OpenGL version - glConfig2.shaderSubgroupAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, KHR_shader_subgroup, r_khr_shader_subgroup.Get() ); + glConfig.shaderSubgroupAvailable = LOAD_EXTENSION_WITH_TEST( ExtFlag_NONE, KHR_shader_subgroup, r_khr_shader_subgroup.Get() ); - if ( glConfig2.shaderSubgroupAvailable ) { + if ( glConfig.shaderSubgroupAvailable ) { int subgroupFeatures; glGetIntegerv( GL_SUBGROUP_SUPPORTED_FEATURES_KHR, &subgroupFeatures ); - glConfig2.shaderSubgroupBasicAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_BASIC_BIT_KHR; - glConfig2.shaderSubgroupVoteAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_VOTE_BIT_KHR; - glConfig2.shaderSubgroupArithmeticAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR; - glConfig2.shaderSubgroupBallotAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR; - glConfig2.shaderSubgroupShuffleAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR; - glConfig2.shaderSubgroupShuffleRelativeAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR; - glConfig2.shaderSubgroupQuadAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_QUAD_BIT_KHR; + glConfig.shaderSubgroupBasicAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_BASIC_BIT_KHR; + glConfig.shaderSubgroupVoteAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_VOTE_BIT_KHR; + glConfig.shaderSubgroupArithmeticAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR; + glConfig.shaderSubgroupBallotAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR; + glConfig.shaderSubgroupShuffleAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR; + glConfig.shaderSubgroupShuffleRelativeAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR; + glConfig.shaderSubgroupQuadAvailable = subgroupFeatures & GL_SUBGROUP_FEATURE_QUAD_BIT_KHR; Log::Notice( "Supported subgroup extensions: basic: %s, vote: %s, arithmetic: %s, ballot: %s, shuffle: %s, " - "shuffle_relative: %s, quad: %s", glConfig2.shaderSubgroupBasicAvailable, - glConfig2.shaderSubgroupVoteAvailable, glConfig2.shaderSubgroupArithmeticAvailable, - glConfig2.shaderSubgroupBallotAvailable, glConfig2.shaderSubgroupShuffleAvailable, - glConfig2.shaderSubgroupShuffleRelativeAvailable, glConfig2.shaderSubgroupQuadAvailable ); + "shuffle_relative: %s, quad: %s", glConfig.shaderSubgroupBasicAvailable, + glConfig.shaderSubgroupVoteAvailable, glConfig.shaderSubgroupArithmeticAvailable, + glConfig.shaderSubgroupBallotAvailable, glConfig.shaderSubgroupShuffleAvailable, + glConfig.shaderSubgroupShuffleRelativeAvailable, glConfig.shaderSubgroupQuadAvailable ); } #else - glConfig2.shaderSubgroupAvailable = false; + glConfig.shaderSubgroupAvailable = false; - glConfig2.shaderSubgroupBasicAvailable = false; - glConfig2.shaderSubgroupVoteAvailable = false; - glConfig2.shaderSubgroupArithmeticAvailable = false; - glConfig2.shaderSubgroupBallotAvailable = false; - glConfig2.shaderSubgroupShuffleAvailable = false; - glConfig2.shaderSubgroupShuffleRelativeAvailable = false; - glConfig2.shaderSubgroupQuadAvailable = false; + glConfig.shaderSubgroupBasicAvailable = false; + glConfig.shaderSubgroupVoteAvailable = false; + glConfig.shaderSubgroupArithmeticAvailable = false; + glConfig.shaderSubgroupBallotAvailable = false; + glConfig.shaderSubgroupShuffleAvailable = false; + glConfig.shaderSubgroupShuffleRelativeAvailable = false; + glConfig.shaderSubgroupQuadAvailable = false; // Currently this functionality is only used by material system shaders - if ( glConfig2.materialSystemAvailable ) { + if ( glConfig.materialSystemAvailable ) { logger.Notice( "^1Using outdated GLEW version, GL_KHR_shader_subgroup unavailable." "Update GLEW to 2.2+ to be able to use this extension" ); } @@ -2589,20 +2589,20 @@ static void GLimp_InitExtensions() // Shader limits. // From GL_ARB_vertex_shader. - glGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig2.maxVertexUniforms ); + glGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig.maxVertexUniforms ); // From GL_ARB_vertex_program. - glGetIntegerv( GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig2.maxVertexAttribs ); + glGetIntegerv( GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig.maxVertexAttribs ); // From GL_ARB_uniform_buffer_object. - if ( glConfig2.uniformBufferObjectAvailable ) + if ( glConfig.uniformBufferObjectAvailable ) { - glGetIntegerv( GL_MAX_UNIFORM_BLOCK_SIZE, &glConfig2.maxUniformBlockSize ); + glGetIntegerv( GL_MAX_UNIFORM_BLOCK_SIZE, &glConfig.maxUniformBlockSize ); } int reservedComponents = 36 * 10; // approximation how many uniforms we have besides the bone matrices - glConfig2.maxVertexSkinningBones = Math::Clamp( ( glConfig2.maxVertexUniforms - reservedComponents ) / 16, 0, MAX_BONES ); - glConfig2.vboVertexSkinningAvailable = r_vboVertexSkinning->integer && ( ( glConfig2.maxVertexSkinningBones >= 12 ) ? true : false ); + glConfig.maxVertexSkinningBones = Math::Clamp( ( glConfig.maxVertexUniforms - reservedComponents ) / 16, 0, MAX_BONES ); + glConfig.vboVertexSkinningAvailable = r_vboVertexSkinning->integer && ( ( glConfig.maxVertexSkinningBones >= 12 ) ? true : false ); GL_CheckErrors(); } @@ -2754,15 +2754,15 @@ bool GLimp_Init() glConfig.vendor_string, glConfig.version_string, glConfig.renderer_string, - glConfig2.hardwareVendor, - glConfig2.driverVendor ); + glConfig.hardwareVendor, + glConfig.driverVendor ); - Log::Debug( "Detected OpenGL hardware vendor: %s", GetGLHardwareVendorName( glConfig2.hardwareVendor ) ); - Log::Debug( "Detected OpenGL driver vendor: %s", GetGLDriverVendorName( glConfig2.driverVendor ) ); + Log::Debug( "Detected OpenGL hardware vendor: %s", GetGLHardwareVendorName( glConfig.hardwareVendor ) ); + Log::Debug( "Detected OpenGL driver vendor: %s", GetGLDriverVendorName( glConfig.driverVendor ) ); - glConfig2.glExtensionsString = std::string(); + glConfig.glExtensionsString = std::string(); - if ( glConfig2.glMajor >= 3 ) + if ( glConfig.glMajor >= 3 ) { GLint numExts, i; @@ -2800,7 +2800,7 @@ bool GLimp_Init() logger.Debug( "OpenGL extensions found: %s", glExtensionsString ); - glConfig2.glExtensionsString = glExtensionsString; + glConfig.glExtensionsString = glExtensionsString; } else { @@ -2821,12 +2821,12 @@ bool GLimp_Init() logger.Debug( "OpenGL extensions found: %s", glExtensionsString ); - glConfig2.glExtensionsString = glExtensionsString; + glConfig.glExtensionsString = glExtensionsString; } } - if ( glConfig2.hardwareVendor == glHardwareVendor_t::ATI && - std::make_pair( glConfig2.glMajor, glConfig2.glMinor ) < std::make_pair( 3, 2 ) ) + if ( glConfig.hardwareVendor == glHardwareVendor_t::ATI && + std::make_pair( glConfig.glMajor, glConfig.glMinor ) < std::make_pair( 3, 2 ) ) { glConfig.hardwareType = glHardwareType_t::GLHW_R300; }