2008/07/09

WMU-6500FS - Mesa 7.0.3



Following image demonstrates the Mesa 3d application running on the box. As can be seen from FPS, there is no HW acceleration :-)



Build results (library): [binary] [files list]
Build results (demos): [binary] [files list]
Info sources: [Home page] [MesaLib dependencies]
Related info: [Xming notes] [Remote desktop for linux] [Compiling Mesa fbdev/DRI drivers without X installed]

For now we try to compile the stand-alone/Xlib mode (no Hardware acceleration necessary ;-)

Dependencies: [file 4.24] [Xorg libraries]

First we have to download and extract the libraries and related stuff:
dev# cd /usr/local/src
dev# wget "http://downloads.sourceforge.net/mesa3d/MesaLib-7.0.3.tar.bz2?modtime=1207336858&big_mirror=0"
dev# tar xjvf MesaLib-7.0.3.tar.bz2
dev# wget "http://downloads.sourceforge.net/mesa3d/MesaDemos-7.0.3.tar.bz2?modtime=1207336927&big_mirror=0"
dev# tar xjvf MesaDemos-7.0.3.tar.bz2
dev# wget "http://downloads.sourceforge.net/mesa3d/MesaGLUT-7.0.3.tar.bz2?modtime=1207336986&big_mirror=0"
dev# tar xjvf MesaGLUT-7.0.3.tar.bz2 
dev# cd Mesa-7.0.3
Now it is necessary to modify the configuration files, we have to replace the following two paths in the configs/linux:
dev# nano configs/linux

#X11_INCLUDES = -I/usr/X11R6/include
X11_INCLUDES = -I/mnt/C/sys/X11/include

#EXTRA_LIB_PATH = -L/usr/X11R6/lib
EXTRA_LIB_PATH = -L/mnt/C/sys/X11/lib
Also we have to alter the installation paths int the configs/default:
dev# nano configs/default

#INSTALL_DIR = /usr/local
INSTALL_DIR = /mnt/C/sys/X11

#DRI_DRIVER_INSTALL_DIR = /usr/X11R6/lib/modules/dri
DRI_DRIVER_INSTALL_DIR = /mnt/C/sys/X11/lib/modules/dri
No we are ready build:
dev# make linux-x86
...
../../lib/libGL.so: undefined reference to `posix_memalign'
collect2: ld returned 1 exit status
Regarding to this forum topic the posix_memalign is currently not implemented in uClibc so we have to disable it.
So let's back to the configuration file:
dev# nano configs/linux

DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
        -D_BSD_SOURCE -D_GNU_SOURCE \
        -DPTHREADS -DUSE_XSHM
# -DHAVE_POSIX_MEMALIGN
Now we try the build...
dev# make linux-x86
... and it completed successfully.

We are ready to start testing some demo apps, we try the notorious gears application:
#dev /mnt/C/sys/bin/mesa-demos/gears
If you get an error message similar to this:
Error: Can't open display:
... you probably did not configured the DISPLAY environment variable properly. For a hint how to do that see the X client/server configuration.

We have now the X client/server properly configured, gears test passed with no problems, we are ready to deploy on the box.
Curiously on the box we observe the following crash:
box# /mnt/C/sys/bin/mesa-demos/gears
Illegal instruction
To get to the heart of the matter we have to digg little deeper, however we need a tool for it. Let's try JoKeR's built version of gdb. For now we are going to debug directly at the box, later on we look at the remote debugging.
box# gdb /mnt/C/sys/bin/mesa-demos/gears
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux-uclibc"...Using host libthread_db library "/mnt/C/sys/lib/libthread_db.so.1".

(gdb) run
Starting program: /tmp/mnt/C/sys/bin/mesa-demos/gears
warning: Cannot initialize thread debugging library: generic error


Program received signal SIGILL, Illegal instruction.
_mesa_x86_cpuid () at x86/common_x86_asm.S:80
80      x86/common_x86_asm.S: No such file or directory.
        in x86/common_x86_asm.S
Current language:  auto; currently asm
(gdb) backtrace
#0  _mesa_x86_cpuid () at x86/common_x86_asm.S:80
#1  0x403053f0 in ?? () from /mnt/C/sys/lib/libGL.so.1
#2  0x4031f980 in quad_tab () from /mnt/C/sys/lib/libGL.so.1
#3  0x4021c24a in _mesa_init_all_x86_transform_asm () at x86/common_x86.c:180
#4  0x4016a17d in _math_init_transformation () at math/m_xform.c:214
#5  0x4016a19a in _math_init () at math/m_xform.c:227
#6  0x400e8674 in one_time_init (ctx=0x8056b38) at main/context.c:368
#7  0x400e75e1 in _mesa_initialize_context (ctx=0x8056b38, visual=0x8054688,
    share_list=0x0, driverFunctions=0xbffff6c0, driverContext=0x0) at main/context.c:1067
#8  0x4026f92b in XMesaCreateContext (v=0x8054688, share_list=0x0)
    at drivers/x11/xm_api.c:1504
#9  0x4026c234 in Fake_glXCreateContext (dpy=0x804cfa0, visinfo=0x8056900,
    share_list=0x0, direct=1) at drivers/x11/fakeglx.c:1401
#10 0x4026a46d in glXCreateContext (dpy=0x804cfa0, visinfo=0x8056900, shareList=0x0,
    direct=1) at drivers/x11/glxapi.c:188
#11 0x40020d22 in __glutCreateWindow (parent=0x0, x=0, y=0, width=300,
    height=1073998032, gameMode=0) at glut_win.c:609
#12 0x40020df3 in glutCreateWindow (title=0x804ae60 "Gears") at glut_win.c:731
#13 0x0804902e in main (argc=1, argv=0xbffffbc4) at gears.c:370
(gdb)
Ok, it seems promising, now we can look at the file in question:
dev# less /usr/local/src/Mesa-7.0.3/src/mesa/x86/common_x86_asm.S
... or we can look for example here on the web. At the line 80 we see the CPUID instruction:
...
76 :  MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
77 :  PUSH_L (EDI)
78 :  PUSH_L (EBX)
79 :  
80 :  CPUID
81 :  
82 :  MOV_L (REGOFF(16, ESP), EDI) /* *eax */
83 :  MOV_L (EAX, REGIND(EDI))
...
At the CPUID instruction description we can see what exactly the this instruction means and when it was introduced.
The following way we can find out the exact info about the CPU in the box:
box# cat /proc/cpuinfo
processor       : 0
vendor_id       : CyrixInstead
cpu family      : 4
model           : 1
model name      : Cx486SLC
stepping        : unknown
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : no
fpu_exception   : no
cpuid level     : -1
wp              : yes
flags           :
bogomips        : 44.33
In the document Application Note112 CyrixCPU Detection Guide I have found the following info:
The Cx486SLC, Cx486DLC, Cx486SRx2, Cx486DRx2, Cx486S, Cx486DX, Cx486DX2, and 5x86 processors do not recognize the CPUID instruction and must be identified using the DIR0 and DIR1 register.
So the cause of the problem is found. There is no support of certain instructions on the box and so we cannot be sure the code we built on the PC will run.
In the configuration file configs/linux-x86 we can see following ASM related switches:
ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
In order not to use ASM implementations we can use linux configuration instead of linux-x86:
dev# make realclean
dev# make linux
Everything seem to be working now :-)

No comments: