mirror of
https://github.com/dhewm/dhewm3.git
synced 2024-11-23 12:53:09 +00:00
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:
parent
f751d7e1b8
commit
c17b80e950
2 changed files with 10 additions and 19 deletions
|
@ -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 <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 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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue