From 660f5728c10910dd8bc808df28d7ea3e083a84a8 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sun, 15 Oct 2023 14:45:16 +0300 Subject: [PATCH] gl1,gl3,gl4,vk: Sync LM size Need to search way to dynamically change prefered lightmap texture size and sync LM caching structures and code. internal_format is always GL_LIGHTMAP_FORMAT so just directly use constant instead set to variable. --- src/client/refresh/gl1/gl1_lightmap.c | 6 ++---- src/client/refresh/gl1/header/local.h | 4 ---- src/client/refresh/gl3/gl3_lightmap.c | 4 +--- src/client/refresh/gl3/header/local.h | 6 ------ src/client/refresh/gl4/gl4_lightmap.c | 4 +--- src/client/refresh/gl4/header/local.h | 6 ------ src/client/refresh/ref_shared.h | 8 ++++++++ src/client/refresh/vk/header/local.h | 3 --- src/client/refresh/vk/vk_lightmap.c | 2 -- 9 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/client/refresh/gl1/gl1_lightmap.c b/src/client/refresh/gl1/gl1_lightmap.c index f42f03b9..1873abf7 100644 --- a/src/client/refresh/gl1/gl1_lightmap.c +++ b/src/client/refresh/gl1/gl1_lightmap.c @@ -71,8 +71,7 @@ LM_UploadBlock(qboolean dynamic) } else { - gl_lms.internal_format = GL_LIGHTMAP_FORMAT; - glTexImage2D(GL_TEXTURE_2D, 0, gl_lms.internal_format, + glTexImage2D(GL_TEXTURE_2D, 0, GL_LIGHTMAP_FORMAT, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, gl_lms.lightmap_buffer); @@ -287,13 +286,12 @@ LM_BeginBuildingLightmaps(model_t *m) } gl_lms.current_lightmap_texture = 1; - gl_lms.internal_format = GL_LIGHTMAP_FORMAT; /* initialize the dynamic lightmap texture */ R_Bind(gl_state.lightmap_textures + 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, gl_lms.internal_format, + glTexImage2D(GL_TEXTURE_2D, 0, GL_LIGHTMAP_FORMAT, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, dummy); } diff --git a/src/client/refresh/gl1/header/local.h b/src/client/refresh/gl1/header/local.h index 02651be6..612617cb 100644 --- a/src/client/refresh/gl1/header/local.h +++ b/src/client/refresh/gl1/header/local.h @@ -62,11 +62,8 @@ #define TEXNUM_IMAGES 1153 #define MAX_GLTEXTURES 1024 #define MAX_SCRAPS 1 -#define BLOCK_WIDTH 128 -#define BLOCK_HEIGHT 128 #define REF_VERSION "Yamagi Quake II OpenGL Refresher" #define BACKFACE_EPSILON 0.01 -#define LIGHTMAP_BYTES 4 #define MAX_LIGHTMAPS 256 #define GL_LIGHTMAP_FORMAT GL_RGBA @@ -334,7 +331,6 @@ typedef struct typedef struct { - int internal_format; int current_lightmap_texture; msurface_t *lightmap_surfaces[MAX_LIGHTMAPS]; diff --git a/src/client/refresh/gl3/gl3_lightmap.c b/src/client/refresh/gl3/gl3_lightmap.c index 03fce717..b9a2bce4 100644 --- a/src/client/refresh/gl3/gl3_lightmap.c +++ b/src/client/refresh/gl3/gl3_lightmap.c @@ -56,8 +56,7 @@ GL3_LM_UploadBlock(void) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gl3_lms.internal_format = GL_LIGHTMAP_FORMAT; - glTexImage2D(GL_TEXTURE_2D, 0, gl3_lms.internal_format, + glTexImage2D(GL_TEXTURE_2D, 0, GL_LIGHTMAP_FORMAT, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, gl3_lms.lightmap_buffers[map]); } @@ -256,7 +255,6 @@ GL3_LM_BeginBuildingLightmaps(gl3model_t *m) gl3_newrefdef.lightstyles = lightstyles; gl3_lms.current_lightmap_texture = 0; - gl3_lms.internal_format = GL_LIGHTMAP_FORMAT; // Note: the dynamic lightmap used to be initialized here, we don't use that anymore. } diff --git a/src/client/refresh/gl3/header/local.h b/src/client/refresh/gl3/header/local.h index da8d48d8..733dca0f 100644 --- a/src/client/refresh/gl3/header/local.h +++ b/src/client/refresh/gl3/header/local.h @@ -186,11 +186,6 @@ typedef struct } gl3UniLights_t; enum { - // width and height used to be 128, so now we should be able to get the same lightmap data - // that used 32 lightmaps before into one, so 4 lightmaps should be enough - BLOCK_WIDTH = 1024, - BLOCK_HEIGHT = 512, - LIGHTMAP_BYTES = 4, MAX_LIGHTMAPS = 4, MAX_LIGHTMAPS_PER_SURFACE = MAXLIGHTMAPS // 4 }; @@ -317,7 +312,6 @@ enum {MAX_GL3TEXTURES = 1024}; typedef struct { - int internal_format; int current_lightmap_texture; // index into gl3state.lightmap_textureIDs[] //msurface_t *lightmap_surfaces[MAX_LIGHTMAPS]; - no more lightmap chains, lightmaps are rendered multitextured diff --git a/src/client/refresh/gl4/gl4_lightmap.c b/src/client/refresh/gl4/gl4_lightmap.c index a079a596..653618b1 100644 --- a/src/client/refresh/gl4/gl4_lightmap.c +++ b/src/client/refresh/gl4/gl4_lightmap.c @@ -56,8 +56,7 @@ GL4_LM_UploadBlock(void) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - gl4_lms.internal_format = GL_LIGHTMAP_FORMAT; - glTexImage2D(GL_TEXTURE_2D, 0, gl4_lms.internal_format, + glTexImage2D(GL_TEXTURE_2D, 0, GL_LIGHTMAP_FORMAT, BLOCK_WIDTH, BLOCK_HEIGHT, 0, GL_LIGHTMAP_FORMAT, GL_UNSIGNED_BYTE, gl4_lms.lightmap_buffers[map]); } @@ -256,7 +255,6 @@ GL4_LM_BeginBuildingLightmaps(gl4model_t *m) gl4_newrefdef.lightstyles = lightstyles; gl4_lms.current_lightmap_texture = 0; - gl4_lms.internal_format = GL_LIGHTMAP_FORMAT; // Note: the dynamic lightmap used to be initialized here, we don't use that anymore. } diff --git a/src/client/refresh/gl4/header/local.h b/src/client/refresh/gl4/header/local.h index 87005411..6f62d248 100644 --- a/src/client/refresh/gl4/header/local.h +++ b/src/client/refresh/gl4/header/local.h @@ -186,11 +186,6 @@ typedef struct } gl4UniLights_t; enum { - // width and height used to be 128, so now we should be able to get the same lightmap data - // that used 32 lightmaps before into one, so 4 lightmaps should be enough - BLOCK_WIDTH = 1024, - BLOCK_HEIGHT = 512, - LIGHTMAP_BYTES = 4, MAX_LIGHTMAPS = 4, MAX_LIGHTMAPS_PER_SURFACE = MAXLIGHTMAPS // 4 }; @@ -319,7 +314,6 @@ enum {MAX_GL4TEXTURES = 1024}; typedef struct { - int internal_format; int current_lightmap_texture; // index into gl4state.lightmap_textureIDs[] //msurface_t *lightmap_surfaces[MAX_LIGHTMAPS]; - no more lightmap chains, lightmaps are rendered multitextured diff --git a/src/client/refresh/ref_shared.h b/src/client/refresh/ref_shared.h index 1be4b228..21e6bf5e 100644 --- a/src/client/refresh/ref_shared.h +++ b/src/client/refresh/ref_shared.h @@ -271,6 +271,14 @@ typedef struct msurface_s struct surfcache_s *cachespots[MIPLEVELS]; /* surface generation data */ } msurface_t; +enum { + // width and height used to be 128, so now we should be able to get the same lightmap data + // that used 32 lightmaps before into one, so 4 lightmaps should be enough + BLOCK_WIDTH = 1024, + BLOCK_HEIGHT = 512, + LIGHTMAP_BYTES = 4, +}; + /* BSPX Light octtree */ #define LGNODE_LEAF (1u<<31) #define LGNODE_MISSING (1u<<30) diff --git a/src/client/refresh/vk/header/local.h b/src/client/refresh/vk/header/local.h index a66b65ee..ec5d6c8f 100644 --- a/src/client/refresh/vk/header/local.h +++ b/src/client/refresh/vk/header/local.h @@ -279,9 +279,6 @@ typedef struct #define MAX_LIGHTMAPS 256 #define DYNLIGHTMAP_OFFSET MAX_LIGHTMAPS -#define BLOCK_WIDTH 128 -#define BLOCK_HEIGHT 128 - typedef struct { int current_lightmap_texture; diff --git a/src/client/refresh/vk/vk_lightmap.c b/src/client/refresh/vk/vk_lightmap.c index 22dfbe8a..c8178258 100644 --- a/src/client/refresh/vk/vk_lightmap.c +++ b/src/client/refresh/vk/vk_lightmap.c @@ -27,8 +27,6 @@ #include "header/local.h" -#define LIGHTMAP_BYTES 4 - void LM_InitBlock(void) {