diff --git a/idlib/math/Simd_SSE.cpp b/idlib/math/Simd_SSE.cpp index 286ebe7..4c5917c 100644 --- a/idlib/math/Simd_SSE.cpp +++ b/idlib/math/Simd_SSE.cpp @@ -40,19 +40,18 @@ If you have questions concerning this license or the applicable additional terms // E //=============================================================== +#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)) #if defined(MACOS_X) && defined(__i386__) #include -#define DRAWVERT_SIZE 60 -#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) - #define SHUFFLEPS( x, y, z, w ) (( (x) & 3 ) << 6 | ( (y) & 3 ) << 4 | ( (z) & 3 ) << 2 | ( (w) & 3 )) #define R_SHUFFLEPS( x, y, z, w ) (( (w) & 3 ) << 6 | ( (z) & 3 ) << 4 | ( (y) & 3 ) << 2 | ( (x) & 3 )) @@ -93,7 +92,6 @@ 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( (int)&((idDrawVert *)0)->xyz == DRAWVERT_XYZ_OFFSET ); /* and eax, ~3 @@ -256,7 +254,6 @@ 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( (int)&((idDrawVert *)0)->xyz == DRAWVERT_XYZ_OFFSET ); __m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; char *indexes_p; @@ -998,12 +995,6 @@ void VPCALL idSIMD_SSE::Dot( float *dst, const idVec3 &constant, const idPlane * #define DRAWVERT_SIZE 60 -#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) #define JOINTQUAT_SIZE (7*4) #define JOINTMAT_SIZE (4*3*4) diff --git a/idlib/math/Simd_SSE2.cpp b/idlib/math/Simd_SSE2.cpp index 6bb89c0..639de48 100644 --- a/idlib/math/Simd_SSE2.cpp +++ b/idlib/math/Simd_SSE2.cpp @@ -76,7 +76,7 @@ void VPCALL idSIMD_SSE2::CmpLT( byte *dst, const byte bitNum, const float *src0, int dst_l; /* if the float array is not aligned on a 4 byte boundary */ - if ( ((int) src0) & 3 ) { + if ( ptrdiff_t(src0) & 3 ) { /* unaligned memory access */ pre = 0; cnt = count >> 2; @@ -152,8 +152,8 @@ void VPCALL idSIMD_SSE2::CmpLT( byte *dst, const byte bitNum, const float *src0, } else { /* aligned memory access */ - aligned = (float *) ((((int) src0) + 15) & ~15); - if ( (int)aligned > ((int)src0) + count ) { + aligned = (float *) ((ptrdiff_t(src0) + 15) & ~15); + if ( ptrdiff_t(aligned) > ptrdiff_t(src0) + count ) { pre = count; post = 0; }