99% merge of d_*.[cS]. just d_polyse to look at

This commit is contained in:
Bill Currie 2001-05-18 20:19:20 +00:00
parent 664c640e42
commit 69ab5c981c
10 changed files with 76 additions and 117 deletions

View file

@ -33,7 +33,7 @@
#include "quakeasm.h" #include "quakeasm.h"
#include "asm_draw.h" #include "asm_draw.h"
//#ifdef USE_INTEL_ASM #ifdef USE_INTEL_ASM
.data .data
LCopyWidth: .long 0 LCopyWidth: .long 0
@ -173,4 +173,4 @@ LLRowLoop:
popl %ebp // restore the caller's stack frame popl %ebp // restore the caller's stack frame
ret ret
//#endif /* USE_INTEL_ASM */ #endif /* USE_INTEL_ASM */

View file

@ -1,7 +1,7 @@
/* /*
d_edge.c d_edge.c
@description@ (description)
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -31,19 +31,16 @@
#endif #endif
#include "d_local.h" #include "d_local.h"
#include "client.h" #include "r_local.h"
#include "render.h"
static int miplevel; static int miplevel;
float scale_for_mip; float scale_for_mip;
int screenwidth; extern int screenwidth;
int ubasestep, errorterm, erroradjustup, erroradjustdown; int ubasestep, errorterm, erroradjustup, erroradjustdown;
int vstartscan; int vstartscan;
// FIXME: should go away
extern void R_RotateBmodel (void);
extern void R_TransformFrustum (void);
vec3_t transformed_modelorg; vec3_t transformed_modelorg;
@ -162,7 +159,7 @@ D_DrawSurfaces (void)
vec3_t world_transformed_modelorg; vec3_t world_transformed_modelorg;
vec3_t local_modelorg; vec3_t local_modelorg;
currententity = &cl_entities[0]; currententity = &r_worldentity;
TransformVector (modelorg, transformed_modelorg); TransformVector (modelorg, transformed_modelorg);
VectorCopy (transformed_modelorg, world_transformed_modelorg); VectorCopy (transformed_modelorg, world_transformed_modelorg);
@ -176,7 +173,7 @@ D_DrawSurfaces (void)
d_zistepv = s->d_zistepv; d_zistepv = s->d_zistepv;
d_ziorigin = s->d_ziorigin; d_ziorigin = s->d_ziorigin;
D_DrawSolidSurface (s, (int) s->data & 0xFF); D_DrawSolidSurface (s, (int) ((long) s->data & 0xFF));
D_DrawZSpans (s->spans); D_DrawZSpans (s->spans);
} }
} else { } else {
@ -229,6 +226,7 @@ D_DrawSurfaces (void)
} }
D_CalcGradients (pface); D_CalcGradients (pface);
Turbulent8 (s->spans); Turbulent8 (s->spans);
D_DrawZSpans (s->spans); D_DrawZSpans (s->spans);
@ -237,7 +235,7 @@ D_DrawSurfaces (void)
// FIXME: we don't want to do this every time! // FIXME: we don't want to do this every time!
// TODO: speed up // TODO: speed up
currententity = &cl_entities[0]; currententity = &r_worldentity;
VectorCopy (world_transformed_modelorg, VectorCopy (world_transformed_modelorg,
transformed_modelorg); transformed_modelorg);
VectorCopy (base_vpn, vpn); VectorCopy (base_vpn, vpn);
@ -281,7 +279,6 @@ D_DrawSurfaces (void)
// FIXME: we don't want to do this every time! // FIXME: we don't want to do this every time!
// TODO: speed up // TODO: speed up
currententity = &cl_entities[0];
VectorCopy (world_transformed_modelorg, VectorCopy (world_transformed_modelorg,
transformed_modelorg); transformed_modelorg);
VectorCopy (base_vpn, vpn); VectorCopy (base_vpn, vpn);
@ -289,6 +286,7 @@ D_DrawSurfaces (void)
VectorCopy (base_vright, vright); VectorCopy (base_vright, vright);
VectorCopy (base_modelorg, modelorg); VectorCopy (base_modelorg, modelorg);
R_TransformFrustum (); R_TransformFrustum ();
currententity = &r_worldentity;
} }
} }
} }

View file

@ -1,7 +1,7 @@
/* /*
d_init.c d_init.c
@description@ rasterization driver initialization
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -30,7 +30,9 @@
# include "config.h" # include "config.h"
#endif #endif
#include "QF/compat.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/vid.h"
#include "d_local.h" #include "d_local.h"
#include "r_cvar.h" #include "r_cvar.h"
@ -50,15 +52,9 @@ extern int d_aflatcolor;
void (*d_drawspans) (espan_t *pspan); void (*d_drawspans) (espan_t *pspan);
/*
===============
D_Init
===============
*/
void void
D_Init (void) D_Init (void)
{ {
r_skydirect = 1; r_skydirect = 1;
r_drawpolys = false; r_drawpolys = false;
@ -75,11 +71,6 @@ D_Init (void)
} }
/*
===============
D_CopyRects
===============
*/
void void
D_CopyRects (vrect_t *prects, int transparent) D_CopyRects (vrect_t *prects, int transparent)
{ {
@ -93,23 +84,14 @@ D_CopyRects (vrect_t *prects, int transparent)
} }
/*
===============
D_EnableBackBufferAccess
===============
*/
void void
D_EnableBackBufferAccess (void) D_EnableBackBufferAccess (void)
{ {
VID_LockBuffer (); VID_LockBuffer ();
} }
/*
===============
D_TurnZOn
===============
*/
void void
D_TurnZOn (void) D_TurnZOn (void)
{ {
@ -117,11 +99,6 @@ D_TurnZOn (void)
} }
/*
===============
D_DisableBackBufferAccess
===============
*/
void void
D_DisableBackBufferAccess (void) D_DisableBackBufferAccess (void)
{ {
@ -129,11 +106,6 @@ D_DisableBackBufferAccess (void)
} }
/*
===============
D_SetupFrame
===============
*/
void void
D_SetupFrame (void) D_SetupFrame (void)
{ {
@ -152,11 +124,7 @@ D_SetupFrame (void)
d_roverwrapped = false; d_roverwrapped = false;
d_initial_rover = sc_rover; d_initial_rover = sc_rover;
d_minmip = d_mipcap->int_val; d_minmip = bound (0, d_mipcap->value, 3);
if (d_minmip > 3)
d_minmip = 3;
else if (d_minmip < 0)
d_minmip = 0;
for (i = 0; i < (NUM_MIPS - 1); i++) for (i = 0; i < (NUM_MIPS - 1); i++)
d_scalemip[i] = basemip[i] * d_mipscale->value; d_scalemip[i] = basemip[i] * d_mipscale->value;
@ -174,15 +142,8 @@ D_SetupFrame (void)
} }
/*
===============
D_UpdateRects
===============
*/
void void
D_UpdateRects (vrect_t *prect) D_UpdateRects (vrect_t *prect)
{ {
// the software driver draws these directly to the vid buffer // the software driver draws these directly to the vid buffer
} }

