Updating to IOQ3 svn 2064, vbos-glsl-17 and various fixes.

This commit is contained in:
Richard Allen 2011-07-11 19:12:59 +00:00
parent 58af049d5f
commit 0f8f033aca
12 changed files with 1692 additions and 0 deletions

View file

@ -0,0 +1,90 @@
; ===========================================================================
; Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu>
;
; This file is part of Quake III Arena source code.
;
; Quake III Arena source code is free software; you can redistribute it
; and/or modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the License,
; or (at your option) any later version.
;
; Quake III Arena source code is distributed in the hope that it will be
; useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with Quake III Arena source code; if not, write to the Free Software
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
; ===========================================================================
; MASM ftol conversion functions using SSE or FPU
; assume __cdecl calling convention is being used for x86, __fastcall for x64
IFNDEF idx64
.model flat, c
ENDIF
; .data
; ifndef idx64
; fpucw WORD 0F7Fh
; endif
.code
IFDEF idx64
; qftol using SSE
qftolsse PROC
cvttss2si eax, xmm0
ret
qftolsse ENDP
qvmftolsse PROC
movss xmm0, dword ptr [rdi + rbx * 4]
cvttss2si eax, xmm0
ret
qvmftolsse ENDP
ELSE
; qftol using FPU
qftolx87m macro src
; not necessary, fpucw is set with _controlfp at startup
; sub esp, 2
; fnstcw word ptr [esp]
; fldcw fpucw
fld dword ptr src
fistp dword ptr src
; fldcw [esp]
mov eax, src
; add esp, 2
ret
endm
qftolx87 PROC
; need this line when storing FPU control word on stack
; qftolx87m [esp + 6]
qftolx87m [esp + 4]
qftolx87 ENDP
qvmftolx87 PROC
qftolx87m [edi + ebx * 4]
qvmftolx87 ENDP
; qftol using SSE
qftolsse PROC
movss xmm0, dword ptr [esp + 4]
cvttss2si eax, xmm0
ret
qftolsse ENDP
qvmftolsse PROC
movss xmm0, dword ptr [edi + ebx * 4]
cvttss2si eax, xmm0
ret
qvmftolsse ENDP
ENDIF
end

88
reaction/code/asm/ftola.c Normal file
View file

@ -0,0 +1,88 @@
/*
===========================================================================
Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu>
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qasm-inline.h"
/*
* GNU inline asm ftol conversion functions using SSE or FPU
*/
long qftolsse(float f)
{
long retval;
__asm__ volatile
(
"cvttss2si %1, %0\n"
: "=r" (retval)
: "x" (f)
);
return retval;
}
int qvmftolsse(void)
{
int retval;
__asm__ volatile
(
"movss (" EDI ", " EBX ", 4), %%xmm0\n"
"cvttss2si %%xmm0, %0\n"
: "=r" (retval)
:
: "%xmm0"
);
return retval;
}
long qftolx87(float f)
{
long retval;
__asm__ volatile
(
"flds %1\n"
"fistpl %1\n"
"mov %1, %0\n"
: "=r" (retval)
: "m" (f)
);
return retval;
}
int qvmftolx87(void)
{
int retval;
__asm__ volatile
(
"flds (" EDI ", " EBX ", 4)\n"
"fistpl (" EDI ", " EBX ", 4)\n"
"mov (" EDI ", " EBX ", 4), %0\n"
: "=r" (retval)
);
return retval;
}

View file

@ -0,0 +1,39 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __ASM_INLINE_I386__
#define __ASM_INLINE_I386__
#include "../qcommon/q_platform.h"
#if idx64
#define EAX "%%rax"
#define EBX "%%rbx"
#define ESP "%%rsp"
#define EDI "%%rdi"
#else
#define EAX "%%eax"
#define EBX "%%ebx"
#define ESP "%%esp"
#define EDI "%%edi"
#endif
#endif

View file

@ -0,0 +1,107 @@
; ===========================================================================
; Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu>
;
; This file is part of Quake III Arena source code.
;
; Quake III Arena source code is free software; you can redistribute it
; and/or modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the License,
; or (at your option) any later version.
;
; Quake III Arena source code is distributed in the hope that it will be
; useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with Quake III Arena source code; if not, write to the Free Software
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
; ===========================================================================
; MASM version of snapvector conversion function using SSE or FPU
; assume __cdecl calling convention is being used for x86, __fastcall for x64
;
; function prototype:
; void qsnapvector(vec3_t vec)
IFNDEF idx64
.model flat, c
ENDIF
.data
ALIGN 16
ssemask DWORD 0FFFFFFFFh, 0FFFFFFFFh, 0FFFFFFFFh, 00000000h
ssecw DWORD 00001F80h
IFNDEF idx64
fpucw WORD 037Fh
ENDIF
.code
IFDEF idx64
; qsnapvector using SSE
qsnapvectorsse PROC
sub rsp, 8
stmxcsr [rsp] ; save SSE control word
ldmxcsr ssecw ; set to round nearest
push rdi
mov rdi, rcx ; maskmovdqu uses rdi as implicit memory operand
movaps xmm1, ssemask ; initialize the mask register for maskmovdqu
movups xmm0, [rdi] ; here is stored our vector. Read 4 values in one go
cvtps2dq xmm0, xmm0 ; convert 4 single fp to int
cvtdq2ps xmm0, xmm0 ; convert 4 int to single fp
maskmovdqu xmm0, xmm1 ; write 3 values back to memory
pop rdi
ldmxcsr [rsp] ; restore sse control word to old value
add rsp, 8
ret
qsnapvectorsse ENDP
ELSE
qsnapvectorsse PROC
sub esp, 8
stmxcsr [esp] ; save SSE control word
ldmxcsr ssecw ; set to round nearest
push edi
mov edi, dword ptr 16[esp] ; maskmovdqu uses edi as implicit memory operand
movaps xmm1, ssemask ; initialize the mask register for maskmovdqu
movups xmm0, [edi] ; here is stored our vector. Read 4 values in one go
cvtps2dq xmm0, xmm0 ; convert 4 single fp to int
cvtdq2ps xmm0, xmm0 ; convert 4 int to single fp
maskmovdqu xmm0, xmm1 ; write 3 values back to memory
pop edi
ldmxcsr [esp] ; restore sse control word to old value
add esp, 8
ret
qsnapvectorsse ENDP
qroundx87 macro src
fld dword ptr src
fistp dword ptr src
fild dword ptr src
fstp dword ptr src
endm
qsnapvectorx87 PROC
mov eax, dword ptr 4[esp]
sub esp, 2
fnstcw word ptr [esp]
fldcw fpucw
qroundx87 [eax]
qroundx87 4[eax]
qroundx87 8[eax]
fldcw [esp]
add esp, 2
qsnapvectorx87 ENDP
ENDIF
end

View file

@ -0,0 +1,87 @@
/*
===========================================================================
Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu>
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#include "qasm-inline.h"
#include "../qcommon/q_shared.h"
/*
* GNU inline asm version of qsnapvector
* See MASM snapvector.asm for commentary
*/
static unsigned char ssemask[16] __attribute__((aligned(16))) =
{
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\x00\x00"
};
static const unsigned int ssecw __attribute__((aligned(16))) = 0x00001F80;
static const unsigned short fpucw = 0x037F;
void qsnapvectorsse(vec3_t vec)
{
uint32_t oldcw __attribute__((aligned(16)));
__asm__ volatile
(
"stmxcsr %3\n"
"ldmxcsr %1\n"
"movaps (%0), %%xmm1\n"
"movups (%2), %%xmm0\n"
"cvtps2dq %%xmm0, %%xmm0\n"
"cvtdq2ps %%xmm0, %%xmm0\n"
// vec MUST reside in register rdi as maskmovdqu uses
// it as an implicit operand. The "D" constraint makes
// sure of that.
"maskmovdqu %%xmm1, %%xmm0\n"
"ldmxcsr %3\n"
:
: "r" (ssemask), "m" (ssecw), "D" (vec), "m" (oldcw)
: "memory", "%xmm0", "%xmm1"
);
}
#define QROUNDX87(src) \
"flds " src "\n" \
"fistp " src "\n" \
"fild " src "\n" \
"fstp " src "\n"
void qsnapvectorx87(vec3_t vec)
{
__asm__ volatile
(
"sub $2, " ESP "\n"
"fnstcw (" ESP ")\n"
"fldcw %0\n"
QROUNDX87("(%1)")
QROUNDX87("4(%1)")
QROUNDX87("8(%1)")
"fldcw (" ESP ")\n"
"add $2, " ESP "\n"
:
: "m" (fpucw), "r" (vec)
: "memory"
);
}

View file

@ -0,0 +1,76 @@
; ===========================================================================
; Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu>
;
; This file is part of Quake III Arena source code.
;
; Quake III Arena source code is free software; you can redistribute it
; and/or modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of the License,
; or (at your option) any later version.
;
; Quake III Arena source code is distributed in the hope that it will be
; useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with Quake III Arena source code; if not, write to the Free Software
; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
; ===========================================================================
; Call wrapper for vm_x86 when built with MSVC in 64 bit mode,
; since MSVC does not support inline x64 assembler code anymore.
;
; assumes __fastcall calling convention
DoSyscall PROTO
.code
; Call to static void DoSyscall(int syscallNum, int programStack, int *opStackBase, uint8_t opStackOfs, intptr_t arg)
qsyscall64 PROC
sub rsp, 28h ; after this esp will be aligned to 16 byte boundary
mov qword ptr [rsp + 20h], rcx ; 5th parameter "arg" is passed on stack
mov r9b, bl ; opStackOfs
mov r8, rdi ; opStackBase
mov edx, esi ; programStack
mov ecx, eax ; syscallNum
mov rax, DoSyscall ; store call address of DoSyscall in rax
call rax
add rsp, 28h
ret
qsyscall64 ENDP
; Call to compiled code after setting up the register environment for the VM
; prototype:
; uint8_t qvmcall64(int *programStack, int *opStack, intptr_t *instructionPointers, byte *dataBase);
qvmcall64 PROC
push rsi ; push non-volatile registers to stack
push rdi
push rbx
; need to save pointer in rcx so we can write back the programData value to caller
push rcx
; registers r8 and r9 have correct value already thanx to __fastcall
xor rbx, rbx ; opStackOfs starts out being 0
mov rdi, rdx ; opStack
mov esi, dword ptr [rcx] ; programStack
call qword ptr [r8] ; instructionPointers[0] is also the entry point
pop rcx
mov dword ptr [rcx], esi ; write back the programStack value
mov al, bl ; return opStack offset
pop rbx
pop rdi
pop rsi
ret
qvmcall64 ENDP
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,129 @@
/*
===========================================================================
This file is part of Quake III Arena source code.
Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __IQM_H__
#define __IQM_H__
#define IQM_MAGIC "INTERQUAKEMODEL"
#define IQM_VERSION 2
#define IQM_MAX_JOINTS 128
typedef struct iqmheader
{
char magic[16];
unsigned int version;
unsigned int filesize;
unsigned int flags;
unsigned int num_text, ofs_text;
unsigned int num_meshes, ofs_meshes;
unsigned int num_vertexarrays, num_vertexes, ofs_vertexarrays;
unsigned int num_triangles, ofs_triangles, ofs_adjacency;
unsigned int num_joints, ofs_joints;
unsigned int num_poses, ofs_poses;
unsigned int num_anims, ofs_anims;
unsigned int num_frames, num_framechannels, ofs_frames, ofs_bounds;
unsigned int num_comment, ofs_comment;
unsigned int num_extensions, ofs_extensions;
} iqmHeader_t;
typedef struct iqmmesh
{
unsigned int name;
unsigned int material;
unsigned int first_vertex, num_vertexes;
unsigned int first_triangle, num_triangles;
} iqmMesh_t;
enum
{
IQM_POSITION = 0,
IQM_TEXCOORD = 1,
IQM_NORMAL = 2,
IQM_TANGENT = 3,
IQM_BLENDINDEXES = 4,
IQM_BLENDWEIGHTS = 5,
IQM_COLOR = 6,
IQM_CUSTOM = 0x10
};
enum
{
IQM_BYTE = 0,
IQM_UBYTE = 1,
IQM_SHORT = 2,
IQM_USHORT = 3,
IQM_INT = 4,
IQM_UINT = 5,
IQM_HALF = 6,
IQM_FLOAT = 7,
IQM_DOUBLE = 8,
};
typedef struct iqmtriangle
{
unsigned int vertex[3];
} iqmTriangle_t;
typedef struct iqmjoint
{
unsigned int name;
int parent;
float translate[3], rotate[4], scale[3];
} iqmJoint_t;
typedef struct iqmpose
{
int parent;
unsigned int mask;
float channeloffset[10];
float channelscale[10];
} iqmPose_t;
typedef struct iqmanim
{
unsigned int name;
unsigned int first_frame, num_frames;
float framerate;
unsigned int flags;
} iqmAnim_t;
enum
{
IQM_LOOP = 1<<0
};
typedef struct iqmvertexarray
{
unsigned int type;
unsigned int flags;
unsigned int format;
unsigned int size;
unsigned int offset;
} iqmVertexArray_t;
typedef struct iqmbounds
{
float bbmin[3], bbmax[3];
float xyradius, radius;
} iqmBounds_t;
#endif

File diff suppressed because it is too large Load diff