--- /dev/null
+# src/mesa/drivers/dri/trident/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = trident_dri.so
+
+# Not yet
+# MINIGLX_SOURCES = server/trident_dri.c
+
+COMMON_SOURCES = \
+ ../../common/driverfuncs.c \
+ ../common/mm.c \
+ ../common/utils.c \
+ ../common/texmem.c \
+ ../common/vblank.c \
+ ../common/xmlconfig.c \
+ ../common/dri_util.c \
+ ../common/glcontextmodes.c
+
+DRIVER_SOURCES = \
+ trident_context.c \
+ trident_state.c \
+ trident_vb.c \
+ trident_dd.c \
+ trident_tris.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
#include "context.h"
#include "simple_list.h"
-#include "mem.h"
#include "matrix.h"
#include "extensions.h"
#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#endif
#include "simple_list.h"
-#include "mem.h"
#include "mm.h"
-static const struct gl_pipeline_stage *trident_pipeline[] = {
+#include "drivers/common/driverfuncs.h"
+#include "dri_util.h"
+
+static const struct tnl_pipeline_stage *trident_pipeline[] = {
&_tnl_vertex_transform_stage,
&_tnl_normal_transform_stage,
&_tnl_lighting_stage,
};
-GLboolean tridentCreateContext( Display *dpy, const __GLcontextModes *glVisual,
+GLboolean tridentCreateContext( const __GLcontextModes *glVisual,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
{
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
tridentContextPtr tmesa;
tridentScreenPtr tridentscrn;
+ struct dd_function_table functions;
#if 0
drm_trident_sarea_t *saPriv=(drm_trident_sarea_t *)(((char*)sPriv->pSAREA)+
sizeof(XF86DRISAREARec));
else
shareCtx = NULL;
- tmesa->glCtx = _mesa_create_context(glVisual, shareCtx, tmesa, GL_TRUE);
+ _mesa_init_driver_functions(&functions);
+
+ tmesa->glCtx =
+ _mesa_create_context(glVisual, shareCtx, &functions, (void *)tmesa);
+
if (!tmesa->glCtx) {
FREE(tmesa);
return GL_FALSE;
}
- tmesa->display = dpy;
-
tmesa->driContext = driContextPriv;
tmesa->driScreen = sPriv;
tmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
tmesa->hHWContext = driContextPriv->hHWContext;
- tmesa->driHwLock = &sPriv->pSAREA->lock;
+ tmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
tmesa->driFd = sPriv->fd;
#if 0
tmesa->sarea = saPriv;
tridentDDInitTriFuncs( ctx );
tridentDDInitState( tmesa );
- driContextPriv->driverPrivate = (void *)tmesa;
+ driContextPriv->driverPrivate = (void *)tmesa;
UNLOCK_HARDWARE(tmesa);
- return GL_TRUE;
+ return GL_TRUE;
}
static void
tmesa->glCtx->DriverCtx = NULL;
_mesa_destroy_context(tmesa->glCtx);
- Xfree(tmesa);
+ _mesa_free(tmesa);
driContextPriv->driverPrivate = NULL;
}
}
static GLboolean
-tridentCreateBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
+tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
__DRIdrawablePrivate *driDrawPriv,
const __GLcontextModes *mesaVis,
GLboolean isPixmap )
}
static void
-tridentSwapBuffers(Display *dpy, void *drawablePrivate)
+tridentSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
{
__DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
- (void) dpy;
if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
tridentContextPtr tmesa;
tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
ctx = tmesa->glCtx;
if (ctx->Visual.doubleBufferMode) {
- _mesa_swapbuffers( ctx ); /* flush pending rendering comands */
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
tridentCopyBuffer( dPriv );
}
}
return GL_TRUE;
}
-static GLboolean
-tridentOpenFullScreen(__DRIcontextPrivate *driContextPriv)
-{
- return GL_TRUE;
-}
-
-static GLboolean
-tridentCloseFullScreen(__DRIcontextPrivate *driContextPriv)
-{
- return GL_TRUE;
-}
-
tridentScreenPtr tridentCreateScreen( __DRIscreenPrivate *sPriv )
{
TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv;
tridentScreenPtr tridentScreen;
- int i;
#if 0
/* Check the DRI version */
FREE(tridentScreen);
return GL_FALSE;
}
-printf("MAPPED at 0x%x\n",tridentScreen->mmio.map);
+printf("MAPPED at %p\n", tridentScreen->mmio.map);
return tridentScreen;
}
tridentSwapBuffers,
tridentMakeCurrent,
tridentUnbindContext,
- tridentOpenFullScreen,
- tridentCloseFullScreen
};
-/*
- * This is the bootstrap function for the driver.
- * The __driCreateScreen name is the symbol that libGL.so fetches.
- * Return: pointer to a __DRIscreenPrivate.
- */
-void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
- int numConfigs, __GLXvisualConfig *config)
+#ifndef USE_NEW_INTERFACE
+#error trident_dri.so is new-interface only.
+#else
+
+static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
+
+PUBLIC void *__driCreateNewScreen( __DRInativeDisplay *dpy, int scrn,
+ __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ __GLcontextModes ** driver_modes )
{
- __DRIscreenPrivate *psp;
- psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &tridentAPI);
- return (void *) psp;
+ __DRIscreenPrivate *psp;
+ /* XXX version checks */
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &tridentAPI);
+
+ if ( psp != NULL ) {
+ create_context_modes = (PFNGLXCREATECONTEXTMODES)
+ glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" );
+#if 0
+ if ( create_context_modes != NULL ) {
+ TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
+ *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
+ GL_TRUE );
+ }
+#endif
+ }
+ return (void *) psp;
}
+#endif
+
void __driRegisterExtensions(void)
{
/* No extensions */
#ifndef _TRIDENT_CONTEXT_H_
#define _TRIDENT_CONTEXT_H_
-#include "compiler.h"
#include "dri_util.h"
#include "macros.h"
#include "mtypes.h"
#include "tnl_dd/t_dd_vertex.h"
#undef TAG
+/* these require that base be dword-aligned */
+static inline void MMIO_OUT32(unsigned char *base, unsigned int offset,
+ unsigned int val)
+{
+ unsigned int *addr = (unsigned int *)(base + offset);
+ *addr = val;
+}
+
+static inline unsigned int MMIO_IN32(unsigned char *base, unsigned int offset)
+{
+ unsigned int *addr = (unsigned int *)(base + offset);
+ return *addr;
+}
+
+#define MMIO_OUT8(base, offset, val) *((base) + (offset)) = (val)
+#define MMIO_IN8(base, offset) *((base) + (offset))
+
struct trident_context;
typedef struct trident_context tridentContextRec;
typedef struct trident_context *tridentContextPtr;
const tridentVertex * );
typedef struct {
- drmHandle handle; /* Handle to the DRM region */
+ drm_handle_t handle; /* Handle to the DRM region */
drmSize size; /* Size of the DRM region */
unsigned char *map; /* Mapping of the DRM region */
} tridentRegionRec, *tridentRegionPtr;
/* Mirrors of some DRI state
*/
- Display *display; /* X server display */
-
int lastStamp; /* mirror driDrawable->lastStamp */
- drmContext hHWContext;
+ drm_context_t hHWContext;
drmLock *driHwLock;
int driFd;
GLint readOffset, readPitch;
GLuint numClipRects; /* Cliprects for the draw buffer */
- XF86DRIClipRectPtr pClipRects;
+ drm_clip_rect_t *pClipRects;
GLint scissor;
- XF86DRIClipRectRec ScissorRect; /* Current software scissor */
+ drm_clip_rect_t ScissorRect; /* Current software scissor */
GLuint Fallback;
GLuint RenderIndex;
void tridentDDInitStateFuncs( GLcontext *ctx );
void tridentDDInitTextureFuncs( GLcontext *ctx );
void tridentDDInitTriFuncs( GLcontext *ctx );
+
extern void tridentBuildVertices( GLcontext *ctx,
GLuint start,
GLuint count,
GLuint newinputs );
+extern void tridentInitVB( GLcontext *ctx );
+extern void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv );
+extern void tridentFallback( tridentContextPtr tmesa, GLuint bit,
+ GLboolean mode );
+extern void tridentCheckTexSizes( GLcontext *ctx );
+extern void tridentChooseVertexState( GLcontext *ctx );
+extern void tridentDDUpdateHWState( GLcontext *ctx );
+extern void tridentUploadHwStateLocked( tridentContextPtr tmesa );
#define TRIDENT_CONTEXT(ctx) ((tridentContextPtr)(ctx->DriverCtx))
#include "swrast/swrast.h"
#include "context.h"
-#define TRIDENT_DATE "20020318"
-
+#define TRIDENT_DATE "20041223"
/* Return the width and height of the current color buffer.
*/
--- /dev/null
+#ifndef _TRIDENT_DRI_
+#define _TRIDENT_DRI_
+
+#include "xf86drm.h"
+
+typedef struct {
+ drm_handle_t regs;
+ drmSize regsSize;
+ drmAddress regsMap;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+ int depthOffset;
+ int depthPitch;
+ int cpp;
+#if 0
+ int textureOffset;
+ int textureSize;
+#endif
+ unsigned int sarea_priv_offset;
+} TRIDENTDRIRec, *TRIDENTDRIPtr;
+
+#endif
--- /dev/null
+/* XXX tridentGetLock doesn't exist... */
+
+#define LOCK_HARDWARE(tmesa) \
+ do { \
+ char __ret = 0; \
+ DRM_CAS(tmesa->driHwLock, tmesa->hHWContext, \
+ DRM_LOCK_HELD | tmesa->hHWContext, __ret); \
+ } while (0)
+
+#define UNLOCK_HARDWARE(tmesa) \
+ DRM_UNLOCK(tmesa->driFd, tmesa->driHwLock, tmesa->hHWContext)
*/
#include "trident_context.h"
#include "trident_lock.h"
+#include "array_cache/acache.h"
#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
#define TRIDENTPACKCOLOR332(r, g, b) \
(((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
{
unsigned char *MMIO;
tridentContextPtr tmesa;
- GLint nbox, i, ret;
+ GLint nbox, i;
int busy;
- XF86DRIClipRectPtr pbox;
+ drm_clip_rect_t *pbox;
assert(dPriv);
assert(dPriv->driContextPriv);
for ( i = 0 ; i < nbox ; i++ ) {
#if 0
GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox );
- XF86DRIClipRectPtr b = tmesa->sarea->boxes;
+ drm_clip_rect_t *b = tmesa->sarea->boxes;
GLint n = 0;
for ( ; i < nr ; i++ ) {
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
- __DRIdrawablePrivate *dPriv = tmesa->driDrawable;
int busy;
GLuint flags = 0;
GLint i;
- GLint ret;
#define DRM_TRIDENT_FRONT 0x01
#define DRM_TRIDENT_BACK 0x02
for ( i = 0 ; i < tmesa->numClipRects ; i++ ) {
#if 0
int nr = MIN2( i + TRIDENT_NR_SAREA_CLIPRECTS, tmesa->numClipRects );
- XF86DRIClipRectPtr box = tmesa->pClipRects;
- XF86DRIClipRectPtr b = tmesa->sarea->boxes;
+ drm_clip_rect_t *box = tmesa->pClipRects;
+ drm_clip_rect_t *b = tmesa->sarea->boxes;
GLint n = 0;
if ( !all ) {
switch ( mode ) {
case GL_FRONT_LEFT:
if (dPriv->numClipRects == 0) {
- static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
+ static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
tmesa->numClipRects = 1;
tmesa->pClipRects = &zeroareacliprect;
} else {
tmesa->numClipRects = dPriv->numClipRects;
- tmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pClipRects;
+ tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
}
tmesa->drawX = dPriv->x;
tmesa->drawY = dPriv->y;
case GL_BACK_LEFT:
if ( dPriv->numBackClipRects == 0 ) {
if (dPriv->numClipRects == 0) {
- static XF86DRIClipRectRec zeroareacliprect = {0,0,0,0};
+ static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
tmesa->numClipRects = 1;
tmesa->pClipRects = &zeroareacliprect;
} else {
tmesa->numClipRects = dPriv->numClipRects;
- tmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pClipRects;
+ tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
tmesa->drawX = dPriv->x;
tmesa->drawY = dPriv->y;
}
}
else {
tmesa->numClipRects = dPriv->numBackClipRects;
- tmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pBackClipRects;
+ tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pBackClipRects;
tmesa->drawX = dPriv->backX;
tmesa->drawY = dPriv->backY;
}
#endif
}
+#if 0
static GLboolean tridentDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
color[0], color[1],
color[2], color[3] );
}
-
+#endif
void tridentDDUpdateState( GLcontext *ctx, GLuint new_state )
{
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
static int first = 1;
int DrawTriangle( tridentContextPtr tmesa)
{
- volatile unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
dmaBufRec clr;
printf("DRAW TRI\n");
const tridentVertex *v0 )
{
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ (void) MMIO;
}
static INLINE void trident_draw_line( tridentContextPtr tmesa,
const tridentVertex *v1 )
{
unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ (void) MMIO;
}
static INLINE void trident_draw_triangle( tridentContextPtr tmesa,
* primitives are being drawn, and only for the unaccelerated
* primitives.
*/
+#if 0
static void
trident_fallback_quad( tridentContextPtr tmesa,
const tridentVertex *v0,
trident_translate_vertex( ctx, v3, &v[3] );
_swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
}
+#endif
+
+/* XXX hack to get the prototype defined in time... */
+void trident_translate_vertex(GLcontext *ctx, const tridentVertex *src,
+ SWvertex *dst);
static void
trident_fallback_tri( tridentContextPtr tmesa,
static struct {
- points_func points;
- line_func line;
- triangle_func triangle;
- quad_func quad;
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
} rast_tab[TRIDENT_MAX_TRIFUNC];
#endif
static void tridentResetLineStipple( GLcontext *ctx );
+#if 0
static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+#endif
static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim );
#define RASTERIZE(x) /*if (tmesa->hw_primitive != hw_prim[x]) \
* which renders strips as strips, the equivalent calculations are
* performed in tridentrender.c.
*/
-
+#if 0
static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
if (tmesa->hw_primitive != hwprim)
tmesa->hw_primitive = hwprim;
}
+#endif
static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim )
{
static void tridentResetLineStipple( GLcontext *ctx )
{
tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ (void) tmesa;
/* Reset the hardware stipple counter.
*/
*/
#include "glheader.h"
#include "mtypes.h"
-#include "mem.h"
#include "macros.h"
#include "colormac.h"
-#include "mmath.h"
#include "swrast_setup/swrast_setup.h"
#include "swrast/swrast.h"
static struct {
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
- interp_func interp;
- copy_pv_func copy_pv;
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
GLboolean (*check_tex_sizes)( GLcontext *ctx );
GLuint vertex_size;
GLuint vertex_stride_shift;
#define DO_PTEX (IND & TRIDENT_PTEX_BIT)
#define VERTEX tridentVertex
+#define VERTEX_COLOR trident_color_t
#define LOCALVARS tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
#define GET_VIEWPORT_MAT() tmesa->hw_viewport
#define GET_TEXSOURCE(n) tmesa->tmu_source[n]
#define GET_VERTEX_FORMAT() tmesa->vertex_format
+#define GET_VERTEX_SIZE() tmesa->vertex_size
#define GET_VERTEX_STORE() tmesa->verts
#define GET_VERTEX_STRIDE_SHIFT() tmesa->vertex_stride_shift
#define GET_UBYTE_COLOR_STORE() &tmesa->UbyteColor
if (!newinputs)
return;
- if (newinputs & VERT_CLIP) {
+ if (newinputs & VERT_BIT_POS) {
setup_tab[tmesa->SetupIndex].emit( ctx, start, count, v, stride );
} else {
GLuint ind = 0;
- if (newinputs & VERT_RGBA)
+ if (newinputs & VERT_BIT_COLOR0)
ind |= TRIDENT_RGBA_BIT;
- if (newinputs & VERT_SPEC_RGB)
+ if (newinputs & VERT_BIT_COLOR1)
ind |= TRIDENT_SPEC_BIT;
- if (newinputs & VERT_TEX0)
+ if (newinputs & VERT_BIT_TEX0)
ind |= TRIDENT_TEX0_BIT;
- if (newinputs & VERT_TEX1)
+ if (newinputs & VERT_BIT_TEX1)
ind |= TRIDENT_TEX1_BIT;
- if (newinputs & VERT_FOG_COORD)
+ if (newinputs & VERT_BIT_FOG)
ind |= TRIDENT_FOG_BIT;
if (tmesa->SetupIndex & TRIDENT_PTEX_BIT)
if (ctx->Fog.Enabled)
ind |= TRIDENT_FOG_BIT;
- if (ctx->Texture._ReallyEnabled) {
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
ind |= TRIDENT_TEX0_BIT;
- if (ctx->Texture.Unit[0]._ReallyEnabled &&
- ctx->Texture.Unit[1]._ReallyEnabled) {
+ if (ctx->Texture.Unit[1]._ReallyEnabled) {
ind |= TRIDENT_TEX1_BIT;
}
}
}
if (tmesa->UbyteSecondaryColor.Ptr) {
- ALIGN_FREE(tmesa->UbyteSecondaryColor.Ptr);
+ ALIGN_FREE((void *)tmesa->UbyteSecondaryColor.Ptr);
tmesa->UbyteSecondaryColor.Ptr = 0;
}
if (tmesa->UbyteColor.Ptr) {
- ALIGN_FREE(tmesa->UbyteColor.Ptr);
+ ALIGN_FREE((void *)tmesa->UbyteColor.Ptr);
tmesa->UbyteColor.Ptr = 0;
}
}