Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Neverwinter Nights "Failed to initialize graphics"
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
yanta
n00b
n00b


Joined: 14 Jun 2005
Posts: 12

PostPosted: Sun Jun 26, 2005 4:42 am    Post subject: Neverwinter Nights "Failed to initialize graphics" Reply with quote

All right, I've been fighting with this problem for weeks now and I'm admitting defeat. Help...

Neverwinter Nights will not start, glxgears crashes my X server, but direct rendering is enabled and OpenGL screensavers work great.

Chipset is S3 Unichrome. After struggling with both the Gentoo DRI how-to here and the Unichrome one here, as well as untold hours of reading posts in these forums like this one, I finally got direct rendering enabled (using the Unichrome via driver and the masked version of x11-drm that supports via on 2.6 kernels).

When I try to run NWN as a user (which honestly is the point of the entire exercise) I get grumpy silence:
Code:
 /opt/nwn $ ./nwn
__driCreateNewScreen - succeeded
libGL warning: 3D driver claims to not support visual 0x22
libGL warning: 3D driver claims to not support visual 0x23
libGL warning: 3D driver claims to not support visual 0x24
libGL warning: 3D driver claims to not support visual 0x25
Failed to initialize graphics.
 /opt/nwn $


If I run it as root I get the same thing only I can hear a tantalizingly familiar Neverwinter Nights "plink" sound when it dies.

I think there's still a driver or OpenGL problem of some sort, because running glxgears is a sure-fire way to turn X into a pile of quivering electrons. I get strange screen flicker, artifacts, and distortion, and I have no recourse but the old Ctrl-Alt-Backspace which puts me back to kdm's login screen. Before it completely degrades I can see that I'm getting fps in the 400-600 range -- not great but probably good enough.

AGP loads fine:
Code:
# dmesg |grep agp
Linux agpgart interface v0.100 (c) Dave Jones
agpgart: Detected VIA KM400/KM400A chipset
agpgart: Maximum main memory to use for agp memory: 380M
agpgart: AGP aperture is 64M @ 0xe0000000
agpgart: Found an AGP 3.5 compliant device at 0000:00:00.0.
agpgart: Device is in legacy mode, falling back to 2.x
agpgart: Putting AGP V2 device at 0000:00:00.0 into 4x mode
agpgart: Putting AGP V2 device at 0000:01:00.0 into 4x mode
#


DRM loads fine:
Code:
# dmesg |grep drm
[drm] Initialized drm 1.0.0 20040925
[drm] Initialized via 2.6.2 20050420 on minor 0: VIA Technologies, Inc. VT8378 [S3 UniChrome] Integrated Video
[drm] Used old pci detect: framebuffer loaded
#


Xorg is happy:
Code:
# grep render /var/log/Xorg.0.log
(II) VIA(0): direct rendering enabled


glxinfo is happy:
Code:
# glxinfo |grep render
direct rendering: Yes
OpenGL renderer string: Mesa DRI UniChrome (KM400) 20041215 x86/MMX+/3DNow!+/SSE
#


*Everything's* happy. It just doesn't work :(.

More troubleshooting info:

Full xorg.conf here
Full kernel config here
Full Xorg log here
Full glxinfo here
Output of lsmod here
Output of lspci here
Full dmesg here

Does anyone have any ideas? What have I missed? What should I try? I would VERY much like to get this game working, because it is the last holdout preventing the deletion of my Windows partition.

Thanks in advance...


Last edited by yanta on Mon Jun 27, 2005 4:30 am; edited 2 times in total
Back to top
View user's profile Send private message
gaminggeek
Apprentice
Apprentice


Joined: 13 Nov 2003
Posts: 231
Location: New Zealand

PostPosted: Sun Jun 26, 2005 5:17 am    Post subject: Reply with quote

you might find it easyer if you go out and find yourself a el-cheepo geforce 2 mx....
Back to top
View user's profile Send private message
yanta
n00b
n00b


Joined: 14 Jun 2005
Posts: 12

PostPosted: Mon Jun 27, 2005 4:28 am    Post subject: Neverwinter Nights "Failed to initialize graphics" Reply with quote

Success!!

After losing my ENTIRE weekend to this silly project I finally got everything working. I wanted to post what I did to assist others who might be fruitlessly Googling, trying to get their S3 Unichrome chipset working with DRI. I just ended up building EVERYTHING using the latest and greatest Mesa CVS version. Being that I've never used cvs before in my life, I'm pretty impressed with myself that it's working 8) .

First, I ended up disregarding both HOW-TOs I linked to above. They both got me in trouble, and I think my strange results came from cherry-picking info out of both of them.

If you're smarter than me you can just follow the instructions here. I got scared off by the warning on the Gentoo HOWTO, and even when I got brave enough to try it I needed a whole day to fight through what applied to me and what didn't... I'll break everything down shotgun-style below for unichrome on x86 with kernel 2.6.11-gentoo-r11. If you have something different make appropriate substitutions. I'm by no means a gentoo guru -- all standard disclaimers apply.

Remove x11-drm if you've installed it (you don't need it).

Code:
#emerge -C x11-drm


If you've installed the unichrome_dri.so files from one of the other HOWTOs, delete it (you'll replace it with a good one later):

Code:
#rm /usr/lib/modules/dri/unichrome_dri.so


If you don't have cvs installed, install it:

Code:
#emerge cvs


Make sure you've got AGP and the VIA chipset built as modules in your kernel (if you don't, obviously you need to recompile your kernel and install it before you reboot at the end):

Code:
Device Drivers  --->
  Character devices  --->
    <M> /dev/agpgart (AGP Support)
    <M> VIA chipset support


Create a directory into which you'll dump the cvs sources and change into it:

Code:
#mkdir /usr/src/DRM; cd /usr/src/DRM


Using cvs, download the X.org, DRM, and Mesa sources (~340MB):

Code:
#cvs -z3 -d:pserver:anoncvs@cvs.freedesktop.org:/cvs/xorg co xc
#cvs -z3 -d:pserver:anonymous@cvs.freedesktop.org:/cvs/dri co drm
#cvs -z3 -d:pserver:anonymous@cvs.freedesktop.org:/cvs/mesa co Mesa


Get the config file to restrict the X build to just what you need:

Code:
#cd /usr/src/DRM/xc/config/cf; wget http://freedesktop.org/~fxkuehl/host.def


Open the config file with your favorite editor, find the line that says "#define XF86CardDrivers", and delete everything but "via". Then you need to patch your X.org source:

Code:
#cd /usr/src/DRM/xc; wget http://freedesktop.org/~fxkuehl/buildtools.patch
#patch -p0 < buildtools.patch


Start X compiling and go for a run, take a shower, and get some lunch. It'll be a while.

Code:
#make World 2>&1 | tee world.log


Once it's done, install your shiny new binaries over the top of your existing X.org (aieeee...scary...back up your /usr/X11R6/lib/modules first):

Code:
#make install
#ldconfig


3D drivers are next. Change to the Mesa config directory:

Code:
#cd /usr/src/DRM/Mesa/configs


There you will find a file called "linux-dri-x86". Open it and add the following lines to the bottom:

Code:
SRC_DIRS = mesa
DRI_DIRS = dri_client unichrome


Build the 3d driver (it goes fast):

Code:
#make linux-dri-x86


Install the 3D driver:

Code:
#cp /usr/src/DRM/Mesa/lib/unichrome_dri.so /usr/X11R6/lib/modules/dri/


Finally, you need to build the DRM modules.

Code:
#cd /usr/src/DRM/drm/linux-core
#make DRM_MODULES="via"


Install the DRM modules:

Code:
#cp via.ko /lib/modules/2.6.11-gentoo-r11/kernel/drivers/char/drm/
#cp drm.ko /lib/modules/2.6.11-gentoo-r11/kernel/drivers/char/drm/


Almost done! Edit /etc/modules.autoload.d/kernel-2.6 and put these four modules in IN ORDER (this took me forever to figure out :(...told you I was dumb):

Code:
agpgart
via-agp
via
drm


Cross your fingers and reboot. It *should* work now.

Good luck! If anyone sees any errors, please point them out. Hope this helps someone.

Even though it's pretty much bedtime on Sunday, I'm going to play some Neverwinter Nights! Ha ha!!
Back to top
View user's profile Send private message
pulzed
n00b
n00b


Joined: 19 May 2005
Posts: 20

PostPosted: Tue Jun 28, 2005 12:07 am    Post subject: Reply with quote

Thanks for the howto man!! :) Will definatly try this soon,,,
Back to top
View user's profile Send private message
leo.fontenelle
Tux's lil' helper
Tux's lil' helper


Joined: 29 May 2005
Posts: 129
Location: Ribeirão Preto, Brasil

PostPosted: Wed Jul 06, 2005 2:36 am    Post subject: Almost ok... Reply with quote

I did things like above, but not everything is ok. I'm posting this in hope that someone can interpret this data:

  • From /var/log/Xorg.0.log:
    Code:
    (--) PCI:*(1:0:0) unknown vendor (0x1106) unknown chipset (0x7205) rev 1, Mem @
    0xe4000000/26, 0xe8000000/24

    [...]

    (II) VIA: driver for VIA chipsets: CLE266, KM400/KN400, K8M800,
            PM800/PM880/CN400
    (II) Primary Device is: PCI 01:00:0
    (--) Assigning device section with no busID to primary device
    (--) Chipset KM400/KN400 found
    (!!) VIA Technologies does not support or endorse this driver in any way.
    (!!) For support please contact the driver maintainer or your X vendor.
    (II) resource ranges after xf86ClaimFixedResources() call:
            [0] -1  0       0xffe00000 - 0xffffffff (0x200000) MX[B](B)
            [1] -1  0       0x00100000 - 0x3fffffff (0x3ff00000) MX[B]E(B)
            [2] -1  0       0x000f0000 - 0x000fffff (0x10000) MX[B]
            [3] -1  0       0x000c0000 - 0x000effff (0x30000) MX[B]
            [4] -1  0       0x00000000 - 0x0009ffff (0xa0000) MX[B]
            [5] -1  0       0xea001000 - 0xea0010f0 (0xf1) MX[B]
            [6] -1  0       0xea000000 - 0xea0000f0 (0xf1) MX[B]
            [7] -1  0       0xe0000000 - 0xdfffffff (0x0) MX[B]O
            [8] -1  0       0xe8000000 - 0xe8fffff0 (0xfffff1) MX[B](B)
            [9] -1  0       0xe4000000 - 0xe8000000 (0x4000001) MX[B](B)
            [10] -1 0       0x0000ffff - 0x0000ffff (0x1) IX[B]
            [11] -1 0       0x00000000 - 0x000000ff (0x100) IX[B]
            [12] -1 0       0x0000e800 - 0x0000e900 (0x101) IX[B]
            [13] -1 0       0x0000e000 - 0x0000e100 (0x101) IX[B]
            [14] -1 0       0x0000dc00 - 0x0000dc10 (0x11) IX[B]
            [15] -1 0       0x0000d800 - 0x0000d820 (0x21) IX[B]
            [16] -1 0       0x0000d400 - 0x0000d420 (0x21) IX[B]
            [17] -1 0       0x0000d000 - 0x0000d020 (0x21) IX[B]
    (WW) ****INVALID MEM ALLOCATION**** b: 0xe4000000 e: 0xe8000000 correcting

    The last line is part of the output in the console when I call startx. I can't say much about what I see, since I'm still compiling KDE. But I get no twm, no xterm, just standard mouse cursor with a big black background; when I move the the mouse around, the cursor moves very oddly, and becomes something like an ugly square black&white icon representing a 3-button mouse with the right button pressed.
    Could it be the version I grabbed from CVS? The output is version 6.8.99.14.

  • I guess the kernel part is ok, but "direct rendering" and "glx" are complaining:

    Code:
    $ dmesg |grep agp
    Linux agpgart interface v0.100 (c) Dave Jones
    agpgart: Detected VIA KM400/KM400A chipset
    agpgart: Maximum main memory to use for agp memory: 380M
    agpgart: AGP aperture is 64M @ 0xe0000000

    $ dmesg |grep drm
    [drm] Initialized drm 1.0.0 20040925
    [drm] Initialized via 2.6.3 20050523 on minor 0: VIA Technologies, Inc. VT8378 [S3 UniChrome] Integrated Video

    $ grep render /var/log/Xorg.0.log
    (II) VIA(0): direct rendering disabled

    $ glxinfo |grep render
    Error: unable to open display (null)


    I believe I got bad luck about the specific version from CVS, but I can't suspect what to download later: xc? Mesa? DRM??
Back to top
View user's profile Send private message
leo.fontenelle
Tux's lil' helper
Tux's lil' helper


Joined: 29 May 2005
Posts: 129
Location: Ribeirão Preto, Brasil

PostPosted: Wed Jul 06, 2005 3:30 pm    Post subject: Update Reply with quote

Update Finished emerging KDE. Now I see all KDE, and the mouse cursor is beautifull. But the cursor still moves oddly. I believe my configuration is correct for a three-buttons wheel PS/2 mouse, I'm just
posting just in case:
Code:

$ zgrep MOUSE /proc/config
CONFIG_INPUT_MOUSEDEV=y
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
CONFIG_INPUT_MOUSE=y
CONFIG_MOUSE_PS2=y
# CONFIG_MOUSE_SERIAL is not set
# CONFIG_MOUSE_VSXXXAA is not set
# CONFIG_USB_MOUSE is not set
# CONFIG_USB_IDMOUSE is not set

$ cat /etc/X11/xorg.conf
[...]
Section "InputDevice"
    Identifier "Mouse1"
    Driver     "mouse"
    Option     "Protocol"      "IntelliMouse"
    Option     "Device"        "/dev/input/mouse0"
    Option     "Buttons"      "5"
    Option     "ZAxisMapping" "4 5"
    Option     "Resolution"   "400"
EndSection
[...]
Back to top
View user's profile Send private message
yanta
n00b
n00b


Joined: 14 Jun 2005
Posts: 12

PostPosted: Fri Jul 08, 2005 3:42 am    Post subject: Reply with quote

Do make sure you're loading DRI and GLX in your xorg.conf and you've got the DRI permissions set.

In the "Modules" section at the top, make sure you've got the following lines uncommented:

Code:
Load   "glx"
Load   "dri"


Also tack these three lines onto the very end of your xorg.conf:

Code:
Section "dri"
   Mode 0666
EndSection


Don't know what to tell you about the mouse. Here's mine:


Code:
Section "InputDevice"

# Identifier and driver

    Identifier  "Mouse1"
    Driver      "mouse"
    Option "Protocol"    "ExplorerPS/2"
    Option "Device"      "/dev/psaux"
    Option "Buttons"     "5"
    Option "ZAxisMapping" "4 5"   
    ...
    Option "Emulate3Buttons"
    ...
EndSection


Good luck!
Back to top
View user's profile Send private message
leo.fontenelle
Tux's lil' helper
Tux's lil' helper


Joined: 29 May 2005
Posts: 129
Location: Ribeirão Preto, Brasil

PostPosted: Sat Jul 09, 2005 11:40 pm    Post subject: It worked! Reply with quote

Silly me... :roll:

Yes, I forgot to enable glx and dri in xorg.conf! The consoles-changing problem got fixed too. And, by the way, even the mouse was misconfigured, it's an explorer ps/2, not intellimouse.

Just a detail... Until this post I had switched back to regular xorg-x11; then I made the cvs Xorg again, and when I restarted things looked a lot larger, without changing resolution or KDE's configs. KDE's panel is the same size, and konsole's console font too, but KDE's splash, titlebar+menu fonts etc are larger.
Back to top
View user's profile Send private message
yanta
n00b
n00b


Joined: 14 Jun 2005
Posts: 12

PostPosted: Wed Aug 10, 2005 10:15 pm    Post subject: update Reply with quote

Rebuilding after a crash, I have discovered that the current CVS is a little freaky so the above instructions probably don't work.

When building the 3D Mesa driver, you now need to add THREE lines to the linux-dri-x86 config file:

Code:
SRC_DIRS = mesa
USING_EGL=0
DRI_DIRS = dri_client unichrome


If you don't want glxgears to seg fault you need to apply the patch here to /usr/src/DRM/Mesa/src/mesa/drivers/dri/common/utils.c. Just create a text file, copy the patch into it, and then type

Code:
patch <yourfilename>


You also have to be in the cd /usr/src/DRM/Mesa directory in order to build it now.

Lastly, a new security patch for the DRM modules has an undefined something somewhere (I'm not a programmer so I couldn't possibly guess what the problem is). I couldn't get the 10 Aug 05 CVS to build but if you REMOVE the changes specified in the patch here it will work. To remove the changes, change to /usr/src/DRM/drm, edit the linux-core/drmP.h, linux-core/drm_context.c, and shared-core/via_mm.c files. DELETE the lines in your files that have + signs in front of them in the patch. Hopefully the CVS will get fixed and this won't be necessary anymore, but it cost me a whole day today...
Back to top
View user's profile Send private message
jgaffney
Apprentice
Apprentice


Joined: 22 Dec 2004
Posts: 165

PostPosted: Wed Aug 24, 2005 12:59 am    Post subject: Reply with quote

OK, I'm attempting to get his to work, but I'm stuck trying to make the linux-dri-x86 file.

Code:

root@gaffmasterG2 Mesa # make linux-dri-x86
(cd configs && rm -f current && ln -s linux-dri-x86 current)
make default
make[1]: Entering directory `/usr/src/DRM/Mesa'
make[2]: Entering directory `/usr/src/DRM/Mesa/src'
Making sources for linux-dri-x86
make[2]: Leaving directory `/usr/src/DRM/Mesa/src'
make[2]: Entering directory `/usr/src/DRM/Mesa/progs'
Making programs for linux-dri-x86
make[2]: Leaving directory `/usr/src/DRM/Mesa/progs'
make[1]: Leaving directory `/usr/src/DRM/Mesa'

root@gaffmasterG2 Mesa # cp /usr/src/DRM/Mesa/lib/unichrome_dri.so /usr/X11R6/lib/modules/dri/
cp: cannot stat `/usr/src/DRM/Mesa/lib/unichrome_dri.so': No such file or directory
root@gaffmasterG2 Mesa #


The /usr/src/DRM/Mesa/lib/ directory apears to be empty, I must have missed something?


Hmmm, maybe something wrong with my host.def file. Here is what I have. A bit confused on if I should remove "Everything" but via or the way I have it?

Code:

#define XFree86CustomVersion "Minimal DRI build from X.org tree"

/* Compiler options */
#define DefaultGcc2i386Opt -O2 -gstabs+ -pipe

/* DDX drivers to build: trim this list to your needs */
#define XF86CardDrivers via

/* DRI drivers are built from Mesa CVS */
#define DriDrivers /**/
#define DevelDRIDrivers /**/

/* Build development (insecure) DRI-aware 2D drivers */
#define BuildDevelDRIDrivers YES

/* Only shared libGL */
#define NormalLibGlx NO

/* Link the drivers against static libexpat to make binary snapshots

[/code]
Back to top
View user's profile Send private message
yanta
n00b
n00b


Joined: 14 Jun 2005
Posts: 12

PostPosted: Tue Sep 20, 2005 11:04 pm    Post subject: Reply with quote

Sorry, I've been out of town. For anyone else having the same problem:

Your hosts.def has to do with the Xorg build; it looks like you're having problems with the 3D driver.

There should be a file in /usr/src/DRM/Mesa/configs called "linux-dri-x86". You need to add the following three lines to the end of this file:

Code:
SRC_DIRS = mesa
USING_EGL=0
DRI_DIRS = dri_client unichrome


I think the last line is what actually makes the driver get built. Remember to change to the /usr/src/DRM/Mesa directory before trying to build it.

Good luck!
Back to top
View user's profile Send private message
yanta
n00b
n00b


Joined: 14 Jun 2005
Posts: 12

PostPosted: Wed Sep 21, 2005 1:59 am    Post subject: Reply with quote

Ack! More changes! This is what comes of using the cvs, I guess.

Now, to get the 3D driver to compile, you must first compile libdrm. So, to change (yet again) the instructions above, execute the following commands AFTER you compile Xorg and BEFORE you compile the 3D driver:

Code:
#cd /usr/src/DRM/drm
#./autogen.sh
#make install
#export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH


The best guide to building DRI is still here, and after doing this enough times I can almost understand it...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum