From d7064639ff76f949d9dec280507dd463baf60cfc Mon Sep 17 00:00:00 2001 From: gez Date: Mon, 23 Apr 2012 17:58:04 +0000 Subject: [PATCH] * Updated to ZDoom r3589: - Patch to allow compilation by clang. - Added a wrapper function to help wallscan() tile textures with heights that are not a power of 2. git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@1364 b0f79afe-0144-0410-b225-9a4edf0717df --- dumb/include/dumb.h | 8 ++--- dumb/src/it/loadmod.c | 4 +-- dumb/src/it/loadmod2.c | 4 +-- dumb/src/it/readmod.c | 9 +++-- dumb/src/it/readmod2.c | 4 +-- src/r_segs.cpp | 78 ++++++++++++++++++++++++++++++++++++----- src/svnrevision.h | 4 +-- src/timidity/timidity.h | 3 +- 8 files changed, 87 insertions(+), 27 deletions(-) diff --git a/dumb/include/dumb.h b/dumb/include/dumb.h index 7af4a1d7..09041ce3 100644 --- a/dumb/include/dumb.h +++ b/dumb/include/dumb.h @@ -400,7 +400,7 @@ DUH *DUMBEXPORT dumb_load_it(const char *filename); DUH *DUMBEXPORT dumb_load_xm(const char *filename); DUH *DUMBEXPORT dumb_load_s3m(const char *filename); DUH *DUMBEXPORT dumb_load_stm(const char *filename); -DUH *DUMBEXPORT dumb_load_mod(const char *filename, int restrict); +DUH *DUMBEXPORT dumb_load_mod(const char *filename, int rstrict); DUH *DUMBEXPORT dumb_load_ptm(const char *filename); DUH *DUMBEXPORT dumb_load_669(const char *filename); DUH *DUMBEXPORT dumb_load_psm(const char *filename, int subsong); @@ -413,7 +413,7 @@ DUH *DUMBEXPORT dumb_read_it(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_xm(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_s3m(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_stm(DUMBFILE *f); -DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int restrict); +DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int rstrict); DUH *DUMBEXPORT dumb_read_ptm(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_669(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_psm(DUMBFILE *f, int subsong); @@ -426,7 +426,7 @@ DUH *DUMBEXPORT dumb_load_it_quick(const char *filename); DUH *DUMBEXPORT dumb_load_xm_quick(const char *filename); DUH *DUMBEXPORT dumb_load_s3m_quick(const char *filename); DUH *DUMBEXPORT dumb_load_stm_quick(const char *filename); -DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int restrict); +DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int rstrict); DUH *DUMBEXPORT dumb_load_ptm_quick(const char *filename); DUH *DUMBEXPORT dumb_load_669_quick(const char *filename); DUH *DUMBEXPORT dumb_load_psm_quick(const char *filename, int subsong); @@ -439,7 +439,7 @@ DUH *DUMBEXPORT dumb_read_it_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_xm_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_s3m_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_stm_quick(DUMBFILE *f); -DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int restrict); +DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int rstrict); DUH *DUMBEXPORT dumb_read_ptm_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_669_quick(DUMBFILE *f); DUH *DUMBEXPORT dumb_read_psm_quick(DUMBFILE *f, int subsong); diff --git a/dumb/src/it/loadmod.c b/dumb/src/it/loadmod.c index 0a2d4019..adb4c283 100644 --- a/dumb/src/it/loadmod.c +++ b/dumb/src/it/loadmod.c @@ -26,7 +26,7 @@ * pointer to the DUH struct. When you have finished with it, you must * pass the pointer to unload_duh() so that the memory can be freed. */ -DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int restrict) +DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int rstrict) { DUH *duh; DUMBFILE *f = dumbfile_open(filename); @@ -34,7 +34,7 @@ DUH *DUMBEXPORT dumb_load_mod_quick(const char *filename, int restrict) if (!f) return NULL; - duh = dumb_read_mod_quick(f, restrict); + duh = dumb_read_mod_quick(f, rstrict); dumbfile_close(f); diff --git a/dumb/src/it/loadmod2.c b/dumb/src/it/loadmod2.c index d2aae8d0..83a41694 100644 --- a/dumb/src/it/loadmod2.c +++ b/dumb/src/it/loadmod2.c @@ -21,9 +21,9 @@ -DUH *DUMBEXPORT dumb_load_mod(const char *filename, int restrict) +DUH *DUMBEXPORT dumb_load_mod(const char *filename, int rstrict) { - DUH *duh = dumb_load_mod_quick(filename, restrict); + DUH *duh = dumb_load_mod_quick(filename, rstrict); dumb_it_do_initial_runthrough(duh); return duh; } diff --git a/dumb/src/it/readmod.c b/dumb/src/it/readmod.c index c2cb4b7b..2f6f8877 100644 --- a/dumb/src/it/readmod.c +++ b/dumb/src/it/readmod.c @@ -441,7 +441,7 @@ static DUMBFILE *dumbfile_buffer_mod_2(DUMBFILE *f, int32 *remain) } -static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int restrict) +static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int rstrict) { DUMB_IT_SIGDATA *sigdata; int n_channels; @@ -550,7 +550,7 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int restrict) } // moo - if ( restrict && sigdata->n_samples == 15 ) + if ( rstrict && sigdata->n_samples == 15 ) { free(sigdata); dumbfile_close(f); @@ -758,16 +758,15 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int restrict) -DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int restrict) +DUH *DUMBEXPORT dumb_read_mod_quick(DUMBFILE *f, int rstrict) { sigdata_t *sigdata; DUH_SIGTYPE_DESC *descptr = &_dumb_sigtype_it; - sigdata = it_mod_load_sigdata(f, restrict); + sigdata = it_mod_load_sigdata(f, rstrict); if (!sigdata) - return NULL; { const char *tag[2][2]; diff --git a/dumb/src/it/readmod2.c b/dumb/src/it/readmod2.c index 34fadf23..a20ccd24 100644 --- a/dumb/src/it/readmod2.c +++ b/dumb/src/it/readmod2.c @@ -21,9 +21,9 @@ -DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int restrict) +DUH *DUMBEXPORT dumb_read_mod(DUMBFILE *f, int rstrict) { - DUH *duh = dumb_read_mod_quick(f, restrict); + DUH *duh = dumb_read_mod_quick(f, rstrict); dumb_it_do_initial_runthrough(duh); return duh; } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 7070215d..4696b441 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -56,6 +56,8 @@ #define WALLYREPEAT 8 +CVAR(Bool, r_np2, true, 0) + //CVAR (Int, ty, 8, 0) //CVAR (Int, tx, 8, 0) @@ -1215,6 +1217,64 @@ void wallscan_striped (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, wallshade = startshade; } +static void call_wallscan(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat) +{ + if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + { + wallscan(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } + else + { + wallscan_striped(x1, x2, uwal, dwal, swal, lwal, yrepeat); + } +} + +//============================================================================= +// +// wallscan_np2 +// +// This is a wrapper around wallscan that helps it tile textures whose heights +// are not powers of 2. It divides the wall into texture-sized strips and calls +// wallscan for each of those. Since only one repetition of the texture fits +// in each strip, wallscan will not tile. +// +//============================================================================= + +void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, fixed_t top, fixed_t bot) +{ + short *up = uwal; + + if (r_np2) + { + short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH]; + short *down; + fixed_t texheight = rw_pic->GetHeight() << FRACBITS; + fixed_t scaledtexheight = FixedDiv(texheight, yrepeat); + fixed_t partition = top - (top - FixedDiv(dc_texturemid, yrepeat) - viewz) % scaledtexheight; + + down = most1; + + dc_texturemid = FixedMul(partition - viewz, yrepeat) + texheight; + while (partition > bot) + { + int j = OWallMost(most3, partition - viewz); + if (j != 3) + { + for (int j = x1; j <= x2; ++j) + { + down[j] = clamp (most3[j], up[j], dwal[j]); + } + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat); + up = down; + down = (down == most1) ? most2 : most1; + } + partition -= scaledtexheight; + dc_texturemid -= texheight; + } + } + call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat); +} + inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, const BYTE *bufplce, BYTE *dest) { dc_iscale = vince; @@ -1681,13 +1741,13 @@ void R_RenderSegLoop () { rw_offset = rw_offset_mid; } - if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - wallscan (x1, x2-1, walltop, wallbottom, swall, lwall, yscale); + wallscan_np2(x1, x2-1, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2)); } else { - wallscan_striped (x1, x2-1, walltop, wallbottom, swall, lwall, yscale); + call_wallscan(x1, x2-1, walltop, wallbottom, swall, lwall, yscale); } } clearbufshort (ceilingclip+x1, x2-x1, viewheight); @@ -1720,13 +1780,13 @@ void R_RenderSegLoop () { rw_offset = rw_offset_top; } - if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - wallscan (x1, x2-1, walltop, wallupper, swall, lwall, yscale); + wallscan_np2(x1, x2-1, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2)); } else { - wallscan_striped (x1, x2-1, walltop, wallupper, swall, lwall, yscale); + call_wallscan(x1, x2-1, walltop, wallupper, swall, lwall, yscale); } } memcpy (ceilingclip+x1, wallupper+x1, (x2-x1)*sizeof(short)); @@ -1762,13 +1822,13 @@ void R_RenderSegLoop () { rw_offset = rw_offset_bottom; } - if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size())) + if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - wallscan (x1, x2-1, walllower, wallbottom, swall, lwall, yscale); + wallscan_np2(x1, x2-1, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2)); } else { - wallscan_striped (x1, x2-1, walllower, wallbottom, swall, lwall, yscale); + call_wallscan(x1, x2-1, walllower, wallbottom, swall, lwall, yscale); } } memcpy (floorclip+x1, walllower+x1, (x2-x1)*sizeof(short)); diff --git a/src/svnrevision.h b/src/svnrevision.h index 7ab99c06..409c92ad 100644 --- a/src/svnrevision.h +++ b/src/svnrevision.h @@ -3,5 +3,5 @@ // This file was automatically generated by the // updaterevision tool. Do not edit by hand. -#define ZD_SVN_REVISION_STRING "3587" -#define ZD_SVN_REVISION_NUMBER 3587 +#define ZD_SVN_REVISION_STRING "3589" +#define ZD_SVN_REVISION_NUMBER 3589 diff --git a/src/timidity/timidity.h b/src/timidity/timidity.h index bc2c16e7..6c46317d 100644 --- a/src/timidity/timidity.h +++ b/src/timidity/timidity.h @@ -117,12 +117,13 @@ typedef float final_volume_t; #define PI 3.14159265358979323846 #endif -#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +#if defined(__GNUC__) && !defined(__clang__) && (defined(__i386__) || defined(__x86_64__)) // [RH] MinGW's pow() function is terribly slow compared to VC8's // (I suppose because it's using an old version from MSVCRT.DLL). // On an Opteron running x86-64 Linux, this also ended up being about // 100 cycles faster than libm's pow(), which is why I'm using this // for GCC in general and not just for MinGW. +// [CE] Clang doesn't yet support some inline ASM operations so I disabled it for that instance extern __inline__ double pow_x87_inline(double x,double y) {