DOS driver updates from Daniel Borca
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 8 Mar 2002 19:27:17 +0000 (19:27 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 8 Mar 2002 19:27:17 +0000 (19:27 +0000)
docs/README.DJ
src/mesa/drivers/dos/dmesa.c
src/mesa/main/Makefile.DJ

index e20454a..8b3a0f5 100644 (file)
@@ -1,4 +1,4 @@
-                   Mesa 4.0.1 DOS/DJGPP Port version 0.2\r
+                   Mesa 4.0.1 DOS/DJGPP Port version 0.3\r
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
 \r
 \r
@@ -6,13 +6,7 @@
 Description:\r
 ~~~~~~~~~~~~\r
 \r
-This is the DOS port of MESA 4.0, for DJGPP programmers... It features some\r
-sort of hardware acceleration, but it's pretty thin: it is entirely based on\r
-VBEAF.DRV from the FreeBE/AF project (http://www.talula.demon.co.uk/freebe/).\r
-Note that SciTech's driver isn't supported because I hate the `nearptr' hack.\r
-Anyway, these drivers don't provide ANY 3D function :-( Moreover, it seems to\r
-me the FreeBE/AF project is not really up to date... Well, it's not much, my\r
-intention was to open the door ;-)\r
+Well, guess what... this is the DOS port of MESA 4.0, for DJGPP fans... Whoa!\r
 \r
 \r
 \r
@@ -54,17 +48,11 @@ style :-( Sorry!
 Pitfalls:\r
 1. The current version supports only RGB[A] modes, for it made no sense to me\r
    to endorse color-index (aka palette) modes.\r
-2. Double-buffered uses page flipping if acceleration is available, else falls\r
-   back to virtual buffer.\r
-3. Single-buffered is not allowed with 24-bit modes, because direct access was\r
-   wrong and fixing it would mean to slow down the other routines; until this\r
-   is really, really necessary, it won't get reimplemented.\r
-4. Another weird "feature" is that buffer width must be multiple of 4 (I'm a\r
+2. Single-buffered is not allowed at all. Until I can find a way to use *REAL*\r
+   hardware acceleration, it won't get implemented.\r
+3. Another weird "feature" is that buffer width must be multiple of 4 (I'm a\r
    lazy programmer and I found that the easiest way to keep buffer handling at\r
    peak performance ;-).\r
-5. The FreeBE/AF driver is searched in the current directory only; therefore,\r
-   to disable hardware acceleration, make sure you don't have VBEAF.DRV where\r
-   your application resides.\r
 \r
 \r
 \r
@@ -123,6 +111,8 @@ v0.2        feb-2002        + fast triangle rasterizers
                        + glut has now an internal timer\r
                        * glut changed to support multi-window (unfinished)\r
                        ! minor PC_HW corrections\r
+v0.3   mar-2002        - removed FreeBE/AF code\r
+                       - removed single-buffer modes\r
 \r
 \r
 \r
index 5ab323d..454b891 100644 (file)
@@ -23,7 +23,7 @@
  */\r
 \r
 /*\r
- * DOS/DJGPP device driver v0.2 for Mesa 4.0\r
+ * DOS/DJGPP device driver v0.3 for Mesa 4.0\r
  *\r
  *  Copyright (C) 2002 - Borca Daniel\r
  *  Email : dborca@yahoo.com\r
  */\r
 struct dmesa_visual {\r
    GLvisual *gl_visual;\r
+   GLboolean db_flag;           /* double buffered? */\r
    GLboolean rgb_flag;          /* RGB mode? */\r
    GLuint depth;                /* bits per pixel (1, 8, 24, etc) */\r
-\r
-   GLint caps;                  /* video mode capabilities */\r
 };\r
 \r
 /*\r
@@ -82,12 +81,7 @@ struct dmesa_buffer {
 \r
    int xpos, ypos;              /* position */\r
    int width, height;           /* size in pixels */\r
-   int pitch, len;              /* number of bytes in a line, then total */\r
-   int cwidth;                  /* scan width */\r
-\r
-   int caps;                    /* video mode capabilities */\r
-\r
-   void (*tri_rgb_flat) ();\r
+   int bwidth, len;             /* bytes in a line, then total */\r
 };\r
 \r
 /*\r
@@ -126,7 +120,7 @@ static void write_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
  void *b = c->Buffer->the_window;\r
  GLuint i, offset;\r
 \r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
  if (mask) {\r
     /* draw some pixels */\r
     for (i=0; i<n; i++, offset++) {\r
@@ -149,7 +143,7 @@ static void write_rgb_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
  void *b = c->Buffer->the_window;\r
  GLuint i, offset;\r
 \r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
  if (mask) {\r
     /* draw some pixels */\r
     for (i=0; i<n; i++, offset++) {\r
@@ -173,7 +167,7 @@ static void write_mono_rgba_span (const GLcontext *ctx,
  void *b = c->Buffer->the_window;\r
  GLuint i, offset, rgba = vl_mixrgba(color);\r
 \r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
  if (mask) {\r
     /* draw some pixels */\r
     for (i=0; i<n; i++, offset++) {\r
@@ -196,7 +190,7 @@ static void read_rgba_span (const GLcontext *ctx, GLuint n, GLint x, GLint y,
  void *b = c->Buffer->the_window;\r
  GLuint i, offset;\r
 \r
- offset = c->Buffer->cwidth * FLIP(y) + x;\r
+ offset = c->Buffer->width * FLIP(y) + x;\r
  /* read all pixels */\r
  for (i=0; i<n; i++, offset++) {\r
      vl_getrgba(b, offset, rgba[i]);\r
@@ -209,7 +203,7 @@ static void write_rgba_pixels (const GLcontext *ctx,
 {\r
  DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
  void *b = c->Buffer->the_window;\r
- GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height;\r
 \r
  if (mask) {\r
     /* draw some pixels */\r
@@ -232,7 +226,7 @@ static void write_mono_rgba_pixels (const GLcontext *ctx,
 {\r
  DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
  void *b = c->Buffer->the_window;\r
- GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height, rgba = vl_mixrgba(color);\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height, rgba = vl_mixrgba(color);\r
 \r
  if (mask) {\r
     /* draw some pixels */\r
@@ -255,7 +249,7 @@ static void read_rgba_pixels (const GLcontext *ctx,
 {\r
  DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
  void *b = c->Buffer->the_window;\r
- GLuint i, w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint i, w = c->Buffer->width, h = c->Buffer->height;\r
 \r
  if (mask) {\r
     /* read some pixels */\r
@@ -290,24 +284,17 @@ static void tri_rgb_flat (GLcontext *ctx,
 {\r
  DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
  void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
 \r
- if (c->Buffer->tri_rgb_flat) {\r
-    c->Buffer->tri_rgb_flat(IROUND(v0->win[0]), IROUND(FLIP2(v0->win[1])),\r
-                            IROUND(v1->win[0]), IROUND(FLIP2(v1->win[1])),\r
-                            IROUND(v2->win[0]), IROUND(FLIP2(v2->win[1])),\r
-                            vl_mixrgb(v2->color));\r
- } else {\r
 #define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);\r
 \r
 #define RENDER_SPAN(span)                                      \\r
  GLuint i, offset = FLIP2(span.y)*w + span.x;                        \\r
  for (i = 0; i < span.count; i++, offset++) {                        \\r
-       vl_putpixel(b, offset, rgb);                            \\r
  }\r
GLuint i, offset = FLIP2(span.y)*w + span.x;                  \\r
for (i = 0; i < span.count; i++, offset++) {                  \\r
+     vl_putpixel(b, offset, rgb);                              \\r
+ }\r
 \r
 #include "swrast/s_tritemp.h"\r
- }\r
 }\r
 \r
 \r
@@ -322,22 +309,22 @@ static void tri_rgb_flat_z (GLcontext *ctx,
 {\r
  DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
  void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
 \r
 #define INTERP_Z 1\r
 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE\r
 #define SETUP_CODE GLuint rgb = vl_mixrgb(v2->color);\r
 \r
 #define RENDER_SPAN(span)                                      \\r
  GLuint i, offset = FLIP2(span.y)*w + span.x;                        \\r
  for (i = 0; i < span.count; i++, offset++) {                        \\r
-       const DEPTH_TYPE z = FixedToDepth(span.z);              \\r
-       if (z < zRow[i]) {                                      \\r
-          vl_putpixel(b, offset, rgb);                         \\r
-          zRow[i] = z;                                         \\r
-       }                                                       \\r
-       span.z += span.zStep;                                   \\r
  }\r
GLuint i, offset = FLIP2(span.y)*w + span.x;                  \\r
for (i = 0; i < span.count; i++, offset++) {                  \\r
+     const DEPTH_TYPE z = FixedToDepth(span.z);                        \\r
+     if (z < zRow[i]) {                                                \\r
+        vl_putpixel(b, offset, rgb);                           \\r
+        zRow[i] = z;                                           \\r
+     }                                                         \\r
+     span.z += span.zStep;                                     \\r
+ }\r
 \r
 #include "swrast/s_tritemp.h"\r
 }\r
@@ -354,21 +341,21 @@ static void tri_rgb_smooth (GLcontext *ctx,
 {\r
  DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
  void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
 \r
 #define INTERP_RGB 1\r
 #define RENDER_SPAN(span)                                      \\r
  GLuint i, offset = FLIP2(span.y)*w + span.x;                        \\r
  for (i = 0; i < span.count; i++, offset++) {                        \\r
-       unsigned char rgb[3];                                   \\r
-       rgb[0] = FixedToInt(span.red);                          \\r
-       rgb[1] = FixedToInt(span.green);                                \\r
-       rgb[2] = FixedToInt(span.blue);                         \\r
-       vl_putpixel(b, offset, vl_mixrgb(rgb));                 \\r
-       span.red += span.redStep;                               \\r
-       span.green += span.greenStep;                           \\r
-       span.blue += span.blueStep;                             \\r
  }\r
GLuint i, offset = FLIP2(span.y)*w + span.x;                  \\r
for (i = 0; i < span.count; i++, offset++) {                  \\r
+     unsigned char rgb[3];                                     \\r
+     rgb[0] = FixedToInt(span.red);                            \\r
+     rgb[1] = FixedToInt(span.green);                          \\r
+     rgb[2] = FixedToInt(span.blue);                           \\r
+     vl_putpixel(b, offset, vl_mixrgb(rgb));                   \\r
+     span.red += span.redStep;                                 \\r
+     span.green += span.greenStep;                             \\r
+     span.blue += span.blueStep;                               \\r
+ }\r
 \r
 #include "swrast/s_tritemp.h"\r
 }\r
@@ -385,29 +372,29 @@ static void tri_rgb_smooth_z (GLcontext *ctx,
 {\r
  DMesaContext c = (DMesaContext)ctx->DriverCtx;\r
  void *b = c->Buffer->the_window;\r
- GLuint w = c->Buffer->cwidth, h = c->Buffer->height;\r
+ GLuint w = c->Buffer->width, h = c->Buffer->height;\r
 \r
 #define INTERP_Z 1\r
 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE\r
 #define INTERP_RGB 1\r
 \r
 #define RENDER_SPAN(span)                                      \\r
  GLuint i, offset = FLIP2(span.y)*w + span.x;                        \\r
  for (i = 0; i < span.count; i++, offset++) {                        \\r
-       const DEPTH_TYPE z = FixedToDepth(span.z);              \\r
-       if (z < zRow[i]) {                                      \\r
-          unsigned char rgb[3];                                        \\r
-          rgb[0] = FixedToInt(span.red);                       \\r
-          rgb[1] = FixedToInt(span.green);                     \\r
-          rgb[2] = FixedToInt(span.blue);                      \\r
-          vl_putpixel(b, offset, vl_mixrgb(rgb));              \\r
-          zRow[i] = z;                                         \\r
-       }                                                       \\r
-       span.red += span.redStep;                               \\r
-       span.green += span.greenStep;                           \\r
-       span.blue += span.blueStep;                             \\r
-       span.z += span.zStep;                                   \\r
  }\r
GLuint i, offset = FLIP2(span.y)*w + span.x;                  \\r
for (i = 0; i < span.count; i++, offset++) {                  \\r
+     const DEPTH_TYPE z = FixedToDepth(span.z);                        \\r
+     if (z < zRow[i]) {                                                \\r
+        unsigned char rgb[3];                                  \\r
+        rgb[0] = FixedToInt(span.red);                         \\r
+        rgb[1] = FixedToInt(span.green);                       \\r
+        rgb[2] = FixedToInt(span.blue);                                \\r
+        vl_putpixel(b, offset, vl_mixrgb(rgb));                        \\r
+        zRow[i] = z;                                           \\r
+     }                                                         \\r
+     span.red += span.redStep;                                 \\r
+     span.green += span.greenStep;                             \\r
+     span.blue += span.blueStep;                               \\r
+     span.z += span.zStep;                                     \\r
+ }\r
 \r
 #include "swrast/s_tritemp.h"\r
 }\r
@@ -505,26 +492,12 @@ static void clear (GLcontext *ctx, GLbitfield mask, GLboolean all,
  if (*colorMask==0xffffffff) {\r
     if (mask & DD_BACK_LEFT_BIT) {\r
        if (all) {\r
-          if CHECK_SOFTDB(b->caps) {\r
-             vl_clear_virtual(b->the_window, b->len, c->ClearColor);\r
-          } else {\r
-             vl_clear(b->the_window, 0, 0, b->width, b->height, c->ClearColor);\r
-          }\r
+          vl_clear(b->the_window, b->len, c->ClearColor);\r
        } else {\r
-          vl_clear(b->the_window, x, y, width, height, c->ClearColor);\r
+          vl_rect(b->the_window, x, y, width, height, c->ClearColor);\r
        }\r
        mask &= ~DD_BACK_LEFT_BIT;\r
     }\r
-    if (mask & DD_FRONT_LEFT_BIT) {\r
-       if (all) {\r
-          x = 0;\r
-          y = 0;\r
-          width = b->width;\r
-          height = b->height;\r
-       }\r
-       vl_clear(b->the_window, x, y, width, height, c->ClearColor);\r
-       mask &= ~DD_FRONT_LEFT_BIT;\r
-    }\r
  }\r
 \r
  if (mask) {\r
@@ -553,7 +526,7 @@ static void set_read_buffer (GLcontext *ctx, GLframebuffer *buffer,
  */\r
 static GLboolean set_draw_buffer (GLcontext *ctx, GLenum mode)\r
 {\r
- if (mode==GL_BACK_LEFT || mode==GL_FRONT_LEFT) {\r
+ if (mode==GL_BACK_LEFT) {\r
     return GL_TRUE;\r
  } else {\r
     return GL_FALSE;\r
@@ -756,8 +729,10 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
 {\r
  DMesaVisual v;\r
  GLint redBits, greenBits, blueBits, alphaBits;\r
- GLint caps;\r
 \r
+ if (!dbFlag) {\r
+    return NULL;\r
+ }\r
  alphaBits = 0;\r
  switch (colDepth) {\r
         case 15:\r
@@ -781,11 +756,7 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
              return NULL;\r
  }\r
 \r
- caps = 0;\r
- if (!dbFlag) {\r
-    caps |= VL_SINGLE;\r
- }\r
- if (vl_video_init(width, height, colDepth, &caps)!=0) {\r
+ if (vl_video_init(width, height, colDepth)!=0) {\r
     return NULL;\r
  }\r
 \r
@@ -808,7 +779,7 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
                                        1);                     /* numSamples */\r
 \r
     v->depth = colDepth;\r
-    v->caps = caps;\r
+    v->db_flag = dbFlag;\r
  }\r
 \r
  return v;\r
@@ -818,7 +789,7 @@ DMesaVisual DMesaCreateVisual (GLint width, GLint height, GLint colDepth,
 \r
 void DMesaDestroyVisual (DMesaVisual v)\r
 {\r
- vl_video_exit();\r
+ vl_video_exit(!0);\r
  _mesa_destroy_visual(v->gl_visual);\r
  free(v);\r
 }\r
@@ -841,12 +812,9 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
     b->xpos = xpos;\r
     b->ypos = ypos;\r
     b->width = width;\r
+    b->bwidth = width * ((visual->depth+7)/8);\r
     b->height = height;\r
-    b->caps = visual->caps;\r
-    b->pitch = b->width*((visual->depth+7)/8);\r
-    b->len = b->pitch*b->height;\r
-\r
-    b->tri_rgb_flat = vl_getprim(TRI_RGB_FLAT);\r
+    b->len = b->bwidth * b->height;\r
  }\r
 \r
  return b;\r
@@ -856,9 +824,7 @@ DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
 \r
 void DMesaDestroyBuffer (DMesaBuffer b)\r
 {\r
- if CHECK_SOFTDB(b->caps) {\r
-    free(b->the_window);\r
- }\r
+ free(b->the_window);\r
  _mesa_destroy_framebuffer(b->gl_buffer);\r
  free(b);\r
 }\r
@@ -911,13 +877,10 @@ void DMesaDestroyContext (DMesaContext c)
 GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)\r
 {\r
  if (c&&b) {\r
-    void *ptr = vl_sync_buffer(b->the_window, b->xpos, b->ypos, b->width, b->height, &b->cwidth);\r
-\r
-    if (b->cwidth==-1) {\r
+    if ((b->the_window=vl_sync_buffer(b->the_window, b->xpos, b->ypos, b->width, b->height))==NULL) {\r
        return GL_FALSE;\r
     }\r
 \r
-    b->the_window = ptr;\r
     c->Buffer = b;\r
 \r
     dmesa_update_state(c->gl_ctx, 0);\r
@@ -939,5 +902,5 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
 void DMesaSwapBuffers (DMesaBuffer b)\r
 {\r
  /* copy/swap back buffer to front if applicable */\r
b->the_window = vl_flip(b->the_window, b->width, b->height, b->pitch);\r
vl_flip(b->the_window, b->bwidth, b->height);\r
 }\r
index e6be420..214882d 100644 (file)
@@ -157,7 +157,7 @@ CORE_SOURCES = \
        tnl/t_vb_texmat.c \\r
        tnl/t_vb_vertex.c\r
 \r
-DRIVER_SOURCES = DOS/dmesa.c DOS/video.c DOS/vbeaf.c DOS/dpmi.c\r
+DRIVER_SOURCES = DOS/dmesa.c DOS/video.c DOS/dpmi.c\r
 \r
 SOURCES = $(CORE_SOURCES) $(DRIVER_SOURCES)\r
 \r
@@ -184,6 +184,5 @@ DOS/dmesa.o: DOS/dmesa.c glheader.h ../include/GL/gl.h context.h glapi.h \
   swrast/s_depth.h swrast/s_lines.h swrast/s_triangle.h swrast/s_trispan.h \\r
   swrast_setup/swrast_setup.h tnl/tnl.h tnl/t_context.h math/m_vector.h \\r
   math/m_xform.h tnl/t_pipeline.h DOS/video.h swrast/s_tritemp.h\r
-DOS/dpmi.o: DOS/dpmi.c DOS/vbeaf.h DOS/dpmiint.h\r
-DOS/vbeaf.o: DOS/vbeaf.c DOS/dpmiint.h DOS/vbeaf.h DOS/video.h\r
-DOS/video.o: DOS/video.c DOS/video.h DOS/dpmiint.h DOS/vbeafint.h DOS/vbeaf.h\r
+DOS/dpmi.o: DOS/dpmi.c DOS/dpmiint.h\r
+DOS/video.o: DOS/video.c DOS/video.h DOS/dpmiint.h\r