Ver código fonte

Kill off trident.

Hm. I could have said "chew trident and spit it out," or perhaps
"spear trident," instead. Dohoho.
tags/mesa_7_7_rc1
Corbin Simpson 17 anos atrás
pai
commit
fd7ee2bcb7

+ 1
- 1
configs/linux-dri Ver arquivo

@@ -64,4 +64,4 @@ GALLIUM_WINSYS_DRM_DIRS = intel
GALLIUM_STATE_TRACKERS_DIRS = egl

DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \
savage sis tdfx trident unichrome ffb swrast
savage sis tdfx unichrome ffb swrast

+ 1
- 1
configs/linux-dri-debug Ver arquivo

@@ -11,6 +11,6 @@ ARCH_FLAGS = -DDEBUG
#DRI_DIRS = i915tex i915
#DRI_DIRS = i965
#DRI_DIRS = radeon r200 r300
#DRI_DIRS = unichrome sis trident
#DRI_DIRS = unichrome sis
#DRI_DIRS = i810 mga r128 tdfx


+ 1
- 1
configs/linux-dri-xcb Ver arquivo

@@ -69,4 +69,4 @@ WINDOW_SYSTEM=dri
# gamma are missing because they have not been converted to use the new
# interface.
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \
savage sis tdfx trident unichrome ffb
savage sis tdfx unichrome ffb

+ 1
- 1
configure.ac Ver arquivo

@@ -769,7 +769,7 @@ if test "$mesa_driver" = dri; then
# default drivers
if test "x$DRI_DIRS" = "xyes"; then
DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \
savage sis tdfx trident unichrome ffb swrast"
savage sis tdfx unichrome ffb swrast"
fi

DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'`

+ 0
- 25
src/mesa/drivers/dri/trident/Makefile Ver arquivo

@@ -1,25 +0,0 @@
# src/mesa/drivers/dri/trident/Makefile

TOP = ../../../../..
include $(TOP)/configs/current

LIBNAME = trident_dri.so

# Not yet
# MINIGLX_SOURCES = server/trident_dri.c

DRIVER_SOURCES = \
trident_context.c \
trident_state.c \
trident_vb.c \
trident_dd.c \
trident_tris.c

C_SOURCES = \
$(COMMON_SOURCES) \
$(DRIVER_SOURCES)

ASM_SOURCES =

include ../Makefile.template


+ 0
- 465
src/mesa/drivers/dri/trident/trident_context.c Ver arquivo

@@ -1,465 +0,0 @@
/*
* Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Alan Hourihane not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Alan Hourihane makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
*
* Trident CyberBladeXP driver.
*
*/
#include "trident_dri.h"
#include "trident_context.h"
#include "trident_lock.h"

#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "vbo/vbo.h"

#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"

#include "main/context.h"
#include "main/simple_list.h"
#include "main/matrix.h"
#include "main/extensions.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/viewport.h"
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
#endif
#include "main/simple_list.h"
#include "main/mm.h"
#include "drirenderbuffer.h"

#include "drivers/common/driverfuncs.h"
#include "dri_util.h"
#include "utils.h"

static const struct tnl_pipeline_stage *trident_pipeline[] = {
&_tnl_vertex_transform_stage,
&_tnl_normal_transform_stage,
&_tnl_lighting_stage,
&_tnl_texgen_stage,
&_tnl_texture_transform_stage,
&_tnl_render_stage,
0,
};


static GLboolean
tridentCreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
tridentContextPtr tmesa;
tridentScreenPtr tridentscrn;
struct dd_function_table functions;
#if 0
drm_trident_sarea_t *saPriv=(drm_trident_sarea_t *)(((char*)sPriv->pSAREA)+
sizeof(XF86DRISAREARec));
#endif

tmesa = (tridentContextPtr) CALLOC( sizeof(*tmesa) );
if ( !tmesa ) return GL_FALSE;

/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((tridentContextPtr) sharedContextPrivate)->glCtx;
else
shareCtx = NULL;

_mesa_init_driver_functions(&functions);

tmesa->glCtx =
_mesa_create_context(glVisual, shareCtx, &functions, (void *)tmesa);

if (!tmesa->glCtx) {
FREE(tmesa);
return GL_FALSE;
}

tmesa->driContext = driContextPriv;
tmesa->driScreen = sPriv;
tmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */

tmesa->hHWContext = driContextPriv->hHWContext;
tmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
tmesa->driFd = sPriv->fd;
#if 0
tmesa->sarea = saPriv;
#endif

tridentscrn = tmesa->tridentScreen = (tridentScreenPtr)(sPriv->private);

ctx = tmesa->glCtx;

ctx->Const.MaxTextureLevels = 13; /* 4K by 4K? Is that right? */
ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */

ctx->Const.MinLineWidth = 0.0;
ctx->Const.MaxLineWidth = 255.0;

ctx->Const.MinLineWidthAA = 0.0;
ctx->Const.MaxLineWidthAA = 65536.0;

ctx->Const.MinPointSize = 0.0;
ctx->Const.MaxPointSize = 255.0;

ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */
ctx->Const.MaxPointSizeAA = 16.0;
ctx->Const.PointSizeGranularity = 0.25;

ctx->Const.MaxDrawBuffers = 1;

#if 0
tmesa->texHeap = mmInit( 0, tmesa->tridentScreen->textureSize );

make_empty_list(&tmesa->TexObjList);
make_empty_list(&tmesa->SwappedOut);

tmesa->CurrentTexObj[0] = 0;
tmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */

tmesa->RenderIndex = ~0;
#endif

/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
_vbo_CreateContext( ctx );
_tnl_CreateContext( ctx );
_swsetup_CreateContext( ctx );

/* Install the customized pipeline:
*/
_tnl_destroy_pipeline( ctx );
_tnl_install_pipeline( ctx, trident_pipeline );

/* Configure swrast to match hardware characteristics:
*/
_swrast_allow_pixel_fog( ctx, GL_FALSE );
_swrast_allow_vertex_fog( ctx, GL_TRUE );

tridentInitVB( ctx );
tridentDDInitExtensions( ctx );
tridentDDInitDriverFuncs( ctx );
tridentDDInitStateFuncs( ctx );
#if 0
tridentDDInitSpanFuncs( ctx );
tridentDDInitTextureFuncs( ctx );
#endif
tridentDDInitTriFuncs( ctx );
tridentDDInitState( tmesa );

