⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t_vtx_x86_gcc.s

📁 winNT技术操作系统,国外开放的原代码和LIUX一样
💻 S
📖 第 1 页 / 共 2 页
字号:
/**************************************************************************

Copyright 2004 Tungsten Graphics Inc., Cedar Park, Texas.

All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
on the rights to use, copy, modify, merge, publish, distribute, sub
license, and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
ATI, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.

**************************************************************************/

/*
 * Authors:
 *   Keith Whitwell <keith@tungstengraphics.com>
 *   Daniel Borca <dborca@yahoo.com>
 */

#if defined (__DJGPP__) || defined (__MINGW32__) || defined (__CYGWIN__)
#define GLOBL( x )	\
.globl _##x;		\
_##x:
#else  /* !defined (__DJGPP__) && !defined (__MINGW32__) && !defined (__CYGWIN__) */
#define GLOBL( x )	\
.globl x;		\
x:
#endif /* !defined (__DJGPP__) && !defined (__MINGW32__) && !defined (__CYGWIN__) */


#if !defined (STDCALL_API)
#define RETCLEAN( x )	ret
#else
#define RETCLEAN( x )	ret $x
#endif


#define _JMP(x)		\
.byte 0xe9;		\
.long x

#define _CALL(x)	\
.byte 0xe8;		\
.long x


/* Someone who knew a lot about this sort of thing would use this
 * macro to note current offsets, etc in a special region of the
 * object file & just make everything work out neat.  I don't know
 * enough to do that...
 */

#define SUBST( x ) (0x10101010 + x)


.data


/* [dBorca] TODO
 * Unfold functions for each vertex size?
 * Build super-specialized SSE versions?
 *
 * There is a trick in Vertex*fv: under certain conditions,
 * we tail to _tnl_wrap_filled_vertex(ctx). This means that
 * if Vertex*fv is STDCALL, then _tnl_wrap_filled_vertex must
 * be STDCALL as well, because (GLcontext *) and (GLfloat *)
 * have the same size.
 */
.align 4
GLOBL ( _tnl_x86_Vertex1fv )
	movl	4(%esp), %ecx
	push	%edi
	push	%esi
	movl	SUBST(0), %edi	/* 0x0 --> tnl->vtx.vbptr */
	movl	(%ecx), %edx	/* load v[0] */
	movl	%edx, (%edi)	/* tnl->vtx.vbptr[0] = v[0] */
	addl	$4, %edi	/* tnl->vtx.vbptr += 1 */
	movl	$SUBST(1), %ecx	/* 0x1 --> (tnl->vtx.vertex_size - 1) */
	movl	$SUBST(2), %esi	/* 0x2 --> (tnl->vtx.vertex + 1) */
	repz
	movsl	%ds:(%esi), %es:(%edi)
	movl	%edi, SUBST(0)	/* 0x0 --> tnl->vtx.vbptr */
	movl	SUBST(3), %edx	/* 0x3 --> counter */
	pop	%esi
	pop	%edi
	dec	%edx		/* counter-- */
	movl	%edx, SUBST(3)	/* 0x3 --> counter */
	je	.0		/* if (counter == 0) goto .0 */
	RETCLEAN(4)		/* return */
	.balign	16
.0:
	movl	$SUBST(4), %eax	/* load ctx */
	movl	%eax, 4(%esp)	/* push ctx */
	_JMP	(SUBST(5))	/* jmp _tnl_wrap_filled_vertex */
GLOBL ( _tnl_x86_Vertex1fv_end )

