mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[sw] Clean up use of vid.colormap8
The main goal was to not update the colormap pointers when only the viewport or fov changed.
This commit is contained in:
parent
3103f400fd
commit
d53b0b0064
12 changed files with 44 additions and 28 deletions
|
@ -143,7 +143,7 @@ extern int d_con_indirect; // if 0, Quake will draw console directly
|
|||
extern vec3_t r_pright, r_pup, r_ppn, r_porigin;
|
||||
|
||||
|
||||
void D_Aff8Patch (void *pcolormap);
|
||||
void D_Aff8Patch (const byte *pcolormap);
|
||||
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height);
|
||||
void D_EndDirectRect (int x, int y, int width, int height);
|
||||
void D_PolysetDraw (void);
|
||||
|
@ -180,7 +180,7 @@ extern byte *r_skysource;
|
|||
// !!! must be kept the same as in quakeasm.h !!!
|
||||
#define TRANSPARENT_COLOR 0xFF
|
||||
|
||||
extern void *acolormap; // FIXME: should go away
|
||||
extern const byte *acolormap; // FIXME: should go away
|
||||
|
||||
//=======================================================================//
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
.extern C(surfrowbytes)
|
||||
.extern C(r_sourcemax)
|
||||
.extern C(r_stepback)
|
||||
.extern C(colormap)
|
||||
.extern C(r_colormap)
|
||||
.extern C(blocksize)
|
||||
.extern C(sourcesstep)
|
||||
.extern C(lightleft)
|
||||
|
|
|
@ -187,6 +187,8 @@ struct vulkan_ctx_s;
|
|||
void R_ClearTextures (void);
|
||||
void R_InitSurfaceChains (mod_brush_t *brush);
|
||||
|
||||
extern const byte *r_colormap;
|
||||
void R_SetColormap (const byte *cmap);
|
||||
extern void R_Surf8Start (void);
|
||||
extern void R_Surf8End (void);
|
||||
extern void R_EdgeCodeStart (void);
|
||||
|
|
|
@ -8,6 +8,7 @@ typedef struct vid_internal_s {
|
|||
void (*flush_caches) (void *data);
|
||||
void (*init_buffers) (void *data);
|
||||
void (*set_palette) (void *data, const byte *palette);
|
||||
void (*set_colormap) (void *data, const byte *colormap);
|
||||
|
||||
void (*choose_visual) (void *data);
|
||||
void (*create_context) (void *data);
|
||||
|
|
|
@ -778,7 +778,7 @@ LPatchTable8:
|
|||
C(R_SurfPatch):
|
||||
pushl %ebx
|
||||
|
||||
movl C(colormap),%eax
|
||||
movl C(r_colormap),%eax
|
||||
movl $LPatchTable8,%ebx
|
||||
movl $32,%ecx
|
||||
LPatchLoop8:
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
affinetridesc_t r_affinetridesc;
|
||||
|
||||
void *acolormap; // FIXME: should go away
|
||||
const byte *acolormap; // FIXME: should go away
|
||||
|
||||
trivertx_t *r_apverts;
|
||||
|
||||
|
@ -540,7 +540,7 @@ R_AliasSetupSkin (entity_t *ent)
|
|||
r_affinetridesc.seamfixupX16 = (a_skinwidth >> 1) << 16;
|
||||
r_affinetridesc.skinheight = pmdl->skinheight;
|
||||
|
||||
acolormap = vid.colormap8;
|
||||
acolormap = r_colormap;
|
||||
if (ent->renderer.skin) {
|
||||
tex_t *base;
|
||||
|
||||
|
@ -631,7 +631,7 @@ R_AliasDrawModel (entity_t *ent, alight_t *lighting)
|
|||
&& r_recursiveaffinetriangles);
|
||||
|
||||
if (!acolormap)
|
||||
acolormap = vid.colormap8;
|
||||
acolormap = r_colormap;
|
||||
|
||||
if (r_affinetridesc.drawtype) {
|
||||
D_PolysetUpdateTables (); // FIXME: precalc...
|
||||
|
|
|
@ -315,7 +315,7 @@ R_IQMDrawModel (entity_t *ent, alight_t *plighting)
|
|||
r_recursiveaffinetriangles;
|
||||
|
||||
//if (!acolormap)
|
||||
acolormap = vid.colormap8;
|
||||
acolormap = r_colormap;
|
||||
|
||||
if (ent != vr_data.view_model)
|
||||
ziscale = (float) 0x8000 *(float) 0x10000;
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
# undef USE_INTEL_ASM //XXX asm pic hack
|
||||
#endif
|
||||
|
||||
void *colormap;
|
||||
const byte *r_colormap;
|
||||
int r_numallocatededges;
|
||||
qboolean r_drawpolys;
|
||||
qboolean r_drawculledpolys;
|
||||
|
@ -315,15 +315,19 @@ R_ViewChanged (void)
|
|||
r_aliastransition = r_aliastransbase->value * res_scale;
|
||||
r_resfudge = r_aliastransadj->value * res_scale;
|
||||
|
||||
D_ViewChanged ();
|
||||
}
|
||||
|
||||
void
|
||||
R_SetColormap (const byte *cmap)
|
||||
{
|
||||
r_colormap = cmap;
|
||||
// TODO: collect 386-specific code in one place
|
||||
#ifdef USE_INTEL_ASM
|
||||
Sys_MakeCodeWriteable ((long) R_Surf8Start,
|
||||
(long) R_Surf8End - (long) R_Surf8Start);
|
||||
colormap = vid.colormap8;
|
||||
R_SurfPatch ();
|
||||
#endif // USE_INTEL_ASM
|
||||
|
||||
D_ViewChanged ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -719,7 +723,7 @@ R_RenderView (void)
|
|||
if ((intptr_t) (&dummy) & 3)
|
||||
Sys_Error ("Stack is missaligned");
|
||||
|
||||
if ((intptr_t) (&colormap) & 3)
|
||||
if ((intptr_t) (&r_colormap) & 3)
|
||||
Sys_Error ("Globals are missaligned");
|
||||
|
||||
R_RenderView_ ();
|
||||
|
|
|
@ -50,15 +50,15 @@ int lightdelta, lightdeltastep;
|
|||
int lightright, lightleftstep, lightrightstep, blockdivshift;
|
||||
static unsigned int blockdivmask;
|
||||
void *prowdestbase;
|
||||
unsigned char *pbasesource;
|
||||
byte *pbasesource;
|
||||
int surfrowbytes; // used by ASM files
|
||||
unsigned int *r_lightptr;
|
||||
int r_stepback;
|
||||
int r_lightwidth;
|
||||
static int r_numhblocks;
|
||||
int r_numvblocks;
|
||||
static unsigned char *r_source;
|
||||
unsigned char *r_sourcemax;
|
||||
static byte *r_source;
|
||||
byte *r_sourcemax;
|
||||
|
||||
void R_DrawSurfaceBlock_mip0 (void);
|
||||
void R_DrawSurfaceBlock_mip1 (void);
|
||||
|
@ -275,7 +275,7 @@ void
|
|||
R_DrawSurfaceBlock_mip0 (void)
|
||||
{
|
||||
int v, i, b, lightstep, lighttemp, light;
|
||||
unsigned char pix, *psource, *prowdest;
|
||||
byte pix, *psource, *prowdest;
|
||||
|
||||
psource = pbasesource;
|
||||
prowdest = prowdestbase;
|
||||
|
@ -297,8 +297,7 @@ R_DrawSurfaceBlock_mip0 (void)
|
|||
|
||||
for (b = 15; b >= 0; b--) {
|
||||
pix = psource[b];
|
||||
prowdest[b] = ((unsigned char *) vid.colormap8)
|
||||
[(light & 0xFF00) + pix];
|
||||
prowdest[b] = r_colormap[(light & 0xFF00) + pix];
|
||||
light += lightstep;
|
||||
}
|
||||
|
||||
|
@ -317,7 +316,7 @@ void
|
|||
R_DrawSurfaceBlock_mip1 (void)
|
||||
{
|
||||
int v, i, b, lightstep, lighttemp, light;
|
||||
unsigned char pix, *psource, *prowdest;
|
||||
byte pix, *psource, *prowdest;
|
||||
|
||||
psource = pbasesource;
|
||||
prowdest = prowdestbase;
|
||||
|
@ -339,8 +338,7 @@ R_DrawSurfaceBlock_mip1 (void)
|
|||
|
||||
for (b = 7; b >= 0; b--) {
|
||||
pix = psource[b];
|
||||
prowdest[b] = ((unsigned char *) vid.colormap8)
|
||||
[(light & 0xFF00) + pix];
|
||||
prowdest[b] = r_colormap[(light & 0xFF00) + pix];
|
||||
light += lightstep;
|
||||
}
|
||||
|
||||
|
@ -359,7 +357,7 @@ void
|
|||
R_DrawSurfaceBlock_mip2 (void)
|
||||
{
|
||||
int v, i, b, lightstep, lighttemp, light;
|
||||
unsigned char pix, *psource, *prowdest;
|
||||
byte pix, *psource, *prowdest;
|
||||
|
||||
psource = pbasesource;
|
||||
prowdest = prowdestbase;
|
||||
|
@ -381,8 +379,7 @@ R_DrawSurfaceBlock_mip2 (void)
|
|||
|
||||
for (b = 3; b >= 0; b--) {
|
||||
pix = psource[b];
|
||||
prowdest[b] = ((unsigned char *) vid.colormap8)
|
||||
[(light & 0xFF00) + pix];
|
||||
prowdest[b] = r_colormap[(light & 0xFF00) + pix];
|
||||
light += lightstep;
|
||||
}
|
||||
|
||||
|
@ -401,7 +398,7 @@ void
|
|||
R_DrawSurfaceBlock_mip3 (void)
|
||||
{
|
||||
int v, i, b, lightstep, lighttemp, light;
|
||||
unsigned char pix, *psource, *prowdest;
|
||||
byte pix, *psource, *prowdest;
|
||||
|
||||
psource = pbasesource;
|
||||
prowdest = prowdestbase;
|
||||
|
@ -423,8 +420,7 @@ R_DrawSurfaceBlock_mip3 (void)
|
|||
|
||||
for (b = 1; b >= 0; b--) {
|
||||
pix = psource[b];
|
||||
prowdest[b] = ((unsigned char *) vid.colormap8)
|
||||
[(light & 0xFF00) + pix];
|
||||
prowdest[b] = r_colormap[(light & 0xFF00) + pix];
|
||||
light += lightstep;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,12 @@ sw_vid_render_set_palette (void *data, const byte *palette)
|
|||
sw_ctx->set_palette (sw_ctx, palette);
|
||||
}
|
||||
|
||||
static void
|
||||
sw_vid_render_set_colormap (void *data, const byte *colormap)
|
||||
{
|
||||
R_SetColormap (colormap);
|
||||
}
|
||||
|
||||
static vid_model_funcs_t model_funcs = {
|
||||
0,
|
||||
sw_Mod_LoadLighting,
|
||||
|
@ -99,6 +105,7 @@ sw_vid_render_init (void)
|
|||
|
||||
vr_data.vid->vid_internal->data = sw_ctx;
|
||||
vr_data.vid->vid_internal->set_palette = sw_vid_render_set_palette;
|
||||
vr_data.vid->vid_internal->set_colormap = sw_vid_render_set_colormap;
|
||||
vr_data.vid->vid_internal->choose_visual = sw_vid_render_choose_visual;
|
||||
vr_data.vid->vid_internal->create_context = sw_vid_render_create_context;
|
||||
|
||||
|
|
|
@ -133,6 +133,9 @@ VID_Init (byte *palette, byte *colormap)
|
|||
viddef.numpages = 1;
|
||||
viddef.colormap8 = colormap;
|
||||
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
||||
if (vid_internal.set_colormap) {
|
||||
vid_internal.set_colormap (vid_internal.data, colormap);
|
||||
}
|
||||
|
||||
VID_GetWindowSize (640, 480);
|
||||
Win_OpenDisplay ();
|
||||
|
|
|
@ -110,6 +110,9 @@ VID_Init (byte *palette, byte *colormap)
|
|||
viddef.numpages = 2;
|
||||
viddef.colormap8 = colormap;
|
||||
viddef.fullbright = 256 - viddef.colormap8[256 * VID_GRADES];
|
||||
if (vid_internal.set_colormap) {
|
||||
vid_internal.set_colormap (vid_internal.data, colormap);
|
||||
}
|
||||
|
||||
srandom (getpid ());
|
||||
|
||||
|
|
Loading…
Reference in a new issue