View file

@ -1,8 +1,7 @@
/* /*
d_modech.c d_modech.c
@description@ called when mode has just changed
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.

View file

@ -1,7 +1,7 @@
/* /*
d_scan.c d_scan.c
@description@ Portable C scan-level rasterization code, all pixel depths.
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -58,8 +58,8 @@ D_WarpScreen (void)
int *turb; int *turb;
int *col; int *col;
byte **row; byte **row;
byte *rowptr[MAXHEIGHT + (AMP2 * 2)]; byte *rowptr[1024];
int column[MAXWIDTH + (AMP2 * 2)]; int column[1280];
float wratio, hratio; float wratio, hratio;
w = r_refdef.vrect.width; w = r_refdef.vrect.width;
@ -84,7 +84,6 @@ D_WarpScreen (void)
for (v = 0; v < scr_vrect.height; v++, dest += vid.rowbytes) { for (v = 0; v < scr_vrect.height; v++, dest += vid.rowbytes) {
col = &column[turb[v]]; col = &column[turb[v]];
row = &rowptr[v]; row = &rowptr[v];
for (u = 0; u < scr_vrect.width; u += 4) { for (u = 0; u < scr_vrect.width; u += 4) {
dest[u + 0] = row[turb[u + 0]][col[u + 0]]; dest[u + 0] = row[turb[u + 0]][col[u + 0]];
dest[u + 1] = row[turb[u + 1]][col[u + 1]]; dest[u + 1] = row[turb[u + 1]][col[u + 1]];
@ -113,7 +112,7 @@ D_DrawTurbulent8Span (void)
r_turb_t += r_turb_tstep; r_turb_t += r_turb_tstep;
} while (--r_turb_spancount > 0); } while (--r_turb_spancount > 0);
} }
#endif // USE_INTEL_ASM #endif // !USE_INTEL_ASM
void void
@ -183,9 +182,10 @@ Turbulent8 (espan_t *pspan)
if (snext > bbextents) if (snext > bbextents)
snext = bbextents; snext = bbextents;
else if (snext < 16) else if (snext < 16)
snext = 16; // prevent round-off error on <0 steps snext = 16; // prevent round-off error on <0
// from from causing overstepping & // steps from
// running off the edge of the texture // from causing overstepping & running off the
// edge of the texture
tnext = (int) (tdivz * z) + tadjust; tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt) if (tnext > bbextentt)
@ -197,10 +197,10 @@ Turbulent8 (espan_t *pspan)
r_turb_sstep = (snext - r_turb_s) >> 4; r_turb_sstep = (snext - r_turb_s) >> 4;
r_turb_tstep = (tnext - r_turb_t) >> 4; r_turb_tstep = (tnext - r_turb_t) >> 4;
} else { } else {
// calculate s/z, t/z, zi->fixed s and t at last pixel in span // calculate s/z, t/z, zi->fixed s and t at last pixel in
// (so can't step off polygon), clamp, calculate s and t steps // span (so can't step off polygon), clamp, calculate s and t
// across span by division, biasing steps low so we don't run // steps across span by division, biasing steps low so we
// off the texture // don't run off the texture
spancountminus1 = (float) (r_turb_spancount - 1); spancountminus1 = (float) (r_turb_spancount - 1);
sdivz += d_sdivzstepu * spancountminus1; sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1; tdivz += d_tdivzstepu * spancountminus1;
@ -308,9 +308,10 @@ D_DrawSpans8 (espan_t *pspan)
if (snext > bbextents) if (snext > bbextents)
snext = bbextents; snext = bbextents;
else if (snext < 8) else if (snext < 8)
snext = 8; // prevent round-off error on <0 steps snext = 8; // prevent round-off error on <0
// from causing overstepping & running // steps from
// off the edge of the texture // from causing overstepping & running off the
// edge of the texture
tnext = (int) (tdivz * z) + tadjust; tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt) if (tnext > bbextentt)
@ -336,8 +337,8 @@ D_DrawSpans8 (espan_t *pspan)
snext = bbextents; snext = bbextents;
else if (snext < 8) else if (snext < 8)
snext = 8; // prevent round-off error on <0 steps snext = 8; // prevent round-off error on <0 steps
// from causing overstepping & running // from from causing overstepping &
// off the edge of the texture // running off the edge of the texture
tnext = (int) (tdivz * z) + tadjust; tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt) if (tnext > bbextentt)
@ -375,7 +376,7 @@ D_DrawZSpans (espan_t *pspan)
int count, doublecount, izistep; int count, doublecount, izistep;
int izi; int izi;
short *pdest; short *pdest;
unsigned ltemp; unsigned int ltemp;
double zi; double zi;
float du, dv; float du, dv;

View file

@ -1,7 +1,7 @@
/* /*
d_sprite.c d_sprite.c
@description@ software top-level rasterization driver module for drawing sprites
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -39,6 +39,7 @@ static sspan_t *sprite_spans;
#ifndef USE_INTEL_ASM #ifndef USE_INTEL_ASM
void void
D_SpriteDrawSpans (sspan_t *pspan) D_SpriteDrawSpans (sspan_t *pspan)
{ {
@ -116,9 +117,10 @@ D_SpriteDrawSpans (sspan_t *pspan)
if (snext > bbextents) if (snext > bbextents)
snext = bbextents; snext = bbextents;
else if (snext < 8) else if (snext < 8)
snext = 8; // prevent round-off error on <0 steps snext = 8; // prevent round-off error on <0
// from causing overstepping & running // steps from
// off the edge of the texture // from causing overstepping & running off the
// edge of the texture
tnext = (int) (tdivz * z) + tadjust; tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt) if (tnext > bbextentt)
@ -130,10 +132,10 @@ D_SpriteDrawSpans (sspan_t *pspan)
sstep = (snext - s) >> 3; sstep = (snext - s) >> 3;
tstep = (tnext - t) >> 3; tstep = (tnext - t) >> 3;
} else { } else {
// calculate s/z, t/z, zi->fixed s and t at last pixel in span // calculate s/z, t/z, zi->fixed s and t at last pixel in
// (so can't step off polygon), clamp, calculate s and t steps // span (so can't step off polygon), clamp, calculate s and t
// across span by division, biasing steps low so we don't run // steps across span by division, biasing steps low so we
// off the texture // don't run off the texture
spancountminus1 = (float) (spancount - 1); spancountminus1 = (float) (spancount - 1);
sdivz += d_sdivzstepu * spancountminus1; sdivz += d_sdivzstepu * spancountminus1;
tdivz += d_tdivzstepu * spancountminus1; tdivz += d_tdivzstepu * spancountminus1;
@ -144,8 +146,8 @@ D_SpriteDrawSpans (sspan_t *pspan)
snext = bbextents; snext = bbextents;
else if (snext < 8) else if (snext < 8)
snext = 8; // prevent round-off error on <0 steps snext = 8; // prevent round-off error on <0 steps
// from causing overstepping & running // from from causing overstepping &
// off the edge of the texture // running off the edge of the texture
tnext = (int) (tdivz * z) + tadjust; tnext = (int) (tdivz * z) + tadjust;
if (tnext > bbextentt) if (tnext > bbextentt)

View file

@ -1,7 +1,7 @@
/* /*
d_surf.c d_surf.c
@description@ rasterization driver surface heap manager
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -30,17 +30,12 @@
# include "config.h" # include "config.h"
#endif #endif
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "game.h"
#include "QF/sys.h"
#include "QF/qargs.h"
#include "QF/console.h"
#include "d_local.h" #include "d_local.h"
#include "QF/qargs.h"
#include "r_local.h" #include "r_local.h"
#include "d_iface.h" #include "QF/sys.h"
#include "render.h"
float surfscale; float surfscale;
qboolean r_cache_thrash; // set if surface cache is thrashing qboolean r_cache_thrash; // set if surface cache is thrashing
@ -74,6 +69,7 @@ D_SurfaceCacheForRes (int width, int height)
if (pix > 64000) if (pix > 64000)
size += (pix - 64000) * 3; size += (pix - 64000) * 3;
return size; return size;
} }
@ -106,9 +102,8 @@ D_ClearCacheGuard (void)
void void
D_InitCaches (void *buffer, int size) D_InitCaches (void *buffer, int size)
{ {
// if (!msg_suppress_1)
if (!msg_suppress_1) // Con_Printf ("%ik surface cache\n", size/1024);
Con_Printf ("%ik surface cache\n", size / 1024);
sc_size = size - GUARDSIZE; sc_size = size - GUARDSIZE;
sc_base = (surfcache_t *) buffer; sc_base = (surfcache_t *) buffer;
@ -156,7 +151,12 @@ D_SCAlloc (int width, int size)
if ((size <= 0) || (size > 0x10000)) if ((size <= 0) || (size > 0x10000))
Sys_Error ("D_SCAlloc: bad cache size %d\n", size); Sys_Error ("D_SCAlloc: bad cache size %d\n", size);
size = (int) &((surfcache_t *) 0)->data[size]; /* This adds the offset of data[0] in the surfcache_t struct. */
size += (int) ((surfcache_t *) 0)->data;
#define SIZE_ALIGN (sizeof(surfcache_t*)-1)
size = (size + SIZE_ALIGN) & ~SIZE_ALIGN;
#undef SIZE_ALIGN
size = (size + 3) & ~3; size = (size + 3) & ~3;
if (size > sc_size) if (size > sc_size)
Sys_Error ("D_SCAlloc: %i > cache size", size); Sys_Error ("D_SCAlloc: %i > cache size", size);
@ -226,7 +226,8 @@ D_SCDump (void)
for (test = sc_base; test; test = test->next) { for (test = sc_base; test; test = test->next) {
if (test == sc_rover) if (test == sc_rover)
Sys_Printf ("ROVER:\n"); Sys_Printf ("ROVER:\n");
printf ("%p : %i bytes %i width\n", test, test->size, test->width); Sys_Printf ("%p : %i bytes %i width\n", test, test->size,
test->width);
} }
} }