driContextPriv->driverPrivate = (void *)tmesa;

UNLOCK_HARDWARE(tmesa);

return GL_TRUE;
}

static void
tridentDestroyContext(__DRIcontextPrivate *driContextPriv)
{
tridentContextPtr tmesa = (tridentContextPtr)driContextPriv->driverPrivate;

if (tmesa) {
_swsetup_DestroyContext( tmesa->glCtx );
_tnl_DestroyContext( tmesa->glCtx );
_vbo_DestroyContext( tmesa->glCtx );
_swrast_DestroyContext( tmesa->glCtx );

/* free the Mesa context */
tmesa->glCtx->DriverCtx = NULL;
_mesa_destroy_context(tmesa->glCtx);

_mesa_free(tmesa);
driContextPriv->driverPrivate = NULL;
}
}


static GLboolean
tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
{
tridentScreenPtr screen = (tridentScreenPtr) driScrnPriv->private;

if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);

{
driRenderbuffer *frontRb
= driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
screen->frontOffset, screen->frontPitch,
driDrawPriv);
/*
tridentSetSpanFunctions(frontRb, mesaVis);
*/
_mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
}

if (mesaVis->doubleBufferMode) {
driRenderbuffer *backRb
= driNewRenderbuffer(GL_RGBA, NULL, screen->cpp,
screen->backOffset, screen->backPitch,
driDrawPriv);
/*
tridentSetSpanFunctions(backRb, mesaVis);
*/
_mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
}

if (mesaVis->depthBits == 16) {
driRenderbuffer *depthRb
= driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp,
screen->depthOffset, screen->depthPitch,
driDrawPriv);
/*
tridentSetSpanFunctions(depthRb, mesaVis);
*/
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
}
else if (mesaVis->depthBits == 24) {
driRenderbuffer *depthRb
= driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp,
screen->depthOffset, screen->depthPitch,
driDrawPriv);
/*
tridentSetSpanFunctions(depthRb, mesaVis);
*/
_mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
}

/* no h/w stencil?
if (mesaVis->stencilBits > 0 && !swStencil) {
driRenderbuffer *stencilRb
= driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
tridentSetSpanFunctions(stencilRb, mesaVis);
_mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
}
*/

_mesa_add_soft_renderbuffers(fb,
GL_FALSE, /* color */
GL_FALSE, /* depth */
mesaVis->stencilBits > 0,
mesaVis->accumRedBits > 0,
GL_FALSE, /* alpha */
GL_FALSE /* aux */);
driDrawPriv->driverPrivate = (void *) fb;

return (driDrawPriv->driverPrivate != NULL);
}
}


static void
tridentDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
_mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
}

static void
tridentSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
{
__DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;

if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
tridentContextPtr tmesa;
GLcontext *ctx;
tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
ctx = tmesa->glCtx;
if (ctx->Visual.doubleBufferMode) {
_mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
tridentCopyBuffer( dPriv );
}
}
else {
/* XXX this shouldn't be an error but we can't handle it for now */
_mesa_problem(NULL, "tridentSwapBuffers: drawable has no context!\n");
}
}

static GLboolean
tridentMakeCurrent(__DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv)
{
if (driContextPriv) {
GET_CURRENT_CONTEXT(ctx);
tridentContextPtr oldCtx = ctx ? TRIDENT_CONTEXT(ctx) : NULL;
tridentContextPtr newCtx = (tridentContextPtr) driContextPriv->driverPrivate;

if ( newCtx != oldCtx ) {
newCtx->dirty = ~0;
}

if (newCtx->driDrawable != driDrawPriv) {
newCtx->driDrawable = driDrawPriv;
#if 0
tridentUpdateWindow ( newCtx->glCtx );
tridentUpdateViewportOffset( newCtx->glCtx );
#endif
}

newCtx->drawOffset = newCtx->tridentScreen->backOffset;
newCtx->drawPitch = newCtx->tridentScreen->backPitch;

_mesa_make_current( newCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );

if (!newCtx->glCtx->Viewport.Width) {
_mesa_set_viewport(newCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
} else {
_mesa_make_current( NULL, NULL, NULL );
}
return GL_TRUE;
}


static GLboolean
tridentUnbindContext( __DRIcontextPrivate *driContextPriv )
{
return GL_TRUE;
}


static tridentScreenPtr
tridentCreateScreen( __DRIscreenPrivate *sPriv )
{
TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv;
tridentScreenPtr tridentScreen;

if (sPriv->devPrivSize != sizeof(TRIDENTDRIRec)) {
fprintf(stderr,"\nERROR! sizeof(TRIDENTDRIRec) does not match passed size from device driver\n");
return GL_FALSE;
}

/* Allocate the private area */
tridentScreen = (tridentScreenPtr) CALLOC( sizeof(*tridentScreen) );
if ( !tridentScreen ) return NULL;

tridentScreen->driScreen = sPriv;

tridentScreen->frontOffset = tDRIPriv->frontOffset;
tridentScreen->backOffset = tDRIPriv->backOffset;
tridentScreen->depthOffset = tDRIPriv->depthOffset;
tridentScreen->frontPitch = tDRIPriv->frontPitch;
tridentScreen->backPitch = tDRIPriv->backPitch;
tridentScreen->depthPitch = tDRIPriv->depthPitch;
tridentScreen->width = tDRIPriv->width;
tridentScreen->height = tDRIPriv->height;

printf("%d %d\n",tridentScreen->width,tridentScreen->height);
printf("%d %d\n",tridentScreen->frontPitch,tridentScreen->backPitch);
printf("offset 0x%x 0x%x\n",tridentScreen->backOffset,tridentScreen->depthOffset);

tridentScreen->mmio.handle = tDRIPriv->regs;
tridentScreen->mmio.size = 0x20000;
if (drmMap(sPriv->fd,
tridentScreen->mmio.handle, tridentScreen->mmio.size,
(drmAddressPtr)&tridentScreen->mmio.map)) {
FREE(tridentScreen);
return GL_FALSE;
}
printf("MAPPED at %p\n", tridentScreen->mmio.map);

return tridentScreen;
}

/* Destroy the device specific screen private data struct.
*/
static void
tridentDestroyScreen( __DRIscreenPrivate *sPriv )
{
tridentScreenPtr tridentScreen = (tridentScreenPtr)sPriv->private;

FREE(tridentScreen);
}

static GLboolean
tridentInitDriver(__DRIscreenPrivate *sPriv)
{
sPriv->private = (void *) tridentCreateScreen( sPriv );

if (!sPriv->private) {
tridentDestroyScreen( sPriv );
return GL_FALSE;
}

return GL_TRUE;
}

/**
* This is the driver specific part of the createNewScreen entry point.
*
* \todo maybe fold this into intelInitDriver
*
* \return the __GLcontextModes supported by this driver
*/
const __DRIconfig **tridentInitScreen(__DRIscreenPrivate *psp)
{
static const __DRIversion ddx_expected = { 4, 0, 0 };
static const __DRIversion dri_expected = { 3, 1, 0 };
static const __DRIversion drm_expected = { 1, 0, 0 };
if ( ! driCheckDriDdxDrmVersions2( "Trident",
&psp->dri_version, & dri_expected,
&psp->ddx_version, & ddx_expected,
&psp->drm_version, & drm_expected ) )
return NULL;

if (!tridentInitDriver(psp))
return NULL;

/* Wait... what? This driver doesn't report any modes... */
#if 0
TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
*driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
GL_TRUE );
#endif

return NULL;
}

const struct __DriverAPIRec driDriverAPI = {
tridentInitScreen,
tridentDestroyScreen,
tridentCreateContext,
tridentDestroyContext,
tridentCreateBuffer,
tridentDestroyBuffer,
tridentSwapBuffers,
tridentMakeCurrent,
tridentUnbindContext,
};

+ 0
- 242
src/mesa/drivers/dri/trident/trident_context.h Ver arquivo

@@ -1,242 +0,0 @@
/*
* Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Alan Hourihane not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Alan Hourihane makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
*
* Trident CyberBladeXP driver.
*
*/
#ifndef _TRIDENT_CONTEXT_H_
#define _TRIDENT_CONTEXT_H_

#include "dri_util.h"
#include "main/macros.h"
#include "main/mtypes.h"
#include "drm.h"
#include "main/mm.h"

#define SUBPIXEL_X (0.0F)
#define SUBPIXEL_Y (0.125F)

#define _TRIDENT_NEW_VERTEX (_NEW_TEXTURE | \
_DD_NEW_TRI_UNFILLED | \
_DD_NEW_TRI_LIGHT_TWOSIDE)

