diff options
Diffstat (limited to 'src/mesa/drivers/dri')
93 files changed, 3596 insertions, 1277 deletions
diff --git a/src/mesa/drivers/dri/common/mm.c b/src/mesa/drivers/dri/common/mm.c index b3be95471d5..6572ccd9914 100644 --- a/src/mesa/drivers/dri/common/mm.c +++ b/src/mesa/drivers/dri/common/mm.c @@ -27,14 +27,13 @@ #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 { diff --git a/src/mesa/drivers/dri/common/texmem.c b/src/mesa/drivers/dri/common/texmem.c index a8878b694d6..4ed05219db9 100644 --- a/src/mesa/drivers/dri/common/texmem.c +++ b/src/mesa/drivers/dri/common/texmem.c @@ -1,6 +1,6 @@ /* * 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 @@ -46,6 +46,7 @@ #include "texmem.h" #include "simple_list.h" #include "imports.h" +#include "macros.h" #include <assert.h> @@ -156,22 +157,22 @@ static void printLocalLRU( driTexHeap * heap, const char *callername ) 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 ); } } @@ -190,7 +191,7 @@ static void printGlobalLRU( driTexHeap * heap, const char *callername ) 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", @@ -323,9 +324,9 @@ void driDestroyTextureObject( driTextureObject * t ) 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 ) { @@ -355,7 +356,7 @@ void driDestroyTextureObject( driTextureObject * t ) } 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 ); } } @@ -645,7 +646,7 @@ driCreateTextureHeap( unsigned heap_id, void * context, unsigned size, 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 ) { @@ -688,7 +689,7 @@ driCreateTextureHeap( unsigned heap_id, void * context, unsigned size, if ( 0 ) - fprintf( stderr, "%s returning %p\n", __FUNCTION__, heap ); + fprintf( stderr, "%s returning %p\n", __FUNCTION__, (void *)heap ); return heap; } @@ -894,7 +895,7 @@ get_max_size( unsigned nr_heaps, /** * 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 @@ -1097,7 +1098,7 @@ driValidateTextureHeaps( driTexHeap * const * 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; } @@ -1105,7 +1106,7 @@ driValidateTextureHeaps( driTexHeap * const * texture_heaps, 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; } @@ -1159,15 +1160,76 @@ driValidateTextureHeaps( driTexHeap * const * texture_heaps, 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; +} diff --git a/src/mesa/drivers/dri/common/texmem.h b/src/mesa/drivers/dri/common/texmem.h index 7199704612a..9afbb0c865b 100644 --- a/src/mesa/drivers/dri/common/texmem.h +++ b/src/mesa/drivers/dri/common/texmem.h @@ -290,4 +290,6 @@ void driInitTextureObjects( GLcontext *ctx, driTextureObject * swapped, GLboolean driValidateTextureHeaps( driTexHeap * const * texture_heaps, unsigned nr_heaps, const driTextureObject * swapped ); +extern void driCalculateTextureFirstLastLevel( driTextureObject * t ); + #endif /* DRI_TEXMEM_H */ diff --git a/src/mesa/drivers/dri/common/vblank.c b/src/mesa/drivers/dri/common/vblank.c index e91dd65260c..d20f743bc9a 100644 --- a/src/mesa/drivers/dri/common/vblank.c +++ b/src/mesa/drivers/dri/common/vblank.c @@ -33,6 +33,7 @@ #include "macros.h" #include "dd.h" #include "vblank.h" +#include "xmlpool.h" /****************************************************************************/ @@ -127,7 +128,7 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv, 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; @@ -163,9 +164,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv, /* 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 } } @@ -183,20 +184,35 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv, /****************************************************************************/ /** * 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; } @@ -204,6 +220,22 @@ GLuint driGetDefaultVBlankFlags( void ) /****************************************************************************/ /** + * 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 * wrap the error message logging. The error message should only be logged * the first time the \c drmWaitVBlank fails. If \c drmWaitVBlank is @@ -265,7 +297,10 @@ driWaitForVBlank( const __DRIdrawablePrivate *priv, GLuint * vbl_seq, *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; } @@ -293,11 +328,14 @@ driWaitForVBlank( const __DRIdrawablePrivate *priv, GLuint * vbl_seq, 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; diff --git a/src/mesa/drivers/dri/common/vblank.h b/src/mesa/drivers/dri/common/vblank.h index 3dab4ead3c2..d460d7a84ad 100644 --- a/src/mesa/drivers/dri/common/vblank.h +++ b/src/mesa/drivers/dri/common/vblank.h @@ -32,6 +32,7 @@ #include "context.h" #include "dri_util.h" +#include "xmlconfig.h" #define VBLANK_FLAG_INTERVAL (1U << 0) /* Respect the swap_interval setting */ @@ -45,7 +46,8 @@ 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 ); diff --git a/src/mesa/drivers/dri/common/xmlconfig.c b/src/mesa/drivers/dri/common/xmlconfig.c new file mode 100644 index 00000000000..a6d4c8ab941 --- /dev/null +++ b/src/mesa/drivers/dri/common/xmlconfig.c @@ -0,0 +1,862 @@ +/* + * 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; +} diff --git a/src/mesa/drivers/dri/common/xmlconfig.h b/src/mesa/drivers/dri/common/xmlconfig.h new file mode 100644 index 00000000000..710e328e015 --- /dev/null +++ b/src/mesa/drivers/dri/common/xmlconfig.h @@ -0,0 +1,125 @@ +/* + * 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 diff --git a/src/mesa/drivers/dri/common/xmlpool.h b/src/mesa/drivers/dri/common/xmlpool.h new file mode 100644 index 00000000000..c1553734782 --- /dev/null +++ b/src/mesa/drivers/dri/common/xmlpool.h @@ -0,0 +1,203 @@ +/* -*- 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 diff --git a/src/mesa/drivers/dri/mga/Makefile.X11 b/src/mesa/drivers/dri/mga/Makefile.X11 index f816616f2cf..cb769838227 100644 --- a/src/mesa/drivers/dri/mga/Makefile.X11 +++ b/src/mesa/drivers/dri/mga/Makefile.X11 @@ -1,4 +1,4 @@ -# $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 @@ -31,7 +31,8 @@ DRIVER_SOURCES = mgadd.c \ ../common/mm.c \ ../common/utils.c \ ../common/texmem.c \ - ../common/vblank.c + ../common/vblank.c \ + ../common/xmlconfig.c FULL_DRIVER_SOURCES = \ mgapixel.c \ @@ -39,6 +40,7 @@ FULL_DRIVER_SOURCES = \ mgatex.c \ mgatexmem.c \ mga_texstate.c \ + mga_texcombine.c \ mgavb.c \ mga_xmesa.c diff --git a/src/mesa/drivers/dri/mga/mga_texcombine.c b/src/mesa/drivers/dri/mga/mga_texcombine.c new file mode 100644 index 00000000000..f0664e37cfa --- /dev/null +++ b/src/mesa/drivers/dri/mga/mga_texcombine.c @@ -0,0 +1,647 @@ +/* + * 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 <[email protected]> + */ + +#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; +} + + diff --git a/src/mesa/drivers/dri/mga/mga_texstate.c b/src/mesa/drivers/dri/mga/mga_texstate.c index fc1406cab9e..5f3e1b1bacc 100644 --- a/src/mesa/drivers/dri/mga/mga_texstate.c +++ b/src/mesa/drivers/dri/mga/mga_texstate.c @@ -52,6 +52,8 @@ static const unsigned TMC_tformat[ TMC_nr_tformat ] = [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, @@ -67,7 +69,7 @@ mgaSetTexImages( mgaContextPtr mmesa, GLint totalSize; GLint width, height; GLint i; - GLint firstLevel, lastLevel, numLevels; + GLint numLevels; GLint log2Width, log2Height; GLuint txformat = 0; GLint ofs; @@ -81,6 +83,8 @@ mgaSetTexImages( mgaContextPtr mmesa, 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; @@ -101,39 +105,21 @@ mgaSetTexImages( mgaContextPtr mmesa, #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) @@ -149,13 +135,9 @@ mgaSetTexImages( mgaContextPtr mmesa, 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 */ @@ -225,7 +207,7 @@ static void mgaUpdateTextureEnvG200( GLcontext *ctx, GLuint unit ) 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; @@ -251,29 +233,160 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] = (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 | @@ -290,33 +403,53 @@ static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] = (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 | @@ -334,20 +467,25 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] = (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 | @@ -355,16 +493,20 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] = 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), }, @@ -377,21 +519,25 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] = (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 | @@ -399,16 +545,20 @@ static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] = 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), }, @@ -421,143 +571,236 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit ) 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 ); @@ -573,7 +816,7 @@ static void disable_tex( GLcontext *ctx, int unit ) mmesa->CurrentTexObj[unit] = NULL; } - if ( unit != 0 ) { + if ( unit != 0 && !mmesa->dualtex_env ) { mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0; } @@ -586,7 +829,7 @@ static void disable_tex( GLcontext *ctx, int unit ) 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]; @@ -649,6 +892,14 @@ static GLboolean update_tex_common( GLcontext *ctx, int 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? */ @@ -680,13 +931,10 @@ static GLboolean update_tex_common( GLcontext *ctx, int unit ) 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; } @@ -697,8 +945,9 @@ static GLboolean updateTextureUnit( GLcontext *ctx, int unit ) 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 ) { @@ -718,6 +967,7 @@ void mgaUpdateTextureState( GLcontext *ctx ) 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 @@ -740,8 +990,4 @@ void mgaUpdateTextureState( GLcontext *ctx ) } FALLBACK( ctx, MGA_FALLBACK_TEXTURE, !ok ); - - /* FIXME: I believe that ChooseVertexState should be called here instead of - * FIXME: in mgaDDValidateState. - */ } diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 16dc349cace..d95c0197ebb 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -1,4 +1,4 @@ -/* $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. @@ -56,11 +56,23 @@ #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 @@ -97,7 +109,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) &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; } @@ -105,23 +117,26 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) 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; @@ -168,7 +183,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) mgaScreen->agp.size, (drmAddress *)&mgaScreen->agp.map) != 0) { - free(mgaScreen); + Xfree(mgaScreen); sPriv->private = NULL; __driUtilMessage("Couldn't map agp region"); return GL_FALSE; @@ -194,7 +209,7 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) 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; @@ -214,13 +229,16 @@ mgaInitDriver(__DRIscreenPrivate *sPriv) 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; } @@ -234,7 +252,11 @@ mgaDestroyScreen(__DRIscreenPrivate *sPriv) 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; } @@ -263,6 +285,10 @@ static const char * const g400_extensions[] = "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) @@ -286,6 +312,7 @@ static const char * const card_extensions[] = "GL_MESA_ycbcr_texture", "GL_SGIS_generate_mipmap", "GL_SGIS_texture_lod", + "GL_NV_texture_rectangle", NULL }; @@ -353,6 +380,10 @@ mgaCreateContext( const __GLcontextModes *mesaVis, 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 ); @@ -388,10 +419,10 @@ mgaCreateContext( const __GLcontextModes *mesaVis, 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 ); @@ -487,14 +518,15 @@ mgaCreateContext( const __GLcontextModes *mesaVis, 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 ); @@ -541,6 +573,9 @@ mgaDestroyContext(__DRIcontextPrivate *driContextPriv) } } + /* free the option cache */ + driDestroyOptionCache (&mmesa->optionCache); + FREE(mmesa); } @@ -614,6 +649,7 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv, 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); @@ -695,7 +731,7 @@ static const struct __DriverAPIRec mgaAPI = { * 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) { @@ -714,30 +750,6 @@ void *__driCreateScreen(struct DRIDriverRec *driver, #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. */ diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.h b/src/mesa/drivers/dri/mga/mga_xmesa.h index de349da0895..d372abe0120 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.h +++ b/src/mesa/drivers/dri/mga/mga_xmesa.h @@ -36,6 +36,7 @@ #include "mtypes.h" #include "mgaregs.h" #include "mga_common.h" +#include "xmlconfig.h" typedef struct mga_screen_private_s { @@ -78,6 +79,9 @@ 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; diff --git a/src/mesa/drivers/dri/mga/mgacontext.h b/src/mesa/drivers/dri/mga/mgacontext.h index 7188f6d9552..50efe4c817f 100644 --- a/src/mesa/drivers/dri/mga/mgacontext.h +++ b/src/mesa/drivers/dri/mga/mgacontext.h @@ -38,6 +38,7 @@ #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)) @@ -79,10 +80,12 @@ typedef void (*mga_point_func)( mgaContextPtr, mgaVertex * ); -/* 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; @@ -149,6 +152,10 @@ typedef struct mga_texture_object_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 { @@ -202,10 +209,11 @@ struct mga_context_t { 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 */ @@ -299,6 +307,10 @@ struct mga_context_t { __DRIscreenPrivate *driScreen; struct mga_screen_private_s *mgaScreen; MGASAREAPrivPtr sarea; + + /* Configuration cache + */ + driOptionCache optionCache; }; #define MGA_CONTEXT(ctx) ((mgaContextPtr)(ctx->DriverCtx)) diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c index 6b50af202a8..fc53912af4c 100644 --- a/src/mesa/drivers/dri/mga/mgaioctl.c +++ b/src/mesa/drivers/dri/mga/mgaioctl.c @@ -26,9 +26,8 @@ * Gareth Hughes <[email protected]> */ /* $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" diff --git a/src/mesa/drivers/dri/mga/mgastate.c b/src/mesa/drivers/dri/mga/mgastate.c index 0d304966d7e..29815008be9 100644 --- a/src/mesa/drivers/dri/mga/mgastate.c +++ b/src/mesa/drivers/dri/mga/mgastate.c @@ -401,7 +401,7 @@ static void mgaDDColorMask(GLcontext *ctx, */ static int mgaStipples[16] = { - 0xffff1, /* See above note */ + 0xffff, 0xa5a5, 0x5a5a, 0xa0a0, @@ -425,9 +425,6 @@ static int mgaStipples[16] = { * * \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 ) @@ -492,8 +489,7 @@ static void updateSpecularLighting( GLcontext *ctx ) 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; @@ -519,14 +515,6 @@ static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname, } -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 */ @@ -671,6 +659,12 @@ static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, 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; @@ -826,8 +820,10 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers ) else mgaXMesaSetBackClipRects( mmesa ); +#ifndef _SOLO + sarea->req_drawable = driDrawable->draw; sarea->req_draw_buffer = mmesa->draw_buffer; - +#endif mgaUpdateClipping( mmesa->glCtx ); mgaCalcViewport( mmesa->glCtx ); @@ -888,6 +884,11 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state) 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; @@ -1034,25 +1035,24 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) } 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], @@ -1070,15 +1070,10 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) 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; } @@ -1089,21 +1084,21 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa ) 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; @@ -1186,13 +1181,14 @@ void mgaInitState( mgaContextPtr mmesa ) 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 | @@ -1227,6 +1223,10 @@ void mgaInitState( mgaContextPtr mmesa ) 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; } @@ -1243,7 +1243,6 @@ void mgaDDInitStateFuncs( GLcontext *ctx ) 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; diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c index 82eccc81498..166bdfc22f3 100644 --- a/src/mesa/drivers/dri/mga/mgatex.c +++ b/src/mesa/drivers/dri/mga/mgatex.c @@ -221,7 +221,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat, 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: @@ -231,7 +231,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat, 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: @@ -243,7 +243,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat, 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: @@ -252,7 +252,7 @@ mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat, 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) && @@ -309,6 +309,7 @@ mgaAllocTexObj( struct gl_texture_object *tObj ) | TF_uvoffset_OGL); t->border_fallback = GL_FALSE; + t->texenv_fallback = GL_FALSE; make_empty_list( & t->base ); @@ -328,31 +329,31 @@ static void mgaDDTexEnv( GLcontext *ctx, GLenum target, 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; } @@ -445,8 +446,9 @@ mgaDDTexParameter( GLcontext *ctx, GLenum target, * to do anything now */ - if ( (t == NULL) - || (target != GL_TEXTURE_2D) ) { + if ( (t == NULL) || + (target != GL_TEXTURE_2D && + target != GL_TEXTURE_RECTANGLE_NV) ) { return; } @@ -492,7 +494,8 @@ static void 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 ); } @@ -547,5 +550,7 @@ mgaDDInitTextureFuncs( GLcontext *ctx ) 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) ); } diff --git a/src/mesa/drivers/dri/mga/mgatex.h b/src/mesa/drivers/dri/mga/mgatex.h index 282577e9f80..94547e38862 100644 --- a/src/mesa/drivers/dri/mga/mgatex.h +++ b/src/mesa/drivers/dri/mga/mgatex.h @@ -46,4 +46,6 @@ void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t ); void mgaDDInitTextureFuncs( GLcontext *ctx ); +GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit ); + #endif diff --git a/src/mesa/drivers/dri/mga/mgatris.c b/src/mesa/drivers/dri/mga/mgatris.c index 054c7f0635d..1c193066ff3 100644 --- a/src/mesa/drivers/dri/mga/mgatris.c +++ b/src/mesa/drivers/dri/mga/mgatris.c @@ -676,8 +676,7 @@ static void mgaFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts, #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) @@ -688,7 +687,7 @@ void mgaChooseRenderState(GLcontext *ctx) 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; @@ -713,9 +712,11 @@ void mgaChooseRenderState(GLcontext *ctx) 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; } } @@ -782,10 +783,9 @@ void mgaRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim ) 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); } } diff --git a/src/mesa/drivers/dri/mga/mgavb.c b/src/mesa/drivers/dri/mga/mgavb.c index 34906865e8d..17dde2bba60 100644 --- a/src/mesa/drivers/dri/mga/mgavb.c +++ b/src/mesa/drivers/dri/mga/mgavb.c @@ -24,7 +24,7 @@ * Authors: * Keith Whitwell <[email protected]> */ -/* $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" @@ -340,6 +340,9 @@ void mgaCheckTexSizes( GLcontext *ctx ) 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); + } } } @@ -456,7 +459,7 @@ void mgaInitVB( GLcontext *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; diff --git a/src/mesa/drivers/dri/r128/Makefile.X11 b/src/mesa/drivers/dri/r128/Makefile.X11 index 7265affcc6c..e8f07a5e3b1 100644 --- a/src/mesa/drivers/dri/r128/Makefile.X11 +++ b/src/mesa/drivers/dri/r128/Makefile.X11 @@ -1,4 +1,4 @@ -# $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 @@ -36,10 +36,11 @@ DRIVER_SOURCES = \ 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) diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c index f7f6d7141d2..e1b003a3587 100644 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ b/src/mesa/drivers/dri/r128/r128_context.c @@ -60,6 +60,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #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 @@ -127,6 +148,10 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual, 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); @@ -191,7 +216,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual, 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. @@ -224,10 +249,8 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual, 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; @@ -277,6 +300,9 @@ void r128DestroyContext( __DRIcontextPrivate *driContextPriv ) } } + /* free the option cache */ + driDestroyOptionCache (&rmesa->optionCache); + FREE( rmesa ); } @@ -305,6 +331,7 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv, newR128Ctx->dirty = R128_UPLOAD_ALL; } + driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags ); newR128Ctx->driDrawable = driDrawPriv; _mesa_make_current2( newR128Ctx->glCtx, diff --git a/src/mesa/drivers/dri/r128/r128_context.h b/src/mesa/drivers/dri/r128/r128_context.h index 9c93012eb0f..453ccb6f537 100644 --- a/src/mesa/drivers/dri/r128/r128_context.h +++ b/src/mesa/drivers/dri/r128/r128_context.h @@ -178,10 +178,6 @@ struct r128_context { */ GLuint doPageFlip; - /* Busy waiting - */ - GLuint do_irqs; - /* Drawable, cliprect and scissor information */ GLint drawOffset, drawPitch; @@ -222,6 +218,10 @@ struct r128_context { */ GLuint vbl_seq; GLuint vblank_flags; + + /* Configuration cache + */ + driOptionCache optionCache; }; #define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx)) diff --git a/src/mesa/drivers/dri/r128/r128_ioctl.c b/src/mesa/drivers/dri/r128/r128_ioctl.c index c5843473e12..2f1e3ad8f9a 100644 --- a/src/mesa/drivers/dri/r128/r128_ioctl.c +++ b/src/mesa/drivers/dri/r128/r128_ioctl.c @@ -31,7 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Gareth Hughes <[email protected]> * */ -#include <errno.h> +#include <errno.h> #include "r128_context.h" #include "r128_state.h" diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 8a8fc252177..8eee8bbe068 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -1,4 +1,4 @@ -/* $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., @@ -55,7 +55,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #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 @@ -80,6 +79,9 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) 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. */ @@ -140,7 +142,6 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) 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; @@ -183,7 +184,23 @@ r128CreateScreen( __DRIscreenPrivate *sPriv ) } 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; } @@ -204,6 +221,9 @@ r128DestroyScreen( __DRIscreenPrivate *sPriv ) drmUnmapBufs( r128Screen->buffers ); drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size ); + /* free all option information */ + driDestroyOptionInfo (&r128Screen->optionCache); + FREE( r128Screen ); sPriv->private = NULL; } @@ -290,10 +310,13 @@ r128InitDriver( __DRIscreenPrivate *sPriv ) 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 ) { @@ -301,7 +324,7 @@ 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 ); @@ -338,7 +361,7 @@ static struct __DriverAPIRec r128API = { * 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) { diff --git a/src/mesa/drivers/dri/r128/r128_screen.h b/src/mesa/drivers/dri/r128/r128_screen.h index 4b1a57292d9..affe9e69ef1 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.h +++ b/src/mesa/drivers/dri/r128/r128_screen.h @@ -39,6 +39,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef GLX_DIRECT_RENDERING #include "r128_sarea.h" +#include "xmlconfig.h" typedef struct { drmHandle handle; /* Handle to the DRM region */ @@ -77,6 +78,9 @@ typedef struct { __DRIscreenPrivate *driScreen; unsigned int sarea_priv_offset; + /* Configuration cache with default values for all contexts */ + driOptionCache optionCache; + } r128ScreenRec, *r128ScreenPtr; diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index 85b3b68402d..110a16a8316 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -706,7 +706,7 @@ static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode ) 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); diff --git a/src/mesa/drivers/dri/r128/r128_texmem.c b/src/mesa/drivers/dri/r128/r128_texmem.c index f6a5dfbbcf3..7bffaf46287 100644 --- a/src/mesa/drivers/dri/r128/r128_texmem.c +++ b/src/mesa/drivers/dri/r128/r128_texmem.c @@ -1,4 +1,4 @@ -/* $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., diff --git a/src/mesa/drivers/dri/r128/r128_texstate.c b/src/mesa/drivers/dri/r128/r128_texstate.c index 3f4347b02e8..3c43eb45286 100644 --- a/src/mesa/drivers/dri/r128/r128_texstate.c +++ b/src/mesa/drivers/dri/r128/r128_texstate.c @@ -1,4 +1,4 @@ -/* $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., @@ -90,17 +90,11 @@ static void r128SetTexImages( r128ContextPtr rmesa, }; /* 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; diff --git a/src/mesa/drivers/dri/r128/r128_vb.c b/src/mesa/drivers/dri/r128/r128_vb.c index 77389016486..0387e5dc977 100644 --- a/src/mesa/drivers/dri/r128/r128_vb.c +++ b/src/mesa/drivers/dri/r128/r128_vb.c @@ -1,4 +1,4 @@ -/* $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 @@ -361,6 +361,9 @@ void r128CheckTexSizes( GLcontext *ctx ) 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); + } } } @@ -489,7 +492,7 @@ void r128InitVB( GLcontext *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; diff --git a/src/mesa/drivers/dri/r200/Makefile.X11 b/src/mesa/drivers/dri/r200/Makefile.X11 index eb41e220f57..aad26a70acc 100644 --- a/src/mesa/drivers/dri/r200/Makefile.X11 +++ b/src/mesa/drivers/dri/r200/Makefile.X11 @@ -1,4 +1,4 @@ -# $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 @@ -33,6 +33,7 @@ DRIVER_SOURCES = r200_context.c \ ../common/utils.c \ ../common/texmem.c \ ../common/vblank.c \ + ../common/xmlconfig.c \ r200_cmdbuf.c \ r200_pixel.c \ r200_tex.c \ diff --git a/src/mesa/drivers/dri/r200/r200_cmdbuf.c b/src/mesa/drivers/dri/r200/r200_cmdbuf.c index a64b32d9160..3a4fa30bcf6 100644 --- a/src/mesa/drivers/dri/r200/r200_cmdbuf.c +++ b/src/mesa/drivers/dri/r200/r200_cmdbuf.c @@ -1,4 +1,4 @@ -/* $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. diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index ec95f05e6ef..b64ee2b1f29 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -1,6 +1,5 @@ -/* $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 @@ -69,7 +68,26 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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. */ @@ -224,7 +242,7 @@ static const struct dri_debug_control debug_control[] = static int -get_ust_nop( int64_t * ust ) +get_ust_nop( uint64_t * ust ) { *ust = 1; return 0; @@ -242,6 +260,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, r200ContextPtr rmesa; GLcontext *ctx, *shareCtx; int i; + int tcl_mode, fthrottle_mode, preferred_bpt; assert(glVisual); assert(driContextPriv); @@ -273,6 +292,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, 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); @@ -295,6 +317,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, 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; @@ -382,36 +407,38 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, 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" ), @@ -420,17 +447,18 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, 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 ); } @@ -474,9 +502,11 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv ) 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; @@ -492,7 +522,7 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv ) * texture object data. */ int i; - + /* this assert is wrong. The default textures are always on swap list assert( is_empty_list( & rmesa->swapped ) ); */ @@ -502,6 +532,9 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv ) } } + /* free the option cache */ + driDestroyOptionCache (&rmesa->optionCache); + FREE( rmesa ); } } @@ -550,6 +583,7 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv, 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 ); diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h index 9e00d7a3585..7421db97e6c 100644 --- a/src/mesa/drivers/dri/r200/r200_context.h +++ b/src/mesa/drivers/dri/r200/r200_context.h @@ -1,6 +1,5 @@ -/* $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 @@ -532,7 +531,7 @@ struct r200_dma_buffer { 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) @@ -779,6 +778,7 @@ struct r200_context { unsigned nr_heaps; driTexHeap * texture_heaps[ R200_NR_TEX_HEAPS ]; driTextureObject swapped; + GLboolean default32BitTextures; /* Rasterization and vertex state: @@ -812,7 +812,7 @@ struct r200_context { /* Clientdata textures; */ - GLuint prefer_agp_client_texturing; + GLuint prefer_gart_client_texturing; /* Drawable, cliprect and scissor information */ @@ -863,6 +863,10 @@ struct r200_context { /* Mirrors of some DRI state */ struct r200_dri_mirror dri; + + /* Configuration cache + */ + driOptionCache optionCache; }; #define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx)) diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.c b/src/mesa/drivers/dri/r200/r200_ioctl.c index 480121a094d..af7c3a0e629 100644 --- a/src/mesa/drivers/dri/r200/r200_ioctl.c +++ b/src/mesa/drivers/dri/r200/r200_ioctl.c @@ -1,6 +1,5 @@ -/* $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 @@ -33,7 +32,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Authors: * Keith Whitwell <[email protected]> */ - + #include <sched.h> #include <errno.h> @@ -773,7 +772,7 @@ void r200Finish( GLcontext *ctx ) } -/* 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. * @@ -782,8 +781,9 @@ void r200Finish( GLcontext *ctx ) * 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; @@ -795,7 +795,7 @@ void *r200AllocateMemoryNV(GLsizei size, GLfloat readfreq, 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")) @@ -804,7 +804,7 @@ void *r200AllocateMemoryNV(GLsizei size, GLfloat readfreq, 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; @@ -819,14 +819,14 @@ void *r200AllocateMemoryNV(GLsizei size, GLfloat readfreq, } { - 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; @@ -837,7 +837,7 @@ void r200FreeMemoryNV(GLvoid *pointer) 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; } @@ -845,16 +845,16 @@ void r200FreeMemoryNV(GLvoid *pointer) 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, @@ -865,8 +865,8 @@ void r200FreeMemoryNV(GLvoid *pointer) 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; @@ -877,41 +877,41 @@ GLuint r200GetAGPOffset(const GLvoid *pointer) 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; } diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.h b/src/mesa/drivers/dri/r200/r200_ioctl.h index 5025c1d2304..a76dbd2ad12 100644 --- a/src/mesa/drivers/dri/r200/r200_ioctl.h +++ b/src/mesa/drivers/dri/r200/r200_ioctl.h @@ -1,6 +1,5 @@ -/* $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 @@ -106,15 +105,15 @@ extern void r200WaitForIdleLocked( r200ContextPtr rmesa ); 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: diff --git a/src/mesa/drivers/dri/r200/r200_lock.c b/src/mesa/drivers/dri/r200/r200_lock.c index c2c5d30c582..9d6cff50ae4 100644 --- a/src/mesa/drivers/dri/r200/r200_lock.c +++ b/src/mesa/drivers/dri/r200/r200_lock.c @@ -1,5 +1,5 @@ -/* $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 @@ -81,6 +81,7 @@ r200UpdatePageFlipping( r200ContextPtr rmesa ) void r200GetLock( r200ContextPtr rmesa, GLuint flags ) { __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; + __DRIscreenPrivate *sPriv = rmesa->dri.screen; RADEONSAREAPrivPtr sarea = rmesa->sarea; int i; diff --git a/src/mesa/drivers/dri/r200/r200_lock.h b/src/mesa/drivers/dri/r200/r200_lock.h index 59bc1d656e1..7a4dfcf15cc 100644 --- a/src/mesa/drivers/dri/r200/r200_lock.h +++ b/src/mesa/drivers/dri/r200/r200_lock.h @@ -1,5 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_maos.h b/src/mesa/drivers/dri/r200/r200_maos.h index 0dfcc5c3ffb..a430497db98 100644 --- a/src/mesa/drivers/dri/r200/r200_maos.h +++ b/src/mesa/drivers/dri/r200/r200_maos.h @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c index f2abaff3afb..7842c0c594f 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c +++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c @@ -1,5 +1,5 @@ -/* $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 @@ -175,6 +175,28 @@ static void emit_ubyte_rgba( GLcontext *ctx, } +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, @@ -285,6 +307,9 @@ static void emit_vector( 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; @@ -304,7 +329,7 @@ static void emit_vector( GLcontext *ctx, -/* 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 ) diff --git a/src/mesa/drivers/dri/r200/r200_maos_vbtmp.h b/src/mesa/drivers/dri/r200/r200_maos_vbtmp.h index a36be45b275..ce258d7988a 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_vbtmp.h +++ b/src/mesa/drivers/dri/r200/r200_maos_vbtmp.h @@ -1,4 +1,4 @@ -/* $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. diff --git a/src/mesa/drivers/dri/r200/r200_maos_verts.c b/src/mesa/drivers/dri/r200/r200_maos_verts.c index cd866f661f7..872bbd47f5c 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_verts.c +++ b/src/mesa/drivers/dri/r200/r200_maos_verts.c @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_pixel.c b/src/mesa/drivers/dri/r200/r200_pixel.c index 94977efd186..29eab6cd2fb 100644 --- a/src/mesa/drivers/dri/r200/r200_pixel.c +++ b/src/mesa/drivers/dri/r200/r200_pixel.c @@ -1,4 +1,4 @@ -/* $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. @@ -160,12 +160,12 @@ r200TryReadPixels( GLcontext *ctx, 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; } @@ -217,7 +217,7 @@ r200TryReadPixels( GLcontext *ctx, 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; @@ -297,7 +297,7 @@ static void do_draw_pix( GLcontext *ctx, 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) @@ -402,11 +402,11 @@ r200TryDrawPixels( GLcontext *ctx, 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; } @@ -426,7 +426,7 @@ r200TryDrawPixels( GLcontext *ctx, 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 ); diff --git a/src/mesa/drivers/dri/r200/r200_pixel.h b/src/mesa/drivers/dri/r200/r200_pixel.h index 8e7aca1a16e..9282d2b147d 100644 --- a/src/mesa/drivers/dri/r200/r200_pixel.h +++ b/src/mesa/drivers/dri/r200/r200_pixel.h @@ -1,4 +1,4 @@ -/* $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. diff --git a/src/mesa/drivers/dri/r200/r200_reg.h b/src/mesa/drivers/dri/r200/r200_reg.h index cc0ae503279..8e9126342f1 100644 --- a/src/mesa/drivers/dri/r200/r200_reg.h +++ b/src/mesa/drivers/dri/r200/r200_reg.h @@ -1,4 +1,4 @@ -/* $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. @@ -1434,11 +1434,5 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define R200_CP_CMD_BITBLT_MULTI 0xC0009B00 #define R200_CP_CMD_TRANS_BITBLT 0xC0009C00 - -#define R200_AGP_TEX_OFFSET 0x02000000 - - - - #endif diff --git a/src/mesa/drivers/dri/r200/r200_sanity.c b/src/mesa/drivers/dri/r200/r200_sanity.c index 11dd36a05cc..291536d5603 100644 --- a/src/mesa/drivers/dri/r200/r200_sanity.c +++ b/src/mesa/drivers/dri/r200/r200_sanity.c @@ -1,4 +1,4 @@ -/* $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 @@ -32,7 +32,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell <[email protected]> * */ -#include <errno.h> + +#include <errno.h> #include "glheader.h" #include "imports.h" diff --git a/src/mesa/drivers/dri/r200/r200_screen.c b/src/mesa/drivers/dri/r200/r200_screen.c index ee52d68a779..4216046d198 100644 --- a/src/mesa/drivers/dri/r200/r200_screen.c +++ b/src/mesa/drivers/dri/r200/r200_screen.c @@ -1,6 +1,5 @@ -/* $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 @@ -43,14 +42,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #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... */ @@ -108,6 +107,8 @@ r200CreateScreen( __DRIscreenPrivate *sPriv ) 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. @@ -118,30 +119,26 @@ r200CreateScreen( __DRIscreenPrivate *sPriv ) 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; } @@ -196,23 +193,27 @@ r200CreateScreen( __DRIscreenPrivate *sPriv ) 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; @@ -229,22 +230,46 @@ r200CreateScreen( __DRIscreenPrivate *sPriv ) 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; } @@ -258,14 +283,16 @@ r200DestroyScreen( __DRIscreenPrivate *sPriv ) 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; } @@ -362,7 +389,7 @@ static struct __DriverAPIRec r200API = { * Return: pointer to a __DRIscreenPrivate. * */ -#ifndef _SOLO +#ifndef _SOLO void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, int numConfigs, __GLXvisualConfig *config) { @@ -380,56 +407,31 @@ void *__driCreateScreen(struct DRIDriverRec *driver, } #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 ); } } } diff --git a/src/mesa/drivers/dri/r200/r200_screen.h b/src/mesa/drivers/dri/r200/r200_screen.h index 1e1f125b0d5..3ed4f550282 100644 --- a/src/mesa/drivers/dri/r200/r200_screen.h +++ b/src/mesa/drivers/dri/r200/r200_screen.h @@ -1,6 +1,5 @@ -/* $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 @@ -43,6 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86drm.h" #include "radeon_common.h" #include "radeon_sarea.h" +#include "xmlconfig.h" typedef struct { drmHandle handle; /* Handle to the DRM region */ @@ -80,7 +80,7 @@ typedef struct { r200RegionRec mmio; r200RegionRec status; - r200RegionRec agpTextures; + r200RegionRec gartTextures; drmBufMapPtr buffers; @@ -88,11 +88,14 @@ typedef struct { __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 diff --git a/src/mesa/drivers/dri/r200/r200_span.c b/src/mesa/drivers/dri/r200/r200_span.c index b469aec429b..7e48a9d5afb 100644 --- a/src/mesa/drivers/dri/r200/r200_span.c +++ b/src/mesa/drivers/dri/r200/r200_span.c @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_span.h b/src/mesa/drivers/dri/r200/r200_span.h index 269ac0593fd..72911e9455c 100644 --- a/src/mesa/drivers/dri/r200/r200_span.h +++ b/src/mesa/drivers/dri/r200/r200_span.h @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_state.h b/src/mesa/drivers/dri/r200/r200_state.h index fe2a7dc0970..118712d8410 100644 --- a/src/mesa/drivers/dri/r200/r200_state.h +++ b/src/mesa/drivers/dri/r200/r200_state.h @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c index ba445d5012b..4c9a69f79d2 100644 --- a/src/mesa/drivers/dri/r200/r200_state_init.c +++ b/src/mesa/drivers/dri/r200/r200_state_init.c @@ -1,4 +1,4 @@ -/* $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. @@ -130,28 +130,15 @@ static GLboolean check_##NM( GLcontext *ctx, int idx ) \ 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. @@ -244,8 +231,15 @@ void r200InitState( r200ContextPtr rmesa ) 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 ); @@ -656,7 +650,7 @@ void r200InitState( r200ContextPtr rmesa ) 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, diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c index dd4025235b6..9d98358d45e 100644 --- a/src/mesa/drivers/dri/r200/r200_swtcl.c +++ b/src/mesa/drivers/dri/r200/r200_swtcl.c @@ -1,6 +1,5 @@ -/* $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 @@ -397,7 +396,7 @@ static void flush_last_swtcl_prim( r200ContextPtr rmesa ) 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); @@ -446,7 +445,7 @@ static __inline void *r200AllocDmaLowVerts( r200ContextPtr rmesa, { - 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; @@ -590,7 +589,7 @@ do { \ \ 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)); \ diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.h b/src/mesa/drivers/dri/r200/r200_swtcl.h index 9a36fb68fa9..f183b931c45 100644 --- a/src/mesa/drivers/dri/r200/r200_swtcl.h +++ b/src/mesa/drivers/dri/r200/r200_swtcl.h @@ -1,4 +1,4 @@ -/* $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. diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c index 9869ad61963..b02a7cc559b 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/src/mesa/drivers/dri/r200/r200_tcl.c @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_tcl.h b/src/mesa/drivers/dri/r200/r200_tcl.h index a2db2e18a6e..0fdf9c22c78 100644 --- a/src/mesa/drivers/dri/r200/r200_tcl.h +++ b/src/mesa/drivers/dri/r200/r200_tcl.h @@ -1,5 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_tex.c b/src/mesa/drivers/dri/r200/r200_tex.c index 5f8d06ae62e..f19f877cab5 100644 --- a/src/mesa/drivers/dri/r200/r200_tex.c +++ b/src/mesa/drivers/dri/r200/r200_tex.c @@ -1,4 +1,4 @@ -/* $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. @@ -296,7 +296,7 @@ r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat, 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: @@ -495,7 +495,7 @@ r200ValidateClientStorage( GLcontext *ctx, GLenum target, * 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; @@ -626,8 +626,8 @@ static void r200TexImage2D( GLcontext *ctx, GLenum target, GLint level, 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. */ @@ -729,8 +729,8 @@ static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level, 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. */ diff --git a/src/mesa/drivers/dri/r200/r200_tex.h b/src/mesa/drivers/dri/r200/r200_tex.h index 9013de6d795..a4301206ed8 100644 --- a/src/mesa/drivers/dri/r200/r200_tex.h +++ b/src/mesa/drivers/dri/r200/r200_tex.h @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_texmem.c b/src/mesa/drivers/dri/r200/r200_texmem.c index 34777085ac5..34db1f4421e 100644 --- a/src/mesa/drivers/dri/r200/r200_texmem.c +++ b/src/mesa/drivers/dri/r200/r200_texmem.c @@ -1,4 +1,4 @@ -/* $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. @@ -35,6 +35,7 @@ SOFTWARE. * Gareth Hughes <[email protected]> * */ + #include <errno.h> #include "glheader.h" @@ -86,12 +87,12 @@ r200DestroyTexObj( r200ContextPtr rmesa, r200TexObjPtr t ) */ -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; @@ -124,7 +125,7 @@ static void r200UploadAGPClientSubImage( r200ContextPtr rmesa, } t->image[0][hwlevel].data = texImage->Data; - srcOffset = r200AgpOffsetFromVirtual( rmesa, texImage->Data ); + srcOffset = r200GartOffsetFromVirtual( rmesa, texImage->Data ); assert( srcOffset != ~0 ); @@ -181,16 +182,16 @@ static void r200UploadRectSubImage( r200ContextPtr rmesa, 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: */ @@ -202,21 +203,21 @@ static void r200UploadRectSubImage( r200ContextPtr rmesa, } } 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; @@ -344,9 +345,9 @@ static void uploadSubImage( r200ContextPtr rmesa, r200TexObjPtr t, } 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; } diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c index e1dc206d927..3d82aac3234 100644 --- a/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/src/mesa/drivers/dri/r200/r200_texstate.c @@ -1,6 +1,5 @@ -/* $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 @@ -106,7 +105,7 @@ static void r200SetTexImages( r200ContextPtr rmesa, 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 @@ -126,66 +125,15 @@ static void r200SetTexImages( r200ContextPtr rmesa, } - /* 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); @@ -199,7 +147,7 @@ static void r200SetTexImages( r200ContextPtr rmesa, const struct gl_texture_image *texImage; GLuint size; - texImage = tObj->Image[i + firstLevel]; + texImage = tObj->Image[i + t->base.firstLevel]; if ( !texImage ) break; @@ -219,10 +167,12 @@ static void r200SetTexImages( r200ContextPtr rmesa, } 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; @@ -305,17 +255,17 @@ static void r200SetTexImages( r200ContextPtr rmesa, (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; @@ -1561,6 +1511,12 @@ static GLboolean enable_tex_3d( GLcontext *ctx, int unit ) 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 ); @@ -1633,7 +1589,7 @@ static GLboolean enable_tex_rect( GLcontext *ctx, int unit ) 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; } diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt.c b/src/mesa/drivers/dri/r200/r200_vtxfmt.c index 5a4f59d9763..a617d3f0290 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt.c @@ -1,6 +1,5 @@ -/* $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 @@ -970,7 +969,7 @@ static void r200VtxFmtFlushVertices( GLcontext *ctx, GLuint flags ) */ -void r200VtxfmtInit( GLcontext *ctx ) +void r200VtxfmtInit( GLcontext *ctx, GLboolean useCodegen ) { r200ContextPtr rmesa = R200_CONTEXT( ctx ); GLvertexformat *vfmt = &(rmesa->vb.vtxfmt); @@ -1067,7 +1066,7 @@ void r200VtxfmtInit( GLcontext *ctx ) 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 ) diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt.h b/src/mesa/drivers/dri/r200/r200_vtxfmt.h index fde3eca4678..39f0a10e4eb 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt.h +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt.h @@ -1,6 +1,5 @@ -/* $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 @@ -44,7 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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 ); @@ -87,7 +86,7 @@ do { \ /* */ -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 ); diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c b/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c index b7f3fec43e0..efef751a616 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c @@ -1,6 +1,5 @@ -/* $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 @@ -860,7 +859,7 @@ static struct dynfn *codegen_noop( GLcontext *ctx, const int *key ) return 0; } -void r200InitCodegen( struct dfn_generators *gen ) +void r200InitCodegen( struct dfn_generators *gen, GLboolean useCodegen ) { gen->Vertex3f = codegen_noop; gen->Vertex3fv = codegen_noop; @@ -889,7 +888,7 @@ void r200InitCodegen( struct dfn_generators *gen ) gen->MultiTexCoord1fARB = codegen_noop; gen->MultiTexCoord1fvARB = codegen_noop; - if (!getenv("R200_NO_CODEGEN")) { + if (useCodegen) { #if defined(USE_X86_ASM) r200InitX86Codegen( gen ); #endif diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c b/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c index 83eb3e13b78..2245bbcef1b 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c b/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c index a806eca0bb3..c4d8af85e16 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c +++ b/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c @@ -1,6 +1,5 @@ -/* $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 diff --git a/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S b/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S index 4980ce1bb76..56a4144e8e7 100644 --- a/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S +++ b/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S @@ -1,4 +1,4 @@ -/* $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. @@ -32,16 +32,6 @@ x: .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 @@ -218,19 +208,70 @@ GLOBL ( _x86_Vertex3fv ) .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 @@ -290,69 +331,13 @@ GLOBL( _x86_Color4ub_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 @@ -360,15 +345,15 @@ GLOBL( _x86_MultiTexCoord2fvARB ) 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 @@ -376,35 +361,132 @@ GLOBL( _x86_MultiTexCoord2fvARB_2 ) 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 ) diff --git a/src/mesa/drivers/dri/radeon/Makefile.X11 b/src/mesa/drivers/dri/radeon/Makefile.X11 index 57ef24e8fba..19dabce262c 100644 --- a/src/mesa/drivers/dri/radeon/Makefile.X11 +++ b/src/mesa/drivers/dri/radeon/Makefile.X11 @@ -1,4 +1,4 @@ -# $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 @@ -49,7 +49,8 @@ DRIVER_SOURCES = radeon_context.c \ ../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 \ diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 835cecbc3a0..5604d9c8c21 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -1,4 +1,4 @@ -/* $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 @@ -69,6 +69,25 @@ int RADEON_DEBUG = (0); #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. */ @@ -102,8 +121,7 @@ static const GLubyte *radeonGetString( GLcontext *ctx, GLenum name ) 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-" ); @@ -229,6 +247,7 @@ radeonCreateContext( const __GLcontextModes *glVisual, radeonContextPtr rmesa; GLcontext *ctx, *shareCtx; int i; + int tcl_mode, fthrottle_mode, preferred_bpt; assert(glVisual); assert(driContextPriv); @@ -258,13 +277,11 @@ radeonCreateContext( const __GLcontextModes *glVisual, 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 + @@ -291,6 +308,9 @@ radeonCreateContext( const __GLcontextModes *glVisual, 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; @@ -338,7 +358,7 @@ radeonCreateContext( const __GLcontextModes *glVisual, 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. */ @@ -392,22 +412,24 @@ radeonCreateContext( const __GLcontextModes *glVisual, 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 ); @@ -417,25 +439,20 @@ radeonCreateContext( const __GLcontextModes *glVisual, 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 ); } @@ -478,9 +495,11 @@ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv ) 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; @@ -497,8 +516,7 @@ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv ) */ 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 ] ); @@ -506,6 +524,9 @@ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv ) } } + /* free the option cache */ + driDestroyOptionCache (&rmesa->optionCache); + FREE( rmesa ); } } @@ -556,11 +577,12 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv, 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 ); diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h index 5f1f9659e84..69808837ea4 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_context.h @@ -444,7 +444,7 @@ struct radeon_dma_buffer { 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) @@ -690,6 +690,7 @@ struct radeon_context { unsigned nr_heaps; driTexHeap * texture_heaps[ RADEON_NR_TEX_HEAPS ]; driTextureObject swapped; + GLboolean default32BitTextures; /* Rasterization and vertex state: @@ -769,6 +770,10 @@ struct radeon_context { */ struct radeon_dri_mirror dri; + /* Configuration cache + */ + driOptionCache optionCache; + /* Performance counters */ diff --git a/src/mesa/drivers/dri/radeon/radeon_ioctl.c b/src/mesa/drivers/dri/radeon/radeon_ioctl.c index a388720aba1..4e1f451e70a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_ioctl.c +++ b/src/mesa/drivers/dri/radeon/radeon_ioctl.c @@ -34,8 +34,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Gareth Hughes <[email protected]> * Keith Whitwell <[email protected]> */ + #include <sched.h> -#include <errno.h> +#include <errno.h> #include "glheader.h" #include "imports.h" @@ -162,7 +163,6 @@ extern void radeonEmitVbufPrim( radeonContextPtr rmesa, drmRadeonCmdHeader *cmd; - assert(rmesa->dri.drmMinor >= 3); assert(!(primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND)); radeonEmitState( rmesa ); @@ -254,7 +254,6 @@ GLushort *radeonAllocEltsOpenEnded( radeonContextPtr 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 ); @@ -317,7 +316,6 @@ void radeonEmitVertexAOS( radeonContextPtr 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", @@ -356,7 +354,6 @@ void radeonEmitAOS( radeonContextPtr rmesa, if (RADEON_DEBUG & DEBUG_IOCTL) fprintf(stderr, "%s\n", __FUNCTION__); - assert(rmesa->dri.drmMinor >= 3); cmd = (drmRadeonCmdHeader *)radeonAllocCmdBuf( rmesa, sz * sizeof(int), __FUNCTION__ ); @@ -531,8 +528,6 @@ void radeonFlushCmdBuf( radeonContextPtr rmesa, const char *caller ) int ret; - assert (rmesa->dri.drmMinor >= 3); - LOCK_HARDWARE( rmesa ); ret = radeonFlushCmdBufLocked( rmesa, caller ); @@ -691,9 +686,6 @@ void radeonAllocDmaRegion( radeonContextPtr rmesa, 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, @@ -719,7 +711,7 @@ static CARD32 radeonGetLastFrame (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) ); } @@ -1012,7 +1004,7 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all, 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 @@ -1154,13 +1146,11 @@ void radeonFlush( GLcontext *ctx ) 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 diff --git a/src/mesa/drivers/dri/radeon/radeon_lock.c b/src/mesa/drivers/dri/radeon/radeon_lock.c index 96a4f9d1123..daf001e048a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_lock.c +++ b/src/mesa/drivers/dri/radeon/radeon_lock.c @@ -53,8 +53,6 @@ radeonUpdatePageFlipping( radeonContextPtr rmesa ) { int use_back; - if (rmesa->dri.drmMinor < 3) - return; rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip; diff --git a/src/mesa/drivers/dri/radeon/radeon_maos.h b/src/mesa/drivers/dri/radeon/radeon_maos.h index 7e2bd643d34..8c8aa15c59f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_maos.h +++ b/src/mesa/drivers/dri/radeon/radeon_maos.h @@ -1,4 +1,4 @@ -/* $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 diff --git a/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c b/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c index cec05a89d7e..fc55b89b030 100644 --- a/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c +++ b/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c @@ -1,4 +1,4 @@ -/* $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 @@ -409,7 +409,7 @@ static void emit_tex_vector( GLcontext *ctx, -/* 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 ) diff --git a/src/mesa/drivers/dri/radeon/radeon_maos_verts.c b/src/mesa/drivers/dri/radeon/radeon_maos_verts.c index 39b1f575074..b32fd624fa3 100644 --- a/src/mesa/drivers/dri/radeon/radeon_maos_verts.c +++ b/src/mesa/drivers/dri/radeon/radeon_maos_verts.c @@ -1,4 +1,4 @@ -/* $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 diff --git a/src/mesa/drivers/dri/radeon/radeon_sanity.c b/src/mesa/drivers/dri/radeon/radeon_sanity.c index e3b37bf3de9..3bc15bdcb47 100644 --- a/src/mesa/drivers/dri/radeon/radeon_sanity.c +++ b/src/mesa/drivers/dri/radeon/radeon_sanity.c @@ -1,4 +1,4 @@ -/* $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 @@ -32,7 +32,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell <[email protected]> * */ -#include <errno.h> +#include <errno.h> #include "glheader.h" diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index ec8ed42d649..8f2042af13f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -1,4 +1,4 @@ -/* $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 @@ -48,7 +48,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef _SOLO #include "glxextensions.h" -#endif +#endif #if 1 /* Including xf86PciInfo.h introduces a bunch of errors... @@ -89,32 +89,26 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv ) 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; } @@ -166,20 +160,26 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv ) 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; @@ -215,21 +215,36 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv ) 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; @@ -244,14 +259,16 @@ void radeonDestroyScreen( __DRIscreenPrivate *sPriv ) 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; } @@ -350,7 +367,7 @@ static struct __DriverAPIRec radeonAPI = { * 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) { @@ -368,10 +385,13 @@ void *__driCreateScreen(struct DRIDriverRec *driver, } #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 ) @@ -381,19 +401,18 @@ __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. */ diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 2c69d8657ae..133c3633c1b 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -48,6 +48,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "radeon_dri.h" #include "radeon_reg.h" #include "radeon_sarea.h" +#include "xmlconfig.h" typedef struct { @@ -83,7 +84,7 @@ typedef struct { radeonRegionRec mmio; radeonRegionRec status; - radeonRegionRec agpTextures; + radeonRegionRec gartTextures; drmBufMapPtr buffers; @@ -91,7 +92,11 @@ typedef struct { __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 ); diff --git a/src/mesa/drivers/dri/radeon/radeon_state_init.c b/src/mesa/drivers/dri/radeon/radeon_state_init.c index 971ea699ea2..0b2a1089b8c 100644 --- a/src/mesa/drivers/dri/radeon/radeon_state_init.c +++ b/src/mesa/drivers/dri/radeon/radeon_state_init.c @@ -1,4 +1,4 @@ -/* $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. * diff --git a/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/src/mesa/drivers/dri/radeon/radeon_swtcl.c index 926b1523d62..89db677392d 100644 --- a/src/mesa/drivers/dri/radeon/radeon_swtcl.c +++ b/src/mesa/drivers/dri/radeon/radeon_swtcl.c @@ -1,4 +1,4 @@ -/* $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 @@ -67,7 +67,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #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 ); @@ -282,7 +281,6 @@ static void radeonRenderStart( GLcontext *ctx ) } if (rmesa->dma.flush != 0 && - rmesa->dma.flush != flush_last_swtcl_prim_compat && rmesa->dma.flush != flush_last_swtcl_prim) rmesa->dma.flush( rmesa ); } @@ -381,7 +379,7 @@ static void flush_last_swtcl_prim( radeonContextPtr 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); @@ -408,46 +406,6 @@ static void flush_last_swtcl_prim( radeonContextPtr rmesa ) } -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, @@ -460,22 +418,18 @@ 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; @@ -624,7 +578,7 @@ do { \ \ 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)); \ @@ -683,15 +637,6 @@ static GLboolean radeon_run_render( GLcontext *ctx, 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) { @@ -952,7 +897,6 @@ static void radeonResetLineStipple( GLcontext *ctx ); #define RADEON_TWOSIDE_BIT 0x01 #define RADEON_UNFILLED_BIT 0x02 -#define RADEON_OFFSET_BIT 0x04 /* drmMinor == 1 */ #define RADEON_MAX_TRIFUNC 0x08 @@ -965,7 +909,7 @@ static struct { #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 @@ -1051,22 +995,6 @@ static struct { #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 ) { @@ -1074,10 +1002,6 @@ 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(); } /**********************************************************************/ @@ -1136,8 +1060,6 @@ void radeonChooseRenderState( GLcontext *ctx ) 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; @@ -1300,7 +1222,7 @@ void radeonInitSwtcl( GLcontext *ctx ) 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; diff --git a/src/mesa/drivers/dri/radeon/radeon_tcl.h b/src/mesa/drivers/dri/radeon/radeon_tcl.h index 1e97d32148a..881264a2676 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tcl.h +++ b/src/mesa/drivers/dri/radeon/radeon_tcl.h @@ -1,4 +1,4 @@ -/* $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 diff --git a/src/mesa/drivers/dri/radeon/radeon_texmem.c b/src/mesa/drivers/dri/radeon/radeon_texmem.c index 3adc2a951c6..284efb225ac 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texmem.c +++ b/src/mesa/drivers/dri/radeon/radeon_texmem.c @@ -35,7 +35,7 @@ SOFTWARE. * Gareth Hughes <[email protected]> * */ -#include <errno.h> +#include <errno.h> #include "glheader.h" #include "imports.h" @@ -112,8 +112,8 @@ static void radeonUploadRectSubImage( radeonContextPtr rmesa, 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; diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c index 6dccd311800..0bece3e8b9b 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c @@ -107,7 +107,7 @@ static void radeonSetTexImages( radeonContextPtr rmesa, 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 @@ -127,40 +127,15 @@ static void radeonSetTexImages( radeonContextPtr rmesa, } - /* 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); @@ -174,7 +149,7 @@ static void radeonSetTexImages( radeonContextPtr rmesa, const struct gl_texture_image *texImage; GLuint size; - texImage = tObj->Image[i + firstLevel]; + texImage = tObj->Image[i + t->base.firstLevel]; if ( !texImage ) break; @@ -194,10 +169,12 @@ static void radeonSetTexImages( radeonContextPtr rmesa, } 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; @@ -237,17 +214,17 @@ static void radeonSetTexImages( radeonContextPtr rmesa, 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; @@ -1500,7 +1477,7 @@ static GLboolean enable_tex_rect( GLcontext *ctx, int unit ) 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; } diff --git a/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c b/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c index b613e9eb434..9af0942898d 100644 --- a/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c +++ b/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c @@ -1,4 +1,4 @@ -/* $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 @@ -937,7 +937,7 @@ static void radeonVtxfmtFlushVertices( GLcontext *ctx, GLuint flags ) */ -void radeonVtxfmtInit( GLcontext *ctx ) +void radeonVtxfmtInit( GLcontext *ctx, GLboolean useCodegen ) { radeonContextPtr rmesa = RADEON_CONTEXT( ctx ); GLvertexformat *vfmt = &(rmesa->vb.vtxfmt); @@ -1034,7 +1034,7 @@ void radeonVtxfmtInit( GLcontext *ctx ) 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 ) diff --git a/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h b/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h index 9792fcbb788..78033908238 100644 --- a/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h +++ b/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h @@ -42,7 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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 ); @@ -84,7 +84,7 @@ do { \ /* */ -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 ); diff --git a/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c b/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c index 188e34a4208..04cffb77729 100644 --- a/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c +++ b/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c @@ -1,4 +1,4 @@ -/* $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 @@ -864,7 +864,7 @@ static struct dynfn *codegen_noop( GLcontext *ctx, int key ) return 0; } -void radeonInitCodegen( struct dfn_generators *gen ) +void radeonInitCodegen( struct dfn_generators *gen, GLboolean useCodegen ) { gen->Vertex3f = codegen_noop; gen->Vertex3fv = codegen_noop; @@ -893,7 +893,7 @@ void radeonInitCodegen( struct dfn_generators *gen ) gen->MultiTexCoord1fARB = codegen_noop; gen->MultiTexCoord1fvARB = codegen_noop; - if (!getenv("RADEON_NO_CODEGEN")) { + if (useCodegen) { #if defined(USE_X86_ASM) radeonInitX86Codegen( gen ); #endif diff --git a/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c b/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c index 0f2c82bd878..71e74381a5a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c +++ b/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c @@ -1,4 +1,4 @@ -/* $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 diff --git a/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c b/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c index 92941ca5f80..59b0db0a5f9 100644 --- a/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c +++ b/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c @@ -1,4 +1,4 @@ -/* $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 diff --git a/src/mesa/drivers/dri/radeon/server/radeon.h b/src/mesa/drivers/dri/radeon/server/radeon.h index 4606a0b71e6..808289b140f 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon.h +++ b/src/mesa/drivers/dri/radeon/server/radeon.h @@ -108,11 +108,11 @@ typedef struct { * \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; /*@}*/ /** @@ -144,11 +144,11 @@ typedef struct { * \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 */ diff --git a/src/mesa/drivers/dri/radeon/server/radeon_common.h b/src/mesa/drivers/dri/radeon/server/radeon_common.h index 0792b5c2e0e..365ecfb9a17 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon_common.h +++ b/src/mesa/drivers/dri/radeon/server/radeon_common.h @@ -31,7 +31,7 @@ * Converted to common header format: * Jens Owen <[email protected]> * - * $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 $ * */ @@ -70,6 +70,7 @@ #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 @@ -94,7 +95,7 @@ typedef struct { unsigned long sarea_priv_offset; int is_pci; int cp_mode; - int agp_size; + int gart_size; int ring_size; int usec_timeout; @@ -109,7 +110,7 @@ typedef struct { 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 { @@ -404,22 +405,22 @@ typedef struct drm_radeon_getparam { 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 { diff --git a/src/mesa/drivers/dri/radeon/server/radeon_dri.c b/src/mesa/drivers/dri/radeon/server/radeon_dri.c index 4271aa7da23..a37561457bc 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon_dri.c +++ b/src/mesa/drivers/dri/radeon/server/radeon_dri.c @@ -318,7 +318,7 @@ static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info) int s, l; if (drmAgpAcquire(ctx->drmFD) < 0) { - fprintf(stderr, "[agp] AGP not available\n"); + fprintf(stderr, "[gart] AGP not available\n"); return 0; } @@ -334,40 +334,40 @@ static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info) /* 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; @@ -378,51 +378,51 @@ static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info) 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 */ @@ -463,7 +463,7 @@ static int RADEONDRIKernelInit( const DRIDriverContext *ctx, 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; @@ -479,7 +479,7 @@ static int RADEONDRIKernelInit( const DRIDriverContext *ctx, 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)); @@ -502,19 +502,19 @@ static void RADEONDRIAgpHeapInit(const DRIDriverContext *ctx, { 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); } } @@ -640,13 +640,13 @@ static int RADEONMemoryInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) 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?? */ @@ -733,7 +733,7 @@ static int RADEONMemoryInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) * 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; @@ -883,7 +883,7 @@ static int RADEONScreenInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) /* Initialize IRQ */ RADEONDRIIrqInit(ctx, info); - /* Initialize kernel agp memory manager */ + /* Initialize kernel gart memory manager */ RADEONDRIAgpHeapInit(ctx, info); /* Initialize the SAREA private data structure */ @@ -919,7 +919,7 @@ static int RADEONScreenInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) 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; @@ -933,10 +933,10 @@ static int RADEONScreenInit( const DRIDriverContext *ctx, RADEONInfoPtr info ) 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. */ @@ -1139,10 +1139,10 @@ static int radeonInitFBDev( DRIDriverContext *ctx ) 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; diff --git a/src/mesa/drivers/dri/radeon/server/radeon_dri.h b/src/mesa/drivers/dri/radeon/server/radeon_dri.h index fce21227cb9..fc96deb1024 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon_dri.h +++ b/src/mesa/drivers/dri/radeon/server/radeon_dri.h @@ -102,10 +102,10 @@ typedef struct { * \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*/ diff --git a/src/mesa/drivers/dri/radeon/server/radeon_reg.h b/src/mesa/drivers/dri/radeon/server/radeon_reg.h index 5570a439458..4bd4d14e783 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon_reg.h +++ b/src/mesa/drivers/dri/radeon/server/radeon_reg.h @@ -1,4 +1,4 @@ -/* $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. @@ -66,6 +66,8 @@ # 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 @@ -232,6 +234,28 @@ # 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) @@ -272,6 +296,9 @@ # 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) @@ -356,7 +383,10 @@ #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) @@ -365,6 +395,12 @@ # 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) @@ -374,7 +410,9 @@ # 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 */ @@ -392,6 +430,23 @@ #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 @@ -582,7 +637,10 @@ # 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) @@ -590,6 +648,8 @@ # 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 @@ -697,6 +757,10 @@ #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) @@ -711,6 +775,12 @@ #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 @@ -723,7 +793,13 @@ #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 @@ -879,7 +955,7 @@ # 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 @@ -891,6 +967,11 @@ # 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 */ @@ -1013,6 +1094,9 @@ #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 @@ -1025,6 +1109,9 @@ # 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 @@ -1878,12 +1965,11 @@ #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 @@ -2012,4 +2098,16 @@ #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 diff --git a/src/mesa/drivers/dri/radeon/server/radeon_sarea.h b/src/mesa/drivers/dri/radeon/server/radeon_sarea.h index 81e4325d7a1..95db1f37ac9 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon_sarea.h +++ b/src/mesa/drivers/dri/radeon/server/radeon_sarea.h @@ -1,11 +1,4 @@ -/** - * \file server/radeon_sarea.h - * \brief SAREA definition. - * - * \author Kevin E. Martin <[email protected]> - * \author Gareth Hughes <[email protected]> - */ - +/* $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. @@ -34,7 +27,12 @@ * 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 <[email protected]> + * Gareth Hughes <[email protected]> + * + */ #ifndef _RADEON_SAREA_H_ #define _RADEON_SAREA_H_ @@ -94,11 +92,11 @@ /* 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 @@ -115,10 +113,6 @@ #endif /* __RADEON_SAREA_DEFINES__ */ - -/** - * \brief Color register format. - */ typedef struct { unsigned int red; unsigned int green; @@ -126,15 +120,8 @@ typedef struct { 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; @@ -149,76 +136,44 @@ typedef struct { 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; @@ -229,82 +184,48 @@ typedef struct { 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 |