FW: Win32 XServer

Kendall Bennett KendallB@scitechsoft.com
Wed Nov 17 18:47:00 GMT 1999

Mike MacDonald <mmacdona@tsi.gte.com> wrote:

> Alot of people out there telling us it can't be done..  That
> REALLY pisses me off.. 

If you are referring to my email, I am not trying to tell you it 
can't done, but rather that it *will* be very difficult to get right. 
I am not saying this to try and put your down, but simply to elighten 
you on the problems you will encounter if you try to get direct 
hardware rendering working under Windows. 

A lot of people involved in this project have been looking over at 
the OS/2 port of XFree86, and saying 'Hey, if OS/2 can do it, so can 
Windows!'. Unfortunately OS/2 has some key underlying architectural 
differences that enable XFree86/2 to work seamlessly. This is 
specifically the ability for an OS/2 console program to run in a 
fullscreen session, and the OS/2 PM *expects* it to take over 
complete control of the graphics hardware (and also allows it 
implement a save/restore on it's state before switch to and from PM). 
Windows simply does not support that (we invented something similar 
many years ago called 'WinDirect' for games, but due to badly written 
Windows display drivers it does not work reliably, and is only for 
Windows 9x not NT).

The fundamental problem with trying to use Direct hardware rendering 
under Windows is that the Windows drivers do not expect *any* other 
program in the system to be directly controlling the graphics 
hardware. Although it may sound like 'DirectX' allows this, in 
reality it doesn't. What it does do is provide an abstraction later 
with more game oriented functions for faster bitmap blitting, and a 
pointer to the framebuffer surface so you can do your own custom 
rendering. DirectX does not expect the programmer to directly program 
the hardware 2D or 3D engines on the graphics card, which is what 
using the XF86_SVGA server entails.

I am also speaking from painful experience here, because we do 
similar things in some of our products (not X-server products, but 
game related ones). We have managed to get it working for a small 
subset of functions, but given the countless hours we have spent 
tuning our code to 'coexist' properly with specific cards and 
specific drivers, it would be a huge task to do the same for the 
existing XFree86 direct rendering code.

However once again I want to stress that I am not saying that an X-
server for Win32 can't be done. It certainly can, but a more fruitful 
approach to this problem is the following:

 1. Forget about trying to get XF86_SVGA working direct to hardware 
    (at least initially; go back and try later if you really wish).

 2. Don't try to directly program the hardware for graphics, mouse or 
    keyboard. Instead write the proper OS support functions for the X 
    event mechanims that talk to the Win32 event mechanism and/or 

 3. Start out with an unaccelerated server (you can base it on 
    XF86_SVGA since the framework is all there), that uses DirectDraw 
    to draw directly on the video memory surface. 

 4. Use smart surface locks around the highest level primitives 
    possible (by smart I mean use a reference counter so you can 
    avoid a re-lock if the surface was already locked by a higher 
    level primitive).

 5. When the above all works, you can then use the DirectDraw BitBlt 
    functions to do solid blits, transparent blits and solid color 
    fills to get some form of acceleration. The blits and color fills 
    will make a *huge* difference, and at that point you will have a 
    *very* useable server.

 6. To make things faster, you can use GDI to draw on the primary 
    surface which would allow you to accelerate text, line drawing 
    and pattern fills.


|   SciTech Software - Building Truly Plug'n'Play Software!     |
| Kendall Bennett          | Email: KendallB@scitechsoft.com    |
| Director of Engineering  | Phone: (530) 894 8400              |
| SciTech Software, Inc.   | Fax  : (530) 894 9069              |
| 505 Wall Street          | ftp  : ftp.scitechsoft.com         |
| Chico, CA 95928, USA     | www  : http://www.scitechsoft.com  |

More information about the Cygwin-xfree mailing list