Submitted By: Kevin Day Date: 2006-06-21 Initial Package Version: 6.4 Upstream Status: submitted Description: This is a recreation of the patch supplied by bug #4197. Except, this time, it encases all of the NO_TEXREL differences under the DEFINE GLX_NO_TEXREL. In hopes that Mesa will accept this upstream given that developers would have to explicitly pass -DGLX_NO_TEXREL. This way, both worlds can be happy. --- Mesa-6.5/src/mesa/x86/glapi_x86.S.orig 2006-06-21 18:41:10.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/glapi_x86.S 2006-06-21 18:56:06.000000000 +0000 @@ -66,34 +66,70 @@ JMP(GL_OFFSET(off)) #elif defined(PTHREADS) +#ifdef GLX_NO_TEXREL # define GL_STUB(fn,off,fn_alt) \ ALIGNTEXT16; \ GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ GL_PREFIX(fn, fn_alt): \ - MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ + CALL(GL_PREFIX(get_dispatchbase, get_dispatchbase)) ;\ TEST_L(EAX, EAX) ; \ JE(1f) ; \ JMP(GL_OFFSET(off)) ; \ 1: CALL(_x86_get_dispatch) ; \ JMP(GL_OFFSET(off)) +#else +# define GL_STUB(fn,off,fn_alt) \ +ALIGNTEXT16; \ +GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ +GL_PREFIX(fn, fn_alt): \ + MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ + TEST_L(EAX, EAX) ; \ + JE(1f) ; \ + JMP(GL_OFFSET(off)) ; \ +1: CALL(_x86_get_dispatch) ; \ + JMP(GL_OFFSET(off)) +#endif /* GLX_NO_TEXREL */ + #elif defined(THREADS) +#ifdef GLX_NO_TEXREL # define GL_STUB(fn,off,fn_alt) \ ALIGNTEXT16; \ GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ GL_PREFIX(fn, fn_alt): \ - MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ + CALL(GL_PREFIX(get_dispatchbase, get_dispatchbase)) ;\ TEST_L(EAX, EAX) ; \ JE(1f) ; \ JMP(GL_OFFSET(off)) ; \ 1: CALL(_glapi_get_dispatch) ; \ JMP(GL_OFFSET(off)) +#else +# define GL_STUB(fn,off,fn_alt) \ +ALIGNTEXT16; \ +GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ +GL_PREFIX(fn, fn_alt): \ + MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ + TEST_L(EAX, EAX) ; \ + JE(1f) ; \ + JMP(GL_OFFSET(off)) ; \ +1: CALL(_glapi_get_dispatch) ; \ + JMP(GL_OFFSET(off)) +#endif /* GLX_NO_TEXREL */ #else /* Non-threaded version. */ +#ifdef GLX_NO_TEXREL +# define GL_STUB(fn,off,fn_alt) \ +ALIGNTEXT16; \ +GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ +GL_PREFIX(fn, fn_alt): \ + CALL(GL_PREFIX(get_dispatchbase, get_dispatchbase)) ;\ + JMP(GL_OFFSET(off)) +#else # define GL_STUB(fn,off,fn_alt) \ ALIGNTEXT16; \ GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ GL_PREFIX(fn, fn_alt): \ MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ JMP(GL_OFFSET(off)) +#endif /* GLX_NO_TEXREL */ #endif #ifdef HAVE_ALIAS @@ -107,6 +143,16 @@ SEG_TEXT +#ifdef GLX_NO_TEXREL + GL_PREFIX(get_dispatchbase, get_dispatchbase): + /* store eip then the dispatch table base in eax */ + MOV_L(CONST(_GLOBAL_OFFSET_TABLE_), EDX) + MOV_L(REGIND(ESP), EAX) + ADD_L(REGOFF(-4, EAX), EAX) + MOV_L(REGBID(EAX, EDX, GLNAME(_glapi_Dispatch)@GOTOFF), EAX) + RET +#endif /* GLX_NO_TEXREL */ + #ifdef GLX_USE_TLS GLOBL GLNAME(_x86_get_dispatch) @@ -123,9 +169,20 @@ ALIGNTEXT16 GLNAME(_x86_get_dispatch): +#ifdef GLX_NO_TEXREL + MOV_L(CONST(_GLOBAL_OFFSET_TABLE_), EDX) + MOV_L(REGIND(ESP), EAX) + ADD_L(REGOFF(-4, EAX), EAX) +#endif /* GLX_NO_TEXREL */ SUB_L(CONST(24), ESP) +#ifdef GLX_NO_TEXREL + MOV_L(REGBID(EAX, EDX, GLNAME(_gl_DispatchTSD)@GOT), EAX) + PUSH_L(REGIND(EAX)) + CALL(GLNAME(pthread_getspecific@PLT)) +#else PUSH_L(GLNAME(_gl_DispatchTSD)) CALL(GLNAME(pthread_getspecific)) +#endif /* GLX_NO_TEXREL */ ADD_L(CONST(28), ESP) RET #elif defined(THREADS) --- Mesa-6.5/src/mesa/x86/mmx_blendtmp.h.orig 2006-06-21 19:00:59.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/mmx_blendtmp.h 2006-06-21 19:06:18.000000000 +0000 @@ -12,6 +12,12 @@ * */ ALIGNTEXT16 +#ifdef GLX_NO_TEXREL +LLBL( TAG(mesa_mmx_blend_get_eip) ): + /* store eip in edx */ + MOV_L ( REGIND(ESP), EDX ) + RET +#endif /* GLX_NO_TEXREL */ GLOBL GLNAME( TAG(_mesa_mmx_blend) ) HIDDEN( TAG(_mesa_mmx_blend) ) GLNAME( TAG(_mesa_mmx_blend) ): @@ -30,6 +36,11 @@ MOV_L ( REGOFF(20, EBP), EDI ) /* rgba */ MOV_L ( REGOFF(24, EBP), ESI ) /* dest */ +#ifdef GLX_NO_TEXREL + CALL ( LLBL( TAG(mesa_mmx_blend_get_eip) ) ) + ADD_L ( CONST(_GLOBAL_OFFSET_TABLE_), EDX ) +#endif /* GLX_NO_TEXREL */ + INIT TEST_L ( CONST(4), EDI ) /* align rgba on an 8-byte boundary */ --- Mesa-6.5/src/mesa/x86/read_rgba_span_x86.S.orig 2006-06-21 19:01:08.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/read_rgba_span_x86.S 2006-06-21 19:04:59.000000000 +0000 @@ -75,6 +75,9 @@ * at the correct places. */ +#ifdef GLX_NO_TEXREL +.text +#endif /* GLX_NO_TEXREL */ .globl _generic_read_RGBA_span_BGRA8888_REV_MMX .hidden _generic_read_RGBA_span_BGRA8888_REV_MMX .type _generic_read_RGBA_span_BGRA8888_REV_MMX, @function @@ -84,8 +87,16 @@ #ifdef USE_INNER_EMMS emms #endif +#if defined(GLX_NO_TEXREL) && defined(__PIC__) +# undef __i686 /* gcc define gets in our way */ + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movq mask@GOTOFF, %mm1 + movq 16+mask@GOTOFF, %mm2 +#else movq mask, %mm1 movq mask+16, %mm2 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ movl 8(%esp), %ebx /* source pointer */ movl 16(%esp), %edx /* number of pixels to copy */ @@ -182,8 +193,15 @@ #ifdef USE_INNER_EMMS emms #endif +#if defined(GLX_NO_TEXREL) && defined(__PIC__) + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movq mask@GOTOFF, %mm1 + movq 16+mask@GOTOFF, %mm2 +#else movq mask, %mm1 movq mask+16, %mm2 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ movl 16(%esp), %ebx /* source pointer */ movl 24(%esp), %edx /* number of pixels to copy */ @@ -341,8 +359,15 @@ pushl %esi pushl %ebx +#if defined(GLX_NO_TEXREL) && defined(__PIC__) + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx + movdqa mask, %xmm1 + movdqa mask+16, %xmm2 +#else movdqa mask, %xmm1 movdqa mask+16, %xmm2 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ movl 12(%esp), %ebx /* source pointer */ movl 20(%esp), %edx /* number of pixels to copy */ @@ -521,18 +546,39 @@ .type _generic_read_RGBA_span_RGB565_MMX, @function _generic_read_RGBA_span_RGB565_MMX: +#ifdef GLX_NO_TEXREL + pushl %ebx +#endif /* GLX_NO_TEXREL */ #ifdef USE_INNER_EMMS emms #endif +#ifdef GLX_NO_TEXREL +#ifdef __PIC__ + call __i686.get_pc_thunk.bx + addl $_GLOBAL_OFFSET_TABLE_, %ebx +#endif /* __PIC__ */ + + movl 8(%esp), %eax /* source pointer */ + movl 12(%esp), %edx /* destination pointer */ + movl 16(%esp), %ecx /* number of pixels to copy */ +#else + movl 4(%esp), %eax /* source pointer */ movl 8(%esp), %edx /* destination pointer */ movl 12(%esp), %ecx /* number of pixels to copy */ +#endif /* GLX_NO_TEXREL */ +#if defined(GLX_NO_TEXREL) && defined(__PIC__) + movq mask_565@GOTOFF, %mm5 + movq prescale@GOTOFF, %mm6 + movq scale@GOTOFF, %mm7 +#else movq mask_565, %mm5 movq prescale, %mm6 movq scale, %mm7 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ sarl $2, %ecx jle .L01 /* Bail early if the count is negative. */ @@ -581,8 +627,13 @@ /* Always set the alpha value to 0xff. */ +#if defined(GLX_NO_TEXREL) && defined(__PIC__) + por alpha@GOTOFF, %mm0 + por alpha@GOTOFF, %mm2 +#else por alpha, %mm0 por alpha, %mm2 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ /* Pack the 16-bit values to 8-bit values and store the converted @@ -609,8 +660,13 @@ pmulhuw %mm7, %mm0 pmulhuw %mm7, %mm2 +#if defined(GLX_NO_TEXREL) && defined(__PIC__) + por alpha@GOTOFF, %mm0 + por alpha@GOTOFF, %mm2 +#else por alpha, %mm0 por alpha, %mm2 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ packuswb %mm2, %mm0 @@ -625,8 +681,11 @@ /* At this point there can be at most 3 pixels left to process. If * there is either 2 or 3 left, process 2. */ - +#ifdef GLX_NO_TEXREL + movl 16(%esp), %ecx +#else movl 12(%esp), %ecx +#endif /* GLX_NO_TEXREL */ testl $0x02, %ecx je .L04 @@ -647,8 +706,13 @@ pmulhuw %mm7, %mm0 pmulhuw %mm7, %mm2 +#if defined(GLX_NO_TEXREL) && defined(__PIC__) + por alpha@GOTOFF, %mm0 + por alpha@GOTOFF, %mm2 +#else por alpha, %mm0 por alpha, %mm2 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ packuswb %mm2, %mm0 @@ -675,7 +739,11 @@ #endif pmulhuw %mm7, %mm0 +#if defined(GLX_NO_TEXREL) && defined(__PIC__) + por alpha@GOTOFF, %mm0 +#else por alpha, %mm0 +#endif /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ packuswb %mm0, %mm0 @@ -685,5 +753,20 @@ #ifdef USE_INNER_EMMS emms #endif + +#ifdef GLX_NO_TEXREL + popl %ebx + ret +#ifdef __PIC__ + .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits +.globl __i686.get_pc_thunk.bx + .hidden __i686.get_pc_thunk.bx + .type __i686.get_pc_thunk.bx,@function +__i686.get_pc_thunk.bx: + movl (%esp), %ebx + ret +#endif /* __PIC__ */ +#else ret +#endif /* GLX_NO_TEXREL */ #endif /* !defined(__DJGPP__) && !defined(__MINGW32__) */ --- Mesa-6.5/configs/linux-dri-x86.orig 2006-06-21 17:40:50.000000000 +0000 +++ Mesa-6.5/configs/linux-dri-x86 2006-06-21 17:41:05.000000000 +0000 @@ -5,7 +5,8 @@ CONFIG_NAME = linux-dri-x86 -# Unnecessary on x86, generally. +# Unnecessary on x86, unless hardening +# if hardening, add -DGLX_NO_TEXREL to DEFINES in linux-dri, and remove this. PIC_FLAGS = # Add -m32 to CFLAGS: --- Mesa-6.5/src/mesa/x86/mmx_blend.S.orig 2006-06-21 19:00:52.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/mmx_blend.S 2006-06-21 19:15:23.000000000 +0000 @@ -302,8 +302,13 @@ #define TAG(x) CONCAT(x,_min) #define LLTAG(x) LLBL2(x,_min) +#ifdef GLX_NO_TEXREL +#define INIT \ + MOVQ ( CONTENT(REGOFF(const_80@GOTOFF, EDX)), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#else #define INIT \ MOVQ ( CONTENT(const_80), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#endif /* GLX_NO_TEXREL */ #define MAIN( rgba, dest ) \ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\ @@ -326,8 +331,13 @@ #define TAG(x) CONCAT(x,_max) #define LLTAG(x) LLBL2(x,_max) +#ifdef GLX_NO_TEXREL +#define INIT \ + MOVQ ( CONTENT(REGOFF(const_80@GOTOFF, EDX)), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#else #define INIT \ MOVQ ( CONTENT(const_80), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#endif /* GLX_NO_TEXREL */ #define MAIN( rgba, dest ) \ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\ @@ -350,9 +360,15 @@ #define TAG(x) CONCAT(x,_modulate) #define LLTAG(x) LLBL2(x,_modulate) +#ifdef GLX_NO_TEXREL +#define INIT \ + PXOR ( MM0, MM0 ) /* 0x0000 | 0x0000 | 0x0000 | 0x0000 */ ;\ + MOVQ ( CONTENT(REGOFF(const_0080@GOTOFF, EDX)), MM7 ) /* 0x0080 | 0x0080 | 0x0080 | 0x0080 */ +#else #define INIT \ PXOR ( MM0, MM0 ) /* 0x0000 | 0x0000 | 0x0000 | 0x0000 */ ;\ MOVQ ( CONTENT(const_0080), MM7 ) /* 0x0080 | 0x0080 | 0x0080 | 0x0080 */ +#endif /* GLX_NO_TEXREL */ #define MAIN( rgba, dest ) \ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\