Browse Source

Sparc optimized GLAPI dispatch table.

tags/mesa_3_5
davem69 24 years ago
parent
commit
775355a88a

+ 53
- 2
src/mesa/glapi/glapi.c View File

@@ -1,4 +1,4 @@
/* $Id: glapi.c,v 1.54 2001/05/29 15:23:49 brianp Exp $ */
/* $Id: glapi.c,v 1.55 2001/06/05 23:54:00 davem69 Exp $ */

/*
* Mesa 3-D graphics library
@@ -52,7 +52,9 @@
#include "glapitable.h"
#include "glthread.h"


#ifdef USE_SPARC_ASM
#include "SPARC/sparc.h"
#endif

/***** BEGIN NO-OP DISPATCH *****/

@@ -1754,6 +1756,55 @@ generate_entrypoint(GLuint functionOffset)
*(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4;
}
return code;
#elif defined(USE_SPARC_ASM)

#ifdef __sparc_v9__
static const unsigned int insn_template[] = {
0x05000000, /* sethi %uhi(_glapi_Dispatch), %g2 */
0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */
0x8410a000, /* or %g2, %ulo(_glapi_Dispatch), %g2 */
0x82106000, /* or %g1, %lo(_glapi_Dispatch), %g1 */
0x8528b020, /* sllx %g2, 32, %g2 */
0xc2584002, /* ldx [%g1 + %g2], %g1 */
0x05000000, /* sethi %hi(8 * glapioffset), %g2 */
0x8410a000, /* or %g2, %lo(8 * glapioffset), %g2 */
0xc6584002, /* ldx [%g1 + %g2], %g3 */
0x81c0c000, /* jmpl %g3, %g0 */
0x01000000 /* nop */
};
#else
static const unsigned int insn_template[] = {
0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */
0xc2006000, /* ld [%g1 + %lo(_glapi_Dispatch)], %g1 */
0xc6006000, /* ld [%g1 + %lo(4*glapioffset)], %g3 */
0x81c0c000, /* jmpl %g3, %g0 */
0x01000000 /* nop */
};
#endif
unsigned int *code = malloc(sizeof(insn_template));
unsigned long glapi_addr = (unsigned long) &_glapi_Dispatch;
if (code) {
memcpy(code, insn_template, sizeof(insn_template));

#ifdef __sparc_v9__
code[0] |= (glapi_addr >> (32 + 10));
code[1] |= ((glapi_addr & 0xffffffff) >> 10);
_mesa_sparc_icache_flush(&code[0]);
code[2] |= ((glapi_addr >> 32) & ((1 << 10) - 1));
code[3] |= (glapi_addr & ((1 << 10) - 1));
_mesa_sparc_icache_flush(&code[2]);
code[6] |= ((functionOffset * 8) >> 10);
code[7] |= ((functionOffset * 8) & ((1 << 10) - 1));
_mesa_sparc_icache_flush(&code[6]);
#else
code[0] |= (glapi_addr >> 10);
code[1] |= (glapi_addr & ((1 << 10) - 1));
_mesa_sparc_icache_flush(&code[0]);
code[2] |= (functionOffset * 4);
_mesa_sparc_icache_flush(&code[2]);
#endif
}
return code;
#else
return NULL;
#endif

+ 10
- 4
src/mesa/glapi/glsparcasm.py View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python

# $Id: glsparcasm.py,v 1.1 2001/06/05 04:30:03 davem69 Exp $
# $Id: glsparcasm.py,v 1.2 2001/06/05 23:54:00 davem69 Exp $

# Mesa 3-D graphics library
# Version: 3.5
@@ -51,15 +51,21 @@ def PrintHead():
print ' * sethi/or instruction sequences below at library init time.'
print ' */'
print ''
print '.text'
print '.data'
print '.align 64'
print ''
print '.globl _mesa_sparc_glapi_begin'
print '_mesa_sparc_glapi_begin:'
print ''
return
#endif

def PrintTail():
print '\t nop'
print ''
print '.globl _mesa_sparc_glapi_end'
print '_mesa_sparc_glapi_end:'
print ''
#endif


@@ -73,13 +79,13 @@ def GenerateDispatchCode(name, offset):
print '\tor\t%g2, %lo(0x00000000), %g2'
print '\tor\t%g1, %lo(0x00000000), %g1'
print '\tsllx\t%g2, 32, %g2'
print '\tor\t%g1, %g2, %g1'
print '\tldx\t[%g1 + %g2], %g1'
print "\tsethi\t%%hi(8 * _gloffset_%s), %%g2" % (offset)
print "\tor\t%%g2, %%lo(8 * _gloffset_%s), %%g2" % (offset)
print '\tldx\t[%g1 + %g2], %g3'
print '#else'
print '\tsethi\t%hi(0x00000000), %g1'
print '\tor\t%g1, %lo(0x00000000), %g1'
print '\tld\t[%g1 + %lo(0x00000000)], %g1'
print "\tld\t[%%g1 + (4 * _gloffset_%s)], %%g3" % (offset)
print '#endif'
print '\tjmpl\t%g3, %g0'

+ 7
- 1
src/mesa/main/context.c View File

@@ -1,4 +1,4 @@
/* $Id: context.c,v 1.140 2001/06/05 03:58:20 davem69 Exp $ */
/* $Id: context.c,v 1.141 2001/06/05 23:54:00 davem69 Exp $ */

/*
* Mesa 3-D graphics library
@@ -66,6 +66,9 @@
#include "Trace/tr_wrapper.h"
#endif

#ifdef USE_SPARC_ASM
#include "SPARC/sparc.h"
#endif

#ifndef MESA_VERBOSE
int MESA_VERBOSE = 0
@@ -453,6 +456,9 @@ one_time_init( void )
_math_init();
_mesa_init_math();

#ifdef USE_SPARC_ASM
_mesa_init_sparc_glapi_relocs();
#endif
if (getenv("MESA_DEBUG")) {
_glapi_noop_enable_warnings(GL_TRUE);
}

+ 2
- 2
src/mesa/main/dispatch.c View File

@@ -1,4 +1,4 @@
/* $Id: dispatch.c,v 1.22 2001/03/28 17:20:20 brianp Exp $ */
/* $Id: dispatch.c,v 1.23 2001/06/05 23:54:00 davem69 Exp $ */

/*
* Mesa 3-D graphics library
@@ -48,7 +48,7 @@
#include "glthread.h"
#endif

#if !defined(USE_X86_ASM)
#if !(defined(USE_X86_ASM) || defined(USE_SPARC_ASM))

#define KEYWORD1
#define KEYWORD2 GLAPIENTRY

+ 1363
- 1223
src/mesa/sparc/glapi_sparc.S
File diff suppressed because it is too large
View File


+ 31
- 2
src/mesa/sparc/sparc.c View File

@@ -1,4 +1,4 @@
/* $Id: sparc.c,v 1.2 2001/05/23 14:42:47 brianp Exp $ */
/* $Id: sparc.c,v 1.3 2001/06/05 23:54:01 davem69 Exp $ */

/*
* Mesa 3-D graphics library
@@ -29,7 +29,6 @@
*/


#include "glheader.h"
#include "context.h"
#include "math/m_vertices.h"
#include "math/m_xform.h"
@@ -107,3 +106,33 @@ void _mesa_init_all_sparc_transform_asm(void)

#endif
}

extern unsigned int _mesa_sparc_glapi_begin;
extern unsigned int _mesa_sparc_glapi_end;

void _mesa_init_sparc_glapi_relocs(void)
{
unsigned int *insn_ptr, *end_ptr;
unsigned long disp_addr;

insn_ptr = &_mesa_sparc_glapi_begin;
end_ptr = &_mesa_sparc_glapi_end;
disp_addr = (unsigned long) &_glapi_Dispatch;

while (insn_ptr < end_ptr) {
#ifdef __sparc_v9__
insn_ptr[0] |= (disp_addr >> (32 + 10));
insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
_mesa_sparc_icache_flush(&insn_ptr[0]);
insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
_mesa_sparc_icache_flush(&insn_ptr[2]);
insn_ptr += 10;
#else
insn_ptr[0] |= (disp_addr >> 10);
insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
_mesa_sparc_icache_flush(&insn_ptr[0]);
insn_ptr += 4;
#endif
}
}

+ 3
- 1
src/mesa/sparc/sparc.h View File

@@ -1,4 +1,4 @@
/* $Id: sparc.h,v 1.1 2001/05/23 14:27:03 brianp Exp $ */
/* $Id: sparc.h,v 1.2 2001/06/05 23:54:01 davem69 Exp $ */

/*
* Mesa 3-D graphics library
@@ -33,5 +33,7 @@
#define SPARC_H

extern void _mesa_init_all_sparc_transform_asm(void);
extern void _mesa_init_sparc_glapi_relocs(void);
extern void _mesa_sparc_icache_flush(unsigned int *);

#endif /* !(SPARC_H) */

+ 40
- 154
src/mesa/sparc/sparc_matrix.h View File

@@ -1,4 +1,34 @@
/* $Id: sparc_matrix.h,v 1.1 2001/05/23 14:27:03 brianp Exp $ */
/* $Id: sparc_matrix.h,v 1.2 2001/06/05 23:54:01 davem69 Exp $ */

#ifndef _SPARC_MATRIX_H
#define _SPARC_MATRIX_H

#ifdef __sparc_v9__
#define LDPTR ldx
#define MAT_M 0x00
#define MAT_INV 0x08
#define V4F_DATA 0x00
#define V4F_START 0x08
#define V4F_COUNT 0x10
#define V4F_STRIDE 0x14
#define V4F_SIZE 0x18
#define V4F_FLAGS 0x1c
#else
#define LDPTR ld
#define MAT_M 0x00
#define MAT_INV 0x04
#define V4F_DATA 0x00
#define V4F_START 0x04
#define V4F_COUNT 0x08
#define V4F_STRIDE 0x0c
#define V4F_SIZE 0x10
#define V4F_FLAGS 0x14
#endif

#define VEC_SIZE_1 1
#define VEC_SIZE_2 3
#define VEC_SIZE_3 7
#define VEC_SIZE_4 15

#define M0 %f16
#define M1 %f17
@@ -17,158 +47,6 @@
#define M14 %f30
#define M15 %f31

/* Seems to work, disable if unaligned traps begin to appear... -DaveM */
#define USE_LD_DOUBLE

#ifndef USE_LD_DOUBLE

#define LDMATRIX_0_1_2_3_12_13_14_15(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + ( 2 * 0x4)], M2; \
ld [BASE + ( 3 * 0x4)], M3; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14; \
ld [BASE + (15 * 0x4)], M15

#define LDMATRIX_0_1_12_13(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13

#define LDMATRIX_0_12_13(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13

#define LDMATRIX_0_1_2_12_13_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + ( 2 * 0x4)], M2; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_12_13_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_1_2_3_4_5_6_7_12_13_14_15(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + ( 2 * 0x4)], M2; \
ld [BASE + ( 3 * 0x4)], M3; \
ld [BASE + ( 4 * 0x4)], M4; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + ( 6 * 0x4)], M6; \
ld [BASE + ( 7 * 0x4)], M7; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14; \
ld [BASE + (15 * 0x4)], M15

#define LDMATRIX_0_1_4_5_12_13(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + ( 4 * 0x4)], M4; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13

#define LDMATRIX_0_5_12_13(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13

#define LDMATRIX_0_1_2_3_4_5_6_12_13_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + ( 2 * 0x4)], M2; \
ld [BASE + ( 3 * 0x4)], M3; \
ld [BASE + ( 4 * 0x4)], M4; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + ( 6 * 0x4)], M6; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_5_12_13_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_5_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_1_2_3_4_5_6_7_8_9_10_11_12_13_14_15(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + ( 2 * 0x4)], M2; \
ld [BASE + ( 3 * 0x4)], M3; \
ld [BASE + ( 4 * 0x4)], M4; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + ( 6 * 0x4)], M6; \
ld [BASE + ( 7 * 0x4)], M7; \
ld [BASE + ( 8 * 0x4)], M8; \
ld [BASE + ( 9 * 0x4)], M9; \
ld [BASE + (10 * 0x4)], M10; \
ld [BASE + (11 * 0x4)], M11; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14; \
ld [BASE + (15 * 0x4)], M15

#define LDMATRIX_0_5_12_13(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13

#define LDMATRIX_0_1_2_4_5_6_8_9_10_12_13_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 1 * 0x4)], M1; \
ld [BASE + ( 2 * 0x4)], M2; \
ld [BASE + ( 4 * 0x4)], M4; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + ( 6 * 0x4)], M6; \
ld [BASE + ( 8 * 0x4)], M8; \
ld [BASE + ( 9 * 0x4)], M9; \
ld [BASE + (10 * 0x4)], M10; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_5_10_12_13_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + (10 * 0x4)], M10; \
ld [BASE + (12 * 0x4)], M12; \
ld [BASE + (13 * 0x4)], M13; \
ld [BASE + (14 * 0x4)], M14

#define LDMATRIX_0_5_8_9_10_14(BASE) \
ld [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 5 * 0x4)], M5; \
ld [BASE + ( 8 * 0x4)], M8; \
ld [BASE + ( 9 * 0x4)], M9; \
ld [BASE + (10 * 0x4)], M10; \
ld [BASE + (14 * 0x4)], M14

#else /* !(USE_LD_DOUBLE) */

#define LDMATRIX_0_1_2_3_12_13_14_15(BASE) \
ldd [BASE + ( 0 * 0x4)], M0; \
ldd [BASE + ( 2 * 0x4)], M2; \
@@ -250,6 +128,14 @@
ld [BASE + ( 5 * 0x4)], M5; \
ldd [BASE + (12 * 0x4)], M12

#define LDMATRIX_0_1_2_4_5_6_8_9_10(BASE) \
ldd [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 2 * 0x4)], M2; \
ldd [BASE + ( 4 * 0x4)], M4; \
ld [BASE + ( 6 * 0x4)], M6; \
ldd [BASE + ( 8 * 0x4)], M8; \
ld [BASE + (10 * 0x4)], M10

#define LDMATRIX_0_1_2_4_5_6_8_9_10_12_13_14(BASE) \
ldd [BASE + ( 0 * 0x4)], M0; \
ld [BASE + ( 2 * 0x4)], M2; \
@@ -274,4 +160,4 @@
ld [BASE + (10 * 0x4)], M10; \
ld [BASE + (14 * 0x4)], M14

#endif /* USE_LD_DOUBLE */
#endif /* !(_SPARC_MATRIX_H) */

+ 2
- 25
src/mesa/sparc/xform.S View File

@@ -1,4 +1,4 @@
/* $Id: xform.S,v 1.1 2001/05/23 14:27:03 brianp Exp $ */
/* $Id: xform.S,v 1.2 2001/06/05 23:54:01 davem69 Exp $ */

/* TODO
*
@@ -16,28 +16,7 @@
* tricky and not much of a gain though.
*/

#ifdef __sparc_v9__
#define LDPTR ldx
#define V4F_DATA 0x00
#define V4F_START 0x08
#define V4F_COUNT 0x10
#define V4F_STRIDE 0x14
#define V4F_SIZE 0x18
#define V4F_FLAGS 0x1c
#else
#define LDPTR ld
#define V4F_DATA 0x00
#define V4F_START 0x04
#define V4F_COUNT 0x08
#define V4F_STRIDE 0x0c
#define V4F_SIZE 0x10
#define V4F_FLAGS 0x14
#endif

#define VEC_SIZE_1 1
#define VEC_SIZE_2 3
#define VEC_SIZE_3 7
#define VEC_SIZE_4 15
#include "sparc_matrix.h"

.text
.align 64
@@ -71,8 +50,6 @@ __set_v4f_4:
retl
st %g2, [%o0 + V4F_FLAGS]

#include "sparc_matrix.h"

/* First the raw versions. */

.globl _mesa_sparc_transform_points1_general

Loading…
Cancel
Save