From 4f90a1db12b4740ea671d54c585f084e09981646 Mon Sep 17 00:00:00 2001 From: dhewg Date: Thu, 15 Dec 2011 18:52:34 +0100 Subject: [PATCH] Partly restore behaviour from c17b80e9 The subtraction was inverted, but change back the behaviour too: Hardcode offsets and check via asserts() in Debug builds. --- idlib/math/Simd_SSE.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/idlib/math/Simd_SSE.cpp b/idlib/math/Simd_SSE.cpp index a4de610..2cf61a0 100644 --- a/idlib/math/Simd_SSE.cpp +++ b/idlib/math/Simd_SSE.cpp @@ -41,12 +41,12 @@ If you have questions concerning this license or the applicable additional terms //=============================================================== #define DRAWVERT_SIZE 60 -#define DRAWVERT_XYZ_OFFSET (ptrdiff_t(src) - ptrdiff_t(&src->xyz)) -#define DRAWVERT_ST_OFFSET (ptrdiff_t(src) - ptrdiff_t(&src->st)) -#define DRAWVERT_NORMAL_OFFSET (ptrdiff_t(src) - ptrdiff_t(&src->normal)) -#define DRAWVERT_TANGENT0_OFFSET (ptrdiff_t(src) - ptrdiff_t(&src->tangents[0])) -#define DRAWVERT_TANGENT1_OFFSET (ptrdiff_t(src) - ptrdiff_t(&src->tangents[1])) -#define DRAWVERT_COLOR_OFFSET (ptrdiff_t(src) - ptrdiff_t(&src->color)) +#define DRAWVERT_XYZ_OFFSET (0*4) +#define DRAWVERT_ST_OFFSET (3*4) +#define DRAWVERT_NORMAL_OFFSET (5*4) +#define DRAWVERT_TANGENT0_OFFSET (8*4) +#define DRAWVERT_TANGENT1_OFFSET (11*4) +#define DRAWVERT_COLOR_OFFSET (14*4) #if defined(__GNUC__) && defined(__SSE__) @@ -92,6 +92,7 @@ void VPCALL idSIMD_SSE::Dot( float *dst, const idPlane &constant, const idDrawVe char *dst_p = (char *) dst; // dst_p = ecx assert( sizeof( idDrawVert ) == DRAWVERT_SIZE ); + assert( ptrdiff_t(&src->xyz) - ptrdiff_t(src) == DRAWVERT_XYZ_OFFSET ); /* and eax, ~3 @@ -254,6 +255,7 @@ idSIMD_SSE::MinMax void VPCALL idSIMD_SSE::MinMax( idVec3 &min, idVec3 &max, const idDrawVert *src, const int *indexes, const int count ) { assert( sizeof( idDrawVert ) == DRAWVERT_SIZE ); + assert( ptrdiff_t(&src->xyz) - ptrdiff_t(src) == DRAWVERT_XYZ_OFFSET ); __m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; char *indexes_p;