add gamma driver - no kernel driver yet
(build tested, not physically tested)
This commit is contained in:
+3
-1
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.X11,v 1.88 2003/09/30 11:13:31 alanh Exp $
|
||||
# $Id: Makefile.X11,v 1.89 2003/09/30 11:28:16 alanh Exp $
|
||||
|
||||
# Mesa 3-D graphics library
|
||||
# Version: 5.1
|
||||
@@ -242,6 +242,7 @@ linux-solo:
|
||||
if [ -d src/mesa/drivers/dri/i810 ] ; then touch src/mesa/drivers/dri/i810/depend ; fi
|
||||
if [ -d src/mesa/drivers/dri/i830 ] ; then touch src/mesa/drivers/dri/i830/depend ; fi
|
||||
if [ -d src/mesa/drivers/dri/sis ] ; then touch src/mesa/drivers/dri/sis/depend ; fi
|
||||
if [ -d src/mesa/drivers/dri/gamma ] ; then touch src/mesa/drivers/dri/gamma/depend ; fi
|
||||
if [ -d src/mesa/drivers/dri/fb ] ; then touch src/mesa/drivers/dri/fb/depend ; fi
|
||||
if [ -d src/glut/mini ] ; then touch src/glut/mini/depend ; fi
|
||||
if [ -d progs/miniglx ] ; then touch progs/miniglx/depend ; fi
|
||||
@@ -254,6 +255,7 @@ linux-solo:
|
||||
if [ -d src/mesa/drivers/dri/i810 ] ; then cd src/mesa/drivers/dri/i810 ; $(MAKE) -f Makefile.X11 $@ ; fi
|
||||
if [ -d src/mesa/drivers/dri/i830 ] ; then cd src/mesa/drivers/dri/i830 ; $(MAKE) -f Makefile.X11 $@ ; fi
|
||||
if [ -d src/mesa/drivers/dri/sis ] ; then cd src/mesa/drivers/dri/sis ; $(MAKE) -f Makefile.X11 $@ ; fi
|
||||
if [ -d src/mesa/drivers/dri/gamma ] ; then cd src/mesa/drivers/dri/gamma ; $(MAKE) -f Makefile.X11 $@ ; fi
|
||||
if [ -d src/mesa/drivers/dri/fb ] ; then cd src/mesa/drivers/dri/fb ; $(MAKE) -f Makefile.X11 $@ ; fi
|
||||
if [ -d src/glx/mini ] ; then cd src/glx/mini ; $(MAKE) -f Makefile.X11 $@ ; fi
|
||||
if [ -d src/glu/mini ] ; then cd src/glu/mini ; $(MAKE) -f Makefile.X11 $@ ; fi
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*
|
||||
*/
|
||||
#include "gamma_context.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "array_cache/acache.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "simple_list.h"
|
||||
#include "imports.h"
|
||||
#include "matrix.h"
|
||||
#include "extensions.h"
|
||||
#if defined(USE_X86_ASM)
|
||||
#include "X86/common_x86_asm.h"
|
||||
#endif
|
||||
#include "simple_list.h"
|
||||
#include "mm.h"
|
||||
|
||||
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_tris.h"
|
||||
|
||||
extern const struct gl_pipeline_stage _gamma_render_stage;
|
||||
|
||||
static const struct gl_pipeline_stage *gamma_pipeline[] = {
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage,
|
||||
&_tnl_fog_coordinate_stage,
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
/* REMOVE: point attenuation stage */
|
||||
#if 1
|
||||
&_gamma_render_stage, /* ADD: unclipped rastersetup-to-dma */
|
||||
#endif
|
||||
&_tnl_render_stage,
|
||||
0,
|
||||
};
|
||||
|
||||
GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate)
|
||||
{
|
||||
GLcontext *ctx, *shareCtx;
|
||||
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
|
||||
gammaContextPtr gmesa;
|
||||
gammaScreenPtr gammascrn;
|
||||
GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
|
||||
sizeof(XF86DRISAREARec));
|
||||
|
||||
gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
|
||||
if ( !gmesa ) return GL_FALSE;
|
||||
|
||||
/* Allocate the Mesa context */
|
||||
if (sharedContextPrivate)
|
||||
shareCtx = ((gammaContextPtr) sharedContextPrivate)->glCtx;
|
||||
else
|
||||
shareCtx = NULL;
|
||||
|
||||
gmesa->glCtx = _mesa_create_context(glVisual, shareCtx, (void *) gmesa, GL_TRUE);
|
||||
if (!gmesa->glCtx) {
|
||||
FREE(gmesa);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
gmesa->driContext = driContextPriv;
|
||||
gmesa->driScreen = sPriv;
|
||||
gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
|
||||
|
||||
gmesa->hHWContext = driContextPriv->hHWContext;
|
||||
gmesa->driHwLock = &sPriv->pSAREA->lock;
|
||||
gmesa->driFd = sPriv->fd;
|
||||
gmesa->sarea = saPriv;
|
||||
|
||||
gammascrn = gmesa->gammaScreen = (gammaScreenPtr)(sPriv->private);
|
||||
|
||||
ctx = gmesa->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;
|
||||
|
||||
gmesa->texHeap = mmInit( 0, gmesa->gammaScreen->textureSize );
|
||||
|
||||
make_empty_list(&gmesa->TexObjList);
|
||||
make_empty_list(&gmesa->SwappedOut);
|
||||
|
||||
gmesa->CurrentTexObj[0] = 0;
|
||||
gmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */
|
||||
|
||||
gmesa->RenderIndex = ~0;
|
||||
|
||||
|
||||
/* Initialize the software rasterizer and helper modules.
|
||||
*/
|
||||
_swrast_CreateContext( ctx );
|
||||
_ac_CreateContext( ctx );
|
||||
_tnl_CreateContext( ctx );
|
||||
_swsetup_CreateContext( ctx );
|
||||
|
||||
/* Install the customized pipeline:
|
||||
*/
|
||||
_tnl_destroy_pipeline( ctx );
|
||||
_tnl_install_pipeline( ctx, gamma_pipeline );
|
||||
|
||||
/* Configure swrast to match hardware characteristics:
|
||||
*/
|
||||
_swrast_allow_pixel_fog( ctx, GL_FALSE );
|
||||
_swrast_allow_vertex_fog( ctx, GL_TRUE );
|
||||
|
||||
gammaInitVB( ctx );
|
||||
gammaDDInitExtensions( ctx );
|
||||
gammaDDInitDriverFuncs( ctx );
|
||||
gammaDDInitStateFuncs( ctx );
|
||||
gammaDDInitSpanFuncs( ctx );
|
||||
gammaDDInitTextureFuncs( ctx );
|
||||
gammaDDInitTriFuncs( ctx );
|
||||
gammaDDInitState( gmesa );
|
||||
|
||||
driContextPriv->driverPrivate = (void *)gmesa;
|
||||
|
||||
GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
|
||||
1, &gmesa->bufIndex, &gmesa->bufSize,
|
||||
&gmesa->buf, &gmesa->bufCount, gammascrn);
|
||||
|
||||
#ifdef DO_VALIDATE
|
||||
GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
|
||||
1, &gmesa->WCbufIndex, &gmesa->WCbufSize,
|
||||
&gmesa->WCbuf, &gmesa->WCbufCount, gammascrn);
|
||||
#endif
|
||||
|
||||
switch (glVisual->depthBits) {
|
||||
case 16:
|
||||
gmesa->DeltaMode = DM_Depth16;
|
||||
gmesa->depth_scale = 1.0f / 0xffff;
|
||||
break;
|
||||
case 24:
|
||||
gmesa->DeltaMode = DM_Depth24;
|
||||
gmesa->depth_scale = 1.0f / 0xffffff;
|
||||
break;
|
||||
case 32:
|
||||
gmesa->DeltaMode = DM_Depth32;
|
||||
gmesa->depth_scale = 1.0f / 0xffffffff;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gmesa->DepthSize = glVisual->depthBits;
|
||||
gmesa->Flags = GAMMA_FRONT_BUFFER;
|
||||
gmesa->Flags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
|
||||
gmesa->Flags |= (gmesa->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0);
|
||||
|
||||
gmesa->EnabledFlags = GAMMA_FRONT_BUFFER;
|
||||
gmesa->EnabledFlags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
|
||||
|
||||
|
||||
if (gmesa->Flags & GAMMA_BACK_BUFFER) {
|
||||
gmesa->readOffset = gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
|
||||
} else {
|
||||
gmesa->readOffset = gmesa->drawOffset = 0;
|
||||
}
|
||||
|
||||
gammaInitHW( gmesa );
|
||||
|
||||
driContextPriv->driverPrivate = (void *)gmesa;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@@ -0,0 +1,405 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_context.h,v 1.6 2002/12/16 16:18:50 dawes Exp $ */
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_CONTEXT_H_
|
||||
#define _GAMMA_CONTEXT_H_
|
||||
|
||||
#include "dri_util.h"
|
||||
#include "colormac.h"
|
||||
#include "gamma_regs.h"
|
||||
#include "gamma_macros.h"
|
||||
#include "gamma_screen.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "glint_dri.h"
|
||||
#include "mm.h"
|
||||
|
||||
typedef union {
|
||||
unsigned int i;
|
||||
float f;
|
||||
} dmaBufRec, *dmaBuf;
|
||||
|
||||
/* Flags for context */
|
||||
#define GAMMA_FRONT_BUFFER 0x00000001
|
||||
#define GAMMA_BACK_BUFFER 0x00000002
|
||||
#define GAMMA_DEPTH_BUFFER 0x00000004
|
||||
#define GAMMA_STENCIL_BUFFER 0x00000008
|
||||
#define GAMMA_ACCUM_BUFFER 0x00000010
|
||||
|
||||
#define GAMMA_MAX_TEXTURE_SIZE 2048
|
||||
|
||||
/* These are the minimum requirements and should probably be increased */
|
||||
#define MAX_MODELVIEW_STACK 16
|
||||
#define MAX_PROJECTION_STACK 2
|
||||
#define MAX_TEXTURE_STACK 2
|
||||
|
||||
extern void gammaDDUpdateHWState(GLcontext *ctx);
|
||||
extern gammaScreenPtr gammaCreateScreen(__DRIscreenPrivate *sPriv);
|
||||
extern void gammaDestroyScreen(__DRIscreenPrivate *sPriv);
|
||||
extern GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
|
||||
__DRIcontextPrivate *driContextPriv,
|
||||
void *sharedContextPrivate);
|
||||
|
||||
#define GAMMA_UPLOAD_ALL 0xffffffff
|
||||
#define GAMMA_UPLOAD_CLIPRECTS 0x00000002
|
||||
#define GAMMA_UPLOAD_ALPHA 0x00000004
|
||||
#define GAMMA_UPLOAD_BLEND 0x00000008
|
||||
#define GAMMA_UPLOAD_DEPTH 0x00000010
|
||||
#define GAMMA_UPLOAD_VIEWPORT 0x00000020
|
||||
#define GAMMA_UPLOAD_SHADE 0x00000040
|
||||
#define GAMMA_UPLOAD_CLIP 0x00000080
|
||||
#define GAMMA_UPLOAD_MASKS 0x00000100
|
||||
#define GAMMA_UPLOAD_WINDOW 0x00000200 /* defunct */
|
||||
#define GAMMA_UPLOAD_GEOMETRY 0x00000400
|
||||
#define GAMMA_UPLOAD_POLYGON 0x00000800
|
||||
#define GAMMA_UPLOAD_DITHER 0x00001000
|
||||
#define GAMMA_UPLOAD_LOGICOP 0x00002000
|
||||
#define GAMMA_UPLOAD_FOG 0x00004000
|
||||
#define GAMMA_UPLOAD_LIGHT 0x00008000
|
||||
#define GAMMA_UPLOAD_CONTEXT 0x00010000
|
||||
#define GAMMA_UPLOAD_TEX0 0x00020000
|
||||
#define GAMMA_UPLOAD_STIPPLE 0x00040000
|
||||
#define GAMMA_UPLOAD_TRANSFORM 0x00080000
|
||||
#define GAMMA_UPLOAD_LINEMODE 0x00100000
|
||||
#define GAMMA_UPLOAD_POINTMODE 0x00200000
|
||||
#define GAMMA_UPLOAD_TRIMODE 0x00400000
|
||||
|
||||
#define GAMMA_NEW_CLIP 0x00000001
|
||||
#define GAMMA_NEW_WINDOW 0x00000002
|
||||
#define GAMMA_NEW_CONTEXT 0x00000004
|
||||
#define GAMMA_NEW_TEXTURE 0x00000008 /* defunct */
|
||||
#define GAMMA_NEW_ALPHA 0x00000010
|
||||
#define GAMMA_NEW_DEPTH 0x00000020
|
||||
#define GAMMA_NEW_MASKS 0x00000040
|
||||
#define GAMMA_NEW_POLYGON 0x00000080
|
||||
#define GAMMA_NEW_CULL 0x00000100
|
||||
#define GAMMA_NEW_LOGICOP 0x00000200
|
||||
#define GAMMA_NEW_FOG 0x00000400
|
||||
#define GAMMA_NEW_LIGHT 0x00000800
|
||||
#define GAMMA_NEW_STIPPLE 0x00001000
|
||||
#define GAMMA_NEW_ALL 0xffffffff
|
||||
|
||||
#define GAMMA_FALLBACK_TRI 0x00000001
|
||||
#define GAMMA_FALLBACK_TEXTURE 0x00000002
|
||||
|
||||
#define FLUSH_BATCH(gmesa) do { \
|
||||
/*FLUSH_DMA_BUFFER(gmesa);*/ \
|
||||
} while(0)
|
||||
|
||||
struct gamma_context;
|
||||
typedef struct gamma_context gammaContextRec;
|
||||
typedef struct gamma_context *gammaContextPtr;
|
||||
typedef struct gamma_texture_object_t *gammaTextureObjectPtr;
|
||||
|
||||
#define VALID_GAMMA_TEXTURE_OBJECT(tobj) (tobj)
|
||||
|
||||
#define GAMMA_TEX_MAXLEVELS 12
|
||||
|
||||
/* For shared texture space managment, these texture objects may also
|
||||
* be used as proxies for regions of texture memory containing other
|
||||
* client's textures. Such proxy textures (not to be confused with GL
|
||||
* proxy textures) are subject to the same LRU aging we use for our
|
||||
* own private textures, and thus we have a mechanism where we can
|
||||
* fairly decide between kicking out our own textures and those of
|
||||
* other clients.
|
||||
*
|
||||
* Non-local texture objects have a valid MemBlock to describe the
|
||||
* region managed by the other client, and can be identified by
|
||||
* 't->globj == 0'
|
||||
*/
|
||||
struct gamma_texture_object_t {
|
||||
struct gamma_texture_object_t *next, *prev;
|
||||
|
||||
GLuint age;
|
||||
struct gl_texture_object *globj;
|
||||
|
||||
int Pitch;
|
||||
int Height;
|
||||
int texelBytes;
|
||||
int totalSize;
|
||||
int bound;
|
||||
|
||||
PMemBlock MemBlock;
|
||||
char * BufAddr;
|
||||
|
||||
GLuint min_level;
|
||||
GLuint max_level;
|
||||
GLuint dirty_images;
|
||||
|
||||
GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
|
||||
|
||||
struct {
|
||||
const struct gl_texture_image *image;
|
||||
int offset; /* into BufAddr */
|
||||
int height;
|
||||
int internalFormat;
|
||||
} image[GAMMA_TEX_MAXLEVELS];
|
||||
|
||||
CARD32 TextureBaseAddr[GAMMA_TEX_MAXLEVELS];
|
||||
CARD32 TextureAddressMode;
|
||||
CARD32 TextureColorMode;
|
||||
CARD32 TextureFilterMode;
|
||||
CARD32 TextureFormat;
|
||||
CARD32 TextureReadMode;
|
||||
CARD32 TextureBorderColor;
|
||||
};
|
||||
|
||||
#define GAMMA_NO_PALETTE 0x0
|
||||
#define GAMMA_USE_PALETTE 0x1
|
||||
#define GAMMA_UPDATE_PALETTE 0x2
|
||||
#define GAMMA_FALLBACK_PALETTE 0x4
|
||||
|
||||
void gammaUpdateTextureState( GLcontext *ctx );
|
||||
|
||||
void gammaDestroyTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
void gammaSwapOutTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
|
||||
void gammaResetGlobalLRU( gammaContextPtr gmesa );
|
||||
void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t );
|
||||
void gammaTexturesGone( gammaContextPtr gmesa,
|
||||
GLuint start, GLuint end,
|
||||
GLuint in_use );
|
||||
|
||||
void gammaEmitHwState( gammaContextPtr gmesa );
|
||||
void gammaDDInitExtensions( GLcontext *ctx );
|
||||
void gammaDDInitDriverFuncs( GLcontext *ctx );
|
||||
void gammaDDInitSpanFuncs( GLcontext *ctx );
|
||||
void gammaDDInitState( gammaContextPtr gmesa );
|
||||
void gammaInitHW( gammaContextPtr gmesa );
|
||||
void gammaDDInitStateFuncs( GLcontext *ctx );
|
||||
void gammaDDInitTextureFuncs( GLcontext *ctx );
|
||||
void gammaDDInitTriFuncs( GLcontext *ctx );
|
||||
|
||||
void gammaUpdateWindow( GLcontext *ctx );
|
||||
void gammaUpdateViewportOffset( GLcontext *ctx );
|
||||
|
||||
void gammaPrintLocalLRU( gammaContextPtr gmesa );
|
||||
void gammaPrintGlobalLRU( gammaContextPtr gmesa );
|
||||
|
||||
extern void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode );
|
||||
#define FALLBACK( imesa, bit, mode ) gammaFallback( imesa, bit, mode )
|
||||
|
||||
/* Use the templated vertex formats. Only one of these is used in gamma.
|
||||
*/
|
||||
#define TAG(x) gamma##x
|
||||
#include "tnl_dd/t_dd_vertex.h"
|
||||
#undef TAG
|
||||
|
||||
typedef void (*gamma_quad_func)( gammaContextPtr,
|
||||
const gammaVertex *,
|
||||
const gammaVertex *,
|
||||
const gammaVertex *,
|
||||
const gammaVertex * );
|
||||
typedef void (*gamma_tri_func)( gammaContextPtr,
|
||||
const gammaVertex *,
|
||||
const gammaVertex *,
|
||||
const gammaVertex * );
|
||||
typedef void (*gamma_line_func)( gammaContextPtr,
|
||||
const gammaVertex *,
|
||||
const gammaVertex * );
|
||||
typedef void (*gamma_point_func)( gammaContextPtr,
|
||||
const gammaVertex * );
|
||||
|
||||
|
||||
struct gamma_context {
|
||||
GLcontext *glCtx; /* Mesa context */
|
||||
|
||||
__DRIcontextPrivate *driContext;
|
||||
__DRIscreenPrivate *driScreen;
|
||||
__DRIdrawablePrivate *driDrawable;
|
||||
|
||||
GLuint new_gl_state;
|
||||
GLuint new_state;
|
||||
GLuint dirty;
|
||||
|
||||
GLINTSAREADRIPtr sarea;
|
||||
|
||||
/* Temporaries for translating away float colors:
|
||||
*/
|
||||
struct gl_client_array UbyteColor;
|
||||
struct gl_client_array UbyteSecondaryColor;
|
||||
|
||||
/* Mirrors of some DRI state
|
||||
*/
|
||||
drmContext hHWContext;
|
||||
drmLock *driHwLock;
|
||||
int driFd;
|
||||
|
||||
GLuint numClipRects; /* Cliprects for the draw buffer */
|
||||
XF86DRIClipRectPtr pClipRects;
|
||||
|
||||
dmaBuf buf; /* DMA buffer for regular cmds */
|
||||
int bufIndex;
|
||||
int bufSize;
|
||||
int bufCount;
|
||||
|
||||
dmaBuf WCbuf; /* DMA buffer for window changed cmds */
|
||||
int WCbufIndex;
|
||||
int WCbufSize;
|
||||
int WCbufCount;
|
||||
|
||||
gammaScreenPtr gammaScreen; /* Screen private DRI data */
|
||||
|
||||
int drawOffset;
|
||||
int readOffset;
|
||||
|
||||
gamma_point_func draw_point;
|
||||
gamma_line_func draw_line;
|
||||
gamma_tri_func draw_tri;
|
||||
gamma_quad_func draw_quad;
|
||||
|
||||
GLuint Fallback;
|
||||
GLuint RenderIndex;
|
||||
GLuint SetupNewInputs;
|
||||
GLuint SetupIndex;
|
||||
|
||||
GLuint vertex_format;
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_stride_shift;
|
||||
GLubyte *verts;
|
||||
|
||||
GLfloat hw_viewport[16];
|
||||
GLuint hw_primitive;
|
||||
GLenum render_primitive;
|
||||
|
||||
GLfloat depth_scale;
|
||||
|
||||
gammaTextureObjectPtr CurrentTexObj[2];
|
||||
struct gamma_texture_object_t TexObjList;
|
||||
struct gamma_texture_object_t SwappedOut;
|
||||
GLenum TexEnvImageFmt[2];
|
||||
|
||||
memHeap_t *texHeap;
|
||||
|
||||
unsigned int lastSwap;
|
||||
int texAge;
|
||||
int ctxAge;
|
||||
int dirtyAge;
|
||||
unsigned int lastStamp;
|
||||
|
||||
|
||||
CARD32 ClearColor;
|
||||
CARD32 Color;
|
||||
CARD32 DitherMode;
|
||||
CARD32 ClearDepth;
|
||||
CARD32 FogMode;
|
||||
CARD32 AreaStippleMode;
|
||||
CARD32 LBReadFormat;
|
||||
CARD32 LBWriteFormat;
|
||||
CARD32 LineMode;
|
||||
CARD32 PointMode;
|
||||
CARD32 TriangleMode;
|
||||
CARD32 AntialiasMode;
|
||||
GLfloat ViewportScaleX;
|
||||
GLfloat ViewportScaleY;
|
||||
GLfloat ViewportScaleZ;
|
||||
GLfloat ViewportOffsetX;
|
||||
GLfloat ViewportOffsetY;
|
||||
GLfloat ViewportOffsetZ;
|
||||
int MatrixMode;
|
||||
int DepthMode;
|
||||
int TransformMode;
|
||||
int LBReadMode;
|
||||
int FBReadMode;
|
||||
int FBWindowBase;
|
||||
int LBWindowBase;
|
||||
int ColorDDAMode;
|
||||
int GeometryMode;
|
||||
int AlphaTestMode;
|
||||
int AlphaBlendMode;
|
||||
int AB_FBReadMode;
|
||||
int AB_FBReadMode_Save;
|
||||
int DeltaMode;
|
||||
int ColorMaterialMode;
|
||||
int FBHardwareWriteMask;
|
||||
int MaterialMode;
|
||||
int NormalizeMode;
|
||||
int LightingMode;
|
||||
int Light0Mode;
|
||||
int Light1Mode;
|
||||
int Light2Mode;
|
||||
int Light3Mode;
|
||||
int Light4Mode;
|
||||
int Light5Mode;
|
||||
int Light6Mode;
|
||||
int Light7Mode;
|
||||
int Light8Mode;
|
||||
int Light9Mode;
|
||||
int Light10Mode;
|
||||
int Light11Mode;
|
||||
int Light12Mode;
|
||||
int Light13Mode;
|
||||
int Light14Mode;
|
||||
int Light15Mode;
|
||||
int LogicalOpMode;
|
||||
int ScissorMode;
|
||||
int ScissorMaxXY;
|
||||
int ScissorMinXY;
|
||||
int Window; /* GID part probably should be in draw priv */
|
||||
int WindowOrigin;
|
||||
int x, y, w, h; /* Probably should be in drawable priv */
|
||||
int FrameCount; /* Probably should be in drawable priv */
|
||||
int NotClipped; /* Probably should be in drawable priv */
|
||||
int WindowChanged; /* Probably should be in drawabl... */
|
||||
int Flags;
|
||||
int EnabledFlags;
|
||||
int DepthSize;
|
||||
int Begin;
|
||||
GLenum ErrorValue;
|
||||
int Texture1DEnabled;
|
||||
int Texture2DEnabled;
|
||||
|
||||
float ModelView[16];
|
||||
float Proj[16];
|
||||
float ModelViewProj[16];
|
||||
float Texture[16];
|
||||
|
||||
float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
|
||||
int ModelViewCount;
|
||||
float ProjStack[(MAX_PROJECTION_STACK-1)*16];
|
||||
int ProjCount;
|
||||
float TextureStack[(MAX_TEXTURE_STACK-1)*16];
|
||||
int TextureCount;
|
||||
};
|
||||
|
||||
static __inline GLuint gammaPackColor( GLuint cpp,
|
||||
GLubyte r, GLubyte g,
|
||||
GLubyte b, GLubyte a )
|
||||
{
|
||||
switch ( cpp ) {
|
||||
case 2:
|
||||
return PACK_COLOR_565( r, g, b );
|
||||
case 4:
|
||||
return PACK_COLOR_8888( a, r, g, b );
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define GAMMA_CONTEXT(ctx) ((gammaContextPtr)(ctx->DriverCtx))
|
||||
|
||||
#endif /* _GAMMA_CONTEXT_H_ */
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_lock.h"
|
||||
#if defined(USE_X86_ASM)
|
||||
#include "X86/common_x86_asm.h"
|
||||
#endif
|
||||
|
||||
#include "context.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define GAMMA_DATE "20021125"
|
||||
|
||||
|
||||
/* Return the width and height of the current color buffer.
|
||||
*/
|
||||
static void gammaDDGetBufferSize( GLframebuffer *buffer,
|
||||
GLuint *width, GLuint *height )
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
GAMMAHW_LOCK( gmesa );
|
||||
*width = gmesa->driDrawable->w;
|
||||
*height = gmesa->driDrawable->h;
|
||||
GAMMAHW_UNLOCK( gmesa );
|
||||
}
|
||||
|
||||
|
||||
/* Return various strings for glGetString().
|
||||
*/
|
||||
static const GLubyte *gammaDDGetString( GLcontext *ctx, GLenum name )
|
||||
{
|
||||
static char buffer[128];
|
||||
|
||||
switch ( name ) {
|
||||
case GL_VENDOR:
|
||||
return (GLubyte *)"VA Linux Systems, Inc.";
|
||||
|
||||
case GL_RENDERER:
|
||||
sprintf( buffer, "Mesa DRI Gamma " GAMMA_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 gammaDDInitExtensions( GLcontext *ctx )
|
||||
{
|
||||
/* None... */
|
||||
}
|
||||
|
||||
/* Initialize the driver's misc functions.
|
||||
*/
|
||||
void gammaDDInitDriverFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.GetBufferSize = gammaDDGetBufferSize;
|
||||
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
|
||||
ctx->Driver.GetString = gammaDDGetString;
|
||||
|
||||
ctx->Driver.Error = NULL;
|
||||
|
||||
/* Pixel path fallbacks
|
||||
*/
|
||||
ctx->Driver.Accum = _swrast_Accum;
|
||||
ctx->Driver.Bitmap = _swrast_Bitmap;
|
||||
ctx->Driver.CopyPixels = _swrast_CopyPixels;
|
||||
ctx->Driver.DrawPixels = _swrast_DrawPixels;
|
||||
ctx->Driver.ReadPixels = _swrast_ReadPixels;
|
||||
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
|
||||
|
||||
/* Swrast hooks for imaging extensions:
|
||||
*/
|
||||
ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
|
||||
ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
|
||||
ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
|
||||
ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
|
||||
}
|
||||
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
* Kevin E. Martin <martin@valinux.com>
|
||||
*
|
||||
*/
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c,v 1.9 2002/10/30 12:51:29 alanh Exp $ */
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "glint_dri.h"
|
||||
|
||||
void gammaInitHW( gammaContextPtr gmesa )
|
||||
{
|
||||
GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv;
|
||||
int i;
|
||||
|
||||
if (gDRIPriv->numMultiDevices == 2) {
|
||||
/* Set up each MX's ScanLineOwnership for OpenGL */
|
||||
CHECK_DMA_BUFFER(gmesa, 5);
|
||||
WRITE(gmesa->buf, BroadcastMask, 1);
|
||||
WRITE(gmesa->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */
|
||||
WRITE(gmesa->buf, BroadcastMask, 2);
|
||||
WRITE(gmesa->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */
|
||||
/* Broadcast to both MX's */
|
||||
WRITE(gmesa->buf, BroadcastMask, 3);
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
|
||||
gmesa->AlphaBlendMode = (AlphaBlendModeDisable |
|
||||
AB_Src_One |
|
||||
AB_Dst_Zero |
|
||||
AB_NoAlphaBufferPresent |
|
||||
AB_ColorFmt_8888 |
|
||||
AB_ColorOrder_RGB |
|
||||
AB_OpenGLType |
|
||||
AB_AlphaDst_FBData |
|
||||
AB_ColorConversionScale |
|
||||
AB_AlphaConversionScale);
|
||||
|
||||
gmesa->DitherMode = DitherModeEnable | DM_ColorOrder_RGB;
|
||||
|
||||
switch (gmesa->gammaScreen->cpp) {
|
||||
case 2:
|
||||
gmesa->DitherMode |= DM_ColorFmt_5555;
|
||||
gmesa->AlphaBlendMode |= AB_ColorFmt_5555;
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PixelSize, 1);
|
||||
break;
|
||||
case 4:
|
||||
gmesa->DitherMode |= DM_ColorFmt_8888;
|
||||
gmesa->AlphaBlendMode |= AB_ColorFmt_8888;
|
||||
WRITE(gmesa->buf, PixelSize, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* FIXME for stencil, gid, etc */
|
||||
switch (gmesa->DepthSize) {
|
||||
case 16:
|
||||
gmesa->LBReadFormat =
|
||||
(LBRF_DepthWidth16 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos16 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos24 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos32 );
|
||||
gmesa->LBWriteFormat =
|
||||
(LBRF_DepthWidth16 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos16 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos24 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos32 );
|
||||
break;
|
||||
case 24:
|
||||
gmesa->LBReadFormat =
|
||||
(LBRF_DepthWidth24 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos24 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos32 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos36 );
|
||||
gmesa->LBWriteFormat =
|
||||
(LBRF_DepthWidth24 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos24 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos32 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos36 );
|
||||
break;
|
||||
case 32:
|
||||
gmesa->LBReadFormat =
|
||||
(LBRF_DepthWidth32 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos32 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos40 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos44 );
|
||||
gmesa->LBWriteFormat =
|
||||
(LBRF_DepthWidth32 |
|
||||
LBRF_StencilWidth8 |
|
||||
LBRF_StencilPos32 |
|
||||
LBRF_FrameCount8 |
|
||||
LBRF_FrameCountPos40 |
|
||||
LBRF_GIDWidth4 |
|
||||
LBRF_GIDPos44 );
|
||||
break;
|
||||
}
|
||||
|
||||
gmesa->FBHardwareWriteMask = 0xffffffff;
|
||||
gmesa->FogMode = FogModeDisable;
|
||||
gmesa->ClearDepth = 0xffffffff;
|
||||
gmesa->AreaStippleMode = AreaStippleModeDisable;
|
||||
gmesa->x = 0;
|
||||
gmesa->y = 0;
|
||||
gmesa->w = 0;
|
||||
gmesa->h = 0;
|
||||
gmesa->FrameCount = 0;
|
||||
gmesa->MatrixMode = GL_MODELVIEW;
|
||||
gmesa->ModelViewCount = 0;
|
||||
gmesa->ProjCount = 0;
|
||||
gmesa->TextureCount = 0;
|
||||
gmesa->PointMode = PM_AntialiasQuality_4x4;
|
||||
gmesa->LineMode = LM_AntialiasQuality_4x4;
|
||||
gmesa->TriangleMode = TM_AntialiasQuality_4x4;
|
||||
gmesa->AntialiasMode = AntialiasModeDisable;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
if (i % 5 == 0)
|
||||
gmesa->ModelView[i] =
|
||||
gmesa->Proj[i] =
|
||||
gmesa->ModelViewProj[i] =
|
||||
gmesa->Texture[i] = 1.0;
|
||||
else
|
||||
gmesa->ModelView[i] =
|
||||
gmesa->Proj[i] =
|
||||
gmesa->ModelViewProj[i] =
|
||||
gmesa->Texture[i] = 0.0;
|
||||
|
||||
gmesa->LBReadMode = (LBReadSrcDisable |
|
||||
LBReadDstDisable |
|
||||
LBDataTypeDefault |
|
||||
LBWindowOriginBot |
|
||||
gDRIPriv->pprod);
|
||||
gmesa->FBReadMode = (FBReadSrcDisable |
|
||||
FBReadDstDisable |
|
||||
FBDataTypeDefault |
|
||||
FBWindowOriginBot |
|
||||
gDRIPriv->pprod);
|
||||
|
||||
if (gDRIPriv->numMultiDevices == 2) {
|
||||
gmesa->LBReadMode |= LBScanLineInt2;
|
||||
gmesa->FBReadMode |= FBScanLineInt2;
|
||||
gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight/2 - 1);
|
||||
gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight/2 - 1);
|
||||
} else {
|
||||
gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight - 1);
|
||||
gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
|
||||
(gmesa->driScreen->fbHeight - 1);
|
||||
}
|
||||
|
||||
gmesa->Begin = (B_AreaStippleDisable |
|
||||
B_LineStippleDisable |
|
||||
B_AntiAliasDisable |
|
||||
B_TextureDisable |
|
||||
B_FogDisable |
|
||||
B_SubPixelCorrectEnable |
|
||||
B_PrimType_Null);
|
||||
|
||||
gmesa->ColorDDAMode = (ColorDDAEnable |
|
||||
ColorDDAGouraud);
|
||||
|
||||
gmesa->GeometryMode = (GM_TextureDisable |
|
||||
GM_FogDisable |
|
||||
GM_FogExp |
|
||||
GM_FrontPolyFill |
|
||||
GM_BackPolyFill |
|
||||
GM_FrontFaceCCW |
|
||||
GM_PolyCullDisable |
|
||||
GM_PolyCullBack |
|
||||
GM_ClipShortLinesDisable |
|
||||
GM_ClipSmallTrisDisable |
|
||||
GM_RenderMode |
|
||||
GM_Feedback2D |
|
||||
GM_CullFaceNormDisable |
|
||||
GM_AutoFaceNormDisable |
|
||||
GM_GouraudShading |
|
||||
GM_UserClipNone |
|
||||
GM_PolyOffsetPointDisable |
|
||||
GM_PolyOffsetLineDisable |
|
||||
GM_PolyOffsetFillDisable |
|
||||
GM_InvertFaceNormCullDisable);
|
||||
|
||||
gmesa->AlphaTestMode = (AlphaTestModeDisable |
|
||||
AT_Always);
|
||||
|
||||
gmesa->AB_FBReadMode_Save = gmesa->AB_FBReadMode = 0;
|
||||
|
||||
gmesa->Window = (WindowEnable | /* For GID testing */
|
||||
W_PassIfEqual |
|
||||
(0 << 5)); /* GID part is set from draw priv (below) */
|
||||
|
||||
gmesa->NotClipped = GL_FALSE;
|
||||
gmesa->WindowChanged = GL_TRUE;
|
||||
|
||||
gmesa->Texture1DEnabled = GL_FALSE;
|
||||
gmesa->Texture2DEnabled = GL_FALSE;
|
||||
|
||||
gmesa->DepthMode |= (DepthModeDisable |
|
||||
DM_WriteMask |
|
||||
DM_Less);
|
||||
|
||||
gmesa->DeltaMode |= (DM_SubPixlCorrectionEnable |
|
||||
DM_SmoothShadingEnable |
|
||||
DM_Target500TXMX);
|
||||
|
||||
gmesa->LightingMode = LightingModeDisable | LightingModeSpecularEnable;
|
||||
gmesa->Light0Mode = LNM_Off;
|
||||
gmesa->Light1Mode = LNM_Off;
|
||||
gmesa->Light2Mode = LNM_Off;
|
||||
gmesa->Light3Mode = LNM_Off;
|
||||
gmesa->Light4Mode = LNM_Off;
|
||||
gmesa->Light5Mode = LNM_Off;
|
||||
gmesa->Light6Mode = LNM_Off;
|
||||
gmesa->Light7Mode = LNM_Off;
|
||||
gmesa->Light8Mode = LNM_Off;
|
||||
gmesa->Light9Mode = LNM_Off;
|
||||
gmesa->Light10Mode = LNM_Off;
|
||||
gmesa->Light11Mode = LNM_Off;
|
||||
gmesa->Light12Mode = LNM_Off;
|
||||
gmesa->Light13Mode = LNM_Off;
|
||||
gmesa->Light14Mode = LNM_Off;
|
||||
gmesa->Light15Mode = LNM_Off;
|
||||
|
||||
gmesa->LogicalOpMode = LogicalOpModeDisable;
|
||||
|
||||
gmesa->MaterialMode = MaterialModeDisable;
|
||||
|
||||
gmesa->ScissorMode = UserScissorDisable | ScreenScissorDisable;
|
||||
|
||||
gmesa->TransformMode = XM_UseModelViewProjMatrix |
|
||||
XM_TexGenModeS_None |
|
||||
XM_TexGenModeT_None |
|
||||
XM_TexGenModeR_None |
|
||||
XM_TexGenModeQ_None;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 20);
|
||||
WRITE(gmesa->buf, LineStippleMode, 0);
|
||||
WRITE(gmesa->buf, RouterMode, 0);
|
||||
WRITE(gmesa->buf, TextureAddressMode, 0);
|
||||
WRITE(gmesa->buf, TextureReadMode, 0);
|
||||
WRITE(gmesa->buf, TextureFilterMode, 0);
|
||||
WRITE(gmesa->buf, TextureColorMode, 0);
|
||||
WRITE(gmesa->buf, StencilMode, 0);
|
||||
WRITE(gmesa->buf, PatternRamMode, 0);
|
||||
WRITE(gmesa->buf, ChromaTestMode, 0);
|
||||
WRITE(gmesa->buf, StatisticMode, 0);
|
||||
WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode);
|
||||
WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode);
|
||||
WRITE(gmesa->buf, FogMode, gmesa->FogMode);
|
||||
WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode);
|
||||
WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode);
|
||||
WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode);
|
||||
WRITE(gmesa->buf, PointMode, gmesa->PointMode);
|
||||
WRITE(gmesa->buf, LineMode, gmesa->LineMode);
|
||||
WRITE(gmesa->buf, LBWriteFormat, gmesa->LBWriteFormat);
|
||||
WRITE(gmesa->buf, LBReadFormat, gmesa->LBReadFormat);
|
||||
|
||||
/* Framebuffer initialization */
|
||||
CHECK_DMA_BUFFER(gmesa, 10);
|
||||
WRITE(gmesa->buf, FBSourceData, 0);
|
||||
WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
|
||||
if (gDRIPriv->numMultiDevices == 2) {
|
||||
WRITE(gmesa->buf, FBPixelOffset,
|
||||
(gmesa->driScreen->fbHeight/2)*gmesa->driScreen->fbWidth);
|
||||
} else {
|
||||
WRITE(gmesa->buf, FBPixelOffset,
|
||||
gmesa->driScreen->fbHeight*gmesa->driScreen->fbWidth);
|
||||
}
|
||||
} else
|
||||
WRITE(gmesa->buf, FBPixelOffset, 0);
|
||||
WRITE(gmesa->buf, FBSourceOffset, 0);
|
||||
WRITE(gmesa->buf, FBHardwareWriteMask, 0xffffffff);
|
||||
WRITE(gmesa->buf, FBSoftwareWriteMask, 0xffffffff);
|
||||
WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
|
||||
WRITE(gmesa->buf, FBWindowBase, gmesa->FBWindowBase);
|
||||
WRITE(gmesa->buf, ScreenSize, ((gmesa->driScreen->fbHeight << 16) |
|
||||
(gmesa->driScreen->fbWidth)));
|
||||
WRITE(gmesa->buf, WindowOrigin, 0x00000000);
|
||||
|
||||
/* Localbuffer initialization */
|
||||
CHECK_DMA_BUFFER(gmesa, 5);
|
||||
WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
|
||||
WRITE(gmesa->buf, LBSourceOffset, 0);
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
|
||||
WRITE(gmesa->buf, LBWindowOffset, 0);
|
||||
WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Rectangle2DControl, 1);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 11);
|
||||
WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
|
||||
WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
|
||||
WRITE(gmesa->buf, FBBlockColor, 0x00000000);
|
||||
WRITE(gmesa->buf, ConstantColor, 0x00000000);
|
||||
WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode);
|
||||
WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
|
||||
WRITE(gmesa->buf, DitherMode, gmesa->DitherMode);
|
||||
if (gDRIPriv->numMultiDevices == 2)
|
||||
WRITE(gmesa->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf);
|
||||
else
|
||||
WRITE(gmesa->buf, RasterizerMode, RM_BiasCoordNearHalf);
|
||||
WRITE(gmesa->buf, GLINTWindow, gmesa->Window);
|
||||
WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth);
|
||||
WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, EdgeFlag, EdgeFlagEnable);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix4, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix5, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix8, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix9, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix10, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix11, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix12, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix13, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix14, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewMatrix15, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix4, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix5, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix8, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix9, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix10, 1.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix11, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix12, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix13, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix14, 0.0);
|
||||
WRITEF(gmesa->buf, ModelViewProjectionMatrix15, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, TextureMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix4, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix5, 1.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix8, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix9, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix10, 1.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix11, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix12, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix13, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix14, 0.0);
|
||||
WRITEF(gmesa->buf, TextureMatrix15, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITEF(gmesa->buf, TexGen0, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen1, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen2, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen3, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen4, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen5, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen6, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen7, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen8, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen9, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen10, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen11, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen12, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen13, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen14, 0.0);
|
||||
WRITEF(gmesa->buf, TexGen15, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 9);
|
||||
WRITEF(gmesa->buf, NormalMatrix0, 1.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix1, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix2, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix3, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix4, 1.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix5, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix6, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix7, 0.0);
|
||||
WRITEF(gmesa->buf, NormalMatrix8, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 3);
|
||||
WRITEF(gmesa->buf, FogDensity, 0.0);
|
||||
WRITEF(gmesa->buf, FogEnd, 0.0);
|
||||
WRITEF(gmesa->buf, FogScale, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITEF(gmesa->buf, LineClipLengthThreshold, 0.0);
|
||||
WRITEF(gmesa->buf, TriangleClipAreaThreshold, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 5);
|
||||
WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
|
||||
WRITE(gmesa->buf, NormalizeMode, NormalizeModeDisable);
|
||||
WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
|
||||
WRITE(gmesa->buf, ColorMaterialMode, ColorMaterialModeDisable);
|
||||
WRITE(gmesa->buf, MaterialMode, MaterialModeDisable);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, FrontSpecularExponent, 0); /* fixed point */
|
||||
WRITE(gmesa->buf, BackSpecularExponent, 0); /* fixed point */
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 29);
|
||||
WRITEF(gmesa->buf, FrontAmbientColorRed, 0.2);
|
||||
WRITEF(gmesa->buf, FrontAmbientColorGreen, 0.2);
|
||||
WRITEF(gmesa->buf, FrontAmbientColorBlue, 0.2);
|
||||
WRITEF(gmesa->buf, BackAmbientColorRed, 0.2);
|
||||
WRITEF(gmesa->buf, BackAmbientColorGreen, 0.2);
|
||||
WRITEF(gmesa->buf, BackAmbientColorBlue, 0.2);
|
||||
WRITEF(gmesa->buf, FrontDiffuseColorRed, 0.8);
|
||||
WRITEF(gmesa->buf, FrontDiffuseColorGreen, 0.8);
|
||||
WRITEF(gmesa->buf, FrontDiffuseColorBlue, 0.8);
|
||||
WRITEF(gmesa->buf, BackDiffuseColorRed, 0.8);
|
||||
WRITEF(gmesa->buf, BackDiffuseColorGreen, 0.8);
|
||||
WRITEF(gmesa->buf, BackDiffuseColorBlue, 0.8);
|
||||
WRITEF(gmesa->buf, FrontSpecularColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, FrontSpecularColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, FrontSpecularColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, BackSpecularColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, BackSpecularColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, BackSpecularColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, FrontEmissiveColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, FrontEmissiveColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, FrontEmissiveColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, BackEmissiveColorRed, 0.0);
|
||||
WRITEF(gmesa->buf, BackEmissiveColorGreen, 0.0);
|
||||
WRITEF(gmesa->buf, BackEmissiveColorBlue, 0.0);
|
||||
WRITEF(gmesa->buf, SceneAmbientColorRed, 0.2);
|
||||
WRITEF(gmesa->buf, SceneAmbientColorGreen, 0.2);
|
||||
WRITEF(gmesa->buf, SceneAmbientColorBlue, 0.2);
|
||||
WRITEF(gmesa->buf, FrontAlpha, 1.0);
|
||||
WRITEF(gmesa->buf, BackAlpha, 1.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 7);
|
||||
WRITE(gmesa->buf, PointSize, 1);
|
||||
WRITEF(gmesa->buf, AApointSize, 1.0);
|
||||
WRITE(gmesa->buf, LineWidth, 1);
|
||||
WRITEF(gmesa->buf, AAlineWidth, 1.0);
|
||||
WRITE(gmesa->buf, LineWidthOffset, 0);
|
||||
WRITE(gmesa->buf, TransformMode, gmesa->TransformMode);
|
||||
WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITE(gmesa->buf, Light0Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light1Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light2Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light3Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light4Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light5Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light6Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light7Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light8Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light9Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light10Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light11Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light12Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light13Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light14Mode, LNM_Off);
|
||||
WRITE(gmesa->buf, Light15Mode, LNM_Off);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 22);
|
||||
WRITEF(gmesa->buf, Light0AmbientIntensityBlue, 0.0);
|
||||
WRITEF(gmesa->buf, Light0AmbientIntensityGreen, 0.0);
|
||||
WRITEF(gmesa->buf, Light0AmbientIntensityRed, 0.0);
|
||||
WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, 1.0);
|
||||
WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, 1.0);
|
||||
WRITEF(gmesa->buf, Light0DiffuseIntensityRed, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpecularIntensityBlue, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpecularIntensityGreen, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpecularIntensityRed, 1.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightDirectionZ, 0.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightDirectionY, 0.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightDirectionX, -1.0);
|
||||
WRITEF(gmesa->buf, Light0SpotlightExponent, 0.0);
|
||||
WRITEF(gmesa->buf, Light0PositionZ, 0.0);
|
||||
WRITEF(gmesa->buf, Light0PositionY, 0.0);
|
||||
WRITEF(gmesa->buf, Light0PositionX, 1.0);
|
||||
WRITEF(gmesa->buf, Light0PositionW, 0.0);
|
||||
WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, -1.0);
|
||||
WRITEF(gmesa->buf, Light0ConstantAttenuation, 1.0);
|
||||
WRITEF(gmesa->buf, Light0LinearAttenuation, 0.0);
|
||||
WRITEF(gmesa->buf, Light0QuadraticAttenuation,0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITEF(gmesa->buf, XBias, 0.0);
|
||||
WRITEF(gmesa->buf, YBias, 0.0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, ViewPortScaleX, gmesa->driScreen->fbWidth/4);
|
||||
WRITEF(gmesa->buf, ViewPortScaleY, gmesa->driScreen->fbHeight/4);
|
||||
WRITEF(gmesa->buf, ViewPortScaleZ, 1.0f);
|
||||
WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->x);
|
||||
WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->y);
|
||||
WRITEF(gmesa->buf, ViewPortOffsetZ, 0.0f);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 3);
|
||||
WRITEF(gmesa->buf, Nz, 1.0);
|
||||
WRITEF(gmesa->buf, Ny, 0.0);
|
||||
WRITEF(gmesa->buf, Nx, 0.0);
|
||||
|
||||
/* Send the initialization commands to the HW */
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_lock.h"
|
||||
|
||||
#ifdef DEBUG_LOCKING
|
||||
char *prevLockFile = NULL;
|
||||
int prevLockLine = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/* Update the hardware state. This is called if another context has
|
||||
* grabbed the hardware lock, which includes the X server. This
|
||||
* function also updates the driver's window state after the X server
|
||||
* moves, resizes or restacks a window -- the change will be reflected
|
||||
* in the drawable position and clip rects. Since the X server grabs
|
||||
* the hardware lock when it changes the window state, this routine will
|
||||
* automatically be called after such a change.
|
||||
*/
|
||||
void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
|
||||
{
|
||||
__DRIdrawablePrivate *dPriv = gmesa->driDrawable;
|
||||
__DRIscreenPrivate *sPriv = gmesa->driScreen;
|
||||
|
||||
drmGetLock( gmesa->driFd, gmesa->hHWContext, flags );
|
||||
|
||||
/* The window might have moved, so we might need to get new clip
|
||||
* rects.
|
||||
*
|
||||
* NOTE: This releases and regrabs the hw lock to allow the X server
|
||||
* to respond to the DRI protocol request for new drawable info.
|
||||
* Since the hardware state depends on having the latest drawable
|
||||
* clip rects, all state checking must be done _after_ this call.
|
||||
*/
|
||||
DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
|
||||
|
||||
if ( gmesa->lastStamp != dPriv->lastStamp ) {
|
||||
gmesa->lastStamp = dPriv->lastStamp;
|
||||
gmesa->new_state |= GAMMA_NEW_WINDOW | GAMMA_NEW_CLIP;
|
||||
}
|
||||
|
||||
gmesa->numClipRects = dPriv->numClipRects;
|
||||
gmesa->pClipRects = dPriv->pClipRects;
|
||||
|
||||
#if 0
|
||||
gmesa->dirty = ~0;
|
||||
|
||||
if ( sarea->ctxOwner != gmesa->hHWContext ) {
|
||||
sarea->ctxOwner = gmesa->hHWContext;
|
||||
gmesa->dirty = GAMMA_UPLOAD_ALL;
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < gmesa->lastTexHeap ; i++ ) {
|
||||
if ( sarea->texAge[i] != gmesa->lastTexAge[i] ) {
|
||||
gammaAgeTextures( gmesa, i );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#ifndef __GAMMA_LOCK_H__
|
||||
#define __GAMMA_LOCK_H__
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
extern void gammaGetLock( gammaContextPtr gmesa, GLuint flags );
|
||||
|
||||
/* Turn DEBUG_LOCKING on to find locking conflicts.
|
||||
*/
|
||||
#define DEBUG_LOCKING 0
|
||||
|
||||
#if DEBUG_LOCKING
|
||||
extern char *prevLockFile;
|
||||
extern int prevLockLine;
|
||||
|
||||
#define DEBUG_LOCK() \
|
||||
do { \
|
||||
prevLockFile = (__FILE__); \
|
||||
prevLockLine = (__LINE__); \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_RESET() \
|
||||
do { \
|
||||
prevLockFile = 0; \
|
||||
prevLockLine = 0; \
|
||||
} while (0)
|
||||
|
||||
#define DEBUG_CHECK_LOCK() \
|
||||
do { \
|
||||
if ( prevLockFile ) { \
|
||||
fprintf( stderr, \
|
||||
"LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
|
||||
prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
|
||||
exit( 1 ); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define DEBUG_LOCK()
|
||||
#define DEBUG_RESET()
|
||||
#define DEBUG_CHECK_LOCK()
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* !!! We may want to separate locks from locks with validation. This
|
||||
* could be used to improve performance for those things commands that
|
||||
* do not do any drawing !!!
|
||||
*/
|
||||
|
||||
/* Lock the hardware and validate our state.
|
||||
*/
|
||||
#define LOCK_HARDWARE( gmesa ) \
|
||||
do { \
|
||||
char __ret = 0; \
|
||||
DEBUG_CHECK_LOCK(); \
|
||||
DRM_CAS( gmesa->driHwLock, gmesa->hHWContext, \
|
||||
(DRM_LOCK_HELD | gmesa->hHWContext), __ret ); \
|
||||
if ( __ret ) \
|
||||
gammaGetLock( gmesa, 0 ); \
|
||||
DEBUG_LOCK(); \
|
||||
} while (0)
|
||||
|
||||
/* Unlock the hardware.
|
||||
*/
|
||||
#define UNLOCK_HARDWARE( gmesa ) \
|
||||
do { \
|
||||
DRM_UNLOCK( gmesa->driFd, \
|
||||
gmesa->driHwLock, \
|
||||
gmesa->hHWContext ); \
|
||||
DEBUG_RESET(); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#define GAMMAHW_LOCK( gmesa ) \
|
||||
DRM_UNLOCK(gmesa->driFd, gmesa->driHwLock, gmesa->hHWContext); \
|
||||
DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
|
||||
gmesa->driScreen->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
|
||||
|
||||
#define GAMMAHW_UNLOCK( gmesa ) \
|
||||
DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
|
||||
gmesa->driScreen->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
|
||||
|
||||
#endif /* __GAMMA_LOCK_H__ */
|
||||
@@ -0,0 +1,328 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h,v 1.5 2002/02/22 21:33:02 dawes Exp $ */
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
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, sub license, 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 (including the
|
||||
next paragraph) 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 NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Kevin E. Martin <kevin@precisioninsight.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_MACROS_H_
|
||||
#define _GAMMA_MACROS_H_
|
||||
|
||||
#ifdef GLX_DIRECT_RENDERING
|
||||
|
||||
#define DEBUG_DRMDMA
|
||||
#define DEBUG_ERRORS
|
||||
#define DEBUG_COMMANDS_NOT
|
||||
#define DEBUG_VERBOSE_NOT
|
||||
#define DEBUG_VERBOSE_EXTRA_NOT
|
||||
|
||||
#define RANDOMIZE_COLORS_NOT
|
||||
#define TURN_OFF_CLEARS_NOT
|
||||
#define CULL_ALL_PRIMS_NOT
|
||||
#define TURN_OFF_DEPTH_NOT
|
||||
#define TURN_OFF_BLEND_NOT
|
||||
#define FAST_CLEAR_4_NOT
|
||||
#define FORCE_DEPTH32_NOT
|
||||
#define DONT_SEND_DMA_NOT
|
||||
#define TURN_OFF_FCP_NOT
|
||||
#define TURN_OFF_TEXTURES_NOT
|
||||
#define DO_VALIDATE
|
||||
|
||||
#define GAMMA_DMA_BUFFER_SIZE 4096
|
||||
|
||||
#if 0
|
||||
#define GAMMA_DMA_SEND_FLAGS DRM_DMA_PRIORITY
|
||||
#define GAMMA_DMA_SEND_FLAGS DRM_DMA_BLOCK
|
||||
#else
|
||||
/* MUST use non-blocking dma flags for drawable lock routines */
|
||||
#define GAMMA_DMA_SEND_FLAGS 0
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define GAMMA_DMA_GET_FLAGS \
|
||||
(DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT)
|
||||
#else
|
||||
#define GAMMA_DMA_GET_FLAGS DRM_DMA_WAIT
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG_DRMDMA) || defined(DEBUG_COMMANDS) || defined(DEBUG_VERBOSE)
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_GLCMDS() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_VERBOSE
|
||||
#define DEBUG_GLCMDS(s) printf s
|
||||
#else
|
||||
#define DEBUG_GLCMDS(s)
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_DMACMDS() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_DRMDMA
|
||||
#define DEBUG_DMACMDS(s) printf s
|
||||
#else
|
||||
#define DEBUG_DMACMDS(s)
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_WRITE() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_COMMANDS
|
||||
#define DEBUG_WRITE(s) printf s
|
||||
#else
|
||||
#define DEBUG_WRITE(s)
|
||||
#endif
|
||||
|
||||
/* Note: The argument to DEBUG_ERROR() _must_ be enclosed in parenthesis */
|
||||
#ifdef DEBUG_ERRORS
|
||||
#define DEBUG_ERROR(s) printf s
|
||||
#else
|
||||
#define DEBUG_ERROR(s)
|
||||
#endif
|
||||
|
||||
#define WRITEV(buf,val1,val2,val3,val4) \
|
||||
do { \
|
||||
buf++->i = 0x9C008300; \
|
||||
buf++->f = val1; \
|
||||
buf++->f = val2; \
|
||||
buf++->f = val3; \
|
||||
buf++->f = val4; \
|
||||
} while (0)
|
||||
|
||||
#define WRITE(buf,reg,val) \
|
||||
do { \
|
||||
buf++->i = Glint##reg##Tag; \
|
||||
buf++->i = val; \
|
||||
DEBUG_WRITE(("WRITE(buf, %s, 0x%08x);\n", #reg, (int)val)); \
|
||||
} while (0)
|
||||
|
||||
#define WRITEF(buf,reg,val) \
|
||||
do { \
|
||||
buf++->i = Glint##reg##Tag; \
|
||||
buf++->f = val; \
|
||||
DEBUG_WRITE(("WRITEF(buf, %s, %f);\n", #reg, (float)val)); \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_WC_DMA_BUFFER(gcp,n) \
|
||||
do { \
|
||||
(gcp)->WCbufCount += (n<<1); \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_DMA_BUFFER(gcp,n) \
|
||||
do { \
|
||||
if ((gcp)->bufCount+(n<<1) >= (gcp)->bufSize) \
|
||||
PROCESS_DMA_BUFFER(gcp); \
|
||||
(gcp)->bufCount += (n<<1); \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_DMA_BUFFER2(gcp,n) \
|
||||
do { \
|
||||
if ((gcp)->bufCount+n >= (gcp)->bufSize) \
|
||||
PROCESS_DMA_BUFFER(gcp); \
|
||||
(gcp)->bufCount += n; \
|
||||
} while (0)
|
||||
|
||||
#define FLUSH_DMA_BUFFER(gcp) \
|
||||
do { \
|
||||
if (gcp->bufCount) \
|
||||
PROCESS_DMA_BUFFER(gcp); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DONT_SEND_DMA
|
||||
#define GET_DMA(fd, hHWCtx, n, idx, size)
|
||||
#define SEND_DMA(fd, hHWCtx,n, idx, cnt)
|
||||
#else
|
||||
#define GET_DMA(fd, hHWCtx, n, idx, size) \
|
||||
do { \
|
||||
drmDMAReq dma; \
|
||||
int retcode, i; \
|
||||
\
|
||||
dma.context = (hHWCtx); \
|
||||
dma.send_count = 0; \
|
||||
dma.send_list = NULL; \
|
||||
dma.send_sizes = NULL; \
|
||||
dma.flags = GAMMA_DMA_GET_FLAGS; \
|
||||
dma.request_count = (n); \
|
||||
dma.request_size = GAMMA_DMA_BUFFER_SIZE; \
|
||||
dma.request_list = (idx); \
|
||||
dma.request_sizes = (size); \
|
||||
\
|
||||
do { \
|
||||
if ((retcode = drmDMA((fd), &dma))) { \
|
||||
DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \
|
||||
} \
|
||||
} while (!(dma).granted_count); \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(size)[i] >>= 2; /* Convert from bytes to words */ \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \
|
||||
do { \
|
||||
drmDMAReq dma; \
|
||||
int retcode, i; \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(cnt)[i] <<= 2; /* Convert from words to bytes */ \
|
||||
} \
|
||||
\
|
||||
dma.context = (hHWCtx); \
|
||||
dma.send_count = 1; \
|
||||
dma.send_list = (idx); \
|
||||
dma.send_sizes = (cnt); \
|
||||
dma.flags = GAMMA_DMA_SEND_FLAGS; \
|
||||
dma.request_count = 0; \
|
||||
dma.request_size = 0; \
|
||||
dma.request_list = NULL; \
|
||||
dma.request_sizes = NULL; \
|
||||
\
|
||||
if ((retcode = drmDMA((fd), &dma))) { \
|
||||
DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \
|
||||
} \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(cnt)[i] = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, gPriv) \
|
||||
do { \
|
||||
int i; \
|
||||
\
|
||||
GET_DMA(fd, hHWCtx, n, idx, size); \
|
||||
\
|
||||
for (i = 0; i < (n); i++) { \
|
||||
(buf)[i] = (dmaBuf)(gPriv)->bufs->list[(idx)[i]].address; \
|
||||
(cnt)[i] = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PROCESS_DMA_BUFFER_TOP_HALF(gcp) \
|
||||
do { \
|
||||
SEND_DMA((gcp)->driFd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufCount); \
|
||||
} while (0)
|
||||
|
||||
#define PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp) \
|
||||
do { \
|
||||
GET_DMA((gcp)->driFd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufSize); \
|
||||
\
|
||||
(gcp)->buf = \
|
||||
(dmaBuf)(gcp)->gammaScreen->bufs->list[(gcp)->bufIndex].address; \
|
||||
} while (0)
|
||||
|
||||
#define PROCESS_DMA_BUFFER(gcp) \
|
||||
do { \
|
||||
VALIDATE_DRAWABLE_INFO(gcp); \
|
||||
PROCESS_DMA_BUFFER_TOP_HALF(gcp); \
|
||||
PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp); \
|
||||
} while (0)
|
||||
|
||||
#ifdef DO_VALIDATE
|
||||
#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp) \
|
||||
do { \
|
||||
/*__DRIscreenPrivate *psp = gcp->driScreen;*/ \
|
||||
__DRIdrawablePrivate *pdp = gcp->driDrawable; \
|
||||
\
|
||||
if (*(pdp->pStamp) != pdp->lastStamp) { \
|
||||
int old_index = pdp->index; \
|
||||
while (*(pdp->pStamp) != pdp->lastStamp) { \
|
||||
DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
|
||||
} \
|
||||
if (pdp->index != old_index) { \
|
||||
gcp->Window &= ~W_GIDMask; \
|
||||
gcp->Window |= (pdp->index << 5); \
|
||||
CHECK_WC_DMA_BUFFER(gcp, 1); \
|
||||
WRITE(gcp->WCbuf, GLINTWindow, gcp->Window|(gcp->FrameCount<<9));\
|
||||
} \
|
||||
\
|
||||
gammaUpdateViewportOffset( gcp->glCtx); \
|
||||
\
|
||||
if (pdp->numClipRects == 1 && \
|
||||
pdp->pClipRects->x1 == pdp->x && \
|
||||
pdp->pClipRects->x2 == (pdp->x+pdp->w) && \
|
||||
pdp->pClipRects->y1 == pdp->y && \
|
||||
pdp->pClipRects->y2 == (pdp->y+pdp->h)) { \
|
||||
CHECK_WC_DMA_BUFFER(gcp, 1); \
|
||||
WRITE(gcp->WCbuf, Rectangle2DControl, 0); \
|
||||
gcp->NotClipped = GL_TRUE; \
|
||||
} else { \
|
||||
CHECK_WC_DMA_BUFFER(gcp, 1); \
|
||||
WRITE(gcp->WCbuf, Rectangle2DControl, 1); \
|
||||
gcp->NotClipped = GL_FALSE; \
|
||||
} \
|
||||
gcp->WindowChanged = GL_TRUE; \
|
||||
\
|
||||
if (gcp->WCbufCount) { \
|
||||
SEND_DMA((gcp)->gammaScreen->driScreen->fd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
|
||||
&(gcp)->WCbufCount); \
|
||||
(gcp)->WCbufIndex = -1; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp) \
|
||||
do { \
|
||||
if ((gcp)->WCbufIndex < 0) { \
|
||||
GET_DMA((gcp)->gammaScreen->driScreen->fd, \
|
||||
(gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
|
||||
&(gcp)->WCbufSize); \
|
||||
\
|
||||
(gcp)->WCbuf = \
|
||||
(dmaBuf)(gcp)->gammaScreen->bufs-> \
|
||||
list[(gcp)->WCbufIndex].address; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define VALIDATE_DRAWABLE_INFO(gcp) \
|
||||
do { \
|
||||
__DRIscreenPrivate *psp = gcp->driScreen; \
|
||||
if (gcp->driDrawable) { \
|
||||
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp); \
|
||||
DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define VALIDATE_DRAWABLE_INFO(gcp)
|
||||
#endif
|
||||
|
||||
#define CALC_LOG2(l2,s) \
|
||||
do { \
|
||||
int __s = s; \
|
||||
l2 = 0; \
|
||||
while (__s > 1) { ++l2; __s >>= 1; } \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _GAMMA_MACROS_H_ */
|
||||
@@ -0,0 +1,659 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h,v 1.5 2002/02/22 21:33:02 dawes Exp $ */
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
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, sub license, 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 (including the
|
||||
next paragraph) 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 NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Authors:
|
||||
* Kevin E. Martin <kevin@precisioninsight.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_REGS_H_
|
||||
#define _GAMMA_REGS_H_
|
||||
|
||||
#include "gamma_client.h"
|
||||
|
||||
/**************** MX FLAGS ****************/
|
||||
/* FBReadMode */
|
||||
#define FBReadSrcDisable 0x00000000
|
||||
#define FBReadSrcEnable 0x00000200
|
||||
#define FBReadDstDisable 0x00000000
|
||||
#define FBReadDstEnable 0x00000400
|
||||
#define FBDataTypeDefault 0x00000000
|
||||
#define FBDataTypeColor 0x00008000
|
||||
#define FBWindowOriginTop 0x00000000
|
||||
#define FBWindowOriginBot 0x00010000
|
||||
#define FBScanLineInt1 0x00000000
|
||||
#define FBScanLineInt2 0x00800000
|
||||
#define FBScanLineInt4 0x01000000
|
||||
#define FBScanLineInt8 0x01800000
|
||||
#define FBSrcAddrConst 0x00000000
|
||||
#define FBSrcAddrIndex 0x10000000
|
||||
#define FBSrcAddrCoord 0x20000000
|
||||
|
||||
/* LBReadMode */
|
||||
#define LBPartialProdMask 0x000001ff
|
||||
#define LBReadSrcDisable 0x00000000
|
||||
#define LBReadSrcEnable 0x00000200
|
||||
#define LBReadDstDisable 0x00000000
|
||||
#define LBReadDstEnable 0x00000400
|
||||
#define LBDataTypeDefault 0x00000000
|
||||
#define LBDataTypeStencil 0x00010000
|
||||
#define LBDataTypeDepth 0x00020000
|
||||
#define LBWindowOriginTop 0x00000000
|
||||
#define LBWindowOriginBot 0x00040000
|
||||
#define LBScanLineInt1 0x00000000
|
||||
#define LBScanLineInt2 0x00100000
|
||||
#define LBScanLineInt4 0x00200000
|
||||
#define LBScanLineInt8 0x00300000
|
||||
|
||||
/* ColorDDAMode */
|
||||
#define ColorDDADisable 0x00000000
|
||||
#define ColorDDAEnable 0x00000001
|
||||
#define ColorDDAFlat 0x00000000
|
||||
#define ColorDDAGouraud 0x00000002
|
||||
#define ColorDDAShadingMask 0x00000002
|
||||
|
||||
/* AlphaTestMode */
|
||||
#define AlphaTestModeDisable 0x00000000
|
||||
#define AlphaTestModeEnable 0x00000001
|
||||
#define AT_Never 0x00000000
|
||||
#define AT_Less 0x00000002
|
||||
#define AT_Equal 0x00000004
|
||||
#define AT_LessEqual 0x00000006
|
||||
#define AT_Greater 0x00000008
|
||||
#define AT_NotEqual 0x0000000a
|
||||
#define AT_GreaterEqual 0x0000000c
|
||||
#define AT_Always 0x0000000e
|
||||
#define AT_CompareMask 0x0000000e
|
||||
#define AT_RefValueMask 0x00000ff0
|
||||
|
||||
/* AlphaBlendMode */
|
||||
#define AlphaBlendModeDisable 0x00000000
|
||||
#define AlphaBlendModeEnable 0x00000001
|
||||
#define AB_Src_Zero 0x00000000
|
||||
#define AB_Src_One 0x00000002
|
||||
#define AB_Src_DstColor 0x00000004
|
||||
#define AB_Src_OneMinusDstColor 0x00000006
|
||||
#define AB_Src_SrcAlpha 0x00000008
|
||||
#define AB_Src_OneMinusSrcAlpha 0x0000000a
|
||||
#define AB_Src_DstAlpha 0x0000000c
|
||||
#define AB_Src_OneMinusDstAlpha 0x0000000e
|
||||
#define AB_Src_SrcAlphaSaturate 0x00000010
|
||||
#define AB_SrcBlendMask 0x0000001e
|
||||
#define AB_Dst_Zero 0x00000000
|
||||
#define AB_Dst_One 0x00000020
|
||||
#define AB_Dst_SrcColor 0x00000040
|
||||
#define AB_Dst_OneMinusSrcColor 0x00000060
|
||||
#define AB_Dst_SrcAlpha 0x00000080
|
||||
#define AB_Dst_OneMinusSrcAlpha 0x000000a0
|
||||
#define AB_Dst_DstAlpha 0x000000c0
|
||||
#define AB_Dst_OneMinusDstAlpha 0x000000e0
|
||||
#define AB_DstBlendMask 0x000000e0
|
||||
#define AB_ColorFmt_8888 0x00000000
|
||||
#define AB_ColorFmt_5555 0x00000100
|
||||
#define AB_ColorFmt_4444 0x00000200
|
||||
#define AB_ColorFmt_4444Front 0x00000300
|
||||
#define AB_ColorFmt_4444Back 0x00000400
|
||||
#define AB_ColorFmt_332Front 0x00000500
|
||||
#define AB_ColorFmt_332Back 0x00000600
|
||||
#define AB_ColorFmt_121Front 0x00000700
|
||||
#define AB_ColorFmt_121Back 0x00000800
|
||||
#define AB_ColorFmt_555Back 0x00000d00
|
||||
#define AB_ColorFmt_CI8 0x00000e00
|
||||
#define AB_ColorFmt_CI4 0x00000f00
|
||||
#define AB_AlphaBufferPresent 0x00000000
|
||||
#define AB_NoAlphaBufferPresent 0x00001000
|
||||
#define AB_ColorOrder_BGR 0x00000000
|
||||
#define AB_ColorOrder_RGB 0x00002000
|
||||
#define AB_OpenGLType 0x00000000
|
||||
#define AB_QuickDraw3DType 0x00004000
|
||||
#define AB_AlphaDst_FBData 0x00000000
|
||||
#define AB_AlphaDst_FBSourceData 0x00008000
|
||||
#define AB_ColorConversionScale 0x00000000
|
||||
#define AB_ColorConversionShift 0x00010000
|
||||
#define AB_AlphaConversionScale 0x00000000
|
||||
#define AB_AlphaConversionShift 0x00020000
|
||||
|
||||
/* AntialiasMode */
|
||||
#define AntialiasModeDisable 0x00000000
|
||||
#define AntialiasModeEnable 0x00000001
|
||||
|
||||
/* AreaStippleMode */
|
||||
#define AreaStippleModeDisable 0x00000000
|
||||
#define AreaStippleModeEnable 0x00000001
|
||||
#define ASM_X32 0x00000008
|
||||
#define ASM_Y32 0x00000040
|
||||
|
||||
/* DepthMode */
|
||||
#define DepthModeDisable 0x00000000
|
||||
#define DepthModeEnable 0x00000001
|
||||
#define DM_WriteMask 0x00000002
|
||||
#define DM_SourceFragment 0x00000000
|
||||
#define DM_SourceLBData 0x00000004
|
||||
#define DM_SourceDepthRegister 0x00000008
|
||||
#define DM_SourceLBSourceData 0x0000000c
|
||||
#define DM_SourceMask 0x0000000c
|
||||
#define DM_Never 0x00000000
|
||||
#define DM_Less 0x00000010
|
||||
#define DM_Equal 0x00000020
|
||||
#define DM_LessEqual 0x00000030
|
||||
#define DM_Greater 0x00000040
|
||||
#define DM_NotEqual 0x00000050
|
||||
#define DM_GreaterEqual 0x00000060
|
||||
#define DM_Always 0x00000070
|
||||
#define DM_CompareMask 0x00000070
|
||||
|
||||
/* FBWriteMode */
|
||||
#define FBWriteModeDisable 0x00000000
|
||||
#define FBWriteModeEnable 0x00000001
|
||||
#define FBW_UploadColorData 0x00000008
|
||||
|
||||
/* FogMode */
|
||||
#define FogModeDisable 0x00000000
|
||||
#define FogModeEnable 0x00000001
|
||||
|
||||
/* LBWriteMode */
|
||||
#define LBWriteModeDisable 0x00000000
|
||||
#define LBWriteModeEnable 0x00000001
|
||||
#define LBW_UploadNone 0x00000000
|
||||
#define LBW_UploadDepth 0x00000002
|
||||
#define LBW_UploadStencil 0x00000004
|
||||
|
||||
/* LBRead/Write Format */
|
||||
#define LBRF_DepthWidth15 0x03 /* only permedia */
|
||||
#define LBRF_DepthWidth16 0x00
|
||||
#define LBRF_DepthWidth24 0x01
|
||||
#define LBRF_DepthWidth32 0x02
|
||||
#define LBRF_StencilWidth0 (0 << 2)
|
||||
#define LBRF_StencilWidth4 (1 << 2)
|
||||
#define LBRF_StencilWidth8 (2 << 2)
|
||||
#define LBRF_StencilPos16 (0 << 4)
|
||||
#define LBRF_StencilPos20 (1 << 4)
|
||||
#define LBRF_StencilPos24 (2 << 4)
|
||||
#define LBRF_StencilPos28 (3 << 4)
|
||||
#define LBRF_StencilPos32 (4 << 4)
|
||||
#define LBRF_FrameCount0 (0 << 7)
|
||||
#define LBRF_FrameCount4 (1 << 7)
|
||||
#define LBRF_FrameCount8 (2 << 7)
|
||||
#define LBRF_FrameCountPos16 (0 << 9)
|
||||
#define LBRF_FrameCountPos20 (1 << 9)
|
||||
#define LBRF_FrameCountPos24 (2 << 9)
|
||||
#define LBRF_FrameCountPos28 (3 << 9)
|
||||
#define LBRF_FrameCountPos32 (4 << 9)
|
||||
#define LBRF_FrameCountPos36 (5 << 9)
|
||||
#define LBRF_FrameCountPos40 (6 << 9)
|
||||
#define LBRF_GIDWidth0 (0 << 12)
|
||||
#define LBRF_GIDWidth4 (1 << 12)
|
||||
#define LBRF_GIDPos16 (0 << 13)
|
||||
#define LBRF_GIDPos20 (1 << 13)
|
||||
#define LBRF_GIDPos24 (2 << 13)
|
||||
#define LBRF_GIDPos28 (3 << 13)
|
||||
#define LBRF_GIDPos32 (4 << 13)
|
||||
#define LBRF_GIDPos36 (5 << 13)
|
||||
#define LBRF_GIDPos40 (6 << 13)
|
||||
#define LBRF_GIDPos44 (7 << 13)
|
||||
#define LBRF_GIDPos48 (8 << 13)
|
||||
#define LBRF_Compact32 (1 << 17)
|
||||
|
||||
/* StencilMode */
|
||||
#define StencilDisable 0x00000000
|
||||
#define StencilEnable 0x00000001
|
||||
|
||||
/* RouterMode */
|
||||
#define R_Order_TextureDepth 0x00000000
|
||||
#define R_Order_DepthTexture 0x00000001
|
||||
|
||||
/* ScissorMode */
|
||||
#define UserScissorDisable 0x00000000
|
||||
#define UserScissorEnable 0x00000001
|
||||
#define ScreenScissorDisable 0x00000000
|
||||
#define ScreenScissorEnable 0x00000002
|
||||
|
||||
/* DitherMode */
|
||||
#define DitherModeDisable 0x00000000
|
||||
#define DitherModeEnable 0x00000001
|
||||
#define DM_DitherDisable 0x00000000
|
||||
#define DM_DitherEnable 0x00000002
|
||||
#define DM_ColorFmt_8888 0x00000000
|
||||
#define DM_ColorFmt_5555 0x00000004
|
||||
#define DM_ColorFmt_4444 0x00000008
|
||||
#define DM_ColorFmt_4444Front 0x0000000c
|
||||
#define DM_ColorFmt_4444Back 0x00000010
|
||||
#define DM_ColorFmt_332Front 0x00000014
|
||||
#define DM_ColorFmt_332Back 0x00000018
|
||||
#define DM_ColorFmt_121Front 0x0000001c
|
||||
#define DM_ColorFmt_121Back 0x00000020
|
||||
#define DM_ColorFmt_555Back 0x00000024
|
||||
#define DM_ColorFmt_CI8 0x00000028
|
||||
#define DM_ColorFmt_CI4 0x0000002c
|
||||
#define DM_XOffsetMask 0x000000c0
|
||||
#define DM_YOffsetMask 0x00000300
|
||||
#define DM_ColorOrder_BGR 0x00000000
|
||||
#define DM_ColorOrder_RGB 0x00000400
|
||||
#define DM_AlphaDitherDefault 0x00000000
|
||||
#define DM_AlphaDitherNone 0x00004000
|
||||
#define DM_Truncate 0x00000000
|
||||
#define DM_Round 0x00008000
|
||||
|
||||
/* RasterizerMode */
|
||||
#define RM_MirrorBitMask 0x00000001
|
||||
#define RM_InvertBitMask 0x00000002
|
||||
#define RM_FractionAdjNo 0x00000000
|
||||
#define RM_FractionAdjZero 0x00000004
|
||||
#define RM_FractionAdjHalf 0x00000008
|
||||
#define RM_FractionAdjNearHalf 0x0000000c
|
||||
#define RM_BiasCoordZero 0x00000000
|
||||
#define RM_BiasCoordHalf 0x00000010
|
||||
#define RM_BiasCoordNearHalf 0x00000020
|
||||
#define RM_BitMaskByteSwap_ABCD 0x00000000
|
||||
#define RM_BitMaskByteSwap_BADC 0x00000080
|
||||
#define RM_BitMaskByteSwap_CDAB 0x00000100
|
||||
#define RM_BitMaskByteSwap_DCBA 0x00000180
|
||||
#define RM_BitMaskPacked 0x00000000
|
||||
#define RM_BitMaskEveryScanline 0x00000200
|
||||
#define RM_BitMaskOffsetMask 0x00007c00
|
||||
#define RM_HostDataByteSwap_ABCD 0x00000000
|
||||
#define RM_HostDataByteSwap_BADC 0x00008000
|
||||
#define RM_HostDataByteSwap_CDAB 0x00010000
|
||||
#define RM_HostDataByteSwap_DCBA 0x00018000
|
||||
#define RM_SingleGLINT 0x00000000
|
||||
#define RM_MultiGLINT 0x00020000
|
||||
#define RM_YLimitsEnable 0x00040000
|
||||
|
||||
/* Window */
|
||||
#define WindowDisable 0x00000000
|
||||
#define WindowEnable 0x00000001
|
||||
#define W_AlwaysPass 0x00000000
|
||||
#define W_NeverPass 0x00000002
|
||||
#define W_PassIfEqual 0x00000004
|
||||
#define W_PassIfNotEqual 0x00000006
|
||||
#define W_CompareMask 0x00000006
|
||||
#define W_ForceLBUpdate 0x00000008
|
||||
#define W_LBUpdateFromSource 0x00000000
|
||||
#define W_LBUpdateFromRegisters 0x00000010
|
||||
#define W_GIDMask 0x000001e0
|
||||
#define W_FrameCountMask 0x0001fe00
|
||||
#define W_StencilFCP 0x00020000
|
||||
#define W_DepthFCP 0x00040000
|
||||
#define W_OverrideWriteFiltering 0x00080000
|
||||
|
||||
/* TextureAddressMode */
|
||||
#define TextureAddressModeDisable 0x00000000
|
||||
#define TextureAddressModeEnable 0x00000001
|
||||
#define TAM_SWrap_Clamp 0x00000000
|
||||
#define TAM_SWrap_Repeat 0x00000002
|
||||
#define TAM_SWrap_Mirror 0x00000004
|
||||
#define TAM_SWrap_Mask 0x00000006
|
||||
#define TAM_TWrap_Clamp 0x00000000
|
||||
#define TAM_TWrap_Repeat 0x00000008
|
||||
#define TAM_TWrap_Mirror 0x00000010
|
||||
#define TAM_TWrap_Mask 0x00000018
|
||||
#define TAM_Operation_2D 0x00000000
|
||||
#define TAM_Operation_3D 0x00000020
|
||||
#define TAM_InhibitDDAInit 0x00000040
|
||||
#define TAM_LODDisable 0x00000000
|
||||
#define TAM_LODEnable 0x00000080
|
||||
#define TAM_DY_Disable 0x00000000
|
||||
#define TAM_DY_Enable 0x00000100
|
||||
#define TAM_WidthMask 0x00001e00
|
||||
#define TAM_HeightMask 0x0001e000
|
||||
#define TAM_TexMapType_1D 0x00000000
|
||||
#define TAM_TexMapType_2D 0x00020000
|
||||
#define TAM_TexMapType_Mask 0x00020000
|
||||
|
||||
/* TextureReadMode */
|
||||
#define TextureReadModeDisable 0x00000000
|
||||
#define TextureReadModeEnable 0x00000001
|
||||
#define TRM_WidthMask 0x0000001e
|
||||
#define TRM_HeightMask 0x000001e0
|
||||
#define TRM_Depth1 0x00000000
|
||||
#define TRM_Depth2 0x00000200
|
||||
#define TRM_Depth4 0x00000400
|
||||
#define TRM_Depth8 0x00000600
|
||||
#define TRM_Depth16 0x00000800
|
||||
#define TRM_Depth32 0x00000a00
|
||||
#define TRM_DepthMask 0x00000e00
|
||||
#define TRM_Border 0x00001000
|
||||
#define TRM_Patch 0x00002000
|
||||
#define TRM_Mag_Nearest 0x00000000
|
||||
#define TRM_Mag_Linear 0x00004000
|
||||
#define TRM_Mag_Mask 0x00004000
|
||||
#define TRM_Min_Nearest 0x00000000
|
||||
#define TRM_Min_Linear 0x00008000
|
||||
#define TRM_Min_NearestMMNearest 0x00010000
|
||||
#define TRM_Min_NearestMMLinear 0x00018000
|
||||
#define TRM_Min_LinearMMNearest 0x00020000
|
||||
#define TRM_Min_LinearMMLinear 0x00028000
|
||||
#define TRM_Min_Mask 0x00038000
|
||||
#define TRM_UWrap_Clamp 0x00000000
|
||||
#define TRM_UWrap_Repeat 0x00040000
|
||||
#define TRM_UWrap_Mirror 0x00080000
|
||||
#define TRM_UWrap_Mask 0x000c0000
|
||||
#define TRM_VWrap_Clamp 0x00000000
|
||||
#define TRM_VWrap_Repeat 0x00100000
|
||||
#define TRM_VWrap_Mirror 0x00200000
|
||||
#define TRM_VWrap_Mask 0x00300000
|
||||
#define TRM_TexMapType_1D 0x00000000
|
||||
#define TRM_TexMapType_2D 0x00400000
|
||||
#define TRM_TexMapType_Mask 0x00400000
|
||||
#define TRM_MipMapDisable 0x00000000
|
||||
#define TRM_MipMapEnable 0x00800000
|
||||
#define TRM_PrimaryCacheDisable 0x00000000
|
||||
#define TRM_PrimaryCacheEnable 0x01000000
|
||||
#define TRM_FBSourceAddr_None 0x00000000
|
||||
#define TRM_FBSourceAddr_Index 0x02000000
|
||||
#define TRM_FBSourceAddr_Coord 0x04000000
|
||||
#define TRM_BorderClamp 0x08000000
|
||||
|
||||
/* TextureColorMode */
|
||||
#define TextureColorModeDisable 0x00000000
|
||||
#define TextureColorModeEnable 0x00000001
|
||||
#define TCM_Modulate 0x00000000
|
||||
#define TCM_Decal 0x00000002
|
||||
#define TCM_Blend 0x00000004
|
||||
#define TCM_Replace 0x00000006
|
||||
#define TCM_ApplicationMask 0x0000000e
|
||||
#define TCM_OpenGLType 0x00000000
|
||||
#define TCM_QuickDraw3DType 0x00000010
|
||||
#define TCM_KdDDA_Disable 0x00000000
|
||||
#define TCM_KdDDA_Enable 0x00000020
|
||||
#define TCM_KsDDA_Disable 0x00000000
|
||||
#define TCM_KsDDA_Enable 0x00000040
|
||||
#define TCM_BaseFormat_Alpha 0x00000000
|
||||
#define TCM_BaseFormat_Lum 0x00000080
|
||||
#define TCM_BaseFormat_LumAlpha 0x00000100
|
||||
#define TCM_BaseFormat_Intensity 0x00000180
|
||||
#define TCM_BaseFormat_RGB 0x00000200
|
||||
#define TCM_BaseFormat_RGBA 0x00000280
|
||||
#define TCM_BaseFormatMask 0x00000380
|
||||
#define TCM_LoadMode_None 0x00000000
|
||||
#define TCM_LoadMode_Ks 0x00000400
|
||||
#define TCM_LoadMode_Kd 0x00000800
|
||||
|
||||
/* TextureCacheControl */
|
||||
#define TCC_Invalidate 0x00000001
|
||||
#define TCC_Disable 0x00000000
|
||||
#define TCC_Enable 0x00000002
|
||||
|
||||
/* TextureFilterMode */
|
||||
#define TextureFilterModeDisable 0x00000000
|
||||
#define TextureFilterModeEnable 0x00000001
|
||||
#define TFM_AlphaMapEnable 0x00000002
|
||||
#define TFM_AlphaMapSense 0x00000004
|
||||
|
||||
/* TextureFormat */
|
||||
#define TF_LittleEndian 0x00000000
|
||||
#define TF_BigEndian 0x00000001
|
||||
#define TF_16Bit_565 0x00000000
|
||||
#define TF_16Bit_555 0x00000002
|
||||
#define TF_ColorOrder_BGR 0x00000000
|
||||
#define TF_ColorOrder_RGB 0x00000004
|
||||
#define TF_Compnents_1 0x00000000
|
||||
#define TF_Compnents_2 0x00000008
|
||||
#define TF_Compnents_3 0x00000010
|
||||
#define TF_Compnents_4 0x00000018
|
||||
#define TF_CompnentsMask 0x00000018
|
||||
#define TF_OutputFmt_Texel 0x00000000
|
||||
#define TF_OutputFmt_Color 0x00000020
|
||||
#define TF_OutputFmt_BitMask 0x00000040
|
||||
#define TF_OutputFmtMask 0x00000060
|
||||
#define TF_MirrorEnable 0x00000080
|
||||
#define TF_InvertEnable 0x00000100
|
||||
#define TF_ByteSwapEnable 0x00000200
|
||||
#define TF_LUTOffsetMask 0x0003fc00
|
||||
#define TF_OneCompFmt_Lum 0x00000000
|
||||
#define TF_OneCompFmt_Alpha 0x00040000
|
||||
#define TF_OneCompFmt_Intensity 0x00080000
|
||||
#define TF_OneCompFmt_Mask 0x000c0000
|
||||
/**************** MX FLAGS ****************/
|
||||
|
||||
/************** GAMMA FLAGS ***************/
|
||||
/* GeometryMode */
|
||||
#define GM_TextureDisable 0x00000000
|
||||
#define GM_TextureEnable 0x00000001
|
||||
#define GM_FogDisable 0x00000000
|
||||
#define GM_FogEnable 0x00000002
|
||||
#define GM_FogLinear 0x00000000
|
||||
#define GM_FogExp 0x00000004
|
||||
#define GM_FogExpSquared 0x00000008
|
||||
#define GM_FogMask 0x0000000C
|
||||
#define GM_FrontPolyPoint 0x00000000
|
||||
#define GM_FrontPolyLine 0x00000010
|
||||
#define GM_FrontPolyFill 0x00000020
|
||||
#define GM_BackPolyPoint 0x00000000
|
||||
#define GM_BackPolyLine 0x00000040
|
||||
#define GM_BackPolyFill 0x00000080
|
||||
#define GM_FB_PolyMask 0x000000F0
|
||||
#define GM_FrontFaceCW 0x00000000
|
||||
#define GM_FrontFaceCCW 0x00000100
|
||||
#define GM_FFMask 0x00000100
|
||||
#define GM_PolyCullDisable 0x00000000
|
||||
#define GM_PolyCullEnable 0x00000200
|
||||
#define GM_PolyCullFront 0x00000000
|
||||
#define GM_PolyCullBack 0x00000400
|
||||
#define GM_PolyCullBoth 0x00000800
|
||||
#define GM_PolyCullMask 0x00000c00
|
||||
#define GM_ClipShortLinesDisable 0x00000000
|
||||
#define GM_ClipShortLinesEnable 0x00001000
|
||||
#define GM_ClipSmallTrisDisable 0x00000000
|
||||
#define GM_ClipSmallTrisEnable 0x00002000
|
||||
#define GM_RenderMode 0x00000000
|
||||
#define GM_SelectMode 0x00004000
|
||||
#define GM_FeedbackMode 0x00008000
|
||||
#define GM_Feedback2D 0x00000000
|
||||
#define GM_Feedback3D 0x00010000
|
||||
#define GM_Feedback3DColor 0x00020000
|
||||
#define GM_Feedback3DColorTexture 0x00030000
|
||||
#define GM_Feedback4DColorTexture 0x00040000
|
||||
#define GM_CullFaceNormDisable 0x00000000
|
||||
#define GM_CullFaceNormEnable 0x00080000
|
||||
#define GM_AutoFaceNormDisable 0x00000000
|
||||
#define GM_AutoFaceNormEnable 0x00100000
|
||||
#define GM_GouraudShading 0x00000000
|
||||
#define GM_FlatShading 0x00200000
|
||||
#define GM_ShadingMask 0x00200000
|
||||
#define GM_UserClipNone 0x00000000
|
||||
#define GM_UserClip0 0x00400000
|
||||
#define GM_UserClip1 0x00800000
|
||||
#define GM_UserClip2 0x01000000
|
||||
#define GM_UserClip3 0x02000000
|
||||
#define GM_UserClip4 0x04000000
|
||||
#define GM_UserClip5 0x08000000
|
||||
#define GM_PolyOffsetPointDisable 0x00000000
|
||||
#define GM_PolyOffsetPointEnable 0x10000000
|
||||
#define GM_PolyOffsetLineDisable 0x00000000
|
||||
#define GM_PolyOffsetLineEnable 0x20000000
|
||||
#define GM_PolyOffsetFillDisable 0x00000000
|
||||
#define GM_PolyOffsetFillEnable 0x40000000
|
||||
#define GM_InvertFaceNormCullDisable 0x00000000
|
||||
#define GM_InvertFaceNormCullEnable 0x80000000
|
||||
|
||||
/* Begin */
|
||||
#define B_AreaStippleDisable 0x00000000
|
||||
#define B_AreaStippleEnable 0x00000001
|
||||
#define B_LineStippleDisable 0x00000000
|
||||
#define B_LineStippleEnable 0x00000002
|
||||
#define B_AntiAliasDisable 0x00000000
|
||||
#define B_AntiAliasEnable 0x00000100
|
||||
#define B_TextureDisable 0x00000000
|
||||
#define B_TextureEnable 0x00002000
|
||||
#define B_FogDisable 0x00000000
|
||||
#define B_FogEnable 0x00004000
|
||||
#define B_SubPixelCorrectDisable 0x00000000
|
||||
#define B_SubPixelCorrectEnable 0x00010000
|
||||
#define B_PrimType_Null 0x00000000
|
||||
#define B_PrimType_Points 0x10000000
|
||||
#define B_PrimType_Lines 0x20000000
|
||||
#define B_PrimType_LineLoop 0x30000000
|
||||
#define B_PrimType_LineStrip 0x40000000
|
||||
#define B_PrimType_Triangles 0x50000000
|
||||
#define B_PrimType_TriangleStrip 0x60000000
|
||||
#define B_PrimType_TriangleFan 0x70000000
|
||||
#define B_PrimType_Quads 0x80000000
|
||||
#define B_PrimType_QuadStrip 0x90000000
|
||||
#define B_PrimType_Polygon 0xa0000000
|
||||
#define B_PrimType_Mask 0xf0000000
|
||||
|
||||
/* EdgeFlag */
|
||||
#define EdgeFlagDisable 0x00000000
|
||||
#define EdgeFlagEnable 0x00000001
|
||||
|
||||
/* NormalizeMode */
|
||||
#define NormalizeModeDisable 0x00000000
|
||||
#define NormalizeModeEnable 0x00000001
|
||||
#define FaceNormalDisable 0x00000000
|
||||
#define FaceNormalEnable 0x00000002
|
||||
#define InvertAutoFaceNormal 0x00000004
|
||||
|
||||
/* LightingMode */
|
||||
#define LightingModeDisable 0x00000000
|
||||
#define LightingModeEnable 0x00000001
|
||||
#define LightingModeTwoSides 0x00000004
|
||||
#define LightingModeLocalViewer 0x00000008
|
||||
#define LightingModeSpecularEnable 0x00008000
|
||||
|
||||
/* Light0Mode */
|
||||
#define Light0ModeDisable 0x00000000
|
||||
#define Light0ModeEnable 0x00000001
|
||||
#define Light0ModeSpotLight 0x00000002
|
||||
#define Light0ModeAttenuation 0x00000004
|
||||
#define Light0ModeLocal 0x00000008
|
||||
|
||||
/* Light0Mode */
|
||||
#define Light1ModeDisable 0x00000000
|
||||
#define Light1ModeEnable 0x00000001
|
||||
#define Light1ModeSpotLight 0x00000002
|
||||
#define Light1ModeAttenuation 0x00000004
|
||||
#define Light1ModeLocal 0x00000008
|
||||
|
||||
/* ColorMaterialMode */
|
||||
#define ColorMaterialModeDisable 0x00000000
|
||||
#define ColorMaterialModeEnable 0x00000001
|
||||
#define ColorMaterialModeFront 0x00000000
|
||||
#define ColorMaterialModeBack 0x00000002
|
||||
#define ColorMaterialModeFrontAndBack 0x00000004
|
||||
#define ColorMaterialModeEmission 0x00000000
|
||||
#define ColorMaterialModeAmbient 0x00000008
|
||||
#define ColorMaterialModeDiffuse 0x00000010
|
||||
#define ColorMaterialModeSpecular 0x00000018
|
||||
#define ColorMaterialModeAmbAndDiff 0x00000020
|
||||
#define ColorMaterialModeMask 0x0000003e
|
||||
|
||||
/* MaterialMode */
|
||||
#define MaterialModeDisable 0x00000000
|
||||
#define MaterialModeEnable 0x00000001
|
||||
#define MaterialModeTwoSides 0x00000080
|
||||
|
||||
/* DeltaMode */
|
||||
#define DM_Target300SX 0x00000000
|
||||
#define DM_Target500TXMX 0x00000001
|
||||
#define DM_Depth16 0x00000004
|
||||
#define DM_Depth24 0x00000008
|
||||
#define DM_Depth32 0x0000000c
|
||||
#define DM_FogEnable 0x00000010
|
||||
#define DM_TextureEnable 0x00000020
|
||||
#define DM_SmoothShadingEnable 0x00000040
|
||||
#define DM_DepthEnable 0x00000080
|
||||
#define DM_SpecularEnable 0x00000100
|
||||
#define DM_DiffuseEnable 0x00000200
|
||||
#define DM_SubPixlCorrectionEnable 0x00000400
|
||||
#define DM_DiamondExit 0x00000800
|
||||
#define DM_NoDraw 0x00001000
|
||||
#define DM_ClampEnable 0x00002000
|
||||
#define DM_TextureParameterAsGiven 0x00000000
|
||||
#define DM_TextureParameterClamped 0x00004000
|
||||
#define DM_TextureParameterNormalized 0x00008000
|
||||
#define DM_BiasCoords 0x00080000
|
||||
#define DM_ColorDiffuse 0x00100000
|
||||
#define DM_ColorSpecular 0x00200000
|
||||
#define DM_FlatShadingMethod 0x00400000
|
||||
|
||||
/* PointMode */
|
||||
#define PM_AntialiasDisable 0x00000000
|
||||
#define PM_AntialiasEnable 0x00000001
|
||||
#define PM_AntialiasQuality_4x4 0x00000000
|
||||
#define PM_AntialiasQuality_8x8 0x00000002
|
||||
|
||||
/* LogicalOpMode */
|
||||
#define LogicalOpModeDisable 0x00000000
|
||||
#define LogicalOpModeEnable 0x00000001
|
||||
#define LogicalOpModeMask 0x0000001e
|
||||
|
||||
/* LineMode */
|
||||
#define LM_StippleDisable 0x00000000
|
||||
#define LM_StippleEnable 0x00000001
|
||||
#define LM_RepeatFactorMask 0x000003fe
|
||||
#define LM_StippleMask 0x03fffc00
|
||||
#define LM_MirrorDisable 0x00000000
|
||||
#define LM_MirrorEnable 0x04000000
|
||||
#define LM_AntialiasDisable 0x00000000
|
||||
#define LM_AntialiasEnable 0x08000000
|
||||
#define LM_AntialiasQuality_4x4 0x00000000
|
||||
#define LM_AntialiasQuality_8x8 0x10000000
|
||||
|
||||
/* TriangleMode */
|
||||
#define TM_AntialiasDisable 0x00000000
|
||||
#define TM_AntialiasEnable 0x00000001
|
||||
#define TM_AntialiasQuality_4x4 0x00000000
|
||||
#define TM_AntialiasQuality_8x8 0x00000002
|
||||
#define TM_UseTriPacketInterface 0x00000004
|
||||
|
||||
/* TransformMode */
|
||||
#define XM_UseModelViewMatrix 0x00000001
|
||||
#define XM_UseModelViewProjMatrix 0x00000002
|
||||
#define XM_XformNormals 0x00000004
|
||||
#define XM_XformFaceNormals 0x00000008
|
||||
#define XM_XformTexture 0x00000010
|
||||
#define XM_XMask 0x00000013
|
||||
#define XM_TexGenModeS_None 0x00000000
|
||||
#define XM_TexGenModeS_ObjLinear 0x00000020
|
||||
#define XM_TexGenModeS_EyeLinear 0x00000040
|
||||
#define XM_TexGenModeS_SphereMap 0x00000060
|
||||
#define XM_TexGenModeT_None 0x00000000
|
||||
#define XM_TexGenModeT_ObjLinear 0x00000080
|
||||
#define XM_TexGenModeT_EyeLinear 0x00000100
|
||||
#define XM_TexGenModeT_SphereMap 0x00000180
|
||||
#define XM_TexGenModeR_None 0x00000000
|
||||
#define XM_TexGenModeR_ObjLinear 0x00000200
|
||||
#define XM_TexGenModeR_EyeLinear 0x00000400
|
||||
#define XM_TexGenModeR_SphereMap 0x00000600
|
||||
#define XM_TexGenModeQ_None 0x00000000
|
||||
#define XM_TexGenModeQ_ObjLinear 0x00000800
|
||||
#define XM_TexGenModeQ_EyeLinear 0x00001000
|
||||
#define XM_TexGenModeQQSphereMap 0x00001800
|
||||
#define XM_TexGenS 0x00002000
|
||||
#define XM_TexGenT 0x00004000
|
||||
#define XM_TexGenR 0x00008000
|
||||
#define XM_TexGenQ 0x00010000
|
||||
|
||||
/* LightNMode */
|
||||
#define LNM_Off 0x00000000
|
||||
#define LNM_On 0x00000001
|
||||
/************** GAMMA FLAGS ***************/
|
||||
|
||||
#endif /* _GAMMA_REGS_H_ */
|
||||
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "macros.h"
|
||||
#include "imports.h"
|
||||
#include "mtypes.h"
|
||||
|
||||
#include "tnl/t_context.h"
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_tris.h"
|
||||
#include "gamma_vb.h"
|
||||
|
||||
|
||||
/* !! Should template this eventually !! */
|
||||
|
||||
static void gamma_emit( GLcontext *ctx, GLuint start, GLuint end)
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLfloat (*coord)[4];
|
||||
GLuint coord_stride;
|
||||
GLubyte (*col)[4];
|
||||
GLuint col_stride;
|
||||
int i;
|
||||
GLuint tc0_stride = 0;
|
||||
GLfloat (*tc0)[4] = 0;
|
||||
GLuint tc0_size = 0;
|
||||
|
||||
if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
|
||||
gamma_import_float_colors( ctx );
|
||||
|
||||
col = VB->ColorPtr[0]->Ptr;
|
||||
col_stride = VB->ColorPtr[0]->StrideB;
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
tc0_stride = VB->TexCoordPtr[0]->stride;
|
||||
tc0 = VB->TexCoordPtr[0]->data;
|
||||
tc0_size = VB->TexCoordPtr[0]->size;
|
||||
coord = VB->ClipPtr->data;
|
||||
coord_stride = VB->ClipPtr->stride;
|
||||
} else {
|
||||
coord = VB->NdcPtr->data;
|
||||
coord_stride = VB->NdcPtr->stride;
|
||||
}
|
||||
|
||||
if (VB->importable_data) {
|
||||
if (start) {
|
||||
coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
|
||||
STRIDE_4UB(col, start * col_stride);
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled)
|
||||
tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
|
||||
}
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 4) {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 9);
|
||||
WRITEF(gmesa->buf, Tq4, tc0[0][3]);
|
||||
WRITEF(gmesa->buf, Tr4, tc0[0][2]);
|
||||
WRITEF(gmesa->buf, Tt4, tc0[0][0]);
|
||||
WRITEF(gmesa->buf, Ts4, tc0[0][1]);
|
||||
WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[0]);
|
||||
WRITEF(gmesa->buf, Vw, coord[0][3]);
|
||||
WRITEF(gmesa->buf, Vz, coord[0][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[0][1]);
|
||||
WRITEF(gmesa->buf, Vx4, coord[0][0]);
|
||||
STRIDE_4UB(col, col_stride);
|
||||
tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
|
||||
coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
|
||||
}
|
||||
} else if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 2) {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 7);
|
||||
WRITEF(gmesa->buf, Tt2, tc0[0][0]);
|
||||
WRITEF(gmesa->buf, Ts2, tc0[0][1]);
|
||||
WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[0]);
|
||||
WRITEF(gmesa->buf, Vw, coord[0][3]);
|
||||
WRITEF(gmesa->buf, Vz, coord[0][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[0][1]);
|
||||
WRITEF(gmesa->buf, Vx4, coord[0][0]);
|
||||
STRIDE_4UB(col, col_stride);
|
||||
tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
|
||||
coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
|
||||
}
|
||||
} else {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[0]);
|
||||
WRITEF(gmesa->buf, Vz, coord[0][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[0][1]);
|
||||
WRITEF(gmesa->buf, Vx3, coord[0][0]);
|
||||
STRIDE_4UB(col, col_stride);
|
||||
coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 4) {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 9);
|
||||
WRITEF(gmesa->buf, Tq4, tc0[i][3]);
|
||||
WRITEF(gmesa->buf, Tr4, tc0[i][2]);
|
||||
WRITEF(gmesa->buf, Tt4, tc0[i][0]);
|
||||
WRITEF(gmesa->buf, Ts4, tc0[i][1]);
|
||||
WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[i]);
|
||||
WRITEF(gmesa->buf, Vw, coord[i][3]);
|
||||
WRITEF(gmesa->buf, Vz, coord[i][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[i][1]);
|
||||
WRITEF(gmesa->buf, Vx4, coord[i][0]);
|
||||
}
|
||||
} else if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 2) {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 7);
|
||||
WRITEF(gmesa->buf, Tt2, tc0[i][0]);
|
||||
WRITEF(gmesa->buf, Ts2, tc0[i][1]);
|
||||
WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[i]);
|
||||
WRITEF(gmesa->buf, Vw, coord[i][3]);
|
||||
WRITEF(gmesa->buf, Vz, coord[i][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[i][1]);
|
||||
WRITEF(gmesa->buf, Vx4, coord[i][0]);
|
||||
}
|
||||
} else {
|
||||
for (i=start; i < end; i++) {
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[i]);
|
||||
WRITEF(gmesa->buf, Vz, coord[i][2]);
|
||||
WRITEF(gmesa->buf, Vy, coord[i][1]);
|
||||
WRITEF(gmesa->buf, Vx3, coord[i][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define HAVE_POINTS 1
|
||||
#define HAVE_LINES 1
|
||||
#define HAVE_LINE_STRIPS 1
|
||||
#define HAVE_TRIANGLES 1
|
||||
#define HAVE_TRI_STRIPS 1
|
||||
#define HAVE_TRI_STRIP_1 0
|
||||
#define HAVE_TRI_FANS 1
|
||||
#define HAVE_QUADS 1
|
||||
#define HAVE_QUAD_STRIPS 1
|
||||
#define HAVE_POLYGONS 1
|
||||
|
||||
#define HAVE_ELTS 0
|
||||
|
||||
static void VERT_FALLBACK( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint flags )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
|
||||
tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
|
||||
tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start, count, flags );
|
||||
GAMMA_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_CLIP;
|
||||
}
|
||||
|
||||
static const GLuint hw_prim[GL_POLYGON+1] = {
|
||||
B_PrimType_Points,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_LineLoop,
|
||||
B_PrimType_LineStrip,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_TriangleStrip,
|
||||
B_PrimType_TriangleFan,
|
||||
B_PrimType_Quads,
|
||||
B_PrimType_QuadStrip,
|
||||
B_PrimType_Polygon
|
||||
};
|
||||
|
||||
static __inline void gammaStartPrimitive( gammaContextPtr gmesa, GLenum prim )
|
||||
{
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, gmesa->Begin | hw_prim[prim]);
|
||||
}
|
||||
|
||||
static __inline void gammaEndPrimitive( gammaContextPtr gmesa )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
|
||||
if ( ctx->Line.SmoothFlag ||
|
||||
ctx->Polygon.SmoothFlag ||
|
||||
ctx->Point.SmoothFlag ) {
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
}
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
#define LOCAL_VARS gammaContextPtr gmesa = GAMMA_CONTEXT(ctx)
|
||||
#define INIT( prim ) gammaStartPrimitive( gmesa, prim )
|
||||
#define FINISH gammaEndPrimitive( gmesa )
|
||||
#define NEW_PRIMITIVE() /* GAMMA_STATECHANGE( gmesa, 0 ) */
|
||||
#define NEW_BUFFER() /* GAMMA_FIREVERTICES( gmesa ) */
|
||||
#define GET_CURRENT_VB_MAX_VERTS() \
|
||||
(gmesa->bufSize - gmesa->bufCount) / 2
|
||||
#define GET_SUBSEQUENT_VB_MAX_VERTS() \
|
||||
GAMMA_DMA_BUFFER_SIZE / 2
|
||||
#define EMIT_VERTS( ctx, j, nr ) gamma_emit(ctx, j, (j)+(nr))
|
||||
|
||||
#define TAG(x) gamma_##x
|
||||
#include "tnl_dd/t_dd_dmatmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render pipeline stage */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
static GLboolean gamma_run_render( GLcontext *ctx,
|
||||
struct gl_pipeline_stage *stage )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i, length, flags = 0;
|
||||
render_func *tab;
|
||||
|
||||
/* GH: THIS IS A HACK!!! */
|
||||
if (VB->ClipOrMask || gmesa->RenderIndex != 0)
|
||||
return GL_TRUE; /* don't handle clipping here */
|
||||
|
||||
/* We don't do elts */
|
||||
if (VB->Elts)
|
||||
return GL_TRUE;
|
||||
|
||||
tab = TAG(render_tab_verts);
|
||||
|
||||
tnl->Driver.Render.Start( ctx );
|
||||
|
||||
for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length)
|
||||
{
|
||||
flags = VB->Primitive[i];
|
||||
length = VB->PrimitiveLength[i];
|
||||
if (length)
|
||||
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
|
||||
}
|
||||
|
||||
tnl->Driver.Render.Finish( ctx );
|
||||
|
||||
return GL_FALSE; /* finished the pipe */
|
||||
}
|
||||
|
||||
|
||||
static void gamma_check_render( GLcontext *ctx,
|
||||
struct gl_pipeline_stage *stage )
|
||||
{
|
||||
GLuint inputs = VERT_BIT_CLIP | VERT_BIT_COLOR0;
|
||||
|
||||
if (ctx->RenderMode == GL_RENDER) {
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
||||
inputs |= VERT_BIT_COLOR1;
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled)
|
||||
inputs |= VERT_BIT_TEX0;
|
||||
|
||||
if (ctx->Texture.Unit[1]._ReallyEnabled)
|
||||
inputs |= VERT_BIT_TEX1;
|
||||
|
||||
if (ctx->Fog.Enabled)
|
||||
inputs |= VERT_BIT_FOG;
|
||||
}
|
||||
|
||||
stage->inputs = inputs;
|
||||
}
|
||||
|
||||
|
||||
static void dtr( struct gl_pipeline_stage *stage )
|
||||
{
|
||||
(void)stage;
|
||||
}
|
||||
|
||||
|
||||
const struct gl_pipeline_stage _gamma_render_stage =
|
||||
{
|
||||
"gamma render",
|
||||
(_DD_NEW_SEPARATE_SPECULAR |
|
||||
_NEW_TEXTURE|
|
||||
_NEW_FOG|
|
||||
_NEW_RENDERMODE), /* re-check (new inputs) */
|
||||
0, /* re-run (always runs) */
|
||||
GL_TRUE, /* active */
|
||||
0, 0, /* inputs (set in check_render), outputs */
|
||||
0, 0, /* changed_inputs, private */
|
||||
dtr, /* destructor */
|
||||
gamma_check_render, /* check - initially set to alloc data */
|
||||
gamma_run_render /* run */
|
||||
};
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "glint_dri.h"
|
||||
|
||||
#include "imports.h"
|
||||
|
||||
gammaScreenPtr gammaCreateScreen( __DRIscreenPrivate *sPriv )
|
||||
{
|
||||
gammaScreenPtr gammaScreen;
|
||||
GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)sPriv->pDevPriv;
|
||||
int i;
|
||||
|
||||
#if 0
|
||||
/* Check the DRI externsion version */
|
||||
if ( sPriv->driMajor != 3 || sPriv->driMinor != 1 ) {
|
||||
__driUtilMessage( "Gamma DRI driver expected DRI version 4.0.x "
|
||||
"but got version %d.%d.%d",
|
||||
sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check that the DDX driver version is compatible */
|
||||
if ( sPriv->ddxMajor != 4 ||
|
||||
sPriv->ddxMinor != 0 ||
|
||||
sPriv->ddxPatch < 0 ) {
|
||||
__driUtilMessage( "r128 DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
/* Check that the DRM driver version is compatible */
|
||||
if ( sPriv->drmMajor != 2 ||
|
||||
sPriv->drmMinor != 1 ||
|
||||
sPriv->drmPatch < 0 ) {
|
||||
__driUtilMessage( "r128 DRI driver expected DRM driver version 2.1.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
|
||||
return GL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate the private area */
|
||||
gammaScreen = (gammaScreenPtr) CALLOC( sizeof(*gammaScreen) );
|
||||
if ( !gammaScreen ) return NULL;
|
||||
|
||||
gammaScreen->regionCount = 4; /* Magic number. Can we fix this? */
|
||||
|
||||
gammaScreen->regions = CALLOC(gammaScreen->regionCount *
|
||||
sizeof(gammaRegion));
|
||||
|
||||
gammaScreen->regions[0].handle = gDRIPriv->registers0.handle;
|
||||
gammaScreen->regions[0].size = gDRIPriv->registers0.size;
|
||||
gammaScreen->regions[1].handle = gDRIPriv->registers1.handle;
|
||||
gammaScreen->regions[1].size = gDRIPriv->registers1.size;
|
||||
gammaScreen->regions[2].handle = gDRIPriv->registers2.handle;
|
||||
gammaScreen->regions[2].size = gDRIPriv->registers2.size;
|
||||
gammaScreen->regions[3].handle = gDRIPriv->registers3.handle;
|
||||
gammaScreen->regions[3].size = gDRIPriv->registers3.size;
|
||||
|
||||
/* Next, map all the regions */
|
||||
for (i = 0; i < gammaScreen->regionCount; i++) {
|
||||
if (drmMap(sPriv->fd,
|
||||
gammaScreen->regions[i].handle,
|
||||
gammaScreen->regions[i].size,
|
||||
&gammaScreen->regions[i].map)) {
|
||||
while (--i > 0) {
|
||||
(void)drmUnmap(gammaScreen->regions[i].map,
|
||||
gammaScreen->regions[i].size);
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the list of dma buffers */
|
||||
gammaScreen->bufs = drmMapBufs(sPriv->fd);
|
||||
|
||||
if (!gammaScreen->bufs) {
|
||||
while (gammaScreen->regionCount > 0) {
|
||||
(void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
|
||||
gammaScreen->regions[gammaScreen->regionCount].size);
|
||||
gammaScreen->regionCount--;
|
||||
}
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
gammaScreen->textureSize = gDRIPriv->textureSize;
|
||||
gammaScreen->logTextureGranularity = gDRIPriv->logTextureGranularity;
|
||||
gammaScreen->cpp = gDRIPriv->cpp;
|
||||
gammaScreen->frontOffset = gDRIPriv->frontOffset;
|
||||
gammaScreen->frontPitch = gDRIPriv->frontPitch;
|
||||
gammaScreen->backOffset = gDRIPriv->backOffset;
|
||||
gammaScreen->backPitch = gDRIPriv->backPitch;
|
||||
gammaScreen->backX = gDRIPriv->backX;
|
||||
gammaScreen->backY = gDRIPriv->backY;
|
||||
gammaScreen->depthOffset = gDRIPriv->depthOffset;
|
||||
gammaScreen->depthPitch = gDRIPriv->depthPitch;
|
||||
|
||||
gammaScreen->driScreen = sPriv;
|
||||
|
||||
return gammaScreen;
|
||||
}
|
||||
|
||||
/* Destroy the device specific screen private data struct.
|
||||
*/
|
||||
void gammaDestroyScreen( __DRIscreenPrivate *sPriv )
|
||||
{
|
||||
gammaScreenPtr gammaScreen = (gammaScreenPtr)sPriv->private;
|
||||
|
||||
/* First, unmap the dma buffers */
|
||||
drmUnmapBufs( gammaScreen->bufs );
|
||||
|
||||
/* Next, unmap all the regions */
|
||||
while (gammaScreen->regionCount > 0) {
|
||||
(void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
|
||||
gammaScreen->regions[gammaScreen->regionCount].size);
|
||||
gammaScreen->regionCount--;
|
||||
}
|
||||
FREE(gammaScreen->regions);
|
||||
FREE(gammaScreen);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
typedef struct _gammaRegion {
|
||||
drmHandle handle;
|
||||
drmSize size;
|
||||
drmAddress map;
|
||||
} gammaRegion, *gammaRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
|
||||
int regionCount; /* Count of register regions */
|
||||
gammaRegion *regions; /* Vector of mapped region info */
|
||||
|
||||
drmBufMapPtr bufs; /* Map of DMA buffers */
|
||||
|
||||
__DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
|
||||
|
||||
int cpp;
|
||||
int frontPitch;
|
||||
int frontOffset;
|
||||
|
||||
int backPitch;
|
||||
int backOffset;
|
||||
int backX;
|
||||
int backY;
|
||||
|
||||
int depthOffset;
|
||||
int depthPitch;
|
||||
|
||||
int textureSize;
|
||||
int logTextureGranularity;
|
||||
} gammaScreenRec, *gammaScreenPtr;
|
||||
@@ -0,0 +1,342 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_span.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_lock.h"
|
||||
#include "colormac.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define DBG 0
|
||||
|
||||
#define LOCAL_VARS \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
gammaScreenPtr gammascrn = gmesa->gammaScreen; \
|
||||
__DRIscreenPrivate *sPriv = gmesa->driScreen; \
|
||||
__DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
|
||||
GLuint pitch = sPriv->fbWidth * gammascrn->cpp; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(sPriv->pFB + \
|
||||
gmesa->drawOffset + \
|
||||
(dPriv->x * gammascrn->cpp) + \
|
||||
(dPriv->y * pitch)); \
|
||||
char *read_buf = (char *)(sPriv->pFB + \
|
||||
gmesa->readOffset + \
|
||||
(dPriv->x * gammascrn->cpp) + \
|
||||
(dPriv->y * pitch)); \
|
||||
GLuint p; \
|
||||
(void) read_buf; (void) buf; (void) p
|
||||
|
||||
/* FIXME! Depth/Stencil read/writes don't work ! */
|
||||
#define LOCAL_DEPTH_VARS \
|
||||
gammaScreenPtr gammascrn = gmesa->gammaScreen; \
|
||||
__DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
|
||||
__DRIscreenPrivate *sPriv = gmesa->driScreen; \
|
||||
GLuint pitch = gammascrn->depthPitch; \
|
||||
GLuint height = dPriv->h; \
|
||||
char *buf = (char *)(sPriv->pFB + \
|
||||
gammascrn->depthOffset + \
|
||||
dPriv->x * gammascrn->cpp + \
|
||||
dPriv->y * pitch)
|
||||
|
||||
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
|
||||
|
||||
|
||||
#define CLIPPIXEL( _x, _y ) \
|
||||
((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
|
||||
|
||||
|
||||
#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
|
||||
if ( _y < miny || _y >= maxy ) { \
|
||||
_n1 = 0, _x1 = x; \
|
||||
} else { \
|
||||
_n1 = _n; \
|
||||
_x1 = _x; \
|
||||
if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
|
||||
if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
|
||||
}
|
||||
|
||||
#define Y_FLIP( _y ) (height - _y - 1)
|
||||
|
||||
#define HW_LOCK() \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
FLUSH_DMA_BUFFER(gmesa); \
|
||||
gammaGetLock( gmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); \
|
||||
GAMMAHW_LOCK( gmesa );
|
||||
|
||||
#define HW_CLIPLOOP() \
|
||||
do { \
|
||||
__DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
|
||||
int _nc = dPriv->numClipRects; \
|
||||
\
|
||||
while ( _nc-- ) { \
|
||||
int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
|
||||
int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
|
||||
int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
|
||||
int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
|
||||
|
||||
#define HW_ENDCLIPLOOP() \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define HW_UNLOCK() GAMMAHW_UNLOCK( gmesa )
|
||||
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Color buffer
|
||||
*/
|
||||
|
||||
/* 16 bit, RGB565 color spanline and pixel functions
|
||||
*/
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = PACK_COLOR_565( color[0], color[1], color[2] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
|
||||
(((int)g & 0xfc) << 3) | \
|
||||
(((int)b & 0xf8) >> 3))
|
||||
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLushort *)(buf + _x*2 + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
|
||||
rgba[0] = (p >> 8) & 0xf8; \
|
||||
rgba[1] = (p >> 3) & 0xfc; \
|
||||
rgba[2] = (p << 3) & 0xf8; \
|
||||
rgba[3] = 0xff; \
|
||||
if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \
|
||||
if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
|
||||
if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) gamma##x##_RGB565
|
||||
#include "spantmp.h"
|
||||
|
||||
|
||||
/* 32 bit, ARGB8888 color spanline and pixel functions
|
||||
*/
|
||||
|
||||
#undef INIT_MONO_PIXEL
|
||||
#define INIT_MONO_PIXEL(p, color) \
|
||||
p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
|
||||
|
||||
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
|
||||
(g << 8) | \
|
||||
(r << 16) | \
|
||||
(a << 24) )
|
||||
|
||||
#define WRITE_PIXEL( _x, _y, p ) \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = p
|
||||
|
||||
#define READ_RGBA( rgba, _x, _y ) \
|
||||
do { \
|
||||
GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch); \
|
||||
rgba[0] = (p >> 16) & 0xff; \
|
||||
rgba[1] = (p >> 8) & 0xff; \
|
||||
rgba[2] = (p >> 0) & 0xff; \
|
||||
rgba[3] = (p >> 24) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
#define TAG(x) gamma##x##_ARGB8888
|
||||
#include "spantmp.h"
|
||||
|
||||
|
||||
/* 16 bit depthbuffer functions.
|
||||
*/
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLushort *)(buf + _x*2 + _y*pitch) = d;
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLushort *)(buf + _x*2 + _y*pitch);
|
||||
|
||||
#define TAG(x) gamma##x##_16
|
||||
#include "depthtmp.h"
|
||||
|
||||
|
||||
|
||||
#if 0 /* Unused */
|
||||
/* 32 bit depthbuffer functions.
|
||||
*/
|
||||
#define WRITE_DEPTH( _x, _y, d ) \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = d;
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + _x*4 + _y*pitch);
|
||||
|
||||
#define TAG(x) gamma##x##_32
|
||||
#include "depthtmp.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* 24/8 bit interleaved depth/stencil functions
|
||||
*/
|
||||
#define WRITE_DEPTH( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
|
||||
tmp &= 0xff; \
|
||||
tmp |= (d) & 0xffffff00; \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_DEPTH( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff;
|
||||
|
||||
|
||||
#define TAG(x) gamma##x##_24_8
|
||||
#include "depthtmp.h"
|
||||
|
||||
#if 0
|
||||
#define WRITE_STENCIL( _x, _y, d ) { \
|
||||
GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
|
||||
tmp &= 0xffffff00; \
|
||||
tmp |= d & 0xff; \
|
||||
*(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
|
||||
}
|
||||
|
||||
#define READ_STENCIL( d, _x, _y ) \
|
||||
d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff;
|
||||
|
||||
#define TAG(x) gamma##x##_24_8
|
||||
#include "stenciltmp.h"
|
||||
|
||||
static void gammaReadRGBASpan8888( const GLcontext *ctx,
|
||||
GLuint n, GLint x, GLint y,
|
||||
GLubyte rgba[][4])
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
gammaScreenPtr gammascrn = gmesa->gammaScreen;
|
||||
CARD32 dwords1, dwords2, i = 0;
|
||||
char *src = (char *)rgba[0];
|
||||
GLuint read = n * gammascrn->cpp; /* Number of bytes we are expecting */
|
||||
CARD32 data;
|
||||
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
CHECK_DMA_BUFFER(gmesa, 16);
|
||||
WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode & ~(LBReadSrcEnable | LBReadDstEnable));
|
||||
WRITE(gmesa->buf, ColorDDAMode, ColorDDAEnable);
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
|
||||
WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode & ~FBReadSrcEnable) | FBReadDstEnable | FBDataTypeColor);
|
||||
WRITE(gmesa->buf, FilterMode, 0x200); /* Pass FBColorData */
|
||||
WRITE(gmesa->buf, FBWriteMode, FBW_UploadColorData | FBWriteModeDisable);
|
||||
WRITE(gmesa->buf, StartXSub, (x+n)<<16);
|
||||
WRITE(gmesa->buf, StartXDom, x<<16);
|
||||
WRITE(gmesa->buf, StartY, y<<16);
|
||||
WRITE(gmesa->buf, GLINTCount, 1);
|
||||
WRITE(gmesa->buf, dXDom, 0<<16);
|
||||
WRITE(gmesa->buf, dXSub, 0<<16);
|
||||
WRITE(gmesa->buf, dY, 1<<16);
|
||||
WRITE(gmesa->buf, Render, PrimitiveTrapezoid);
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
|
||||
moredata:
|
||||
|
||||
dwords1 = *(volatile CARD32*)(void *)(((CARD8*)gammascrn->regions[0].map) + (GlintOutFIFOWords));
|
||||
dwords2 = *(volatile CARD32*)(void *)(((CARD8*)gammascrn->regions[2].map) + (GlintOutFIFOWords));
|
||||
|
||||
if (dwords1) {
|
||||
memcpy(src, (char*)gammascrn->regions[1].map + 0x1000, dwords1 << 2);
|
||||
src += dwords1 << 2;
|
||||
read -= dwords1 << 2;
|
||||
}
|
||||
if (dwords2) {
|
||||
memcpy(src, (char*)gammascrn->regions[3].map + 0x1000, dwords2 << 2);
|
||||
src += dwords2 << 2;
|
||||
read -= dwords2 << 2;
|
||||
}
|
||||
|
||||
if (read)
|
||||
goto moredata;
|
||||
|
||||
done:
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
|
||||
WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
|
||||
WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
|
||||
WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
|
||||
WRITE(gmesa->buf, FilterMode, 0x400);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gammaSetBuffer( GLcontext *ctx,
|
||||
GLframebuffer *colorBuffer,
|
||||
GLuint bufferBit )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
switch ( bufferBit ) {
|
||||
case FRONT_LEFT_BIT:
|
||||
gmesa->readOffset = 0;
|
||||
break;
|
||||
case BACK_LEFT_BIT:
|
||||
gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaDDInitSpanFuncs( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
|
||||
|
||||
swdd->SetBuffer = gammaSetBuffer;
|
||||
|
||||
switch ( gmesa->gammaScreen->cpp ) {
|
||||
case 2:
|
||||
swdd->WriteRGBASpan = gammaWriteRGBASpan_RGB565;
|
||||
swdd->WriteRGBSpan = gammaWriteRGBSpan_RGB565;
|
||||
swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_RGB565;
|
||||
swdd->WriteRGBAPixels = gammaWriteRGBAPixels_RGB565;
|
||||
swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_RGB565;
|
||||
swdd->ReadRGBASpan = gammaReadRGBASpan_RGB565;
|
||||
swdd->ReadRGBAPixels = gammaReadRGBAPixels_RGB565;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
swdd->WriteRGBASpan = gammaWriteRGBASpan_ARGB8888;
|
||||
swdd->WriteRGBSpan = gammaWriteRGBSpan_ARGB8888;
|
||||
swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_ARGB8888;
|
||||
swdd->WriteRGBAPixels = gammaWriteRGBAPixels_ARGB8888;
|
||||
swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_ARGB8888;
|
||||
#if 1
|
||||
swdd->ReadRGBASpan = gammaReadRGBASpan_ARGB8888;
|
||||
#else
|
||||
swdd->ReadRGBASpan = gammaReadRGBASpan8888;
|
||||
#endif
|
||||
swdd->ReadRGBAPixels = gammaReadRGBAPixels_ARGB8888;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( gmesa->glCtx->Visual.depthBits ) {
|
||||
case 16:
|
||||
swdd->ReadDepthSpan = gammaReadDepthSpan_16;
|
||||
swdd->WriteDepthSpan = gammaWriteDepthSpan_16;
|
||||
swdd->ReadDepthPixels = gammaReadDepthPixels_16;
|
||||
swdd->WriteDepthPixels = gammaWriteDepthPixels_16;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
swdd->ReadDepthSpan = gammaReadDepthSpan_24_8;
|
||||
swdd->WriteDepthSpan = gammaWriteDepthSpan_24_8;
|
||||
swdd->ReadDepthPixels = gammaReadDepthPixels_24_8;
|
||||
swdd->WriteDepthPixels = gammaWriteDepthPixels_24_8;
|
||||
|
||||
#if 0
|
||||
swdd->ReadStencilSpan = gammaReadStencilSpan_24_8;
|
||||
swdd->WriteStencilSpan = gammaWriteStencilSpan_24_8;
|
||||
swdd->ReadStencilPixels = gammaReadStencilPixels_24_8;
|
||||
swdd->WriteStencilPixels = gammaWriteStencilPixels_24_8;
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,428 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "imports.h"
|
||||
#include "simple_list.h"
|
||||
#include "enums.h"
|
||||
#include "texstore.h"
|
||||
#include "teximage.h"
|
||||
#include "texformat.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#include "mm.h"
|
||||
#include "gamma_context.h"
|
||||
#include "colormac.h"
|
||||
|
||||
|
||||
/*
|
||||
* Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
|
||||
*/
|
||||
#if 0
|
||||
static GLuint gammaComputeLodBias(GLfloat bias)
|
||||
{
|
||||
return bias;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gammaSetTexWrapping(gammaTextureObjectPtr t,
|
||||
GLenum wraps, GLenum wrapt)
|
||||
{
|
||||
CARD32 t1 = t->TextureAddressMode;
|
||||
CARD32 t2 = t->TextureReadMode;
|
||||
|
||||
t1 &= ~(TAM_SWrap_Mask | TAM_TWrap_Mask);
|
||||
t2 &= ~(TRM_UWrap_Mask | TRM_VWrap_Mask);
|
||||
|
||||
if (wraps != GL_CLAMP) {
|
||||
t1 |= TAM_SWrap_Repeat;
|
||||
t2 |= TRM_UWrap_Repeat;
|
||||
}
|
||||
|
||||
if (wrapt != GL_CLAMP) {
|
||||
t1 |= TAM_TWrap_Repeat;
|
||||
t2 |= TRM_VWrap_Repeat;
|
||||
}
|
||||
|
||||
t->TextureAddressMode = t1;
|
||||
t->TextureReadMode = t2;
|
||||
}
|
||||
|
||||
|
||||
static void gammaSetTexFilter(gammaContextPtr gmesa,
|
||||
gammaTextureObjectPtr t,
|
||||
GLenum minf, GLenum magf,
|
||||
GLfloat bias)
|
||||
{
|
||||
CARD32 t1 = t->TextureAddressMode;
|
||||
CARD32 t2 = t->TextureReadMode;
|
||||
|
||||
t2 &= ~(TRM_Mag_Mask | TRM_Min_Mask);
|
||||
|
||||
switch (minf) {
|
||||
case GL_NEAREST:
|
||||
t1 &= ~TAM_LODEnable;
|
||||
t2 &= ~TRM_MipMapEnable;
|
||||
t2 |= TRM_Min_Nearest;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
t1 &= ~TAM_LODEnable;
|
||||
t2 &= ~TRM_MipMapEnable;
|
||||
t2 |= TRM_Min_Linear;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_NEAREST:
|
||||
t2 |= TRM_Min_NearestMMNearest;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_NEAREST:
|
||||
t2 |= TRM_Min_LinearMMNearest;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_LINEAR:
|
||||
t2 |= TRM_Min_NearestMMLinear;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_LINEAR:
|
||||
t2 |= TRM_Min_LinearMMLinear;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (magf) {
|
||||
case GL_NEAREST:
|
||||
t2 |= TRM_Mag_Nearest;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
t2 |= TRM_Mag_Linear;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
t->TextureAddressMode = t1;
|
||||
t->TextureReadMode = t2;
|
||||
}
|
||||
|
||||
|
||||
static void gammaSetTexBorderColor(gammaContextPtr gmesa,
|
||||
gammaTextureObjectPtr t,
|
||||
GLubyte color[4])
|
||||
{
|
||||
t->TextureBorderColor = PACK_COLOR_8888(color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
|
||||
static void gammaTexParameter( GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *tObj,
|
||||
GLenum pname, const GLfloat *params )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
if (!t)
|
||||
return;
|
||||
|
||||
/* Can't do the update now as we don't know whether to flush
|
||||
* vertices or not. Setting gmesa->new_state means that
|
||||
* gammaUpdateTextureState() will be called before any triangles are
|
||||
* rendered. If a statechange has occurred, it will be detected at
|
||||
* that point, and buffered vertices flushed.
|
||||
*/
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_MIN_FILTER:
|
||||
case GL_TEXTURE_MAG_FILTER:
|
||||
{
|
||||
GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
|
||||
gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_WRAP_S:
|
||||
case GL_TEXTURE_WRAP_T:
|
||||
gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_BORDER_COLOR:
|
||||
gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_BASE_LEVEL:
|
||||
case GL_TEXTURE_MAX_LEVEL:
|
||||
case GL_TEXTURE_MIN_LOD:
|
||||
case GL_TEXTURE_MAX_LOD:
|
||||
/* This isn't the most efficient solution but there doesn't appear to
|
||||
* be a nice alternative for Radeon. Since there's no LOD clamping,
|
||||
* we just have to rely on loading the right subset of mipmap levels
|
||||
* to simulate a clamped LOD.
|
||||
*/
|
||||
gammaSwapOutTexObj( gmesa, t );
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (t == gmesa->CurrentTexObj[0])
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0;
|
||||
|
||||
#if 0
|
||||
if (t == gmesa->CurrentTexObj[1]) {
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void gammaTexEnv( GLcontext *ctx, GLenum target,
|
||||
GLenum pname, const GLfloat *param )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
GLuint unit = ctx->Texture.CurrentUnit;
|
||||
|
||||
/* Only one env color. Need a fallback if env colors are different
|
||||
* and texture setup references env color in both units.
|
||||
*/
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_ENV_COLOR: {
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
GLfloat *fc = texUnit->EnvColor;
|
||||
GLuint r, g, b, a, col;
|
||||
CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
|
||||
CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
|
||||
|
||||
col = ((a << 24) |
|
||||
(r << 16) |
|
||||
(g << 8) |
|
||||
(b << 0));
|
||||
|
||||
break;
|
||||
}
|
||||
case GL_TEXTURE_ENV_MODE:
|
||||
gmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_LOD_BIAS_EXT:
|
||||
#if 0 /* ?!?!?! */
|
||||
{
|
||||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
(void) t;
|
||||
/* XXX Looks like there's something missing here */
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void gammaTexImage1D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLint width, GLint border,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *pack,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_teximage1d( ctx, target, level, internalFormat,
|
||||
width, border, format, type,
|
||||
pixels, pack, texObj, texImage );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void gammaTexSubImage1D( GLcontext *ctx,
|
||||
GLenum target,
|
||||
GLint level,
|
||||
GLint xoffset,
|
||||
GLsizei width,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *pack,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
|
||||
format, type, pixels, pack, texObj,
|
||||
texImage);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gammaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLint width, GLint height, GLint border,
|
||||
GLenum format, GLenum type, const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_teximage2d( ctx, target, level, internalFormat,
|
||||
width, height, border, format, type,
|
||||
pixels, packing, texObj, texImage );
|
||||
}
|
||||
|
||||
static void gammaTexSubImage2D( GLcontext *ctx,
|
||||
GLenum target,
|
||||
GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid *pixels,
|
||||
const struct gl_pixelstore_attrib *packing,
|
||||
struct gl_texture_object *texObj,
|
||||
struct gl_texture_image *texImage )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
|
||||
if (t) {
|
||||
gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
|
||||
}
|
||||
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
|
||||
height, format, type, pixels, packing, texObj,
|
||||
texImage);
|
||||
}
|
||||
|
||||
|
||||
static void gammaBindTexture( GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *tObj )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
|
||||
if (!t) {
|
||||
GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
|
||||
t = CALLOC_STRUCT(gamma_texture_object_t);
|
||||
|
||||
/* Initialize non-image-dependent parts of the state:
|
||||
*/
|
||||
t->globj = tObj;
|
||||
|
||||
t->TextureAddressMode = TextureAddressModeEnable | TAM_Operation_3D |
|
||||
TAM_DY_Enable | TAM_LODEnable;
|
||||
t->TextureReadMode = TextureReadModeEnable | TRM_PrimaryCacheEnable |
|
||||
TRM_MipMapEnable | TRM_BorderClamp | TRM_Border;
|
||||
t->TextureColorMode = TextureColorModeEnable;
|
||||
t->TextureFilterMode = TextureFilterModeEnable;
|
||||
|
||||
if (target == GL_TEXTURE_2D) {
|
||||
t->TextureAddressMode |= TAM_TexMapType_2D;
|
||||
t->TextureReadMode |= TRM_TexMapType_2D;
|
||||
} else
|
||||
if (target == GL_TEXTURE_1D) {
|
||||
t->TextureAddressMode |= TAM_TexMapType_1D;
|
||||
t->TextureReadMode |= TRM_TexMapType_1D;
|
||||
}
|
||||
|
||||
t->TextureColorMode = TextureColorModeEnable;
|
||||
|
||||
t->TextureFilterMode = TextureFilterModeEnable;
|
||||
|
||||
#ifdef MESA_LITTLE_ENDIAN
|
||||
t->TextureFormat = (TF_LittleEndian |
|
||||
#else
|
||||
t->TextureFormat = (TF_BigEndian |
|
||||
#endif
|
||||
TF_ColorOrder_RGB |
|
||||
TF_OutputFmt_Texel);
|
||||
|
||||
t->dirty_images = ~0;
|
||||
|
||||
tObj->DriverData = t;
|
||||
make_empty_list( t );
|
||||
|
||||
gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
|
||||
gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
|
||||
gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
|
||||
if (t) {
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
#if 0
|
||||
if (gmesa)
|
||||
GAMMA_FIREVERTICES( gmesa );
|
||||
#endif
|
||||
gammaDestroyTexObj( gmesa, t );
|
||||
tObj->DriverData = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static GLboolean gammaIsTextureResident( GLcontext *ctx,
|
||||
struct gl_texture_object *tObj )
|
||||
{
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
return t && t->MemBlock;
|
||||
}
|
||||
|
||||
static void gammaInitTextureObjects( GLcontext *ctx )
|
||||
{
|
||||
struct gl_texture_object *texObj;
|
||||
GLuint tmp = ctx->Texture.CurrentUnit;
|
||||
|
||||
ctx->Texture.CurrentUnit = 0;
|
||||
|
||||
texObj = ctx->Texture.Unit[0].Current1D;
|
||||
gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
|
||||
|
||||
texObj = ctx->Texture.Unit[0].Current2D;
|
||||
gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
|
||||
|
||||
#if 0
|
||||
ctx->Texture.CurrentUnit = 1;
|
||||
|
||||
texObj = ctx->Texture.Unit[1].Current1D;
|
||||
gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
|
||||
|
||||
texObj = ctx->Texture.Unit[1].Current2D;
|
||||
gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
|
||||
#endif
|
||||
|
||||
ctx->Texture.CurrentUnit = tmp;
|
||||
}
|
||||
|
||||
|
||||
void gammaDDInitTextureFuncs( GLcontext *ctx )
|
||||
{
|
||||
ctx->Driver.TexEnv = gammaTexEnv;
|
||||
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
|
||||
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
|
||||
ctx->Driver.TexImage2D = gammaTexImage2D;
|
||||
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
|
||||
ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
|
||||
ctx->Driver.TexSubImage2D = gammaTexSubImage2D;
|
||||
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
|
||||
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
|
||||
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
|
||||
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
|
||||
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
|
||||
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
|
||||
ctx->Driver.BindTexture = gammaBindTexture;
|
||||
ctx->Driver.DeleteTexture = gammaDeleteTexture;
|
||||
ctx->Driver.TexParameter = gammaTexParameter;
|
||||
ctx->Driver.UpdateTexturePalette = 0;
|
||||
ctx->Driver.IsTextureResident = gammaIsTextureResident;
|
||||
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
|
||||
|
||||
gammaInitTextureObjects( ctx );
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c,v 1.5 2002/11/05 17:46:07 tsi Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glheader.h"
|
||||
#include "colormac.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "simple_list.h"
|
||||
#include "enums.h"
|
||||
|
||||
#include "mm.h"
|
||||
#include "glint_dri.h"
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_lock.h"
|
||||
|
||||
void gammaDestroyTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
|
||||
{
|
||||
if (!t) return;
|
||||
|
||||
/* This is sad - need to sync *in case* we upload a texture
|
||||
* to this newly free memory...
|
||||
*/
|
||||
if (t->MemBlock) {
|
||||
mmFreeMem(t->MemBlock);
|
||||
t->MemBlock = 0;
|
||||
|
||||
if (gmesa && t->age > gmesa->dirtyAge)
|
||||
gmesa->dirtyAge = t->age;
|
||||
}
|
||||
|
||||
if (t->globj)
|
||||
t->globj->DriverData = 0;
|
||||
|
||||
if (gmesa) {
|
||||
if (gmesa->CurrentTexObj[0] == t) {
|
||||
gmesa->CurrentTexObj[0] = 0;
|
||||
gmesa->dirty &= ~GAMMA_UPLOAD_TEX0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (gmesa->CurrentTexObj[1] == t) {
|
||||
gmesa->CurrentTexObj[1] = 0;
|
||||
gmesa->dirty &= ~GAMMA_UPLOAD_TEX1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
remove_from_list(t);
|
||||
free(t);
|
||||
}
|
||||
|
||||
|
||||
void gammaSwapOutTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
|
||||
{
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
if (t->MemBlock) {
|
||||
mmFreeMem(t->MemBlock);
|
||||
t->MemBlock = 0;
|
||||
|
||||
if (t->age > gmesa->dirtyAge)
|
||||
gmesa->dirtyAge = t->age;
|
||||
}
|
||||
|
||||
t->dirty_images = ~0;
|
||||
move_to_tail(&(gmesa->SwappedOut), t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Upload an image from mesa's internal copy.
|
||||
*/
|
||||
static void gammaUploadTexLevel( gammaContextPtr gmesa, gammaTextureObjectPtr t, int level )
|
||||
{
|
||||
const struct gl_texture_image *image = t->image[level].image;
|
||||
int i,j;
|
||||
int l2d;
|
||||
#if 0
|
||||
int offset = 0;
|
||||
#endif
|
||||
int words, depthLog2;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
l2d = 5; /* 32bits per texel == 1<<5 */
|
||||
|
||||
if (level == 0) {
|
||||
t->TextureAddressMode &= ~(TAM_WidthMask | TAM_HeightMask);
|
||||
t->TextureAddressMode |= (image->WidthLog2 << 9) |
|
||||
(image->HeightLog2 << 13);
|
||||
t->TextureReadMode &= ~(TRM_WidthMask | TRM_HeightMask |
|
||||
TRM_DepthMask | TRM_Border |
|
||||
TRM_Patch);
|
||||
t->TextureReadMode |= (image->WidthLog2 << 1) |
|
||||
(image->HeightLog2 << 5) |
|
||||
(l2d << 9);
|
||||
t->TextureFormat &= ~(TF_CompnentsMask | TF_OneCompFmt_Mask);
|
||||
}
|
||||
|
||||
t->TextureBaseAddr[level] = /* ??? */
|
||||
(unsigned long)(t->image[level].offset + t->BufAddr) << 5;
|
||||
|
||||
CALC_LOG2(depthLog2, 1<<l2d);
|
||||
words = (image->Width * image->Height) >> (5-depthLog2);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 3);
|
||||
WRITE(gmesa->buf, LBWindowBase, t->TextureBaseAddr[level] >> 5);
|
||||
WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
|
||||
WRITE(gmesa->buf, WaitForCompletion, 0);
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
|
||||
switch (t->image[level].internalFormat) {
|
||||
case GL_RGB:
|
||||
case 3:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_3;
|
||||
|
||||
#if 0 /* This is the texture download code we SHOULD be using */
|
||||
/* In the routines below, but this causes an DMA overrun - WHY ? */
|
||||
while (offset < words) {
|
||||
int count = gmesa->bufSize;
|
||||
int i;
|
||||
count -= 3;
|
||||
if (count > words-offset) count = words-offset;
|
||||
|
||||
gmesa->buf->i = GlintTextureDownloadOffsetTag;
|
||||
gmesa->buf++;
|
||||
gmesa->buf->i = offset;
|
||||
gmesa->buf++;
|
||||
gmesa->buf->i = (GlintTextureDataTag | ((count-1) << 16));
|
||||
gmesa->buf++;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
gmesa->buf->i = PACK_COLOR_565(src[0],src[1],src[2]);
|
||||
gmesa->buf++;
|
||||
src += 3;
|
||||
}
|
||||
|
||||
gmesa->bufCount = count+3; /* texture data + 3 values */
|
||||
offset += count;
|
||||
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
#else
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_565(src[0],src[1],src[2]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 3;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_RGBA:
|
||||
case 4:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_4;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 4;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_LUMINANCE:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Lum;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_888(src[0],src[0],src[0]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src ++;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_INTENSITY:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Intensity;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src ++;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_2;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 2;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
case GL_ALPHA:
|
||||
{
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
if (level == 0)
|
||||
t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Alpha;
|
||||
|
||||
/* The UGLY way, and SLOW !, but the above sometimes causes
|
||||
* a DMA overrun error ??? FIXME ! */
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureDownloadOffset, 0);
|
||||
for (i = 0; i < words; i++) {
|
||||
unsigned int data;
|
||||
data = PACK_COLOR_8888(255,255,255,src[0]);
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, TextureData, data);
|
||||
src += 1;
|
||||
}
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
}
|
||||
break;
|
||||
|
||||
/* TODO: Translate color indices *now*:
|
||||
*/
|
||||
case GL_COLOR_INDEX:
|
||||
{
|
||||
GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
|
||||
GLubyte *src = (GLubyte *)image->Data;
|
||||
|
||||
for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
|
||||
for (i = 0 ; i < image->Width ; i++) {
|
||||
dst[i] = src[0];
|
||||
src += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Not supported texture format %s\n",
|
||||
_mesa_lookup_enum_by_nr(image->Format));
|
||||
}
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, WaitForCompletion, 0);
|
||||
WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
|
||||
}
|
||||
|
||||
void gammaPrintLocalLRU( gammaContextPtr gmesa )
|
||||
{
|
||||
gammaTextureObjectPtr t;
|
||||
int sz = 1 << (gmesa->gammaScreen->logTextureGranularity);
|
||||
|
||||
foreach( t, &gmesa->TexObjList ) {
|
||||
if (!t->globj)
|
||||
fprintf(stderr, "Placeholder %d at %x sz %x\n",
|
||||
t->MemBlock->ofs / sz,
|
||||
t->MemBlock->ofs,
|
||||
t->MemBlock->size);
|
||||
else
|
||||
fprintf(stderr, "Texture at %x sz %x\n",
|
||||
t->MemBlock->ofs,
|
||||
t->MemBlock->size);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void gammaPrintGlobalLRU( gammaContextPtr gmesa )
|
||||
{
|
||||
int i, j;
|
||||
GAMMATextureRegionPtr list = gmesa->sarea->texList;
|
||||
|
||||
for (i = 0, j = GAMMA_NR_TEX_REGIONS ; i < GAMMA_NR_TEX_REGIONS ; i++) {
|
||||
fprintf(stderr, "list[%d] age %d next %d prev %d\n",
|
||||
j, list[j].age, list[j].next, list[j].prev);
|
||||
j = list[j].next;
|
||||
if (j == GAMMA_NR_TEX_REGIONS) break;
|
||||
}
|
||||
|
||||
if (j != GAMMA_NR_TEX_REGIONS)
|
||||
fprintf(stderr, "Loop detected in global LRU\n");
|
||||
}
|
||||
|
||||
|
||||
void gammaResetGlobalLRU( gammaContextPtr gmesa )
|
||||
{
|
||||
GAMMATextureRegionPtr list = gmesa->sarea->texList;
|
||||
int sz = 1 << gmesa->gammaScreen->logTextureGranularity;
|
||||
int i;
|
||||
|
||||
/* (Re)initialize the global circular LRU list. The last element
|
||||
* in the array (GAMMA_NR_TEX_REGIONS) is the sentinal. Keeping it
|
||||
* at the end of the array allows it to be addressed rationally
|
||||
* when looking up objects at a particular location in texture
|
||||
* memory.
|
||||
*/
|
||||
for (i = 0 ; (i+1) * sz <= gmesa->gammaScreen->textureSize ; i++) {
|
||||
list[i].prev = i-1;
|
||||
list[i].next = i+1;
|
||||
list[i].age = 0;
|
||||
}
|
||||
|
||||
i--;
|
||||
list[0].prev = GAMMA_NR_TEX_REGIONS;
|
||||
list[i].prev = i-1;
|
||||
list[i].next = GAMMA_NR_TEX_REGIONS;
|
||||
list[GAMMA_NR_TEX_REGIONS].prev = i;
|
||||
list[GAMMA_NR_TEX_REGIONS].next = 0;
|
||||
gmesa->sarea->texAge = 0;
|
||||
}
|
||||
|
||||
|
||||
void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t )
|
||||
{
|
||||
int i;
|
||||
int logsz = gmesa->gammaScreen->logTextureGranularity;
|
||||
int start = t->MemBlock->ofs >> logsz;
|
||||
int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
|
||||
GAMMATextureRegionPtr list = gmesa->sarea->texList;
|
||||
|
||||
gmesa->texAge = ++gmesa->sarea->texAge;
|
||||
|
||||
/* Update our local LRU
|
||||
*/
|
||||
move_to_head( &(gmesa->TexObjList), t );
|
||||
|
||||
/* Update the global LRU
|
||||
*/
|
||||
for (i = start ; i <= end ; i++) {
|
||||
|
||||
list[i].in_use = 1;
|
||||
list[i].age = gmesa->texAge;
|
||||
|
||||
/* remove_from_list(i)
|
||||
*/
|
||||
list[(unsigned)list[i].next].prev = list[i].prev;
|
||||
list[(unsigned)list[i].prev].next = list[i].next;
|
||||
|
||||
/* insert_at_head(list, i)
|
||||
*/
|
||||
list[i].prev = GAMMA_NR_TEX_REGIONS;
|
||||
list[i].next = list[GAMMA_NR_TEX_REGIONS].next;
|
||||
list[(unsigned)list[GAMMA_NR_TEX_REGIONS].next].prev = i;
|
||||
list[GAMMA_NR_TEX_REGIONS].next = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Called for every shared texture region which has increased in age
|
||||
* since we last held the lock.
|
||||
*
|
||||
* Figures out which of our textures have been ejected by other clients,
|
||||
* and pushes a placeholder texture onto the LRU list to represent
|
||||
* the other client's textures.
|
||||
*/
|
||||
void gammaTexturesGone( gammaContextPtr gmesa,
|
||||
GLuint offset,
|
||||
GLuint size,
|
||||
GLuint in_use )
|
||||
{
|
||||
gammaTextureObjectPtr t, tmp;
|
||||
|
||||
foreach_s ( t, tmp, &gmesa->TexObjList ) {
|
||||
|
||||
if (t->MemBlock->ofs >= offset + size ||
|
||||
t->MemBlock->ofs + t->MemBlock->size <= offset)
|
||||
continue;
|
||||
|
||||
/* It overlaps - kick it off. Need to hold onto the currently bound
|
||||
* objects, however.
|
||||
*/
|
||||
gammaSwapOutTexObj( gmesa, t );
|
||||
}
|
||||
|
||||
if (in_use) {
|
||||
t = (gammaTextureObjectPtr) calloc(1,sizeof(*t));
|
||||
if (!t) return;
|
||||
|
||||
t->MemBlock = mmAllocMem( gmesa->texHeap, size, 0, offset);
|
||||
insert_at_head( &gmesa->TexObjList, t );
|
||||
}
|
||||
|
||||
/* Reload any lost textures referenced by current vertex buffer.
|
||||
*/
|
||||
#if 0
|
||||
if (gmesa->vertex_buffer) {
|
||||
int i, j;
|
||||
|
||||
fprintf(stderr, "\n\nreload tex\n");
|
||||
|
||||
for (i = 0 ; i < gmesa->statenr ; i++) {
|
||||
for (j = 0 ; j < 2 ; j++) {
|
||||
gammaTextureObjectPtr t = gmesa->state_tex[j][i];
|
||||
if (t) {
|
||||
if (t->MemBlock == 0)
|
||||
gammaUploadTexImages( gmesa, t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Hard to do this with the lock held:
|
||||
*/
|
||||
/* GAMMA_FIREVERTICES( gmesa ); */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* This is called with the lock held. May have to eject our own and/or
|
||||
* other client's texture objects to make room for the upload.
|
||||
*/
|
||||
void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t )
|
||||
{
|
||||
int i;
|
||||
int ofs;
|
||||
int numLevels;
|
||||
|
||||
/* /fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
#if 0
|
||||
LOCK_HARDWARE( gmesa );
|
||||
#endif
|
||||
|
||||
/* Do we need to eject LRU texture objects?
|
||||
*/
|
||||
if (!t->MemBlock) {
|
||||
while (1)
|
||||
{
|
||||
t->MemBlock = mmAllocMem( gmesa->texHeap, t->totalSize, 12, 0 );
|
||||
if (t->MemBlock)
|
||||
break;
|
||||
|
||||
if (gmesa->TexObjList.prev == gmesa->CurrentTexObj[0] ||
|
||||
gmesa->TexObjList.prev == gmesa->CurrentTexObj[1]) {
|
||||
fprintf(stderr, "Hit bound texture in upload\n");
|
||||
gammaPrintLocalLRU( gmesa );
|
||||
return;
|
||||
}
|
||||
|
||||
if (gmesa->TexObjList.prev == &(gmesa->TexObjList)) {
|
||||
fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
|
||||
mmDumpMemInfo( gmesa->texHeap );
|
||||
return;
|
||||
}
|
||||
|
||||
gammaSwapOutTexObj( gmesa, gmesa->TexObjList.prev );
|
||||
}
|
||||
|
||||
ofs = t->MemBlock->ofs;
|
||||
t->BufAddr = (char *)(unsigned long)(gmesa->LBWindowBase + ofs); /* ??? */
|
||||
|
||||
if (t == gmesa->CurrentTexObj[0])
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0;
|
||||
|
||||
#if 0
|
||||
if (t == gmesa->CurrentTexObj[1])
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX1;
|
||||
#endif
|
||||
|
||||
gammaUpdateTexLRU( gmesa, t );
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (gmesa->dirtyAge >= GET_DISPATCH_AGE(gmesa))
|
||||
gammaWaitAgeLocked( gmesa, gmesa->dirtyAge );
|
||||
#endif
|
||||
|
||||
numLevels = t->lastLevel - t->firstLevel + 1;
|
||||
for (i = 0 ; i < numLevels ; i++)
|
||||
if (t->dirty_images & (1<<i))
|
||||
gammaUploadTexLevel( gmesa, t, i );
|
||||
|
||||
t->dirty_images = 0;
|
||||
|
||||
#if 0
|
||||
UNLOCK_HARDWARE( gmesa );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c,v 1.5 2002/11/05 17:46:07 tsi Exp $ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "glheader.h"
|
||||
#include "macros.h"
|
||||
#include "mtypes.h"
|
||||
#include "simple_list.h"
|
||||
#include "enums.h"
|
||||
|
||||
#include "mm.h"
|
||||
#include "gamma_context.h"
|
||||
|
||||
static void gammaSetTexImages( gammaContextPtr gmesa,
|
||||
struct gl_texture_object *tObj )
|
||||
{
|
||||
GLuint height, width, pitch, i, log_pitch;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
|
||||
const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
|
||||
GLint firstLevel, lastLevel, numLevels;
|
||||
GLint log2Width, log2Height;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
t->texelBytes = 2;
|
||||
|
||||
/* Compute which mipmap levels we really want to send to the hardware.
|
||||
* This depends on the base image size, GL_TEXTURE_MIN_LOD,
|
||||
* GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
|
||||
* Yes, this looks overly complicated, but it's all needed.
|
||||
*/
|
||||
if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
|
||||
firstLevel = lastLevel = tObj->BaseLevel;
|
||||
}
|
||||
else {
|
||||
firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
|
||||
firstLevel = MAX2(firstLevel, tObj->BaseLevel);
|
||||
lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
|
||||
lastLevel = MAX2(lastLevel, tObj->BaseLevel);
|
||||
lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
|
||||
lastLevel = MIN2(lastLevel, tObj->MaxLevel);
|
||||
lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
|
||||
}
|
||||
|
||||
/* save these values */
|
||||
t->firstLevel = firstLevel;
|
||||
t->lastLevel = lastLevel;
|
||||
|
||||
numLevels = lastLevel - firstLevel + 1;
|
||||
|
||||
log2Width = tObj->Image[firstLevel]->WidthLog2;
|
||||
log2Height = tObj->Image[firstLevel]->HeightLog2;
|
||||
|
||||
|
||||
/* Figure out the amount of memory required to hold all the mipmap
|
||||
* levels. Choose the smallest pitch to accomodate the largest
|
||||
* mipmap:
|
||||
*/
|
||||
width = tObj->Image[firstLevel]->Width * t->texelBytes;
|
||||
for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
|
||||
log_pitch++;
|
||||
|
||||
/* All images must be loaded at this pitch. Count the number of
|
||||
* lines required:
|
||||
*/
|
||||
for ( height = i = 0 ; i < numLevels ; i++ ) {
|
||||
t->image[i].image = tObj->Image[firstLevel + i];
|
||||
t->image[i].offset = height * pitch;
|
||||
t->image[i].internalFormat = baseImage->Format;
|
||||
height += t->image[i].image->Height;
|
||||
t->TextureBaseAddr[i] = /* ??? */
|
||||
(unsigned long)(t->image[i].offset + t->BufAddr) << 5;
|
||||
|
||||
}
|
||||
|
||||
t->Pitch = pitch;
|
||||
t->totalSize = height*pitch;
|
||||
t->max_level = i-1;
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* | GAMMA_UPLOAD_TEX1*/;
|
||||
|
||||
gammaUploadTexImages( gmesa, t );
|
||||
}
|
||||
|
||||
static void gammaUpdateTexEnv( GLcontext *ctx, GLuint unit )
|
||||
{
|
||||
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
const struct gl_texture_object *tObj = texUnit->_Current;
|
||||
const GLuint format = tObj->Image[tObj->BaseLevel]->Format;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
GLuint tc;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
tc = t->TextureColorMode & ~(TCM_BaseFormatMask | TCM_ApplicationMask);
|
||||
|
||||
switch (format) {
|
||||
case GL_RGB:
|
||||
tc |= TCM_BaseFormat_RGB;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
tc |= TCM_BaseFormat_Lum;
|
||||
break;
|
||||
case GL_ALPHA:
|
||||
tc |= TCM_BaseFormat_Alpha;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
tc |= TCM_BaseFormat_LumAlpha;
|
||||
break;
|
||||
case GL_INTENSITY:
|
||||
tc |= TCM_BaseFormat_Intensity;
|
||||
break;
|
||||
case GL_RGBA:
|
||||
tc |= TCM_BaseFormat_RGBA;
|
||||
break;
|
||||
case GL_COLOR_INDEX:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (texUnit->EnvMode) {
|
||||
case GL_REPLACE:
|
||||
tc |= TCM_Replace;
|
||||
break;
|
||||
case GL_MODULATE:
|
||||
tc |= TCM_Modulate;
|
||||
break;
|
||||
case GL_ADD:
|
||||
/* do nothing ???*/
|
||||
break;
|
||||
case GL_DECAL:
|
||||
tc |= TCM_Decal;
|
||||
break;
|
||||
case GL_BLEND:
|
||||
tc |= TCM_Blend;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown tex env mode");
|
||||
return;
|
||||
}
|
||||
|
||||
t->TextureColorMode = tc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void gammaUpdateTexUnit( GLcontext *ctx, GLuint unit )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT)
|
||||
{
|
||||
struct gl_texture_object *tObj = texUnit->_Current;
|
||||
gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
|
||||
|
||||
/* Upload teximages (not pipelined)
|
||||
*/
|
||||
if (t->dirty_images) {
|
||||
gammaSetTexImages( gmesa, tObj );
|
||||
if (!t->MemBlock) {
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (tObj->Image[tObj->BaseLevel]->Border > 0) {
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Update state if this is a different texture object to last
|
||||
* time.
|
||||
*/
|
||||
if (gmesa->CurrentTexObj[unit] != t) {
|
||||
gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* << unit */;
|
||||
gmesa->CurrentTexObj[unit] = t;
|
||||
gammaUpdateTexLRU( gmesa, t ); /* done too often */
|
||||
}
|
||||
|
||||
/* Update texture environment if texture object image format or
|
||||
* texture environment state has changed.
|
||||
*/
|
||||
if (tObj->Image[tObj->BaseLevel]->Format != gmesa->TexEnvImageFmt[unit]) {
|
||||
gmesa->TexEnvImageFmt[unit] = tObj->Image[tObj->BaseLevel]->Format;
|
||||
gammaUpdateTexEnv( ctx, unit );
|
||||
}
|
||||
}
|
||||
else if (texUnit->_ReallyEnabled) {
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
|
||||
}
|
||||
else /*if (gmesa->CurrentTexObj[unit])*/ {
|
||||
gmesa->CurrentTexObj[unit] = 0;
|
||||
gmesa->TexEnvImageFmt[unit] = 0;
|
||||
gmesa->dirty &= ~(GAMMA_UPLOAD_TEX0<<unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaUpdateTextureState( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_FALSE );
|
||||
gammaUpdateTexUnit( ctx, 0 );
|
||||
#if 0
|
||||
gammaUpdateTexUnit( ctx, 1 );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,653 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_tris.h"
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "macros.h"
|
||||
#include "colormac.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Build hardware rasterization functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define GAMMA_RAST_ALPHA_BIT 0x01
|
||||
#define GAMMA_RAST_TEX_BIT 0x02
|
||||
#define GAMMA_RAST_FLAT_BIT 0x04
|
||||
|
||||
static gamma_point_func gamma_point_tab[0x8];
|
||||
static gamma_line_func gamma_line_tab[0x8];
|
||||
static gamma_tri_func gamma_tri_tab[0x8];
|
||||
static gamma_quad_func gamma_quad_tab[0x8];
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT)
|
||||
#define TAG(x) x##_alpha
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_TEX_BIT)
|
||||
#define TAG(x) x##_tex
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT)
|
||||
#define TAG(x) x##_alpha_tex
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_alpha_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_tex_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
|
||||
#define TAG(x) x##_alpha_tex_flat
|
||||
#include "gamma_tritmp.h"
|
||||
|
||||
|
||||
static void init_rast_tab( void )
|
||||
{
|
||||
gamma_init();
|
||||
gamma_init_alpha();
|
||||
gamma_init_tex();
|
||||
gamma_init_alpha_tex();
|
||||
gamma_init_flat();
|
||||
gamma_init_alpha_flat();
|
||||
gamma_init_tex_flat();
|
||||
gamma_init_alpha_tex_flat();
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Rasterization fallback helpers *
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
/* This code is hit only when a mix of accelerated and unaccelerated
|
||||
* primitives are being drawn, and only for the unaccelerated
|
||||
* primitives.
|
||||
*/
|
||||
static void
|
||||
gamma_fallback_quad( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2,
|
||||
const gammaVertex *v3 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[4];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
gamma_translate_vertex( ctx, v1, &v[1] );
|
||||
gamma_translate_vertex( ctx, v2, &v[2] );
|
||||
gamma_translate_vertex( ctx, v3, &v[3] );
|
||||
_swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
|
||||
}
|
||||
|
||||
static void
|
||||
gamma_fallback_tri( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[3];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
gamma_translate_vertex( ctx, v1, &v[1] );
|
||||
gamma_translate_vertex( ctx, v2, &v[2] );
|
||||
_swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
|
||||
}
|
||||
|
||||
static void
|
||||
gamma_fallback_line( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[2];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
gamma_translate_vertex( ctx, v1, &v[1] );
|
||||
_swrast_Line( ctx, &v[0], &v[1] );
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static void
|
||||
gamma_fallback_point( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0 )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
SWvertex v[1];
|
||||
gamma_translate_vertex( ctx, v0, &v[0] );
|
||||
_swrast_Point( ctx, &v[0] );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Choose rasterization functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define _GAMMA_NEW_RASTER_STATE (_NEW_FOG | \
|
||||
_NEW_TEXTURE | \
|
||||
_DD_NEW_TRI_SMOOTH | \
|
||||
_DD_NEW_LINE_SMOOTH | \
|
||||
_DD_NEW_POINT_SMOOTH | \
|
||||
_DD_NEW_TRI_STIPPLE | \
|
||||
_DD_NEW_LINE_STIPPLE)
|
||||
|
||||
#define LINE_FALLBACK (0)
|
||||
#define TRI_FALLBACK (0)
|
||||
|
||||
static void gammaChooseRasterState(GLcontext *ctx)
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint ind = 0;
|
||||
|
||||
if ( ctx->Line.SmoothFlag ||
|
||||
ctx->Polygon.SmoothFlag ||
|
||||
ctx->Point.SmoothFlag )
|
||||
gmesa->Begin |= B_AntiAliasEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_AntiAliasEnable;
|
||||
|
||||
if ( ctx->Texture.Unit[0]._ReallyEnabled ) {
|
||||
ind |= GAMMA_RAST_TEX_BIT;
|
||||
gmesa->Begin |= B_TextureEnable;
|
||||
} else
|
||||
gmesa->Begin &= ~B_TextureEnable;
|
||||
|
||||
if (flags & DD_LINE_STIPPLE)
|
||||
gmesa->Begin |= B_LineStippleEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_LineStippleEnable;
|
||||
|
||||
if (flags & DD_TRI_STIPPLE)
|
||||
gmesa->Begin |= B_AreaStippleEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_AreaStippleEnable;
|
||||
|
||||
if (ctx->Fog.Enabled)
|
||||
gmesa->Begin |= B_FogEnable;
|
||||
else
|
||||
gmesa->Begin &= ~B_FogEnable;
|
||||
|
||||
if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
|
||||
ind |= GAMMA_RAST_ALPHA_BIT;
|
||||
|
||||
if ( flags & DD_FLATSHADE )
|
||||
ind |= GAMMA_RAST_FLAT_BIT;
|
||||
|
||||
gmesa->draw_line = gamma_line_tab[ind];
|
||||
gmesa->draw_tri = gamma_tri_tab[ind];
|
||||
gmesa->draw_quad = gamma_quad_tab[ind];
|
||||
gmesa->draw_point = gamma_point_tab[ind];
|
||||
|
||||
/* Hook in fallbacks for specific primitives. CURRENTLY DISABLED
|
||||
*/
|
||||
if (flags & LINE_FALLBACK)
|
||||
gmesa->draw_line = gamma_fallback_line;
|
||||
|
||||
if (flags & TRI_FALLBACK) {
|
||||
gmesa->draw_tri = gamma_fallback_tri;
|
||||
gmesa->draw_quad = gamma_fallback_quad;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Macros for t_dd_tritmp.h to draw basic primitives *
|
||||
***********************************************************************/
|
||||
|
||||
#define TRI( a, b, c ) \
|
||||
do { \
|
||||
gmesa->draw_tri( gmesa, a, b, c ); \
|
||||
} while (0)
|
||||
|
||||
#define QUAD( a, b, c, d ) \
|
||||
do { \
|
||||
gmesa->draw_quad( gmesa, a, b, c, d ); \
|
||||
} while (0)
|
||||
|
||||
#define LINE( v0, v1 ) \
|
||||
do { \
|
||||
gmesa->draw_line( gmesa, v0, v1 ); \
|
||||
} while (0)
|
||||
|
||||
#define POINT( v0 ) \
|
||||
do { \
|
||||
gmesa->draw_point( gmesa, v0 ); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Build render functions from dd templates *
|
||||
***********************************************************************/
|
||||
|
||||
#define GAMMA_OFFSET_BIT 0x01
|
||||
#define GAMMA_TWOSIDE_BIT 0x02
|
||||
#define GAMMA_UNFILLED_BIT 0x04
|
||||
#define GAMMA_FALLBACK_BIT 0x08
|
||||
#define GAMMA_MAX_TRIFUNC 0x10
|
||||
|
||||
|
||||
static struct {
|
||||
points_func points;
|
||||
line_func line;
|
||||
triangle_func triangle;
|
||||
quad_func quad;
|
||||
} rast_tab[GAMMA_MAX_TRIFUNC];
|
||||
|
||||
|
||||
#define DO_FALLBACK (IND & GAMMA_FALLBACK_BIT)
|
||||
#define DO_OFFSET 0 /* (IND & GAMMA_OFFSET_BIT) */
|
||||
#define DO_UNFILLED 0 /* (IND & GAMMA_UNFILLED_BIT) */
|
||||
#define DO_TWOSIDE (IND & GAMMA_TWOSIDE_BIT)
|
||||
#define DO_FLAT 0
|
||||
#define DO_TRI 1
|
||||
#define DO_QUAD 1
|
||||
#define DO_LINE 1
|
||||
#define DO_POINTS 1
|
||||
#define DO_FULL_QUAD 1
|
||||
|
||||
#define HAVE_RGBA 1
|
||||
#define HAVE_SPEC 0
|
||||
#define HAVE_BACK_COLORS 0
|
||||
#define HAVE_HW_FLATSHADE 1
|
||||
#define VERTEX gammaVertex
|
||||
#define TAB rast_tab
|
||||
|
||||
#define DEPTH_SCALE 1.0
|
||||
#define UNFILLED_TRI unfilled_tri
|
||||
#define UNFILLED_QUAD unfilled_quad
|
||||
#define VERT_X(_v) _v->v.x
|
||||
#define VERT_Y(_v) _v->v.y
|
||||
#define VERT_Z(_v) _v->v.z
|
||||
#define AREA_IS_CCW( a ) (a > 0)
|
||||
#define GET_VERTEX(e) (gmesa->verts + (e<<gmesa->vertex_stride_shift))
|
||||
|
||||
#define VERT_SET_RGBA( v, c ) COPY_4V( v->ub4[4], c)
|
||||
#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
|
||||
#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
|
||||
#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
|
||||
|
||||
#define LOCAL_VARS(n) \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
GLuint color[n]; \
|
||||
(void) color;
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Helpers for rendering unfilled primitives *
|
||||
***********************************************************************/
|
||||
|
||||
static const GLuint hw_prim[GL_POLYGON+1] = {
|
||||
B_PrimType_Points,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_Lines,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles,
|
||||
B_PrimType_Triangles
|
||||
};
|
||||
|
||||
static void gammaResetLineStipple( GLcontext *ctx );
|
||||
static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim );
|
||||
static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim );
|
||||
|
||||
#define RASTERIZE(x) if (gmesa->hw_primitive != hw_prim[x]) \
|
||||
gammaRasterPrimitive( ctx, hw_prim[x] )
|
||||
#define RENDER_PRIMITIVE gmesa->render_primitive
|
||||
#define TAG(x) x
|
||||
#define IND GAMMA_FALLBACK_BIT
|
||||
#include "tnl_dd/t_dd_unfilled.h"
|
||||
#undef IND
|
||||
|
||||
/***********************************************************************
|
||||
* Generate GL render functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define IND (0)
|
||||
#define TAG(x) x
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_OFFSET_BIT)
|
||||
#define TAG(x) x##_offset
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT)
|
||||
#define TAG(x) x##_twoside
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT)
|
||||
#define TAG(x) x##_twoside_offset
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_offset_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT|GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_twoside_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
|
||||
#define TAG(x) x##_twoside_offset_unfilled
|
||||
#include "tnl_dd/t_dd_tritmp.h"
|
||||
|
||||
|
||||
|
||||
static void init_render_tab( void )
|
||||
{
|
||||
init();
|
||||
init_offset();
|
||||
init_twoside();
|
||||
init_twoside_offset();
|
||||
init_unfilled();
|
||||
init_offset_unfilled();
|
||||
init_twoside_unfilled();
|
||||
init_twoside_offset_unfilled();
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render unclipped begin/end objects */
|
||||
/**********************************************************************/
|
||||
|
||||
#define VERT(x) (gammaVertex *)(gammaverts + (x << shift))
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
for ( ; start < count ; start++) \
|
||||
gmesa->draw_point( gmesa, VERT(start) )
|
||||
#define RENDER_LINE( v0, v1 ) \
|
||||
gmesa->draw_line( gmesa, VERT(v0), VERT(v1) )
|
||||
#define RENDER_TRI( v0, v1, v2 ) \
|
||||
gmesa->draw_tri( gmesa, VERT(v0), VERT(v1), VERT(v2) )
|
||||
#define RENDER_QUAD( v0, v1, v2, v3 ) \
|
||||
gmesa->draw_quad( gmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
|
||||
#define INIT(x) gammaRenderPrimitive( ctx, x );
|
||||
#undef LOCAL_VARS
|
||||
#define LOCAL_VARS \
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
|
||||
const GLuint shift = gmesa->vertex_stride_shift; \
|
||||
const char *gammaverts = (char *)gmesa->verts; \
|
||||
const GLboolean stipple = ctx->Line.StippleFlag; \
|
||||
(void) stipple;
|
||||
#define RESET_STIPPLE if ( stipple ) gammaResetLineStipple( ctx );
|
||||
#define RESET_OCCLUSION
|
||||
#define PRESERVE_VB_DEFS
|
||||
#define ELT(x) (x)
|
||||
#define TAG(x) gamma_##x##_verts
|
||||
#include "tnl/t_vb_rendertmp.h"
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Render clipped primitives */
|
||||
/**********************************************************************/
|
||||
|
||||
static void gammaRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
|
||||
GLuint n )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint prim = gmesa->render_primitive;
|
||||
|
||||
/* Render the new vertices as an unclipped polygon.
|
||||
*/
|
||||
{
|
||||
GLuint *tmp = VB->Elts;
|
||||
VB->Elts = (GLuint *)elts;
|
||||
tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
|
||||
VB->Elts = tmp;
|
||||
}
|
||||
|
||||
/* Restore the render primitive
|
||||
*/
|
||||
if (prim != GL_POLYGON)
|
||||
tnl->Driver.Render.PrimitiveNotify( ctx, prim );
|
||||
}
|
||||
|
||||
static void gammaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
tnl->Driver.Render.Line( ctx, ii, jj );
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Choose render functions */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
#define _GAMMA_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \
|
||||
_DD_NEW_TRI_LIGHT_TWOSIDE | \
|
||||
_DD_NEW_TRI_OFFSET)
|
||||
|
||||
#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
|
||||
|
||||
static void gammaChooseRenderState(GLcontext *ctx)
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint flags = ctx->_TriangleCaps;
|
||||
GLuint index = 0;
|
||||
|
||||
if (flags & ANY_RASTER_FLAGS) {
|
||||
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= GAMMA_TWOSIDE_BIT;
|
||||
if (flags & DD_TRI_OFFSET) index |= GAMMA_OFFSET_BIT;
|
||||
if (flags & DD_TRI_UNFILLED) index |= GAMMA_UNFILLED_BIT;
|
||||
}
|
||||
|
||||
if (gmesa->RenderIndex != index) {
|
||||
gmesa->RenderIndex = index;
|
||||
|
||||
tnl->Driver.Render.Points = rast_tab[index].points;
|
||||
tnl->Driver.Render.Line = rast_tab[index].line;
|
||||
tnl->Driver.Render.Triangle = rast_tab[index].triangle;
|
||||
tnl->Driver.Render.Quad = rast_tab[index].quad;
|
||||
|
||||
if (gmesa->RenderIndex == 0)
|
||||
tnl->Driver.Render.PrimTabVerts = gamma_render_tab_verts;
|
||||
else
|
||||
tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
|
||||
tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
|
||||
tnl->Driver.Render.ClippedLine = gammaRenderClippedLine;
|
||||
tnl->Driver.Render.ClippedPolygon = gammaRenderClippedPoly;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* High level hooks for t_vb_render.c */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Determine the rasterized primitive when not drawing unfilled
|
||||
* polygons.
|
||||
*
|
||||
* Used only for the default render stage which always decomposes
|
||||
* primitives to trianges/lines/points. For the accelerated stage,
|
||||
* which renders strips as strips, the equivalent calculations are
|
||||
* performed in gammarender.c.
|
||||
*/
|
||||
|
||||
static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
if (gmesa->hw_primitive != hwprim)
|
||||
gmesa->hw_primitive = hwprim;
|
||||
}
|
||||
|
||||
static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
gmesa->render_primitive = prim;
|
||||
}
|
||||
|
||||
static void gammaRunPipeline( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
if ( gmesa->new_state )
|
||||
gammaDDUpdateHWState( ctx );
|
||||
|
||||
if (gmesa->new_gl_state) {
|
||||
if (gmesa->new_gl_state & _NEW_TEXTURE)
|
||||
gammaUpdateTextureState( ctx );
|
||||
|
||||
if (!gmesa->Fallback) {
|
||||
if (gmesa->new_gl_state & _GAMMA_NEW_VERTEX)
|
||||
gammaChooseVertexState( ctx );
|
||||
|
||||
if (gmesa->new_gl_state & _GAMMA_NEW_RASTER_STATE)
|
||||
gammaChooseRasterState( ctx );
|
||||
|
||||
if (gmesa->new_gl_state & _GAMMA_NEW_RENDERSTATE)
|
||||
gammaChooseRenderState( ctx );
|
||||
}
|
||||
|
||||
gmesa->new_gl_state = 0;
|
||||
}
|
||||
|
||||
_tnl_run_pipeline( ctx );
|
||||
}
|
||||
|
||||
static void gammaRenderStart( GLcontext *ctx )
|
||||
{
|
||||
/* Check for projective texturing. Make sure all texcoord
|
||||
* pointers point to something. (fix in mesa?)
|
||||
*/
|
||||
gammaCheckTexSizes( ctx );
|
||||
}
|
||||
|
||||
static void gammaRenderFinish( GLcontext *ctx )
|
||||
{
|
||||
if (0)
|
||||
_swrast_flush( ctx ); /* never needed */
|
||||
}
|
||||
|
||||
static void gammaResetLineStipple( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
|
||||
/* Reset the hardware stipple counter.
|
||||
*/
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, UpdateLineStippleCounters, 0);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Transition to/from hardware rasterization. */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode )
|
||||
{
|
||||
GLcontext *ctx = gmesa->glCtx;
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint oldfallback = gmesa->Fallback;
|
||||
|
||||
if (mode) {
|
||||
gmesa->Fallback |= bit;
|
||||
if (oldfallback == 0) {
|
||||
_swsetup_Wakeup( ctx );
|
||||
_tnl_need_projected_coords( ctx, GL_TRUE );
|
||||
gmesa->RenderIndex = ~0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gmesa->Fallback &= ~bit;
|
||||
if (oldfallback == bit) {
|
||||
_swrast_flush( ctx );
|
||||
tnl->Driver.Render.Start = gammaRenderStart;
|
||||
tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
|
||||
tnl->Driver.Render.Finish = gammaRenderFinish;
|
||||
tnl->Driver.Render.BuildVertices = gammaBuildVertices;
|
||||
tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
|
||||
gmesa->new_gl_state |= (_GAMMA_NEW_RENDERSTATE|
|
||||
_GAMMA_NEW_RASTER_STATE|
|
||||
_GAMMA_NEW_VERTEX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Initialization. */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
void gammaDDInitTriFuncs( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
static int firsttime = 1;
|
||||
|
||||
if (firsttime) {
|
||||
init_rast_tab();
|
||||
init_render_tab();
|
||||
firsttime = 0;
|
||||
}
|
||||
|
||||
gmesa->RenderIndex = ~0;
|
||||
|
||||
tnl->Driver.RunPipeline = gammaRunPipeline;
|
||||
tnl->Driver.Render.Start = gammaRenderStart;
|
||||
tnl->Driver.Render.Finish = gammaRenderFinish;
|
||||
tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
|
||||
tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
|
||||
tnl->Driver.Render.BuildVertices = gammaBuildVertices;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#ifndef _GAMMA_TRIS_H
|
||||
#define _GAMMA_TRIS_H
|
||||
|
||||
extern void gammaDDTrifuncInit(void);
|
||||
extern void gammaDDChooseTriRenderState(GLcontext *);
|
||||
|
||||
|
||||
|
||||
#endif /* !(_GAMMA_TRIS_H) */
|
||||
@@ -0,0 +1,495 @@
|
||||
static void TAG(gamma_point)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0 )
|
||||
{
|
||||
CARD32 vColor;
|
||||
CARD32 vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Points;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_line)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1 )
|
||||
{
|
||||
CARD32 vColor;
|
||||
CARD32 vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Lines;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#else
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v1->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v1->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_triangle)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2 )
|
||||
{
|
||||
CARD32 vColor;
|
||||
CARD32 vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Triangles;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#else
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v2->v.color.alpha << 24) |
|
||||
(v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v1->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v1->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v2->v.color.alpha << 24) |
|
||||
(v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v2->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v2->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_quad)( gammaContextPtr gmesa,
|
||||
const gammaVertex *v0,
|
||||
const gammaVertex *v1,
|
||||
const gammaVertex *v2,
|
||||
const gammaVertex *v3 )
|
||||
{
|
||||
CARD32 vColor;
|
||||
CARD32 vBegin;
|
||||
|
||||
vBegin = gmesa->Begin | B_PrimType_Quads;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, Begin, vBegin);
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v0->v.color.alpha << 24) |
|
||||
(v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v0->v.color.blue << 16) |
|
||||
(v0->v.color.green << 8) |
|
||||
(v0->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#else
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v3->v.color.alpha << 24) |
|
||||
(v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v0->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v0->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v0->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v0->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v0->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v0->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v1->v.color.alpha << 24) |
|
||||
(v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v1->v.color.blue << 16) |
|
||||
(v1->v.color.green << 8) |
|
||||
(v1->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v1->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v1->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v1->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v1->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v1->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v1->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v2->v.color.alpha << 24) |
|
||||
(v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v2->v.color.blue << 16) |
|
||||
(v2->v.color.green << 8) |
|
||||
(v2->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v2->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v2->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v2->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v2->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v2->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v2->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
#if (IND & GAMMA_RAST_ALPHA_BIT)
|
||||
vColor = (v3->v.color.alpha << 24) |
|
||||
(v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor4, vColor);
|
||||
#else
|
||||
vColor = (v3->v.color.blue << 16) |
|
||||
(v3->v.color.green << 8) |
|
||||
(v3->v.color.red << 0);
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, PackedColor3, vColor);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & GAMMA_RAST_TEX_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 6);
|
||||
WRITEF(gmesa->buf, Tt2, v3->v.u0);
|
||||
WRITEF(gmesa->buf, Ts2, v3->v.v0);
|
||||
WRITEF(gmesa->buf, Vw, v3->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v3->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v3->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v3->v.x);
|
||||
#else
|
||||
CHECK_DMA_BUFFER(gmesa, 4);
|
||||
WRITEF(gmesa->buf, Vw, v3->v.w);
|
||||
WRITEF(gmesa->buf, Vz, v3->v.z);
|
||||
WRITEF(gmesa->buf, Vy, v3->v.y);
|
||||
WRITEF(gmesa->buf, Vx4, v3->v.x);
|
||||
#endif
|
||||
|
||||
#if !(IND & GAMMA_RAST_FLAT_BIT)
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, FlushSpan, 0);
|
||||
#endif
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 1);
|
||||
WRITE(gmesa->buf, End, 0);
|
||||
}
|
||||
|
||||
static void TAG(gamma_init)(void)
|
||||
{
|
||||
gamma_point_tab[IND] = TAG(gamma_point);
|
||||
gamma_line_tab[IND] = TAG(gamma_line);
|
||||
gamma_tri_tab[IND] = TAG(gamma_triangle);
|
||||
gamma_quad_tab[IND] = TAG(gamma_quad);
|
||||
}
|
||||
|
||||
#undef IND
|
||||
#undef TAG
|
||||
@@ -0,0 +1,380 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_vb.c,v 1.4 2003/03/26 20:43:48 tsi Exp $ */
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#include "glheader.h"
|
||||
#include "mtypes.h"
|
||||
#include "imports.h"
|
||||
#include "macros.h"
|
||||
#include "colormac.h"
|
||||
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/t_context.h"
|
||||
#include "tnl/tnl.h"
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "gamma_tris.h"
|
||||
|
||||
|
||||
#define GAMMA_TEX0_BIT 0x1
|
||||
#define GAMMA_RGBA_BIT 0x2
|
||||
#define GAMMA_XYZW_BIT 0x4
|
||||
#define GAMMA_PTEX_BIT 0x8
|
||||
#define GAMMA_FOG_BIT 0x10
|
||||
#define GAMMA_SPEC_BIT 0x20
|
||||
#define GAMMA_MAX_SETUP 0x40
|
||||
|
||||
static struct {
|
||||
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
|
||||
interp_func interp;
|
||||
copy_pv_func copy_pv;
|
||||
GLboolean (*check_tex_sizes)( GLcontext *ctx );
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_stride_shift;
|
||||
GLuint vertex_format;
|
||||
} setup_tab[GAMMA_MAX_SETUP];
|
||||
|
||||
#define TINY_VERTEX_FORMAT 1
|
||||
#define NOTEX_VERTEX_FORMAT 2
|
||||
#define TEX0_VERTEX_FORMAT 3
|
||||
#define TEX1_VERTEX_FORMAT 0
|
||||
#define PROJ_TEX1_VERTEX_FORMAT 0
|
||||
#define TEX2_VERTEX_FORMAT 0
|
||||
#define TEX3_VERTEX_FORMAT 0
|
||||
#define PROJ_TEX3_VERTEX_FORMAT 0
|
||||
|
||||
#define DO_XYZW (IND & GAMMA_XYZW_BIT)
|
||||
#define DO_RGBA (IND & GAMMA_RGBA_BIT)
|
||||
#define DO_SPEC (IND & GAMMA_SPEC_BIT)
|
||||
#define DO_FOG (IND & GAMMA_FOG_BIT)
|
||||
#define DO_TEX0 (IND & GAMMA_TEX0_BIT)
|
||||
#define DO_TEX1 0
|
||||
#define DO_TEX2 0
|
||||
#define DO_TEX3 0
|
||||
#define DO_PTEX (IND & GAMMA_PTEX_BIT)
|
||||
|
||||
#define VERTEX gammaVertex
|
||||
#define VERTEX_COLOR gamma_color_t
|
||||
#define GET_VIEWPORT_MAT() 0
|
||||
#define GET_TEXSOURCE(n) n
|
||||
#define GET_VERTEX_FORMAT() GAMMA_CONTEXT(ctx)->vertex_format
|
||||
#define GET_VERTEX_STORE() GAMMA_CONTEXT(ctx)->verts
|
||||
#define GET_VERTEX_STRIDE_SHIFT() GAMMA_CONTEXT(ctx)->vertex_stride_shift
|
||||
#define INVALIDATE_STORED_VERTICES()
|
||||
#define GET_UBYTE_COLOR_STORE() &GAMMA_CONTEXT(ctx)->UbyteColor
|
||||
#define GET_UBYTE_SPEC_COLOR_STORE() &GAMMA_CONTEXT(ctx)->UbyteSecondaryColor
|
||||
|
||||
#define HAVE_HW_VIEWPORT 1
|
||||
#define HAVE_HW_DIVIDE 1
|
||||
#define HAVE_RGBA_COLOR 0 /* we're BGRA */
|
||||
#define HAVE_TINY_VERTICES 1
|
||||
#define HAVE_NOTEX_VERTICES 1
|
||||
#define HAVE_TEX0_VERTICES 1
|
||||
#define HAVE_TEX1_VERTICES 0
|
||||
#define HAVE_TEX2_VERTICES 0
|
||||
#define HAVE_TEX3_VERTICES 0
|
||||
#define HAVE_PTEX_VERTICES 1
|
||||
|
||||
#define PTEX_FALLBACK() /* never needed */
|
||||
|
||||
#define IMPORT_QUALIFIER
|
||||
#define IMPORT_FLOAT_COLORS gamma_import_float_colors
|
||||
#define IMPORT_FLOAT_SPEC_COLORS gamma_import_float_spec_colors
|
||||
|
||||
#define INTERP_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].interp
|
||||
#define COPY_PV_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].copy_pv
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Generate pv-copying and translation functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define TAG(x) gamma_##x
|
||||
#include "tnl_dd/t_dd_vb.c"
|
||||
|
||||
/***********************************************************************
|
||||
* Generate vertex emit and interp functions *
|
||||
***********************************************************************/
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT)
|
||||
#define TAG(x) x##_wg
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_wgs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT|GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgpt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT|\
|
||||
GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgspt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT)
|
||||
#define TAG(x) x##_wgf
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_wgfs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT|\
|
||||
GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfpt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\
|
||||
GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_wgfst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\
|
||||
GAMMA_TEX0_BIT|GAMMA_PTEX_BIT)
|
||||
#define TAG(x) x##_wgfspt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_t0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_FOG_BIT)
|
||||
#define TAG(x) x##_f
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_ft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT)
|
||||
#define TAG(x) x##_g
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_gs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gt0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT)
|
||||
#define TAG(x) x##_gf
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT)
|
||||
#define TAG(x) x##_gfs
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gft0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
|
||||
#define TAG(x) x##_gfst0
|
||||
#include "tnl_dd/t_dd_vbtmp.h"
|
||||
|
||||
static void init_setup_tab( void )
|
||||
{
|
||||
init_wg();
|
||||
init_wgs();
|
||||
init_wgt0();
|
||||
init_wgpt0();
|
||||
init_wgst0();
|
||||
init_wgspt0();
|
||||
init_wgf();
|
||||
init_wgfs();
|
||||
init_wgft0();
|
||||
init_wgfpt0();
|
||||
init_wgfst0();
|
||||
init_wgfspt0();
|
||||
init_t0();
|
||||
init_f();
|
||||
init_ft0();
|
||||
init_g();
|
||||
init_gs();
|
||||
init_gt0();
|
||||
init_gst0();
|
||||
init_gf();
|
||||
init_gfs();
|
||||
init_gft0();
|
||||
init_gfst0();
|
||||
}
|
||||
|
||||
void gammaCheckTexSizes( GLcontext *ctx )
|
||||
{
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
|
||||
if (!setup_tab[gmesa->SetupIndex].check_tex_sizes(ctx)) {
|
||||
/* Invalidate stored verts
|
||||
*/
|
||||
gmesa->SetupNewInputs = ~0;
|
||||
gmesa->SetupIndex |= GAMMA_PTEX_BIT;
|
||||
|
||||
if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
|
||||
tnl->Driver.Render.Interp = setup_tab[gmesa->SetupIndex].interp;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[gmesa->SetupIndex].copy_pv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gammaBuildVertices( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint newinputs )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
GLubyte *v = ((GLubyte *)gmesa->verts + (start<<gmesa->vertex_stride_shift));
|
||||
GLuint stride = 1<<gmesa->vertex_stride_shift;
|
||||
|
||||
newinputs |= gmesa->SetupNewInputs;
|
||||
gmesa->SetupNewInputs = 0;
|
||||
|
||||
if (!newinputs)
|
||||
return;
|
||||
|
||||
if (newinputs & VERT_BIT_CLIP) {
|
||||
setup_tab[gmesa->SetupIndex].emit( ctx, start, count, v, stride );
|
||||
} else {
|
||||
GLuint ind = 0;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR0)
|
||||
ind |= GAMMA_RGBA_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR1)
|
||||
ind |= GAMMA_SPEC_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_TEX0)
|
||||
ind |= GAMMA_TEX0_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_FOG)
|
||||
ind |= GAMMA_FOG_BIT;
|
||||
|
||||
if (gmesa->SetupIndex & GAMMA_PTEX_BIT)
|
||||
ind = ~0;
|
||||
|
||||
ind &= gmesa->SetupIndex;
|
||||
|
||||
if (ind) {
|
||||
setup_tab[ind].emit( ctx, start, count, v, stride );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void gammaChooseVertexState( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
GLuint ind = GAMMA_XYZW_BIT|GAMMA_RGBA_BIT;
|
||||
|
||||
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
|
||||
ind |= GAMMA_SPEC_BIT;
|
||||
|
||||
if (ctx->Fog.Enabled)
|
||||
ind |= GAMMA_FOG_BIT;
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled) {
|
||||
_tnl_need_projected_coords( ctx, GL_FALSE );
|
||||
ind |= GAMMA_TEX0_BIT;
|
||||
} else
|
||||
_tnl_need_projected_coords( ctx, GL_FALSE );
|
||||
|
||||
gmesa->SetupIndex = ind;
|
||||
|
||||
if (setup_tab[ind].vertex_format != gmesa->vertex_format) {
|
||||
gmesa->vertex_format = setup_tab[ind].vertex_format;
|
||||
gmesa->vertex_size = setup_tab[ind].vertex_size;
|
||||
gmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
|
||||
}
|
||||
|
||||
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
|
||||
tnl->Driver.Render.Interp = gamma_interp_extras;
|
||||
tnl->Driver.Render.CopyPV = gamma_copy_pv_extras;
|
||||
} else {
|
||||
tnl->Driver.Render.Interp = setup_tab[ind].interp;
|
||||
tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaInitVB( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
|
||||
|
||||
gmesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32);
|
||||
|
||||
{
|
||||
static int firsttime = 1;
|
||||
if (firsttime) {
|
||||
init_setup_tab();
|
||||
firsttime = 0;
|
||||
gmesa->vertex_stride_shift = 6; /* FIXME - only one vertex setup */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void gammaFreeVB( GLcontext *ctx )
|
||||
{
|
||||
gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
|
||||
if (gmesa->verts) {
|
||||
ALIGN_FREE(gmesa->verts);
|
||||
gmesa->verts = 0;
|
||||
}
|
||||
|
||||
if (gmesa->UbyteSecondaryColor.Ptr) {
|
||||
ALIGN_FREE(gmesa->UbyteSecondaryColor.Ptr);
|
||||
gmesa->UbyteSecondaryColor.Ptr = 0;
|
||||
}
|
||||
|
||||
if (gmesa->UbyteColor.Ptr) {
|
||||
ALIGN_FREE(gmesa->UbyteColor.Ptr);
|
||||
gmesa->UbyteColor.Ptr = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
* Keith Whitwell, <keith@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver.
|
||||
*/
|
||||
|
||||
#ifndef GAMMAVB_INC
|
||||
#define GAMMAVB_INC
|
||||
|
||||
#include "mtypes.h"
|
||||
#include "swrast/swrast.h"
|
||||
|
||||
#define _GAMMA_NEW_VERTEX (_NEW_TEXTURE | \
|
||||
_DD_NEW_TRI_UNFILLED | \
|
||||
_DD_NEW_TRI_LIGHT_TWOSIDE)
|
||||
|
||||
|
||||
extern void gammaChooseVertexState( GLcontext *ctx );
|
||||
extern void gammaCheckTexSizes( GLcontext *ctx );
|
||||
extern void gammaBuildVertices( GLcontext *ctx,
|
||||
GLuint start,
|
||||
GLuint count,
|
||||
GLuint newinputs );
|
||||
|
||||
|
||||
extern void gamma_import_float_colors( GLcontext *ctx );
|
||||
extern void gamma_import_float_spec_colors( GLcontext *ctx );
|
||||
|
||||
extern void gamma_translate_vertex( GLcontext *ctx,
|
||||
const gammaVertex *src,
|
||||
SWvertex *dst );
|
||||
|
||||
extern void gammaInitVB( GLcontext *ctx );
|
||||
extern void gammaFreeVB( GLcontext *ctx );
|
||||
|
||||
extern void gamma_print_vertex( GLcontext *ctx, const gammaVertex *v );
|
||||
extern void gammaPrintSetupFlags(char *msg, GLuint flags );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,296 @@
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c,v 1.14 2002/10/30 12:51:30 alanh Exp $ */
|
||||
/*
|
||||
* Copyright 2001 by Alan Hourihane.
|
||||
*
|
||||
* 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@tungstengraphics.com>
|
||||
*
|
||||
* 3DLabs Gamma driver
|
||||
*/
|
||||
|
||||
#include "gamma_context.h"
|
||||
#include "gamma_vb.h"
|
||||
#include "context.h"
|
||||
#include "matrix.h"
|
||||
#include "glint_dri.h"
|
||||
|
||||
#include "swrast/swrast.h"
|
||||
#include "swrast_setup/swrast_setup.h"
|
||||
#include "tnl/tnl.h"
|
||||
#include "array_cache/acache.h"
|
||||
|
||||
static GLboolean
|
||||
gammaInitDriver(__DRIscreenPrivate *sPriv)
|
||||
{
|
||||
sPriv->private = (void *) gammaCreateScreen( sPriv );
|
||||
|
||||
if (!sPriv->private) {
|
||||
gammaDestroyScreen( sPriv );
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gammaDestroyContext(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
gammaContextPtr gmesa = (gammaContextPtr)driContextPriv->driverPrivate;
|
||||
|
||||
if (gmesa) {
|
||||
_swsetup_DestroyContext( gmesa->glCtx );
|
||||
_tnl_DestroyContext( gmesa->glCtx );
|
||||
_ac_DestroyContext( gmesa->glCtx );
|
||||
_swrast_DestroyContext( gmesa->glCtx );
|
||||
|
||||
gammaFreeVB( gmesa->glCtx );
|
||||
|
||||
/* free the Mesa context */
|
||||
gmesa->glCtx->DriverCtx = NULL;
|
||||
_mesa_destroy_context(gmesa->glCtx);
|
||||
|
||||
Xfree(gmesa);
|
||||
driContextPriv->driverPrivate = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
gammaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
const __GLcontextModes *mesaVis,
|
||||
GLboolean isPixmap )
|
||||
{
|
||||
if (isPixmap) {
|
||||
return GL_FALSE; /* not implemented */
|
||||
}
|
||||
else {
|
||||
driDrawPriv->driverPrivate = (void *)
|
||||
_mesa_create_framebuffer(mesaVis,
|
||||
GL_FALSE, /* software depth buffer? */
|
||||
mesaVis->stencilBits > 0,
|
||||
mesaVis->accumRedBits > 0,
|
||||
mesaVis->alphaBits > 0
|
||||
);
|
||||
return (driDrawPriv->driverPrivate != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gammaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
|
||||
{
|
||||
_mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gammaSwapBuffers( __DRIdrawablePrivate *dPriv )
|
||||
{
|
||||
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
|
||||
gammaContextPtr gmesa;
|
||||
__DRIscreenPrivate *driScrnPriv;
|
||||
GLcontext *ctx;
|
||||
|
||||
gmesa = (gammaContextPtr) dPriv->driContextPriv->driverPrivate;
|
||||
ctx = gmesa->glCtx;
|
||||
driScrnPriv = gmesa->driScreen;
|
||||
|
||||
_mesa_notifySwapBuffers(ctx);
|
||||
|
||||
VALIDATE_DRAWABLE_INFO(gmesa);
|
||||
|
||||
/* Flush any partially filled buffers */
|
||||
FLUSH_DMA_BUFFER(gmesa);
|
||||
|
||||
DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock,
|
||||
driScrnPriv->drawLockID);
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
|
||||
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
|
||||
int src, dst, x0, y0, x1, h;
|
||||
int i;
|
||||
int nRect = dPriv->numClipRects;
|
||||
XF86DRIClipRectPtr pRect = dPriv->pClipRects;
|
||||
__DRIscreenPrivate *driScrnPriv = gmesa->driScreen;
|
||||
GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
|
||||
FBReadSrcEnable));
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
|
||||
|
||||
for (i = 0; i < nRect; i++, pRect++) {
|
||||
x0 = pRect->x1;
|
||||
x1 = pRect->x2;
|
||||
h = pRect->y2 - pRect->y1;
|
||||
|
||||
y0 = driScrnPriv->fbHeight - (pRect->y1+h);
|
||||
if (gDRIPriv->numMultiDevices == 2)
|
||||
src = (y0/2)*driScrnPriv->fbWidth+x0;
|
||||
else
|
||||
src = y0*driScrnPriv->fbWidth+x0;
|
||||
|
||||
y0 += driScrnPriv->fbHeight;
|
||||
if (gDRIPriv->numMultiDevices == 2)
|
||||
dst = (y0/2)*driScrnPriv->fbWidth+x0;
|
||||
else
|
||||
dst = y0*driScrnPriv->fbWidth+x0;
|
||||
|
||||
CHECK_DMA_BUFFER(gmesa, 9);
|
||||
WRITE(gmesa->buf, StartXDom, x0<<16); /* X0dest */
|
||||
WRITE(gmesa->buf, StartY, y0<<16); /* Y0dest */
|
||||
WRITE(gmesa->buf, StartXSub, x1<<16); /* X1dest */
|
||||
WRITE(gmesa->buf, GLINTCount, h); /* H */
|
||||
WRITE(gmesa->buf, dY, 1<<16); /* ydir */
|
||||
WRITE(gmesa->buf, dXDom, 0<<16);
|
||||
WRITE(gmesa->buf, dXSub, 0<<16);
|
||||
WRITE(gmesa->buf, FBSourceOffset, (dst-src));
|
||||
WRITE(gmesa->buf, Render, 0x00040048); /* NOT_DONE */
|
||||
}
|
||||
|
||||
/*
|
||||
** NOTE: FBSourceOffset (above) is backwards from what is
|
||||
** described in the manual (i.e., dst-src instead of src-dst)
|
||||
** due to our using the bottom-left window origin instead of the
|
||||
** top-left window origin.
|
||||
*/
|
||||
|
||||
/* Restore FBReadMode */
|
||||
CHECK_DMA_BUFFER(gmesa, 2);
|
||||
WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
|
||||
gmesa->AB_FBReadMode));
|
||||
WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
|
||||
}
|
||||
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
|
||||
PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
|
||||
|
||||
DRM_SPINUNLOCK(&driScrnPriv->pSAREA->drawable_lock,
|
||||
driScrnPriv->drawLockID);
|
||||
VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
|
||||
|
||||
if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
|
||||
PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
|
||||
} else {
|
||||
_mesa_problem(NULL, "gammaSwapBuffers: drawable has no context!\n");
|
||||
}
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
gammaMakeCurrent(__DRIcontextPrivate *driContextPriv,
|
||||
__DRIdrawablePrivate *driDrawPriv,
|
||||
__DRIdrawablePrivate *driReadPriv)
|
||||
{
|
||||
if (driContextPriv) {
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
gammaContextPtr oldGammaCtx = ctx ? GAMMA_CONTEXT(ctx) : NULL;
|
||||
gammaContextPtr newGammaCtx = (gammaContextPtr) driContextPriv->driverPrivate;
|
||||
|
||||
if ( newGammaCtx != oldGammaCtx ) {
|
||||
newGammaCtx->dirty = ~0;
|
||||
}
|
||||
|
||||
if (newGammaCtx->driDrawable != driDrawPriv) {
|
||||
newGammaCtx->driDrawable = driDrawPriv;
|
||||
gammaUpdateWindow ( newGammaCtx->glCtx );
|
||||
gammaUpdateViewportOffset( newGammaCtx->glCtx );
|
||||
}
|
||||
|
||||
#if 0
|
||||
newGammaCtx->Window &= ~W_GIDMask;
|
||||
newGammaCtx->Window |= (driDrawPriv->index << 5);
|
||||
CHECK_DMA_BUFFER(newGammaCtx,1);
|
||||
WRITE(newGammaCtx->buf, GLINTWindow, newGammaCtx->Window);
|
||||
#endif
|
||||
|
||||
newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
|
||||
|
||||
_mesa_make_current2( newGammaCtx->glCtx,
|
||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *) driReadPriv->driverPrivate );
|
||||
|
||||
if (!newGammaCtx->glCtx->Viewport.Width) {
|
||||
_mesa_set_viewport(newGammaCtx->glCtx, 0, 0,
|
||||
driDrawPriv->w, driDrawPriv->h);
|
||||
}
|
||||
} else {
|
||||
_mesa_make_current( 0, 0 );
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
gammaUnbindContext( __DRIcontextPrivate *driContextPriv )
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
gammaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
gammaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
|
||||
{
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static struct __DriverAPIRec gammaAPI = {
|
||||
gammaInitDriver,
|
||||
gammaDestroyScreen,
|
||||
gammaCreateContext,
|
||||
gammaDestroyContext,
|
||||
gammaCreateBuffer,
|
||||
gammaDestroyBuffer,
|
||||
gammaSwapBuffers,
|
||||
gammaMakeCurrent,
|
||||
gammaUnbindContext,
|
||||
gammaOpenFullScreen,
|
||||
gammaCloseFullScreen
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* This is the bootstrap function for the driver.
|
||||
* The __driCreateScreen name is the symbol that libGL.so fetches.
|
||||
* Return: pointer to a __DRIscreenPrivate.
|
||||
*/
|
||||
#ifndef _SOLO
|
||||
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
|
||||
int numConfigs, __GLXvisualConfig *config)
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &gammaAPI);
|
||||
return (void *) psp;
|
||||
}
|
||||
#else
|
||||
void *__driCreateScreen(struct DRIDriverRec *driver,
|
||||
struct DRIDriverContextRec *driverContext)
|
||||
{
|
||||
__DRIscreenPrivate *psp;
|
||||
psp = __driUtilCreateScreen(driver, driverContext, &gammaAPI);
|
||||
return (void *) psp;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
/* glint_common.h -- common header definitions for Gamma 2D/3D/DRM suite
|
||||
*
|
||||
* Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* 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 (including the next
|
||||
* paragraph) 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
|
||||
* PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
|
||||
*
|
||||
* Converted to common header format:
|
||||
* Jens Owen <jens@tungstengraphics.com>
|
||||
*
|
||||
* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_common.h,v 1.2 2003/04/03 16:52:18 dawes Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GLINT_COMMON_H_
|
||||
#define _GLINT_COMMON_H_
|
||||
|
||||
/*
|
||||
* WARNING: If you change any of these defines, make sure to change
|
||||
* the kernel include file as well (gamma_drm.h)
|
||||
*/
|
||||
|
||||
/* Driver specific DRM command indices
|
||||
* NOTE: these are not OS specific, but they are driver specific
|
||||
*/
|
||||
#define DRM_GAMMA_INIT 0x00
|
||||
#define DRM_GAMMA_COPY 0x01
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
GAMMA_INIT_DMA = 0x01,
|
||||
GAMMA_CLEANUP_DMA = 0x02
|
||||
} func;
|
||||
int sarea_priv_offset;
|
||||
int pcimode;
|
||||
unsigned int mmio0;
|
||||
unsigned int mmio1;
|
||||
unsigned int mmio2;
|
||||
unsigned int mmio3;
|
||||
unsigned int buffers_offset;
|
||||
int num_rast;
|
||||
} drmGAMMAInit;
|
||||
|
||||
extern int drmGAMMAInitDMA( int fd, drmGAMMAInit *info );
|
||||
extern int drmGAMMACleanupDMA( int fd );
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,123 @@
|
||||
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h,v 1.7 2002/10/30 12:52:16 alanh Exp $ */
|
||||
/**************************************************************************
|
||||
|
||||
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
|
||||
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, sub license, 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 (including the
|
||||
next paragraph) 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 NON-INFRINGEMENT.
|
||||
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Author:
|
||||
* Jens Owen <jens@tungstengraphics.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GLINT_DRI_H_
|
||||
#define _GLINT_DRI_H_
|
||||
|
||||
#include "xf86drm.h"
|
||||
#include "glint_common.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned int GDeltaMode;
|
||||
unsigned int GDepthMode;
|
||||
unsigned int GGeometryMode;
|
||||
unsigned int GTransformMode;
|
||||
} GAMMAContextRegionRec, *GAMMAContextRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
unsigned char next, prev; /* indices to form a circular LRU */
|
||||
unsigned char in_use; /* owned by a client, or free? */
|
||||
int age; /* tracked by clients to update local LRU's */
|
||||
} GAMMATextureRegionRec, *GAMMATextureRegionPtr;
|
||||
|
||||
typedef struct {
|
||||
GAMMAContextRegionRec context_state;
|
||||
|
||||
unsigned int dirty;
|
||||
|
||||
/* Maintain an LRU of contiguous regions of texture space. If
|
||||
* you think you own a region of texture memory, and it has an
|
||||
* age different to the one you set, then you are mistaken and
|
||||
* it has been stolen by another client. If global texAge
|
||||
* hasn't changed, there is no need to walk the list.
|
||||
*
|
||||
* These regions can be used as a proxy for the fine-grained
|
||||
* texture information of other clients - by maintaining them
|
||||
* in the same lru which is used to age their own textures,
|
||||
* clients have an approximate lru for the whole of global
|
||||
* texture space, and can make informed decisions as to which
|
||||
* areas to kick out. There is no need to choose whether to
|
||||
* kick out your own texture or someone else's - simply eject
|
||||
* them all in LRU order.
|
||||
*/
|
||||
|
||||
#define GAMMA_NR_TEX_REGIONS 64
|
||||
GAMMATextureRegionRec texList[GAMMA_NR_TEX_REGIONS+1];
|
||||
/* Last elt is sentinal */
|
||||
int texAge; /* last time texture was uploaded */
|
||||
int last_enqueue; /* last time a buffer was enqueued */
|
||||
int last_dispatch; /* age of the most recently dispatched buffer */
|
||||
int last_quiescent; /* */
|
||||
int ctxOwner; /* last context to upload state */
|
||||
|
||||
int vertex_prim;
|
||||
} GLINTSAREADRIRec, *GLINTSAREADRIPtr;
|
||||
|
||||
/*
|
||||
* Glint specific record passed back to client driver
|
||||
* via DRIGetDeviceInfo request
|
||||
*/
|
||||
typedef struct {
|
||||
drmRegion registers0;
|
||||
drmRegion registers1;
|
||||
drmRegion registers2;
|
||||
drmRegion registers3;
|
||||
int numMultiDevices;
|
||||
int pprod;
|
||||
int cpp;
|
||||
int frontOffset;
|
||||
int frontPitch;
|
||||
int backOffset;
|
||||
int backPitch;
|
||||
int backX;
|
||||
int backY;
|
||||
int depthOffset;
|
||||
int depthPitch;
|
||||
int textureSize;
|
||||
int logTextureGranularity;
|
||||
} GLINTDRIRec, *GLINTDRIPtr;
|
||||
|
||||
#define GLINT_DRI_BUF_COUNT 256
|
||||
#define GLINT_DRI_BUF_SIZE 4096
|
||||
|
||||
#define GAMMA_NR_TEX_REGIONS 64
|
||||
|
||||
#define DMA_WRITE(val,reg) \
|
||||
do { \
|
||||
pGlint->buf2D++ = Glint##reg##Tag; \
|
||||
pGlint->buf2D++ = val; \
|
||||
} while (0)
|
||||
|
||||
#endif /* _GLINT_DRI_H_ */
|
||||
@@ -55,7 +55,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
/* drmBufPtr buf; */
|
||||
/* int i; */
|
||||
|
||||
/* buffer = Xmalloc(I810_DMA_BUF_SZ); */
|
||||
/* buffer = CALLOC(I810_DMA_BUF_SZ); */
|
||||
/* if(buffer == NULL) return -1; */
|
||||
/* for(i = 0; i < I810_DMA_BUF_NR; i++) { */
|
||||
/* buf = &(buffers->list[i]); */
|
||||
@@ -68,10 +68,10 @@ static drmBufMapPtr i810_create_empty_buffers(void)
|
||||
{
|
||||
drmBufMapPtr retval;
|
||||
|
||||
retval = (drmBufMapPtr)Xmalloc(sizeof(drmBufMap));
|
||||
retval = (drmBufMapPtr)ALIGN_MALLOC(sizeof(drmBufMap));
|
||||
if(retval == NULL) return NULL;
|
||||
memset(retval, 0, sizeof(drmBufMap));
|
||||
retval->list = (drmBufPtr)Xmalloc(sizeof(drmBuf) * I810_DMA_BUF_NR);
|
||||
retval->list = (drmBufPtr)ALIGN_MALLOC(sizeof(drmBuf) * I810_DMA_BUF_NR);
|
||||
if(retval->list == NULL) {
|
||||
Xfree(retval);
|
||||
return NULL;
|
||||
@@ -110,7 +110,7 @@ i810InitDriver(__DRIscreenPrivate *sPriv)
|
||||
}
|
||||
|
||||
/* Allocate the private area */
|
||||
i810Screen = (i810ScreenPrivate *)Xmalloc(sizeof(i810ScreenPrivate));
|
||||
i810Screen = (i810ScreenPrivate *)CALLOC(sizeof(i810ScreenPrivate));
|
||||
if (!i810Screen) {
|
||||
__driUtilMessage("i810InitDriver: alloc i810ScreenPrivate struct failed");
|
||||
return GL_FALSE;
|
||||
|
||||
@@ -57,7 +57,7 @@ static int i830_malloc_proxy_buf(drmBufMapPtr buffers)
|
||||
drmBufPtr buf;
|
||||
int i;
|
||||
|
||||
buffer = Xmalloc(I830_DMA_BUF_SZ);
|
||||
buffer = ALIGN_MALLOC(I830_DMA_BUF_SZ);
|
||||
if(buffer == NULL) return -1;
|
||||
for(i = 0; i < I830_DMA_BUF_NR; i++) {
|
||||
buf = &(buffers->list[i]);
|
||||
@@ -71,10 +71,10 @@ static drmBufMapPtr i830_create_empty_buffers(void)
|
||||
{
|
||||
drmBufMapPtr retval;
|
||||
|
||||
retval = (drmBufMapPtr)Xmalloc(sizeof(drmBufMap));
|
||||
retval = (drmBufMapPtr)ALIGN_MALLOC(sizeof(drmBufMap));
|
||||
if(retval == NULL) return NULL;
|
||||
memset(retval, 0, sizeof(drmBufMap));
|
||||
retval->list = (drmBufPtr)Xmalloc(sizeof(drmBuf) * I830_DMA_BUF_NR);
|
||||
retval->list = (drmBufPtr)ALIGN_MALLOC(sizeof(drmBuf) * I830_DMA_BUF_NR);
|
||||
if(retval->list == NULL) {
|
||||
Xfree(retval);
|
||||
return NULL;
|
||||
@@ -146,7 +146,7 @@ static GLboolean i830InitDriver(__DRIscreenPrivate *sPriv)
|
||||
}
|
||||
|
||||
/* Allocate the private area */
|
||||
i830Screen = (i830ScreenPrivate *)Xmalloc(sizeof(i830ScreenPrivate));
|
||||
i830Screen = (i830ScreenPrivate *)CALLOC(sizeof(i830ScreenPrivate));
|
||||
if (!i830Screen) {
|
||||
fprintf(stderr,"\nERROR! Allocating private area failed\n");
|
||||
return GL_FALSE;
|
||||
|
||||
Reference in New Issue
Block a user