Carmack On 3D Linux 71
Gaza wrote in to send us
an Essay written by John Carmack to
help in making GL drivers
for Linux. Its kinda techie stuff, but its still
interesting.
A Fortran compiler is the hobgoblin of little minis.
Xshm and Xdga (Score:1)
Xdga allows for direct graphics access to a video card's frame buffer. This has been around
since Xfree86 3.2 or so and is used for things like XawTV, etc. A write-up can be found
here [ucsd.edu].
Re:"Kind of techie stuff" (Score:1)
Office 97 will run happily on a P-100 with 64 MB of RAM. Office 2k, on the other hand, will want my K6-III 500 (I know you said "K6-2 450," but I have a K6-III 500).
Games are almost always FIRST to stretch the hardware boundaries and all that advancement and innovation we love, but the rest of the industry eventually realises "hey, there are, like, a squillion people with massively powerful boxes, let's see if we can tax them as much as these games do!" Thus, the proliferation of "features" (I'm pretty sure I don't know about half the features in Office97, nor will I ever likely use them).
Enough for now.
The problem is... (Score:1)
Writing for the TNT may be easy, but one can't get away with just supporting the TNT.
Maybe using built-in support for the TNT (and other well-supported cards) and using fbcon/svgalib/X for everyone else would work, though... .
makes sense to me... (Score:1)
Re:Direct rendering + GLX (Score:1)
GLX allows _non-local_ X Clients to send OpenGL commands to the X server. i.e. a client running on
somewhere.else.net can send OpenGL drawing instructions to your X server on your.host.net -
thus allowing HW accelerated functions of the gfx card on my.host.net to be used by a program running on somewhere.else.net to display on my.host.net.
Of course, if the server isn't running on a computer with hw-accelerated 3D, GLX can still be used. There's already a glx module for XFree86 that just passes all GLX stuff to Mesa. It worked fine for me.
This is much wider reaching than "simply" hw-accelerating direct-rendering to a window.
Incidentally, you can already get Mesa running on top of Glide to do this, by using a dodgy copy-3d-buffer-mem-to-window hack.
PI are also laying down a standard implementation for adding HW 3D accel to X, for any 3D card, which is what you're talking about. However, a lot of the first generation 3D cards don't "officialy" support rendering to anything but full screen (thus necessitating dogy hacks), whereas the X-Server/Client paradigm really should support 3D-accelerated rendering to windows too. Of course, the DGA extension (analogous to, though not the same as, DirectX (which is _not_ Direct3D, which is Microsoft doing their utmost to kill OpenGL)) may well be built upon to allow fullscreen mode 3D-accelerated rendering.
VMware and UAE both need DGA for optimum performance.
Re:makes sense to me... (Score:1)
Suppose an app that wants to switch its display frames synchronously with the vertical retrace. Well, on the PC you won't have to suppose much, because we can only switch frames during the vertical retrace. whatever.
So suppose this app is using double buffering. It renders one buffer while the other one is being shown on screen. when it's done, you want to switch buffers. but the switch cannot occur before the vertical retrace - so you have one buffer that is completely rendered and the other one that you cannot use yet because it is still being shown on-screen.
if your screen shows 60 frames per second but you can only render 59 frames per second, with double buffering you will only be able to show 30 frames per second - you take just a bit more that a frame delay to render a buffer, and then you have to wait till the start of the next frame. with triple buffering, you will be able to display your 59 frames per second.
To bring up another point (Score:4)
While this is great for doing things over a network, it limits performance, especially performance where huge chunks of data must be thrown around (like in higher resolutions/depth) on the local machine.
UNIX (LOCAL) sockets speed this up by about 100% (or more or less, depending on the implementation), but it's still fundamentally flawed.
Each write to the X Server must involve the kernel's interaction. This introduces more overhead than it probably ever should. Especially if you want excessively high performance.
It's a simple fact. While the X Server remains a seperate process that can only be updated via a local socket, performance will be gated.
I'm not an expert on The X Window System, so I really don't know what a viable solution would entail. I'm just throwing this out: What if we were to make an extension to Xlib that would ask the X Server if it would allow the Xclient to mmap part of the framebuffer (it's client area) or just mmap the entire thing? All subsequent Xlib calls would write to the framebuffer.
This introduces a whole mess of issues, but we need to do SOMETHING. Anyone want to open up discussion? or tell me how wrong I am?
--Michael Bacarella
Re:Can be faster in some situations (Score:1)
take a look at http://finger.planetquake.com/plan.asp?userid=joh
(The entry from 9/10/98)
I'm not saying that it would be impossible to do, but it is probably not that easy to do.
oh.. and shared memory is probably faster than unix domain sockets.
/Andreas
Re:speed solution? (Score:1)
/Andreas
Re:Oooh TNT2 (Score:1)
If 3d support under Linux is a must I'd wait with the G400 until I heard that the specs for the 3d part was released. (Or until matrox releases a working OpenGL driver for XFree86, whichever comes first...
Keep in mind that the specs for the G200 was released half a year after the card appeared in shops. In the 3d accelerator market half a year is a very long time... but on the other hand.. matrox did release the specs, let us hope that they continue to do that.
/AE
/dev/fb (Score:1)
If you are using for example matroxfb you can change resolution of the console at will.
/Andreas
Re:The problem is... (Score:2)
Re:It already exists (Score:1)
Anyway, regarding X in general, I know that the XFree guys were asking for more people to help with their project in general -- I understand that 4.0 is pretty far behind where they'd like to be..
If I knew more about graphics, I'd probably try and help, but it's not my strong suit..
Re:Can be faster in some situations (Score:1)
Re:3d graphics with RIVA TNT AGP card? (Score:1)
Berkeley is spelled "Berkeley", not "Berkely".
It says "only two products". If you believe that, it's very funny!
"Kind of techie stuff" (Score:2)
I mean, we have to take the occassional break from making fun of Bill "Richboy" Gates and beating up on Jesse Berst to still do geek-type stuff on occassion, don't we? I'd think so.
Now that I'm done abusing Rob (for now), here's my constructive observation:
I've always argued that games were vital to Linux because of the user base and notoriety that they bring, as well as enhancing my ability to kill time at the office. This article, however, point out another big advantage that I hadn't really considered before: Linux games spur technical enhancements.
I feel stupid for now adding this to my list of "Why I like games" before, but it's up there next to number one right now. Hey, you could even argue that games are what drive us to get better and better computers: I mean, who needs a 450Mhz k6-2 to run Word Perfect or that other word processor from those guys in Washington?
----
KGIcon (Score:1)
Find out yourself. (Score:1)
More stories like this!!! (Score:2)
We need more stories like this on /., instead of all the World Dominion fluff and mindless flaming.
TedC
Re:To bring up another point (Score:1)
Re:To bring up another point (Score:3)
You're too late, it's already been done. It's called DGA (Direct Graphics Access) and has been part of modern X servers for a while now. With a DGA application you get *equal* performance when compared to FB or SVGALIB.
The obvious examples of well written DGA apps include XMAME and SNES9X.
DGA even works exactly like you suggested. It lets you mmap the framebuffer.
The MITSHM solution others have pointed to is simply not good enough. You still get bogged down in the X socket, so there are a couple of wasted copies involved, and performance degrades fairly noticeably. DGA is the better solution.
Please be careful to know that though sockets are "fundamentally flawed" (in that sockets are always going to reduce performance), the concept of X isn't fundamentally flawed. SGI uses mmap'd ring buffers for local clients, avoiding all the issues with system call overhead. SGI manages to retain the benefits of the X abstraction without sacrificing performance. They just used cleverer X-server code.
Remember that all good systems will sacrifice some speed for a good abstraction. Even Linux is guilty of sacrificing that extra 10% performance to keep the nice UNIX abstraction. X is a really nice abstraction, so don't blame it for losing a few percentile points of performance.
Also, the XFree86 team could really do with a lot more coders. X is easily as complicated as a UNIX kernel, if not more so, but they have a lot fewer people working on XFree86 than work on the Linux kernel! There are a lot of very cool ideas that X can do - stuff invented by SGI - that the XFree86 group would like to do, but without good coders these ideas will never be implemented. If you want a real project to get your teeth into then XFree86 is challenging: drivers aren't the only things XFree86 members work on! And, if you really like 3D stuff and OpenGL, then now is the right time to help work on XFree86!
Re:Q3 and 3D in Linux (Score:1)
Re:It already exists (Score:1)
To me it sounds like this situation is one in which the user is going to be focused pretty heavily on what this program is generating. In this case, you don't really want other windows onscreen, so it's not just the overhead of X you don't want, it's also the functionality.
OpenGL boards (Score:2)
3DLabs has a variety of much newer, more powerful boards you can learn about at their website [3dlabs.com]. I'm sure some other people make GL boards -- Gloria comes to mind. All $$$$!
Under Linux you can use GL on your Voodoo1 ($30) or Voodoo2/Banshee ($80), supported thru Mesa (not as fast as it could be, since it's Mesa on top of Glide). Under Windoze, you can use 3Dfx's OpenGL ICD, which is really only a subset of GL implemented for Quake (and therefore not really any good for graphix work), and is also slo since it's going thru M$ function calls (yuck). Many other boards have GL ICD's for Windoze, and nVidia is supposed to be writing one for the TNT for Linux.
Re:To bring up another point (Score:1)
There are huge wins besides networking with getting all the graphics into it's own process and easily worth the overhead.
Re:makes sense to me... (Score:1)
- Thomas
Re:Wrong. (Score:2)
For 3D that's a different story. OpenGL does support something called a direct rendering context. This is a GLX context that has semantics that allow libGL.so to be implemented in a way that it talks directly to hardware. In any case I feel that it would be foolish to expose an API that allows talking to hardware to a programmer. It's way to complex and gives to much opprtunity to screw things up (not intentionally, but hey, show me a bugfree piece of HW). Having OpenGL there and let libGL.so do the talking to the hardware makes way more sence.
- Thomas
Re:OpenGL boards (Score:2)
1. 8mb ram
2. AGP
3. Linux support (2D/3D) -- not to mention one of the fastest 2D X servers around.
You can play q3a with it using the mlx/mesa modules, very cool. I got my card for 45 bucks. That's an accelgraphics permedia2 board.
--
speed solution? (Score:2)
--
Re:The problem is... (Score:1)
That is a valid point. Hopefully, however, we have a driver architecture flexible enough to work in client or server mode. Meaning that the driver can work in the X server for places where you still want to talk over a socket (AF_LOCAL or AF_INET) but can also talk directly to the card for special programs like Q3.
I don't think our graphics card architecture (XFree drivers, essentially) currently is even close to this, but I'm sure that someone will eventually make it work.
Re:It already exists (Score:2)
With modern video cards, this is completely reasonable. The TNT has channels that allow up to 127 programs to communicate directly with the hardware. IIRC, the privileged program (X server or kernel) creates a channel by specifying a clipping region and a 64k region of memory that the client can mmap(). The TNT (with help from the kernel - it needs an interrupt handler) the interraction between all these clients.
There are papers out there that describe how good graphics cards should be designed. A good graphics card allows for app->video with accelerated (2d and 3d) features. It is nice to see that these cards are starting to show up for ~$100.
Re:It already exists (Score:1)
app -> socket -> X -> video
X with shm is like this:
app -> X -> video
Note that there's still a context switch. This is Not A Good Thing. We need this:
app -> video
Thus we have svgalib, ggi, SDL, and so forth.
Re:3d graphics with RIVA TNT AGP card? (Score:1)
"Berzerkeley"...
Wrong. (Score:1)
Your idea about mmapping the framebuffer and allowing Xlib to deal with it directly is completely flawed, OTOH. First off, it disables use of hardware acceleration, which means performance would drop much more than using a Unix socket for communication with the X server. However, even if you have some sort of plugins for the Xlib which provice acceleration for specific cards, there would have to be a single semaphore for serializing access to the card's accelerator between different X clients.
People who designed X were not stupid and really, really experienced. X does have flaws, but not where you showed them.
Anyway, all of the above applies to "classical", 2D operation mode of X. Direct 3D rendering for games is something absolutely different, and your ideas, transformed to some point, are correct
Heck, Precision Insight had them half a year ago
Cheers,
-diskena
Re:To bring up another point (Score:1)
That sounds like it would solve some 2D problems, but not 3D, and not a more general class of 2D problems either.
It wouldn't solve 3D problems because the cards need access to your data to do the raster rendering themselves. It sounds like you're advocating mainly framebuffer access, which isn't enough for this kind of thing.
Also, a lot of programs would want access to the 2D acceleration features of a card, and this solution doesn't allow for that either.
Maybe some kind of special shared-memory only version of the X protocol that allowed you to refer to client resources by shared memory offset so the server could access them directly. This would allow you to do anything with the shared memory area that you could normally do with the X protocol.
I also may be talking out of my hat here because I don't know a huge amount about how X servers or graphics cards work.
You miss the point! (Score:1)
And that doesn't do 3D...
And you're wasting another slot in your system..
YET - My Banshee cost me $99, has excellent 2D, and I'm not wasting slots.
I don't think anyone who bought a Banshee bought it because they thought it would trounce the V2..
Re:It already exists (Score:1)
Most programs like things such as acceleration from video cards, at which point no sane programmer wants app->video card, that's just painful as hell as then you have to start supporting the acceleration of all different video cards, which is what X is around for in the first place.
So while what you're talking about is useful for unnacelerated video playback, it doesn't have much applicability to anything else. Wouldn't be that bad an idea, though, except that it would be a bit hard to work out the security model for.
Remember who's making glide (Score:1)
If you want someone to whom you are the customer to write drivers, ask the makers of the voodoo chipsets to write their own drivers and do it on a timely basis for a funded company. Daryll's doing an amazing job considering that he's not being paid for it.
It already exists (Score:2)
Q3 and 3D in Linux (Score:1)
Can be faster in some situations (Score:2)
Consider the situation where the opengl driver for a card needs to do a bit of non trivial preprocessing of the gl commands before sending them off to the graphics card (the extreme of this is software rendering). Now AFAIK gl is not thread safe, so this processing would occurin the same thread of execution as the program.
Now with GLX and a multi processor machine, the render preprocessing would occur in a separate process, in effect giving your program a separate render thread that could run on the other processor.
As for X connections being slow, the X protocol spec defines how information should be sent accross the network. For local connections (eg
Re:Q3 and 3D in Linux (Score:1)
Don't bother with the video downgrade (Score:1)
Hardware you ask?
AMD 233, 64 Meg Ram, Voodoo Rush
Software?
Redhat Linux 5.2 out of the box install with one exception, Glide and modified SVGA server for Voodoo card.
Oh yeah, in quake 2 I can't get mouse to act right. I turn on "freelook" and all I can see is the floor.
Erm..Direct Rendering. (Score:2)
Re:3d graphics with RIVA TNT AGP card? (Score:1)
doozy
3d graphics with RIVA TNT AGP card? (Score:1)
Re:Q3 and 3D in Linux (Score:1)
Re:GL Cards (Score:1)
Are there actually TNT GL drivers for Linux now? I thought we had to wait until the TNT2 came out and use those drivers (backwards compatibility, right?)
"Software is like sex- the best is for free"
Re:(OT) Re: your sig... (Score:1)
Hmmm.... I dunno, I've been using NT4 for months now and haven't gotten a single blue screen... the performance SUCKS on my P2-350, but it hasn't crashed yet. Of course, maybe that's cuz I only use it for an hour or so at a time before I can't stand it anymore and reboot into good ol' Linux.
"Software is like sex- the best is for free"
x86defile youre a genius (Score:1)
Anyway I think that your idea sounds quite reasonable, granted that developers of X and developers of proggies that use the new X extensions can cooperate (additionally, authors of different x programs need to cooperate in case a user somehow invokes two programs which directly map the framebuffer at the same time
Making suggestionslike this is a good first step to gettinga formal proposal, and then to getting something
Sounds like a good idea to me (and yes of course I realise the implications of complication wrt other programs, but it CAN be worked out and if linux is to gain any marketshare amongst the gamers of the coming years as games get more and more complex, then this is somethign that would definately be quite useful
James
Oh no! Techno-fear... (Score:1)
(Bonus points for spotting the reference in the title)
Re:More stories like this!!! (Score:1)
Why not create
I visit
Direct rendering (Score:1)
XFree also supports the DGA and MIT_SHM X extensions than can be used to speed up local clients.
Re:Cards support? (Score:1)
Note that vesafb will work for any card with a VESA 2.0 BIOS and linear frame buffer.
Re:3d graphics with RIVA TNT AGP card? (Score:1)
I've seen this so many times i can't hardly believe it. You miss the joke! It should read "BSD and LSD". (As in BSD unix, original unix did not come from berkley, but from AT&T.)
GL Cards (Score:2)
--
Alan L. * Webmaster of www.UnixPower.org