.align 4
GLOBL ( _tnl_x86_Vertex2fv )
	movl	4(%esp), %ecx
	push	%edi
	push	%esi
	movl	SUBST(0), %edi	/* load tnl->vtx.vbptr */
	movl	(%ecx), %edx	/* load v[0] */
	movl	4(%ecx), %eax	/* load v[1] */
	movl	%edx, (%edi)	/* tnl->vtx.vbptr[0] = v[0] */
	movl	%eax, 4(%edi)	/* tnl->vtx.vbptr[1] = v[1] */
	addl	$8, %edi	/* tnl->vtx.vbptr += 2 */
	movl	$SUBST(1), %ecx	/* vertex_size - 2 */
	movl	$SUBST(2), %esi	/* tnl->vtx.vertex + 2 */
	repz
	movsl	%ds:(%esi), %es:(%edi)
	movl	%edi, SUBST(0)	/* save tnl->vtx.vbptr */
	movl	SUBST(3), %edx	/* load counter */
	pop	%esi
	pop	%edi
	dec	%edx		/* counter-- */
	movl	%edx, SUBST(3)	/* save counter */
	je	.1		/* if (counter == 0) goto .1 */
	RETCLEAN(4)		/* return */
	.balign	16
.1:
	movl	$SUBST(4), %eax	/* load ctx */
	movl	%eax, 4(%esp)	/* push ctx */
	_JMP	(SUBST(5))	/* jmp _tnl_wrap_filled_vertex */
GLOBL ( _tnl_x86_Vertex2fv_end )

.align 4
GLOBL ( _tnl_x86_Vertex3fv )
	movl	4(%esp), %ecx
	push	%edi
	push	%esi
	movl	SUBST(0), %edi	/* load tnl->vtx.vbptr */
	movl	(%ecx), %edx	/* load v[0] */
	movl	4(%ecx), %eax	/* load v[1] */
	movl	8(%ecx), %esi	/* load v[2] */
	movl	%edx, (%edi)	/* tnl->vtx.vbptr[0] = v[0] */
	movl	%eax, 4(%edi)	/* tnl->vtx.vbptr[1] = v[1] */
	movl	%esi, 8(%edi)	/* tnl->vtx.vbptr[2] = v[2] */
	addl	$12, %edi	/* tnl->vtx.vbptr += 3 */
	movl	$SUBST(1), %ecx	/* vertex_size - 3 */
	movl	$SUBST(2), %esi	/* tnl->vtx.vertex + 3 */
	repz
	movsl	%ds:(%esi), %es:(%edi)
	movl	%edi, SUBST(0)	/* save tnl->vtx.vbptr */
	movl	SUBST(3), %edx	/* load counter */
	pop	%esi
	pop	%edi
	dec	%edx		/* counter-- */
	movl	%edx, SUBST(3)	/* save counter */
	je	.2		/* if (counter == 0) goto .2 */
	RETCLEAN(4)		/* return */
	.balign	16
.2:
	movl	$SUBST(4), %eax	/* load ctx */
	movl	%eax, 4(%esp)	/* push ctx */
	_JMP	(SUBST(5))	/* jmp _tnl_wrap_filled_vertex */
GLOBL ( _tnl_x86_Vertex3fv_end )

.align 4
GLOBL ( _tnl_x86_Vertex4fv )
	movl	4(%esp), %ecx
	push	%edi
	push	%esi
	movl	SUBST(0), %edi	/* load tnl->vtx.vbptr */
	movl	(%ecx), %edx	/* load v[0] */
	movl	4(%ecx), %eax	/* load v[1] */
	movl	8(%ecx), %esi	/* load v[2] */
	movl	12(%ecx), %ecx	/* load v[3] */
	movl	%edx, (%edi)	/* tnl->vtx.vbptr[0] = v[0] */
	movl	%eax, 4(%edi)	/* tnl->vtx.vbptr[1] = v[1] */
	movl	%esi, 8(%edi)	/* tnl->vtx.vbptr[2] = v[2] */
	movl	%ecx, 12(%edi)	/* tnl->vtx.vbptr[3] = v[3] */
	addl	$16, %edi	/* tnl->vtx.vbptr += 4 */
	movl	$SUBST(1), %ecx	/* vertex_size - 4 */
	movl	$SUBST(2), %esi	/* tnl->vtx.vertex + 4 */
	repz
	movsl	%ds:(%esi), %es:(%edi)
	movl	%edi, SUBST(0)	/* save tnl->vtx.vbptr */
	movl	SUBST(3), %edx	/* load counter */
	pop	%esi
	pop	%edi
	dec	%edx		/* counter-- */
	movl	%edx, SUBST(3)	/* save counter */
	je	.3		/* if (counter == 0) goto .3 */
	RETCLEAN(4)		/* return */
	.balign	16
.3:
	movl	$SUBST(4), %eax	/* load ctx */
	movl	%eax, 4(%esp)	/* push ctx */
	_JMP	(SUBST(5))	/* jmp _tnl_wrap_filled_vertex */
GLOBL ( _tnl_x86_Vertex4fv_end )


/**
 * Generic handlers for vector format data. 
 */
GLOBL( _tnl_x86_Attribute1fv )
	movl	4(%esp), %ecx
	movl	(%ecx), %eax	/* load v[0] */
	movl	%eax, SUBST(0)	/* store v[0] to current vertex */
	RETCLEAN(4)
GLOBL ( _tnl_x86_Attribute1fv_end )

GLOBL( _tnl_x86_Attribute2fv )
	movl	4(%esp), %ecx
	movl	(%ecx), %eax	/* load v[0] */
	movl	4(%ecx), %edx	/* load v[1] */
	movl	%eax, SUBST(0)	/* store v[0] to current vertex */
	movl	%edx, SUBST(1)	/* store v[1] to current vertex */
	RETCLEAN(4)
GLOBL ( _tnl_x86_Attribute2fv_end )

GLOBL( _tnl_x86_Attribute3fv )
	movl	4(%esp), %ecx
	movl	(%ecx), %eax	/* load v[0] */
	movl	4(%ecx), %edx	/* load v[1] */
	movl	8(%ecx), %ecx	/* load v[2] */
	movl	%eax, SUBST(0)	/* store v[0] to current vertex */
	movl	%edx, SUBST(1)	/* store v[1] to current vertex */
	movl	%ecx, SUBST(2)	/* store v[2] to current vertex */
	RETCLEAN(4)
GLOBL ( _tnl_x86_Attribute3fv_end )

GLOBL( _tnl_x86_Attribute4fv )
	movl	4(%esp), %ecx
	movl	(%ecx), %eax	/* load v[0] */
	movl	4(%ecx), %edx	/* load v[1] */
	movl	%eax, SUBST(0)	/* store v[0] to current vertex */
	movl	%edx, SUBST(1)	/* store v[1] to current vertex */
	movl	8(%ecx), %eax	/* load v[2] */
	movl	12(%ecx), %edx	/* load v[3] */
	movl	%eax, SUBST(2)	/* store v[2] to current vertex */
	movl	%edx, SUBST(3)	/* store v[3] to current vertex */
	RETCLEAN(4)
GLOBL ( _tnl_x86_Attribute4fv_end )


/* Choosers:
 *
 * Must generate all of these ahead of first usage.  Generate at
 * compile-time?
 */
GLOBL( _tnl_x86_choose_fv )
	subl	$12, %esp	/* gcc does 16 byte alignment of stack frames? */
	movl	$SUBST(0), (%esp)	/* arg 0 - attrib */
	movl	$SUBST(1), 4(%esp)	/* arg 1 - N */
	_CALL	(SUBST(2))		/* call do_choose */
	add	$12, %esp		/* tear down stack frame */
	jmp	*%eax			/* jump to new func */
GLOBL ( _tnl_x86_choose_fv_end )


/* FIRST LEVEL FUNCTIONS -- these are plugged directly into GL dispatch.
 *
 * In the 1st level dispatch functions, switch to a different
 * calling convention -- (const GLfloat *v) in %ecx.
 *
 * As with regular (x86) dispatch, don't create a new stack frame -
 * just let the 'ret' in the dispatched function return straight
 * back to the original caller.
 *
 * Vertex/Normal/Color, etc: the address of the function pointer
 * is known at codegen time.
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -