Fix SIMD pointer casts/offsets for x86_64

Get the idDrawVert member offsets directly instead of hardcoding
them and checking them via assert() at runtime.

Fixes compile error:
cast from pointer to smaller type 'int' loses information
This commit is contained in:
dhewg 2011-12-13 17:03:33 +01:00
parent f751d7e1b8
commit c17b80e950
2 changed files with 10 additions and 19 deletions

View file

@ -40,19 +40,18 @@ If you have questions concerning this license or the applicable additional terms
// E // 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__) #if defined(MACOS_X) && defined(__i386__)
#include <xmmintrin.h> #include <xmmintrin.h>
#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 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 )) #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 char *dst_p = (char *) dst; // dst_p = ecx
assert( sizeof( idDrawVert ) == DRAWVERT_SIZE ); assert( sizeof( idDrawVert ) == DRAWVERT_SIZE );
assert( (int)&((idDrawVert *)0)->xyz == DRAWVERT_XYZ_OFFSET );
/* /*
and eax, ~3 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 ) { void VPCALL idSIMD_SSE::MinMax( idVec3 &min, idVec3 &max, const idDrawVert *src, const int *indexes, const int count ) {
assert( sizeof( idDrawVert ) == DRAWVERT_SIZE ); assert( sizeof( idDrawVert ) == DRAWVERT_SIZE );
assert( (int)&((idDrawVert *)0)->xyz == DRAWVERT_XYZ_OFFSET );
__m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7; __m128 xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
char *indexes_p; 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_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 JOINTQUAT_SIZE (7*4)
#define JOINTMAT_SIZE (4*3*4) #define JOINTMAT_SIZE (4*3*4)

View file

@ -76,7 +76,7 @@ void VPCALL idSIMD_SSE2::CmpLT( byte *dst, const byte bitNum, const float *src0,
int dst_l; int dst_l;
/* if the float array is not aligned on a 4 byte boundary */ /* if the float array is not aligned on a 4 byte boundary */
if ( ((int) src0) & 3 ) { if ( ptrdiff_t(src0) & 3 ) {
/* unaligned memory access */ /* unaligned memory access */
pre = 0; pre = 0;
cnt = count >> 2; cnt = count >> 2;
@ -152,8 +152,8 @@ void VPCALL idSIMD_SSE2::CmpLT( byte *dst, const byte bitNum, const float *src0,
} }
else { else {
/* aligned memory access */ /* aligned memory access */
aligned = (float *) ((((int) src0) + 15) & ~15); aligned = (float *) ((ptrdiff_t(src0) + 15) & ~15);
if ( (int)aligned > ((int)src0) + count ) { if ( ptrdiff_t(aligned) > ptrdiff_t(src0) + count ) {
pre = count; pre = count;
post = 0; post = 0;
} }