photo of Macallan

Rants & Ramblings

Another kernel graphics driver

, , , ,

I got me a new toy - a Blade 2500, 2x 1.28GHz US-IIIi, 4GB RAM and two so far unsupported graphics boards, namely an XVR-500 and an XVR-1200. Of course I had to do something about the graphics boards.
As it turns out both use different variants of 3Dlabs Wildcat OpenGL accelerators to which not a shred of documentation is publicly available. Linux and OpenBSD support them to some degree, OpenBSD even has some acceleration for some of them, but all very hacky and with loads of unanswered questions.
The problem with these boards is that we get the hardware in a quite insane state - there are two 8bit framebuffers, two 32bit framebuffers, and somewhere there's a control plane which selects for each pixel from which framebuffer the colour information comes. Unfortunately this control plane contains garbage ( pixels appear randomly selected from the two 8bit framebuffers ) and we have no idea how to access it, so what both OpenBSD and Linux do is to do all drawing operations in both framebuffers to make sure the pixels show up.
This approach has a few distinctive disadvantages - it's slow, and when you do scrolling operations you can see which pixel belongs to what framebuffer since they scroll one after the other ( of course the latter point is moot on boards where OpenBSD supports acceleration ).
To get around this my driver goes a different route - it uses a shadow framebuffer in main memory. Although wsdisplay already supports shadow framebuffers I couldn't use it since I still need to update two framebuffers, so I had to write my own. All operations are done on the shadow buffer first and then copied into both framebuffers. This has the following advantages:
  • all framebuffer reads over the PCI bus are eliminated
  • all drawing operations that involve reading from the framebuffer are done in cached memory
  • copying data from the shadow buffer to the graphics board happens from cache
  • all drawing operations are done only once, into cached memory, and copying the results to the graphics board is much faster than repeating the drawing operation

The result is speed which can rival some older accelerators, at least if you stick the board into a 64bit/66MHz slot.
That said, the wcfb driver has been tested with XVR-500 and XVR-1200 boards in a Blade 2500 and an Ultra 60, it should work fine in other machines ( as long as the firmware sets up a usable graphics mode ) and it will probably work with other Wildcat-based graphics boards like the Expert3D series, XVR-600 etc.

A simple guide to Sun graphics hardware on NetBSDAnother SBus monster

Comments

Thabo Thabotizz Wednesday, June 2, 2010 5:38:11 PM

Ooh! You really know your stuff. up

Lloyd Fosslloyd3369 Monday, May 9, 2011 8:47:08 PM

I have a Sun Ultra Enterprise 450 with an XVR-1200 in it that I've been trying to get to work correctly for weeks. If I type something like "devalias <enter> devalias <enter> devalias <enter>" at the OpenBoot prompt, the text scrolls extremely quickly and nicely. Then if I type "boot disk" and OpenBSD 4.9 begins to load, all the output messages scroll up the screen nice and fast and beautiful as well UNTIL it loads the ifb driver. Then after that the lines of text start scrolling at a speed up about 1 per second. The text appears to be jump up half of a line first and then all the way up to the next line. Its hard to explain, but sort of like a 'ghost' effect.

You seem to know quite a bit about the XVR-1200, considering you wrote your own device driver for it and everything?! I bought the XVR-1200 because OpenBSD 'supposedly' supported it in 24-bit accelerated mode. At least, that's what the ifb(4) documentation leads one to believe. What's the deal? I can't get X to run either. I also have a PGX64 card which works just fine (console is 'okay' speed-wise and X runs 'okay' as well), but I thought the XVR-1200 would make this card seem like a dinosaur.

Any help? Advice? I don't fully understand how OpenBSD loads or configures device drivers. Are there options that I can change? I know this post is over a year old, but maybe you would be willing to help a fellow Sun enthusiast finally get some graphical 'umph'?

Macallan Monday, May 9, 2011 9:12:13 PM

From your description is looks like OpenBSD's driver simply repeats every drawing operation for each framebuffer, hence the ghost effect. This is insane for two reasons - it looks bad and it's SLOW, even in 8 bit ( my driver used to do that too and this approach being unusably slow led me to do the trick described above )
So, if you want decent X on a PCI Sun running something else than Solaris stay away from WildCat boards - we have no real docs and unless 3Dlabs changes its corporate mind we're not going to get any. The PGX64 is a Rage XL which should Just Work(tm) with Xorg, if you want something with more video memory ( all mach64 are limited to 8MB by design, I don't know how much memory the PGX64 has but it's probably not much more than 4MB ) get an XVR-100, that's a 32MB Radeon RV100.
Also, OpenBSD is rather misleading in their hardware support docs - then they say "24bit accelerated framebuffer" they mean the hardware capabilities, not necessarily driver support. They have some acceleration for some WildCat variants ( in the jfb driver IIRC ) but that still has the same problem ( two framebuffers with semi-random visibility ) and it's all rather hackish.
That said, I never actually used OpenBSD, we just occasionally look at their code for hardware documentation.
If you want to fix up OpenBSD's driver to be a little faster just look at my wcfb driver in NetBSD - the drawing and cacheing code should be easy enough to port to OpenBSD.

Lloyd Fosslloyd3369 Tuesday, May 10, 2011 3:26:18 AM

Thanks for the info! My PGX64 has 8 Mb of video memory. I am not sure if they all do though. Some may have 4 Mb? As stated before, it does work decently for both console and X graphics. But for example, using XFCE with compositing turned on, semi-transparent windows don't exactly just glide across the screen when moved. Its very choppy. I may have to pick up an XVR-100 on eBay and try that out. I have looked at your NetBSD wcfb driver source code, however porting / compiling it to work with OpenBSD is currently beyond my learning curve. I wouldn't even know where to begin. worried

Its funny how OpenBSD prides themselves on how excellent their documentation and man pages are. It seems to me that the driver descriptions should reflect their current operational status and not their theoretical abilities. If I had more motivation, I'd probably write them and argue this point.

Macallan Tuesday, May 10, 2011 4:55:03 AM

Mach64 can't really accelerate compositing ops. There's a hack to use the texture mapping engine with some of them but the problem with that is that you're going to run out of video memory rather quickly - textures have to be in video memory and that's not exactly abundant on those boards and I don't think the Xorg driver knows how to DMA them in from main memory. Even if it did that needs kernel support which OpenBSD isn't likely to have ( I know NetBSD doesn't have it ).
I'm not sure if the E450 has UPA slots - if it does you may want to play with a Creator3D. These boards can accelerate most xrender operations ( and for their age they're ridiculously fast at it - they beat the crap out of an xvr-100 at x11perf -aaftext ), the problem is that the damage and composite extensions don't really seem to work with XAA ( which is what the sunffb driver uses ). The UPA slots offer a lot more bandwidth than PCI and they have their own connection to the crossbar that connects CPUs, memory, PCI bridges etc., so even without hw acceleration they're probably faster at eyecandy effects.
So, what I'm trying to say is, if you want dropshadows, transparency and such your best bet is an xvr-100. These cards also have DVI ports, although they need a firmware update to enable it at boot time.

Lloyd Fosslloyd3369 Tuesday, May 10, 2011 11:10:05 AM

My E450 motherboard only has (4) UPA slots for the CPU(s). Some of the E450 motherboards have a 5th UPA slot that sits a bit higher than the CPU slots and is horizontal (looks and works more like an SBUS slot). Try finding a horizontal UPA Creator3D card on eBay (or anywhere) though?! They're pretty hard to come by. Then some E450's even have a Creator3D card soldered directly to the motherboard at the same location. Mine has the solder points, but no connector present. I thought about maybe trying to solder one on, but the thought of heating up 160 contacts in very close proximity to each other just wasn't all that appealing. Perhaps one day I will just swap the motherboard out for one that has the connector. Until then, I think I will give the XVR-100 a shot. BTW, Thabo was right, you really know your stuff!!

Macallan Tuesday, May 10, 2011 1:22:30 PM

Yeah, I wouldn't try to do that kind of soldering myself either - too much of a chance of creating unintentional connections which would be hard to track down and fix. My soldering iron's tip probably isn't even small / pointy enough to heat a single pin on one of those connectors.
That said, while horizontal Creator(3D) cards aren't nearly as numerous as the vertical variety they do show up on ebay every now and then, often mislabeled as SBus cards. Usually you can tell from the picture what it actually is ( For example, if the card itself is single slot but wider than the SBus-like connector it's very likely a Creator. The SBus slots in most SPARCStations are too close together to allow that kind of overhang. ) There are lots of people on ebay who sell Sun gear without any real knowledge of it.

Write a comment

New comments have been disabled for this post.