#define TRIDENT_FALLBACK_TEXTURE 0x01
#define TRIDENT_FALLBACK_DRAW_BUFFER 0x02

#define TRIDENT_NEW_CLIP 0x01

#define TRIDENT_UPLOAD_COMMAND_D 0x00000001
#define TRIDENT_UPLOAD_CONTEXT 0x04000000
#define TRIDENT_UPLOAD_CLIPRECTS 0x80000000

#define TAG(x) trident##x
#include "tnl_dd/t_dd_vertex.h"
#undef TAG

/* these require that base be dword-aligned */
static INLINE void MMIO_OUT32(unsigned char *base, unsigned int offset,
unsigned int val)
{
unsigned int *addr = (unsigned int *)(base + offset);
*addr = val;
}

static INLINE unsigned int MMIO_IN32(unsigned char *base, unsigned int offset)
{
unsigned int *addr = (unsigned int *)(base + offset);
return *addr;
}

#define MMIO_OUT8(base, offset, val) *((base) + (offset)) = (val)
#define MMIO_IN8(base, offset) *((base) + (offset))

struct trident_context;
typedef struct trident_context tridentContextRec;
typedef struct trident_context *tridentContextPtr;

typedef void (*trident_quad_func)( tridentContextPtr,
const tridentVertex *,
const tridentVertex *,
const tridentVertex *,
const tridentVertex * );
typedef void (*trident_tri_func)( tridentContextPtr,
const tridentVertex *,
const tridentVertex *,
const tridentVertex * );
typedef void (*trident_line_func)( tridentContextPtr,
const tridentVertex *,
const tridentVertex * );
typedef void (*trident_point_func)( tridentContextPtr,
const tridentVertex * );

typedef struct {
drm_handle_t handle; /* Handle to the DRM region */
drmSize size; /* Size of the DRM region */
unsigned char *map; /* Mapping of the DRM region */
} tridentRegionRec, *tridentRegionPtr;

typedef struct {
__DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */

drmBufMapPtr buffers;

unsigned int frontOffset;
unsigned int frontPitch;
unsigned int backOffset;
unsigned int backPitch;
unsigned int depthOffset;
unsigned int depthPitch;
unsigned int width;
unsigned int height;
unsigned int cpp;

#if 0
unsigned int sarea_priv_offset;
#endif

tridentRegionRec mmio;
} tridentScreenRec, *tridentScreenPtr;

/**
* tridentRenderbuffer, derived from Mesa's gl_renderbuffer
*/
typedef struct {
struct gl_renderbuffer Base;
/* XXX per-window info should go here */
int foo, bar;
} tridentRenderbuffer;


struct trident_context {
GLcontext *glCtx; /* Mesa context */

__DRIcontextPrivate *driContext;
__DRIscreenPrivate *driScreen;
__DRIdrawablePrivate *driDrawable;

GLuint new_gl_state;
GLuint new_state;
GLuint dirty;

#if 0
drm_trident_sarea_t *sarea;
#endif

/* Temporaries for translating away float colors:
*/
struct gl_client_array UbyteColor;
struct gl_client_array UbyteSecondaryColor;

/* Mirrors of some DRI state
*/
int lastStamp; /* mirror driDrawable->lastStamp */

drm_context_t hHWContext;
drmLock *driHwLock;
int driFd;

tridentScreenPtr tridentScreen; /* Screen private DRI data */

/* Visual, drawable, cliprect and scissor information
*/
GLenum DrawBuffer;
GLint drawOffset, drawPitch;
GLint drawX, drawY; /* origin of drawable in draw buffer */
GLint readOffset, readPitch;

GLuint numClipRects; /* Cliprects for the draw buffer */
drm_clip_rect_t *pClipRects;

GLint scissor;
drm_clip_rect_t ScissorRect; /* Current software scissor */

GLuint Fallback;
GLuint RenderIndex;
GLuint SetupNewInputs;
GLuint SetupIndex;
GLfloat hw_viewport[16];
GLfloat depth_scale;
GLuint vertex_format;
GLuint vertex_size;
GLuint vertex_stride_shift;
GLubyte *verts;

GLint tmu_source[2];

GLuint hw_primitive;
GLenum render_primitive;

trident_point_func draw_point;
trident_line_func draw_line;
trident_tri_func draw_tri;
trident_quad_func draw_quad;

#if 0
gammaTextureObjectPtr CurrentTexObj[2];
struct gamma_texture_object_t TexObjList;
struct gamma_texture_object_t SwappedOut;
GLenum TexEnvImageFmt[2];

struct mem_block *texHeap;

int lastSwap;
int texAge;
int ctxAge;
int dirtyAge;
int lastStamp;
#endif

/* Chip state */
int commandD;

/* Context State */
int ClearColor;
};

void tridentDDInitExtensions( GLcontext *ctx );
void tridentDDInitDriverFuncs( GLcontext *ctx );
void tridentDDInitSpanFuncs( GLcontext *ctx );
void tridentDDInitState( tridentContextPtr tmesa );
void tridentInitHW( tridentContextPtr tmesa );
void tridentDDInitStateFuncs( GLcontext *ctx );
void tridentDDInitTextureFuncs( GLcontext *ctx );
void tridentDDInitTriFuncs( GLcontext *ctx );

extern void tridentBuildVertices( GLcontext *ctx,
GLuint start,
GLuint count,
GLuint newinputs );
extern void tridentInitVB( GLcontext *ctx );
extern void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv );
extern void tridentFallback( tridentContextPtr tmesa, GLuint bit,
GLboolean mode );
extern void tridentCheckTexSizes( GLcontext *ctx );
extern void tridentChooseVertexState( GLcontext *ctx );
extern void tridentDDUpdateHWState( GLcontext *ctx );
extern void tridentUploadHwStateLocked( tridentContextPtr tmesa );

#define TRIDENT_CONTEXT(ctx) ((tridentContextPtr)(ctx->DriverCtx))

#endif /* _TRIDENT_CONTEXT_H_ */

+ 0
- 110
src/mesa/drivers/dri/trident/trident_dd.c Ver arquivo

@@ -1,110 +0,0 @@
/*
* Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Alan Hourihane not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Alan Hourihane makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
*
* Trident CyberBladeXP driver.
*
*/
#include "trident_context.h"
#include "trident_lock.h"
#if defined(USE_X86_ASM)
#include "x86/common_x86_asm.h"
#endif

#include "swrast/swrast.h"
#include "main/context.h"
#include "main/framebuffer.h"

#define TRIDENT_DATE "20041223"

/* Return the width and height of the current color buffer.
*/
static void tridentDDGetBufferSize( GLframebuffer *framebuffer,
GLuint *width, GLuint *height )
{
GET_CURRENT_CONTEXT(ctx);
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);

LOCK_HARDWARE(tmesa);
*width = tmesa->driDrawable->w;
*height = tmesa->driDrawable->h;
UNLOCK_HARDWARE(tmesa);
}


/* Return various strings for glGetString().
*/
static const GLubyte *tridentDDGetString( GLcontext *ctx, GLenum name )
{
static char buffer[128];

switch ( name ) {
case GL_VENDOR:
return (GLubyte *)"Alan Hourihane";

case GL_RENDERER:
sprintf( buffer, "Mesa DRI Trident " TRIDENT_DATE );

/* Append any CPU-specific information.
*/
#ifdef USE_X86_ASM
if ( _mesa_x86_cpu_features ) {
strncat( buffer, " x86", 4 );
}
#ifdef USE_MMX_ASM
if ( cpu_has_mmx ) {
strncat( buffer, "/MMX", 4 );
}
#endif
#ifdef USE_3DNOW_ASM
if ( cpu_has_3dnow ) {
strncat( buffer, "/3DNow!", 7 );
}
#endif
#ifdef USE_SSE_ASM
if ( cpu_has_xmm ) {
strncat( buffer, "/SSE", 4 );
}
#endif
#endif
return (GLubyte *)buffer;

default:
return NULL;
}
}

/* Enable the extensions supported by this driver.
*/
void tridentDDInitExtensions( GLcontext *ctx )
{
/* None... */
}

/* Initialize the driver's misc functions.
*/
void tridentDDInitDriverFuncs( GLcontext *ctx )
{
ctx->Driver.GetBufferSize = tridentDDGetBufferSize;
ctx->Driver.GetString = tridentDDGetString;
ctx->Driver.Error = NULL;
}

+ 0
- 28
src/mesa/drivers/dri/trident/trident_dri.h Ver arquivo

@@ -1,28 +0,0 @@
#ifndef _TRIDENT_DRI_
#define _TRIDENT_DRI_

#include "xf86drm.h"

typedef struct {
drm_handle_t regs;
drmSize regsSize;
drmAddress regsMap;
int deviceID;
int width;
int height;
int mem;
int frontOffset;
int frontPitch;
int backOffset;
int backPitch;
int depthOffset;
int depthPitch;
int cpp;
#if 0
int textureOffset;
int textureSize;
#endif
unsigned int sarea_priv_offset;
} TRIDENTDRIRec, *TRIDENTDRIPtr;

#endif

+ 0
- 11
src/mesa/drivers/dri/trident/trident_lock.h Ver arquivo

@@ -1,11 +0,0 @@
/* XXX tridentGetLock doesn't exist... */

#define LOCK_HARDWARE(tmesa) \
do { \
char __ret = 0; \
DRM_CAS(tmesa->driHwLock, tmesa->hHWContext, \
DRM_LOCK_HELD | tmesa->hHWContext, __ret); \
} while (0)

#define UNLOCK_HARDWARE(tmesa) \
DRM_UNLOCK(tmesa->driFd, tmesa->driHwLock, tmesa->hHWContext)

+ 0
- 548
src/mesa/drivers/dri/trident/trident_state.c Ver arquivo

@@ -1,548 +0,0 @@
/*
* Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Alan Hourihane not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Alan Hourihane makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
*
* Trident CyberBladeXP driver.
*
*/
#include "trident_context.h"
#include "trident_lock.h"
#include "vbo/vbo.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
#include "main/framebuffer.h"

#define TRIDENTPACKCOLOR332(r, g, b) \
(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))

#define TRIDENTPACKCOLOR1555(r, g, b, a) \
((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
((a) ? 0x8000 : 0))

#define TRIDENTPACKCOLOR565(r, g, b) \
((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))

#define TRIDENTPACKCOLOR888(r, g, b) \
(((r) << 16) | ((g) << 8) | (b))

#define TRIDENTPACKCOLOR8888(r, g, b, a) \
(((a) << 24) | ((r) << 16) | ((g) << 8) | (b))

#define TRIDENTPACKCOLOR4444(r, g, b, a) \
((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))

static INLINE GLuint tridentPackColor( GLuint cpp,
GLubyte r, GLubyte g,
GLubyte b, GLubyte a )
{
switch ( cpp ) {
case 2:
return TRIDENTPACKCOLOR565( r, g, b );
case 4:
return TRIDENTPACKCOLOR8888( r, g, b, a );
default:
return 0;
}
}

void tridentUploadHwStateLocked( tridentContextPtr tmesa )
{
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
#if 0
ATISAREAPrivPtr sarea = tmesa->sarea;
trident_context_regs_t *regs = &(sarea->ContextState);
#endif

if ( tmesa->dirty & TRIDENT_UPLOAD_COMMAND_D ) {
MMIO_OUT32(MMIO, 0x00281C, tmesa->commandD );
tmesa->dirty &= ~TRIDENT_UPLOAD_COMMAND_D;
}

if ( tmesa->dirty & TRIDENT_UPLOAD_CLIPRECTS ) {
/* XXX FIX ME ! */
MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height );
MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width );
tmesa->dirty &= ~TRIDENT_UPLOAD_CLIPRECTS;
}

tmesa->dirty = 0;
}

/* Copy the back color buffer to the front color buffer.
*/
void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv )
{
unsigned char *MMIO;
tridentContextPtr tmesa;
GLint nbox, i;
int busy;
drm_clip_rect_t *pbox;

assert(dPriv);
assert(dPriv->driContextPriv);
assert(dPriv->driContextPriv->driverPrivate);

tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
MMIO = tmesa->tridentScreen->mmio.map;

LOCK_HARDWARE( tmesa );

/* use front buffer cliprects */
nbox = dPriv->numClipRects;
pbox = dPriv->pClipRects;

for ( i = 0 ; i < nbox ; i++ ) {
#if 0
GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox );
drm_clip_rect_t *b = tmesa->sarea->boxes;
GLint n = 0;

for ( ; i < nr ; i++ ) {
*b++ = pbox[i];
n++;
}
tmesa->sarea->nbox = n;
#endif

MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4);
MMIO_OUT32(MMIO, 0x2154, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4);
MMIO_OUT8(MMIO, 0x2127, 0xCC); /* Copy Rop */
MMIO_OUT32(MMIO, 0x2128, 0x4); /* scr2scr */
MMIO_OUT32(MMIO, 0x2138, (pbox->x1 << 16) | pbox->y1);
MMIO_OUT32(MMIO, 0x213C, (pbox->x1 << 16) | pbox->y1);
MMIO_OUT32(MMIO, 0x2140, (pbox->x2 - pbox->x1) << 16 | (pbox->y2 - pbox->y1) );
MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
#define GE_BUSY 0x80
for (;;) {
busy = MMIO_IN8(MMIO, 0x2120);
if ( !(busy & GE_BUSY) )
break;
}
}

UNLOCK_HARDWARE( tmesa );

#if 0
tmesa->dirty |= (MACH64_UPLOAD_CONTEXT |
MACH64_UPLOAD_MISC |
MACH64_UPLOAD_CLIPRECTS);
#endif
}


static void tridentDDClear( GLcontext *ctx, GLbitfield mask )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
int busy;
GLuint flags = 0;
GLint i;
GLint cx, cy, cw, ch;

#define DRM_TRIDENT_FRONT 0x01
#define DRM_TRIDENT_BACK 0x02
#define DRM_TRIDENT_DEPTH 0x04

if ( tmesa->new_state )
tridentDDUpdateHWState( ctx );

if ( mask & BUFFER_BIT_FRONT_LEFT ) {
flags |= DRM_TRIDENT_FRONT;
mask &= ~BUFFER_BIT_FRONT_LEFT;
}

if ( mask & BUFFER_BIT_BACK_LEFT ) {
flags |= DRM_TRIDENT_BACK;
mask &= ~BUFFER_BIT_BACK_LEFT;
}

if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
flags |= DRM_TRIDENT_DEPTH;
mask &= ~BUFFER_BIT_DEPTH;
}

LOCK_HARDWARE(tmesa);

/* get region after locking: */
cx = ctx->DrawBuffer->_Xmin;
cy = ctx->DrawBuffer->_Ymin;
cw = ctx->DrawBuffer->_Xmax - cx;
ch = ctx->DrawBuffer->_Ymax - cy;

if ( flags ) {
cx += tmesa->drawX;
cy += tmesa->drawY;
/* HACK!!!
*/
if ( tmesa->dirty & ~TRIDENT_UPLOAD_CLIPRECTS ) {
tridentUploadHwStateLocked( tmesa );
}
for ( i = 0 ; i < tmesa->numClipRects ; i++ ) {
#if 0
int nr = MIN2( i + TRIDENT_NR_SAREA_CLIPRECTS, tmesa->numClipRects );
drm_clip_rect_t *box = tmesa->pClipRects;
drm_clip_rect_t *b = tmesa->sarea->boxes;
GLint n = 0;
if ( !all ) {
for ( ; i < nr ; i++ ) {
GLint x = box[i].x1;
GLint y = box[i].y1;
GLint w = box[i].x2 - x;
GLint h = box[i].y2 - y;
if ( x < cx ) w -= cx - x, x = cx;
if ( y < cy ) h -= cy - y, y = cy;
if ( x + w > cx + cw ) w = cx + cw - x;
if ( y + h > cy + ch ) h = cy + ch - y;
if ( w <= 0 ) continue;
if ( h <= 0 ) continue;
b->x1 = x;
b->y1 = y;
b->x2 = x + w;
b->y2 = y + h;
b++;
n++;
}
} else {
for ( ; i < nr ; i++ ) {
*b++ = box[i];
n++;
}
}
tmesa->sarea->nbox = n;
#endif
if (flags & DRM_TRIDENT_BACK) {
MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4);
MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
#define GE_BUSY 0x80
for (;;) {
busy = MMIO_IN8(MMIO, 0x2120);
if ( !(busy & GE_BUSY) )
break;
}
}
if (flags & DRM_TRIDENT_DEPTH) {
MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->depthPitch << 20 | tmesa->tridentScreen->depthOffset>>4);
MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
#define GE_BUSY 0x80
for (;;) {
busy = MMIO_IN8(MMIO, 0x2120);
if ( !(busy & GE_BUSY) )
break;
}
}
MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4);
if (flags & DRM_TRIDENT_FRONT) {
MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
#define GE_BUSY 0x80
for (;;) {
busy = MMIO_IN8(MMIO, 0x2120);
if ( !(busy & GE_BUSY) )
break;
}
}
}
#if 0
tmesa->dirty |= (TRIDENT_UPLOAD_CONTEXT |
TRIDENT_UPLOAD_MISC |
TRIDENT_UPLOAD_CLIPRECTS);
#endif
}

UNLOCK_HARDWARE(tmesa);

if ( mask )
_swrast_Clear( ctx, mask );
}

static void tridentDDShadeModel( GLcontext *ctx, GLenum mode )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
GLuint s = tmesa->commandD;

#define TRIDENT_FLAT_SHADE 0x000000E0
#define TRIDENT_FLAT_SHADE_VERTEX_C 0x00000060
#define TRIDENT_FLAT_SHADE_GOURAUD 0x00000080

s &= ~TRIDENT_FLAT_SHADE;

switch ( mode ) {
case GL_FLAT:
s |= TRIDENT_FLAT_SHADE_VERTEX_C;
break;
case GL_SMOOTH:
s |= TRIDENT_FLAT_SHADE_GOURAUD;
break;
default:
return;
}

if ( tmesa->commandD != s ) {
tmesa->commandD = s;

tmesa->dirty |= TRIDENT_UPLOAD_COMMAND_D;
}
}

static void
tridentCalcViewport( GLcontext *ctx )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
const GLfloat *v = ctx->Viewport._WindowMap.m;
GLfloat *m = tmesa->hw_viewport;

/* See also trident_translate_vertex.
*/
m[MAT_SX] = v[MAT_SX];
m[MAT_TX] = v[MAT_TX] + tmesa->drawX + SUBPIXEL_X;
m[MAT_SY] = - v[MAT_SY];
m[MAT_TY] = - v[MAT_TY] + tmesa->driDrawable->h + tmesa->drawY + SUBPIXEL_Y;
#if 0
m[MAT_SZ] = v[MAT_SZ] * tmesa->depth_scale;
m[MAT_TZ] = v[MAT_TZ] * tmesa->depth_scale;
#else
m[MAT_SZ] = v[MAT_SZ];
m[MAT_TZ] = v[MAT_TZ];
#endif

tmesa->SetupNewInputs = ~0;
}

static void tridentDDViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
tridentCalcViewport( ctx );
}

static void tridentDDDepthRange( GLcontext *ctx,
GLclampd nearval, GLclampd farval )
{
tridentCalcViewport( ctx );
}

static void
tridentSetCliprects( tridentContextPtr tmesa, GLenum mode )
{
__DRIdrawablePrivate *dPriv = tmesa->driDrawable;

switch ( mode ) {
case GL_FRONT_LEFT:
if (dPriv->numClipRects == 0) {
static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
tmesa->numClipRects = 1;
tmesa->pClipRects = &zeroareacliprect;
} else {
tmesa->numClipRects = dPriv->numClipRects;
tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
}
tmesa->drawX = dPriv->x;
tmesa->drawY = dPriv->y;
break;
case GL_BACK_LEFT:
if ( dPriv->numBackClipRects == 0 ) {
if (dPriv->numClipRects == 0) {
static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
tmesa->numClipRects = 1;
tmesa->pClipRects = &zeroareacliprect;
} else {
tmesa->numClipRects = dPriv->numClipRects;
tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
tmesa->drawX = dPriv->x;
tmesa->drawY = dPriv->y;
}
}
else {
tmesa->numClipRects = dPriv->numBackClipRects;
tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pBackClipRects;
tmesa->drawX = dPriv->backX;
tmesa->drawY = dPriv->backY;
}
break;
default:
return;
}

#if 0
tmesa->dirty |= TRIDENT_UPLOAD_CLIPRECTS;
#endif
}

#if 0
static GLboolean tridentDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
int found = GL_TRUE;

if ( tmesa->DrawBuffer != mode ) {
tmesa->DrawBuffer = mode;
switch ( mode ) {
case GL_FRONT_LEFT:
tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE );
tmesa->drawOffset = tmesa->tridentScreen->frontOffset;
tmesa->drawPitch = tmesa->tridentScreen->frontPitch;
tridentSetCliprects( tmesa, GL_FRONT_LEFT );
break;
case GL_BACK_LEFT:
tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE );
tmesa->drawOffset = tmesa->tridentScreen->backOffset;
tmesa->drawPitch = tmesa->tridentScreen->backPitch;
tridentSetCliprects( tmesa, GL_BACK_LEFT );
break;
default:
tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_TRUE );
found = GL_FALSE;
break;
}

#if 0
tmesa->setup.dst_off_pitch = (((tmesa->drawPitch/8) << 22) |
(tmesa->drawOffset >> 3));

tmesa->dirty |= MACH64_UPLOAD_DST_OFF_PITCH | MACH64_UPLOAD_CONTEXT;
#endif
}

return found;
}

static void tridentDDClearColor( GLcontext *ctx,
const GLchan color[4] )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);

tmesa->ClearColor = tridentPackColor( tmesa->tridentScreen->cpp,
color[0], color[1],
color[2], color[3] );
}
#endif

static void
tridentDDUpdateState( GLcontext *ctx, GLuint new_state )
{
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
_vbo_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
TRIDENT_CONTEXT(ctx)->new_gl_state |= new_state;
}


/* Initialize the context's hardware state.
*/
void tridentDDInitState( tridentContextPtr tmesa )
{
tmesa->new_state = 0;

switch ( tmesa->glCtx->Visual.depthBits ) {
case 16:
tmesa->depth_scale = 1.0 / (GLfloat)0xffff;
break;
case 24:
tmesa->depth_scale = 1.0 / (GLfloat)0xffffff;
break;
}
}

void tridentDDUpdateHWState( GLcontext *ctx )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
int new_state = tmesa->new_state;

if ( new_state )
{
tmesa->new_state = 0;

#if 0
/* Update the various parts of the context's state.
*/
if ( new_state & GAMMA_NEW_ALPHA )
tridentUpdateAlphaMode( ctx );

if ( new_state & GAMMA_NEW_DEPTH )
tridentUpdateZMode( ctx );

if ( new_state & GAMMA_NEW_FOG )
gammaUpdateFogAttrib( ctx );

if ( new_state & GAMMA_NEW_CLIP )
gammaUpdateClipping( ctx );

if ( new_state & GAMMA_NEW_POLYGON )
gammaUpdatePolygon( ctx );

if ( new_state & GAMMA_NEW_CULL )
gammaUpdateCull( ctx );

if ( new_state & GAMMA_NEW_MASKS )
gammaUpdateMasks( ctx );

if ( new_state & GAMMA_NEW_STIPPLE )
gammaUpdateStipple( ctx );
#endif
}

/* HACK ! */

#if 0
gammaEmitHwState( tmesa );
#endif
}

/* Initialize the driver's state functions.
*/
void tridentDDInitStateFuncs( GLcontext *ctx )
{
ctx->Driver.UpdateState = tridentDDUpdateState;

ctx->Driver.Clear = tridentDDClear;
ctx->Driver.DepthRange = tridentDDDepthRange;
ctx->Driver.ShadeModel = tridentDDShadeModel;
ctx->Driver.Viewport = tridentDDViewport;
}

+ 0
- 1125
src/mesa/drivers/dri/trident/trident_tris.c
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 0
- 434
src/mesa/drivers/dri/trident/trident_vb.c Ver arquivo

@@ -1,434 +0,0 @@
/*
* Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK.
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Alan Hourihane not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Alan Hourihane makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
*
* Trident CyberBladeXP driver.
*
*/
#include "main/glheader.h"
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/colormac.h"

#include "swrast_setup/swrast_setup.h"
#include "swrast/swrast.h"
#include "tnl/t_context.h"
#include "tnl/tnl.h"

#include "trident_context.h"

#define TRIDENT_TEX1_BIT 0x1
#define TRIDENT_TEX0_BIT 0x2
#define TRIDENT_RGBA_BIT 0x4
#define TRIDENT_SPEC_BIT 0x8
#define TRIDENT_FOG_BIT 0x10
#define TRIDENT_XYZW_BIT 0x20
#define TRIDENT_PTEX_BIT 0x40
#define TRIDENT_MAX_SETUP 0x80

static struct {
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
tnl_interp_func interp;
tnl_copy_pv_func copy_pv;
GLboolean (*check_tex_sizes)( GLcontext *ctx );
GLuint vertex_size;
GLuint vertex_stride_shift;
GLuint vertex_format;
} setup_tab[TRIDENT_MAX_SETUP];

#define TINY_VERTEX_FORMAT 1
#define NOTEX_VERTEX_FORMAT 2
#define TEX0_VERTEX_FORMAT 3
#define TEX1_VERTEX_FORMAT 4
#define PROJ_TEX1_VERTEX_FORMAT 5
#define TEX2_VERTEX_FORMAT 6
#define TEX3_VERTEX_FORMAT 7
#define PROJ_TEX3_VERTEX_FORMAT 8

#define DO_XYZW (IND & TRIDENT_XYZW_BIT)
#define DO_RGBA (IND & TRIDENT_RGBA_BIT)
#define DO_SPEC (IND & TRIDENT_SPEC_BIT)
#define DO_FOG (IND & TRIDENT_FOG_BIT)
#define DO_TEX0 (IND & TRIDENT_TEX0_BIT)
#define DO_TEX1 (IND & TRIDENT_TEX1_BIT)
#define DO_TEX2 0
#define DO_TEX3 0
#define DO_PTEX (IND & TRIDENT_PTEX_BIT)

#define VERTEX tridentVertex
#define VERTEX_COLOR trident_color_t
#define LOCALVARS tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
#define GET_VIEWPORT_MAT() tmesa->hw_viewport
#define GET_TEXSOURCE(n) tmesa->tmu_source[n]
#define GET_VERTEX_FORMAT() tmesa->vertex_format
#define GET_VERTEX_SIZE() tmesa->vertex_size
#define GET_VERTEX_STORE() tmesa->verts
#define GET_VERTEX_STRIDE_SHIFT() tmesa->vertex_stride_shift
#define GET_UBYTE_COLOR_STORE() &tmesa->UbyteColor
#define GET_UBYTE_SPEC_COLOR_STORE() &tmesa->UbyteSecondaryColor
#define HAVE_HW_VIEWPORT 0
#define HAVE_HW_DIVIDE 0
#define HAVE_RGBA_COLOR 0
#define HAVE_TINY_VERTICES 1
#define HAVE_NOTEX_VERTICES 1
#define HAVE_TEX0_VERTICES 1
#define HAVE_TEX1_VERTICES 1
#define HAVE_TEX2_VERTICES 0
#define HAVE_TEX3_VERTICES 0
#define HAVE_PTEX_VERTICES 0

#define UNVIEWPORT_VARS \
const GLfloat dx = - tmesa->drawX - SUBPIXEL_X; \
const GLfloat dy = (tmesa->driDrawable->h + \
tmesa->drawY + SUBPIXEL_Y); \
const GLfloat sz = 1.0 / tmesa->depth_scale

#define UNVIEWPORT_X(x) x + dx;
#define UNVIEWPORT_Y(y) - y + dy;
#define UNVIEWPORT_Z(z) z * sz;

#define PTEX_FALLBACK() tridentFallback(TRIDENT_CONTEXT(ctx), TRIDENT_FALLBACK_TEXTURE, 1)

