Linux redivivus

This commit is contained in:
dborca
2003-10-10 09:53:30 +00:00
parent 29570c57c4
commit c9a74b1b17
5 changed files with 321 additions and 107 deletions

View File

@@ -1868,7 +1868,7 @@ _GlideInitEnvironment(int which)
/* Get CPU Info */ /* Get CPU Info */
_cpuid (&_GlideRoot.CPUType); _cpuid (&_GlideRoot.CPUType);
#if !(GLIDE_PLATFORM & GLIDE_OS_UNIX) #if !DRI_BUILD
/* Pass retrieved CPU Info into minihwc */ /* Pass retrieved CPU Info into minihwc */
hwcSetCPUInfo(&_GlideRoot.CPUType); hwcSetCPUInfo(&_GlideRoot.CPUType);
#endif #endif

View File

@@ -2791,7 +2791,7 @@ GR_EXT_ENTRY(grSstWinOpenExt, GrContext_t, ( FxU32 hWnd,
gcFifo->fifoRead = HW_FIFO_PTR( FXTRUE ); gcFifo->fifoRead = HW_FIFO_PTR( FXTRUE );
#endif /* USE_PACKET_FIFO */ #endif /* USE_PACKET_FIFO */
#if !(GLIDE_PLATFORM & GLIDE_OS_UNIX) #if !DRI_BUILD
if ( (void*)gcFifo->fifoPtr != (void*)gcFifo->fifoRead ) { if ( (void*)gcFifo->fifoPtr != (void*)gcFifo->fifoRead ) {
#ifdef GLIDE_INIT_HWC #ifdef GLIDE_INIT_HWC
hwcRestoreVideo( bInfo ); hwcRestoreVideo( bInfo );
@@ -2799,7 +2799,7 @@ GR_EXT_ENTRY(grSstWinOpenExt, GrContext_t, ( FxU32 hWnd,
GDBG_INFO( gc->myLevel, "Initial fifo state is incorrect\n" ); GDBG_INFO( gc->myLevel, "Initial fifo state is incorrect\n" );
return 0; return 0;
} }
#endif /* GLIDE_PLATFORM & GLIDE_OS_UNIX */ #endif /* DRI_BUILD */
#if __POWERPC__ && PCI_BUMP_N_GRIND #if __POWERPC__ && PCI_BUMP_N_GRIND
enableCopyBackCache((FxU32)gcFifo->fifoStart,gcFifo->fifoSize); enableCopyBackCache((FxU32)gcFifo->fifoStart,gcFifo->fifoSize);
@@ -3204,9 +3204,12 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context))
*/ */
GDBG_INFO(gc->myLevel, " Restore Video\n"); GDBG_INFO(gc->myLevel, " Restore Video\n");
#if !(GLIDE_PLATFORM & GLIDE_OS_UNIX) #if !(GLIDE_PLATFORM & GLIDE_OS_UNIX)
if (!*gc->lostContext) { if (!*gc->lostContext)
#endif /* !(GLIDE_PLATFORM & GLIDE_OS_UNIX) */
#if !DRI_BUILD
/* disable SLI and AA */ /* disable SLI and AA */
#ifdef FX_GLIDE_NAPALM #ifdef FX_GLIDE_NAPALM
{
if (IS_NAPALM(gc->bInfo->pciInfo.deviceID)) { if (IS_NAPALM(gc->bInfo->pciInfo.deviceID)) {
_grChipMask( SST_CHIP_MASK_ALL_CHIPS ); _grChipMask( SST_CHIP_MASK_ALL_CHIPS );
_grTex2ppc(FXFALSE); _grTex2ppc(FXFALSE);
@@ -3224,7 +3227,7 @@ GR_ENTRY(grSstWinClose, FxBool, (GrContext_t context))
#endif #endif
hwcRestoreVideo(gc->bInfo); hwcRestoreVideo(gc->bInfo);
} }
#endif /* !(GLIDE_PLATFORM & GLIDE_OS_UNIX) */ #endif /* !DRI_BUILD */
#endif /* !GLIDE_INIT_HAL */ #endif /* !GLIDE_INIT_HAL */
/*-------------------------- /*--------------------------

View File

@@ -1,104 +1,57 @@
# Linux tests makefile for Glide3
# #
# THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY # Copyright (c) 2002 - Borca Daniel
# PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT # Email : dborca@users.sourceforge.net
# TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX # Web : http://www.geocities.com/dborca
# INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE #
# DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). # $Header$
# THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
# EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
# FULL TEXT OF THE NON-WARRANTY PROVISIONS.
#
# USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
# RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
# TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
# AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
# SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
# THE UNITED STATES.
#
# COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
# #
LDIRT= $(wildcard test?? *.o lib*)
# Special case rush because its built off of the sst1 tree #
ifeq ($(FX_GLIDE_HW),SST96) # Available options:
GLIDE_ROOT = $(BUILD_ROOT)/sst1 #
else # Environment variables:
GLIDE_ROOT = $(BUILD_ROOT)/$(FX_GLIDE_HW) # DGA=1 Build DGA version (experimental).
# default = no
# XPATH specify X libraries path; needed by DGA.
# default = /usr/X11/lib
# CPU optimize for the given processor.
# default = pentium
#
# Targets:
# <file.exe> build a specific file
#
.PHONY: all
.SUFFIXES: .c .o .exe
.SECONDARY: tlib.o
FX_GLIDE_HW = h5
TOP = ../../..
CPU ?= pentium
XPATH ?= /usr/X11/lib
CC = gcc
CFLAGS = -Wall -O2 -ffast-math -mcpu=$(CPU)
CFLAGS += -Iinclude
CFLAGS += -DH3
CFLAGS += -DFX_GLIDE_NAPALM=1
LDFLAGS = -s -Llib
LDLIBS = -lglide3
ifeq ($(DGA),1)
LDFLAGS += -L$(XPATH)
LDLIBS += -lX11 -lXext -lXxf86dga
endif endif
LDLIBS += -lm
LCINCS += -I$(GLIDE_ROOT)/include .c.o:
$(CC) -o $@ $(CFLAGS) -c $<
ifeq ($(FX_GLIDE_HW), h5) %.exe: tlib.o %.o
LCDEFS += -DFX_GLIDE_NAPALM=1 $(CC) -o $@ $(LDFLAGS) $^ $(LDLIBS)
endif
LIBOBJS = tlib.o
GLIDELIB = -L$(GLIDE_ROOT)/lib -lglide3x
LLDLIBS = $(LIBOBJS) $(GLIDELIB)
PRIVATE_HEADERS = tlib.h tlib.c tldata.inc
CFILES = test00.c \
test01.c \
test02.c \
test03.c \
test04.c \
test05.c \
test06.c \
test07.c \
test08.c \
test09.c \
test10.c \
test11.c \
test12.c \
test13.c \
test14.c \
test15.c \
test16.c \
test17.c \
test18.c \
test19.c \
test20.c \
test21.c \
test22.c \
test23.c \
test24.c \
test25.c \
test26.c \
test27.c \
test28.c \
test29.c \
test30.c \
test31.c \
test32.c \
test33.c \
test34.c \
test35.c \
test36.c \
test37.c \
test38.c \
test39.c \
test40.c \
test41.c \
test42.c \
test43.c \
test44.c \
test45.c \
test46.c \
test47.c \
test48.c \
test49.c \
display.c \
sbench.c
PROGRAMS = $(CFILES:.c=)
DATAFILES = alpha.3df decal1.3df lava.3df light.3df matt1.3df miro.3df
include $(BUILD_ROOT)/swlibs/include/make/3dfx.mak
$(PROGRAMS): $(LIBOBJS)
all:
$(error Must specify <filename.exe> to build)

View File

@@ -0,0 +1,245 @@
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONL
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGH
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DF
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT T
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS I
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FA
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS O
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVE
**
** $Header$
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if USE_XDGA_SWITCH
#include <X11/Xlib.h>
#include <X11/extensions/xf86dga.h>
#include <X11/extensions/xf86vmode.h>
static Display *dpy = 0;
static XDGADevice *dev = 0;
static XDGAMode *vidModes = 0;
#endif
#include <minihwc.h>
#include <hwcio.h>
#include "h3cinit.h"
#include "glide.h"
#include "fxglide.h"
#define CFG_FILE "/etc/conf.3dfx/voodoo3"
static struct envitem_t {
char *env;
char *val;
struct envitem_t *next;
} *first = NULL;
static FxU32 saveVidProcCfg;
static FxU32 saveLfbMemoryConfig;
static FxU32 saveMiscInit0;
FxBool setVideoMode(void *hwnd,
int xRes,
int yRes,
int h3pixelSize,
int refresh,
void *hmon,
char *regpath,
char *devicename)
{
GR_DCL_GC;
hwcBoardInfo *bInfo = gc->bInfo;
#if USE_XDGA_SWITCH
int eventbase, errorbase;
int i, numModes;
dpy=XOpenDisplay("");
if (!dpy) {
GDBG_INFO(80, "Failed to open X display\n");
return FXFALSE;
}
if (XDGAQueryExtension(dpy, &eventbase, &errorbase)) {
int major, minor;
XDGAQueryVersion(dpy, &major, &minor);
if (major>1 && minor<0) {
XCloseDisplay(dpy);
GDBG_INFO(80, "Banshee/V3 requires DGA version 1.x\n");
return FXFALSE;
}
}
vidModes = XDGAQueryModes(dpy, DefaultScreen(dpy), &numModes);
for (i=0; i<numModes; i++)
if ((vidModes[i].viewportWidth==xRes) &&
(vidModes[i].viewportHeight==yRes))
break;
if (i==numModes) {
GDBG_INFO(80, "Server doesn't support requested resolution\n");
vidModes=0;
return FXFALSE;
}
if ((dev = XDGASetMode(dpy, DefaultScreen(dpy), vidModes[i].num)) == NULL) {
GDBG_INFO(80, "Failed to set required video mode\n");
return FXFALSE;
}
XDGASync(dpy, False);
#else
if (!h3InitSetVideoMode(bInfo->regInfo.ioPortBase, xRes, yRes, refresh, FXTRUE)) {
GDBG_INFO(80, "Setmode failed -- unimplemented resolution\n");
return FXFALSE;
}
#endif
HWC_IO_LOAD(bInfo->regInfo, vidProcCfg, saveVidProcCfg);
HWC_IO_LOAD(bInfo->regInfo, lfbMemoryConfig, saveLfbMemoryConfig);
HWC_IO_LOAD(bInfo->regInfo, miscInit0, saveMiscInit0);
return FXTRUE;
} /* setVideoMode */
void resetVideo (void)
{
GR_DCL_GC;
hwcBoardInfo *bInfo = gc->bInfo;
HWC_IO_STORE(bInfo->regInfo, lfbMemoryConfig, saveLfbMemoryConfig);
HWC_IO_STORE(bInfo->regInfo, vidProcCfg, saveVidProcCfg);
HWC_IO_STORE(bInfo->regInfo, miscInit0, saveMiscInit0);
#if USE_XDGA_SWITCH
if (dpy) {
if (!XDGASetMode(dpy, DefaultScreen(dpy), 0)) {
GDBG_INFO(80, "Failed to return to previous video mode\n");
}
vidModes = NULL;
XCloseDisplay(dpy);
dpy = NULL;
XFree(dev);
}
#else
/* XXX to do */
#endif
GDBG_INFO(80, "resetVideo(): \n");
} /* resetVideo */
static void loadEnvFile (void)
{
FILE *file;
char data[256];
char *env, *val;
struct envitem_t *item;
FxBool sawError = FXFALSE;
static FxBool envinit = FXFALSE;
if (envinit) {
return;
}
envinit = FXTRUE;
if ((file = fopen(CFG_FILE, "r")) == NULL) {
return;
}
while (fgets(data, 255, file) != NULL) {
if ((*data=='#') || (*data=='\n')) {
continue;
}
if ((val = strchr(data, '=')) == NULL) {
if (!sawError) {
sawError = FXTRUE;
fprintf(stderr, "In config file " CFG_FILE ":\n");
}
fprintf(stderr, "Malformed line: %s\n", data);
continue;
}
*val++ = '\0';
env = data;
item = malloc(sizeof(struct envitem_t));
item->env = malloc(strlen(env)+1);
strcpy(item->env, env);
item->val = malloc(strlen(val)+1);
strcpy(item->val, val);
item->next = first;
first = item;
}
}
char *file_getenv (const char *a)
{
struct envitem_t *ptr;
char *result;
if ((result = getenv(a)) != NULL) {
return result;
}
loadEnvFile();
for (ptr = first; ptr != NULL; ptr = ptr->next) {
if (!strcmp(ptr->env, a)) {
return ptr->val;
}
}
return NULL;
}
void hwcSetSLIAAMode(hwcBoardInfo *bInfo,
FxU32 sliEnable,
FxU32 aaEnable,
FxU32 analogSLI,
FxU32 sliBandHeight,
FxU32 totalMem,
FxU32 numChips,
FxU32 aaSampleHigh,
FxU32 aaColorBuffStart,
FxU32 aaDepthBuffStart,
FxU32 aaDepthBuffEnd,
FxU32 bpp)
{
/* XXX to do */
}
#include <linutil.h>
/*-------------------------------------------------------------------
Function: tlKbHit
Date: 2/28
Implementor(s): jdt
Library: test library
Description:
Returns true if there are pending characters in the input queue
Arguments:
none
Return:
nonzero if keys in queue
-------------------------------------------------------------------*/
int hwcKbHit( void ) {
return lin_kbhit();
}
char hwcGetCH( void ) {
return lin_getch();
}

View File

@@ -749,6 +749,7 @@
#include <math.h> #include <math.h>
#include <3dfx.h> #include <3dfx.h>
#include <glide.h>
#ifdef HWC_EXT_INIT #ifdef HWC_EXT_INIT
#include "hwcext.h" #include "hwcext.h"
@@ -873,13 +874,11 @@ typedef struct sli_aa_request {
#endif #endif
//#if defined(HWC_EXT_INIT) //#if defined(HWC_EXT_INIT)
#ifndef __DJGPP__ #if !defined(__DJGPP__) && !(GLIDE_PLATFORM & GLIDE_OS_UNIX)
#define GETENV(a, b) hwcGetenvEx(a, b) #define GETENV(a, b) hwcGetenvEx(a, b)
#else #else
#define GETENV(a, b) hwcGetenv(a) #define GETENV(a, b) hwcGetenv(a)
#endif
#ifdef __DJGPP__
#define _aligned_malloc(a, b) malloc(a) #define _aligned_malloc(a, b) malloc(a)
#define _aligned_free free #define _aligned_free free
/* don't like macros, because of side-effects */ /* don't like macros, because of side-effects */
@@ -1032,6 +1031,8 @@ modify [eax];
#define P6FENCE __sync() #define P6FENCE __sync()
#elif defined(__DJGPP__) || defined (__MINGW32__) #elif defined(__DJGPP__) || defined (__MINGW32__)
#define P6FENCE __asm __volatile ("xchg %%eax, _fenceVar":::"%eax") #define P6FENCE __asm __volatile ("xchg %%eax, _fenceVar":::"%eax")
#elif (GLIDE_PLATFORM & GLIDE_OS_UNIX)
#define P6FENCE __asm __volatile ("xchg %%eax, fenceVar":::"%eax")
#else #else
#error "P6 Fencing in-line assembler code needs to be added for this compiler" #error "P6 Fencing in-line assembler code needs to be added for this compiler"
#endif /* Compiler specific fence commands */ #endif /* Compiler specific fence commands */
@@ -1838,6 +1839,7 @@ hwcInit(FxU32 vID, FxU32 dID)
if(IS_NAPALM(hInfo.boardInfo[i].pciInfo.deviceID)) { if(IS_NAPALM(hInfo.boardInfo[i].pciInfo.deviceID)) {
FxU32 device_vendor; FxU32 device_vendor;
#if !(GLIDE_PLATFORM & GLIDE_OS_UNIX) /* [dBorca] Hack alert: TODO bare Linux SLI */
/* Detect two-chip board */ /* Detect two-chip board */
device_vendor = hwcReadConfigRegister(&hInfo.boardInfo[i], 1, offsetof(SstPCIConfigRegs, deviceID_vendorID)); device_vendor = hwcReadConfigRegister(&hInfo.boardInfo[i], 1, offsetof(SstPCIConfigRegs, deviceID_vendorID));
if((device_vendor & 0xFFFF) == 0x121a && (IS_NAPALM((device_vendor >> 16)))) { if((device_vendor & 0xFFFF) == 0x121a && (IS_NAPALM((device_vendor >> 16)))) {
@@ -1864,6 +1866,7 @@ hwcInit(FxU32 vID, FxU32 dID)
hInfo.boardInfo[i].pciInfo.pciBaseAddr[(chip << 2) + 2] = hInfo.boardInfo[i].pciInfo.pciBaseAddr[(chip << 2) + 2] =
hwcReadConfigRegister(&hInfo.boardInfo[i], chip, offsetof(SstPCIConfigRegs, ioBaseAddr)); hwcReadConfigRegister(&hInfo.boardInfo[i], chip, offsetof(SstPCIConfigRegs, ioBaseAddr));
} }
#endif
} }
// Save realNumChips // Save realNumChips
@@ -2020,6 +2023,9 @@ hwcMapBoard(hwcBoardInfo *bInfo, FxU32 bAddrMask)
bAddr, length; bAddr, length;
bInfo->isMapped = FXTRUE; bInfo->isMapped = FXTRUE;
/* [dBorca] Hack alert:
bInfo->procHandle = getpid();
*/
if (IS_NAPALM(bInfo->pciInfo.deviceID)) if (IS_NAPALM(bInfo->pciInfo.deviceID))
length = 32*1024*1024; length = 32*1024*1024;
@@ -4404,7 +4410,7 @@ hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo *vidTiming,
} }
#endif #endif
#ifdef __DOS32__ #ifndef __WIN32__ /* DOS and Linux */
/* Now call the cinit code */ /* Now call the cinit code */
h3InitVideoOverlaySurface( h3InitVideoOverlaySurface(
@@ -5408,7 +5414,7 @@ hwcInitVideo(hwcBoardInfo *bInfo, FxBool tiled, FxVideoTimingInfo *vidTiming,
HWC_IO_STORE(bInfo->regInfo, pciInit0, pciInit0); HWC_IO_STORE(bInfo->regInfo, pciInit0, pciInit0);
} }
#ifdef __DJGPP__ #if defined(__DJGPP__) || (GLIDE_PLATFORM & GLIDE_OS_UNIX)
HWC_IO_STORE(bInfo->regInfo, vidProcCfg, vidProcCfg | SST_VIDEO_PROCESSOR_EN); HWC_IO_STORE(bInfo->regInfo, vidProcCfg, vidProcCfg | SST_VIDEO_PROCESSOR_EN);
#endif #endif
@@ -6900,6 +6906,7 @@ FxU32 hwcAAReadRegion16(hwcBoardInfo *bInfo, FxU32 colBufNum,
/* Gamma table */ /* Gamma table */
FxU32 gss_red[256], gss_green[256], gss_blue[256], gss_red_shifted[256]; FxU32 gss_red[256], gss_green[256], gss_blue[256], gss_red_shifted[256];
/*ZZZ*/FxU32 _gss_red[256], _gss_green[256], _gss_blue[256], _gss_red_shifted[256];
static void hwcCopyBuffer8888Flipped(hwcBoardInfo *bInfo, FxU16 *source, int w, int h, FxU8 *dst, int aaShift) static void hwcCopyBuffer8888Flipped(hwcBoardInfo *bInfo, FxU16 *source, int w, int h, FxU8 *dst, int aaShift)
{ {
@@ -8807,6 +8814,12 @@ char *
hwcGetenv(const char *a) hwcGetenv(const char *a)
{ {
return hwcGetenvEx(a, opengl_regpath); return hwcGetenvEx(a, opengl_regpath);
#elif (GLIDE_PLATFORM & GLIDE_OS_UNIX)
extern char *file_getenv (const char *a);
char *
hwcGetenv(const char *a)
{
return file_getenv(a);
#else #else
char * char *
hwcGetenv(const char *a) hwcGetenv(const char *a)