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 16:27:47.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/glapi_x86.S 2006-06-21 16:40:35.000000000 +0000 @@ -61,7 +61,11 @@ ALIGNTEXT16; \ GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ GL_PREFIX(fn, fn_alt): \ - CALL(_x86_get_dispatch) ; \ +#ifdef GLX_NO_TEXREL + CALL(GL_PREFIX(get_dispatchbase, get_dispatchbase)) ;\ +#else + MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ +#fi NOP ; \ JMP(GL_OFFSET(off)) @@ -70,7 +74,11 @@ ALIGNTEXT16; \ GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ GL_PREFIX(fn, fn_alt): \ - MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ +#ifdef GLX_NO_TEXREL + CALL(GL_PREFIX(get_dispatchbase, get_dispatchbase)) ;\ +#else + MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ +#fi TEST_L(EAX, EAX) ; \ JE(1f) ; \ JMP(GL_OFFSET(off)) ; \ @@ -81,7 +89,11 @@ ALIGNTEXT16; \ GLOBL_FN(GL_PREFIX(fn, fn_alt)); \ GL_PREFIX(fn, fn_alt): \ - MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ +#ifdef GLX_NO_TEXREL + CALL(GL_PREFIX(get_dispatchbase, get_dispatchbase)) ;\ +#else + MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \ +#fi TEST_L(EAX, EAX) ; \ JE(1f) ; \ JMP(GL_OFFSET(off)) ; \ @@ -92,7 +104,7 @@ 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)) ;\ JMP(GL_OFFSET(off)) #endif @@ -107,6 +119,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 + #ifdef GLX_USE_TLS GLOBL GLNAME(_x86_get_dispatch) @@ -123,9 +145,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 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 ADD_L(CONST(28), ESP) RET #elif defined(THREADS) --- Mesa-6.5/src/mesa/x86/mmx_blend.S.orig 2006-06-21 16:40:52.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/mmx_blend.S 2006-06-21 16:44:00.000000000 +0000 @@ -303,7 +303,11 @@ #define LLTAG(x) LLBL2(x,_min) #define INIT \ +#ifdef GLX_NO_TEXREL + MOVQ ( CONTENT(REGOFF(const_80@GOTOFF, EDX)), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#else MOVQ ( CONTENT(const_80), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#endif #define MAIN( rgba, dest ) \ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\ @@ -327,7 +331,11 @@ #define LLTAG(x) LLBL2(x,_max) #define INIT \ +#ifdef GLX_NO_TEXREL + MOVQ ( CONTENT(REGOFF(const_80@GOTOFF, EDX)), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#else MOVQ ( CONTENT(const_80), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/ +#endif #define MAIN( rgba, dest ) \ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\ @@ -352,7 +360,11 @@ #define INIT \ PXOR ( MM0, MM0 ) /* 0x0000 | 0x0000 | 0x0000 | 0x0000 */ ;\ +#ifdef GLX_NO_TEXREL + MOVQ ( CONTENT(REGOFF(const_0080@GOTOFF, EDX)), MM7 ) /* 0x0080 | 0x0080 | 0x0080 | 0x0080 */ +#else MOVQ ( CONTENT(const_0080), MM7 ) /* 0x0080 | 0x0080 | 0x0080 | 0x0080 */ +#endif #define MAIN( rgba, dest ) \ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\ --- Mesa-6.5/src/mesa/x86/mmx_blendtmp.h.orig 2006-06-21 16:45:57.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/mmx_blendtmp.h 2006-06-21 16:48:11.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 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 + 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 16:48:44.000000000 +0000 +++ Mesa-6.5/src/mesa/x86/read_rgba_span_x86.S 2006-06-21 17:22:04.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 /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ movq mask, %mm1 movq mask+16, %mm2 +#endif 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,37 @@ .type _generic_read_RGBA_span_RGB565_MMX, @function _generic_read_RGBA_span_RGB565_MMX: + pushl %ebx #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 +625,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 +658,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 +679,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 +704,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 +#fi /* defined(GLX_NO_TEXREL) && defined(__PIC__) */ packuswb %mm2, %mm0 @@ -675,7 +737,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 +751,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: