From 1b3402d429c4168d0dab4680e28ffbcdbf45d1f5 Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Sun, 28 Jun 2015 10:30:51 +0200 Subject: [PATCH] Revert "Change back to ATTR_FORCE_INLINE and added option for double division for perspective correction" This reverts commit d14f86b2f0dfb4c6c1502e3606b25e371ae3095c. make -R verbose=1 -C build/projects/sdl/mame/gmake-linux config=release64 Compiling src/emu/video/voodoo.c... g++ -MMD -MP -DPTR64=1 -DCRLF=2 -DLSB_FIRST -DFLAC__NO_DLL -DNATIVE_DRC=drcbe_x64 -DLUA_COMPAT_APIINTCASTS -I../../../../../src/osd -I../../../../../src/emu -I../../../../../src/mame -I../../../../../src/lib -I../../../../../src/lib/util -I../../../../../3rdparty -I../../../../generated/emu -I../../../../generated/emu/layout -I../../../../../src/emu/cpu/m68000 -I../../../../../3rdparty/expat/lib -I../../../../../3rdparty/zlib -I../../../../../3rdparty/lua/src -m64 --pipe -Wno-deprecated-declarations -O3 -fno-strict-aliasing -march=native -fPIC -Wno-unknown-pragmas -Wall -Wcast-align -Wundef -Wformat-security -Wwrite-strings -Wno-sign-compare -Wno-conversion -Wno-unused-result -Wno-narrowing -Wno-attributes -Wno-array-bounds -D__USE_MINGW_ANSI_STDIO=1 -m64 -DINLINE="static inline" -x c++ -std=gnu++98 -Woverloaded-virtual -o "../../../../linux_gcc/obj/x64/Release/src/emu/video/voodoo.o" -MF ../../../../linux_gcc/obj/x64/Release/src/emu/video/voodoo.d -c "../../../../../src/emu/video/voodoo.c" In file included from ../../../../../src/emu/video/voodoo.c:151:0: ../../../../../src/emu/video/vooddefs.h: In function 'INT32 lfb_w(voodoo_state*, offs_t, UINT32, UINT32)': ../../../../../src/emu/video/vooddefs.h:3763:24: error: inlining failed in call to always_inline 'bool depthTest(UINT16, stats_block*, INT32, UINT32, INT32)': function body can be overwritten at link time ATTR_FORCE_INLINE bool depthTest(UINT16 zaColorReg, stats_block *stats, INT32 destDepth, UINT32 fbzModeReg, INT32 biasdepth) ^ ../../../../../src/emu/video/voodoo.c:3381:20: error: called from here if (!depthTest((UINT16) v->reg[zaColor].u, stats, depth[x], v->reg[fbzMode].u, biasdepth)) ^ In file included from ../../../../../src/emu/video/voodoo.c:151:0: ../../../../../src/emu/video/vooddefs.h:2405:24: error: inlining failed in call to always_inline 'bool chromaKeyTest(voodoo_state*, stats_block*, UINT32, rgb_union)': function body can be overwritten at link time ATTR_FORCE_INLINE bool chromaKeyTest(voodoo_state *v, stats_block *stats, UINT32 fbzModeReg, rgb_union color) ^ ../../../../../src/emu/video/voodoo.c:3385:24: error: called from here if (!chromaKeyTest(v, stats, v->reg[fbzMode].u, color)) ^ In file included from ../../../../../src/emu/video/voodoo.c:151:0: ../../../../../src/emu/video/vooddefs.h:2578:24: error: inlining failed in call to always_inline 'bool alphaTest(voodoo_state*, stats_block*, UINT32, UINT8)': function body can be overwritten at link time ATTR_FORCE_INLINE bool alphaTest(voodoo_state *v, stats_block *stats, UINT32 alphaModeReg, UINT8 alpha) ^ ../../../../../src/emu/video/voodoo.c:3391:20: error: called from here if (!alphaTest(v, stats, v->reg[alphaMode].u, color.rgb.a)) ^ In file included from ../../../../../src/emu/video/voodoo.c:151:0: ../../../../../src/emu/video/vooddefs.h:3118:24: error: inlining failed in call to always_inline 'void applyFogging(voodoo_state*, UINT32, UINT32, INT32, const UINT8*, INT32, rgb_union&, INT32, INT64, rgb_union)': function body can be overwritten at link time ATTR_FORCE_INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, INT32 x, const UINT8 *dither4, INT32 fogDepth, rgb_union &color, INT32 iterz, INT64 iterw, rgb_union iterargb) ^ ../../../../../src/emu/video/vooddefs.h:3856:96: error: called from here applyFogging(VV, FOGMODE, FBZCOLORPATH, XX, DITHER4, fogdepth, color, ITERZ, ITERW, ITERAXXX); \ ^ ../../../../../src/emu/video/voodoo.c:3399:5: note: in expansion of macro 'PIXEL_PIPELINE_END' PIXEL_PIPELINE_END(v, stats, dither, dither4, dither_lookup, x, dest, depth, ^ ../../../../../src/emu/video/vooddefs.h:2807:24: error: inlining failed in call to always_inline 'void alphaBlend(UINT32, UINT32, INT32, const UINT8*, int, UINT16*, rgb_union, rgb_union&)': function body can be overwritten at link time ATTR_FORCE_INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *dither, int dpix, UINT16 *depth, rgb_union preFog, rgb_union &color) ^ ../../../../../src/emu/video/vooddefs.h:3858:77: error: called from here alphaBlend(FBZMODE, ALPHAMODE, XX, DITHER, dest[XX], depth, preFog, color); \ ^ ../../../../../src/emu/video/voodoo.c:3399:5: note: in expansion of macro 'PIXEL_PIPELINE_END' PIXEL_PIPELINE_END(v, stats, dither, dither4, dither_lookup, x, dest, depth, ^ ../../../../../src/emu/video/vooddefs.h:3763:24: error: inlining failed in call to always_inline 'bool depthTest(UINT16, stats_block*, INT32, UINT32, INT32)': function body can be overwritten at link time ATTR_FORCE_INLINE bool depthTest(UINT16 zaColorReg, stats_block *stats, INT32 destDepth, UINT32 fbzModeReg, INT32 biasdepth) ^ ../../../../../src/emu/video/voodoo.c:3381:20: error: called from here if (!depthTest((UINT16) v->reg[zaColor].u, stats, depth[x], v->reg[fbzMode].u, biasdepth)) ^ In file included from ../../../../../src/emu/video/voodoo.c:151:0: ../../../../../src/emu/video/vooddefs.h:2405:24: error: inlining failed in call to always_inline 'bool chromaKeyTest(voodoo_state*, stats_block*, UINT32, rgb_union)': function body can be overwritten at link time ATTR_FORCE_INLINE bool chromaKeyTest(voodoo_state *v, stats_block *stats, UINT32 fbzModeReg, rgb_union color) ^ ../../../../../src/emu/video/voodoo.c:3385:24: error: called from here if (!chromaKeyTest(v, stats, v->reg[fbzMode].u, color)) ^ In file included from ../../../../../src/emu/video/voodoo.c:151:0: ../../../../../src/emu/video/vooddefs.h:2578:24: error: inlining failed in call to always_inline 'bool alphaTest(voodoo_state*, stats_block*, UINT32, UINT8)': function body can be overwritten at link time ATTR_FORCE_INLINE bool alphaTest(voodoo_state *v, stats_block *stats, UINT32 alphaModeReg, UINT8 alpha) ^ ../../../../../src/emu/video/voodoo.c:3391:20: error: called from here if (!alphaTest(v, stats, v->reg[alphaMode].u, color.rgb.a)) ^ In file included from ../../../../../src/emu/video/voodoo.c:151:0: ../../../../../src/emu/video/vooddefs.h:3118:24: error: inlining failed in call to always_inline 'void applyFogging(voodoo_state*, UINT32, UINT32, INT32, const UINT8*, INT32, rgb_union&, INT32, INT64, rgb_union)': function body can be overwritten at link time ATTR_FORCE_INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, INT32 x, const UINT8 *dither4, INT32 fogDepth, rgb_union &color, INT32 iterz, INT64 iterw, rgb_union iterargb) ^ ../../../../../src/emu/video/vooddefs.h:3856:96: error: called from here applyFogging(VV, FOGMODE, FBZCOLORPATH, XX, DITHER4, fogdepth, color, ITERZ, ITERW, ITERAXXX); \ ^ ../../../../../src/emu/video/voodoo.c:3399:5: note: in expansion of macro 'PIXEL_PIPELINE_END' PIXEL_PIPELINE_END(v, stats, dither, dither4, dither_lookup, x, dest, depth, ^ ../../../../../src/emu/video/vooddefs.h:2807:24: error: inlining failed in call to always_inline 'void alphaBlend(UINT32, UINT32, INT32, const UINT8*, int, UINT16*, rgb_union, rgb_union&)': function body can be overwritten at link time ATTR_FORCE_INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *dither, int dpix, UINT16 *depth, rgb_union preFog, rgb_union &color) ^ ../../../../../src/emu/video/vooddefs.h:3858:77: error: called from here alphaBlend(FBZMODE, ALPHAMODE, XX, DITHER, dest[XX], depth, preFog, color); \ ^ ../../../../../src/emu/video/voodoo.c:3399:5: note: in expansion of macro 'PIXEL_PIPELINE_END' PIXEL_PIPELINE_END(v, stats, dither, dither4, dither_lookup, x, dest, depth, ^ optional.make:7932: recipe for target '../../../../linux_gcc/obj/x64/Release/src/emu/video/voodoo.o' failed make[2]: *** [../../../../linux_gcc/obj/x64/Release/src/emu/video/voodoo.o] Error 1 Makefile:76: recipe for target 'optional' failed make[1]: *** [optional] Error 2 makefile:908: recipe for target 'linux_x64' failed make: *** [linux_x64] Error 2 --- src/emu/video/vooddefs.h | 79 +++++++++------------------------------- 1 file changed, 18 insertions(+), 61 deletions(-) diff --git a/src/emu/video/vooddefs.h b/src/emu/video/vooddefs.h index 4349a686932..f20ed902896 100644 --- a/src/emu/video/vooddefs.h +++ b/src/emu/video/vooddefs.h @@ -26,9 +26,6 @@ enum // Use old macro style or newer SSE2 optimized functions #define USE_OLD_RASTER 0 -// Use old table lookup versus straight double divide -#define USE_FAST_RECIP 1 - /* maximum number of TMUs */ #define MAX_TMU 2 @@ -2203,7 +2200,7 @@ while (0) #if (!defined(MAME_DEBUG) || defined(__OPTIMIZE__)) && (defined(__SSE2__) || defined(_MSC_VER)) && defined(PTR64) // NB: This code should no longer be SSE2-specific now that it uses rgbaint_t, consider removing the #define and the #else case. -ATTR_FORCE_INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 itera, UINT32 FBZCP) +INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 itera, UINT32 FBZCP) { rgb_t result; rgbaint_t colorint((INT32) (itera>>12), (INT32) (iterr>>12), (INT32) (iterg>>12), (INT32) (iterb>>12)); @@ -2233,7 +2230,7 @@ ATTR_FORCE_INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 #else -ATTR_FORCE_INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 itera, UINT32 FBZCP) +INLINE UINT32 clampARGB(INT32 iterr, INT32 iterg, INT32 iterb, INT32 itera, UINT32 FBZCP) { rgb_union result; INT16 r, g, b, a; @@ -2402,7 +2399,7 @@ do } \ while (0) -ATTR_FORCE_INLINE bool chromaKeyTest(voodoo_state *v, stats_block *stats, UINT32 fbzModeReg, rgb_union color) +INLINE bool chromaKeyTest(voodoo_state *v, stats_block *stats, UINT32 fbzModeReg, rgb_union color) { if (FBZMODE_ENABLE_CHROMAKEY(fbzModeReg)) { @@ -2575,7 +2572,7 @@ do } \ while (0) -ATTR_FORCE_INLINE bool alphaTest(voodoo_state *v, stats_block *stats, UINT32 alphaModeReg, UINT8 alpha) +INLINE bool alphaTest(voodoo_state *v, stats_block *stats, UINT32 alphaModeReg, UINT8 alpha) { if (ALPHAMODE_ALPHATEST(alphaModeReg)) { @@ -2804,7 +2801,7 @@ do } \ while (0) -ATTR_FORCE_INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *dither, int dpix, UINT16 *depth, rgb_union preFog, rgb_union &color) +INLINE void alphaBlend(UINT32 FBZMODE, UINT32 ALPHAMODE, INT32 x, const UINT8 *dither, int dpix, UINT16 *depth, rgb_union preFog, rgb_union &color) { if (ALPHAMODE_ALPHABLEND(ALPHAMODE)) { @@ -3115,7 +3112,7 @@ do } \ while (0) -ATTR_FORCE_INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, INT32 x, const UINT8 *dither4, INT32 fogDepth, rgb_union &color, INT32 iterz, INT64 iterw, rgb_union iterargb) +INLINE void applyFogging(voodoo_state *v, UINT32 fogModeReg, UINT32 fbzCpReg, INT32 x, const UINT8 *dither4, INT32 fogDepth, rgb_union &color, INT32 iterz, INT64 iterw, rgb_union iterargb) { if (FOGMODE_ENABLE_FOG(fogModeReg)) { @@ -3254,21 +3251,17 @@ do { \ INT32 blendr, blendg, blendb, blenda; \ INT32 tr, tg, tb, ta; \ - INT32 s, t, lod, ilod; \ + INT32 oow, s, t, lod, ilod; \ INT32 smax, tmax; \ UINT32 texbase; \ rgb_union c_local; \ - \ + \ /* determine the S/T/LOD values for this texture */ \ if (TEXMODE_ENABLE_PERSPECTIVE(TEXMODE)) \ { \ - if (USE_FAST_RECIP) { \ - const INT32 oow = fast_reciplog((ITERW), &lod); \ - s = ((INT64)oow * (ITERS)) >> 29; \ - t = ((INT64)oow * (ITERT)) >> 29; \ - } else { \ - multi_reciplog(ITERS, ITERT, ITERW, lod, s, t); \ - } \ + oow = fast_reciplog((ITERW), &lod); \ + s = ((INT64)oow * (ITERS)) >> 29; \ + t = ((INT64)oow * (ITERT)) >> 29; \ lod += (LODBASE); \ } \ else \ @@ -3760,7 +3753,7 @@ do } \ while (0) -ATTR_FORCE_INLINE bool depthTest(UINT16 zaColorReg, stats_block *stats, INT32 destDepth, UINT32 fbzModeReg, INT32 biasdepth) +INLINE bool depthTest(UINT16 zaColorReg, stats_block *stats, INT32 destDepth, UINT32 fbzModeReg, INT32 biasdepth) { /* handle depth buffer testing */ if (FBZMODE_ENABLE_DEPTHBUF(fbzModeReg)) @@ -4185,7 +4178,7 @@ do } \ while (0) -ATTR_FORCE_INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPATH, UINT32 FBZMODE, UINT32 ALPHAMODE, +INLINE bool combineColor(voodoo_state *VV, stats_block *STATS, UINT32 FBZCOLORPATH, UINT32 FBZMODE, UINT32 ALPHAMODE, rgb_union TEXELARGB, INT32 ITERZ, INT64 ITERW, rgb_union ITERARGB, rgb_union &color) { rgb_union c_other; @@ -4628,39 +4621,7 @@ static void raster_##name(void *destbase, INT32 y, const poly_extent *extent, co } \ } -// ****************************************************************************************************************************** -// Computes a log2 of a 16.32 value to 2 fractional bits of precision. -// The return value is coded as a 24.8 value. -// The maximum error using a 4 bit lookup from the mantissa is 0.0875, which is less than 1/2 lsb (0.125) for 2 bits of fraction. -// ****************************************************************************************************************************** -ATTR_FORCE_INLINE INT32 new_log2(double &value) -{ - static const INT32 new_log2_table[16] = {0, 22, 44, 63, 82, 100, 118, 134, 150, 165, 179, 193, 207, 220, 232, 244}; - UINT64 ival = *((UINT64 *)&value); - // We zero the result if negative so don't worry about the sign bit - INT32 exp = (ival>>52); - exp -= 1023+32; - exp <<= 8; - UINT32 addr = (UINT64)(ival>>48) & 0xf; - exp += new_log2_table[addr]; - // Return 0 if negative - return (ival & ((UINT64)1<<63)) ? 0 : exp; -} - -// Computes A/C and B/C and returns log2 of 1/C -// A, B and C are 16.32 values. The results are 14.18. -ATTR_FORCE_INLINE void multi_reciplog(INT64 valueA, INT64 valueB, INT64 valueC, INT32 &log, INT32 &resA, INT32 &resB) -{ - double recip = 1.0f/valueC; - double resAD = valueA * recip * ((INT64)1<<(47-29)); - double resBD = valueB * recip * ((INT64)1<<(47-29)); - log = new_log2(recip); - resA = resAD; - resB = resBD; -} - - -ATTR_FORCE_INLINE UINT32 genTexture(tmu_state *TT, INT32 x, const UINT8 *dither4, const UINT32 TEXMODE, rgb_t *LOOKUP, INT32 LODBASE, INT64 ITERS, INT64 ITERT, INT64 ITERW, INT32 &lod) +INLINE UINT32 genTexture(tmu_state *TT, INT32 x, const UINT8 *dither4, const UINT32 TEXMODE, rgb_t *LOOKUP, INT32 LODBASE, INT64 ITERS, INT64 ITERT, INT64 ITERW, INT32 &lod) { UINT32 result; INT32 s, t, ilod; @@ -4670,14 +4631,10 @@ ATTR_FORCE_INLINE UINT32 genTexture(tmu_state *TT, INT32 x, const UINT8 *dither4 if (TEXMODE_ENABLE_PERSPECTIVE(TEXMODE)) { INT32 wLog; - if (USE_FAST_RECIP) { - const INT32 oow = fast_reciplog((ITERW), &wLog); - s = ((INT64)oow * (ITERS)) >> 29; - t = ((INT64)oow * (ITERT)) >> 29; - } else { - multi_reciplog(ITERS, ITERT, ITERW, wLog, s, t); - } + const INT32 oow = fast_reciplog((ITERW), &wLog); lod += wLog; + s = ((INT64)oow * (ITERS)) >> 29; + t = ((INT64)oow * (ITERT)) >> 29; } else { @@ -4851,7 +4808,7 @@ ATTR_FORCE_INLINE UINT32 genTexture(tmu_state *TT, INT32 x, const UINT8 *dither4 return result; } -ATTR_FORCE_INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_local, rgb_union c_other, INT32 lod) +INLINE UINT32 combineTexture(tmu_state *TT, const UINT32 TEXMODE, rgb_union c_local, rgb_union c_other, INT32 lod) { UINT32 result; //INT32 blendr, blendg, blendb, blenda;