mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
this seems to give ~2.9% speed boost to overkill for null-render
This commit is contained in:
parent
37335f4ec3
commit
acdd37b381
1 changed files with 41 additions and 69 deletions
|
@ -112,7 +112,7 @@ msurface_t **sky_chain_tail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void (*R_AddDynamicLights) (msurface_t *surf);
|
void (*R_AddDynamicLights) (msurface_t *surf);
|
||||||
void (*R_BuildLightMap) (msurface_t *surf, byte *dest, int stride);
|
void (*R_BuildLightMap) (msurface_t *surf);
|
||||||
|
|
||||||
|
|
||||||
// LordHavoc: place for gl_rsurf setup code
|
// LordHavoc: place for gl_rsurf setup code
|
||||||
|
@ -274,10 +274,10 @@ R_AddDynamicLights_3 (msurface_t *surf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_BuildLightMap_1 (msurface_t *surf, byte *dest, int stride)
|
R_BuildLightMap_1 (msurface_t *surf)
|
||||||
{
|
{
|
||||||
byte *lightmap;
|
byte *dest;
|
||||||
int maps, shift, size, smax, tmax, i, j;
|
int maps, size, smax, tmax, i, j, stride;
|
||||||
unsigned int scale;
|
unsigned int scale;
|
||||||
unsigned int *bl;
|
unsigned int *bl;
|
||||||
|
|
||||||
|
@ -286,7 +286,6 @@ R_BuildLightMap_1 (msurface_t *surf, byte *dest, int stride)
|
||||||
smax = (surf->extents[0] >> 4) + 1;
|
smax = (surf->extents[0] >> 4) + 1;
|
||||||
tmax = (surf->extents[1] >> 4) + 1;
|
tmax = (surf->extents[1] >> 4) + 1;
|
||||||
size = smax * tmax;
|
size = smax * tmax;
|
||||||
lightmap = surf->samples;
|
|
||||||
|
|
||||||
// set to full bright if no light data
|
// set to full bright if no light data
|
||||||
if (!r_worldentity.model->lightdata) {
|
if (!r_worldentity.model->lightdata) {
|
||||||
|
@ -298,7 +297,10 @@ R_BuildLightMap_1 (msurface_t *surf, byte *dest, int stride)
|
||||||
memset (&blocklights[0], 0, gl_internalformat * size * sizeof(int));
|
memset (&blocklights[0], 0, gl_internalformat * size * sizeof(int));
|
||||||
|
|
||||||
// add all the lightmaps
|
// add all the lightmaps
|
||||||
if (lightmap) {
|
if (surf->samples) {
|
||||||
|
byte *lightmap;
|
||||||
|
|
||||||
|
lightmap = surf->samples;
|
||||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||||
maps++) {
|
maps++) {
|
||||||
scale = d_lightstylevalue[surf->styles[maps]];
|
scale = d_lightstylevalue[surf->styles[maps]];
|
||||||
|
@ -315,32 +317,24 @@ R_BuildLightMap_1 (msurface_t *surf, byte *dest, int stride)
|
||||||
|
|
||||||
store:
|
store:
|
||||||
// bound and shift
|
// bound and shift
|
||||||
stride -= smax * lightmap_bytes;
|
stride = (BLOCK_WIDTH - smax) * lightmap_bytes;
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
|
|
||||||
#if 0
|
dest = lightmaps[surf->lightmaptexturenum]
|
||||||
if (gl_mtex_active) {
|
+ (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
|
||||||
shift = 7; // 0-1 lightmap range.
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
shift = 8; // 0-2 lightmap range.
|
|
||||||
#if 0
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < tmax; i++, dest += stride) {
|
for (i = 0; i < tmax; i++, dest += stride) {
|
||||||
for (j = 0; j < smax; j++) {
|
for (j = 0; j < smax; j++) {
|
||||||
*dest++ = min (*bl >> shift, 255);
|
*dest++ = min (*bl >> 8, 255);
|
||||||
bl++;
|
bl++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_BuildLightMap_3 (msurface_t *surf, byte *dest, int stride)
|
R_BuildLightMap_3 (msurface_t *surf)
|
||||||
{
|
{
|
||||||
byte *lightmap;
|
byte *dest;
|
||||||
int maps, shift, size, smax, tmax, i, j;
|
int maps, size, smax, tmax, i, j, stride;
|
||||||
unsigned int scale;
|
unsigned int scale;
|
||||||
unsigned int *bl;
|
unsigned int *bl;
|
||||||
|
|
||||||
|
@ -349,7 +343,6 @@ R_BuildLightMap_3 (msurface_t *surf, byte *dest, int stride)
|
||||||
smax = (surf->extents[0] >> 4) + 1;
|
smax = (surf->extents[0] >> 4) + 1;
|
||||||
tmax = (surf->extents[1] >> 4) + 1;
|
tmax = (surf->extents[1] >> 4) + 1;
|
||||||
size = smax * tmax;
|
size = smax * tmax;
|
||||||
lightmap = surf->samples;
|
|
||||||
|
|
||||||
// set to full bright if no light data
|
// set to full bright if no light data
|
||||||
if (!r_worldentity.model->lightdata) {
|
if (!r_worldentity.model->lightdata) {
|
||||||
|
@ -361,7 +354,10 @@ R_BuildLightMap_3 (msurface_t *surf, byte *dest, int stride)
|
||||||
memset (&blocklights[0], 0, gl_internalformat * size * sizeof(int));
|
memset (&blocklights[0], 0, gl_internalformat * size * sizeof(int));
|
||||||
|
|
||||||
// add all the lightmaps
|
// add all the lightmaps
|
||||||
if (lightmap) {
|
if (surf->samples) {
|
||||||
|
byte *lightmap;
|
||||||
|
|
||||||
|
lightmap = surf->samples;
|
||||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||||
maps++) {
|
maps++) {
|
||||||
scale = d_lightstylevalue[surf->styles[maps]];
|
scale = d_lightstylevalue[surf->styles[maps]];
|
||||||
|
@ -378,36 +374,28 @@ R_BuildLightMap_3 (msurface_t *surf, byte *dest, int stride)
|
||||||
|
|
||||||
store:
|
store:
|
||||||
// bound and shift
|
// bound and shift
|
||||||
stride -= smax * lightmap_bytes;
|
stride = (BLOCK_WIDTH - smax) * lightmap_bytes;
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
|
|
||||||
#if 0
|
dest = lightmaps[surf->lightmaptexturenum]
|
||||||
if (gl_mtex_active) {
|
+ (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
|
||||||
shift = 7; // 0-1 lightmap range.
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
shift = 8; // 0-2 lightmap range.
|
|
||||||
#if 0
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < tmax; i++, dest += stride) {
|
for (i = 0; i < tmax; i++, dest += stride) {
|
||||||
for (j = 0; j < smax; j++) {
|
for (j = 0; j < smax; j++) {
|
||||||
*dest++ = min (*bl >> shift, 255);
|
*dest++ = min (*bl >> 8, 255);
|
||||||
bl++;
|
bl++;
|
||||||
*dest++ = min (*bl >> shift, 255);
|
*dest++ = min (*bl >> 8, 255);
|
||||||
bl++;
|
bl++;
|
||||||
*dest++ = min (*bl >> shift, 255);
|
*dest++ = min (*bl >> 8, 255);
|
||||||
bl++;
|
bl++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_BuildLightMap_4 (msurface_t *surf, byte * dest, int stride)
|
R_BuildLightMap_4 (msurface_t *surf)
|
||||||
{
|
{
|
||||||
byte *lightmap;
|
byte *dest;
|
||||||
int maps, shift, size, smax, tmax, i, j;
|
int maps, size, smax, tmax, i, j, stride;
|
||||||
unsigned int scale;
|
unsigned int scale;
|
||||||
unsigned int *bl;
|
unsigned int *bl;
|
||||||
|
|
||||||
|
@ -416,7 +404,6 @@ R_BuildLightMap_4 (msurface_t *surf, byte * dest, int stride)
|
||||||
smax = (surf->extents[0] >> 4) + 1;
|
smax = (surf->extents[0] >> 4) + 1;
|
||||||
tmax = (surf->extents[1] >> 4) + 1;
|
tmax = (surf->extents[1] >> 4) + 1;
|
||||||
size = smax * tmax;
|
size = smax * tmax;
|
||||||
lightmap = surf->samples;
|
|
||||||
|
|
||||||
// set to full bright if no light data
|
// set to full bright if no light data
|
||||||
if (!r_worldentity.model->lightdata) {
|
if (!r_worldentity.model->lightdata) {
|
||||||
|
@ -428,7 +415,10 @@ R_BuildLightMap_4 (msurface_t *surf, byte * dest, int stride)
|
||||||
memset (&blocklights[0], 0, gl_internalformat * size * sizeof(int));
|
memset (&blocklights[0], 0, gl_internalformat * size * sizeof(int));
|
||||||
|
|
||||||
// add all the lightmaps
|
// add all the lightmaps
|
||||||
if (lightmap) {
|
if (surf->samples) {
|
||||||
|
byte *lightmap;
|
||||||
|
|
||||||
|
lightmap = surf->samples;
|
||||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255;
|
||||||
maps++) {
|
maps++) {
|
||||||
scale = d_lightstylevalue[surf->styles[maps]];
|
scale = d_lightstylevalue[surf->styles[maps]];
|
||||||
|
@ -445,26 +435,18 @@ R_BuildLightMap_4 (msurface_t *surf, byte * dest, int stride)
|
||||||
|
|
||||||
store:
|
store:
|
||||||
// bound and shift
|
// bound and shift
|
||||||
stride -= smax * lightmap_bytes;
|
stride = (BLOCK_WIDTH - smax) * lightmap_bytes;
|
||||||
bl = blocklights;
|
bl = blocklights;
|
||||||
|
|
||||||
#if 0
|
dest = lightmaps[surf->lightmaptexturenum]
|
||||||
if (gl_mtex_active) {
|
+ (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
|
||||||
shift = 7; // 0-1 lightmap range.
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
shift = 8; // 0-2 lightmap range.
|
|
||||||
#if 0
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < tmax; i++, dest += stride) {
|
for (i = 0; i < tmax; i++, dest += stride) {
|
||||||
for (j = 0; j < smax; j++) {
|
for (j = 0; j < smax; j++) {
|
||||||
*dest++ = min (*bl >> shift, 255);
|
*dest++ = min (*bl >> 8, 255);
|
||||||
bl++;
|
bl++;
|
||||||
*dest++ = min (*bl >> shift, 255);
|
*dest++ = min (*bl >> 8, 255);
|
||||||
bl++;
|
bl++;
|
||||||
*dest++ = min (*bl >> shift, 255);
|
*dest++ = min (*bl >> 8, 255);
|
||||||
bl++;
|
bl++;
|
||||||
dest++; // `*dest++ = 255;` for RGBA internal format
|
dest++; // `*dest++ = 255;` for RGBA internal format
|
||||||
// instead of RGB
|
// instead of RGB
|
||||||
|
@ -570,11 +552,7 @@ R_DrawMultitexturePoly (msurface_t *s)
|
||||||
|
|
||||||
if ((s->dlightframe == r_framecount) || s->cached_dlight) {
|
if ((s->dlightframe == r_framecount) || s->cached_dlight) {
|
||||||
dynamic:
|
dynamic:
|
||||||
R_BuildLightMap (s,
|
R_BuildLightMap (s);
|
||||||
lightmaps[s->lightmaptexturenum] +
|
|
||||||
(s->light_t * BLOCK_WIDTH +
|
|
||||||
s->light_s) * lightmap_bytes,
|
|
||||||
BLOCK_WIDTH * lightmap_bytes);
|
|
||||||
GL_UploadLightmap (i, s->light_s, s->light_t,
|
GL_UploadLightmap (i, s->light_s, s->light_t,
|
||||||
(s->extents[0] >> 4) + 1,
|
(s->extents[0] >> 4) + 1,
|
||||||
(s->extents[1] >> 4) + 1);
|
(s->extents[1] >> 4) + 1);
|
||||||
|
@ -663,7 +641,6 @@ R_RenderFullbrights (void)
|
||||||
void
|
void
|
||||||
R_RenderBrushPoly (msurface_t *fa)
|
R_RenderBrushPoly (msurface_t *fa)
|
||||||
{
|
{
|
||||||
byte *base;
|
|
||||||
float *v;
|
float *v;
|
||||||
int maps, smax, tmax, i;
|
int maps, smax, tmax, i;
|
||||||
glRect_t *theRect;
|
glRect_t *theRect;
|
||||||
|
@ -709,9 +686,7 @@ R_RenderBrushPoly (msurface_t *fa)
|
||||||
theRect->w = (fa->light_s - theRect->l) + smax;
|
theRect->w = (fa->light_s - theRect->l) + smax;
|
||||||
if ((theRect->h + theRect->t) < (fa->light_t + tmax))
|
if ((theRect->h + theRect->t) < (fa->light_t + tmax))
|
||||||
theRect->h = (fa->light_t - theRect->t) + tmax;
|
theRect->h = (fa->light_t - theRect->t) + tmax;
|
||||||
base = lightmaps[fa->lightmaptexturenum] +
|
R_BuildLightMap (fa);
|
||||||
(fa->light_t * BLOCK_WIDTH + fa->light_s) * lightmap_bytes;
|
|
||||||
R_BuildLightMap (fa, base, BLOCK_WIDTH * lightmap_bytes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1189,6 @@ BuildSurfaceDisplayList (msurface_t *fa)
|
||||||
static void
|
static void
|
||||||
GL_CreateSurfaceLightmap (msurface_t *surf)
|
GL_CreateSurfaceLightmap (msurface_t *surf)
|
||||||
{
|
{
|
||||||
byte *base;
|
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
|
|
||||||
if (surf->flags & (SURF_DRAWSKY | SURF_DRAWTURB))
|
if (surf->flags & (SURF_DRAWSKY | SURF_DRAWTURB))
|
||||||
|
@ -1225,9 +1199,7 @@ GL_CreateSurfaceLightmap (msurface_t *surf)
|
||||||
|
|
||||||
surf->lightmaptexturenum =
|
surf->lightmaptexturenum =
|
||||||
AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
|
AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
|
||||||
base = lightmaps[surf->lightmaptexturenum] +
|
R_BuildLightMap (surf);
|
||||||
(surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
|
|
||||||
R_BuildLightMap (surf, base, BLOCK_WIDTH * lightmap_bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue