From 15a1ebdd740103f6de4e5b8d08409610a9ef114a Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Mon, 15 Jul 2024 12:45:15 -0400 Subject: [PATCH] Deleted gl1_biglightmaps glTexSubImage2D() calls are very slow, and are even slower when the texture is big. Dynamic lighting changes are small compared to the huge 512x512 size of the lightmap this option provided, so it was detrimental to performance. Original logic remains underneath if there's a need of a comeback. --- doc/040_cvarlist.md | 4 --- src/client/refresh/gl1/gl1_main.c | 36 ++++++--------------------- src/client/refresh/gl1/header/local.h | 1 - 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index 0c0bba93..1cd8b87e 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -471,10 +471,6 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` ## Graphics (OpenGL 1.4 only) -* **gl1_biglightmaps**: Enables lightmaps and scrap to use a bigger - texture size, which means fewer texture switches, improving - performance. Default is `1` (enabled). Requires a `vid_restart`. - * **gl1_intensity**: Sets the color intensity. Must be a floating point value, at least `1.0` - default is `2.0`. Applied when textures are loaded, so it needs a `vid_restart`. diff --git a/src/client/refresh/gl1/gl1_main.c b/src/client/refresh/gl1/gl1_main.c index 1afef160..4edfe024 100644 --- a/src/client/refresh/gl1/gl1_main.c +++ b/src/client/refresh/gl1/gl1_main.c @@ -91,7 +91,6 @@ cvar_t *gl1_particle_square; cvar_t *gl1_palettedtexture; cvar_t *gl1_pointparameters; cvar_t *gl1_multitexture; -cvar_t *gl1_biglightmaps; cvar_t *gl_drawbuffer; cvar_t *gl_lightmap; @@ -1221,7 +1220,6 @@ R_Register(void) gl1_palettedtexture = ri.Cvar_Get("r_palettedtextures", "0", CVAR_ARCHIVE); gl1_pointparameters = ri.Cvar_Get("gl1_pointparameters", "1", CVAR_ARCHIVE); gl1_multitexture = ri.Cvar_Get("gl1_multitexture", "1", CVAR_ARCHIVE); - gl1_biglightmaps = ri.Cvar_Get("gl1_biglightmaps", "1", CVAR_ARCHIVE); gl_drawbuffer = ri.Cvar_Get("gl_drawbuffer", "GL_BACK", 0); r_vsync = ri.Cvar_Get("r_vsync", "1", CVAR_ARCHIVE); @@ -1402,7 +1400,7 @@ R_SetMode(void) qboolean RI_Init(void) { - int j, max_tex_size; + int j; byte *colormap; extern float r_turbsin[256]; @@ -1621,35 +1619,17 @@ RI_Init(void) // ---- - /* Big lightmaps */ - R_Printf(PRINT_ALL, " - Big lightmaps: "); + /* Big lightmaps: this used to be fast, but after the implementation of the "GL Buffer", it + * became too evident that the bigger the texture, the slower the call to glTexSubImage2D() is. + * Original logic remains, but it's preferable not to make it visible to the user. + * Let's see if something changes in the future. + */ gl_state.block_width = BLOCK_WIDTH; gl_state.block_height = BLOCK_HEIGHT; gl_state.max_lightmaps = MAX_LIGHTMAPS; - gl_state.scrap_width = BLOCK_WIDTH; - gl_state.scrap_height = BLOCK_HEIGHT; - glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_tex_size); - if (max_tex_size > BLOCK_WIDTH) - { - if (gl1_biglightmaps->value) - { - gl_state.block_width = gl_state.block_height = Q_min(max_tex_size, 512); - gl_state.max_lightmaps = (BLOCK_WIDTH * BLOCK_HEIGHT * MAX_LIGHTMAPS) - / (gl_state.block_width * gl_state.block_height); - gl_state.scrap_width = gl_state.scrap_height = - (gl_config.npottextures)? Q_min(max_tex_size, 384) : Q_min(max_tex_size, 256); - R_Printf(PRINT_ALL, "Okay\n"); - } - else - { - R_Printf(PRINT_ALL, "Disabled\n"); - } - } - else - { - R_Printf(PRINT_ALL, "Failed, detected texture size = %d\n", max_tex_size); - } + gl_state.scrap_width = BLOCK_WIDTH * 2; + gl_state.scrap_height = BLOCK_HEIGHT * 2; // ---- diff --git a/src/client/refresh/gl1/header/local.h b/src/client/refresh/gl1/header/local.h index cfa97c15..ada739b9 100644 --- a/src/client/refresh/gl1/header/local.h +++ b/src/client/refresh/gl1/header/local.h @@ -165,7 +165,6 @@ extern cvar_t *gl1_overbrightbits; extern cvar_t *gl1_palettedtexture; extern cvar_t *gl1_pointparameters; extern cvar_t *gl1_multitexture; -extern cvar_t *gl1_biglightmaps; extern cvar_t *gl1_particle_min_size; extern cvar_t *gl1_particle_max_size;