"CFLAGS = -g -std=c99 -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE" \
"CXXFLAGS = -g -std=c99 -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE" \
"GLUT_CFLAGS = -fexceptions" \
- "GL_LIB_DEPS = -lm -lpthread" \
+ "GL_LIB_DEPS = -lm -lpthread -lexpat" \
"GLU_LIB_DEPS = -L$(TOP)/lib -lGL -lm -Wl,-rpath,$(TOP)/lib" \
"GLUT_LIB_DEPS = -L$(TOP)/lib -lGLU -lGL -lm -Wl,-rpath,$(TOP)/lib" \
"APP_LIB_DEPS = -L$(TOP)/lib -lglut -lGLU -lGL -lm -lpthread -Wl,-rpath,$(TOP)/lib"
* the drawable that was bound. Otherwise, this is NULL.
*/
__DRIdrawablePrivate *fullscreen;
+
+
+ /**
+ * \brief Screen number for when multiple screens are supported
+ */
+ int myNum;
};
extern void
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* $Id: miniglx.c,v 1.1 2003/08/22 20:11:43 brianp Exp $ */
+/* $Id: miniglx.c,v 1.2 2003/10/21 06:05:40 jonsmirl Exp $ */
/**
* \mainpage Mini GLX
nr = sscanf(buf, "%04x\t%04x%04x", &encode,
&vendor, &device);
- bus = encode >> 16;
+ bus = encode >> 8;
dev = (encode & 0xFF) >> 3;
fn = encode & 0x7;
#include <stdio.h>
#include "mm.h"
-#include "hwlog.h"
void mmDumpMemInfo( memHeap_t *heap )
{
TMemBlock *p;
- fprintf(stderr, "Memory heap %p:\n", heap);
+ fprintf(stderr, "Memory heap %p:\n", (void *)heap);
if (heap == 0) {
fprintf(stderr, " heap == 0\n");
} else {
/*
* Copyright 2000-2001 VA Linux Systems, Inc.
- * (c) Copyright IBM Corporation 2002
+ * (C) Copyright IBM Corporation 2002, 2003
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
#include "texmem.h"
#include "simple_list.h"
#include "imports.h"
+#include "macros.h"
#include <assert.h>
continue;
if (!t->tObj) {
fprintf( stderr, "Placeholder (%p) %d at 0x%x sz 0x%x\n",
- t,
+ (void *)t,
t->memBlock->ofs / sz,
t->memBlock->ofs,
t->memBlock->size );
} else {
fprintf( stderr, "Texture (%p) at 0x%x sz 0x%x\n",
- t,
+ (void *)t,
t->memBlock->ofs,
t->memBlock->size );
}
}
foreach ( t, heap->swapped_objects ) {
if (!t->tObj) {
- fprintf( stderr, "Swapped Placeholder (%p)\n", t );
+ fprintf( stderr, "Swapped Placeholder (%p)\n", (void *)t );
} else {
- fprintf( stderr, "Swapped Texture (%p)\n", t );
+ fprintf( stderr, "Swapped Texture (%p)\n", (void *)t );
}
}
int i, j;
fprintf( stderr, "%s in %s:\nGlobal LRU, heap %d list %p:\n",
- __FUNCTION__, callername, heap->heapId, list );
+ __FUNCTION__, callername, heap->heapId, (void *)list );
for ( i = 0, j = heap->nrRegions ; i < heap->nrRegions ; i++ ) {
fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n",
if ( 0 ) {
fprintf( stderr, "[%s:%d] freeing %p (tObj = %p, DriverData = %p)\n",
__FILE__, __LINE__,
- t,
- (t != NULL) ? t->tObj : NULL,
- (t != NULL && t->tObj != NULL) ? t->tObj->DriverData : NULL );
+ (void *)t,
+ (void *)((t != NULL) ? t->tObj : NULL),
+ (void *)((t != NULL && t->tObj != NULL) ? t->tObj->DriverData : NULL ));
}
if ( t != NULL ) {
}
if ( 0 ) {
- fprintf( stderr, "[%s:%d] done freeing %p\n", __FILE__, __LINE__, t );
+ fprintf( stderr, "[%s:%d] done freeing %p\n", __FILE__, __LINE__, (void *)t );
}
}
if ( 0 )
fprintf( stderr, "%s( %u, %p, %u, %u, %u )\n",
__FUNCTION__,
- heap_id, context, size, alignmentShift, nr_regions );
+ heap_id, (void *)context, size, alignmentShift, nr_regions );
heap = (driTexHeap *) CALLOC( sizeof( driTexHeap ) );
if ( heap != NULL ) {
if ( 0 )
- fprintf( stderr, "%s returning %p\n", __FUNCTION__, heap );
+ fprintf( stderr, "%s returning %p\n", __FUNCTION__, (void *)heap );
return heap;
}
/**
* Given the amount of texture memory, the number of texture units, and the
* maximum size of a texel, calculate the maximum texture size the driver can
- * adverteise.
+ * advertise.
*
* \param heaps Texture heaps for this card
* \param nr_heap Number of texture heaps
if ( !check_in_heap( t, heap ) ) {
fprintf( stderr, "%s memory block for texture object @ %p not "
"found in heap #%d\n",
- __FUNCTION__, t, i );
+ __FUNCTION__, (void *)t, i );
return GL_FALSE;
}
if ( t->totalSize > t->memBlock->size ) {
fprintf( stderr, "%s: Memory block for texture object @ %p is "
"only %u bytes, but %u are required\n",
- __FUNCTION__, t, t->totalSize, t->memBlock->size );
+ __FUNCTION__, (void *)t, t->totalSize, t->memBlock->size );
return GL_FALSE;
}
foreach ( t, swapped ) {
if ( t->memBlock != NULL ) {
fprintf( stderr, "%s: Swapped texobj %p has non-NULL memblock %p\n",
- __FUNCTION__, t, t->memBlock );
+ __FUNCTION__, (void *)t, (void *)t->memBlock );
return GL_FALSE;
}
i++;
}
#if 0
- fprintf( stderr, "%s: swapped texture count = %u\n", i );
+ fprintf( stderr, "%s: swapped texture count = %u\n", __FUNCTION__, i );
#endif
return GL_TRUE;
}
+
+
+
+
+/****************************************************************************/
+/**
+ * Compute which mipmap levels that really need to be sent 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.
+ */
+
+void
+driCalculateTextureFirstLastLevel( driTextureObject * t )
+{
+ struct gl_texture_object * const tObj = t->tObj;
+ const struct gl_texture_image * const baseImage =
+ tObj->Image[tObj->BaseLevel];
+
+ /* These must be signed values. MinLod and MaxLod can be negative numbers,
+ * and having firstLevel and lastLevel as signed prevents the need for
+ * extra sign checks.
+ */
+ int firstLevel;
+ int lastLevel;
+
+ /* Yes, this looks overly complicated, but it's all needed.
+ */
+
+ switch (tObj->Target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
+ /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
+ */
+
+ 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, t->tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, t->tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, t->tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_TEXTURE_4D_SGIS:
+ firstLevel = lastLevel = 0;
+ break;
+ default:
+ return;
+ }
+
+ /* save these values */
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+}
GLboolean driValidateTextureHeaps( driTexHeap * const * texture_heaps,
unsigned nr_heaps, const driTextureObject * swapped );
+extern void driCalculateTextureFirstLastLevel( driTextureObject * t );
+
#endif /* DRI_TEXMEM_H */
#include "macros.h"
#include "dd.h"
#include "vblank.h"
+#include "xmlpool.h"
/****************************************************************************/
if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
/* FIXME: This doesn't seem like the right thing to return here.
*/
-#ifndef _SOLO
+#ifndef _SOLO
return GLX_BAD_CONTEXT;
#else
return -1;
/* FIXME: This doesn't seem like the right thing to return here.
*/
#ifndef _SOLO
- return GLX_BAD_CONTEXT;
+ return GLX_BAD_CONTEXT;
#else
- return -1;
+ return -1;
#endif
}
}
/****************************************************************************/
/**
* Gets a set of default vertical-blank-wait flags based on the internal GLX
- * API version and several environment variables.
+ * API version and several configuration options.
*/
-GLuint driGetDefaultVBlankFlags( void )
+GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache )
{
GLuint flags = 0;
-
+ int vblank_mode;
flags |= (driCompareGLXAPIVersion( 20030317 ) >= 0)
? VBLANK_FLAG_INTERVAL : 0;
- flags |= (getenv("LIBGL_SYNC_REFRESH") != NULL)
- ? VBLANK_FLAG_SYNC : 0;
- flags |= (getenv("LIBGL_THROTTLE_REFRESH") != NULL)
- ? VBLANK_FLAG_THROTTLE : 0;
+
+ if ( driCheckOption( optionCache, "vblank_mode", DRI_ENUM ) )
+ vblank_mode = driQueryOptioni( optionCache, "vblank_mode" );
+ else
+ vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
+
+ switch (vblank_mode) {
+ case DRI_CONF_VBLANK_NEVER:
+ flags = 0;
+ break;
+ case DRI_CONF_VBLANK_DEF_INTERVAL_0:
+ break;
+ case DRI_CONF_VBLANK_DEF_INTERVAL_1:
+ flags |= VBLANK_FLAG_THROTTLE;
+ break;
+ case DRI_CONF_VBLANK_ALWAYS_SYNC:
+ flags |= VBLANK_FLAG_SYNC;
+ break;
+ }
return flags;
}
+/****************************************************************************/
+/**
+ * Sets the default swap interval when the drawable is first bound to a
+ * direct rendering context.
+ */
+
+void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags )
+{
+#ifndef _SOLO
+ if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
+ priv->pdraw->swap_interval = (flags & VBLANK_FLAG_THROTTLE) != 0 ? 1 : 0;
+ }
+#endif
+}
+
+
/****************************************************************************/
/**
* Wrapper to call \c drmWaitVBlank. The main purpose of this function is to
*missed_deadline = GL_FALSE;
- if ( (flags & VBLANK_FLAG_NO_IRQ) != 0 ) {
+ if ( (flags & (VBLANK_FLAG_INTERVAL |
+ VBLANK_FLAG_THROTTLE |
+ VBLANK_FLAG_SYNC)) == 0 ||
+ (flags & VBLANK_FLAG_NO_IRQ) != 0 ) {
return 0;
}
vbl.request.type = DRM_VBLANK_ABSOLUTE;
if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
-#ifndef _SOLO
+#ifndef _SOLO
interval = priv->pdraw->swap_interval;
#else
interval = 0;
-#endif
+#endif
+ /* this must have been initialized when the drawable was first bound
+ * to a direct rendering context. */
+ assert ( interval != (unsigned)-1 );
}
else if ( (flags & VBLANK_FLAG_THROTTLE) != 0 ) {
interval = 1;
#include "context.h"
#include "dri_util.h"
+#include "xmlconfig.h"
#define VBLANK_FLAG_INTERVAL (1U << 0) /* Respect the swap_interval setting
*/
extern int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count );
extern int driWaitForMSC32( __DRIdrawablePrivate *priv,
int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc );
-extern GLuint driGetDefaultVBlankFlags( void );
+extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache );
+extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv, GLuint flags );
extern int driWaitForVBlank( const __DRIdrawablePrivate *priv,
GLuint * vbl_seq, GLuint flags, GLboolean * missed_deadline );
--- /dev/null
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+/**
+ * \file xmlconfig.c
+ * \brief Driver-independent client-side part of the XML configuration
+ * \author Felix Kuehling
+ */
+
+#include "glheader.h"
+
+#include <string.h>
+#include <assert.h>
+#include <expat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include "imports.h"
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+/*
+ * OS dependent ways of getting the name of the running program
+ */
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#undef GET_PROGRAM_NAME
+
+#if defined(__GNU_LIBRARY__) || defined(__GLIBC__)
+# define GET_PROGRAM_NAME() program_invocation_short_name
+#elif defined(__FreeBSD__) && (__FreeBSD__ >= 2)
+# include <osreldate.h>
+# if (__FreeBSD_version >= 440000)
+# include <stdlib.h>
+# define GET_PROGRAM_NAME() getprogname()
+# endif
+#elif defined(__NetBSD__) && defined(__NetBSD_Version) && (__NetBSD_Version >= 106000100)
+# include <stdlib.h>
+# define GET_PROGRAM_NAME() getprogname()
+#endif
+
+#if !defined(GET_PROGRAM_NAME)
+# if defined(OpenBSD) || defined(NetBSD)
+/* This is a hack. It's said to work on OpenBSD, NetBSD and GNU. It's
+ * used as a last resort, if there is no documented facility available. */
+static const char *__getProgramName () {
+ extern const char *__progname;
+ return progname;
+}
+# define GET_PROGRAM_NAME() __getProgramName()
+# else
+# define GET_PROGRAM_NAME() ""
+# warning "Per application configuration won't with your OS version work."
+# endif
+#endif
+
+/** \brief Find an option in an option cache with the name as key */
+static GLuint findOption (const driOptionCache *cache, const char *name) {
+ GLuint len = strlen (name);
+ GLuint size = 1 << cache->tableSize, mask = size - 1;
+ GLuint hash = 0;
+ GLuint i, shift;
+
+ /* compute a hash from the variable length name */
+ for (i = 0, shift = 0; i < len; ++i, shift = (shift+8) & 31)
+ hash += (GLuint)name[i] << shift;
+ hash *= hash;
+ hash = (hash >> (16-cache->tableSize/2)) & mask;
+
+ /* this is just the starting point of the linear search for the option */
+ for (i = 0; i < size; ++i, hash = (hash+1) & mask) {
+ /* if we hit an empty entry then the option is not defined (yet) */
+ if (cache->info[hash].name == 0)
+ break;
+ else if (!strcmp (name, cache->info[hash].name))
+ break;
+ }
+ /* this assertion fails if the hash table is full */
+ assert (i < size);
+
+ return hash;
+}
+
+/** \brief Count the real number of options in an option cache */
+static GLuint countOptions (const driOptionCache *cache) {
+ GLuint size = 1 << cache->tableSize;
+ GLuint i, count = 0;
+ for (i = 0; i < size; ++i)
+ if (cache->info[i].name)
+ count++;
+ return count;
+}
+
+/** \brief Like strdup but using MALLOC and with error checking. */
+#define XSTRDUP(dest,source) do { \
+ GLuint len = strlen (source); \
+ if (!(dest = MALLOC (len+1))) { \
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
+ abort(); \
+ } \
+ memcpy (dest, source, len+1); \
+} while (0)
+
+static int compare (const void *a, const void *b) {
+ return strcmp (*(char *const*)a, *(char *const*)b);
+}
+/** \brief Binary search in a string array. */
+static GLuint bsearchStr (const XML_Char *name,
+ const XML_Char *elems[], GLuint count) {
+ const XML_Char **found;
+ found = bsearch (&name, elems, count, sizeof (XML_Char *), compare);
+ if (found)
+ return found - elems;
+ else
+ return count;
+}
+
+/** \brief Parse a value of a given type. */
+static GLboolean parseValue (driOptionValue *v, driOptionType type,
+ const XML_Char *string) {
+ const XML_Char *tail;
+ /* skip leading white-space */
+ string += strspn (string, " \f\n\r\t\v");
+ switch (type) {
+ case DRI_BOOL:
+ if (!strcmp (string, "false")) {
+ v->_bool = GL_FALSE;
+ tail = string + 5;
+ } else if (!strcmp (string, "true")) {
+ v->_bool = GL_TRUE;
+ tail = string + 4;
+ }
+ else
+ return GL_FALSE;
+ break;
+ case DRI_ENUM: /* enum is just a special integer */
+ case DRI_INT:
+ v->_int = strtol (string, (char **)&tail, 0);
+ break;
+ case DRI_FLOAT:
+ v->_float = strtod (string, (char **)&tail);
+ break;
+ }
+
+ if (tail == string)
+ return GL_FALSE; /* empty string (or containing only white-space) */
+ /* skip trailing white space */
+ if (*tail)
+ tail += strspn (tail, " \f\n\r\t\v");
+ if (*tail)
+ return GL_FALSE; /* something left over that is not part of value */
+
+ return GL_TRUE;
+}
+
+/** \brief Parse a list of ranges of type info->type. */
+static GLboolean parseRanges (driOptionInfo *info, const XML_Char *string) {
+ XML_Char *cp, *range;
+ GLuint nRanges, i;
+ driOptionRange *ranges;
+
+ XSTRDUP (cp, string);
+ /* pass 1: determine the number of ranges (number of commas + 1) */
+ range = cp;
+ for (nRanges = 1; *range; ++range)
+ if (*range == ',')
+ ++nRanges;
+
+ if ((ranges = MALLOC (nRanges*sizeof(driOptionRange))) == NULL) {
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
+ abort();
+ }
+
+ /* pass 2: parse all ranges into preallocated array */
+ range = cp;
+ for (i = 0; i < nRanges; ++i) {
+ XML_Char *end, *sep;
+ assert (range);
+ end = strchr (range, ',');
+ if (end)
+ *end = '\0';
+ sep = strchr (range, ':');
+ if (sep) { /* non-empty interval */
+ *sep = '\0';
+ if (!parseValue (&ranges[i].start, info->type, range) ||
+ !parseValue (&ranges[i].end, info->type, sep+1))
+ break;
+ if (info->type == DRI_INT &&
+ ranges[i].start._int > ranges[i].end._int)
+ break;
+ if (info->type == DRI_FLOAT &&
+ ranges[i].start._float > ranges[i].end._float)
+ break;
+ } else { /* empty interval */
+ if (!parseValue (&ranges[i].start, info->type, range))
+ break;
+ ranges[i].end = ranges[i].start;
+ }
+ if (end)
+ range = end+1;
+ else
+ range = NULL;
+ }
+ FREE (cp);
+ if (i < nRanges) {
+ FREE (ranges);
+ return GL_FALSE;
+ } else
+ assert (range == NULL);
+
+ info->nRanges = nRanges;
+ info->ranges = ranges;
+ return GL_TRUE;
+}
+
+/** \brief Check if a value is in one of info->ranges. */
+static GLboolean checkValue (const driOptionValue *v, const driOptionInfo *info) {
+ GLuint i;
+ assert (info->type != DRI_BOOL); /* should be caught by the parser */
+ if (info->nRanges == 0)
+ return GL_TRUE;
+ switch (info->type) {
+ case DRI_ENUM: /* enum is just a special integer */
+ case DRI_INT:
+ for (i = 0; i < info->nRanges; ++i)
+ if (v->_int >= info->ranges[i].start._int &&
+ v->_int <= info->ranges[i].end._int)
+ return GL_TRUE;
+ break;
+ case DRI_FLOAT:
+ for (i = 0; i < info->nRanges; ++i)
+ if (v->_float >= info->ranges[i].start._float &&
+ v->_float <= info->ranges[i].end._float)
+ return GL_TRUE;
+ break;
+ default:
+ assert (0); /* should never happen */
+ }
+ return GL_FALSE;
+}
+
+/** \brief Output a warning message. */
+#define XML_WARNING1(msg) do {\
+ __driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser)); \
+} while (0)
+#define XML_WARNING(msg,args...) do { \
+ __driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser), \
+ args); \
+} while (0)
+/** \brief Output an error message. */
+#define XML_ERROR1(msg) do { \
+ __driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser)); \
+} while (0)
+#define XML_ERROR(msg,args...) do { \
+ __driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser), \
+ args); \
+} while (0)
+/** \brief Output a fatal error message and abort. */
+#define XML_FATAL1(msg) do { \
+ fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
+ data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser)); \
+ abort();\
+} while (0)
+#define XML_FATAL(msg,args...) do { \
+ fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
+ data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser), \
+ args); \
+ abort();\
+} while (0)
+
+/** \brief Parser context for __driConfigOptions. */
+struct OptInfoData {
+ const char *name;
+ XML_Parser parser;
+ driOptionCache *cache;
+ GLboolean inDriInfo;
+ GLboolean inSection;
+ GLboolean inDesc;
+ GLboolean inOption;
+ GLboolean inEnum;
+ int curOption;
+};
+
+/** \brief Elements in __driConfigOptions. */
+enum OptInfoElem {
+ OI_DESCRIPTION = 0, OI_DRIINFO, OI_ENUM, OI_OPTION, OI_SECTION, OI_COUNT
+};
+static const XML_Char *OptInfoElems[] = {
+ "description", "driinfo", "enum", "option", "section"
+};
+
+/** \brief Parse attributes of an enum element.
+ *
+ * We're not actually interested in the data. Just make sure this is ok
+ * for external configuration tools.
+ */
+static void parseEnumAttr (struct OptInfoData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *value = NULL, *text = NULL;
+ driOptionValue v;
+ GLuint opt = data->curOption;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "value")) value = attr[i+1];
+ else if (!strcmp (attr[i], "text")) text = attr[i+1];
+ else XML_FATAL("illegal enum attribute: %s.", attr[i]);
+ }
+ if (!value) XML_FATAL1 ("value attribute missing in enum.");
+ if (!text) XML_FATAL1 ("text attribute missing in enum.");
+ if (!parseValue (&v, data->cache->info[opt].type, value))
+ XML_FATAL ("illegal enum value: %s.", value);
+ if (!checkValue (&v, &data->cache->info[opt]))
+ XML_FATAL ("enum value out of valid range: %s.", value);
+}
+
+/** \brief Parse attributes of a description element.
+ *
+ * We're not actually interested in the data. Just make sure this is ok
+ * for external configuration tools.
+ */
+static void parseDescAttr (struct OptInfoData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *lang = NULL, *text = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "lang")) lang = attr[i+1];
+ else if (!strcmp (attr[i], "text")) text = attr[i+1];
+ else XML_FATAL("illegal description attribute: %s.", attr[i]);
+ }
+ if (!lang) XML_FATAL1 ("lang attribute missing in description.");
+ if (!text) XML_FATAL1 ("text attribute missing in description.");
+}
+
+/** \brief Parse attributes of an option element. */
+static void parseOptInfoAttr (struct OptInfoData *data, const XML_Char **attr) {
+ enum OptAttr {OA_DEFAULT = 0, OA_NAME, OA_TYPE, OA_VALID, OA_COUNT};
+ static const XML_Char *optAttr[] = {"default", "name", "type", "valid"};
+ const XML_Char *attrVal[OA_COUNT] = {NULL, NULL, NULL, NULL};
+ const char *defaultVal;
+ driOptionCache *cache = data->cache;
+ GLuint opt, i;
+ for (i = 0; attr[i]; i += 2) {
+ GLuint attrName = bsearchStr (attr[i], optAttr, OA_COUNT);
+ if (attrName >= OA_COUNT)
+ XML_FATAL ("illegal option attribute: %s", attr[i]);
+ attrVal[attrName] = attr[i+1];
+ }
+ if (!attrVal[OA_NAME]) XML_FATAL1 ("name attribute missing in option.");
+ if (!attrVal[OA_TYPE]) XML_FATAL1 ("type attribute missing in option.");
+ if (!attrVal[OA_DEFAULT]) XML_FATAL1 ("default attribute missing in option.");
+
+ opt = findOption (cache, attrVal[OA_NAME]);
+ if (cache->info[opt].name)
+ XML_FATAL ("option %s redefined.", attrVal[OA_NAME]);
+ data->curOption = opt;
+
+ XSTRDUP (cache->info[opt].name, attrVal[OA_NAME]);
+
+ if (!strcmp (attrVal[OA_TYPE], "bool"))
+ cache->info[opt].type = DRI_BOOL;
+ else if (!strcmp (attrVal[OA_TYPE], "enum"))
+ cache->info[opt].type = DRI_ENUM;
+ else if (!strcmp (attrVal[OA_TYPE], "int"))
+ cache->info[opt].type = DRI_INT;
+ else if (!strcmp (attrVal[OA_TYPE], "float"))
+ cache->info[opt].type = DRI_FLOAT;
+ else
+ XML_FATAL ("illegal type in option: %s.", attrVal[OA_TYPE]);
+
+ defaultVal = getenv (cache->info[opt].name);
+ if (defaultVal != NULL) {
+ /* don't use XML_WARNING, we want the user to see this! */
+ fprintf (stderr,
+ "ATTENTION: default value of option %s overridden by environment.\n",
+ cache->info[opt].name);
+ } else
+ defaultVal = attrVal[OA_DEFAULT];
+ if (!parseValue (&cache->values[opt], cache->info[opt].type, defaultVal))
+ XML_FATAL ("illegal default value: %s.", defaultVal);
+
+ if (attrVal[OA_VALID]) {
+ if (cache->info[opt].type == DRI_BOOL)
+ XML_FATAL1 ("boolean option with valid attribute.");
+ if (!parseRanges (&cache->info[opt], attrVal[OA_VALID]))
+ XML_FATAL ("illegal valid attribute: %s.", attrVal[OA_VALID]);
+ if (!checkValue (&cache->values[opt], &cache->info[opt]))
+ XML_FATAL ("default value out of valid range '%s': %s.",
+ attrVal[OA_VALID], defaultVal);
+ } else if (cache->info[opt].type == DRI_ENUM) {
+ XML_FATAL1 ("valid attribute missing in option (mandatory for enums).");
+ } else {
+ cache->info[opt].nRanges = 0;
+ cache->info[opt].ranges = NULL;
+ }
+}
+
+/** \brief Handler for start element events. */
+static void optInfoStartElem (void *userData, const XML_Char *name,
+ const XML_Char **attr) {
+ struct OptInfoData *data = (struct OptInfoData *)userData;
+ enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT);
+ switch (elem) {
+ case OI_DRIINFO:
+ if (data->inDriInfo)
+ XML_FATAL1 ("nested <driinfo> elements.");
+ if (attr[0])
+ XML_FATAL1 ("attributes specified on <driinfo> element.");
+ data->inDriInfo = GL_TRUE;
+ break;
+ case OI_SECTION:
+ if (!data->inDriInfo)
+ XML_FATAL1 ("<section> must be inside <driinfo>.");
+ if (data->inSection)
+ XML_FATAL1 ("nested <section> elements.");
+ if (attr[0])
+ XML_FATAL1 ("attributes specified on <section> element.");
+ data->inSection = GL_TRUE;
+ break;
+ case OI_DESCRIPTION:
+ if (!data->inSection && !data->inOption)
+ XML_FATAL1 ("<description> must be inside <description> or <option.");
+ if (data->inDesc)
+ XML_FATAL1 ("nested <description> elements.");
+ data->inDesc = GL_TRUE;
+ parseDescAttr (data, attr);
+ break;
+ case OI_OPTION:
+ if (!data->inSection)
+ XML_FATAL1 ("<option> must be inside <section>.");
+ if (data->inDesc)
+ XML_FATAL1 ("<option> nested in <description> element.");
+ if (data->inOption)
+ XML_FATAL1 ("nested <option> elements.");
+ data->inOption = GL_TRUE;
+ parseOptInfoAttr (data, attr);
+ break;
+ case OI_ENUM:
+ if (!(data->inOption && data->inDesc))
+ XML_FATAL1 ("<enum> must be inside <option> and <description>.");
+ if (data->inEnum)
+ XML_FATAL1 ("nested <enum> elements.");
+ data->inEnum = GL_TRUE;
+ parseEnumAttr (data, attr);
+ break;
+ default:
+ XML_FATAL ("unknown element: %s.", name);
+ }
+}
+
+/** \brief Handler for end element events. */
+static void optInfoEndElem (void *userData, const XML_Char *name) {
+ struct OptInfoData *data = (struct OptInfoData *)userData;
+ enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT);
+ switch (elem) {
+ case OI_DRIINFO:
+ data->inDriInfo = GL_FALSE;
+ break;
+ case OI_SECTION:
+ data->inSection = GL_FALSE;
+ break;
+ case OI_DESCRIPTION:
+ data->inDesc = GL_FALSE;
+ break;
+ case OI_OPTION:
+ data->inOption = GL_FALSE;
+ break;
+ case OI_ENUM:
+ data->inEnum = GL_FALSE;
+ break;
+ default:
+ assert (0); /* should have been caught by StartElem */
+ }
+}
+
+void driParseOptionInfo (driOptionCache *info) {
+ XML_Parser p;
+ int status;
+ struct OptInfoData userData;
+ struct OptInfoData *data = &userData;
+ GLuint nOptions;
+
+ /* determine hash table size and allocate memory */
+ GLuint size, log2size;
+ for (size = 1, log2size = 0; size < __driNConfigOptions*3/2;
+ size <<= 1, ++log2size);
+ info->tableSize = log2size;
+ info->info = CALLOC (size * sizeof (driOptionInfo));
+ info->values = CALLOC (size * sizeof (driOptionInfo));
+ if (info->info == NULL || info->values == NULL) {
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
+ abort();
+ }
+
+ p = XML_ParserCreate ("UTF-8"); /* always UTF-8 */
+ XML_SetElementHandler (p, optInfoStartElem, optInfoEndElem);
+ XML_SetUserData (p, data);
+
+ userData.name = "__driConfigOptions";
+ userData.parser = p;
+ userData.cache = info;
+ userData.inDriInfo = GL_FALSE;
+ userData.inSection = GL_FALSE;
+ userData.inDesc = GL_FALSE;
+ userData.inOption = GL_FALSE;
+ userData.inEnum = GL_FALSE;
+ userData.curOption = -1;
+
+ status = XML_Parse (p, __driConfigOptions, strlen (__driConfigOptions), 1);
+ if (!status)
+ XML_FATAL ("%s.", XML_ErrorString(XML_GetErrorCode(p)));
+
+ XML_ParserFree (p);
+
+ /* Check if the actual number of options matches __driNConfigOptions.
+ * A mismatch is not fatal (a hash table overflow would be) but we
+ * want the driver developer's attention anyway. */
+ nOptions = countOptions (info);
+ if (nOptions != __driNConfigOptions) {
+ fprintf (stderr,
+ "Error: __driNConfigOptions (%u) does not match the actual number of options in\n"
+ " __driConfigOptions (%u).\n",
+ __driNConfigOptions, nOptions);
+ }
+}
+
+/** \brief Parser context for configuration files. */
+struct OptConfData {
+ const char *name;
+ XML_Parser parser;
+ driOptionCache *cache;
+ GLint screenNum;
+ const char *driverName, *execName;
+ GLuint ignoringDevice;
+ GLuint ignoringApp;
+ GLuint inDriConf;
+ GLuint inDevice;
+ GLuint inApp;
+ GLuint inOption;
+};
+
+/** \brief Elements in configuration files. */
+enum OptConfElem {
+ OC_APPLICATION = 0, OC_DEVICE, OC_DRICONF, OC_OPTION, OC_COUNT
+};
+static const XML_Char *OptConfElems[] = {
+ "application", "device", "driconf", "option"
+};
+
+/** \brief Parse attributes of a device element. */
+static void parseDeviceAttr (struct OptConfData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *driver = NULL, *screen = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "driver")) driver = attr[i+1];
+ else if (!strcmp (attr[i], "screen")) screen = attr[i+1];
+ else XML_WARNING("unkown device attribute: %s.", attr[i]);
+ }
+ if (driver && strcmp (driver, data->driverName))
+ data->ignoringDevice = data->inDevice;
+ else if (screen) {
+ driOptionValue screenNum;
+ if (!parseValue (&screenNum, DRI_INT, screen))
+ XML_WARNING("illegal screen number: %s.", screen);
+ else if (screenNum._int != data->screenNum)
+ data->ignoringDevice = data->inDevice;
+ }
+}
+
+/** \brief Parse attributes of an application element. */
+static void parseAppAttr (struct OptConfData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *name = NULL, *exec = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "name")) name = attr[i+1];
+ else if (!strcmp (attr[i], "executable")) exec = attr[i+1];
+ else XML_WARNING("unkown application attribute: %s.", attr[i]);
+ }
+ if (exec && strcmp (exec, data->execName))
+ data->ignoringApp = data->inApp;
+}
+
+/** \brief Parse attributes of an option element. */
+static void parseOptConfAttr (struct OptConfData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *name = NULL, *value = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "name")) name = attr[i+1];
+ else if (!strcmp (attr[i], "value")) value = attr[i+1];
+ else XML_WARNING("unkown option attribute: %s.", attr[i]);
+ }
+ if (!name) XML_WARNING1 ("name attribute missing in option.");
+ if (!value) XML_WARNING1 ("value attribute missing in option.");
+ if (name && value) {
+ driOptionCache *cache = data->cache;
+ GLuint opt = findOption (cache, name);
+ if (cache->info[opt].name == NULL)
+ XML_WARNING ("undefined option: %s.", name);
+ else if (getenv (cache->info[opt].name))
+ /* don't use XML_WARNING, we want the user to see this! */
+ fprintf (stderr, "ATTENTION: option value of option %s ignored.\n",
+ cache->info[opt].name);
+ else if (!parseValue (&cache->values[opt], cache->info[opt].type, value))
+ XML_WARNING ("illegal option value: %s.", value);
+ }
+}
+
+/** \brief Handler for start element events. */
+static void optConfStartElem (void *userData, const XML_Char *name,
+ const XML_Char **attr) {
+ struct OptConfData *data = (struct OptConfData *)userData;
+ enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT);
+ switch (elem) {
+ case OC_DRICONF:
+ if (data->inDriConf)
+ XML_WARNING1 ("nested <driconf> elements.");
+ if (attr[0])
+ XML_WARNING1 ("attributes specified on <driconf> element.");
+ data->inDriConf++;
+ break;
+ case OC_DEVICE:
+ if (!data->inDriConf)
+ XML_WARNING1 ("<device> should be inside <driconf>.");
+ if (data->inDevice)
+ XML_WARNING1 ("nested <device> elements.");
+ data->inDevice++;
+ if (!data->ignoringDevice && !data->ignoringApp)
+ parseDeviceAttr (data, attr);
+ break;
+ case OC_APPLICATION:
+ if (!data->inDevice)
+ XML_WARNING1 ("<application> should be inside <device>.");
+ if (data->inApp)
+ XML_WARNING1 ("nested <application> elements.");
+ data->inApp++;
+ if (!data->ignoringDevice && !data->ignoringApp)
+ parseAppAttr (data, attr);
+ break;
+ case OC_OPTION:
+ if (!data->inApp)
+ XML_WARNING1 ("<option> should be inside <application>.");
+ if (data->inOption)
+ XML_WARNING1 ("nested <option> elements.");
+ data->inOption++;
+ if (!data->ignoringDevice && !data->ignoringApp)
+ parseOptConfAttr (data, attr);
+ break;
+ default:
+ XML_WARNING ("unknown element: %s.", name);
+ }
+}
+
+/** \brief Handler for end element events. */
+static void optConfEndElem (void *userData, const XML_Char *name) {
+ struct OptConfData *data = (struct OptConfData *)userData;
+ enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT);
+ switch (elem) {
+ case OC_DRICONF:
+ data->inDriConf--;
+ break;
+ case OC_DEVICE:
+ if (data->inDevice-- == data->ignoringDevice)
+ data->ignoringDevice = 0;
+ break;
+ case OC_APPLICATION:
+ if (data->inApp-- == data->ignoringApp)
+ data->ignoringApp = 0;
+ break;
+ case OC_OPTION:
+ data->inOption--;
+ break;
+ default:
+ /* unknown element, warning was produced on start tag */;
+ }
+}
+
+/** \brief Initialize an option cache based on info */
+static void initOptionCache (driOptionCache *cache, driOptionCache *info) {
+ cache->info = info->info;
+ cache->tableSize = info->tableSize;
+ cache->values = MALLOC ((1<<info->tableSize) * sizeof (driOptionValue));
+ if (cache->values == NULL) {
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
+ abort();
+ }
+ memcpy (cache->values, info->values,
+ (1<<info->tableSize) * sizeof (driOptionValue));
+}
+
+/** \brief Parse the named configuration file */
+static void parseOneConfigFile (XML_Parser p) {
+#define BUF_SIZE 0x1000
+ struct OptConfData *data = (struct OptConfData *)XML_GetUserData (p);
+ int status;
+ int fd;
+
+ if ((fd = open (data->name, O_RDONLY)) == -1) {
+ __driUtilMessage ("Can't open configuration file %s: %s.",
+ data->name, strerror (errno));
+ return;
+ }
+
+ while (1) {
+ int bytesRead;
+ void *buffer = XML_GetBuffer (p, BUF_SIZE);
+ if (!buffer) {
+ __driUtilMessage ("Can't allocate parser buffer.");
+ break;
+ }
+ bytesRead = read (fd, buffer, BUF_SIZE);
+ if (bytesRead == -1) {
+ __driUtilMessage ("Error reading from configuration file %s: %s.",
+ data->name, strerror (errno));
+ break;
+ }
+ status = XML_ParseBuffer (p, bytesRead, bytesRead == 0);
+ if (!status) {
+ XML_ERROR ("%s.", XML_ErrorString(XML_GetErrorCode(p)));
+ break;
+ }
+ if (bytesRead == 0)
+ break;
+ }
+
+ close (fd);
+#undef BUF_SIZE
+}
+
+void driParseConfigFiles (driOptionCache *cache, driOptionCache *info,
+ GLint screenNum, const char *driverName) {
+ char *filenames[2] = {"/etc/drirc", NULL};
+ char *home;
+ GLuint i;
+ struct OptConfData userData;
+
+ initOptionCache (cache, info);
+
+ userData.cache = cache;
+ userData.screenNum = screenNum;
+ userData.driverName = driverName;
+#ifndef _SOLO
+ userData.execName = GET_PROGRAM_NAME();
+#else
+ userData.execName = "Solo";
+#endif
+
+ if ((home = getenv ("HOME"))) {
+ GLuint len = strlen (home);
+ filenames[1] = MALLOC (len + 7+1);
+ if (filenames[1] == NULL)
+ __driUtilMessage ("Can't allocate memory for %s/.drirc.", home);
+ else {
+ memcpy (filenames[1], home, len);
+ memcpy (filenames[1] + len, "/.drirc", 7+1);
+ }
+ }
+
+ for (i = 0; i < 2; ++i) {
+ XML_Parser p;
+ if (filenames[i] == NULL)
+ continue;
+
+ p = XML_ParserCreate (NULL); /* use encoding specified by file */
+ XML_SetElementHandler (p, optConfStartElem, optConfEndElem);
+ XML_SetUserData (p, &userData);
+ userData.parser = p;
+ userData.name = filenames[i];
+ userData.ignoringDevice = 0;
+ userData.ignoringApp = 0;
+ userData.inDriConf = 0;
+ userData.inDevice = 0;
+ userData.inApp = 0;
+ userData.inOption = 0;
+
+ parseOneConfigFile (p);
+ XML_ParserFree (p);
+ }
+
+ if (filenames[1])
+ FREE (filenames[1]);
+}
+
+void driDestroyOptionInfo (driOptionCache *info) {
+ driDestroyOptionCache (info);
+ if (info->info) {
+ GLuint i, size = 1 << info->tableSize;
+ for (i = 0; i < size; ++i) {
+ if (info->info[i].name) {
+ FREE (info->info[i].name);
+ if (info->info[i].ranges)
+ FREE (info->info[i].ranges);
+ }
+ }
+ FREE (info->info);
+ }
+}
+
+void driDestroyOptionCache (driOptionCache *cache) {
+ if (cache->values)
+ FREE (cache->values);
+}
+
+GLboolean driCheckOption (const driOptionCache *cache, const char *name,
+ driOptionType type) {
+ GLuint i = findOption (cache, name);
+ return cache->info[i].name != NULL && cache->info[i].type == type;
+}
+
+GLboolean driQueryOptionb (const driOptionCache *cache, const char *name) {
+ GLuint i = findOption (cache, name);
+ /* make sure the option is defined and has the correct type */
+ assert (cache->info[i].name != NULL);
+ assert (cache->info[i].type == DRI_BOOL);
+ return cache->values[i]._bool;
+}
+
+GLint driQueryOptioni (const driOptionCache *cache, const char *name) {
+ GLuint i = findOption (cache, name);
+ /* make sure the option is defined and has the correct type */
+ assert (cache->info[i].name != NULL);
+ assert (cache->info[i].type == DRI_INT || cache->info[i].type == DRI_ENUM);
+ return cache->values[i]._int;
+}
+
+GLfloat driQueryOptionf (const driOptionCache *cache, const char *name) {
+ GLuint i = findOption (cache, name);
+ /* make sure the option is defined and has the correct type */
+ assert (cache->info[i].name != NULL);
+ assert (cache->info[i].type == DRI_FLOAT);
+ return cache->values[i]._float;
+}
--- /dev/null
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+/**
+ * \file xmlconfig.h
+ * \brief Driver-independent client-side part of the XML configuration
+ * \author Felix Kuehling
+ */
+
+#ifndef __XMLCONFIG_H
+#define __XMLCONFIG_H
+
+/** \brief Option data types */
+typedef enum driOptionType {
+ DRI_BOOL, DRI_ENUM, DRI_INT, DRI_FLOAT
+} driOptionType;
+
+/** \brief Option value */
+typedef union driOptionValue {
+ GLboolean _bool; /**< \brief Boolean */
+ GLint _int; /**< \brief Integer or Enum */
+ GLfloat _float; /**< \brief Floating-point */
+} driOptionValue;
+
+/** \brief Single range of valid values
+ *
+ * For empty ranges (a single value) start == end */
+typedef struct driOptionRange {
+ driOptionValue start; /**< \brief Start */
+ driOptionValue end; /**< \brief End */
+} driOptionRange;
+
+/** \brief Information about an option */
+typedef struct driOptionInfo {
+ char *name; /**< \brief Name */
+ driOptionType type; /**< \brief Type */
+ driOptionRange *ranges; /**< \brief Array of ranges */
+ GLuint nRanges; /**< \brief Number of ranges */
+} driOptionInfo;
+
+/** \brief Option cache
+ *
+ * \li One in <driver>Screen caching option info and the default values
+ * \li One in each <driver>Context with the actual values for that context */
+typedef struct driOptionCache {
+ driOptionInfo *info;
+ /**< \brief Array of option infos
+ *
+ * Points to the same array in the screen and all contexts */
+ driOptionValue *values;
+ /**< \brief Array of option values
+ *
+ * \li Default values in screen
+ * \li Actual values in contexts
+ */
+ GLuint tableSize;
+ /**< \brief Size of the arrays
+ *
+ * Depending on the hash function this may differ from __driNConfigOptions.
+ * In the current implementation it's not actually a size but log2(size).
+ * The value is the same in the screen and all contexts. */
+} driOptionCache;
+
+/** \brief XML document describing available options
+ *
+ * This must be defined in a driver-specific soure file. xmlpool.h
+ * defines helper macros and common options. */
+extern const char __driConfigOptions[];
+/** \brief The number of options supported by a driver
+ *
+ * This is used to choose an appropriate hash table size. So any value
+ * larger than the actual number of options will work. */
+extern const GLuint __driNConfigOptions;
+
+/** \brief Parse XML option info from __driConfigOptions
+ *
+ * To be called in <driver>CreateScreen */
+void driParseOptionInfo (driOptionCache *info);
+/** \brief Initialize option cache from info and parse configuration files
+ *
+ * To be called in <driver>CreateContext. screenNum and driverName select
+ * device sections. */
+void driParseConfigFiles (driOptionCache *cache, driOptionCache *info,
+ GLint screenNum, const char *driverName);
+/** \brief Destroy option info
+ *
+ * To be called in <driver>DestroyScreen */
+void driDestroyOptionInfo (driOptionCache *info);
+/** \brief Destroy option cache
+ *
+ * To be called in <driver>DestroyContext */
+void driDestroyOptionCache (driOptionCache *cache);
+
+/** \brief Check if there exists a certain option */
+GLboolean driCheckOption (const driOptionCache *cache, const char *name,
+ driOptionType type);
+
+/** \brief Query a boolean option value */
+GLboolean driQueryOptionb (const driOptionCache *cache, const char *name);
+/** \brief Query an integer option value */
+GLint driQueryOptioni (const driOptionCache *cache, const char *name);
+/** \brief Query a floating-point option value */
+GLfloat driQueryOptionf (const driOptionCache *cache, const char *name);
+
+#endif
--- /dev/null
+/* -*- mode:C; coding: mult-utf-8-unix -*-
+ *
+ * !!! Important: This file is encoded in UTF-8 !!!
+ *
+ * Note (Emacs): You need Mule. In Debian the package is called
+ * mule-ucs.
+ *
+ * Note (Emacs): You may have to enable multibyte characters in the
+ * Mule customization group or by setting
+ * default-enable-multibyte-characters to t in your .emacs:
+ */
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+/**
+ * \file xmlpool.h
+ * \brief Pool of common options
+ * \author Felix Kuehling
+ *
+ * This file defines macros that can be used to construct driConfigOptions
+ * in the drivers.
+ */
+
+#ifndef __XMLPOOL_H
+#define __XMLPOOL_H
+
+/*
+ * generic macros
+ */
+
+/** \brief Begin __driConfigOptions */
+#define DRI_CONF_BEGIN \
+"<driinfo>\n"
+
+/** \brief End __driConfigOptions */
+#define DRI_CONF_END \
+"</driinfo>\n"
+
+/** \brief Begin a section of related options */
+#define DRI_CONF_SECTION_BEGIN \
+"<section>\n"
+
+/** \brief End a section of related options */
+#define DRI_CONF_SECTION_END \
+"</section>\n"
+
+/** \brief Begin an option definition */
+#define DRI_CONF_OPT_BEGIN(name,type,def) \
+"<option name=\""#name"\" type=\""#type"\" default=\""#def"\">\n"
+
+/** \brief Begin an option definition with restrictions on valid values */
+#define DRI_CONF_OPT_BEGIN_V(name,type,def,valid) \
+"<option name=\""#name"\" type=\""#type"\" default=\""#def"\" valid=\""valid"\">\n"
+
+/** \brief End an option description */
+#define DRI_CONF_OPT_END \
+"</option>\n"
+
+/** \brief A verbal description in a specified language (empty version) */
+#define DRI_CONF_DESC(lang,text) \
+"<description lang=\""#lang"\" text=\""text"\"/>\n"
+
+/** \brief A verbal description in a specified language */
+#define DRI_CONF_DESC_BEGIN(lang,text) \
+"<description lang=\""#lang"\" text=\""text"\">\n"
+
+/** \brief End a description */
+#define DRI_CONF_DESC_END \
+"</description>\n"
+
+/** \brief A verbal description of an enum value */
+#define DRI_CONF_ENUM(value,text) \
+"<enum value=\""#value"\" text=\""text"\"/>\n"
+
+/*
+ * predefined option sections and options with multi-lingual descriptions
+ */
+
+/** \brief Debugging options */
+#define DRI_CONF_SECTION_DEBUG \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,"Debugging") \
+ DRI_CONF_DESC(de,"Fehlersuche")
+
+#define DRI_CONF_NO_RAST(def) \
+DRI_CONF_OPT_BEGIN(no_rast,bool,def) \
+ DRI_CONF_DESC(en,"Disable 3D acceleration") \
+ DRI_CONF_DESC(de,"3D-Beschleunigung abschalten") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_PERFORMANCE_BOXES(def) \
+DRI_CONF_OPT_BEGIN(performance_boxes,bool,def) \
+ DRI_CONF_DESC(en,"Show performance boxes") \
+ DRI_CONF_DESC(de,"Zeige Performanceboxen") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_DEBUG_DMA(def) \
+DRI_CONF_OPT_BEGIN(debug_dma,bool,def) \
+ DRI_CONF_DESC(en,"Debug DMA buffers") \
+ DRI_CONF_DESC(de,"DMA Puffer debuggen") \
+DRI_CONF_OPT_END
+
+
+/** \brief Texture-related options */
+#define DRI_CONF_SECTION_QUALITY \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,"Image Quality") \
+ DRI_CONF_DESC(de,"Bildqualität")
+
+#define DRI_CONF_PREFERRED_BPT(def,valid) \
+DRI_CONF_OPT_BEGIN_V(preferred_bpt,enum,def,valid) \
+ DRI_CONF_DESC_BEGIN(en,"Preferred texture color depth") \
+ DRI_CONF_ENUM(0,"Same as frame buffer") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Bevorzugte Textur Farbtiefe") \
+ DRI_CONF_ENUM(0,"So wie der Framebuffer") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+/** \brief Performance-related options */
+#define DRI_CONF_SECTION_PERFORMANCE \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,"Performance") \
+ DRI_CONF_DESC(de,"Leistung")
+
+#define DRI_CONF_TCL_SW 0
+#define DRI_CONF_TCL_PIPELINED 1
+#define DRI_CONF_TCL_VTXFMT 2
+#define DRI_CONF_TCL_CODEGEN 3
+#define DRI_CONF_TCL_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(tcl_mode,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,"TCL mode (Transformation, Clipping, Lighting)") \
+ DRI_CONF_ENUM(0,"Software") \
+ DRI_CONF_ENUM(1,"TCL stage in MESA pipeline") \
+ DRI_CONF_ENUM(2,"Bypass MESA's pipeline") \
+ DRI_CONF_ENUM(3,"Bypass MESA's pipeline with state-based code generation") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"TCL Modus (Transformation, Clipping, Licht)") \
+ DRI_CONF_ENUM(0,"Software") \
+ DRI_CONF_ENUM(1,"TCL Stufe in MESA Pipeline") \
+ DRI_CONF_ENUM(2,"Umgehe MESA's Pipeline") \
+ DRI_CONF_ENUM(3,"Umgehe MESA's Pipeline mit zustandsbasierter Codegenerierung") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_FTHROTTLE_BUSY 0
+#define DRI_CONF_FTHROTTLE_USLEEPS 1
+#define DRI_CONF_FTHROTTLE_IRQS 2
+#define DRI_CONF_FTHROTTLE_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(fthrottle_mode,enum,def,"0:2") \
+ DRI_CONF_DESC_BEGIN(en,"Frame throttling") \
+ DRI_CONF_ENUM(0,"Busy waiting") \
+ DRI_CONF_ENUM(1,"Usleeps") \
+ DRI_CONF_ENUM(2,"Software interrupts") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Framethrottling") \
+ DRI_CONF_ENUM(0,"Aktives Warten") \
+ DRI_CONF_ENUM(1,"Usleeps") \
+ DRI_CONF_ENUM(2,"Sortware Interrutps") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_VBLANK_NEVER 0
+#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
+#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
+#define DRI_CONF_VBLANK_ALWAYS_SYNC 3
+#define DRI_CONF_VBLANK_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(vblank_mode,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,"Synchronization with vertical refresh (swap intervals)") \
+ DRI_CONF_ENUM(0,"Never, FPS rulez!") \
+ DRI_CONF_ENUM(1,"Application preference, default interval 0") \
+ DRI_CONF_ENUM(2,"Application preference, default interval 1") \
+ DRI_CONF_ENUM(3,"Application preference, always synchronize with refresh") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Synchronisation mit dem vertikalen Bildaufbau (swap intervals)") \
+ DRI_CONF_ENUM(0,"Niemals, immer die maximale Framerate") \
+ DRI_CONF_ENUM(1,"Anwendung entscheidet, Standardinterval 0") \
+ DRI_CONF_ENUM(2,"Anwendung entscheidet, Standardinterval 1") \
+ DRI_CONF_ENUM(3,"Anwendung entscheidet, immer mit Bildaufbau synchronisieren") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#endif
-# $Id: Makefile.X11,v 1.4 2003/10/20 02:17:33 jonsmirl Exp $
+# $Id: Makefile.X11,v 1.5 2003/10/21 06:05:41 jonsmirl Exp $
# Mesa 3-D graphics library
# Version: 5.0
../common/mm.c \
../common/utils.c \
../common/texmem.c \
- ../common/vblank.c
+ ../common/vblank.c \
+ ../common/xmlconfig.c
FULL_DRIVER_SOURCES = \
mgapixel.c \
mgatex.c \
mgatexmem.c \
mga_texstate.c \
+ mga_texcombine.c \
mgavb.c \
mga_xmesa.c
--- /dev/null
+/*
+ * Copyright (c) 2003 Ville Syrjala
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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:
+ * Ville Syrjala <syrjala@sci.fi>
+ */
+
+#include "glheader.h"
+
+#include "mgacontext.h"
+#include "mgatex.h"
+#include "mgaregs.h"
+
+/*
+ * GL_ARB_texture_env_combine
+ * GL_EXT_texture_env_combine
+ * GL_ARB_texture_env_crossbar
+ * GL_ATI_texture_env_combine3
+ */
+
+#define ARG_DISABLE 0xffffffff
+#define MGA_ARG1 0
+#define MGA_ARG2 1
+#define MGA_ALPHA 2
+
+GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
+ GLuint numColorArgs = 0, numAlphaArgs = 0;
+ GLuint arg1[3], arg2[3], alpha[3];
+ int args[3];
+ int i;
+
+ switch (texUnit->CombineModeRGB) {
+ case GL_REPLACE:
+ numColorArgs = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ numColorArgs = 2;
+ break;
+ case GL_INTERPOLATE:
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ numColorArgs = 3;
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch (texUnit->CombineModeA) {
+ case GL_REPLACE:
+ numAlphaArgs = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ numAlphaArgs = 2;
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ /* Start fresh :) */
+ *reg = 0;
+
+ /* COLOR */
+ for (i = 0; i < 3; i++) {
+ arg1[i] = 0;
+ arg2[i] = 0;
+ alpha[i] = 0;
+ }
+
+ for (i = 0;i < numColorArgs; i++) {
+ switch (texUnit->CombineSourceRGB[i]) {
+ case GL_TEXTURE:
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_currtex;
+ break;
+ case GL_TEXTURE0:
+ if (source == 0) {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_currtex;
+ } else {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_prevtex;
+ }
+ break;
+ case GL_TEXTURE1:
+ if (source == 0) {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE0) */
+ arg2[i] |= TD0_color_arg2_prevstage;
+ alpha[i] |= TD0_color_alpha_prevstage;
+ } else {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_currtex;
+ }
+ break;
+ case GL_CONSTANT:
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= TD0_color_arg2_fcol;
+ alpha[i] |= TD0_color_alpha_fcol;
+ break;
+ case GL_PRIMARY_COLOR:
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE1) */
+ if (unit == 0 || (mmesa->setup.tdualstage0 &
+ ((TD0_color_sel_mul & TD0_color_sel_add) |
+ (TD0_alpha_sel_mul & TD0_alpha_sel_add)))) {
+ arg2[i] |= TD0_color_arg2_diffuse;
+ alpha[i] |= TD0_color_alpha_diffuse;
+ } else {
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_PREVIOUS:
+ arg1[i] |= ARG_DISABLE;
+ if (unit == 0) {
+ arg2[i] |= TD0_color_arg2_diffuse;
+ alpha[i] |= TD0_color_alpha_diffuse;
+ } else {
+ arg2[i] |= TD0_color_arg2_prevstage;
+ alpha[i] |= TD0_color_alpha_prevstage;
+ }
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch (texUnit->CombineOperandRGB[i]) {
+ case GL_SRC_COLOR:
+ arg1[i] |= 0;
+ arg2[i] |= 0;
+ alpha[i] |= ARG_DISABLE;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ arg1[i] |= TD0_color_arg1_inv_enable;
+ arg2[i] |= TD0_color_arg2_inv_enable;
+ alpha[i] |= ARG_DISABLE;
+ break;
+ case GL_SRC_ALPHA:
+ arg1[i] |= TD0_color_arg1_replicatealpha_enable;
+ arg2[i] |= TD0_color_arg2_replicatealpha_enable;
+ alpha[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ arg1[i] |= (TD0_color_arg1_replicatealpha_enable |
+ TD0_color_arg1_inv_enable);
+ arg2[i] |= (TD0_color_arg2_replicatealpha_enable |
+ TD0_color_arg2_inv_enable);
+ alpha[i] |= (TD0_color_alpha1inv_enable |
+ TD0_color_alpha2inv_enable);
+ break;
+ }
+ }
+
+ switch (texUnit->CombineModeRGB) {
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ /* Special handling for ATI_texture_env_combine3.
+ * If Arg1 == Arg0 or Arg1 == Arg2 we can use arg1 or arg2 as input for
+ * both multiplier and adder.
+ */
+ /* Arg1 == arg1 */
+ if (arg1[1] == arg1[0]) {
+ if ((arg1[1] | arg2[2]) != ARG_DISABLE) {
+ *reg |= arg1[1] | arg2[2];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG1; args[2] = MGA_ARG2;
+ break;
+ } else
+ if ((arg1[1] | alpha[2]) != ARG_DISABLE) {
+ *reg |= arg1[1] | alpha[2];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG1; args[2] = MGA_ALPHA;
+ break;
+ }
+ }
+ if (arg1[1] == arg1[2]) {
+ if ((arg1[1] | arg2[0]) != ARG_DISABLE) {
+ *reg |= arg1[1] | arg2[0];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG1; args[2] = MGA_ARG1;
+ break;
+ } else
+ if ((arg1[1] | alpha[0]) != ARG_DISABLE) {
+ *reg |= arg1[1] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG1; args[2] = MGA_ARG1;
+ break;
+ }
+ }
+ /* fallthrough */
+ case GL_MODULATE_SUBTRACT_ATI:
+ /* Arg1 == arg2 */
+ if (arg2[1] == arg2[0]) {
+ if ((arg2[1] | arg1[2]) != ARG_DISABLE) {
+ *reg |= arg2[1] | arg1[2];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG2; args[2] = MGA_ARG1;
+ break;
+ } else
+ if ((arg2[1] | alpha[2]) != ARG_DISABLE) {
+ *reg |= arg2[1] | alpha[2];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG2; args[2] = MGA_ALPHA;
+ break;
+ }
+ }
+ if (arg2[1] == arg2[2]) {
+ if ((arg2[1] | arg1[0]) != ARG_DISABLE) {
+ *reg |= arg2[1] | arg1[0];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG2; args[2] = MGA_ARG2;
+ break;
+ } else
+ if ((arg2[1] | alpha[0]) != ARG_DISABLE) {
+ *reg |= arg2[1] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG2; args[2] = MGA_ARG2;
+ break;
+ }
+ }
+ /* fallthrough */
+ default:
+ /* Find working combo of arg1, arg2 and alpha.
+ *
+ * Keep the Arg0 != alpha cases first since there's
+ * no way to get alpha out by itself (GL_REPLACE).
+ *
+ * Keep the Arg2 == alpha cases first because only alpha has the
+ * capabilities to function as Arg2 (GL_INTERPOLATE). Also good for
+ * GL_ADD, GL_ADD_SIGNED, GL_SUBTRACT since we can't get alpha to the
+ * adder.
+ *
+ * Keep the Arg1 == alpha cases last for GL_MODULATE_ADD_ATI,
+ * GL_MODULATE_SIGNED_ADD_ATI. Again because we can't get alpha to the
+ * adder.
+ *
+ * GL_MODULATE_SUBTRACT_ATI needs special treatment since it requires
+ * that Arg1 == arg2. This requirement clashes with those of other modes.
+ */
+ if ((arg1[0] | arg2[1] | alpha[2]) != ARG_DISABLE) {
+ *reg |= arg1[0] | arg2[1] | alpha[2];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG2; args[2] = MGA_ALPHA;
+ } else
+ if ((arg1[1] | arg2[0] | alpha[2]) != ARG_DISABLE &&
+ texUnit->CombineModeRGB != GL_MODULATE_SUBTRACT_ATI) {
+ *reg |= arg1[1] | arg2[0] | alpha[2];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG1; args[2] = MGA_ALPHA;
+ } else
+ if ((arg1[1] | arg2[2] | alpha[0]) != ARG_DISABLE &&
+ texUnit->CombineModeRGB != GL_MODULATE_SUBTRACT_ATI) {
+ *reg |= arg1[1] | arg2[2] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG1; args[2] = MGA_ARG2;
+ } else
+ if ((arg1[2] | arg2[1] | alpha[0]) != ARG_DISABLE) {
+ *reg |= arg1[2] | arg2[1] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG2; args[2] = MGA_ARG1;
+ } else
+ if ((arg1[0] | arg2[2] | alpha[1]) != ARG_DISABLE) {
+ *reg |= arg1[0] | arg2[2] | alpha[1];
+ args[0] = MGA_ARG1; args[1] = MGA_ALPHA; args[2] = MGA_ARG2;
+ } else
+ if ((arg1[2] | arg2[0] | alpha[1]) != ARG_DISABLE) {
+ *reg |= arg1[2] | arg2[0] | alpha[1];
+ args[0] = MGA_ARG2; args[1] = MGA_ALPHA; args[2] = MGA_ARG1;
+ } else {
+ /* nothing suitable */
+ return GL_FALSE;
+ }
+ }
+
+ switch (texUnit->CombineModeRGB) {
+ case GL_REPLACE:
+ if (texUnit->CombineScaleShiftRGB) {
+ return GL_FALSE;
+ }
+
+ if (args[0] == MGA_ARG1) {
+ *reg |= TD0_color_sel_arg1;
+ } else if (args[0] == MGA_ARG2) {
+ *reg |= TD0_color_sel_arg2;
+ } else if (args[0] == MGA_ALPHA) {
+ /* Can't get alpha out by itself */
+ return GL_FALSE;
+ }
+ break;
+ case GL_MODULATE:
+ if (texUnit->CombineScaleShiftRGB == 1) {
+ *reg |= TD0_color_modbright_2x;
+ } else if (texUnit->CombineScaleShiftRGB == 2) {
+ *reg |= TD0_color_modbright_4x;
+ }
+
+ *reg |= TD0_color_sel_mul;
+
+ if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) {
+ if (args[0] == MGA_ARG1 || args[1] == MGA_ARG1) {
+ *reg |= TD0_color_arg2mul_alpha2;
+ } else if (args[0] == MGA_ARG2 || args[1] == MGA_ARG2) {
+ *reg |= TD0_color_arg1mul_alpha1;
+ }
+ }
+ break;
+ case GL_ADD_SIGNED:
+ *reg |= TD0_color_addbias_enable;
+ /* fallthrough */
+ case GL_ADD:
+ if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA){
+ /* Can't get alpha to the adder */
+ return GL_FALSE;
+ }
+ if (texUnit->CombineScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->CombineScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_add |
+ TD0_color_sel_add);
+ break;
+ case GL_INTERPOLATE:
+ if (args[2] != MGA_ALPHA) {
+ /* Only alpha can function as Arg2 */
+ return GL_FALSE;
+ }
+ if (texUnit->CombineScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->CombineScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_arg1mul_alpha1 |
+ TD0_color_blend_enable |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_add);
+
+ /* Have to do this with xor since GL_ONE_MINUS_SRC_ALPHA may have
+ * already touched this bit.
+ */
+ *reg ^= TD0_color_alpha1inv_enable;
+
+ if (args[0] == MGA_ARG2) {
+ /* Swap arguments */
+ *reg ^= (TD0_color_arg1mul_alpha1 |
+ TD0_color_arg2mul_alpha2 |
+ TD0_color_alpha1inv_enable |
+ TD0_color_alpha2inv_enable);
+ }
+
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* Linear blending mode needs dualtex enabled */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ mmesa->dualtex_env = GL_TRUE;
+ }
+ break;
+ case GL_SUBTRACT:
+ if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) {
+ /* Can't get alpha to the adder */
+ return GL_FALSE;
+ }
+ if (texUnit->CombineScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->CombineScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_sub |
+ TD0_color_sel_add);
+
+ if (args[0] == MGA_ARG2) {
+ /* Swap arguments */
+ *reg ^= (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_inv_enable);
+ }
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ *reg |= TD0_color_addbias_enable;
+ /* fallthrough */
+ case GL_MODULATE_ADD_ATI:
+ if (args[1] == MGA_ALPHA) {
+ /* Can't get alpha to the adder */
+ return GL_FALSE;
+ }
+ if (texUnit->CombineScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->CombineScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_add |
+ TD0_color_sel_add);
+
+ if (args[1] == args[0] || args[1] == args[2]) {
+ *reg |= TD0_color_arg1add_mulout;
+ if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA)
+ *reg |= TD0_color_arg1mul_alpha1;
+
+ if (args[1] == MGA_ARG1) {
+ /* Swap adder arguments */
+ *reg ^= (TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout);
+ if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA) {
+ /* Swap multiplier arguments */
+ *reg ^= (TD0_color_arg1mul_alpha1 |
+ TD0_color_arg2mul_alpha2);
+ }
+ }
+ } else {
+ *reg |= (TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1add_mulout);
+
+ if (args[1] == MGA_ARG1) {
+ /* Swap arguments */
+ *reg ^= (TD0_color_arg1mul_alpha1 |
+ TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout);
+ }
+ }
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ if (args[1] != MGA_ARG2) {
+ /* Can't swap arguments */
+ return GL_FALSE;
+ }
+ if (texUnit->CombineScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->CombineScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_sub |
+ TD0_color_sel_add);
+
+ if (args[1] == args[0] || args[1] == args[2]) {
+ *reg |= TD0_color_arg1add_mulout;
+ if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA)
+ *reg |= TD0_color_arg1mul_alpha1;
+ } else {
+ *reg |= (TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1add_mulout);
+ }
+ break;
+ }
+
+
+ /* ALPHA */
+ for (i = 0; i < 2; i++) {
+ arg1[i] = 0;
+ arg2[i] = 0;
+ }
+
+ for (i = 0; i < numAlphaArgs; i++) {
+ switch (texUnit->CombineSourceA[i]) {
+ case GL_TEXTURE:
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ break;
+ case GL_TEXTURE0:
+ if (source == 0) {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ } else {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= TD0_alpha_arg2_prevtex;
+ }
+ break;
+ case GL_TEXTURE1:
+ if (source == 0) {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE0) */
+ arg2[i] |= TD0_alpha_arg2_prevstage;
+ } else {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_CONSTANT:
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= TD0_alpha_arg2_fcol;
+ break;
+ case GL_PRIMARY_COLOR:
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE1) */
+ if (unit == 0 || (mmesa->setup.tdualstage0 &
+ ((TD0_color_sel_mul & TD0_color_sel_add) |
+ (TD0_alpha_sel_mul & TD0_alpha_sel_add)))) {
+ arg2[i] |= TD0_alpha_arg2_diffuse;
+ } else {
+ arg2[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_PREVIOUS:
+ arg1[i] |= ARG_DISABLE;
+ if (unit == 0) {
+ arg2[i] |= TD0_alpha_arg2_diffuse;
+ } else {
+ arg2[i] |= TD0_alpha_arg2_prevstage;
+ }
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch (texUnit->CombineOperandA[i]) {
+ case GL_SRC_ALPHA:
+ arg1[i] |= 0;
+ arg2[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ arg1[i] |= TD0_alpha_arg1_inv_enable;
+ arg2[i] |= TD0_alpha_arg2_inv_enable;
+ break;
+ }
+ }
+
+ /* Find a working combo of arg1 and arg2 */
+ if ((arg1[0] | arg2[1]) != ARG_DISABLE) {
+ *reg |= arg1[0] | arg2[1];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG2;
+ } else
+ if ((arg1[1] | arg2[0]) != ARG_DISABLE) {
+ *reg |= arg1[1] | arg2[0];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG1;
+ } else {
+ /* nothing suitable */
+ return GL_FALSE;
+ }
+
+ switch (texUnit->CombineModeA) {
+ case GL_REPLACE:
+ if (texUnit->CombineScaleShiftA) {
+ return GL_FALSE;
+ }
+
+ if (args[0] == MGA_ARG1){
+ *reg |= TD0_alpha_sel_arg1;
+ } else if (args[0] == MGA_ARG2) {
+ *reg |= TD0_alpha_sel_arg2;
+ }
+ break;
+ case GL_MODULATE:
+ if (texUnit->CombineScaleShiftA == 1) {
+ *reg |= TD0_alpha_modbright_2x;
+ } else if (texUnit->CombineScaleShiftA == 2) {
+ *reg |= TD0_alpha_modbright_4x;
+ }
+
+ *reg |= TD0_alpha_sel_mul;
+ break;
+ case GL_ADD_SIGNED:
+ *reg |= TD0_alpha_addbias_enable;
+ /* fallthrough */
+ case GL_ADD:
+ if (texUnit->CombineScaleShiftA == 1) {
+ *reg |= TD0_alpha_add2x_enable;
+ } else if (texUnit->CombineScaleShiftA == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ break;
+ case GL_SUBTRACT:
+ if (texUnit->CombineScaleShiftA == 1) {
+ *reg |= TD0_alpha_add2x_enable;
+ } else if (texUnit->CombineScaleShiftA == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_alpha_add_disable |
+ TD0_alpha_sel_add);
+
+ if (args[0] == MGA_ARG2) {
+ /* Swap arguments */
+ *reg ^= (TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_inv_enable);
+ }
+ break;
+ }
+
+ return GL_TRUE;
+}
+
+
[MESA_FORMAT_RGB565] = TMC_tformat_tw16 | TMC_takey_1 | TMC_tamask_0,
[MESA_FORMAT_ARGB4444] = TMC_tformat_tw12 | TMC_takey_1 | TMC_tamask_0,
[MESA_FORMAT_ARGB1555] = TMC_tformat_tw15 | TMC_takey_1 | TMC_tamask_0,
+ [MESA_FORMAT_AL88] = TMC_tformat_tw8al | TMC_takey_1 | TMC_tamask_0,
+ [MESA_FORMAT_I8] = TMC_tformat_tw8a | TMC_takey_1 | TMC_tamask_0,
[MESA_FORMAT_CI8] = TMC_tformat_tw8 | TMC_takey_1 | TMC_tamask_0,
[MESA_FORMAT_YCBCR] = TMC_tformat_tw422uyvy | TMC_takey_1 | TMC_tamask_0,
[MESA_FORMAT_YCBCR_REV] = TMC_tformat_tw422 | TMC_takey_1 | TMC_tamask_0,
GLint totalSize;
GLint width, height;
GLint i;
- GLint firstLevel, lastLevel, numLevels;
+ GLint numLevels;
GLint log2Width, log2Height;
GLuint txformat = 0;
GLint ofs;
case MESA_FORMAT_RGB565: txformat = TMC_tformat_tw16; break;
case MESA_FORMAT_ARGB4444: txformat = TMC_tformat_tw12; break;
case MESA_FORMAT_ARGB1555: txformat = TMC_tformat_tw15; break;
+ case MESA_FORMAT_AL88: txformat = TMC_tformat_tw8al; break;
+ case MESA_FORMAT_I8: txformat = TMC_tformat_tw8a; break;
case MESA_FORMAT_CI8: txformat = TMC_tformat_tw8; break;
case MESA_FORMAT_YCBCR: txformat = TMC_tformat_tw422uyvy; break;
case MESA_FORMAT_YCBCR_REV: txformat = TMC_tformat_tw422; break;
#endif /* MGA_USE_TABLE_FOR_FORMAT */
- if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
- /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
- */
-
- firstLevel = lastLevel = tObj->BaseLevel;
- } else {
- /* 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.
- */
-
- 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 */
- }
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ log2Width = tObj->Image[t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[t->base.firstLevel]->HeightLog2;
- log2Width = tObj->Image[firstLevel]->WidthLog2;
- log2Height = tObj->Image[firstLevel]->HeightLog2;
- width = tObj->Image[firstLevel]->Width;
- height = tObj->Image[firstLevel]->Height;
+ width = tObj->Image[t->base.firstLevel]->Width;
+ height = tObj->Image[t->base.firstLevel]->Height;
- numLevels = MIN2( lastLevel - firstLevel + 1,
+ numLevels = MIN2( t->base.lastLevel - t->base.firstLevel + 1,
MGA_IS_G200(mmesa) ? G200_TEX_MAXLEVELS : G400_TEX_MAXLEVELS);
totalSize = 0;
for ( i = 0 ; i < numLevels ; i++ ) {
- const struct gl_texture_image * const texImage = tObj->Image[i+firstLevel];
+ const struct gl_texture_image * const texImage =
+ tObj->Image[ i + t->base.firstLevel ];
if ( (texImage == NULL)
|| ((i != 0)
baseImage->TexFormat->TexelBytes) + 31) & ~31;
}
- numLevels = i;
- lastLevel = firstLevel + numLevels - 1;
-
/* save these values */
- t->base.firstLevel = firstLevel;
- t->base.lastLevel = lastLevel;
-
+ numLevels = i;
+ t->base.lastLevel = t->base.firstLevel + numLevels - 1;
t->base.totalSize = totalSize;
/* setup hardware register values */
t->setup.texctl2 |= TMC_decalblend_enable;
break;
case GL_BLEND:
- FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
+ t->texenv_fallback = GL_TRUE;
break;
default:
break;
(0),
/* GL_REPLACE
+ * Cv = Cs
+ * Av = Af
*/
(TD0_color_sel_arg1 |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg2 ),
+ TD0_alpha_sel_arg2),
/* GL_MODULATE
+ * Cv = Cf Cs
+ * Av = Af
*/
(TD0_color_arg2_diffuse |
TD0_color_sel_mul |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_mul),
+ TD0_alpha_sel_arg2),
/* GL_DECAL
+ * Cv = Cs
+ * Av = Af
*/
(TD0_color_sel_arg1 |
TD0_alpha_arg2_diffuse |
TD0_alpha_sel_arg2),
- /* GL_BLEND
+ /* GL_BLEND (Cc=0.0)
+ * Cv = Cf ( 1 - Cs )
+ * Av = Af
+ */
+ (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cf + Cs
+ * Av = Af
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* Disable combiner stage
*/
(0),
+
+ /* GL_REPLACE
+ * Cv = Cs
+ * Av = Ap
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_MODULATE
+ * Cv = Cp Cs
+ * Av = Ap
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_DECAL
+ * Cv = Cs
+ * Av = Ap
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_BLEND (Cc=0.0)
+ * Cv = Cp ( 1 - Cs )
+ * Av = Ap
+ */
+ (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_prevstage |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cp + Cs
+ * Av = Ap
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+ },
+};
+
+static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* Disable combiner stage
+ */
+ (0),
+
+ /* GL_REPLACE
+ * Cv = Cs
+ * Av = As
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_sel_arg1),
+
+ /* GL_MODULATE
+ * Cv = Cf Cs
+ * Av = Af As
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul),
+
+ /* GL_DECAL
+ * tmp = Cf ( 1 - As )
+ * Cv = tmp + Cs As
+ * Av = Af
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_alpha_currtex |
+ TD0_color_alpha1inv_enable |
+ TD0_color_arg1mul_alpha1 |
+ TD0_color_blend_enable |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+
+ /* GL_BLEND (Cc=0.0)
+ * Cv = Cf ( 1 - Cs )
+ * Av = Af As
+ */
+ (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul),
/* GL_ADD
+ * Cv = Cf + Cs
+ * Av = Af As
*/
(TD0_color_arg2_diffuse |
TD0_color_add_add |
(0),
/* GL_REPLACE
+ * Cv = Cs
+ * Av = As
*/
(TD0_color_sel_arg1 |
- TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg2 ),
+ TD0_alpha_sel_arg1),
/* GL_MODULATE
+ * Cv = Cp Cs
+ * Av = Ap As
*/
(TD0_color_arg2_prevstage |
- TD0_color_alpha_prevstage |
TD0_color_sel_mul |
TD0_alpha_arg2_prevstage |
TD0_alpha_sel_mul),
/* GL_DECAL
+ * tmp = Cp ( 1 - As )
+ * Cv = tmp + Cs As
+ * Av = Ap
*/
- (TD0_color_sel_arg1 |
+ (TD0_color_arg2_prevstage |
+ TD0_color_alpha_currtex |
+ TD0_color_alpha1inv_enable |
+ TD0_color_arg1mul_alpha1 |
+ TD0_color_blend_enable |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_add |
TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_arg2 ),
+ TD0_alpha_sel_arg2),
- /* GL_BLEND
+ /* GL_BLEND (Cc=0.0)
+ * Cv = Cp ( 1 - Cs )
+ * Av = Ap As
*/
- (0),
+ (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_prevstage |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_mul),
/* GL_ADD
+ * Cv = Cp + Cs
+ * Av = Ap As
*/
(TD0_color_arg2_prevstage |
- TD0_color_alpha_prevstage |
TD0_color_add_add |
TD0_color_sel_add |
TD0_alpha_arg2_prevstage |
(0),
/* GL_REPLACE
+ * Cv = Cf
+ * Av = As
*/
- (TD0_color_sel_arg2 |
- TD0_color_arg2_diffuse |
- TD0_alpha_sel_arg1 ),
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_arg2 |
+ TD0_alpha_sel_arg1),
/* GL_MODULATE
- * FIXME: Is this correct?
+ * Cv = Cf
+ * Av = Af As
*/
(TD0_color_arg2_diffuse |
- TD0_color_sel_mul |
+ TD0_color_sel_arg2 |
TD0_alpha_arg2_diffuse |
TD0_alpha_sel_mul),
- /* GL_DECAL
+ /* GL_DECAL (undefined)
+ * Cv = Cf
+ * Av = Af
*/
(TD0_color_arg2_diffuse |
TD0_color_sel_arg2 |
TD0_alpha_sel_arg2),
/* GL_BLEND
+ * Cv = Cf
+ * Av = Af As
*/
(TD0_color_arg2_diffuse |
- TD0_color_sel_mul |
+ TD0_color_sel_arg2 |
TD0_alpha_arg2_diffuse |
TD0_alpha_sel_mul),
/* GL_ADD
+ * Cv = Cf
+ * Av = Af As
*/
(TD0_color_arg2_diffuse |
- TD0_color_sel_mul |
+ TD0_color_sel_arg2 |
TD0_alpha_arg2_diffuse |
TD0_alpha_sel_mul),
},
(0),
/* GL_REPLACE
+ * Cv = Cp
+ * Av = As
*/
- (TD0_color_sel_arg2 |
- TD0_color_arg2_diffuse |
- TD0_alpha_sel_arg1 ),
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_sel_arg1),
/* GL_MODULATE
- * FIXME: Is this correct?
+ * Cv = Cp
+ * Av = Ap As
*/
(TD0_color_arg2_prevstage |
- TD0_color_alpha_prevstage |
- TD0_color_sel_mul |
+ TD0_color_sel_arg2 |
TD0_alpha_arg2_prevstage |
TD0_alpha_sel_mul),
- /* GL_DECAL
+ /* GL_DECAL (undefined)
+ * Cv = Cp
+ * Av = Ap
*/
(TD0_color_arg2_prevstage |
TD0_color_sel_arg2 |
TD0_alpha_sel_arg2),
/* GL_BLEND
+ * Cv = Cp
+ * Av = Ap As
*/
- (TD0_color_arg2_diffuse |
- TD0_color_sel_mul |
- TD0_alpha_arg2_diffuse |
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
TD0_alpha_sel_mul),
/* GL_ADD
+ * Cv = Cp
+ * Av = Ap As
*/
(TD0_color_arg2_prevstage |
- TD0_color_sel_mul |
+ TD0_color_sel_arg2 |
TD0_alpha_arg2_prevstage |
TD0_alpha_sel_mul),
},
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
const struct gl_texture_object *tObj = texUnit->_Current;
GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
+ mgaTextureObjectPtr t;
GLenum format;
- if ( tObj != ctx->Texture.Unit[source].Current2D || !tObj )
+ if ( !tObj ||
+ (tObj != ctx->Texture.Unit[source].Current2D &&
+ tObj != ctx->Texture.Unit[source].CurrentRect) )
return;
format = tObj->Image[tObj->BaseLevel]->Format;
+ t = (mgaTextureObjectPtr) tObj->DriverData;
+
switch (ctx->Texture.Unit[source].EnvMode) {
case GL_REPLACE:
- if (format == GL_RGB || format == GL_LUMINANCE) {
- *reg = g400_color_combine[unit][MGA_REPLACE];
- }
- else if (format == GL_ALPHA) {
+ if (format == GL_ALPHA) {
*reg = g400_alpha_combine[unit][MGA_REPLACE];
- }
- else {
- *reg = (TD0_color_sel_arg1 |
- TD0_alpha_sel_arg1 );
+ } else if (format == GL_RGB || format == GL_LUMINANCE) {
+ *reg = g400_color_combine[unit][MGA_REPLACE];
+ } else {
+ *reg = g400_color_alpha_combine[unit][MGA_REPLACE];
}
break;
case GL_MODULATE:
- *reg = g400_color_combine[unit][MGA_MODULATE];
+ if (format == GL_ALPHA) {
+ *reg = g400_alpha_combine[unit][MGA_MODULATE];
+ } else if (format == GL_RGB || format == GL_LUMINANCE) {
+ *reg = g400_color_combine[unit][MGA_MODULATE];
+ } else {
+ *reg = g400_color_alpha_combine[unit][MGA_MODULATE];
+ }
break;
+
case GL_DECAL:
if (format == GL_RGB) {
- *reg = g400_color_combine[unit][MGA_DECAL];
+ *reg = g400_color_combine[unit][MGA_DECAL];
+ } else if (format == GL_RGBA) {
+ *reg = g400_color_alpha_combine[unit][MGA_DECAL];
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* Linear blending mode needs dual texturing enabled */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ mmesa->dualtex_env = GL_TRUE;
+ }
+ } else {
+ /* Undefined */
+ *reg = g400_alpha_combine[unit][MGA_DECAL];
}
- else if ( format == GL_RGBA ) {
-#if 0
+ break;
+
+ case GL_ADD:
+ if (format == GL_ALPHA) {
+ *reg = g400_alpha_combine[unit][MGA_ADD];
+ } else if (format == GL_RGB || format == GL_LUMINANCE) {
+ *reg = g400_color_combine[unit][MGA_ADD];
+ } else if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
+ *reg = g400_color_alpha_combine[unit][MGA_ADD];
+ } else if (format == GL_INTENSITY) {
+ /* Cv = Cf + Cs
+ * Av = Af + As
+ */
if (unit == 0) {
- /* this doesn't work */
*reg = (TD0_color_arg2_diffuse |
- TD0_color_alpha_currtex |
- TD0_color_alpha2inv_enable |
- TD0_color_arg2mul_alpha2 |
- TD0_color_arg1mul_alpha1 |
- TD0_color_blend_enable |
- TD0_color_arg1add_mulout |
- TD0_color_arg2add_mulout |
TD0_color_add_add |
- TD0_color_sel_mul |
+ TD0_color_sel_add |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg2 );
- }
- else {
+ TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ } else {
*reg = (TD0_color_arg2_prevstage |
- TD0_color_alpha_currtex |
- TD0_color_alpha2inv_enable |
- TD0_color_arg2mul_alpha2 |
- TD0_color_arg1mul_alpha1 |
TD0_color_add_add |
TD0_color_sel_add |
TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_arg2 );
+ TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
}
-#else
- /* s/w fallback, pretty sure we can't do in h/w */
- FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
- if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
- fprintf( stderr, "FALLBACK: GL_DECAL RGBA texture, unit=%d\n",
- unit );
-#endif
- }
- else {
- *reg = g400_alpha_combine[unit][MGA_DECAL];
}
break;
- case GL_ADD:
- if (format == GL_INTENSITY) {
- if (unit == 0) {
- *reg = ( TD0_color_arg2_diffuse |
- TD0_color_add_add |
- TD0_color_sel_add |
- TD0_alpha_arg2_diffuse |
- TD0_alpha_add_enable |
- TD0_alpha_sel_add);
- }
- else {
- *reg = ( TD0_color_arg2_prevstage |
- TD0_color_add_add |
- TD0_color_sel_add |
- TD0_alpha_arg2_prevstage |
- TD0_alpha_add_enable |
- TD0_alpha_sel_add);
- }
- }
- else if (format == GL_ALPHA) {
- *reg = g400_alpha_combine[unit][MGA_ADD];
- }
- else {
- *reg = g400_color_combine[unit][MGA_ADD];
- }
- break;
-
case GL_BLEND:
if (format == GL_ALPHA) {
- *reg = g400_alpha_combine[unit][MGA_BLEND];
- }
- else {
- FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
- if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
- fprintf( stderr, "FALLBACK: GL_BLEND envcolor=0x%08x\n",
- mmesa->envcolor );
-
- /* Do singletexture GL_BLEND with 'all ones' env-color
- * by using both texture units. Multitexture gl_blend
- * is a fallback.
- */
- if (unit == 0) {
- /* Part 1: R1 = Rf ( 1 - Rt )
- * A1 = Af At
- */
- *reg = ( TD0_color_arg2_diffuse |
- TD0_color_arg1_inv_enable |
- TD0_color_sel_mul |
- TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg1);
+ *reg = g400_alpha_combine[unit][MGA_BLEND];
+ } else {
+ if (mmesa->blend_flags & MGA_BLEND_RGB_ZERO) {
+ if (format == GL_RGB || format == GL_LUMINANCE) {
+ *reg = g400_color_combine[unit][MGA_BLEND];
+ } else if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
+ *reg = g400_color_alpha_combine[unit][MGA_BLEND];
+ } else if (format == GL_INTENSITY) {
+ if (mmesa->blend_flags & MGA_BLEND_ALPHA_ZERO) {
+ /* Cv = Cf ( 1 - Cs )
+ * Av = Af ( 1 - As )
+ */
+ if (unit == 0) {
+ *reg = (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ } else {
+ *reg = (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_prevstage |
+ TD0_color_sel_mul |
+ TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_mul);
+ }
+ } else if (mmesa->blend_flags & MGA_BLEND_ALPHA_ONE &&
+ ctx->Texture._EnabledUnits != 0x03) {
+ /* C1 = Cf ( 1 - Cs )
+ * A1 = Af ( 1 - As )
+ */
+ *reg = (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ /* Cv = C1
+ * Av = A1 + As
+ */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ mmesa->dualtex_env = GL_TRUE;
+ } else {
+ t->texenv_fallback = GL_TRUE;
+ }
+ }
+ } else if (mmesa->blend_flags & MGA_BLEND_RGB_ONE &&
+ ctx->Texture._EnabledUnits != 0x03) {
+ if (format == GL_RGB || format == GL_LUMINANCE) {
+ /* C1 = Cf ( 1 - Cs )
+ * A1 = Af
+ */
+ *reg = (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2);
+ /* Cv = C1 + Cs
+ * Av = A1
+ */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ mmesa->dualtex_env = GL_TRUE;
+ } else if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
+ /* C1 = Cf ( 1 - Cs )
+ * A1 = Af As
+ */
+ *reg = (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ /* Cv = C1 + Cs
+ * Av = A1
+ */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ mmesa->dualtex_env = GL_TRUE;
+ } else if (format == GL_INTENSITY) {
+ if (mmesa->blend_flags & MGA_BLEND_ALPHA_ZERO) {
+ /* C1 = Cf ( 1 - Cs )
+ * A1 = Af ( 1 - As )
+ */
+ *reg = (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ /* Cv = C1 + Cs
+ * Av = A1
+ */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ mmesa->dualtex_env = GL_TRUE;
+ } else if (mmesa->blend_flags & MGA_BLEND_ALPHA_ONE) {
+ /* C1 = Cf ( 1 - Cs )
+ * A1 = Af ( 1 - As )
+ */
+ *reg = (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ /* Cv = C1 + Cs
+ * Av = A1 + As
+ */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ mmesa->dualtex_env = GL_TRUE;
+ } else {
+ t->texenv_fallback = GL_TRUE;
+ }
+ }
} else {
- /* Part 2: R2 = R1 + Rt
- * A2 = A1
- */
- *reg = ( TD0_color_arg2_prevstage |
- TD0_color_add_add |
- TD0_color_sel_add |
- TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_arg2);
+ t->texenv_fallback = GL_TRUE;
}
}
break;
+ case GL_COMBINE_EXT:
+ if (!mgaUpdateTextureEnvCombine(ctx, unit))
+ t->texenv_fallback = GL_TRUE;
+ break;
default:
break;
}
}
-
static void disable_tex( GLcontext *ctx, int unit )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
mmesa->CurrentTexObj[unit] = NULL;
}
- if ( unit != 0 ) {
+ if ( unit != 0 && !mmesa->dualtex_env ) {
mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
}
mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit);
}
-static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
+static GLboolean enable_tex( GLcontext *ctx, int unit )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
const int source = mmesa->tmu_source[unit];
t->setup.texctl2 |= TMC_dualtex_enable;
}
+ t->texenv_fallback = GL_FALSE;
+
+ /* Set this before mgaUpdateTextureEnvG400() since
+ * GL_ARB_texture_env_crossbar may have to disable texturing.
+ */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_texture_trap;
+
/* FIXME: The Radeon has some cached state so that it can avoid calling
* FIXME: UpdateTextureEnv in some cases. Is that possible here?
*/
mgaUpdateTextureEnvG200( ctx, unit );
}
-
- mmesa->setup.dwgctl &= DC_opcod_MASK;
- mmesa->setup.dwgctl |= DC_opcod_texture_trap;
mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit);
FALLBACK( ctx, MGA_FALLBACK_BORDER_MODE, t->border_fallback );
- return !t->border_fallback;
+ return !t->border_fallback && !t->texenv_fallback;
}
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
- if ( texUnit->_ReallyEnabled == TEXTURE_2D_BIT) {
- return(enable_tex_2d( ctx, unit ) &&
+ if ( texUnit->_ReallyEnabled == TEXTURE_2D_BIT ||
+ texUnit->_ReallyEnabled == TEXTURE_RECT_BIT ) {
+ return(enable_tex( ctx, unit ) &&
update_tex_common( ctx, unit ));
}
else if ( texUnit->_ReallyEnabled ) {
GLboolean ok;
unsigned i;
+ mmesa->dualtex_env = GL_FALSE;
/* This works around a quirk with the MGA hardware. If only OpenGL
* TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The
}
FALLBACK( ctx, MGA_FALLBACK_TEXTURE, !ok );
-
- /* FIXME: I believe that ChooseVertexState should be called here instead of
- * FIXME: in mgaDDValidateState.
- */
}
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v 1.18 2002/12/16 16:18:52 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v 1.19 2003/03/26 20:43:49 tsi Exp $ */
/*
* Copyright 2000-2001 VA Linux Systems, Inc.
* All Rights Reserved.
#include "utils.h"
#include "vblank.h"
-#include "dri_util.h"
+
#ifndef _SOLO
#include "glxextensions.h"
#endif
+/* MGA configuration
+ */
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+const GLuint __driNConfigOptions = 1;
+
#ifndef MGA_DEBUG
int MGA_DEBUG = 0;
#endif
&gp, sizeof(gp));
if (ret) {
fprintf(stderr, "drmMgaGetParam (MGA_PARAM_IRQ_NR): %d\n", ret);
- free(mgaScreen);
+ FREE(mgaScreen);
sPriv->private = NULL;
return GL_FALSE;
}
mgaScreen->linecomp_sane = (sPriv->ddxMajor > 1) || (sPriv->ddxMinor > 1)
|| ((sPriv->ddxMinor == 1) && (sPriv->ddxPatch > 0));
-#ifndef _SOLO
- if ( ! mgaScreen->linecomp_sane ) {
- PFNGLXDISABLEEXTENSIONPROC glx_disable_extension;
+#ifndef _SOLO
+ if ( driCompareGLXAPIVersion( 20030813 ) >= 0 ) {
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
+ void * const psc = sPriv->psc->screenConfigs;
- glx_disable_extension = (PFNGLXDISABLEEXTENSIONPROC)
- glXGetProcAddress( "__glXDisableExtension" );
+ if ( glx_enable_extension != NULL ) {
+ if ( mgaScreen->linecomp_sane ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
- if ( glx_disable_extension != NULL ) {
- (*glx_disable_extension)( "GLX_SGI_swap_control" );
- (*glx_disable_extension)( "GLX_SGI_video_sync" );
- (*glx_disable_extension)( "GLX_MESA_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
}
}
#endif
if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
serverInfo->chipset != MGA_CARD_TYPE_G400) {
- free(mgaScreen);
+ FREE(mgaScreen);
sPriv->private = NULL;
__driUtilMessage("Unrecognized chipset");
return GL_FALSE;
mgaScreen->agp.size,
(drmAddress *)&mgaScreen->agp.map) != 0)
{
- free(mgaScreen);
+ Xfree(mgaScreen);
sPriv->private = NULL;
__driUtilMessage("Couldn't map agp region");
return GL_FALSE;
serverInfo->agpTextureSize,
(drmAddress *)&mgaScreen->texVirtual[MGA_AGP_HEAP]) != 0)
{
- free(mgaScreen);
+ FREE(mgaScreen);
sPriv->private = NULL;
__driUtilMessage("Couldn't map agptexture region");
return GL_FALSE;
mgaScreen->bufs = drmMapBufs(sPriv->fd);
if (!mgaScreen->bufs) {
/*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/
- free(mgaScreen);
+ FREE(mgaScreen);
sPriv->private = NULL;
__driUtilMessage("Couldn't map dma buffers");
return GL_FALSE;
}
mgaScreen->sarea_priv_offset = serverInfo->sarea_priv_offset;
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&mgaScreen->optionCache);
+
return GL_TRUE;
}
fprintf(stderr, "mgaDestroyScreen\n");
/*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/
- free(mgaScreen);
+
+ /* free all option information */
+ driDestroyOptionInfo (&mgaScreen->optionCache);
+
+ FREE(mgaScreen);
sPriv->private = NULL;
}
"GL_ARB_multitexture",
"GL_ARB_texture_env_add",
"GL_EXT_texture_env_add",
+ "GL_ARB_texture_env_combine",
+ "GL_EXT_texture_env_combine",
+ "GL_ARB_texture_env_crossbar",
+ "GL_ATI_texture_env_combine3",
"GL_EXT_texture_edge_clamp",
"GL_SGIS_texture_edge_clamp",
#if defined (MESA_packed_depth_stencil)
"GL_MESA_ycbcr_texture",
"GL_SGIS_generate_mipmap",
"GL_SGIS_texture_lod",
+ "GL_NV_texture_rectangle",
NULL
};
mmesa->sarea = (void *)saPriv;
mmesa->glBuffer = NULL;
+ /* Parse configuration files */
+ driParseConfigFiles (&mmesa->optionCache, &mgaScreen->optionCache,
+ sPriv->myNum, "mga");
+
(void) memset( mmesa->texture_heaps, 0, sizeof( mmesa->texture_heaps ) );
make_empty_list( & mmesa->swapped );
mmesa->nr_heaps,
& ctx->Const,
4,
- 11, /* max 2D texture size is 1024x1024 */
+ 11, /* max 2D texture size is 2048x2048 */
0, /* 3D textures unsupported. */
0, /* cube textures unsupported. */
- 0, /* texture rectangles unsupported. */
+ 11, /* max texture rect size is 2048x2048 */
maxlevels,
GL_FALSE );
mmesa->vblank_flags = ((mmesa->mgaScreen->irq == 0)
|| !mmesa->mgaScreen->linecomp_sane)
- ? VBLANK_FLAG_NO_IRQ : driGetDefaultVBlankFlags();
+ ? VBLANK_FLAG_NO_IRQ : driGetDefaultVBlankFlags(&mmesa->optionCache);
#ifndef _SOLO
- mmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( "__glXGetUST" );
- if ( mmesa->get_ust == NULL )
-#endif
- {
+ mmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( (const GLubyte *) "__glXGetUST" );
+ if ( mmesa->get_ust == NULL ) {
mmesa->get_ust = get_ust_nop;
}
+#else
+ mmesa->get_ust = get_ust_nop;
+#endif
(*mmesa->get_ust)( & mmesa->swap_ust );
}
}
+ /* free the option cache */
+ driDestroyOptionCache (&mmesa->optionCache);
+
FREE(mmesa);
}
mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
if (mmesa->driDrawable != driDrawPriv) {
+ driDrawableInitVBlank( driDrawPriv, mmesa->vblank_flags );
mmesa->driDrawable = driDrawPriv;
mmesa->dirty = ~0;
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
* The __driCreateScreen name is the symbol that libGL.so fetches.
* Return: pointer to a __DRIscreenPrivate.
*/
-#ifndef _SOLO
+#ifndef _SOLO
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config)
{
#endif
-#ifndef _SOLO
-/* This function is called by libGL.so as soon as libGL.so is loaded.
- * This is where we'd register new extension functions with the dispatcher.
- */
-void
-__driRegisterExtensions( void )
-{
- PFNGLXENABLEEXTENSIONPROC glx_enable_extension;
-
-
- if ( driCompareGLXAPIVersion( 20030317 ) >= 0 ) {
- glx_enable_extension = (PFNGLXENABLEEXTENSIONPROC)
- glXGetProcAddress( "__glXEnableExtension" );
-
- if ( glx_enable_extension != NULL ) {
- (*glx_enable_extension)( "GLX_SGI_swap_control", GL_FALSE );
- (*glx_enable_extension)( "GLX_SGI_video_sync", GL_FALSE );
- (*glx_enable_extension)( "GLX_MESA_swap_control", GL_FALSE );
- (*glx_enable_extension)( "GLX_MESA_swap_frame_usage", GL_FALSE );
- }
- }
-}
-#endif
-
/**
* Get information about previous buffer swaps.
*/
#include "mtypes.h"
#include "mgaregs.h"
#include "mga_common.h"
+#include "xmlconfig.h"
typedef struct mga_screen_private_s {
drmRegion primary;
drmRegion buffers;
unsigned int sarea_priv_offset;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
} mgaScreenPrivate;
#include "mga_sarea.h"
#include "texmem.h"
#include "macros.h"
+#include "xmlconfig.h"
#define MGA_SET_FIELD(reg,mask,val) reg = ((reg) & (mask)) | ((val) & ~(mask))
#define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK))
-/* Reasons why the GL_BLEND fallback mightn't work:
+/* GL_BLEND has some limitations
*/
-#define MGA_BLEND_ENV_COLOR 0x1
-#define MGA_BLEND_MULTITEX 0x2
+#define MGA_BLEND_RGB_ZERO 0x1
+#define MGA_BLEND_RGB_ONE 0x2
+#define MGA_BLEND_ALPHA_ZERO 0x4
+#define MGA_BLEND_ALPHA_ONE 0x8
struct mga_texture_object_s;
struct mga_screen_private_s;
* to fallback for GL_CLAMP_TO_BORDER.
*/
GLboolean border_fallback;
+ /* Depending on multitxturing and environment color
+ * GL_BLEND may have to be a software fallback.
+ */
+ GLboolean texenv_fallback;
} mgaTextureObject_t;
struct mga_hw_state {
struct gl_client_array UbyteColor;
struct gl_client_array UbyteSecondaryColor;
- /* Support for limited GL_BLEND fallback
+ /* Support for GL_DECAL and GL_BLEND
*/
unsigned int blend_flags;
unsigned int envcolor;
+ GLboolean dualtex_env;
/* Rasterization state
*/
__DRIscreenPrivate *driScreen;
struct mga_screen_private_s *mgaScreen;
MGASAREAPrivPtr sarea;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
};
#define MGA_CONTEXT(ctx) ((mgaContextPtr)(ctx->DriverCtx))
* Gareth Hughes <gareth@valinux.com>
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.c,v 1.16 2002/12/16 16:18:52 dawes Exp $ */
-
-#include <sched.h>
#include <errno.h>
+#include <sched.h>
#include "mtypes.h"
#include "macros.h"
*/
static int mgaStipples[16] = {
- 0xffff1, /* See above note */
+ 0xffff,
0xa5a5,
0x5a5a,
0xa0a0,
*
* \param ctx GL rendering context to be affected
* \param mask Pointer to the 32x32 stipple mask
- *
- * \note the fully opaque pattern (0xffff) has been disabled in order
- * to work around a conformance issue.
*/
static void mgaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
unsigned int specen;
- specen = (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
- ctx->Light.Enabled) ? TMC_specen_enable : 0;
+ specen = (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) ? TMC_specen_enable : 0;
if ( specen != mmesa->hw.specen ) {
mmesa->hw.specen = specen;
}
-static void mgaDDShadeModel(GLcontext *ctx, GLenum mode)
-{
- /* FIXME: This used to FLUSH_BATCH and set MGA_NEW_TEXTURE in new_state,
- * FIXME: so I'm not sure what to do here now.
- */
-}
-
-
/* =============================================================
* Stencil
*/
case GL_DECR:
stencilctl |= SC_szpassop_decrsat;
break;
+ case GL_INCR_WRAP:
+ stencilctl |= SC_szpassop_incr;
+ break;
+ case GL_DECR_WRAP:
+ stencilctl |= SC_szpassop_decr;
+ break;
case GL_INVERT:
stencilctl |= SC_szpassop_invert;
break;
else
mgaXMesaSetBackClipRects( mmesa );
+#ifndef _SOLO
+ sarea->req_drawable = driDrawable->draw;
sarea->req_draw_buffer = mmesa->draw_buffer;
-
+#endif
mgaUpdateClipping( mmesa->glCtx );
mgaCalcViewport( mmesa->glCtx );
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
switch(cap) {
+ case GL_LIGHTING:
+ case GL_COLOR_SUM_EXT:
+ FLUSH_BATCH( mmesa );
+ updateSpecularLighting( ctx );
+ break;
case GL_ALPHA_TEST:
FLUSH_BATCH( mmesa );
mmesa->hw.alpha_func_enable = (state) ? ~0 : 0;
}
if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) {
- mmesa->CurrentTexObj[0]->setup.texctl2 &= ~TMC_specen_enable;
- mmesa->CurrentTexObj[0]->setup.texctl2 |= mmesa->hw.specen;
-
memcpy(&sarea->TexState[0],
&mmesa->CurrentTexObj[0]->setup,
sizeof(sarea->TexState[0]));
}
if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) {
- mmesa->CurrentTexObj[1]->setup.texctl2 &= ~TMC_specen_enable;
- mmesa->CurrentTexObj[1]->setup.texctl2 |= mmesa->hw.specen;
-
memcpy(&sarea->TexState[1],
&mmesa->CurrentTexObj[1]->setup,
sizeof(sarea->TexState[1]));
}
- if ( (sarea->TexState[0].texctl2 & TMC_borderen_MASK) !=
- (sarea->TexState[1].texctl2 & TMC_borderen_MASK) ) {
+ if (mmesa->dualtex_env) {
+ sarea->TexState[0].texctl2 |= TMC_dualtex_enable;
+ memcpy( &sarea->TexState[1], &sarea->TexState[0],
+ sizeof(sarea->TexState[0]) );
+ mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0;
+ } else if ( (sarea->TexState[0].texctl2 & TMC_borderen_MASK) !=
+ (sarea->TexState[1].texctl2 & TMC_borderen_MASK) ) {
const int borderen = sarea->TexState[1].texctl2 & ~TMC_borderen_MASK;
memcpy( &sarea->TexState[1], &sarea->TexState[0],
mmesa->sarea->dirty |= mmesa->dirty;
mmesa->dirty &= MGA_UPLOAD_CLIPRECTS;
- /* This is a bit of a hack but seems to be the best place to ensure
- * that separate specular is disabled when not needed.
- */
- if (ctx->Texture._EnabledUnits == 0 ||
- !ctx->Light.Enabled ||
- ctx->Light.Model.ColorControl == GL_SINGLE_COLOR) {
- sarea->TexState[0].texctl2 &= ~TMC_specen_enable;
- sarea->TexState[1].texctl2 &= ~TMC_specen_enable;
- }
+ sarea->TexState[0].texctl2 &= ~TMC_specen_enable;
+ sarea->TexState[1].texctl2 &= ~TMC_specen_enable;
+ sarea->TexState[0].texctl2 |= mmesa->hw.specen;
+ sarea->TexState[1].texctl2 |= mmesa->hw.specen;
}
static void mgaDDValidateState( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- int new_state = mmesa->NewGLState;
-
FLUSH_BATCH( mmesa );
- if (mmesa->NewGLState & _MGA_NEW_RASTERSETUP) {
- mgaChooseVertexState( ctx );
+ if (mmesa->NewGLState & _NEW_TEXTURE) {
+ mgaUpdateTextureState(ctx);
}
- if (mmesa->NewGLState & _MGA_NEW_RENDERSTATE) {
- mgaChooseRenderState( ctx );
- }
+ if (!mmesa->Fallback) {
+ if (mmesa->NewGLState & _MGA_NEW_RASTERSETUP) {
+ mgaChooseVertexState( ctx );
+ }
- if (new_state & _NEW_TEXTURE) {
- mgaUpdateTextureState(ctx);
+ if (mmesa->NewGLState & _MGA_NEW_RENDERSTATE) {
+ mgaChooseRenderState( ctx );
+ }
}
mmesa->NewGLState = 0;
break;
}
+ mmesa->hw.blend_func = AC_src_one | AC_dst_zero;
mmesa->hw.zmode = DC_zmode_zlt | DC_atype_zi;
mmesa->hw.stencil = (0x0ff << S_smsk_SHIFT) | (0x0ff << S_swtmsk_SHIFT);
mmesa->hw.stencilctl = SC_smode_salways | SC_sfailop_keep
| SC_szfailop_keep | SC_szpassop_keep;
mmesa->hw.stencil_enable = 0;
- mmesa->hw.cull = _CULL_NEGATIVE;
- mmesa->hw.cull_dualtex = _CULL_POSITIVE;
+ mmesa->hw.cull = _CULL_DISABLE;
+ mmesa->hw.cull_dualtex = _CULL_DISABLE;
mmesa->hw.specen = 0;
mmesa->setup.dwgctl = (DC_opcod_trap |
mmesa->setup.tdualstage1 = 0;
mmesa->setup.fcol = 0;
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+
+ mmesa->envcolor = 0;
+ mmesa->blend_flags = MGA_BLEND_RGB_ZERO | MGA_BLEND_ALPHA_ZERO;
+ mmesa->dualtex_env = GL_FALSE;
}
ctx->Driver.DepthMask = mgaDDDepthMask;
ctx->Driver.Fogfv = mgaDDFogfv;
ctx->Driver.Scissor = mgaDDScissor;
- ctx->Driver.ShadeModel = mgaDDShadeModel;
ctx->Driver.CullFace = mgaDDCullFaceFrontFace;
ctx->Driver.FrontFace = mgaDDCullFaceFrontFace;
ctx->Driver.ColorMask = mgaDDColorMask;
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_argb4444;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_rgb565;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_rgb565;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_argb4444;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
/* FIXME: This will report incorrect component sizes... */
- return &_mesa_texformat_argb4444;
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;
case GL_YCBCR_MESA:
if (MGA_IS_G400(mmesa) &&
| TF_uvoffset_OGL);
t->border_fallback = GL_FALSE;
+ t->texenv_fallback = GL_FALSE;
make_empty_list( & t->base );
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-
switch( pname ) {
case GL_TEXTURE_ENV_COLOR: {
GLubyte c[4];
- GLuint envColor;
UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
- envColor = mgaPackColor( mmesa->mgaScreen->cpp, c[0], c[1], c[2], c[3] );
mmesa->envcolor = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
- if (mmesa->setup.fcol != envColor) {
+ if (mmesa->setup.fcol != mmesa->envcolor) {
FLUSH_BATCH(mmesa);
- mmesa->setup.fcol = envColor;
+ mmesa->setup.fcol = mmesa->envcolor;
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
- mmesa->blend_flags &= ~MGA_BLEND_ENV_COLOR;
+ mmesa->blend_flags = 0;
+
+ if ((mmesa->envcolor & 0xffffff) == 0x0) {
+ mmesa->blend_flags |= MGA_BLEND_RGB_ZERO;
+ } else if ((mmesa->envcolor & 0xffffff) == 0xffffff) {
+ mmesa->blend_flags |= MGA_BLEND_RGB_ONE;
+ }
- /* Actually just require all four components to be
- * equal. This permits a single-pass GL_BLEND.
- *
- * More complex multitexture/multipass fallbacks
- * for blend can be done later.
- */
- if (mmesa->envcolor != 0x0 && mmesa->envcolor != 0xffffffff)
- mmesa->blend_flags |= MGA_BLEND_ENV_COLOR;
+ if ((mmesa->envcolor >> 24) == 0x0) {
+ mmesa->blend_flags |= MGA_BLEND_ALPHA_ZERO;
+ } else if ((mmesa->envcolor >> 24) == 0xff) {
+ mmesa->blend_flags |= MGA_BLEND_ALPHA_ONE;
+ }
}
break;
}
* to do anything now
*/
- if ( (t == NULL)
- || (target != GL_TEXTURE_2D) ) {
+ if ( (t == NULL) ||
+ (target != GL_TEXTURE_2D &&
+ target != GL_TEXTURE_RECTANGLE_NV) ) {
return;
}
mgaDDBindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
- if ( target == GL_TEXTURE_2D ) {
+ if ( target == GL_TEXTURE_2D ||
+ target == GL_TEXTURE_RECTANGLE_NV ) {
if ( tObj->DriverData == NULL ) {
mgaAllocTexObj( tObj );
}
ctx->Driver.TexEnv = mgaDDTexEnv;
ctx->Driver.TexParameter = mgaDDTexParameter;
- driInitTextureObjects( ctx, & mmesa->swapped, DRI_TEXMGR_DO_TEXTURE_2D );
+ driInitTextureObjects( ctx, & mmesa->swapped,
+ (DRI_TEXMGR_DO_TEXTURE_2D |
+ DRI_TEXMGR_DO_TEXTURE_RECT) );
}
void mgaDDInitTextureFuncs( GLcontext *ctx );
+GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit );
+
#endif
#define POINT_FALLBACK (DD_POINT_SMOOTH)
#define LINE_FALLBACK (DD_LINE_SMOOTH | DD_LINE_STIPPLE)
#define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_UNFILLED)
-#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK| \
- DD_TRI_STIPPLE)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \
DD_TRI_UNFILLED)
GLuint flags = ctx->_TriangleCaps;
GLuint index = 0;
- if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS|DD_TRI_STIPPLE)) {
if (flags & ANY_RASTER_FLAGS) {
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= MGA_TWOSIDE_BIT;
if (flags & DD_TRI_OFFSET) index |= MGA_OFFSET_BIT;
if (flags & TRI_FALLBACK)
mmesa->draw_tri = mga_fallback_tri;
- if ((flags & DD_TRI_STIPPLE) && !mmesa->haveHwStipple)
- mmesa->draw_tri = mga_fallback_tri;
-
+ index |= MGA_FALLBACK_BIT;
+ }
+
+ if ((flags & DD_TRI_STIPPLE) && !mmesa->haveHwStipple) {
+ mmesa->draw_tri = mga_fallback_tri;
index |= MGA_FALLBACK_BIT;
}
}
if (ctx->Polygon.StippleFlag && mmesa->haveHwStipple)
{
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mmesa->setup.dwgctl &= ~(0xf<<20);
if (mmesa->raster_primitive == GL_TRIANGLES)
mmesa->setup.dwgctl |= mmesa->poly_stipple;
- else
- mmesa->setup.dwgctl &= ~(0xf<<20);
}
}
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.c,v 1.14 2002/10/30 12:51:36 alanh Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.c,v 1.15 2003/03/26 20:43:49 tsi Exp $ */
#include "mgacontext.h"
#include "mgavb.h"
tnl->Driver.Render.Interp = setup_tab[mmesa->SetupIndex].interp;
tnl->Driver.Render.CopyPV = setup_tab[mmesa->SetupIndex].copy_pv;
}
+ if (mmesa->Fallback) {
+ tnl->Driver.Render.Start(ctx);
+ }
}
}
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
- mmesa->verts = ALIGN_MALLOC(size * sizeof(mgaVertex), 32);
+ mmesa->verts = (GLubyte *)ALIGN_MALLOC(size * sizeof(mgaVertex), 32);
{
static int firsttime = 1;
-# $Id: Makefile.X11,v 1.2 2003/10/20 02:17:33 jonsmirl Exp $
+# $Id: Makefile.X11,v 1.3 2003/10/21 06:05:43 jonsmirl Exp $
# Mesa 3-D graphics library
# Version: 5.0
r128_span.c \
r128_texmem.c \
r128_vb.c \
- ../common/mm.c \
- ../common/utils.c \
- ../common/texmem.c \
- ../common/vblank.c
+ ../common/mm.c \
+ ../common/utils.c \
+ ../common/texmem.c \
+ ../common/vblank.c \
+ ../common/xmlconfig.c
INCLUDES = $(MINIGLX_INCLUDES) \
$(SHARED_INCLUDES)
#include "utils.h"
#include "texmem.h"
+/* R128 configuration
+ */
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+#if ENABLE_PERF_BOXES
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_PERFORMANCE_BOXES(false)
+ DRI_CONF_SECTION_END
+#endif
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+#if ENABLE_PERF_BOXES
+const GLuint __driNConfigOptions = 2;
+#else
+const GLuint __driNConfigOptions = 1;
+#endif
+
#ifndef R128_DEBUG
int R128_DEBUG = 0;
#endif
r128scrn = rmesa->r128Screen = (r128ScreenPtr)(sPriv->private);
+ /* Parse configuration files */
+ driParseConfigFiles (&rmesa->optionCache, &r128scrn->optionCache,
+ r128scrn->driScreen->myNum, "r128");
+
rmesa->sarea = (R128SAREAPrivPtr)((char *)sPriv->pSAREA +
r128scrn->sarea_priv_offset);
ctx->Const.LineWidthGranularity = 1.0;
#if ENABLE_PERF_BOXES
- rmesa->boxes = (getenv( "LIBGL_PERFORMANCE_BOXES" ) != NULL);
+ rmesa->boxes = driQueryOptionb(&rmesa->optionCache, "performance_boxes");
#endif
/* Initialize the software rasterizer and helper modules.
r128DDInitTextureFuncs( ctx );
r128DDInitState( rmesa );
- rmesa->do_irqs = (rmesa->r128Screen->irq && !getenv("R128_NO_IRQS"));
-
- rmesa->vblank_flags = (rmesa->do_irqs)
- ? driGetDefaultVBlankFlags() : VBLANK_FLAG_NO_IRQ;
+ rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
+ ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
driContextPriv->driverPrivate = (void *)rmesa;
}
}
+ /* free the option cache */
+ driDestroyOptionCache (&rmesa->optionCache);
+
FREE( rmesa );
}
newR128Ctx->dirty = R128_UPLOAD_ALL;
}
+ driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags );
newR128Ctx->driDrawable = driDrawPriv;
_mesa_make_current2( newR128Ctx->glCtx,
*/
GLuint doPageFlip;
- /* Busy waiting
- */
- GLuint do_irqs;
-
/* Drawable, cliprect and scissor information
*/
GLint drawOffset, drawPitch;
*/
GLuint vbl_seq;
GLuint vblank_flags;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
};
#define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx))
* Gareth Hughes <gareth@valinux.com>
*
*/
-#include <errno.h>
+#include <errno.h>
#include "r128_context.h"
#include "r128_state.h"
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.c,v 1.8 2002/12/16 16:18:53 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.c,v 1.9 2003/03/26 20:43:49 tsi Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
*/
#define PCI_CHIP_RAGE128LE 0x4C45
#define PCI_CHIP_RAGE128LF 0x4C46
-#define PCI_CHIP_RAGE128PD 0x5044
#define PCI_CHIP_RAGE128PF 0x5046
#define PCI_CHIP_RAGE128PR 0x5052
#define PCI_CHIP_RAGE128RE 0x5245
r128Screen = (r128ScreenPtr) CALLOC( sizeof(*r128Screen) );
if ( !r128Screen ) return NULL;
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&r128Screen->optionCache);
+
/* This is first since which regions we map depends on whether or
* not we are using a PCI card.
*/
case PCI_CHIP_RAGE128RL:
r128Screen->chipset = R128_CARD_TYPE_R128;
break;
- case PCI_CHIP_RAGE128PD:
case PCI_CHIP_RAGE128PF:
r128Screen->chipset = R128_CARD_TYPE_R128_PRO;
break;
}
r128Screen->driScreen = sPriv;
+#ifndef _SOLO
+ if ( driCompareGLXAPIVersion( 20030813 ) >= 0 ) {
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if ( glx_enable_extension != NULL ) {
+ if ( r128Screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ }
+ }
+#endif
return r128Screen;
}
drmUnmapBufs( r128Screen->buffers );
drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size );
+ /* free all option information */
+ driDestroyOptionInfo (&r128Screen->optionCache);
+
FREE( r128Screen );
sPriv->private = NULL;
}
return GL_TRUE;
}
-
#ifndef _SOLO
-/* This function is called by libGL.so as soon as libGL.so is loaded.
+/**
+ * This function is called by libGL.so as soon as libGL.so is loaded.
* This is where we register new extension functions with the dispatcher.
+ *
+ * \todo This interface has been deprecated, so we should probably remove
+ * this function before the next XFree86 release.
*/
void __driRegisterExtensions( void )
{
if ( driCompareGLXAPIVersion( 20030317 ) >= 0 ) {
glx_enable_extension = (PFNGLXENABLEEXTENSIONPROC)
- glXGetProcAddress( "__glXEnableExtension" );
+ glXGetProcAddress( (const GLubyte *) "__glXEnableExtension" );
if ( glx_enable_extension != NULL ) {
glx_enable_extension( "GLX_SGI_swap_control", GL_FALSE );
* The __driCreateScreen name is the symbol that libGL.so fetches.
* Return: pointer to a __DRIscreenPrivate.
*/
-#ifndef _SOLO
+#ifndef _SOLO
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config)
{
#ifdef GLX_DIRECT_RENDERING
#include "r128_sarea.h"
+#include "xmlconfig.h"
typedef struct {
drmHandle handle; /* Handle to the DRM region */
__DRIscreenPrivate *driScreen;
unsigned int sarea_priv_offset;
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+
} r128ScreenRec, *r128ScreenPtr;
break;
}
- /* We want to update the s/w rast state too so that r200SetBuffer()
+ /* We want to update the s/w rast state too so that r128DDSetBuffer()
* gets called.
*/
_swrast_DrawBuffer(ctx, mode);
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_texmem.c,v 1.1 2002/02/22 21:44:58 dawes Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_texstate.c,v 1.1 2002/02/22 21:44:58 dawes Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
};
/* 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.
*/
- 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 */
+
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ firstLevel = t->base.firstLevel;
+ lastLevel = t->base.lastLevel;
log2Pitch = tObj->Image[firstLevel]->WidthLog2;
log2Height = tObj->Image[firstLevel]->HeightLog2;
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.c,v 1.15 2002/10/30 12:51:43 alanh Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.c,v 1.16 2003/03/26 20:43:49 tsi Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
tnl->Driver.Render.Interp = setup_tab[rmesa->SetupIndex].interp;
tnl->Driver.Render.CopyPV = setup_tab[rmesa->SetupIndex].copy_pv;
}
+ if (rmesa->Fallback) {
+ tnl->Driver.Render.Start(ctx);
+ }
}
}
r128ContextPtr rmesa = R128_CONTEXT(ctx);
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
- rmesa->verts = ALIGN_MALLOC(size * 4 * 16, 32);
+ rmesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32);
{
static int firsttime = 1;
-# $Id: Makefile.X11,v 1.5 2003/10/20 02:17:33 jonsmirl Exp $
+# $Id: Makefile.X11,v 1.6 2003/10/21 06:05:46 jonsmirl Exp $
# Mesa 3-D graphics library
# Version: 5.0
../common/utils.c \
../common/texmem.c \
../common/vblank.c \
+ ../common/xmlconfig.c \
r200_cmdbuf.c \
r200_pixel.c \
r200_tex.c \
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_cmdbuf.c,v 1.1 2002/10/30 12:51:51 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.c,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
int R200_DEBUG = (0);
#endif
-
+/* R200 configuration
+ */
+#include "xmlpool.h"
+
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_PREFERRED_BPT(0,"0,16,32")
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+const GLuint __driNConfigOptions = 5;
/* Return the width and height of the given buffer.
*/
static int
-get_ust_nop( int64_t * ust )
+get_ust_nop( uint64_t * ust )
{
*ust = 1;
return 0;
r200ContextPtr rmesa;
GLcontext *ctx, *shareCtx;
int i;
+ int tcl_mode, fthrottle_mode, preferred_bpt;
assert(glVisual);
assert(driContextPriv);
rmesa->dri.fd = sPriv->fd;
rmesa->dri.drmMinor = sPriv->drmMinor;
+ /* Parse configuration files */
+ driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+ screen->driScreen->myNum, "r200");
rmesa->r200Screen = screen;
rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
screen->sarea_priv_offset);
sizeof( r200TexObj ),
(destroy_texture_object_t *) r200DestroyTexObj );
}
+ preferred_bpt = driQueryOptioni (&rmesa->optionCache, "preferred_bpt");
+ rmesa->default32BitTextures =
+ ( ( preferred_bpt == 0 && screen->cpp == 4 ) || preferred_bpt == 32 );
rmesa->swtcl.RenderIndex = ~0;
rmesa->lost_context = 1;
r200InitState( rmesa );
r200InitSwtcl( ctx );
+ fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
rmesa->iw.irq_seq = -1;
rmesa->irqsEmitted = 0;
rmesa->do_irqs = (rmesa->dri.drmMinor >= 6 &&
- !getenv("R200_NO_IRQS") &&
+ fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
rmesa->r200Screen->irq);
+ rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+
if (!rmesa->do_irqs)
- fprintf(stderr,
- "IRQ's not enabled, falling back to busy waits: %d %d %d\n",
+ fprintf(stderr,
+ "IRQ's not enabled, falling back to %s: %d %d %d\n",
+ rmesa->do_usleeps ? "usleeps" : "busy waits",
rmesa->dri.drmMinor,
- !!getenv("R200_NO_IRQS"),
+ fthrottle_mode,
rmesa->r200Screen->irq);
+ rmesa->vblank_flags = (rmesa->r200Screen->irq != 0)
+ ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
- rmesa->do_usleeps = !getenv("R200_NO_USLEEPS");
-
- rmesa->vblank_flags = (rmesa->do_irqs)
- ? driGetDefaultVBlankFlags() : VBLANK_FLAG_NO_IRQ;
-
- rmesa->prefer_agp_client_texturing =
- (getenv("R200_AGP_CLIENT_TEXTURES") != 0);
-
-#ifndef _SOLO
- rmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( "__glXGetUST" );
+ rmesa->prefer_gart_client_texturing =
+ (getenv("R200_GART_CLIENT_TEXTURES") != 0);
+#ifndef _SOLO
+ rmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( (const GLubyte *) "__glXGetUST" );
if ( rmesa->get_ust == NULL ) {
rmesa->get_ust = get_ust_nop;
}
-
- (*rmesa->get_ust)( & rmesa->swap_ust );
+#else
+ rmesa->get_ust = get_ust_nop;
#endif
+ (*rmesa->get_ust)( & rmesa->swap_ust );
+
#if DO_DEBUG
R200_DEBUG = driParseDebugString( getenv( "R200_DEBUG" ),
debug_control );
#endif
- if (getenv("R200_NO_RAST")) {
+ tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
fprintf(stderr, "disabling 3D acceleration\n");
FALLBACK(rmesa, R200_FALLBACK_DISABLE, 1);
}
- else if (getenv("R200_NO_TCL")) {
+ else if (tcl_mode == DRI_CONF_TCL_SW) {
fprintf(stderr, "disabling TCL support\n");
TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
}
else {
- if (!getenv("R200_NO_VTXFMT")) {
- r200VtxfmtInit( ctx );
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT) {
+ r200VtxfmtInit( ctx, tcl_mode >= DRI_CONF_TCL_CODEGEN );
}
_tnl_need_dlist_norm_lengths( ctx, GL_FALSE );
}
r200FlushCmdBuf( rmesa, __FUNCTION__ );
}
- if (!rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
- if (!getenv("R200_NO_VTXFMT"))
+ if (!(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)) {
+ int tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
r200VtxfmtDestroy( rmesa->glCtx );
+ }
/* free the Mesa context */
rmesa->glCtx->DriverCtx = NULL;
* texture object data.
*/
int i;
-
+
/* this assert is wrong. The default textures are always on swap list
assert( is_empty_list( & rmesa->swapped ) ); */
}
}
+ /* free the option cache */
+ driDestroyOptionCache (&rmesa->optionCache);
+
FREE( rmesa );
}
}
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, newCtx->glCtx);
if ( newCtx->dri.drawable != driDrawPriv ) {
+ driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
newCtx->dri.drawable = driDrawPriv;
r200UpdateWindow( newCtx->glCtx );
r200UpdateViewportOffset( newCtx->glCtx );
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
drmBufPtr buf;
};
-#define GET_START(rvb) (rmesa->r200Screen->agp_buffer_offset + \
+#define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset + \
(rvb)->address - rmesa->dma.buf0_address + \
(rvb)->start)
unsigned nr_heaps;
driTexHeap * texture_heaps[ R200_NR_TEX_HEAPS ];
driTextureObject swapped;
+ GLboolean default32BitTextures;
/* Rasterization and vertex state:
/* Clientdata textures;
*/
- GLuint prefer_agp_client_texturing;
+ GLuint prefer_gart_client_texturing;
/* Drawable, cliprect and scissor information
*/
/* Mirrors of some DRI state
*/
struct r200_dri_mirror dri;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
};
#define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.c,v 1.4 2002/12/17 00:32:56 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
*/
-
+
#include <sched.h>
#include <errno.h>
}
-/* This version of AllocateMemoryNV allocates only agp memory, and
+/* This version of AllocateMemoryMESA allocates only GART memory, and
* only does so after the point at which the driver has been
* initialized.
*
* the kernel data structures, and the current context to get the
* device fd.
*/
-void *r200AllocateMemoryNV(GLsizei size, GLfloat readfreq,
- GLfloat writefreq, GLfloat priority)
+void *r200AllocateMemoryMESA(GLsizei size,
+ GLfloat readfreq, GLfloat writefreq,
+ GLfloat priority)
{
GET_CURRENT_CONTEXT(ctx);
r200ContextPtr rmesa;
fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq,
writefreq, priority);
- if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || rmesa->r200Screen->IsPCI )
+ if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->r200Screen->gartTextures.map)
return NULL;
if (getenv("R200_NO_ALLOC"))
if (rmesa->dri.drmMinor < 6)
return NULL;
- alloc.region = RADEON_MEM_REGION_AGP;
+ alloc.region = RADEON_MEM_REGION_GART;
alloc.alignment = 0;
alloc.size = size;
alloc.region_offset = ®ion_offset;
}
{
- char *region_start = (char *)rmesa->r200Screen->agpTextures.map;
+ char *region_start = (char *)rmesa->r200Screen->gartTextures.map;
return (void *)(region_start + region_offset);
}
}
-/* Called via glXFreeMemoryNV() */
-void r200FreeMemoryNV(GLvoid *pointer)
+/* Called via glXFreeMemoryMESA() */
+void r200FreeMemoryMESA(GLvoid *pointer)
{
GET_CURRENT_CONTEXT(ctx);
r200ContextPtr rmesa;
if (R200_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s %p\n", __FUNCTION__, pointer);
- if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || rmesa->r200Screen->IsPCI ) {
+ if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->r200Screen->gartTextures.map) {
fprintf(stderr, "%s: no context\n", __FUNCTION__);
return;
}
if (rmesa->dri.drmMinor < 6)
return;
- region_offset = (char *)pointer - (char *)rmesa->r200Screen->agpTextures.map;
+ region_offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
if (region_offset < 0 ||
- region_offset > rmesa->r200Screen->agpTextures.size) {
+ region_offset > rmesa->r200Screen->gartTextures.size) {
fprintf(stderr, "offset %d outside range 0..%d\n", region_offset,
- rmesa->r200Screen->agpTextures.size);
+ rmesa->r200Screen->gartTextures.size);
return;
}
- memfree.region = RADEON_MEM_REGION_AGP;
+ memfree.region = RADEON_MEM_REGION_GART;
memfree.region_offset = region_offset;
ret = drmCommandWrite( rmesa->r200Screen->driScreen->fd,
fprintf(stderr, "%s: DRM_RADEON_FREE ret %d\n", __FUNCTION__, ret);
}
-/* Called via glXGetAGPOffsetMESA() */
-GLuint r200GetAGPOffset(const GLvoid *pointer)
+/* Called via glXGetMemoryOffsetMESA() */
+GLuint r200GetMemoryOffsetMESA(const GLvoid *pointer)
{
GET_CURRENT_CONTEXT(ctx);
r200ContextPtr rmesa;
return ~0;
}
- if (!r200IsAgpMemory( rmesa, pointer, 0 ))
+ if (!r200IsGartMemory( rmesa, pointer, 0 ))
return ~0;
if (rmesa->dri.drmMinor < 6)
return ~0;
- card_offset = r200AgpOffsetFromVirtual( rmesa, pointer );
+ card_offset = r200GartOffsetFromVirtual( rmesa, pointer );
- return card_offset - rmesa->r200Screen->agp_base;
+ return card_offset - rmesa->r200Screen->gart_base;
}
-GLboolean r200IsAgpMemory( r200ContextPtr rmesa, const GLvoid *pointer,
+GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
GLint size )
{
- int offset = (char *)pointer - (char *)rmesa->r200Screen->agpTextures.map;
+ int offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
int valid = (size >= 0 &&
offset >= 0 &&
- offset + size < rmesa->r200Screen->agpTextures.size);
+ offset + size < rmesa->r200Screen->gartTextures.size);
if (R200_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "r200IsAgpMemory( %p ) : %d\n", pointer, valid );
+ fprintf(stderr, "r200IsGartMemory( %p ) : %d\n", pointer, valid );
return valid;
}
-GLuint r200AgpOffsetFromVirtual( r200ContextPtr rmesa, const GLvoid *pointer )
+GLuint r200GartOffsetFromVirtual( r200ContextPtr rmesa, const GLvoid *pointer )
{
- int offset = (char *)pointer - (char *)rmesa->r200Screen->agpTextures.map;
+ int offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
- if (offset < 0 || offset > rmesa->r200Screen->agpTextures.size)
+ if (offset < 0 || offset > rmesa->r200Screen->gartTextures.size)
return ~0;
else
- return rmesa->r200Screen->agp_texture_offset + offset;
+ return rmesa->r200Screen->gart_texture_offset + offset;
}
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
extern void r200WaitForVBlank( r200ContextPtr rmesa );
extern void r200InitIoctlFuncs( GLcontext *ctx );
-extern void *r200AllocateMemoryNV( GLsizei size, GLfloat readfreq,
+extern void *r200AllocateMemoryMESA( GLsizei size, GLfloat readfreq,
GLfloat writefreq, GLfloat priority );
-extern void r200FreeMemoryNV( GLvoid *pointer );
-extern GLuint r200GetAGPOffset( const GLvoid *pointer );
-extern GLboolean r200IsAgpMemory( r200ContextPtr rmesa, const GLvoid *pointer,
- GLint size );
+extern void r200FreeMemoryMESA( GLvoid *pointer );
+extern GLuint r200GetMemoryOffsetMESA( const GLvoid *pointer );
+extern GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
+ GLint size );
-extern GLuint r200AgpOffsetFromVirtual( r200ContextPtr rmesa,
- const GLvoid *pointer );
+extern GLuint r200GartOffsetFromVirtual( r200ContextPtr rmesa,
+ const GLvoid *pointer );
/* ================================================================
* Helper macros:
-/* $XFree86$ */
-/**************************************************************************
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
void r200GetLock( r200ContextPtr rmesa, GLuint flags )
{
__DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen;
RADEONSAREAPrivPtr sarea = rmesa->sarea;
int i;
-/* $XFree86$ */
-/**************************************************************************
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
-/**************************************************************************
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos_arrays.c,v 1.3 2003/02/23 23:59:01 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
}
+static void emit_vec4( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 4)
+ COPY_DWORDS( out, data, count );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out++;
+ data += stride;
+ }
+}
static void emit_vec8( GLcontext *ctx,
/* Emit the data
*/
switch (size) {
+ case 1:
+ emit_vec4( ctx, rvb, data, stride, count );
+ break;
case 2:
emit_vec8( ctx, rvb, data, stride, count );
break;
-/* Emit any changed arrays to new agp memory, re-emit a packet to
+/* Emit any changed arrays to new GART memory, re-emit a packet to
* update the arrays.
*/
void r200EmitArrays( GLcontext *ctx, GLuint inputs )
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos_vbtmp.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos_verts.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.c,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
if (R200_DEBUG & DEBUG_PIXEL)
fprintf(stderr, "%s\n", __FUNCTION__);
- /* Only accelerate reading to agp buffers.
+ /* Only accelerate reading to GART buffers.
*/
- if ( !r200IsAgpMemory(rmesa, pixels,
+ if ( !r200IsGartMemory(rmesa, pixels,
pitch * height * rmesa->r200Screen->cpp ) ) {
if (R200_DEBUG & DEBUG_PIXEL)
- fprintf(stderr, "%s: dest not agp\n", __FUNCTION__);
+ fprintf(stderr, "%s: dest not GART\n", __FUNCTION__);
return GL_FALSE;
}
int nbox = dPriv->numClipRects;
int src_offset = rmesa->state.color.drawOffset;
int src_pitch = rmesa->state.color.drawPitch * rmesa->r200Screen->cpp;
- int dst_offset = r200AgpOffsetFromVirtual( rmesa, pixels);
+ int dst_offset = r200GartOffsetFromVirtual( rmesa, pixels );
int dst_pitch = pitch * rmesa->r200Screen->cpp;
XF86DRIClipRectRec *box = dPriv->pClipRects;
int i;
int i;
int blit_format;
int size;
- int src_offset = r200AgpOffsetFromVirtual( rmesa, pixels);
+ int src_offset = r200GartOffsetFromVirtual( rmesa, pixels );
int src_pitch = pitch * rmesa->r200Screen->cpp;
if (R200_DEBUG & DEBUG_PIXEL)
if (planemask != ~0)
return GL_FALSE; /* fix me -- should be possible */
- /* Can't do conversions on agp reads/draws.
+ /* Can't do conversions on GART reads/draws.
*/
- if ( !r200IsAgpMemory( rmesa, pixels, size ) ) {
+ if ( !r200IsGartMemory( rmesa, pixels, size ) ) {
if (R200_DEBUG & DEBUG_PIXEL)
- fprintf(stderr, "%s: not agp memory\n", __FUNCTION__);
+ fprintf(stderr, "%s: not GART memory\n", __FUNCTION__);
return GL_FALSE;
}
return GL_FALSE;
}
- if ( r200IsAgpMemory(rmesa, pixels, size) )
+ if ( r200IsGartMemory(rmesa, pixels, size) )
{
do_draw_pix( ctx, x, y, width, height, pitch, pixels,
dest, planemask );
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_reg.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
#define R200_CP_CMD_BITBLT_MULTI 0xC0009B00
#define R200_CP_CMD_TRANS_BITBLT 0xC0009C00
-
-#define R200_AGP_TEX_OFFSET 0x02000000
-
-
-
-
#endif
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_sanity.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
/**************************************************************************
Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
* Keith Whitwell <keith@tungstengraphics.com>
*
*/
-#include <errno.h>
+
+#include <errno.h>
#include "glheader.h"
#include "imports.h"
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_screen.c,v 1.4 2003/05/08 09:25:35 herrb Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
#include "r200_screen.h"
#include "r200_context.h"
#include "r200_ioctl.h"
+#include "radeon_macros.h"
+#include "radeon_reg.h"
#include "utils.h"
#include "vblank.h"
-
#ifndef _SOLO
#include "glxextensions.h"
-#endif
-
+#endif
#if 1
/* Including xf86PciInfo.h introduces a bunch of errors...
*/
break;
}
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&screen->optionCache);
/* This is first since which regions we map depends on whether or
* not we are using a PCI card.
int ret;
drmRadeonGetParam gp;
- gp.param = RADEON_PARAM_AGP_BUFFER_OFFSET;
- gp.value = &screen->agp_buffer_offset;
+ gp.param = RADEON_PARAM_GART_BUFFER_OFFSET;
+ gp.value = &screen->gart_buffer_offset;
ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
&gp, sizeof(gp));
if (ret) {
FREE( screen );
- fprintf(stderr, "drmRadeonGetParam (RADEON_PARAM_AGP_BUFFER_OFFSET): %d\n", ret);
+ fprintf(stderr, "drmRadeonGetParam (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret);
return NULL;
}
- screen->agp_texture_offset =
- screen->agp_buffer_offset + 2*1024*1024;
-
-
if (sPriv->drmMinor >= 6) {
- gp.param = RADEON_PARAM_AGP_BASE;
- gp.value = &screen->agp_base;
+ gp.param = RADEON_PARAM_GART_BASE;
+ gp.value = &screen->gart_base;
ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
&gp, sizeof(gp));
if (ret) {
FREE( screen );
- fprintf(stderr, "drmR200GetParam (RADEON_PARAM_AGP_BASE): %d\n", ret);
+ fprintf(stderr, "drmR200GetParam (RADEON_PARAM_GART_BASE): %d\n", ret);
return NULL;
}
return NULL;
}
- if ( !screen->IsPCI ) {
- screen->agpTextures.handle = dri_priv->agpTexHandle;
- screen->agpTextures.size = dri_priv->agpTexMapSize;
+ if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
+ unsigned char *RADEONMMIO = screen->mmio.map;
+
+ screen->gartTextures.handle = dri_priv->gartTexHandle;
+ screen->gartTextures.size = dri_priv->gartTexMapSize;
if ( drmMap( sPriv->fd,
- screen->agpTextures.handle,
- screen->agpTextures.size,
- (drmAddressPtr)&screen->agpTextures.map ) ) {
+ screen->gartTextures.handle,
+ screen->gartTextures.size,
+ (drmAddressPtr)&screen->gartTextures.map ) ) {
drmUnmapBufs( screen->buffers );
drmUnmap( screen->status.map, screen->status.size );
drmUnmap( screen->mmio.map, screen->mmio.size );
FREE( screen );
- __driUtilMessage("%s: IsPCI failed\n", __FUNCTION__);
+ __driUtilMessage("%s: drmMAP failed for GART texture area\n", __FUNCTION__);
return NULL;
}
- }
-
+ screen->gart_texture_offset = dri_priv->gartTexOffset + ( screen->IsPCI
+ ? INREG( RADEON_AIC_LO_ADDR )
+ : ( ( INREG( RADEON_MC_AGP_LOCATION ) & 0x0ffffU ) << 16 ) );
+ }
screen->cpp = dri_priv->bpp / 8;
screen->AGPMode = dri_priv->AGPMode;
screen->logTexGranularity[RADEON_CARD_HEAP] =
dri_priv->log2TexGran;
- if ( screen->IsPCI ) {
+ if ( !screen->gartTextures.map ) {
screen->numTexHeaps = RADEON_NR_TEX_HEAPS - 1;
- screen->texOffset[RADEON_AGP_HEAP] = 0;
- screen->texSize[RADEON_AGP_HEAP] = 0;
- screen->logTexGranularity[RADEON_AGP_HEAP] = 0;
+ screen->texOffset[RADEON_GART_HEAP] = 0;
+ screen->texSize[RADEON_GART_HEAP] = 0;
+ screen->logTexGranularity[RADEON_GART_HEAP] = 0;
} else {
screen->numTexHeaps = RADEON_NR_TEX_HEAPS;
- screen->texOffset[RADEON_AGP_HEAP] =
- dri_priv->agpTexOffset + R200_AGP_TEX_OFFSET;
- screen->texSize[RADEON_AGP_HEAP] = dri_priv->agpTexMapSize;
- screen->logTexGranularity[RADEON_AGP_HEAP] =
- dri_priv->log2AGPTexGran;
+ screen->texOffset[RADEON_GART_HEAP] = screen->gart_texture_offset;
+ screen->texSize[RADEON_GART_HEAP] = dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_GART_HEAP] =
+ dri_priv->log2GARTTexGran;
}
screen->driScreen = sPriv;
screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
+#ifndef _SOLO
+ if ( driCompareGLXAPIVersion( 20030813 ) >= 0 ) {
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if ( glx_enable_extension != NULL ) {
+ if ( screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+
+ if ( driCompareGLXAPIVersion( 20030818 ) >= 0 ) {
+ sPriv->psc->allocateMemory = r200AllocateMemoryMESA;
+ sPriv->psc->freeMemory = r200FreeMemoryMESA;
+ sPriv->psc->memoryOffset = r200GetMemoryOffsetMESA;
+
+ (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
+ }
+ }
+ }
+#endif
return screen;
}
if (!screen)
return;
- if ( !screen->IsPCI ) {
- drmUnmap( screen->agpTextures.map,
- screen->agpTextures.size );
+ if ( screen->gartTextures.map ) {
+ drmUnmap( screen->gartTextures.map, screen->gartTextures.size );
}
drmUnmapBufs( screen->buffers );
drmUnmap( screen->status.map, screen->status.size );
drmUnmap( screen->mmio.map, screen->mmio.size );
+ /* free all option information */
+ driDestroyOptionInfo (&screen->optionCache);
+
FREE( screen );
sPriv->private = NULL;
}
* Return: pointer to a __DRIscreenPrivate.
*
*/
-#ifndef _SOLO
+#ifndef _SOLO
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config)
{
}
#endif
-
-
#ifndef _SOLO
-/* This function is called by libGL.so to allow the driver to dynamically
+/**
+ * This function is called by libGL.so to allow the driver to dynamically
* extend libGL. We can add new GLX functions and/or new GL functions.
* Note that _mesa_create_context() will probably add most of the newer
* OpenGL extension functions into the dispatcher.
+ *
+ * \todo This interface has been deprecated, so we should probably remove
+ * this function before the next XFree86 release.
*/
void
__driRegisterExtensions( void )
{
PFNGLXENABLEEXTENSIONPROC glx_enable_extension;
- typedef void *(*registerFunc)(const char *funcName, void *funcAddr);
- registerFunc regFunc;
if ( driCompareGLXAPIVersion( 20030317 ) >= 0 ) {
glx_enable_extension = (PFNGLXENABLEEXTENSIONPROC)
- glXGetProcAddress( "__glXEnableExtension" );
+ glXGetProcAddress( (const GLubyte *) "__glXEnableExtension" );
if ( glx_enable_extension != NULL ) {
- glx_enable_extension( "GLX_SGI_swap_control", GL_FALSE );
- glx_enable_extension( "GLX_SGI_video_sync", GL_FALSE );
- glx_enable_extension( "GLX_MESA_swap_control", GL_FALSE );
- glx_enable_extension( "GLX_MESA_swap_frame_usage", GL_FALSE );
-
-
- /* Get pointers to libGL's __glXRegisterGLXFunction
- * and __glXRegisterGLXExtensionString, if they exist.
- */
- regFunc = (registerFunc) glXGetProcAddress( "__glXRegisterGLXFunction" );
-
- if (regFunc) {
- /* register our GLX extensions with libGL */
- void *p;
- p = regFunc("glXAllocateMemoryNV", (void *) r200AllocateMemoryNV);
- if (p)
- ; /* XXX already registered - what to do, wrap? */
-
- p = regFunc("glXFreeMemoryNV", (void *) r200FreeMemoryNV);
- if (p)
- ; /* XXX already registered - what to do, wrap? */
-
- p = regFunc("glXGetAGPOffsetMESA", (void *) r200GetAGPOffset);
- if (p)
- ; /* XXX already registered - what to do, wrap? */
-
- glx_enable_extension( "GLX_NV_vertex_array_range", GL_TRUE );
- glx_enable_extension( "GLX_MESA_agp_offset", GL_TRUE );
- }
+ (*glx_enable_extension)( "GLX_SGI_swap_control", GL_FALSE );
+ (*glx_enable_extension)( "GLX_SGI_video_sync", GL_FALSE );
+ (*glx_enable_extension)( "GLX_MESA_swap_control", GL_FALSE );
+ (*glx_enable_extension)( "GLX_MESA_swap_frame_usage", GL_FALSE );
}
}
}
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_screen.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
#include "xf86drm.h"
#include "radeon_common.h"
#include "radeon_sarea.h"
+#include "xmlconfig.h"
typedef struct {
drmHandle handle; /* Handle to the DRM region */
r200RegionRec mmio;
r200RegionRec status;
- r200RegionRec agpTextures;
+ r200RegionRec gartTextures;
drmBufMapPtr buffers;
__DRIscreenPrivate *driScreen;
unsigned int sarea_priv_offset;
- unsigned int agp_buffer_offset; /* offset in card memory space */
- unsigned int agp_texture_offset; /* offset in card memory space */
- unsigned int agp_base;
+ unsigned int gart_buffer_offset; /* offset in card memory space */
+ unsigned int gart_texture_offset; /* offset in card memory space */
+ unsigned int gart_base;
GLboolean drmSupportsCubeMaps; /* need radeon kernel module >=1.7 */
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
} r200ScreenRec, *r200ScreenPtr;
#endif
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state.h,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state_init.c,v 1.4 2003/02/22 06:21:11 dawes Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
CHECK( always, GL_TRUE )
+CHECK( never, GL_FALSE )
CHECK( tex_any, ctx->Texture._EnabledUnits )
CHECK( tex, ctx->Texture.Unit[idx]._ReallyEnabled )
CHECK( fog, ctx->Fog.Enabled )
TCL_CHECK( tcl, GL_TRUE )
-TCL_CHECK( tcl_tex_any, ctx->Texture._EnabledUnits )
TCL_CHECK( tcl_tex, ctx->Texture.Unit[idx]._ReallyEnabled )
TCL_CHECK( tcl_lighting, ctx->Light.Enabled )
-TCL_CHECK( tcl_eyespace_or_lighting, ctx->_NeedEyeCoords || ctx->Light.Enabled )
TCL_CHECK( tcl_light, ctx->Light.Enabled && ctx->Light.Light[idx].Enabled )
TCL_CHECK( tcl_ucp, (ctx->Transform.ClipPlanesEnabled & (1 << idx)) )
-/* TCL_CHECK( tcl_eyespace_or_fog, ctx->_NeedEyeCoords || ctx->Fog.Enabled ) */
-
-
-static GLboolean check_tcl_eyespace_or_fog( GLcontext *ctx, int idx )
-{
- r200ContextPtr rmesa = R200_CONTEXT(ctx);
- int res;
- (void) idx;
- res = !rmesa->TclFallback && (ctx->_NeedEyeCoords || ctx->Fog.Enabled);
- fprintf(stderr, "%s: %d\n", __FUNCTION__, res);
- return res;
-}
/* Initialize the context's hardware state.
ALLOC_STATE( tf, tex_any, TF_STATE_SIZE, "TF/tfactor", 0 );
ALLOC_STATE( tex[0], tex_any, TEX_STATE_SIZE, "TEX/tex-0", 0 );
ALLOC_STATE( tex[1], tex_any, TEX_STATE_SIZE, "TEX/tex-1", 1 );
- ALLOC_STATE( cube[0], tex_any, CUBE_STATE_SIZE, "CUBE/tex-0", 0 );
- ALLOC_STATE( cube[1], tex_any, CUBE_STATE_SIZE, "CUBE/tex-1", 1 );
+
+ if (rmesa->r200Screen->drmSupportsCubeMaps) {
+ ALLOC_STATE( cube[0], tex_any, CUBE_STATE_SIZE, "CUBE/tex-0", 0 );
+ ALLOC_STATE( cube[1], tex_any, CUBE_STATE_SIZE, "CUBE/tex-1", 1 );
+ }
+ else {
+ ALLOC_STATE( cube[0], never, CUBE_STATE_SIZE, "CUBE/tex-0", 0 );
+ ALLOC_STATE( cube[1], never, CUBE_STATE_SIZE, "CUBE/tex-1", 1 );
+ }
ALLOC_STATE( tcl, tcl, TCL_STATE_SIZE, "TCL/tcl", 0 );
ALLOC_STATE( msl, tcl, MSL_STATE_SIZE, "MSL/matrix-select", 0 );
ctx->Driver.Lightfv( ctx, p, GL_LINEAR_ATTENUATION,
&l->LinearAttenuation );
ctx->Driver.Lightfv( ctx, p, GL_QUADRATIC_ATTENUATION,
- &l->QuadraticAttenuation );
+ &l->QuadraticAttenuation );
}
ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_AMBIENT,
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c,v 1.5 2003/05/06 23:52:08 daenzer Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
if (rmesa->dma.current.buf) {
struct r200_dma_region *current = &rmesa->dma.current;
- GLuint current_offset = (rmesa->r200Screen->agp_buffer_offset +
+ GLuint current_offset = (rmesa->r200Screen->gart_buffer_offset +
current->buf->buf->idx * RADEON_BUFFER_SIZE +
current->start);
{
- char *head = rmesa->dma.current.address + rmesa->dma.current.ptr;
+ GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr);
rmesa->dma.current.ptr += bytes;
rmesa->swtcl.numverts += nverts;
return head;
\
r200EmitVertexAOS( rmesa, \
rmesa->swtcl.vertex_size, \
- (rmesa->r200Screen->agp_buffer_offset + \
+ (rmesa->r200Screen->gart_buffer_offset + \
rmesa->swtcl.indexed_verts.buf->buf->idx * \
RADEON_BUFFER_SIZE + \
rmesa->swtcl.indexed_verts.start)); \
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.c,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
-/**************************************************************************
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.h,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.c,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
GLenum format, GLenum type )
{
r200ContextPtr rmesa = R200_CONTEXT(ctx);
- const GLboolean do32bpt = ( rmesa->r200Screen->cpp == 4 );
+ const GLboolean do32bpt = rmesa->default32BitTextures;
switch ( internalFormat ) {
case 4:
* relaxed, but would need to store the image pitch somewhere,
* as packing details might change before image is uploaded:
*/
- if (!r200IsAgpMemory( rmesa, pixels, srcHeight * srcRowStride ) ||
+ if (!r200IsGartMemory( rmesa, pixels, srcHeight * srcRowStride ) ||
(srcRowStride & 63))
return 0;
fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
/* Normal path: copy (to cached memory) and eventually upload
- * via another copy to agp memory and then a blit... Could
- * eliminate one copy by going straight to (permanent) agp.
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
*
* Note, this will call r200ChooseTextureFormat.
*/
fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
/* Normal path: copy (to cached memory) and eventually upload
- * via another copy to agp memory and then a blit... Could
- * eliminate one copy by going straight to (permanent) agp.
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
*
* Note, this will call r200ChooseTextureFormat.
*/
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texmem.c,v 1.5 2002/12/17 00:32:56 dawes Exp $ */
/**************************************************************************
Copyright (C) Tungsten Graphics 2002. All Rights Reserved.
* Gareth Hughes <gareth@valinux.com>
*
*/
+
#include <errno.h>
#include "glheader.h"
*/
-static void r200UploadAGPClientSubImage( r200ContextPtr rmesa,
- r200TexObjPtr t,
- struct gl_texture_image *texImage,
- GLint hwlevel,
- GLint x, GLint y,
- GLint width, GLint height )
+static void r200UploadGARTClientSubImage( r200ContextPtr rmesa,
+ r200TexObjPtr t,
+ struct gl_texture_image *texImage,
+ GLint hwlevel,
+ GLint x, GLint y,
+ GLint width, GLint height )
{
const struct gl_texture_format *texFormat = texImage->TexFormat;
GLuint srcPitch, dstPitch;
}
t->image[0][hwlevel].data = texImage->Data;
- srcOffset = r200AgpOffsetFromVirtual( rmesa, texImage->Data );
+ srcOffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
assert( srcOffset != ~0 );
height = texImage->Height;
dstPitch = t->pp_txpitch + 32;
- if (rmesa->prefer_agp_client_texturing && texImage->IsClientData) {
- /* In this case, could also use agp texturing. This is
+ if (rmesa->prefer_gart_client_texturing && texImage->IsClientData) {
+ /* In this case, could also use GART texturing. This is
* currently disabled, but has been tested & works.
*/
- t->pp_txoffset = r200AgpOffsetFromVirtual( rmesa, texImage->Data );
+ t->pp_txoffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
t->pp_txpitch = texImage->RowStride * texFormat->TexelBytes - 32;
if (R200_DEBUG & DEBUG_TEXTURE)
fprintf(stderr,
- "Using agp texturing for rectangular client texture\n");
+ "Using GART texturing for rectangular client texture\n");
/* Release FB memory allocated for this image:
*/
}
}
else if (texImage->IsClientData) {
- /* Data already in agp memory, with usable pitch.
+ /* Data already in GART memory, with usable pitch.
*/
GLuint srcPitch;
srcPitch = texImage->RowStride * texFormat->TexelBytes;
r200EmitBlit( rmesa,
blit_format,
srcPitch,
- r200AgpOffsetFromVirtual( rmesa, texImage->Data ),
+ r200GartOffsetFromVirtual( rmesa, texImage->Data ),
dstPitch, t->bufAddr,
0, 0,
0, 0,
width, height );
}
else {
- /* Data not in agp memory, or bad pitch.
+ /* Data not in GART memory, or bad pitch.
*/
for (done = 0; done < height ; ) {
struct r200_dma_region region;
}
else if (texImage->IsClientData) {
if ( R200_DEBUG & DEBUG_TEXTURE )
- fprintf( stderr, "%s: image data is in agp client storage\n",
+ fprintf( stderr, "%s: image data is in GART client storage\n",
__FUNCTION__);
- r200UploadAGPClientSubImage( rmesa, t, texImage, hwlevel,
+ r200UploadGARTClientSubImage( rmesa, t, texImage, hwlevel,
x, y, width, height );
return;
}
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texstate.c,v 1.3 2003/02/15 22:18:47 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
GLint curOffset;
GLint i;
- GLint firstLevel=0, lastLevel=0, numLevels;
+ GLint numLevels;
GLint log2Width, log2Height, log2Depth;
/* Set the hardware texture format
}
-
/* 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 (R200_DEBUG & DEBUG_TEXTURE)
- fprintf(stderr,
- "%s: BaseLevel %d MinLod %f MaxLod %f MaxLevel %d\n",
- __FUNCTION__,
- tObj->BaseLevel, tObj->MinLod, tObj->MaxLod,
- tObj->MaxLevel);
-
-
- switch (tObj->Target) {
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_CUBE_MAP:
- 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 */
- log2Width = tObj->Image[firstLevel]->WidthLog2;
- log2Height = tObj->Image[firstLevel]->HeightLog2;
- log2Depth = 0;
- break;
- case GL_TEXTURE_3D:
- firstLevel = tObj->BaseLevel;
- lastLevel = tObj->BaseLevel;
- log2Width = tObj->Image[firstLevel]->WidthLog2;
- log2Height = tObj->Image[firstLevel]->HeightLog2;
- log2Depth = tObj->Image[firstLevel]->DepthLog2;
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- firstLevel = lastLevel = 0;
- log2Width = log2Height = 1; /* ? */
- log2Depth = 0;
- break;
- default:
- return;
- }
-
- /* save these values */
- t->base.firstLevel = firstLevel;
- t->base.lastLevel = lastLevel;
- numLevels = lastLevel - firstLevel + 1;
-
- if (R200_DEBUG & DEBUG_TEXTURE)
- fprintf(stderr,
- "%s: firstLevel %d last Level %d w,h: %d,%d log(w,h) %d,%d\n",
- __FUNCTION__, firstLevel, lastLevel,
- tObj->Image[firstLevel]->Width,
- tObj->Image[firstLevel]->Height,
- tObj->Image[firstLevel]->WidthLog2,
- tObj->Image[firstLevel]->HeightLog2);
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ log2Width = tObj->Image[t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[t->base.firstLevel]->HeightLog2;
+ log2Depth = tObj->Image[t->base.firstLevel]->DepthLog2;
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
const struct gl_texture_image *texImage;
GLuint size;
- texImage = tObj->Image[i + firstLevel];
+ texImage = tObj->Image[i + t->base.firstLevel];
if ( !texImage )
break;
}
assert(size > 0);
- if (curOffset & 0x1f) {
- /* align to 32-byte offset */
- curOffset = (curOffset + 0x1f) & ~0x1f;
- }
+
+ /* Align to 32-byte offset. It is faster to do this unconditionally
+ * (no branch penalty).
+ */
+
+ curOffset = (curOffset + 0x1f) & ~0x1f;
t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES;
t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES;
(log2Height << R200_FACE_HEIGHT_4_SHIFT));
}
- t->pp_txsize = (((tObj->Image[firstLevel]->Width - 1) << 0) |
- ((tObj->Image[firstLevel]->Height - 1) << 16));
+ t->pp_txsize = (((tObj->Image[t->base.firstLevel]->Width - 1) << 0) |
+ ((tObj->Image[t->base.firstLevel]->Height - 1) << 16));
/* Only need to round to nearest 32 for textures, but the blitter
* requires 64-byte aligned pitches, and we may/may not need the
* blitter. NPOT only!
*/
if (baseImage->IsCompressed)
- t->pp_txpitch = (tObj->Image[firstLevel]->Width + 63) & ~(63);
+ t->pp_txpitch = (tObj->Image[t->base.firstLevel]->Width + 63) & ~(63);
else
- t->pp_txpitch = ((tObj->Image[firstLevel]->Width * baseImage->TexFormat->TexelBytes) + 63) & ~(63);
+ t->pp_txpitch = ((tObj->Image[t->base.firstLevel]->Width * baseImage->TexFormat->TexelBytes) + 63) & ~(63);
t->pp_txpitch -= 32;
t->dirty_state = TEX_ALL;
ASSERT(tObj->Target == GL_TEXTURE_3D);
+ /* R100 & R200 do not support mipmaps for 3D textures.
+ */
+ if ( (tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR) ) {
+ return GL_FALSE;
+ }
+
if ( t->base.dirty_images[0] ) {
R200_FIREVERTICES( rmesa );
r200SetTexImages( rmesa, tObj );
R200_FIREVERTICES( rmesa );
r200SetTexImages( rmesa, tObj );
r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
- if ( !t->base.memBlock && !rmesa->prefer_agp_client_texturing )
+ if ( !t->base.memBlock && !rmesa->prefer_gart_client_texturing )
return GL_FALSE;
}
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt.c,v 1.4 2003/05/06 23:52:08 daenzer Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
*/
-void r200VtxfmtInit( GLcontext *ctx )
+void r200VtxfmtInit( GLcontext *ctx, GLboolean useCodegen )
{
r200ContextPtr rmesa = R200_CONTEXT( ctx );
GLvertexformat *vfmt = &(rmesa->vb.vtxfmt);
make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
- r200InitCodegen( &rmesa->vb.codegen );
+ r200InitCodegen( &rmesa->vb.codegen, useCodegen );
}
static void free_funcs( struct dynfn *l )
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
extern void r200VtxfmtUpdate( GLcontext *ctx );
-extern void r200VtxfmtInit( GLcontext *ctx );
+extern void r200VtxfmtInit( GLcontext *ctx, GLboolean useCodegen );
extern void r200VtxfmtInvalidate( GLcontext *ctx );
extern void r200VtxfmtDestroy( GLcontext *ctx );
extern void r200VtxfmtInitChoosers( GLvertexformat *vfmt );
/*
*/
-void r200InitCodegen( struct dfn_generators *gen );
+void r200InitCodegen( struct dfn_generators *gen, GLboolean useCodegen );
void r200InitX86Codegen( struct dfn_generators *gen );
void r200InitSSECodegen( struct dfn_generators *gen );
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_c.c,v 1.2 2002/12/16 16:18:56 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
return 0;
}
-void r200InitCodegen( struct dfn_generators *gen )
+void r200InitCodegen( struct dfn_generators *gen, GLboolean useCodegen )
{
gen->Vertex3f = codegen_noop;
gen->Vertex3fv = codegen_noop;
gen->MultiTexCoord1fARB = codegen_noop;
gen->MultiTexCoord1fvARB = codegen_noop;
- if (!getenv("R200_NO_CODEGEN")) {
+ if (useCodegen) {
#if defined(USE_X86_ASM)
r200InitX86Codegen( gen );
#endif
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_sse.c,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86$ */
-/**************************************************************************
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_x86.c,v 1.2 2002/12/16 16:18:56 dawes Exp $ */
+/*
Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
The Weather Channel (TM) funded Tungsten Graphics to develop the
-/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxtmp_x86.S,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxtmp_x86.S,v 1.2 2002/11/07 18:31:59 tsi Exp $ */
/**************************************************************************
Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
.data
.align 4
-GLOBL( _x86_Normal3fv)
- movl 4(%esp), %eax /* load 'v' off stack */
- movl (%eax), %ecx /* load v[0] */
- movl 4(%eax), %edx /* load v[1] */
- movl 8(%eax), %eax /* load v[2] */
- movl %ecx, 0 /* store v[0] to current vertex */
- movl %edx, 4 /* store v[1] to current vertex */
- movl %eax, 8 /* store v[2] to current vertex */
- ret
-GLOBL ( _x86_Normal3fv_end )
/*
vertex 3f vertex size 4
.6: jmp *0
GLOBL ( _x86_Vertex3fv_end )
-/*
- Normal 3f
-*/
-GLOBL ( _x86_Normal3f )
- movl $0x12345678, %edx
+
+/**
+ * Generic handler for 2 float format data. This can be used for
+ * TexCoord2f and possibly other functions.
+ */
+
+GLOBL ( _x86_Attribute2f )
+ movl $0x0, %edx
movl 4(%esp), %eax
+ movl 8(%esp), %ecx
movl %eax, (%edx)
- movl 8(%esp), %eax
- movl %eax, 4(%edx)
+ movl %ecx, 4(%edx)
+ ret
+GLOBL ( _x86_Attribute2f_end )
+
+
+/**
+ * Generic handler for 2 float vector format data. This can be used for
+ * TexCoord2fv and possibly other functions.
+ */
+
+GLOBL( _x86_Attribute2fv)
+ movl 4(%esp), %eax /* load 'v' off stack */
+ movl (%eax), %ecx /* load v[0] */
+ movl 4(%eax), %eax /* load v[1] */
+ movl %ecx, 0 /* store v[0] to current vertex */
+ movl %eax, 4 /* store v[1] to current vertex */
+ ret
+GLOBL ( _x86_Attribute2fv_end )
+
+
+/**
+ * Generic handler for 3 float format data. This can be used for
+ * Normal3f, Color3f (when the color target is also float), or
+ * TexCoord3f.
+ */
+
+GLOBL ( _x86_Attribute3f )
+ movl 4(%esp), %ecx
+ movl 8(%esp), %edx
movl 12(%esp), %eax
- movl %eax, 8(%edx)
+ movl %ecx, 0
+ movl %edx, 4
+ movl %eax, 8
ret
-GLOBL ( _x86_Normal3f_end )
+GLOBL ( _x86_Attribute3f_end )
+
+/**
+ * Generic handler for 3 float vector format data. This can be used for
+ * Normal3f, Color3f (when the color target is also float), or
+ * TexCoord3f.
+ */
+
+GLOBL( _x86_Attribute3fv)
+ movl 4(%esp), %eax /* load 'v' off stack */
+ movl (%eax), %ecx /* load v[0] */
+ movl 4(%eax), %edx /* load v[1] */
+ movl 8(%eax), %eax /* load v[2] */
+ movl %ecx, 0 /* store v[0] to current vertex */
+ movl %edx, 4 /* store v[1] to current vertex */
+ movl %eax, 8 /* store v[2] to current vertex */
+ ret
+GLOBL ( _x86_Attribute3fv_end )
+
/*
Color 4ubv_ub
ret
GLOBL( _x86_Color4ub_ub_end )
-/*
- Color3fv_3f
-*/
-GLOBL( _x86_Color3fv_3f )
- movl 4(%esp), %eax
- movl $0, %edx
- movl (%eax), %ecx
- movl %ecx, (%edx)
- movl 4(%eax), %ecx
- movl %ecx, 4(%edx)
- movl 8(%eax), %ecx
- movl %ecx, 8(%edx)
- ret
-GLOBL( _x86_Color3fv_3f_end )
-
-/*
- Color3f_3f
-*/
-GLOBL( _x86_Color3f_3f )
- movl $0x12345678, %edx
- movl 4(%esp), %eax
- movl %eax, (%edx)
- movl 8(%esp,1), %eax
- movl %eax, 4(%edx)
- movl 12(%esp), %eax
- movl %eax, 8(%edx)
- ret
-GLOBL( _x86_Color3f_3f_end )
/*
- TexCoord2fv
+ MultiTexCoord2fv st0/st1
*/
-
-GLOBL( _x86_TexCoord2fv )
- movl 4(%esp), %eax
- movl $0x12345678, %edx
- movl (%eax), %ecx
- movl 4(%eax), %eax
- movl %ecx, (%edx)
- movl %eax, 4(%edx)
- ret
-
-GLOBL( _x86_TexCoord2fv_end )
-/*
- TexCoord2f
-*/
-GLOBL( _x86_TexCoord2f )
- movl $0x12345678, %edx
+GLOBL( _x86_MultiTexCoord2fv )
movl 4(%esp), %eax
movl 8(%esp), %ecx
- movl %eax, (%edx)
- movl %ecx, 4(%edx)
- ret
-GLOBL( _x86_TexCoord2f_end )
-
-/*
- MultiTexCoord2fvARB st0/st1
-*/
-GLOBL( _x86_MultiTexCoord2fvARB )
-
- movl 4(%esp), %eax
- movl 8(%esp), %ecx
- sub $0x84c0, %eax
and $1, %eax
movl (%ecx), %edx
shl $3, %eax
movl %edx, 0xdeadbeef(%eax)
movl %ecx, 0xdeadbeef(%eax)
ret
-GLOBL( _x86_MultiTexCoord2fvARB_end )
+GLOBL( _x86_MultiTexCoord2fv_end )
+
/*
- MultiTexCoord2fvARB
+ MultiTexCoord2fv
*/
-GLOBL( _x86_MultiTexCoord2fvARB_2 )
+GLOBL( _x86_MultiTexCoord2fv_2 )
movl 4(%esp,1), %eax
movl 8(%esp,1), %ecx
- sub $0x84c0, %eax
and $0x1, %eax
movl 0(,%eax,4), %edx
movl (%ecx), %eax
movl 4(%ecx), %eax
movl %eax, 4(%edx)
ret
-
-GLOBL( _x86_MultiTexCoord2fvARB_2_end )
+GLOBL( _x86_MultiTexCoord2fv_2_end )
/*
- MultiTexCoord2fARB st0/st1
+ MultiTexCoord2f st0/st1
*/
-GLOBL( _x86_MultiTexCoord2fARB )
+GLOBL( _x86_MultiTexCoord2f )
movl 4(%esp), %eax
movl 8(%esp), %edx
- sub $0x84c0, %eax
movl 12(%esp), %ecx
and $1, %eax
shl $3, %eax
movl %edx, 0xdeadbeef(%eax)
movl %ecx, 0xdeadbeef(%eax)
ret
-GLOBL( _x86_MultiTexCoord2fARB_end )
+GLOBL( _x86_MultiTexCoord2f_end )
/*
- MultiTexCoord2fARB
+ MultiTexCoord2f
*/
-GLOBL( _x86_MultiTexCoord2fARB_2 )
+GLOBL( _x86_MultiTexCoord2f_2 )
movl 4(%esp), %eax
movl 8(%esp), %edx
- sub $0x84c0, %eax
movl 12(%esp,1), %ecx
and $1,%eax
movl 0(,%eax,4), %eax
movl %edx, (%eax)
movl %ecx, 4(%eax)
ret
-GLOBL( _x86_MultiTexCoord2fARB_2_end )
+GLOBL( _x86_MultiTexCoord2f_2_end )
+
+/**
+ * This can be used as a template for either Color3fv (when the color
+ * target is also a 3f) or Normal3fv.
+ */
+
+GLOBL( _sse_Attribute3fv )
+ movl 4(%esp), %eax
+ movlps (%eax), %xmm0
+ movl 8(%eax), %eax
+ movlps %xmm0, 0
+ movl %eax, 8
+ ret
+GLOBL( _sse_Attribute3fv_end )
+
+/**
+ * This can be used as a template for either Color3f (when the color
+ * target is also a 3f) or Normal3f.
+ */
+
+GLOBL( _sse_Attribute3f )
+ movlps 4(%esp), %xmm0
+ movl 12(%esp), %eax
+ movlps %xmm0, 0
+ movl %eax, 8
+ ret
+GLOBL( _sse_Attribute3f_end )
+
+
+/**
+ * Generic handler for 2 float vector format data. This can be used for
+ * TexCoord2fv and possibly other functions.
+ */
+
+GLOBL( _sse_Attribute2fv )
+ movl 4(%esp), %eax
+ movlps (%eax), %xmm0
+ movlps %xmm0, 0
+ ret
+GLOBL( _sse_Attribute2fv_end )
+
+
+/**
+ * Generic handler for 2 float format data. This can be used for
+ * TexCoord2f and possibly other functions.
+ */
+
+GLOBL( _sse_Attribute2f )
+ movlps 4(%esp), %xmm0
+ movlps %xmm0, 0
+ ret
+GLOBL( _sse_Attribute2f_end )
+
+/*
+ MultiTexCoord2fv st0/st1
+*/
+GLOBL( _sse_MultiTexCoord2fv )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $1, %eax
+ movlps (%ecx), %xmm0
+ movlps %xmm0, 0xdeadbeef(,%eax,8)
+ ret
+GLOBL( _sse_MultiTexCoord2fv_end )
+
+/*
+ MultiTexCoord2fv
+*/
+GLOBL( _sse_MultiTexCoord2fv_2 )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $0x1, %eax
+ movl 0(,%eax,4), %edx
+ movlps (%ecx), %xmm0
+ movlps %xmm0, (%edx)
+ ret
+GLOBL( _sse_MultiTexCoord2fv_2_end )
+
+/*
+ MultiTexCoord2f st0/st1
+*/
+GLOBL( _sse_MultiTexCoord2f )
+ movl 4(%esp), %eax
+ and $1, %eax
+ movlps 8(%esp), %xmm0
+ movlps %xmm0, 0xdeadbeef(,%eax,8)
+ ret
+GLOBL( _sse_MultiTexCoord2f_end )
+
+/*
+ MultiTexCoord2f
+*/
+GLOBL( _sse_MultiTexCoord2f_2 )
+ movl 4(%esp), %eax
+ movlps 8(%esp), %xmm0
+ and $1,%eax
+ movl 0(,%eax,4), %eax
+ movlps %xmm0, (%eax)
+ ret
+GLOBL( _sse_MultiTexCoord2f_2_end )
-# $Id: Makefile.X11,v 1.2 2003/10/20 02:17:33 jonsmirl Exp $
+# $Id: Makefile.X11,v 1.3 2003/10/21 06:05:49 jonsmirl Exp $
# Mesa 3-D graphics library
# Version: 5.0
../common/mm.c \
../common/utils.c \
../common/texmem.c \
- ../common/vblank.c
+ ../common/vblank.c \
+ ../common/xmlconfig.c
SUBSET_DRIVER_SOURCES = \
radeon_subset_bitmap.c \
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.c,v 1.7 2003/02/08 21:26:45 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.c,v 1.9 2003/09/24 02:43:12 dawes Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
#endif
+/* Radeon configuration
+ */
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_PREFERRED_BPT(0,"0,16,32")
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+const GLuint __driNConfigOptions = 5;
/* Return the width and height of the given buffer.
*/
offset = driGetRendererString( buffer, "Radeon", DRIVER_DATE,
agp_mode );
- sprintf( & buffer[ offset ], "%s %sTCL",
- ( rmesa->dri.drmMinor < 3 ) ? " DRM-COMPAT" : "",
+ sprintf( & buffer[ offset ], "%sTCL",
!(rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
? "" : "NO-" );
radeonContextPtr rmesa;
GLcontext *ctx, *shareCtx;
int i;
+ int tcl_mode, fthrottle_mode, preferred_bpt;
assert(glVisual);
assert(driContextPriv);
rmesa->dri.hwContext = driContextPriv->hHWContext;
rmesa->dri.hwLock = &sPriv->pSAREA->lock;
rmesa->dri.fd = sPriv->fd;
+ rmesa->dri.drmMinor = sPriv->drmMinor;
- /* If we don't have 1.3, fallback to the 1.1 interfaces.
- */
- if (getenv("RADEON_COMPAT") || sPriv->drmMinor < 3 )
- rmesa->dri.drmMinor = 1;
- else
- rmesa->dri.drmMinor = sPriv->drmMinor;
+ /* Parse configuration files */
+ driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+ screen->driScreen->myNum, "radeon");
rmesa->radeonScreen = screen;
rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],
& rmesa->c_textureSwaps );
}
+ preferred_bpt = driQueryOptioni (&rmesa->optionCache, "preferred_bpt");
+ rmesa->default32BitTextures =
+ ( ( preferred_bpt == 0 && screen->cpp == 4 ) || preferred_bpt == 32 );
rmesa->swtcl.RenderIndex = ~0;
rmesa->lost_context = 1;
MIN2( ctx->Const.MaxArrayLockSize,
RADEON_BUFFER_SIZE / RADEON_MAX_TCL_VERTSIZE );
- rmesa->boxes = (getenv("LIBGL_PERFORMANCE_BOXES") != NULL);
+ rmesa->boxes = 0;
/* Initialize the software rasterizer and helper modules.
*/
radeonInitState( rmesa );
radeonInitSwtcl( ctx );
+ fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
rmesa->iw.irq_seq = -1;
rmesa->irqsEmitted = 0;
- rmesa->do_irqs = (rmesa->radeonScreen->irq && !getenv("RADEON_NO_IRQS"));
+ rmesa->do_irqs = (rmesa->radeonScreen->irq != 0 &&
+ fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
- rmesa->do_usleeps = !getenv("RADEON_NO_USLEEPS");
-
- rmesa->vblank_flags = (rmesa->do_irqs)
- ? driGetDefaultVBlankFlags() : VBLANK_FLAG_NO_IRQ;
+ rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+ rmesa->vblank_flags = (rmesa->radeonScreen->irq != 0)
+ ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
#ifndef _SOLO
- rmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( "__glXGetUST" );
- if ( rmesa->get_ust == NULL )
-#endif
- {
+ rmesa->get_ust = (PFNGLXGETUSTPROC) glXGetProcAddress( (const GLubyte *) "__glXGetUST" );
+ if ( rmesa->get_ust == NULL ) {
rmesa->get_ust = get_ust_nop;
}
+#else
+ rmesa->get_ust = get_ust_nop;
+#endif
(*rmesa->get_ust)( & rmesa->swap_ust );
debug_control );
#endif
- if (getenv("RADEON_NO_RAST")) {
+ tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
fprintf(stderr, "disabling 3D acceleration\n");
FALLBACK(rmesa, RADEON_FALLBACK_DISABLE, 1);
- }
- else if (getenv("RADEON_TCL_FORCE_ENABLE")) {
- fprintf(stderr, "Enabling TCL support... this will probably crash\n");
- fprintf(stderr, " your card if it isn't capable of TCL!\n");
- rmesa->radeonScreen->chipset |= RADEON_CHIPSET_TCL;
- } else if (getenv("RADEON_TCL_FORCE_DISABLE") ||
- rmesa->dri.drmMinor < 3 ||
- !(rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL)) {
+ } else if (tcl_mode == DRI_CONF_TCL_SW ||
+ !(rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL)) {
rmesa->radeonScreen->chipset &= ~RADEON_CHIPSET_TCL;
fprintf(stderr, "disabling TCL support\n");
TCL_FALLBACK(rmesa->glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
}
if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) {
- if (!getenv("RADEON_NO_VTXFMT"))
- radeonVtxfmtInit( ctx );
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
+ radeonVtxfmtInit( ctx, tcl_mode >= DRI_CONF_TCL_CODEGEN );
_tnl_need_dlist_norm_lengths( ctx, GL_FALSE );
}
radeonFlushCmdBuf( rmesa, __FUNCTION__ );
}
- if (!rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
- if (!getenv("RADEON_NO_VTXFMT"))
+ if (!(rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)) {
+ int tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
radeonVtxfmtDestroy( rmesa->glCtx );
+ }
/* free the Mesa context */
rmesa->glCtx->DriverCtx = NULL;
*/
int i;
- /* this assert is not correct, default textures are always on swap list
- assert( is_empty_list( & rmesa->swapped ) ); */
+ assert( is_empty_list( & rmesa->swapped ) );
for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
}
}
+ /* free the option cache */
+ driDestroyOptionCache (&rmesa->optionCache);
+
FREE( rmesa );
}
}
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, newCtx->glCtx);
if ( newCtx->dri.drawable != driDrawPriv ) {
+ driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
newCtx->dri.drawable = driDrawPriv;
radeonUpdateWindow( newCtx->glCtx );
radeonUpdateViewportOffset( newCtx->glCtx );
}
-
+
_mesa_make_current2( newCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
drmBufPtr buf;
};
-#define GET_START(rvb) (rmesa->radeonScreen->agp_buffer_offset + \
+#define GET_START(rvb) (rmesa->radeonScreen->gart_buffer_offset + \
(rvb)->address - rmesa->dma.buf0_address + \
(rvb)->start)
unsigned nr_heaps;
driTexHeap * texture_heaps[ RADEON_NR_TEX_HEAPS ];
driTextureObject swapped;
+ GLboolean default32BitTextures;
/* Rasterization and vertex state:
*/
struct radeon_dri_mirror dri;
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+
/* Performance counters
*/
* Gareth Hughes <gareth@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
*/
+
#include <sched.h>
-#include <errno.h>
+#include <errno.h>
#include "glheader.h"
#include "imports.h"
drmRadeonCmdHeader *cmd;
- assert(rmesa->dri.drmMinor >= 3);
assert(!(primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
radeonEmitState( rmesa );
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s %d\n", __FUNCTION__, min_nr);
- assert(rmesa->dri.drmMinor >= 3);
assert((primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
radeonEmitState( rmesa );
rmesa->ioctl.vertex_offset = offset;
#else
drmRadeonCmdHeader *cmd;
- assert(rmesa->dri.drmMinor >= 3);
if (RADEON_DEBUG & (DEBUG_PRIMS|DEBUG_IOCTL))
fprintf(stderr, "%s: vertex_size 0x%x offset 0x%x \n",
if (RADEON_DEBUG & DEBUG_IOCTL)
fprintf(stderr, "%s\n", __FUNCTION__);
- assert(rmesa->dri.drmMinor >= 3);
cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, sz * sizeof(int),
__FUNCTION__ );
int ret;
- assert (rmesa->dri.drmMinor >= 3);
-
LOCK_HARDWARE( rmesa );
ret = radeonFlushCmdBufLocked( rmesa, caller );
rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
rmesa->dma.current.start =
rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
-
- if ( rmesa->dri.drmMinor < 3 )
- radeonRefillCurrentDmaRegion( rmesa );
}
void radeonAllocDmaRegionVerts( radeonContextPtr rmesa,
drmRadeonGetParam gp;
gp.param = RADEON_PARAM_LAST_FRAME;
- gp.value = &frame;
+ gp.value = (int *)&frame;
ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
&gp, sizeof(gp) );
}
drmRadeonGetParam gp;
gp.param = RADEON_PARAM_LAST_CLEAR;
- gp.value = &clear;
+ gp.value = (int *)&clear;
ret = drmCommandWriteRead( rmesa->dri.fd,
DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
} else
if (rmesa->dma.flush)
rmesa->dma.flush( rmesa );
- if (rmesa->dri.drmMinor >= 3) {
- if (!is_empty_list(&rmesa->hw.dirty))
- radeonEmitState( rmesa );
+ if (!is_empty_list(&rmesa->hw.dirty))
+ radeonEmitState( rmesa );
- if (rmesa->store.cmd_used)
- radeonFlushCmdBuf( rmesa, __FUNCTION__ );
- }
+ if (rmesa->store.cmd_used)
+ radeonFlushCmdBuf( rmesa, __FUNCTION__ );
}
/* Make sure all commands have been sent to the hardware and have
{
int use_back;
- if (rmesa->dri.drmMinor < 3)
- return;
rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip;
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_maos.h,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_maos_arrays.c,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-/* Emit any changed arrays to new agp memory, re-emit a packet to
+/* Emit any changed arrays to new GART memory, re-emit a packet to
* update the arrays.
*/
void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_maos_verts.c,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_sanity.c,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
/**************************************************************************
Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
* Keith Whitwell <keith@tungstengraphics.com>
*
*/
-#include <errno.h>
+#include <errno.h>
#include "glheader.h"
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c,v 1.6 2002/12/16 16:18:58 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c,v 1.7 2003/03/26 20:43:51 tsi Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
#ifndef _SOLO
#include "glxextensions.h"
-#endif
+#endif
#if 1
/* Including xf86PciInfo.h introduces a bunch of errors...
return NULL;
}
- if ( sPriv->drmMinor < 3 ||
- getenv("RADEON_COMPAT")) {
- fprintf( stderr, "Radeon DRI driver:\n\t"
- "Compatibility mode for DRM driver version %d.%d.%d\n\t"
- "TCL will be disabled, expect reduced performance\n\t"
- "(prefer DRM radeon.o 1.3.x or newer)\n\t",
- sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
- }
-
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&screen->optionCache);
/* This is first since which regions we map depends on whether or
* not we are using a PCI card.
*/
screen->IsPCI = dri_priv->IsPCI;
- if (sPriv->drmMinor >= 3) {
+ {
int ret;
drmRadeonGetParam gp;
- gp.param = RADEON_PARAM_AGP_BUFFER_OFFSET;
- gp.value = &screen->agp_buffer_offset;
+ gp.param = RADEON_PARAM_GART_BUFFER_OFFSET;
+ gp.value = &screen->gart_buffer_offset;
ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
&gp, sizeof(gp));
if (ret) {
- fprintf(stderr, "drmRadeonGetParam (RADEON_PARAM_AGP_BUFFER_OFFSET): %d\n", ret);
+ FREE( screen );
+ fprintf(stderr, "drmRadeonGetParam (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret);
return NULL;
}
return NULL;
}
- if ( !screen->IsPCI ) {
- screen->agpTextures.handle = dri_priv->agpTexHandle;
- screen->agpTextures.size = dri_priv->agpTexMapSize;
+ if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
+ unsigned char *RADEONMMIO = screen->mmio.map;
+
+ screen->gartTextures.handle = dri_priv->gartTexHandle;
+ screen->gartTextures.size = dri_priv->gartTexMapSize;
if ( drmMap( sPriv->fd,
- screen->agpTextures.handle,
- screen->agpTextures.size,
- (drmAddressPtr)&screen->agpTextures.map ) ) {
+ screen->gartTextures.handle,
+ screen->gartTextures.size,
+ (drmAddressPtr)&screen->gartTextures.map ) ) {
drmUnmapBufs( screen->buffers );
drmUnmap( screen->status.map, screen->status.size );
drmUnmap( screen->mmio.map, screen->mmio.size );
FREE( screen );
- __driUtilMessage("%s: IsPCI failed\n", __FUNCTION__);
+ __driUtilMessage("%s: drmMap failed for GART texture area\n", __FUNCTION__);
return NULL;
}
+
+ screen->gart_texture_offset = dri_priv->gartTexOffset + ( screen->IsPCI
+ ? INREG( RADEON_AIC_LO_ADDR )
+ : ( ( INREG( RADEON_MC_AGP_LOCATION ) & 0x0ffffU ) << 16 ) );
}
screen->chipset = 0;
screen->logTexGranularity[RADEON_CARD_HEAP] =
dri_priv->log2TexGran;
- if ( screen->IsPCI
- || getenv( "RADEON_AGPTEXTURING_FORCE_DISABLE" ) ) {
+ if ( !screen->gartTextures.map
+ || getenv( "RADEON_GARTTEXTURING_FORCE_DISABLE" ) ) {
screen->numTexHeaps = RADEON_NR_TEX_HEAPS - 1;
- screen->texOffset[RADEON_AGP_HEAP] = 0;
- screen->texSize[RADEON_AGP_HEAP] = 0;
- screen->logTexGranularity[RADEON_AGP_HEAP] = 0;
+ screen->texOffset[RADEON_GART_HEAP] = 0;
+ screen->texSize[RADEON_GART_HEAP] = 0;
+ screen->logTexGranularity[RADEON_GART_HEAP] = 0;
} else {
screen->numTexHeaps = RADEON_NR_TEX_HEAPS;
- screen->texOffset[RADEON_AGP_HEAP] =
- dri_priv->agpTexOffset + RADEON_AGP_TEX_OFFSET;
- screen->texSize[RADEON_AGP_HEAP] = dri_priv->agpTexMapSize;
- screen->logTexGranularity[RADEON_AGP_HEAP] =
- dri_priv->log2AGPTexGran;
+ screen->texOffset[RADEON_GART_HEAP] = screen->gart_texture_offset;
+ screen->texSize[RADEON_GART_HEAP] = dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_GART_HEAP] =
+ dri_priv->log2GARTTexGran;
}
+#ifndef _SOLO
+ if ( driCompareGLXAPIVersion( 20030813 ) >= 0 ) {
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) glXGetProcAddress( (const GLubyte *) "__glXScrEnableExtension" );
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if ( glx_enable_extension != NULL ) {
+ if ( screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ }
+ }
+#endif
screen->driScreen = sPriv;
screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
return screen;
if (!screen)
return;
- if ( !screen->IsPCI ) {
- drmUnmap( screen->agpTextures.map,
- screen->agpTextures.size );
+ if ( screen->gartTextures.map ) {
+ drmUnmap( screen->gartTextures.map, screen->gartTextures.size );
}
drmUnmapBufs( screen->buffers );
drmUnmap( screen->status.map, screen->status.size );
drmUnmap( screen->mmio.map, screen->mmio.size );
+ /* free all option information */
+ driDestroyOptionInfo (&screen->optionCache);
+
FREE( screen );
sPriv->private = NULL;
}
* The __driCreateScreen name is the symbol that libGL.so fetches.
* Return: pointer to a __DRIscreenPrivate.
*/
-#ifndef _SOLO
+#ifndef _SOLO
void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
int numConfigs, __GLXvisualConfig *config)
{
}
#endif
-
#ifndef _SOLO
-/* This function is called by libGL.so as soon as libGL.so is loaded.
+/**
+ * This function is called by libGL.so as soon as libGL.so is loaded.
* This is where we'd register new extension functions with the dispatcher.
+ *
+ * \todo This interface has been deprecated, so we should probably remove
+ * this function before the next XFree86 release.
*/
void
__driRegisterExtensions( void )
if ( driCompareGLXAPIVersion( 20030317 ) >= 0 ) {
glx_enable_extension = (PFNGLXENABLEEXTENSIONPROC)
- glXGetProcAddress( "__glXEnableExtension" );
+ glXGetProcAddress( (const GLubyte *) "__glXEnableExtension" );
if ( glx_enable_extension != NULL ) {
- glx_enable_extension( "GLX_SGI_swap_control", GL_FALSE );
- glx_enable_extension( "GLX_SGI_video_sync", GL_FALSE );
- glx_enable_extension( "GLX_MESA_swap_control", GL_FALSE );
- glx_enable_extension( "GLX_MESA_swap_frame_usage", GL_FALSE );
+ (*glx_enable_extension)( "GLX_SGI_swap_control", GL_FALSE );
+ (*glx_enable_extension)( "GLX_SGI_video_sync", GL_FALSE );
+ (*glx_enable_extension)( "GLX_MESA_swap_control", GL_FALSE );
+ (*glx_enable_extension)( "GLX_MESA_swap_frame_usage", GL_FALSE );
}
}
}
#endif
-
/**
* Get information about previous buffer swaps.
*/
#include "radeon_dri.h"
#include "radeon_reg.h"
#include "radeon_sarea.h"
+#include "xmlconfig.h"
typedef struct {
radeonRegionRec mmio;
radeonRegionRec status;
- radeonRegionRec agpTextures;
+ radeonRegionRec gartTextures;
drmBufMapPtr buffers;
__DRIscreenPrivate *driScreen;
unsigned int sarea_priv_offset;
- unsigned int agp_buffer_offset; /* offset in card memory space */
+ unsigned int gart_buffer_offset; /* offset in card memory space */
+ unsigned int gart_texture_offset; /* offset in card memory space */
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
} radeonScreenRec, *radeonScreenPtr;
extern radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv );
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state_init.c,v 1.3 2003/02/22 06:21:11 dawes Exp $ */
/*
* Copyright 2000, 2001 VA Linux Systems Inc., Fremont, California.
*
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_swtcl.c,v 1.6 2003/05/06 23:52:08 daenzer Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
#define RADEON_MAX_SETUP 0x40
static void flush_last_swtcl_prim( radeonContextPtr rmesa );
-static void flush_last_swtcl_prim_compat( radeonContextPtr rmesa );
static struct {
void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
}
if (rmesa->dma.flush != 0 &&
- rmesa->dma.flush != flush_last_swtcl_prim_compat &&
rmesa->dma.flush != flush_last_swtcl_prim)
rmesa->dma.flush( rmesa );
}
if (rmesa->dma.current.buf) {
struct radeon_dma_region *current = &rmesa->dma.current;
- GLuint current_offset = (rmesa->radeonScreen->agp_buffer_offset +
+ GLuint current_offset = (rmesa->radeonScreen->gart_buffer_offset +
current->buf->buf->idx * RADEON_BUFFER_SIZE +
current->start);
}
-static void flush_last_swtcl_prim_compat( radeonContextPtr rmesa )
-{
- struct radeon_dma_region *current = &rmesa->dma.current;
-
- if (RADEON_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "%s buf %p start %d ptr %d\n",
- __FUNCTION__,
- current->buf,
- current->start,
- current->ptr);
-
- assert (!(rmesa->swtcl.hw_primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
- assert (current->start +
- rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
- current->ptr);
- assert (current->start == 0);
-
- rmesa->dma.flush = 0;
-
- if (current->ptr && current->buf) {
- assert (current->buf->refcount == 1);
-
- radeonCompatEmitPrimitive( rmesa,
- rmesa->swtcl.vertex_format,
- rmesa->swtcl.hw_primitive,
- rmesa->swtcl.numverts);
-
- /* The buffer has been released:
- */
- FREE(current->buf);
- current->buf = 0;
- current->start = 0;
- current->ptr = current->end;
-
- }
-
- rmesa->swtcl.numverts = 0;
-}
-
-
/* Alloc space in the current dma region.
*/
static __inline void *radeonAllocDmaLowVerts( radeonContextPtr rmesa,
if (!rmesa->dma.flush) {
rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
- if (rmesa->dri.drmMinor == 1)
- rmesa->dma.flush = flush_last_swtcl_prim_compat;
- else
- rmesa->dma.flush = flush_last_swtcl_prim;
+ rmesa->dma.flush = flush_last_swtcl_prim;
}
assert( vsize == rmesa->swtcl.vertex_size * 4 );
- assert( rmesa->dma.flush == flush_last_swtcl_prim ||
- rmesa->dma.flush == flush_last_swtcl_prim_compat);
+ assert( rmesa->dma.flush == flush_last_swtcl_prim );
assert (rmesa->dma.current.start +
rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
rmesa->dma.current.ptr);
{
- char *head = rmesa->dma.current.address + rmesa->dma.current.ptr;
+ GLubyte *head = (GLubyte *)(rmesa->dma.current.address + rmesa->dma.current.ptr);
rmesa->dma.current.ptr += bytes;
rmesa->swtcl.numverts += nverts;
return head;
\
radeonEmitVertexAOS( rmesa, \
rmesa->swtcl.vertex_size, \
- (rmesa->radeonScreen->agp_buffer_offset + \
+ (rmesa->radeonScreen->gart_buffer_offset + \
rmesa->swtcl.indexed_verts.buf->buf->idx * \
RADEON_BUFFER_SIZE + \
rmesa->swtcl.indexed_verts.start)); \
ctx->Line.StippleFlag) /* GH: THIS IS A HACK!!! */
return GL_TRUE;
- if (rmesa->dri.drmMinor < 3) {
- /* drm 1.1 doesn't support vertex primitives starting in the
- * middle of a buffer. It doesn't support sane indexed vertices
- * either. drm 1.2 fixes both of these problems, but we don't have a
- * compatibility layer to that version yet.
- */
- return GL_TRUE;
- }
-
tnl->Driver.Render.Start( ctx );
if (VB->Elts) {
#define RADEON_TWOSIDE_BIT 0x01
#define RADEON_UNFILLED_BIT 0x02
-#define RADEON_OFFSET_BIT 0x04 /* drmMinor == 1 */
#define RADEON_MAX_TRIFUNC 0x08
#define DO_FALLBACK 0
-#define DO_OFFSET (IND & RADEON_OFFSET_BIT)
+#define DO_OFFSET 0
#define DO_UNFILLED (IND & RADEON_UNFILLED_BIT)
#define DO_TWOSIDE (IND & RADEON_TWOSIDE_BIT)
#define DO_FLAT 0
#define TAG(x) x##_twoside_unfilled
#include "tnl_dd/t_dd_tritmp.h"
-#define IND (RADEON_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (RADEON_TWOSIDE_BIT|RADEON_OFFSET_BIT)
-#define TAG(x) x##_twoside_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (RADEON_UNFILLED_BIT|RADEON_OFFSET_BIT)
-#define TAG(x) x##_unfilled_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
-#define IND (RADEON_TWOSIDE_BIT|RADEON_UNFILLED_BIT|RADEON_OFFSET_BIT)
-#define TAG(x) x##_twoside_unfilled_offset
-#include "tnl_dd/t_dd_tritmp.h"
-
static void init_rast_tab( void )
{
init_twoside();
init_unfilled();
init_twoside_unfilled();
- init_offset();
- init_twoside_offset();
- init_unfilled_offset();
- init_twoside_unfilled_offset();
}
/**********************************************************************/
if (flags & DD_TRI_LIGHT_TWOSIDE) index |= RADEON_TWOSIDE_BIT;
if (flags & DD_TRI_UNFILLED) index |= RADEON_UNFILLED_BIT;
- if ((flags & DD_TRI_OFFSET) &&
- rmesa->dri.drmMinor == 1) index |= RADEON_OFFSET_BIT;
if (index != rmesa->swtcl.RenderIndex) {
tnl->Driver.Render.Points = rast_tab[index].points;
tnl->Driver.Render.ResetLineStipple = radeonResetLineStipple;
tnl->Driver.Render.BuildVertices = radeonBuildVertices;
- rmesa->swtcl.verts = ALIGN_MALLOC( size * 16 * 4, 32 );
+ rmesa->swtcl.verts = (GLubyte *)ALIGN_MALLOC( size * 16 * 4, 32 );
rmesa->swtcl.RenderIndex = ~0;
rmesa->swtcl.render_primitive = GL_TRIANGLES;
rmesa->swtcl.hw_primitive = 0;
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tcl.h,v 1.2 2003/02/08 21:26:45 dawes Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
* Gareth Hughes <gareth@valinux.com>
*
*/
-#include <errno.h>
+#include <errno.h>
#include "glheader.h"
#include "imports.h"
height = texImage->Height;
dstPitch = t->pp_txpitch + 32;
- { /* FIXME: prefer AGP-texturing if possible */
- /* Data not in agp memory, or bad pitch.
+ { /* FIXME: prefer GART-texturing if possible */
+ /* Data not in GART memory, or bad pitch.
*/
for (done = 0; done < height ; ) {
struct radeon_dma_region region;
const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
GLint curOffset;
GLint i;
- GLint firstLevel=0, lastLevel=0, numLevels;
+ GLint numLevels;
GLint log2Width, log2Height, log2Depth;
/* Set the hardware texture format
}
-
/* 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.
*/
- switch (tObj->Target) {
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- 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 */
- log2Width = tObj->Image[firstLevel]->WidthLog2;
- log2Height = tObj->Image[firstLevel]->HeightLog2;
- log2Depth = 0;
- break;
- case GL_TEXTURE_RECTANGLE_NV:
- firstLevel = lastLevel = 0;
- log2Width = log2Height = 1; /* ? */
- log2Depth = 0;
- break;
- default:
- return;
- }
- /* save these values */
- t->base.firstLevel = firstLevel;
- t->base.lastLevel = lastLevel;
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ log2Width = tObj->Image[t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[t->base.firstLevel]->HeightLog2;
+ log2Depth = tObj->Image[t->base.firstLevel]->DepthLog2;
- numLevels = lastLevel - firstLevel + 1;
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
const struct gl_texture_image *texImage;
GLuint size;
- texImage = tObj->Image[i + firstLevel];
+ texImage = tObj->Image[i + t->base.firstLevel];
if ( !texImage )
break;
}
assert(size > 0);
- if (curOffset & 0x1f) {
- /* align to 32-byte offset */
- curOffset = (curOffset + 0x1f) & ~0x1f;
- }
+
+ /* Align to 32-byte offset. It is faster to do this unconditionally
+ * (no branch penalty).
+ */
+
+ curOffset = (curOffset + 0x1f) & ~0x1f;
t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES;
t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES;
t->pp_txformat |= ((log2Width << RADEON_TXFORMAT_WIDTH_SHIFT) |
(log2Height << RADEON_TXFORMAT_HEIGHT_SHIFT));
- t->pp_txsize = (((tObj->Image[firstLevel]->Width - 1) << 0) |
- ((tObj->Image[firstLevel]->Height - 1) << 16));
+ t->pp_txsize = (((tObj->Image[t->base.firstLevel]->Width - 1) << 0) |
+ ((tObj->Image[t->base.firstLevel]->Height - 1) << 16));
/* Only need to round to nearest 32 for textures, but the blitter
* requires 64-byte aligned pitches, and we may/may not need the
* blitter. NPOT only!
*/
if (baseImage->IsCompressed)
- t->pp_txpitch = (tObj->Image[firstLevel]->Width + 63) & ~(63);
+ t->pp_txpitch = (tObj->Image[t->base.firstLevel]->Width + 63) & ~(63);
else
- t->pp_txpitch = ((tObj->Image[firstLevel]->Width * baseImage->TexFormat->TexelBytes) + 63) & ~(63);
+ t->pp_txpitch = ((tObj->Image[t->base.firstLevel]->Width * baseImage->TexFormat->TexelBytes) + 63) & ~(63);
t->pp_txpitch -= 32;
t->dirty_state = TEX_ALL;
RADEON_FIREVERTICES( rmesa );
radeonSetTexImages( rmesa, tObj );
radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, 0 );
- if ( !t->base.memBlock /* && !rmesa->prefer_agp_client_texturing FIXME */ ) {
+ if ( !t->base.memBlock /* && !rmesa->prefer_gart_client_texturing FIXME */ ) {
fprintf(stderr, "%s: upload failed\n", __FUNCTION__);
return GL_FALSE;
}
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c,v 1.5 2002/12/16 16:18:59 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c,v 1.6 2003/05/06 23:52:08 daenzer Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
*/
-void radeonVtxfmtInit( GLcontext *ctx )
+void radeonVtxfmtInit( GLcontext *ctx, GLboolean useCodegen )
{
radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
GLvertexformat *vfmt = &(rmesa->vb.vtxfmt);
make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
- radeonInitCodegen( &rmesa->vb.codegen );
+ radeonInitCodegen( &rmesa->vb.codegen, useCodegen );
}
static void free_funcs( struct dynfn *l )
extern void radeonVtxfmtUpdate( GLcontext *ctx );
-extern void radeonVtxfmtInit( GLcontext *ctx );
+extern void radeonVtxfmtInit( GLcontext *ctx, GLboolean useCodegen );
extern void radeonVtxfmtInvalidate( GLcontext *ctx );
extern void radeonVtxfmtDestroy( GLcontext *ctx );
extern void radeonVtxfmtInitChoosers( GLvertexformat *vfmt );
/*
*/
-void radeonInitCodegen( struct dfn_generators *gen );
+void radeonInitCodegen( struct dfn_generators *gen, GLboolean useCodegen );
void radeonInitX86Codegen( struct dfn_generators *gen );
void radeonInitSSECodegen( struct dfn_generators *gen );
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt_c.c,v 1.2 2002/12/16 16:18:59 dawes Exp $ */
/**************************************************************************
Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
return 0;
}
-void radeonInitCodegen( struct dfn_generators *gen )
+void radeonInitCodegen( struct dfn_generators *gen, GLboolean useCodegen )
{
gen->Vertex3f = codegen_noop;
gen->Vertex3fv = codegen_noop;
gen->MultiTexCoord1fARB = codegen_noop;
gen->MultiTexCoord1fvARB = codegen_noop;
- if (!getenv("RADEON_NO_CODEGEN")) {
+ if (useCodegen) {
#if defined(USE_X86_ASM)
radeonInitX86Codegen( gen );
#endif
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt_sse.c,v 1.1 2002/10/30 12:51:58 alanh Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
-/* $XFree86$ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt_x86.c,v 1.2 2002/12/21 17:02:16 dawes Exp $ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
* \name AGP
*/
/*@{*/
- drmSize agpSize; /**< \brief AGP map size */
- drmHandle agpMemHandle; /**< \brief AGP map handle */
- unsigned long agpOffset; /**< \brief AGP offset */
- int agpMode; /**< \brief AGP mode */
- int agpFastWrite;
+ drmSize gartSize; /**< \brief AGP map size */
+ drmHandle gartMemHandle; /**< \brief AGP map handle */
+ unsigned long gartOffset; /**< \brief AGP offset */
+ int gartMode; /**< \brief AGP mode */
+ int gartFastWrite;
/*@}*/
/**
* \name CP AGP Texture data
*/
/*@{*/
- unsigned long agpTexStart; /**< \brief Offset into AGP space */
- drmHandle agpTexHandle; /**< \brief Handle from drmAddMap() */
- drmSize agpTexMapSize; /**< \brief Size of map */
- int agpTexSize; /**< \brief Size of AGP tex space (in MB) */
- int log2AGPTexGran;
+ unsigned long gartTexStart; /**< \brief Offset into AGP space */
+ drmHandle gartTexHandle; /**< \brief Handle from drmAddMap() */
+ drmSize gartTexMapSize; /**< \brief Size of map */
+ int gartTexSize; /**< \brief Size of AGP tex space (in MB) */
+ int log2GARTTexGran;
/*@}*/
int drmMinor; /**< \brief DRM device minor number */
* Converted to common header format:
* Jens Owen <jens@tungstengraphics.com>
*
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drmRadeon.h,v 1.6 2001/04/16 15:02:13 tsi Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_common.h,v 1.2 2003/04/07 01:22:09 martin Exp $
*
*/
#define DRM_RADEON_INIT_HEAP 0x15
#define DRM_RADEON_IRQ_EMIT 0x16
#define DRM_RADEON_IRQ_WAIT 0x17
+#define DRM_RADEON_CP_RESUME 0x18
#define DRM_RADEON_MAX_DRM_COMMAND_INDEX 0x39
unsigned long sarea_priv_offset;
int is_pci;
int cp_mode;
- int agp_size;
+ int gart_size;
int ring_size;
int usec_timeout;
unsigned long ring_offset;
unsigned long ring_rptr_offset;
unsigned long buffers_offset;
- unsigned long agp_textures_offset;
+ unsigned long gart_textures_offset;
} drmRadeonInit;
typedef struct {
void *value;
} drmRadeonGetParam;
-#define RADEON_PARAM_AGP_BUFFER_OFFSET 1
-#define RADEON_PARAM_LAST_FRAME 2
-#define RADEON_PARAM_LAST_DISPATCH 3
-#define RADEON_PARAM_LAST_CLEAR 4
-#define RADEON_PARAM_IRQ_NR 5
-#define RADEON_PARAM_AGP_BASE 6
+#define RADEON_PARAM_GART_BUFFER_OFFSET 1
+#define RADEON_PARAM_LAST_FRAME 2
+#define RADEON_PARAM_LAST_DISPATCH 3
+#define RADEON_PARAM_LAST_CLEAR 4
+#define RADEON_PARAM_IRQ_NR 5
+#define RADEON_PARAM_GART_BASE 6
-#define RADEON_MEM_REGION_AGP 1
-#define RADEON_MEM_REGION_FB 2
+#define RADEON_MEM_REGION_GART 1
+#define RADEON_MEM_REGION_FB 2
typedef struct drm_radeon_mem_alloc {
int region;
int alignment;
int size;
- int *region_offset; /* offset from start of fb or agp */
+ int *region_offset; /* offset from start of fb or GART */
} drmRadeonMemAlloc;
typedef struct drm_radeon_mem_free {
int s, l;
if (drmAgpAcquire(ctx->drmFD) < 0) {
- fprintf(stderr, "[agp] AGP not available\n");
+ fprintf(stderr, "[gart] AGP not available\n");
return 0;
}
/* Disable fast write entirely - too many lockups.
*/
mode &= ~RADEON_AGP_MODE_MASK;
- switch (info->agpMode) {
+ switch (info->gartMode) {
case 4: mode |= RADEON_AGP_4X_MODE;
case 2: mode |= RADEON_AGP_2X_MODE;
case 1: default: mode |= RADEON_AGP_1X_MODE;
}
if (drmAgpEnable(ctx->drmFD, mode) < 0) {
- fprintf(stderr, "[agp] AGP not enabled\n");
+ fprintf(stderr, "[gart] AGP not enabled\n");
drmAgpRelease(ctx->drmFD);
return 0;
}
- info->agpOffset = 0;
+ info->gartOffset = 0;
- if ((ret = drmAgpAlloc(ctx->drmFD, info->agpSize*1024*1024, 0, NULL,
- &info->agpMemHandle)) < 0) {
- fprintf(stderr, "[agp] Out of memory (%d)\n", ret);
+ if ((ret = drmAgpAlloc(ctx->drmFD, info->gartSize*1024*1024, 0, NULL,
+ &info->gartMemHandle)) < 0) {
+ fprintf(stderr, "[gart] Out of memory (%d)\n", ret);
drmAgpRelease(ctx->drmFD);
return 0;
}
fprintf(stderr,
- "[agp] %d kB allocated with handle 0x%08x\n",
- info->agpSize*1024, (unsigned)info->agpMemHandle);
+ "[gart] %d kB allocated with handle 0x%08x\n",
+ info->gartSize*1024, (unsigned)info->gartMemHandle);
if (drmAgpBind(ctx->drmFD,
- info->agpMemHandle, info->agpOffset) < 0) {
- fprintf(stderr, "[agp] Could not bind\n");
- drmAgpFree(ctx->drmFD, info->agpMemHandle);
+ info->gartMemHandle, info->gartOffset) < 0) {
+ fprintf(stderr, "[gart] Could not bind\n");
+ drmAgpFree(ctx->drmFD, info->gartMemHandle);
drmAgpRelease(ctx->drmFD);
return 0;
}
/* Initialize the CP ring buffer data */
- info->ringStart = info->agpOffset;
+ info->ringStart = info->gartOffset;
info->ringMapSize = info->ringSize*1024*1024 + DRM_PAGE_SIZE;
info->ringReadOffset = info->ringStart + info->ringMapSize;
info->bufMapSize = info->bufSize*1024*1024;
/* Reserve the rest for AGP textures */
- info->agpTexStart = info->bufStart + info->bufMapSize;
- s = (info->agpSize*1024*1024 - info->agpTexStart);
+ info->gartTexStart = info->bufStart + info->bufMapSize;
+ s = (info->gartSize*1024*1024 - info->gartTexStart);
l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS);
if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY;
- info->agpTexMapSize = (s >> l) << l;
- info->log2AGPTexGran = l;
+ info->gartTexMapSize = (s >> l) << l;
+ info->log2GARTTexGran = l;
if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize,
DRM_AGP, DRM_READ_ONLY, &info->ringHandle) < 0) {
- fprintf(stderr, "[agp] Could not add ring mapping\n");
+ fprintf(stderr, "[gart] Could not add ring mapping\n");
return 0;
}
- fprintf(stderr, "[agp] ring handle = 0x%08lx\n", info->ringHandle);
+ fprintf(stderr, "[gart] ring handle = 0x%08lx\n", info->ringHandle);
if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize,
DRM_AGP, DRM_READ_ONLY, &info->ringReadPtrHandle) < 0) {
fprintf(stderr,
- "[agp] Could not add ring read ptr mapping\n");
+ "[gart] Could not add ring read ptr mapping\n");
return 0;
}
fprintf(stderr,
- "[agp] ring read ptr handle = 0x%08lx\n",
+ "[gart] ring read ptr handle = 0x%08lx\n",
info->ringReadPtrHandle);
if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize,
DRM_AGP, 0, &info->bufHandle) < 0) {
fprintf(stderr,
- "[agp] Could not add vertex/indirect buffers mapping\n");
+ "[gart] Could not add vertex/indirect buffers mapping\n");
return 0;
}
fprintf(stderr,
- "[agp] vertex/indirect buffers handle = 0x%08lx\n",
+ "[gart] vertex/indirect buffers handle = 0x%08lx\n",
info->bufHandle);
- if (drmAddMap(ctx->drmFD, info->agpTexStart, info->agpTexMapSize,
- DRM_AGP, 0, &info->agpTexHandle) < 0) {
+ if (drmAddMap(ctx->drmFD, info->gartTexStart, info->gartTexMapSize,
+ DRM_AGP, 0, &info->gartTexHandle) < 0) {
fprintf(stderr,
- "[agp] Could not add AGP texture map mapping\n");
+ "[gart] Could not add AGP texture map mapping\n");
return 0;
}
fprintf(stderr,
- "[agp] AGP texture map handle = 0x%08lx\n",
- info->agpTexHandle);
+ "[gart] AGP texture map handle = 0x%08lx\n",
+ info->gartTexHandle);
/* Initialize Radeon's AGP registers */
/* Ring buffer is at AGP offset 0 */
drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec);
drmInfo.is_pci = 0;
drmInfo.cp_mode = RADEON_DEFAULT_CP_BM_MODE;
- drmInfo.agp_size = info->agpSize*1024*1024;
+ drmInfo.gart_size = info->gartSize*1024*1024;
drmInfo.ring_size = info->ringSize*1024*1024;
drmInfo.usec_timeout = 1000;
drmInfo.fb_bpp = ctx->bpp;
drmInfo.ring_offset = info->ringHandle;
drmInfo.ring_rptr_offset = info->ringReadPtrHandle;
drmInfo.buffers_offset = info->bufHandle;
- drmInfo.agp_textures_offset = info->agpTexHandle;
+ drmInfo.gart_textures_offset = info->gartTexHandle;
ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_INIT, &drmInfo,
sizeof(drmRadeonInit));
{
drmRadeonMemInitHeap drmHeap;
- /* Start up the simple memory manager for agp space */
- drmHeap.region = RADEON_MEM_REGION_AGP;
+ /* Start up the simple memory manager for gart space */
+ drmHeap.region = RADEON_MEM_REGION_GART;
drmHeap.start = 0;
- drmHeap.size = info->agpTexMapSize;
+ drmHeap.size = info->gartTexMapSize;
if (drmCommandWrite(ctx->drmFD, DRM_RADEON_INIT_HEAP,
&drmHeap, sizeof(drmHeap))) {
fprintf(stderr,
- "[drm] Failed to initialized agp heap manager\n");
+ "[drm] Failed to initialized gart heap manager\n");
} else {
fprintf(stderr,
- "[drm] Initialized kernel agp heap manager, %d\n",
- info->agpTexMapSize);
+ "[drm] Initialized kernel gart heap manager, %d\n",
+ info->gartTexMapSize);
}
}
info->frontPitch = ctx->shared.virtualWidth;
fprintf(stderr,
- "Using %d MB AGP aperture\n", info->agpSize);
+ "Using %d MB AGP aperture\n", info->gartSize);
fprintf(stderr,
"Using %d MB for the ring buffer\n", info->ringSize);
fprintf(stderr,
"Using %d MB for vertex/indirect buffers\n", info->bufSize);
fprintf(stderr,
- "Using %d MB for AGP textures\n", info->agpTexSize);
+ "Using %d MB for AGP textures\n", info->gartTexSize);
/* Front, back and depth buffers - everything else texture??
*/
* Setups a RADEONDRIRec structure to be passed to radeon_dri.so for its
* initialization.
*/
-static int RADEONScreenInit( const DRIDriverContext *ctx, RADEONInfoPtr info )
+static int RADEONScreenInit( DRIDriverContext *ctx, RADEONInfoPtr info )
{
RADEONDRIPtr pRADEONDRI;
int err;
/* Initialize IRQ */
RADEONDRIIrqInit(ctx, info);
- /* Initialize kernel agp memory manager */
+ /* Initialize kernel gart memory manager */
RADEONDRIAgpHeapInit(ctx, info);
/* Initialize the SAREA private data structure */
pRADEONDRI->depth = ctx->bpp; /* XXX: depth */
pRADEONDRI->bpp = ctx->bpp;
pRADEONDRI->IsPCI = 0;
- pRADEONDRI->AGPMode = info->agpMode;
+ pRADEONDRI->AGPMode = info->gartMode;
pRADEONDRI->frontOffset = info->frontOffset;
pRADEONDRI->frontPitch = info->frontPitch;
pRADEONDRI->backOffset = info->backOffset;
pRADEONDRI->registerSize = info->registerSize;
pRADEONDRI->statusHandle = info->ringReadPtrHandle;
pRADEONDRI->statusSize = info->ringReadMapSize;
- pRADEONDRI->agpTexHandle = info->agpTexHandle;
- pRADEONDRI->agpTexMapSize = info->agpTexMapSize;
- pRADEONDRI->log2AGPTexGran = info->log2AGPTexGran;
- pRADEONDRI->agpTexOffset = info->agpTexStart;
+ pRADEONDRI->gartTexHandle = info->gartTexHandle;
+ pRADEONDRI->gartTexMapSize = info->gartTexMapSize;
+ pRADEONDRI->log2GARTTexGran = info->log2GARTTexGran;
+ pRADEONDRI->gartTexOffset = info->gartTexStart;
pRADEONDRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
/* Don't release the lock now - let the VT switch handler do it. */
ctx->driverPrivate = (void *)info;
- info->agpFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE;
- info->agpMode = RADEON_DEFAULT_AGP_MODE;
- info->agpSize = RADEON_DEFAULT_AGP_SIZE;
- info->agpTexSize = RADEON_DEFAULT_AGP_TEX_SIZE;
+ info->gartFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE;
+ info->gartMode = RADEON_DEFAULT_AGP_MODE;
+ info->gartSize = RADEON_DEFAULT_AGP_SIZE;
+ info->gartTexSize = RADEON_DEFAULT_AGP_TEX_SIZE;
info->bufSize = RADEON_DEFAULT_BUFFER_SIZE;
info->ringSize = RADEON_DEFAULT_RING_SIZE;
* \name CP AGP Texture data
*/
/*@{*/
- drmHandle agpTexHandle; /**< \brief AGP texture area map handle */
- drmSize agpTexMapSize; /**< \brief AGP texture area map size */
- int log2AGPTexGran; /**< \brief AGP texture granularity in log base 2 */
- int agpTexOffset; /**< \brief AGP texture area offset in AGP space */
+ drmHandle gartTexHandle; /**< \brief AGP texture area map handle */
+ drmSize gartTexMapSize; /**< \brief AGP texture area map size */
+ int log2GARTTexGran; /**< \brief AGP texture granularity in log base 2 */
+ int gartTexOffset; /**< \brief AGP texture area offset in AGP space */
/*@}*/
unsigned int sarea_priv_offset; /**< \brief offset of the private SAREA data*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h,v 1.25 2003/02/07 18:08:59 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h,v 1.30 2003/10/07 22:47:12 martin Exp $ */
/*
* Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
* VA Linux Systems Inc., Fremont, California.
# define RADEON_AGP_APER_SIZE_4MB (0x3f << 0)
# define RADEON_AGP_APER_SIZE_MASK (0x3f << 0)
#define RADEON_AGP_COMMAND 0x0f60 /* PCI */
+#define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config*/
+# define RADEON_AGP_ENABLE (1<<8)
#define RADEON_AGP_PLL_CNTL 0x000b /* PLL */
#define RADEON_AGP_STATUS 0x0f5c /* PCI */
# define RADEON_AGP_1X_MODE 0x01
# define RADEON_CONSTANT_COLOR_ZERO 0x00000000
#define RADEON_CRC_CMDFIFO_ADDR 0x0740
#define RADEON_CRC_CMDFIFO_DOUT 0x0744
+#define RADEON_GRPH_BUFFER_CNTL 0x02f0
+# define RADEON_GRPH_START_REQ_MASK (0x7f)
+# define RADEON_GRPH_START_REQ_SHIFT 0
+# define RADEON_GRPH_STOP_REQ_MASK (0x7f<<8)
+# define RADEON_GRPH_STOP_REQ_SHIFT 8
+# define RADEON_GRPH_CRITICAL_POINT_MASK (0x7f<<16)
+# define RADEON_GRPH_CRITICAL_POINT_SHIFT 16
+# define RADEON_GRPH_CRITICAL_CNTL (1<<28)
+# define RADEON_GRPH_BUFFER_SIZE (1<<29)
+# define RADEON_GRPH_CRITICAL_AT_SOF (1<<30)
+# define RADEON_GRPH_STOP_CNTL (1<<31)
+#define RADEON_GRPH2_BUFFER_CNTL 0x03f0
+# define RADEON_GRPH2_START_REQ_MASK (0x7f)
+# define RADEON_GRPH2_START_REQ_SHIFT 0
+# define RADEON_GRPH2_STOP_REQ_MASK (0x7f<<8)
+# define RADEON_GRPH2_STOP_REQ_SHIFT 8
+# define RADEON_GRPH2_CRITICAL_POINT_MASK (0x7f<<16)
+# define RADEON_GRPH2_CRITICAL_POINT_SHIFT 16
+# define RADEON_GRPH2_CRITICAL_CNTL (1<<28)
+# define RADEON_GRPH2_BUFFER_SIZE (1<<29)
+# define RADEON_GRPH2_CRITICAL_AT_SOF (1<<30)
+# define RADEON_GRPH2_STOP_CNTL (1<<31)
#define RADEON_CRTC_CRNT_FRAME 0x0214
#define RADEON_CRTC_EXT_CNTL 0x0054
# define RADEON_CRTC_VGA_XOVERSCAN (1 << 0)
# define RADEON_CRTC2_CSYNC_EN (1 << 27)
# define RADEON_CRTC2_HSYNC_DIS (1 << 28)
# define RADEON_CRTC2_VSYNC_DIS (1 << 29)
+#define RADEON_CRTC_MORE_CNTL 0x27c
+# define RADEON_CRTC_H_CUTOFF_ACTIVE_EN (1<<4)
+# define RADEON_CRTC_V_CUTOFF_ACTIVE_EN (1<<5)
#define RADEON_CRTC_GUI_TRIG_VLINE 0x0218
#define RADEON_CRTC_H_SYNC_STRT_WID 0x0204
# define RADEON_CRTC_H_SYNC_STRT_PIX (0x07 << 0)
#define RADEON_DAC_CNTL 0x0058
# define RADEON_DAC_RANGE_CNTL (3 << 0)
+# define RADEON_DAC_RANGE_CNTL_MASK 0x03
# define RADEON_DAC_BLANKING (1 << 2)
+# define RADEON_DAC_CMP_EN (1 << 3)
+# define RADEON_DAC_CMP_OUTPUT (1 << 7)
# define RADEON_DAC_8BIT_EN (1 << 8)
# define RADEON_DAC_VGA_ADR_EN (1 << 13)
# define RADEON_DAC_PDWN (1 << 15)
# define RADEON_DAC2_DAC_CLK_SEL (1 << 0)
# define RADEON_DAC2_DAC2_CLK_SEL (1 << 1)
# define RADEON_DAC2_PALETTE_ACC_CTL (1 << 5)
+#define RADEON_DAC_EXT_CNTL 0x0280
+# define RADEON_DAC_FORCE_BLANK_OFF_EN (1 << 4)
+# define RADEON_DAC_FORCE_DATA_EN (1 << 5)
+# define RADEON_DAC_FORCE_DATA_SEL_MASK (3 << 6)
+# define RADEON_DAC_FORCE_DATA_MASK 0x0003ff00
+# define RADEON_DAC_FORCE_DATA_SHIFT 8
#define RADEON_TV_DAC_CNTL 0x088c
# define RADEON_TV_DAC_STD_MASK 0x0300
# define RADEON_TV_DAC_RDACPD (1 << 24)
# define RADEON_CRT2_DISP1_SEL (1 << 5)
#define RADEON_DISP_OUTPUT_CNTL 0x0d64
# define RADEON_DISP_DAC_SOURCE_MASK 0x03
+# define RADEON_DISP_DAC2_SOURCE_MASK 0x0c
# define RADEON_DISP_DAC_SOURCE_CRTC2 0x01
+# define RADEON_DISP_DAC2_SOURCE_CRTC2 0x04
#define RADEON_DAC_CRC_SIG 0x02cc
#define RADEON_DAC_DATA 0x03c9 /* VGA */
#define RADEON_DAC_MASK 0x03c6 /* VGA */
#define RADEON_DEVICE_ID 0x0f02 /* PCI */
#define RADEON_DISP_MISC_CNTL 0x0d00
# define RADEON_SOFT_RESET_GRPH_PP (1 << 0)
+#define RADEON_DISP_MERGE_CNTL 0x0d60
+# define RADEON_DISP_ALPHA_MODE_MASK 0x03
+# define RADEON_DISP_ALPHA_MODE_KEY 0
+# define RADEON_DISP_ALPHA_MODE_PER_PIXEL 1
+# define RADEON_DISP_ALPHA_MODE_GLOBAL 2
+# define RADEON_DISP_RGB_OFFSET_EN (1<<8)
+# define RADEON_DISP_GRPH_ALPHA_MASK (0xff << 16)
+# define RADEON_DISP_OV0_ALPHA_MASK (0xff << 24)
+# define RADEON_DISP_LIN_TRANS_BYPASS (0x01 << 9)
+#define RADEON_DISP2_MERGE_CNTL 0x0d68
+# define RADEON_DISP2_RGB_OFFSET_EN (1<<8)
+#define RADEON_DISP_LIN_TRANS_GRPH_A 0x0d80
+#define RADEON_DISP_LIN_TRANS_GRPH_B 0x0d84
+#define RADEON_DISP_LIN_TRANS_GRPH_C 0x0d88
+#define RADEON_DISP_LIN_TRANS_GRPH_D 0x0d8c
+#define RADEON_DISP_LIN_TRANS_GRPH_E 0x0d90
+#define RADEON_DISP_LIN_TRANS_GRPH_F 0x0d98
#define RADEON_DP_BRUSH_BKGD_CLR 0x1478
#define RADEON_DP_BRUSH_FRGD_CLR 0x147c
#define RADEON_DP_CNTL 0x16c0
# define RADEON_FP2_BLANK_EN (1 << 1)
# define RADEON_FP2_ON (1 << 2)
# define RADEON_FP2_PANEL_FORMAT (1 << 3)
-# define RADEON_FP2_SEL_CRTC2 (1 << 13)
+# define RADEON_FP2_SOURCE_SEL_MASK (3 << 10)
+# define RADEON_FP2_SOURCE_SEL_CRTC2 (1 << 10)
+# define RADEON_FP2_SRC_SEL_MASK (3 << 13)
+# define RADEON_FP2_SRC_SEL_CRTC2 (1 << 13)
# define RADEON_FP2_FP_POL (1 << 16)
# define RADEON_FP2_LP_POL (1 << 17)
# define RADEON_FP2_SCK_POL (1 << 18)
# define RADEON_FP2_PAD_FLOP_EN (1 << 22)
# define RADEON_FP2_CRC_EN (1 << 23)
# define RADEON_FP2_CRC_READ_EN (1 << 24)
+# define RADEON_FP2_DV0_EN (1 << 25)
+# define RADEON_FP2_DV0_RATE_SEL_SDR (1 << 26)
#define RADEON_FP_H_SYNC_STRT_WID 0x02c4
#define RADEON_FP_H2_SYNC_STRT_WID 0x03c4
#define RADEON_FP_HORZ_STRETCH 0x028c
#define RADEON_MAX_LATENCY 0x0f3f /* PCI */
#define RADEON_MC_AGP_LOCATION 0x014c
#define RADEON_MC_FB_LOCATION 0x0148
+#define RADEON_DISPLAY_BASE_ADDR 0x23c
+#define RADEON_DISPLAY2_BASE_ADDR 0x33c
+#define RADEON_OV0_BASE_ADDR 0x43c
+#define RADEON_NB_TOM 0x15c
#define RADEON_MCLK_CNTL 0x0012 /* PLL */
# define RADEON_FORCEON_MCLKA (1 << 16)
# define RADEON_FORCEON_MCLKB (1 << 17)
#define RADEON_MEM_ADDR_CONFIG 0x0148
#define RADEON_MEM_BASE 0x0f10 /* PCI */
#define RADEON_MEM_CNTL 0x0140
+# define RADEON_MEM_NUM_CHANNELS_MASK 0x01
+# define RADEON_MEM_USE_B_CH_ONLY (1<<1)
+# define RV100_HALF_MODE (1<<3)
+# define R300_MEM_NUM_CHANNELS_MASK 0x03
+# define R300_MEM_USE_CD_CH_ONLY (1<<2)
+#define RADEON_MEM_TIMING_CNTL 0x0144 /* EXT_MEM_CNTL */
#define RADEON_MEM_INIT_LAT_TIMER 0x0154
#define RADEON_MEM_INTF_CNTL 0x014c
#define RADEON_MEM_SDRAM_MODE_REG 0x0158
#define RADEON_MPLL_CNTL 0x000e /* PLL */
#define RADEON_MPP_TB_CONFIG 0x01c0 /* ? */
#define RADEON_MPP_GP_CONFIG 0x01c8 /* ? */
-
+#define R300_MC_IND_INDEX 0x01f8
+# define R300_MC_IND_ADDR_MASK 0x3f
+#define R300_MC_IND_DATA 0x01fc
+#define R300_MC_READ_CNTL_AB 0x017c
+# define R300_MEM_RBS_POSITION_A_MASK 0x03
+#define R300_MC_READ_CNTL_CD_mcind 0x24
+# define R300_MEM_RBS_POSITION_C_MASK 0x03
#define RADEON_N_VIF_COUNT 0x0248
# define RADEON_P2PLL_REF_DIV_MASK 0x03ff
# define RADEON_P2PLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
# define RADEON_P2PLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
-# define R300_PPLL_REF_DIV_ACC_MASK (0x3ff < 18)
+# define R300_PPLL_REF_DIV_ACC_MASK (0x3ff << 18)
# define R300_PPLL_REF_DIV_ACC_SHIFT 18
#define RADEON_PALETTE_DATA 0x00b4
#define RADEON_PALETTE_30_DATA 0x00b8
# define RADEON_PIX2CLK_SRC_SEL_PSCANCLK 0x01
# define RADEON_PIX2CLK_SRC_SEL_BYTECLK 0x02
# define RADEON_PIX2CLK_SRC_SEL_P2PLLCLK 0x03
+# define RADEON_PIX2CLK_ALWAYS_ONb (1<<6)
+# define RADEON_PIX2CLK_DAC_ALWAYS_ONb (1<<7)
+# define RADEON_PIXCLK_TV_SRC_SEL (1 << 8)
+# define RADEON_PIXCLK_LVDS_ALWAYS_ONb (1 << 14)
+# define RADEON_PIXCLK_TMDS_ALWAYS_ONb (1 << 15)
#define RADEON_PLANE_3D_MASK_C 0x1d44
#define RADEON_PLL_TEST_CNTL 0x0013 /* PLL */
#define RADEON_PMI_CAP_ID 0x0f5c /* PCI */
#define RADEON_TEST_DEBUG_MUX 0x0124
#define RADEON_TEST_DEBUG_OUT 0x012c
#define RADEON_TMDS_PLL_CNTL 0x02a8
+#define RADEON_TMDS_TRANSMITTER_CNTL 0x02a4
+# define RADEON_TMDS_TRANSMITTER_PLLEN 1
+# define RADEON_TMDS_TRANSMITTER_PLLRST 2
#define RADEON_TRAIL_BRES_DEC 0x1614
#define RADEON_TRAIL_BRES_ERR 0x160c
#define RADEON_TRAIL_BRES_INC 0x1610
# define RADEON_VCLK_SRC_SEL_PSCANCLK 0x01
# define RADEON_VCLK_SRC_SEL_BYTECLK 0x02
# define RADEON_VCLK_SRC_SEL_PPLLCLK 0x03
+# define RADEON_PIXCLK_ALWAYS_ONb (1<<6)
+# define RADEON_PIXCLK_DAC_ALWAYS_ONb (1<<7)
+
#define RADEON_VENDOR_ID 0x0f00 /* PCI */
#define RADEON_VGA_DDA_CONFIG 0x02e8
#define RADEON_VGA_DDA_ON_OFF 0x02ec
#define RADEON_AIC_CNTL 0x01d0
# define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
+#define RADEON_AIC_LO_ADDR 0x01dc
/* Constants */
-#define RADEON_AGP_TEX_OFFSET 0x02000000
-
#define RADEON_LAST_FRAME_REG RADEON_GUI_SCRATCH_REG0
#define RADEON_LAST_CLEAR_REG RADEON_GUI_SCRATCH_REG2
#define RADEON_SS_HORZ_GUARD_DISCARD_ADJ_ADDR 51
#define RADEON_SS_SHININESS 60
+#define RADEON_TV_MASTER_CNTL 0x0800
+# define RADEON_TVCLK_ALWAYS_ONb (1 << 30)
+#define RADEON_TV_DAC_CNTL 0x088c
+# define RADEON_TV_DAC_CMPOUT (1 << 5)
+#define RADEON_TV_PRE_DAC_MUX_CNTL 0x0888
+# define RADEON_Y_RED_EN (1 << 0)
+# define RADEON_C_GRN_EN (1 << 1)
+# define RADEON_CMP_BLU_EN (1 << 2)
+# define RADEON_RED_MX_FORCE_DAC_DATA (6 << 4)
+# define RADEON_GRN_MX_FORCE_DAC_DATA (6 << 8)
+# define RADEON_BLU_MX_FORCE_DAC_DATA (6 << 12)
+# define RADEON_TV_FORCE_DAC_DATA_SHIFT 16
#endif
-/**
- * \file server/radeon_sarea.h
- * \brief SAREA definition.
- *
- * \author Kevin E. Martin <martin@xfree86.org>
- * \author Gareth Hughes <gareth@valinux.com>
- */
-
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_sarea.h,v 1.5 2002/10/30 12:52:14 alanh Exp $ */
/*
* Copyright 2000 ATI Technologies Inc., Markham, Ontario,
* VA Linux Systems Inc., Fremont, California.
* DEALINGS IN THE SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_sarea.h,v 1.4 2002/04/24 16:20:41 martin Exp $ */
+/*
+ * Authors:
+ * Kevin E. Martin <martin@xfree86.org>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
#ifndef _RADEON_SAREA_H_
#define _RADEON_SAREA_H_
/* Keep these small for testing */
#define RADEON_NR_SAREA_CLIPRECTS 12
-/* There are 2 heaps (local/AGP). Each region within a heap is a
+/* There are 2 heaps (local/GART). Each region within a heap is a
* minimum of 64k, and there are at most 64 of them per heap.
*/
#define RADEON_CARD_HEAP 0
-#define RADEON_AGP_HEAP 1
+#define RADEON_GART_HEAP 1
#define RADEON_NR_TEX_HEAPS 2
#define RADEON_NR_TEX_REGIONS 64
#define RADEON_LOG_TEX_GRANULARITY 16
#endif /* __RADEON_SAREA_DEFINES__ */
-
-/**
- * \brief Color register format.
- */
typedef struct {
unsigned int red;
unsigned int green;
unsigned int alpha;
} radeon_color_regs_t;
-
-/**
- * \brief Context registers.
- */
typedef struct {
- /**
- * \name Context state
- */
- /*@{*/
+ /* Context state */
unsigned int pp_misc;
unsigned int pp_fog_color;
unsigned int re_solid_color;
unsigned int re_width_height;
unsigned int rb3d_colorpitch;
unsigned int se_cntl;
- /*@}*/
- /**
- * \name Vertex format state
- */
- /*@{*/
+ /* Vertex format state */
unsigned int se_coord_fmt;
- /*@}*/
- /**
- * \name Line state
- */
- /*@{*/
+ /* Line state */
unsigned int re_line_pattern;
unsigned int re_line_state;
unsigned int se_line_width;
- /*@}*/
- /**
- * \name Bumpmap state
- */
- /*@{*/
+ /* Bumpmap state */
unsigned int pp_lum_matrix;
unsigned int pp_rot_matrix_0;
unsigned int pp_rot_matrix_1;
- /*@}*/
- /**
- * \name Mask state
- */
- /*@{*/
+ /* Mask state */
unsigned int rb3d_stencilrefmask;
unsigned int rb3d_ropcntl;
unsigned int rb3d_planemask;
- /*@}*/
- /**
- * \name Viewport state
- */
- /*@{*/
+ /* Viewport state */
unsigned int se_vport_xscale;
unsigned int se_vport_xoffset;
unsigned int se_vport_yscale;
unsigned int se_vport_yoffset;
unsigned int se_vport_zscale;
unsigned int se_vport_zoffset;
- /*@}*/
- /**
- * \name Setup state
- */
- /*@{*/
+ /* Setup state */
unsigned int se_cntl_status;
- /*@}*/
- /**
- * \name Misc state
- */
- /*@{*/
+ /* Misc state */
unsigned int re_top_left;
unsigned int re_misc;
- /*@}*/
} radeon_context_regs_t;
-
-/**
- * \brief Setup registers for each texture unit
- */
+/* Setup registers for each texture unit */
typedef struct {
unsigned int pp_txfilter;
unsigned int pp_txformat;
unsigned int pp_border_color;
} radeon_texture_regs_t;
-/**
- * \brief 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 RADEONSAREAPriv::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.
- *
- * \sa RADEONSAREAPriv::texList.
- */
-typedef struct {
- unsigned char next; /**< \brief indices to form a circular LRU */
- unsigned char prev; /**< \brief indices to form a circular LRU */
- unsigned char in_use; /**< \brief owned by a client, or free? */
- int age; /**< \brief tracked by clients to update local LRU's */
-} radeon_tex_region_t;
-
-
-/**
- * \brief Private SAREA definition
- *
- * The channel for communication of state information to the kernel
- * on firing a vertex buffer.
- */
typedef struct {
- radeon_context_regs_t ContextState; /** \brief Context registers */
+ /* The channel for communication of state information to the kernel
+ * on firing a vertex buffer.
+ */
+ radeon_context_regs_t ContextState;
radeon_texture_regs_t TexState[RADEON_MAX_TEXTURE_UNITS];
- /**< \brief Texture registers */
- unsigned int dirty;
- unsigned int vertsize; /**< \brief vertex size */
- unsigned int vc_format; /**< \brief vertex format */
+ unsigned int dirty;
+ unsigned int vertsize;
+ unsigned int vc_format;
- /**
- * \name Cliprects
- *
- * The current cliprects, or a subset thereof.
- */
- /*@{*/
- XF86DRIClipRectRec boxes[RADEON_NR_SAREA_CLIPRECTS];
- /**< \brief cliprects */
- unsigned int nbox; /**< \brief number of cliprects */
- /*@}*/
-
- /**
- * \name Counters
- *
- * Counters for throttling rendering of clients.
- */
- /*@{*/
- unsigned int last_frame; /**< \brief last emmited frame */
+ /* The current cliprects, or a subset thereof */
+ XF86DRIClipRectRec boxes[RADEON_NR_SAREA_CLIPRECTS];
+ unsigned int nbox;
+
+ /* Counters for throttling of rendering clients */
+ unsigned int last_frame;
unsigned int last_dispatch;
- unsigned int last_clear; /**< \brief last emmited clear */
- /*@}*/
+ unsigned int last_clear;
- /**
- * \name LRU
- */
- /*@{*/
- /** \brief Texture regions.
- * Last element is sentinal
+ /* 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.
*/
+ /* Last elt is sentinal */
drmTextureRegion texList[RADEON_NR_TEX_HEAPS][RADEON_NR_TEX_REGIONS+1];
- /** \brief last time texture was uploaded */
+ /* last time texture was uploaded */
unsigned int texAge[RADEON_NR_TEX_HEAPS];
- /*@}*/
- int ctxOwner; /**< \brief last context to upload state */
- int pfAllowPageFlip; /**< \brief set by the 2d driver, read by the client */
- int pfCurrentPage; /**< \brief set by kernel, read by others */
- int crtc2_base; /**< \brief for pageflipping with CloneMode */
+ int ctxOwner; /* last context to upload state */
+ int pfAllowPageFlip; /* set by the 2d driver, read by the client */
+ int pfCurrentPage; /* set by kernel, read by others */
+ int crtc2_base; /* for pageflipping with CloneMode */
} RADEONSAREAPriv, *RADEONSAREAPrivPtr;
#endif