From 398c6b7980ac52ba15af78f45e71f49f33ded1aa Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 4 Feb 2003 02:43:27 +0000 Subject: DOS updates (Daniel Borca) --- src/mesa/drivers/dos/dmesa.c | 81 +++++++++++++++++++++++++---- src/mesa/drivers/dos/vesa/vesa.c | 33 ++++++------ src/mesa/drivers/dos/vga/vga.c | 33 ++++++------ src/mesa/drivers/dos/video.c | 109 +++++++++++++++++++++++++++------------ src/mesa/drivers/dos/video.h | 5 +- src/mesa/drivers/dos/virtual.S | 29 +++++------ src/mesa/main/Makefile.DJ | 35 ++++++------- 7 files changed, 211 insertions(+), 114 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c index 4541559e2c..ec9f3b2224 100644 --- a/src/mesa/drivers/dos/dmesa.c +++ b/src/mesa/drivers/dos/dmesa.c @@ -356,7 +356,7 @@ static void read_index_span (const GLcontext *ctx, GLuint n, GLint x, GLint y, offset = c->Buffer->width * FLIP(y) + x; /* read all pixels */ for (i=0; iDriverCtx)->Buffer; - if ((new_window=vl_sync_buffer(b->the_window, xpos, ypos, width, height)) == NULL) { + if (vl_sync_buffer(&b->the_window, xpos, ypos, b->width, b->height) != 0) { return GL_FALSE; } else { - b->the_window = new_window; b->xpos = xpos; b->ypos = ypos; + return GL_TRUE; + } + +#else + + return GL_FALSE; +#endif +} + + + +GLboolean DMesaResizeBuffer (GLint width, GLint height) +{ +#ifndef FX + GET_CURRENT_CONTEXT(ctx); + DMesaBuffer b = ((DMesaContext)ctx->DriverCtx)->Buffer; + + if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, width, height) != 0) { + return GL_FALSE; + } else { b->width = width; b->height = height; return GL_TRUE; @@ -1107,7 +1125,7 @@ GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b) { #ifndef FX if ((c != NULL) && (b != NULL)) { - if (!DMesaViewport(b, b->xpos, b->ypos, b->width, b->height)) { + if (vl_sync_buffer(&b->the_window, b->xpos, b->ypos, b->width, b->height) != 0) { return GL_FALSE; } @@ -1153,3 +1171,46 @@ void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue) vl_setCI(ndx, red, green, blue); #endif } + + + +void DMesaGetIntegerv (GLenum pname, GLint *params) +{ +#ifndef FX + GET_CURRENT_CONTEXT(ctx); + const DMesaContext c = (ctx == NULL) ? NULL : (DMesaContext)ctx->DriverCtx; +#else + const fxMesaContext c = fxMesaGetCurrentContext(); +#endif + + if (c == NULL) { + return; + } + + switch (pname) { + case DMESA_Y_ORIGIN: + #ifndef FX + params[0] = GL_FALSE; + #else + params[0] = GL_TRUE; + #endif + break; + case DMESA_SCREEN_SIZE: + #ifndef FX + vl_get_screen_size(¶ms[0], ¶ms[1]); + #else + params[0] = c->screen_width; + params[1] = c->screen_height; + #endif + break; + case DMESA_ARGB_ORDER: + #ifndef FX + params[0] = GL_FALSE; + #else + params[0] = !c->bgrOrder; + #endif + break; + default: + break; + } +} diff --git a/src/mesa/drivers/dos/vesa/vesa.c b/src/mesa/drivers/dos/vesa/vesa.c index 26c474317f..1f3de844d7 100644 --- a/src/mesa/drivers/dos/vesa/vesa.c +++ b/src/mesa/drivers/dos/vesa/vesa.c @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -454,22 +455,23 @@ static void vesa_restore (void) * In : color index, R, G, B * Out : - * - * Note: uses normalized values + * Note: uses integer values */ -static void vesa_setCI_f (int index, float red, float green, float blue) +static void vesa_setCI_i (int index, int red, int green, int blue) { - float max = (1 << vesa_color_precision) - 1; - - int _red = red * max; - int _green = green * max; - int _blue = blue * max; - +#if 0 __asm("\n\ movw $0x1010, %%ax \n\ movb %1, %%dh \n\ movb %2, %%ch \n\ int $0x10 \n\ -"::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx"); + "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); +#else + outportb(0x03C8, index); + outportb(0x03C9, red); + outportb(0x03C9, green); + outportb(0x03C9, blue); +#endif } @@ -479,16 +481,13 @@ static void vesa_setCI_f (int index, float red, float green, float blue) * In : color index, R, G, B * Out : - * - * Note: uses integer values + * Note: uses normalized values */ -static void vesa_setCI_i (int index, int red, int green, int blue) +static void vesa_setCI_f (int index, float red, float green, float blue) { - __asm("\n\ - movw $0x1010, %%ax \n\ - movb %1, %%dh \n\ - movb %2, %%ch \n\ - int $0x10 \n\ -"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); + float max = (1 << vesa_color_precision) - 1; + + vesa_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); } diff --git a/src/mesa/drivers/dos/vga/vga.c b/src/mesa/drivers/dos/vga/vga.c index 1888d98947..d1d2db51b5 100644 --- a/src/mesa/drivers/dos/vga/vga.c +++ b/src/mesa/drivers/dos/vga/vga.c @@ -31,6 +31,7 @@ */ +#include #include #include "vga.h" @@ -158,22 +159,23 @@ static void vga_restore (void) * In : color index, R, G, B * Out : - * - * Note: uses normalized values + * Note: uses integer values */ -static void vga_setCI_f (int index, float red, float green, float blue) +static void vga_setCI_i (int index, int red, int green, int blue) { - float max = (1 << vga_color_precision) - 1; - - int _red = red * max; - int _green = green * max; - int _blue = blue * max; - +#if 0 __asm("\n\ movw $0x1010, %%ax \n\ movb %1, %%dh \n\ movb %2, %%ch \n\ int $0x10 \n\ - "::"b"(index), "m"(_red), "m"(_green), "c"(_blue):"%eax", "%edx"); + "::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); +#else + outportb(0x03C8, index); + outportb(0x03C9, red); + outportb(0x03C9, green); + outportb(0x03C9, blue); +#endif } @@ -183,16 +185,13 @@ static void vga_setCI_f (int index, float red, float green, float blue) * In : color index, R, G, B * Out : - * - * Note: uses integer values + * Note: uses normalized values */ -static void vga_setCI_i (int index, int red, int green, int blue) +static void vga_setCI_f (int index, float red, float green, float blue) { - __asm("\n\ - movw $0x1010, %%ax \n\ - movb %1, %%dh \n\ - movb %2, %%ch \n\ - int $0x10 \n\ -"::"b"(index), "m"(red), "m"(green), "c"(blue):"%eax", "%edx"); + float max = (1 << vga_color_precision) - 1; + + vga_setCI_i(index, (int)(red * max), (int)(green * max), (int)(blue * max)); } diff --git a/src/mesa/drivers/dos/video.c b/src/mesa/drivers/dos/video.c index 5f4d9d5bed..aba99ac542 100644 --- a/src/mesa/drivers/dos/video.c +++ b/src/mesa/drivers/dos/video.c @@ -45,6 +45,7 @@ static vl_driver *drv; /* based upon mode specific data: valid entire session */ int vl_video_selector; +static vl_mode *video_mode; static int video_scanlen, video_bypp; /* valid until next buffer */ void *vl_current_draw_buffer, *vl_current_read_buffer; @@ -93,6 +94,7 @@ int (*vl_mixfix) (fixed r, fixed g, fixed b); int (*vl_mixrgb) (const unsigned char rgb[]); int (*vl_mixrgba) (const unsigned char rgba[]); void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]); +int (*vl_getpixel) (unsigned int offset); void (*vl_clear) (int color); void (*vl_rect) (int x, int y, int width, int height, int color); void (*vl_flip) (void); @@ -243,30 +245,43 @@ static void v_getrgba32 (unsigned int offset, unsigned char rgba[4]) -/* Desc: set one palette entry +/* Desc: pixel retrieval * - * In : index, R, G, B - * Out : - + * In : pixel offset + * Out : pixel value * - * Note: color components are in range [0.0 .. 1.0] + * Note: uses current read buffer */ -void vl_setCI (int index, float red, float green, float blue) +static int v_getpixel8 (unsigned int offset) { - drv->setCI_f(index, red, green, blue); + return ((word8 *)vl_current_read_buffer)[offset]; +} +#define v_getpixel15 v_getpixel16 +static int v_getpixel16 (unsigned int offset) +{ + return ((word16 *)vl_current_read_buffer)[offset]; +} +static int v_getpixel24 (unsigned int offset) +{ + return *(word32 *)((long)vl_current_read_buffer+offset*3); +} +static int v_getpixel32 (unsigned int offset) +{ + return ((word32 *)vl_current_read_buffer)[offset]; } -/* Desc: read pixel from 8bit buffer +/* Desc: set one palette entry * - * In : pixel offset - * Out : pixel read + * In : index, R, G, B + * Out : - * - * Note: used only for CI modes + * Note: color components are in range [0.0 .. 1.0] */ -int vl_getCIpixel (unsigned int offset) +void vl_setCI (int index, float red, float green, float blue) { - return ((word8 *)vl_current_read_buffer)[offset]; + drv->setCI_f(index, red, green, blue); } @@ -276,7 +291,7 @@ int vl_getCIpixel (unsigned int offset) * In : color, R, G, B * Out : - * - * Note: color components are in range [0 .. 63] + * Note: - */ static void fake_setcolor (int c, int r, int g, int b) { @@ -326,33 +341,56 @@ static void fake_buildpalette (int bits) /* Desc: sync buffer with video hardware * - * In : old buffer, position, size - * Out : new buffer + * In : ptr to old buffer, position, size + * Out : 0 if success * * Note: - */ -void *vl_sync_buffer (void *buffer, int x, int y, int width, int height) +int vl_sync_buffer (void **buffer, int x, int y, int width, int height) { - void *newbuf; - - if (width&7) { - return NULL; + if ((width & 7) || (x < 0) || (y < 0) || (x+width > video_mode->xres) || (y+height > video_mode->yres)) { + return -1; } else { - if ((newbuf=realloc(buffer, width * height * video_bypp)) != NULL) { - vl_current_width = width; - vl_current_height = height; - vl_current_stride = vl_current_width * video_bypp; - vl_current_bytes = vl_current_stride * height; - - vl_current_offset = video_scanlen * y + video_bypp * x; - vl_current_delta = video_scanlen - vl_current_stride; + void *newbuf = *buffer; + + if ((newbuf == NULL) || (vl_current_width != width) || (vl_current_height != height)) { + newbuf = realloc(newbuf, width * height * video_bypp); } - return vl_current_draw_buffer = vl_current_read_buffer = newbuf; + + if (newbuf == NULL) { + return -2; + } + + vl_current_width = width; + vl_current_height = height; + vl_current_stride = vl_current_width * video_bypp; + vl_current_bytes = vl_current_stride * height; + + vl_current_offset = video_scanlen * y + video_bypp * x; + vl_current_delta = video_scanlen - vl_current_stride; + + vl_current_draw_buffer = vl_current_read_buffer = *buffer = newbuf; + return 0; } } +/* Desc: get screen geometry + * + * In : ptr to WIDTH, ptr to HEIGHT + * Out : - + * + * Note: - + */ +void vl_get_screen_size (int *width, int *height) +{ + *width = video_mode->xres; + *height = video_mode->yres; +} + + + /* Desc: retrieve CPU MMX capability * * In : - @@ -364,8 +402,7 @@ int vl_can_mmx (void) { #ifdef USE_MMX_ASM extern int _mesa_identify_x86_cpu_features (void); - int _mesa_x86_cpu_features = _mesa_identify_x86_cpu_features(); - return (_mesa_x86_cpu_features & 0x00800000); + return (_mesa_identify_x86_cpu_features() & 0x00800000); #else return 0; #endif @@ -382,9 +419,14 @@ int vl_can_mmx (void) */ static int vl_setup_mode (vl_mode *p) { + if (p == NULL) { + return -1; + } + #define INITPTR(bpp) \ vl_putpixel = v_putpixel##bpp; \ vl_getrgba = v_getrgba##bpp; \ + vl_getpixel = v_getpixel##bpp; \ vl_rect = v_rect##bpp; \ vl_mixfix = vl_mixfix##bpp; \ vl_mixrgb = vl_mixrgb##bpp; \ @@ -413,6 +455,7 @@ static int vl_setup_mode (vl_mode *p) #undef INITPTR + video_mode = p; video_bypp = (p->bpp+7)/8; video_scanlen = p->scanlen; vl_video_selector = p->sel; @@ -476,8 +519,8 @@ int vl_video_init (int width, int height, int bpp, int rgb, int refresh) } } - /* check, setup and enter mode */ - if ((p!=NULL) && (vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) { + /* setup and enter mode */ + if ((vl_setup_mode(p) == 0) && (drv->entermode(p, refresh) == 0)) { vl_flip = drv->blit; if (fake) { min = drv->getCIprec(); diff --git a/src/mesa/drivers/dos/video.h b/src/mesa/drivers/dos/video.h index 3197338e63..8dfb9a9176 100644 --- a/src/mesa/drivers/dos/video.h +++ b/src/mesa/drivers/dos/video.h @@ -45,11 +45,12 @@ extern void (*vl_clear) (int color); extern void (*vl_rect) (int x, int y, int width, int height, int color); extern void (*vl_flip) (void); extern void (*vl_putpixel) (unsigned int offset, int color); +extern int (*vl_getpixel) (unsigned int offset); void vl_setCI (int index, float red, float green, float blue); -int vl_getCIpixel (unsigned int offset); -void *vl_sync_buffer (void *buffer, int x, int y, int width, int height); +int vl_sync_buffer (void **buffer, int x, int y, int width, int height); +void vl_get_screen_size (int *width, int *height); void vl_video_exit (void); int vl_video_init (int width, int height, int bpp, int rgb, int refresh); diff --git a/src/mesa/drivers/dos/virtual.S b/src/mesa/drivers/dos/virtual.S index 4dbbbb3e3f..c5a72975fe 100644 --- a/src/mesa/drivers/dos/virtual.S +++ b/src/mesa/drivers/dos/virtual.S @@ -107,13 +107,12 @@ _v_clear_common: .p2align 5,,31 .global _v_clear8_mmx _v_clear8_mmx: - movl 4(%esp), %eax - movb %al, %ah - pushw %ax - pushw %ax - pushw %ax - pushw %ax +#ifdef USE_MMX_ASM + movq 4(%esp), %mm0 + punpcklbw %mm0, %mm0 + punpcklwd %mm0, %mm0 jmp _v_clear_common_mmx +#endif /* Desc: void v_clear16_mmx (int color); * @@ -125,12 +124,11 @@ _v_clear8_mmx: .p2align 5,,31 .global _v_clear16_mmx _v_clear16_mmx: - movl 4(%esp), %eax - pushw %ax - pushw %ax - pushw %ax - pushw %ax +#ifdef USE_MMX_ASM + movq 4(%esp), %mm0 + punpcklwd %mm0, %mm0 jmp _v_clear_common_mmx +#endif /* Desc: void v_clear32_mmx (int color); * @@ -142,15 +140,13 @@ _v_clear16_mmx: .p2align 5,,31 .global _v_clear32_mmx _v_clear32_mmx: - movl 4(%esp), %eax - pushl %eax - pushl %eax +#ifdef USE_MMX_ASM + movq 4(%esp), %mm0 .balign 4 _v_clear_common_mmx: -#ifdef USE_MMX_ASM + punpckldq %mm0, %mm0 movl _vl_current_bytes, %ecx movl _vl_current_draw_buffer, %edx - movq (%esp), %mm0 shrl $3, %ecx .balign 4 0: @@ -160,7 +156,6 @@ _v_clear_common_mmx: jnz 0b emms #endif - addl $8, %esp ret /* Desc: void v_clear24 (int color); diff --git a/src/mesa/main/Makefile.DJ b/src/mesa/main/Makefile.DJ index 9bbbec6bb2..cabeff1036 100644 --- a/src/mesa/main/Makefile.DJ +++ b/src/mesa/main/Makefile.DJ @@ -1,7 +1,7 @@ # Mesa 3-D graphics library -# Version: 5.1 +# Version: 4.1 # -# Copyright (C) 1999-2003 Brian Paul All Rights Reserved. +# Copyright (C) 1999-2002 Brian Paul All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -20,7 +20,7 @@ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# DOS/DJGPP core makefile v1.3 for Mesa 5.1 +# DOS/DJGPP core makefile v1.3 for Mesa 5.0 # # Copyright (C) 2002 - Borca Daniel # Email : dborca@yahoo.com @@ -33,18 +33,18 @@ # Environment variables: # CFLAGS # -# GLIDE absolute path to Glide SDK; used with FX. +# GLIDE path to Glide3 SDK include files; used with FX. # default = $(TOP)/include/glide3 -# FX=1 build for 3dfx Glide3; use it if you have the glide -# SDK (designed for your platform), and, of course, a -# 3dfx card... Note that this disables compilation of -# actual DMesa code, as Glide does all the stuff! +# FX=1 build for 3dfx Glide3. Note that this disables +# compilation of most DMesa code and requires fxMesa. +# As a consequence, you'll need the DJGPP Glide3 +# library to build any application. # default = no # HAVE_X86=1 optimize for i386. # default = no -# HAVE_MMX=1 MMX instructions; use only if you assembler/compiler -# supports MMX instruction set; backwards compatibility -# with older processors is still preserved. +# HAVE_MMX=1 allow MMX specializations, provided your assembler +# supports MMX instruction set. However, the true CPU +# capabilities are checked at run-time to avoid crashes. # default = no # HAVE_SSE=1 (see HAVE_MMX) # default = no @@ -119,10 +119,6 @@ CORE_SOURCES = \ lines.c \ matrix.c \ mmath.c \ - nvprogram.c \ - nvfragparse.c \ - nvvertexec.c \ - nvvertparse.c \ pixel.c \ points.c \ polygon.c \ @@ -136,6 +132,10 @@ CORE_SOURCES = \ texstate.c \ texstore.c \ texutil.c \ + varray.c \ + vpexec.c \ + vpparse.c \ + vpstate.c \ vtxfmt.c \ math/m_debug_clip.c \ math/m_debug_norm.c \ @@ -166,7 +166,6 @@ CORE_SOURCES = \ swrast/s_lines.c \ swrast/s_logic.c \ swrast/s_masking.c \ - swrast/s_nvfragprog.c \ swrast/s_pixeltex.c \ swrast/s_points.c \ swrast/s_readpix.c \ @@ -297,9 +296,9 @@ ifeq ($(DXE3GEN),) $(warning somewhere in PATH, and DXE3.LD in DJGPP/LIB directory.) else ifdef FX - -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL/FX DJGPP" -E gl -E DMesa -X -P glid3.dxe -U $(OBJECTS) + -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL/FX DJGPP" -E _gl -E _DMesa -P glid3.dxe -U $(OBJECTS) else - -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL DJGPP" -E gl -E DMesa -X -U $(OBJECTS) + -dxe3gen -o $(LIBDIR)/$(GL_DXE) -I $(LIBDIR)/$(GL_IMP) -D "MesaGL DJGPP" -E _gl -E _DMesa -U $(OBJECTS) endif endif -- cgit v1.2.3