Commit 3a3e63dc authored by Daniel Borca Borca's avatar Daniel Borca Borca

DMesa now uses OSMesa as a back-end.

parent 3a46dff2
......@@ -20,9 +20,9 @@
# 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 makefile v1.6 for Mesa
# DOS/DJGPP makefile for Mesa
#
# Copyright (C) 2002 - Daniel Borca
# Author: Daniel Borca
# Email : dborca@users.sourceforge.net
# Web : http://www.geocities.com/dborca
......@@ -31,9 +31,6 @@
# Available options:
#
# Environment variables:
# GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
# or `mesa'.
# default = mesa
# GLIDE path to Glide3 SDK; used with FX.
# default = $(TOP)/glide3
# FX=1 build for 3dfx Glide3. Note that this disables
......@@ -57,8 +54,6 @@
.PHONY : all libgl libglu libglut clean realclean
GLU ?= mesa
CFLAGS = -Wall -W -pedantic
CFLAGS += -O2 -ffast-math
......@@ -75,7 +70,7 @@ all: libgl libglu libglut
libgl: lib
$(MAKE) -f Makefile.DJ -C src/mesa
libglu: lib
$(MAKE) -f Makefile.DJ -C src/glu/$(GLU)
$(MAKE) -f Makefile.DJ -C src/glu/sgi
libglut: lib
$(MAKE) -f Makefile.DJ -C src/glut/dos
......
Mesa 6.3 DOS/DJGPP Port v1.7
Mesa 6.5 DOS/DJGPP Port v1.8
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -7,8 +7,7 @@ Description:
~~~~~~~~~~~~
Well, guess what... this is the DOS port of Mesa 6.3, for DJGPP fans... Whoa!
The driver has its origins in ddsample.c, written by Brian Paul and found by me
in Mesa 3.4.2.
The driver uses OSMesa to draw off screen, and then blits the buffer.
......@@ -32,9 +31,6 @@ Available options:
Environment variables:
CPU optimize for the given processor.
default = pentium
GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
or `mesa'.
default = mesa
GLIDE path to Glide3 SDK; used with FX.
default = $(TOP)/glide3
FX=1 build for 3dfx Glide3. Note that this disables
......@@ -56,11 +52,9 @@ Available options:
Tested on:
CPU: AMD Athlon XP 1800+
Mainboard: GA-7VTXE w/ 512 MB DDRAM
Video card: Voodoo5 6000 AGP w/ 128 MB SDRAM
DJGPP: djdev 2.04 + gcc v3.4.3 + make v3.80
OS: DOS and Win98SE
Video card: Radeon 9500
DJGPP: djdev 2.04 + gcc v4.1.0 + make v3.80
OS: DOS, Win98SE, WinXP (using Videoport driver)
......@@ -98,7 +92,7 @@ FAQ:
Q) DMesa is so SLOOOW! The Win32 OpenGL performs so much better...
A) Is that a question? If you have a 3dfx Voodoo (any model), you're
lucky (check http://sourceforge.net/projects/glide for the DJGPP port).
If you haven't, sorry; everything is done in software. Suggestions?
If you haven't, sorry; everything is done in software.
Q) I tried to set refresh rate w/ DMesa, but without success.
A) Refresh rate control works only for VESA 3.0 and the 3dfx driver (in
......@@ -107,7 +101,8 @@ FAQ:
Q) I made a simple application and it does nothing. It exits right away. Not
even a blank screen.
A) Pure software drivers (VESA/VGA/NUL) support only double-buffered modes.
A) Software drivers (VESA/VGA/NUL) must to be constructed as single-buffered
visuals. However, DMesaSwapBuffers must be called to get any output.
A) Another weird "feature" is that buffer width must be multiple of 8 (I'm a
lazy programmer and I found that the easiest way to keep buffer handling
at peak performance ;-).
......@@ -265,6 +260,11 @@ v1.7 (???-2005)
* no more GLX sources in DOS GLUT
* made GLUT timer callbacks less accurate but safer
v1.8 (apr-2006)
* killed lots of code, the driver is now a front-end to OSMesa
* fixed problem with WinNT (http://www.volny.cz/martin.sulak/)
- removed 3dfx Glide3 support (temporarily?)
Contact:
......
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.7 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Daniel Borca
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
......@@ -35,7 +35,7 @@
#define DMESA_H_included
#define DMESA_MAJOR_VERSION 6
#define DMESA_MINOR_VERSION 3
#define DMESA_MINOR_VERSION 5
/* Sample Usage:
*
......@@ -138,7 +138,7 @@ void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);
/*
* DMesa functions
*/
typedef void (*DMesaProc) (void);
typedef void (*DMesaProc) ();
DMesaProc DMesaGetProcAddress (const char *name);
/*
......@@ -149,8 +149,8 @@ DMesaProc DMesaGetProcAddress (const char *name);
#define DMESA_GET_VIDEO_MODES 0x0300
#define DMESA_GET_BUFFER_ADDR 0x0400
#define DMESA_DRIVER_SWDB_BIT 0x1 /* software double-buffered */
#define DMESA_DRIVER_LLWO_BIT 0x2 /* lower-left window origin */
#define DMESA_DRIVER_DBL_BIT 0x1 /* double-buffered */
#define DMESA_DRIVER_YUP_BIT 0x2 /* lower-left window origin */
int DMesaGetIntegerv (GLenum pname, GLint *params);
#ifdef __cplusplus
......
......@@ -66,6 +66,10 @@ glutCreateWindow (const char *title)
int i;
int m8width = (_glut_default.width + 7) & ~7;
if (!(_glut_default.mode & GLUT_DOUBLE)) {
return 0;
}
/* We set the Visual once. This will be our desktop (graphic mode).
* We should do this in the `glutInit' code, but we don't have any idea
* about its geometry. Supposedly, when we are about to create one
......@@ -73,7 +77,7 @@ glutCreateWindow (const char *title)
*/
if (!visual) {
if ((visual=DMesaCreateVisual(_glut_default.x + m8width, _glut_default.y + _glut_default.height, _glut_visual.bpp, _glut_visual.refresh,
_glut_default.mode & GLUT_DOUBLE,
GLUT_SINGLE,
!(_glut_default.mode & GLUT_INDEX),
(_glut_default.mode & GLUT_ALPHA ) ? _glut_visual.alpha : 0,
(_glut_default.mode & GLUT_DEPTH ) ? _glut_visual.depth : 0,
......
......@@ -103,8 +103,8 @@ DRIVER_SOURCES += \
$(GLIDE_DRIVER_SOURCES)
else
DRIVER_SOURCES += \
$(OSMESA_DRIVER_SOURCES) \
drivers/dos/video.c \
drivers/dos/virtual.S \
drivers/dos/vesa.c \
drivers/dos/blit.S \
drivers/dos/vga.c \
......@@ -112,8 +112,6 @@ DRIVER_SOURCES += \
drivers/dos/dpmi.c
endif
#DRIVER_SOURCES += $(OSMESA_DRIVER_SOURCES)
SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
......
This diff is collapsed.
This diff is collapsed.
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.5 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
......
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.6 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
......@@ -54,6 +54,8 @@ typedef unsigned long word32;
#define _16_ *(word16 *)&
#define _32_ *(word32 *)&
typedef void (*BLTFUNC) (void);
/*
* video mode structure
......@@ -75,7 +77,7 @@ typedef struct vl_mode {
*/
typedef struct {
vl_mode *(*init) (void);
int (*entermode) (vl_mode *p, int refresh);
int (*entermode) (vl_mode *p, int refresh, int fbbits);
void (*blit) (void);
void (*setCI_f) (int index, float red, float green, float blue);
void (*setCI_i) (int index, int red, int green, int blue);
......@@ -100,32 +102,4 @@ void _remove_selector (int *segment);
int _can_mmx (void);
/*
* asm routines to deal with virtual buffering
*/
extern void v_clear8 (int color);
#define v_clear15 v_clear16
extern void v_clear16 (int color);
extern void v_clear24 (int color);
extern void v_clear32 (int color);
extern void v_clear8_mmx (int color);
#define v_clear15_mmx v_clear16_mmx
extern void v_clear16_mmx (int color);
extern void v_clear24_mmx (int color);
extern void v_clear32_mmx (int color);
extern void v_rect8 (int x, int y, int width, int height, int color);
#define v_rect15 v_rect16
extern void v_rect16 (int x, int y, int width, int height, int color);
extern void v_rect24 (int x, int y, int width, int height, int color);
extern void v_rect32 (int x, int y, int width, int height, int color);
extern void v_putpixel8 (unsigned int offset, int color);
#define v_putpixel15 v_putpixel16
extern void v_putpixel16 (unsigned int offset, int color);
extern void v_putpixel24 (unsigned int offset, int color);
extern void v_putpixel32 (unsigned int offset, int color);
#endif
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.7 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
......@@ -137,13 +137,13 @@ null_fini (void)
* Note: -
*/
static int
null_entermode (vl_mode *p, int refresh)
null_entermode (vl_mode *p, int refresh, int fbbits)
{
NUL.blit = null_blit_nop;
return 0;
(void)(p && refresh); /* silence compiler warning */
(void)(p && refresh && fbbits); /* silence compiler warning */
}
......
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.6 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
......
This diff is collapsed.
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.3 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
......@@ -42,6 +42,24 @@ extern void vesa_b_dump_virtual (void);
extern void vesa_l_dump_virtual (void);
extern void vesa_l_dump_virtual_mmx (void);
extern void vesa_l_dump_32_to_24 (void);
extern void vesa_l_dump_32_to_16 (void);
extern void vesa_l_dump_32_to_15 (void);
extern void vesa_l_dump_32_to_8 (void);
extern void vesa_l_dump_24_to_32 (void);
extern void vesa_l_dump_24_to_8 (void);
extern void vesa_l_dump_16_to_15 (void);
extern void vesa_l_dump_16_to_8 (void);
extern void vesa_b_dump_32_to_24 (void);
extern void vesa_b_dump_32_to_16 (void);
extern void vesa_b_dump_32_to_15 (void);
extern void vesa_b_dump_32_to_8 (void);
extern void vesa_b_dump_24_to_32 (void);
extern void vesa_b_dump_24_to_8 (void);
extern void vesa_b_dump_16_to_15 (void);
extern void vesa_b_dump_16_to_8 (void);
extern vl_driver VESA;
#endif
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.7 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
......@@ -123,6 +123,41 @@ vga_fini (void)
}
/* Desc: Attempts to choose a suitable blitter.
*
* In : ptr to mode structure, software framebuffer bits
* Out : blitter funciton, or NULL
*
* Note: -
*/
static BLTFUNC
_choose_blitter (vl_mode *p, int fbbits)
{
BLTFUNC blitter;
switch (fbbits) {
case 8:
blitter = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
break;
case 16:
blitter = vesa_l_dump_16_to_8;
break;
case 24:
blitter = vesa_l_dump_24_to_8;
break;
case 32:
blitter = vesa_l_dump_32_to_8;
break;
default:
return NULL;
}
return blitter;
(void)p;
}
/* Desc: Attempts to enter specified video mode.
*
* In : ptr to mode structure, refresh rate
......@@ -131,27 +166,31 @@ vga_fini (void)
* Note: -
*/
static int
vga_entermode (vl_mode *p, int refresh)
vga_entermode (vl_mode *p, int refresh, int fbbits)
{
if (!(p->mode & 0x4000)) {
return -1;
}
VGA.blit = _can_mmx() ? vesa_l_dump_virtual_mmx : vesa_l_dump_virtual;
if (!(p->mode & 0x4000)) {
return -1;
}
if (oldmode == -1) {
__asm("\n\
VGA.blit = _choose_blitter(p, fbbits);
if (VGA.blit == NULL) {
return !0;
}
if (oldmode == -1) {
__asm("\n\
movb $0x0f, %%ah \n\
int $0x10 \n\
andl $0xff, %%eax \n\
movl %%eax, %0 \n\
":"=g"(oldmode)::"%eax", "%ebx");
}
":"=g"(oldmode)::"%eax", "%ebx");
}
__asm("int $0x10"::"a"(p->mode&0xff));
__asm("int $0x10"::"a"(p->mode&0xff));
return 0;
return 0;
(void)refresh; /* silence compiler warning */
(void)refresh; /* silence compiler warning */
}
......
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.3 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
......
This diff is collapsed.
......@@ -23,9 +23,9 @@
*/
/*
* DOS/DJGPP device driver v1.5 for Mesa
* DOS/DJGPP device driver for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Author: Daniel Borca
* Email : dborca@users.sourceforge.net
* Web : http://www.geocities.com/dborca
*/
......@@ -43,16 +43,7 @@ typedef int fixed;
#define VL_GET_SCREEN_SIZE 0x0202
#define VL_GET_VIDEO_MODES 0x0300
extern int (*vl_mixfix) (fixed r, fixed g, fixed b);
extern int (*vl_mixrgb) (const unsigned char rgb[]);
extern int (*vl_mixrgba) (const unsigned char rgba[]);
extern void (*vl_getrgba) (unsigned int offset, unsigned char rgba[4]);
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);
......@@ -60,6 +51,6 @@ int vl_sync_buffer (void **buffer, int x, int y, int width, int height);
int vl_get (int pname, int *params);
void vl_video_exit (void);
int vl_video_init (int width, int height, int bpp, int rgb, int refresh);
int vl_video_init (int width, int height, int bpp, int rgb, int refresh, int fbbits);
#endif
/*
* Mesa 3-D graphics library
* Version: 4.0
*
* Copyright (C) 1999 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"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* 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 device driver v1.3 for Mesa
*
* Copyright (C) 2002 - Borca Daniel
* Email : dborca@yahoo.com
* Web : http://www.geocities.com/dborca
*/
.file "virtual.S"
/*
* extern void *vl_current_draw_buffer;
* extern int vl_current_width, vl_current_bytes;
*/
.text
/* Desc: void v_clear8 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear8
_v_clear8:
movl 4(%esp), %eax
movb %al, %ah
pushw %ax
pushw %ax
popl %eax
jmp _v_clear_common
/* Desc: void v_clear16 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear16
_v_clear16:
movl 4(%esp), %eax
pushw %ax
pushw %ax
popl %eax
jmp _v_clear_common
/* Desc: void v_clear32 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear32
_v_clear32:
movl 4(%esp), %eax
.balign 4
_v_clear_common:
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
shrl $2, %ecx
.balign 4
0:
movl %eax, (%edx)
addl $4, %edx
decl %ecx
jnz 0b
ret
/* Desc: void v_clear8_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear8_mmx
_v_clear8_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
punpcklbw %mm0, %mm0
punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
#endif
/* Desc: void v_clear16_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear16_mmx
_v_clear16_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
punpcklwd %mm0, %mm0
jmp _v_clear_common_mmx
#endif
/* Desc: void v_clear32_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear32_mmx
_v_clear32_mmx:
#ifdef USE_MMX_ASM
movd 4(%esp), %mm0
.balign 4
_v_clear_common_mmx:
punpckldq %mm0, %mm0
movl _vl_current_bytes, %ecx
movl _vl_current_draw_buffer, %edx
shrl $3, %ecx
.balign 4
0:
movq %mm0, (%edx)
addl $8, %edx
decl %ecx
jnz 0b
emms
#endif
ret
/* Desc: void v_clear24 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear24
_v_clear24:
movl $0xaaaaaaab, %eax
mull _vl_current_bytes
movl 4(%esp), %eax
movl %edx, %ecx
pushl %ebx
movl _vl_current_draw_buffer, %edx
shrl %ecx
movb 10(%esp), %bl
.balign 4
0:
movw %ax, (%edx)
movb %bl, 2(%edx)
addl $3, %edx
decl %ecx
jnz 0b
popl %ebx
ret
/* Desc: void v_clear24_mmx (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_clear24_mmx
_v_clear24_mmx:
#ifdef USE_MMX_ASM
movl 4(%esp), %eax
movl %eax, %edx
movl %eax, %ecx
shll $16, %edx
rorl $8, %ecx
movw %cx, %dx
rorl $16, %ecx
movb %dh, %cl
shll $8, %eax
movb %ch, %al
rorl $8, %eax
pushl %edx
pushl %eax
movq (%esp), %mm0
pushl %ecx
movq (%esp), %mm1
pushl %edx
movq (%esp), %mm2
movl $0xaaaaaaab, %eax
mull _vl_current_bytes
movl %edx, %ecx
movl _vl_current_draw_buffer, %edx
shrl $4, %ecx
.balign 4
0:
movq %mm0, (%edx)
movq %mm1, 8(%edx)
movq %mm2, 16(%edx)
addl $24, %edx
decl %ecx
jnz 0b
emms
addl $16, %esp
#endif
ret
/* Desc: void v_rect8 (int color);
*
* In : color
* Out : -
*
* Note: uses current draw buffer
*/
.p2align 5,,31
.global _v_rect8
_v_rect8:
cld
pushl %esi
pushl %edi
movl 28(%esp), %eax
movl _vl_current_width, %esi
movl 16(%esp), %edi
movb %al, %ah
movl 20(%esp), %ecx