#define IMPORT_FLOAT_COLORS trident_import_float_colors
#define IMPORT_FLOAT_SPEC_COLORS trident_import_float_spec_colors

#define INTERP_VERTEX setup_tab[tmesa->SetupIndex].interp
#define COPY_PV_VERTEX setup_tab[tmesa->SetupIndex].copy_pv

/***********************************************************************
* Generate pv-copying and translation functions *
***********************************************************************/

#define TAG(x) trident_##x
#include "tnl_dd/t_dd_vb.c"

/***********************************************************************
* Generate vertex emit and interp functions *
***********************************************************************/

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT)
#define TAG(x) x##_wg
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT)
#define TAG(x) x##_wgs
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_wgt0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_wgt0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
#define TAG(x) x##_wgpt0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_wgst0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_wgst0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
#define TAG(x) x##_wgspt0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT)
#define TAG(x) x##_wgf
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT)
#define TAG(x) x##_wgfs
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_wgft0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_wgft0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
#define TAG(x) x##_wgfpt0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_wgfst0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_wgfst0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
#define TAG(x) x##_wgfspt0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_TEX0_BIT)
#define TAG(x) x##_t0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_t0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_FOG_BIT)
#define TAG(x) x##_f
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_ft0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_ft0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT)
#define TAG(x) x##_g
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT)
#define TAG(x) x##_gs
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_gt0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_gt0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_gst0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_gst0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT)
#define TAG(x) x##_gf
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT)
#define TAG(x) x##_gfs
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_gft0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_gft0t1
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
#define TAG(x) x##_gfst0
#include "tnl_dd/t_dd_vbtmp.h"

#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
#define TAG(x) x##_gfst0t1
#include "tnl_dd/t_dd_vbtmp.h"

static void init_setup_tab( void )
{
init_wg();
init_wgs();
init_wgt0();
init_wgt0t1();
init_wgpt0();
init_wgst0();
init_wgst0t1();
init_wgspt0();
init_wgf();
init_wgfs();
init_wgft0();
init_wgft0t1();
init_wgfpt0();
init_wgfst0();
init_wgfst0t1();
init_wgfspt0();
init_t0();
init_t0t1();
init_f();
init_ft0();
init_ft0t1();
init_g();
init_gs();
init_gt0();
init_gt0t1();
init_gst0();
init_gst0t1();
init_gf();
init_gfs();
init_gft0();
init_gft0t1();
init_gfst0();
init_gfst0t1();
}

void tridentBuildVertices( GLcontext *ctx,
GLuint start,
GLuint count,
GLuint newinputs )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
GLubyte *v = ((GLubyte *)tmesa->verts + (start<<tmesa->vertex_stride_shift));
GLuint stride = 1<<tmesa->vertex_stride_shift;

newinputs |= tmesa->SetupNewInputs;
tmesa->SetupNewInputs = 0;

if (!newinputs)
return;

if (newinputs & VERT_BIT_POS) {
setup_tab[tmesa->SetupIndex].emit( ctx, start, count, v, stride );
} else {
GLuint ind = 0;

if (newinputs & VERT_BIT_COLOR0)
ind |= TRIDENT_RGBA_BIT;

if (newinputs & VERT_BIT_COLOR1)
ind |= TRIDENT_SPEC_BIT;

if (newinputs & VERT_BIT_TEX0)
ind |= TRIDENT_TEX0_BIT;

if (newinputs & VERT_BIT_TEX1)
ind |= TRIDENT_TEX1_BIT;

if (newinputs & VERT_BIT_FOG)
ind |= TRIDENT_FOG_BIT;

if (tmesa->SetupIndex & TRIDENT_PTEX_BIT)
ind = ~0;

ind &= tmesa->SetupIndex;

if (ind) {
setup_tab[ind].emit( ctx, start, count, v, stride );
}
}
}

void tridentCheckTexSizes( GLcontext *ctx )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );

if (!setup_tab[tmesa->SetupIndex].check_tex_sizes(ctx)) {
TNLcontext *tnl = TNL_CONTEXT(ctx);

/* Invalidate stored verts
*/
tmesa->SetupNewInputs = ~0;
tmesa->SetupIndex |= TRIDENT_PTEX_BIT;

if (!tmesa->Fallback &&
!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
tnl->Driver.Render.Interp = setup_tab[tmesa->SetupIndex].interp;
tnl->Driver.Render.CopyPV = setup_tab[tmesa->SetupIndex].copy_pv;
}
}
}

void tridentChooseVertexState( GLcontext *ctx )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint ind = TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT;

if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
ind |= TRIDENT_SPEC_BIT;

if (ctx->Fog.Enabled)
ind |= TRIDENT_FOG_BIT;

if (ctx->Texture.Unit[0]._ReallyEnabled) {
ind |= TRIDENT_TEX0_BIT;
if (ctx->Texture.Unit[1]._ReallyEnabled) {
ind |= TRIDENT_TEX1_BIT;
}
}

tmesa->SetupIndex = ind;

if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
tnl->Driver.Render.Interp = trident_interp_extras;
tnl->Driver.Render.CopyPV = trident_copy_pv_extras;
} else {
tnl->Driver.Render.Interp = setup_tab[ind].interp;
tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
}

if (setup_tab[ind].vertex_format != tmesa->vertex_format) {
tmesa->vertex_format = setup_tab[ind].vertex_format;
tmesa->vertex_size = setup_tab[ind].vertex_size;
tmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
}
}

void tridentInitVB( GLcontext *ctx )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;

tmesa->verts = (GLubyte *)ALIGN_MALLOC( size * 16 * 4, 32 );

{
static int firsttime = 1;
if (firsttime) {
init_setup_tab();
firsttime = 0;
}
}
}

void tridentFreeVB( GLcontext *ctx )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);

if (tmesa->verts) {
ALIGN_FREE(tmesa->verts);
tmesa->verts = 0;
}

if (tmesa->UbyteSecondaryColor.Ptr) {
ALIGN_FREE((void *)tmesa->UbyteSecondaryColor.Ptr);
tmesa->UbyteSecondaryColor.Ptr = 0;
}

if (tmesa->UbyteColor.Ptr) {
ALIGN_FREE((void *)tmesa->UbyteColor.Ptr);
tmesa->UbyteColor.Ptr = 0;
}
}

Carregando…
Cancelar
Salvar