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.
This commit is contained in:
Denis Pauk 2023-10-15 14:45:16 +03:00
parent 1ab6214ff0
commit 660f5728c1
9 changed files with 12 additions and 31 deletions

View File

@ -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);
}

View File

@ -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];

View File

@ -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.
}

View File

@ -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

View File

@ -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.
}

View File

@ -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

View File

@ -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)

View File

@ -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;

View File

@ -27,8 +27,6 @@
#include "header/local.h"
#define LIGHTMAP_BYTES 4
void
LM_InitBlock(void)
{