View file

@ -1,7 +1,7 @@
/* /*
d_vars.c d_vars.c
@description@ global refresh variables
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
@ -26,18 +26,18 @@
$Id$ $Id$
*/ */
#ifndef USE_INTEL_ASM
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#ifndef USE_INTEL_ASM #include "host.h"
#include "QF/qtypes.h"
// all global and static refresh variables are collected in a contiguous block // all global and static refresh variables are collected in a contiguous block
// to avoid cache conflicts. // to avoid cache conflicts.
// global refresh variables ---------------------------- // global refresh variables -----------------------------
// FIXME: make into one big structure, like cl or sv // FIXME: make into one big structure, like cl or sv
// FIXME: do separately for refresh engine and driver // FIXME: do separately for refresh engine and driver
@ -55,4 +55,4 @@ short *d_pzbuffer;
unsigned int d_zrowbytes; unsigned int d_zrowbytes;
unsigned int d_zwidth; unsigned int d_zwidth;
#endif // USE_INTEL_ASM #endif // !USE_INTEL_ASM

View file

@ -1,7 +1,7 @@
/* /*
d_zpoint.c d_zpoint.c
@description@ software driver module for drawing z-buffered points
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.

View file

@ -82,8 +82,6 @@ D_CopyRects (vrect_t *prects, int transparent)
// console); Quake will then draw into wherever the driver points vid.buffer // console); Quake will then draw into wherever the driver points vid.buffer
// and will call this function before swapping buffers // and will call this function before swapping buffers
UNUSED (prects);
UNUSED (transparent);
} }
@ -149,5 +147,4 @@ void
D_UpdateRects (vrect_t *prect) D_UpdateRects (vrect_t *prect)
{ {
// the software driver draws these directly to the vid buffer // the software driver draws these directly to the vid buffer
UNUSED (prect);
} }