summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/sis
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/sis')
-rw-r--r--src/mesa/drivers/dri/sis/Makefile.solo1
-rw-r--r--src/mesa/drivers/dri/sis/sis_context.c20
-rw-r--r--src/mesa/drivers/dri/sis/sis_dd.c23
-rw-r--r--src/mesa/drivers/dri/sis/sis_dd.h2
-rw-r--r--src/mesa/drivers/dri/sis/sis_tex.c134
-rw-r--r--src/mesa/drivers/dri/sis/sis_tex.h2
6 files changed, 95 insertions, 87 deletions
diff --git a/src/mesa/drivers/dri/sis/Makefile.solo b/src/mesa/drivers/dri/sis/Makefile.solo
index 655c4e7d31c..7648d6921b9 100644
--- a/src/mesa/drivers/dri/sis/Makefile.solo
+++ b/src/mesa/drivers/dri/sis/Makefile.solo
@@ -38,6 +38,7 @@ DRIVER_SOURCES = \
sis_texstate.c \
sis_tris.c \
sis_vb.c \
+ ../../common/driverfuncs.c \
../common/mm.c \
../common/utils.c \
../common/texmem.c \
diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c
index 7daa947a464..8a20f7ec0ee 100644
--- a/src/mesa/drivers/dri/sis/sis_context.c
+++ b/src/mesa/drivers/dri/sis/sis_context.c
@@ -48,6 +48,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "extensions.h"
#include "utils.h"
+#include "drivers/common/driverfuncs.h"
+
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "array_cache/acache.h"
@@ -108,19 +110,26 @@ sisCreateContext( const __GLcontextModes *glVisual,
sisContextPtr smesa;
sisScreenPtr sisScreen;
int i;
+ struct dd_function_table functions;
smesa = (sisContextPtr)CALLOC( sizeof(*smesa) );
- if ( smesa == NULL )
+ if (smesa == NULL)
return GL_FALSE;
+ /* Init default driver functions then plug in our SIS-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ sisInitTextureFuncs(&functions);
+
/* Allocate the Mesa context */
if (sharedContextPrivate)
shareCtx = ((sisContextPtr)sharedContextPrivate)->glCtx;
else
shareCtx = NULL;
- smesa->glCtx = _mesa_create_context( glVisual, shareCtx, (void *) smesa,
- GL_TRUE);
- if (smesa->glCtx == NULL) {
+ smesa->glCtx = _mesa_create_context( glVisual, shareCtx,
+ &functions, (void *) smesa);
+ if (!smesa->glCtx) {
FREE(smesa);
return GL_FALSE;
}
@@ -217,14 +226,13 @@ sisCreateContext( const __GLcontextModes *glVisual,
_swrast_allow_pixel_fog( ctx, GL_TRUE );
_swrast_allow_vertex_fog( ctx, GL_FALSE );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
sisDDInitStateFuncs( ctx );
sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */
sisInitVB( ctx );
sisInitTriFuncs( ctx );
- sisDDInitDriverFuncs( ctx );
sisDDInitSpanFuncs( ctx );
sisDDInitStencilFuncs( ctx );
- sisDDInitTextureFuncs( ctx );
driInitExtensions( ctx, card_extensions, GL_FALSE );
diff --git a/src/mesa/drivers/dri/sis/sis_dd.c b/src/mesa/drivers/dri/sis/sis_dd.c
index aecc20e53db..2c97d270fda 100644
--- a/src/mesa/drivers/dri/sis/sis_dd.c
+++ b/src/mesa/drivers/dri/sis/sis_dd.c
@@ -48,7 +48,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Return the width and height of the given buffer.
*/
static void
-sisDDGetBufferSize( GLframebuffer *buffer,
+sisGetBufferSize( GLframebuffer *buffer,
GLuint *width, GLuint *height )
{
GET_CURRENT_CONTEXT(ctx);
@@ -63,7 +63,7 @@ sisDDGetBufferSize( GLframebuffer *buffer,
/* Return various strings for glGetString().
*/
static const GLubyte *
-sisDDGetString( GLcontext *ctx, GLenum name )
+sisGetString( GLcontext *ctx, GLenum name )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
static char buffer[128];
@@ -88,7 +88,7 @@ sisDDGetString( GLcontext *ctx, GLenum name )
/* Send all commands to the hardware. No-op, due to mmio.
*/
static void
-sisDDFlush( GLcontext *ctx )
+sisFlush( GLcontext *ctx )
{
/* Do nothing */
}
@@ -97,11 +97,11 @@ sisDDFlush( GLcontext *ctx )
* completed processing.
*/
static void
-sisDDFinish( GLcontext *ctx )
+sisFinish( GLcontext *ctx )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisDDFlush( ctx );
+ sisFlush( ctx );
WaitEngIdle( smesa );
}
@@ -165,12 +165,11 @@ sisUpdateBufferSize( sisContextPtr smesa )
/* Initialize the driver's misc functions.
*/
void
-sisDDInitDriverFuncs( GLcontext *ctx )
+sisInitDriverFuncs( struct dd_function_table *functions )
{
- ctx->Driver.GetBufferSize = sisDDGetBufferSize;
- ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
- ctx->Driver.GetString = sisDDGetString;
- ctx->Driver.Finish = sisDDFinish;
- ctx->Driver.Flush = sisDDFlush;
- ctx->Driver.Error = NULL;
+ functions->GetBufferSize = sisGetBufferSize;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetString = sisGetString;
+ functions->Finish = sisFinish;
+ functions->Flush = sisFlush;
}
diff --git a/src/mesa/drivers/dri/sis/sis_dd.h b/src/mesa/drivers/dri/sis/sis_dd.h
index 9ff5f5b00d0..a016bf8b266 100644
--- a/src/mesa/drivers/dri/sis/sis_dd.h
+++ b/src/mesa/drivers/dri/sis/sis_dd.h
@@ -36,7 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
extern void sisUpdateBufferSize( sisContextPtr smesa );
-extern void sisDDInitDriverFuncs( GLcontext *ctx );
+extern void sisInitDriverFuncs( struct dd_function_table *functions );
#endif
#endif
diff --git a/src/mesa/drivers/dri/sis/sis_tex.c b/src/mesa/drivers/dri/sis/sis_tex.c
index f5df84b3e7c..ece0c519b70 100644
--- a/src/mesa/drivers/dri/sis/sis_tex.c
+++ b/src/mesa/drivers/dri/sis/sis_tex.c
@@ -40,7 +40,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "teximage.h"
#include "texobj.h"
-#define ALIGN(value, align) (char *)((long)(value + align - 1) & ~(align - 1))
+#define ALIGN(value, align) (GLubyte *)((long)(value + align - 1) & ~(align - 1))
#define TEXTURE_HW_ALIGNMENT 4
#define TEXTURE_HW_PLUS (4 + 4)
@@ -139,7 +139,7 @@ sisFreeTexImage( sisContextPtr smesa, sisTexObjPtr t, int level )
}
static void
-sisDDTexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param )
+sisTexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
@@ -147,9 +147,9 @@ sisDDTexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param )
}
static void
-sisDDTexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *texObj, GLenum pname,
- const GLfloat *params )
+sisTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj, GLenum pname,
+ const GLfloat *params )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
@@ -157,22 +157,13 @@ sisDDTexParameter( GLcontext *ctx, GLenum target,
}
static void
-sisDDBindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *texObj )
+sisBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
-
- if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
- if ( texObj->DriverData == NULL ) {
- sisAllocTexObj( texObj );
- }
- }
+ sisTexObjPtr t = texObj->DriverData;
- t = texObj->DriverData;
-
- if (t == NULL)
- return;
+ assert(t);
if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) {
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
@@ -182,7 +173,7 @@ sisDDBindTexture( GLcontext *ctx, GLenum target,
}
static void
-sisDDDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
+sisDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
sisTexObjPtr t;
@@ -191,10 +182,11 @@ sisDDDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
smesa->clearTexCache = GL_TRUE;
t = texObj->DriverData;
+ assert(t);
if (t == NULL) {
/*
* this shows the texture is default object and never be a
- * argument of sisDDTexImage*
+ * argument of sisTexImage*
*/
return;
}
@@ -208,14 +200,14 @@ sisDDDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
_mesa_delete_texture_object(ctx, texObj);
}
-static GLboolean sisDDIsTextureResident( GLcontext * ctx,
+static GLboolean sisIsTextureResident( GLcontext * ctx,
struct gl_texture_object *texObj )
{
return (texObj->DriverData != NULL);
}
static const struct gl_texture_format *
-sisDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type )
{
/* XXX 16-bit internal texture formats? */
@@ -275,7 +267,7 @@ sisDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
}
}
-static void sisDDTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+static void sisTexImage1D( GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
@@ -284,13 +276,10 @@ static void sisDDTexImage1D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
-
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ sisTexObjPtr t = texObj->DriverData;
- /* Note, this will call sisDDChooseTextureFormat */
+ assert(t);
+ /* Note, this will call sisChooseTextureFormat */
_mesa_store_teximage1d( ctx, target, level, internalFormat,
width, border, format, type,
pixels, packing, texObj, texImage );
@@ -311,7 +300,7 @@ static void sisDDTexImage1D( GLcontext *ctx, GLenum target, GLint level,
}
-static void sisDDTexSubImage1D( GLcontext *ctx,
+static void sisTexSubImage1D( GLcontext *ctx,
GLenum target,
GLint level,
GLint xoffset,
@@ -323,14 +312,13 @@ static void sisDDTexSubImage1D( GLcontext *ctx,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
+ sisTexObjPtr t = texObj->DriverData;
GLuint copySize;
GLint texelBytes;
- char *src, *dst;
+ const char *src;
+ GLubyte *dst;
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ assert(t);
_mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
format, type, pixels, packing, texObj,
@@ -359,7 +347,7 @@ static void sisDDTexSubImage1D( GLcontext *ctx,
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
}
-static void sisDDTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+static void sisTexImage2D( GLcontext *ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLenum format, GLenum type, const GLvoid *pixels,
@@ -368,13 +356,11 @@ static void sisDDTexImage2D( GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
+ sisTexObjPtr t = texObj->DriverData;
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ assert(t);
- /* Note, this will call sisDDChooseTextureFormat */
+ /* Note, this will call sisChooseTextureFormat */
_mesa_store_teximage2d(ctx, target, level, internalFormat,
width, height, border, format, type, pixels,
&ctx->Unpack, texObj, texImage);
@@ -394,7 +380,7 @@ static void sisDDTexImage2D( GLcontext *ctx, GLenum target, GLint level,
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
}
-static void sisDDTexSubImage2D( GLcontext *ctx,
+static void sisTexSubImage2D( GLcontext *ctx,
GLenum target,
GLint level,
GLint xoffset, GLint yoffset,
@@ -406,16 +392,15 @@ static void sisDDTexSubImage2D( GLcontext *ctx,
struct gl_texture_image *texImage )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
- sisTexObjPtr t;
+ sisTexObjPtr t = texObj->DriverData;
GLuint copySize;
GLint texelBytes;
- char *src, *dst;
+ const char *src;
+ GLubyte *dst;
int j;
GLuint soffset;
- if ( texObj->DriverData == NULL )
- sisAllocTexObj( texObj );
- t = texObj->DriverData;
+ assert(t);
_mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
height, format, type, pixels, packing, texObj,
@@ -449,28 +434,43 @@ static void sisDDTexSubImage2D( GLcontext *ctx,
smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format;
}
smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ */
+static struct gl_texture_object *
+sisNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ sisTexObjPtr t;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+ t = (sisTexObjPtr) sisAllocTexObj( obj );
+ if (!t) {
+ _mesa_delete_texture_object(ctx, obj);
+ return NULL;
+ }
+ return obj;
}
-void sisDDInitTextureFuncs( GLcontext *ctx )
+
+void sisInitTextureFuncs( struct dd_function_table *functions )
{
- ctx->Driver.TexEnv = sisDDTexEnv;
- ctx->Driver.ChooseTextureFormat = sisDDChooseTextureFormat;
- ctx->Driver.TexImage1D = sisDDTexImage1D;
- ctx->Driver.TexSubImage1D = sisDDTexSubImage1D;
- ctx->Driver.TexImage2D = sisDDTexImage2D;
- ctx->Driver.TexSubImage2D = sisDDTexSubImage2D;
- ctx->Driver.TexImage3D = _mesa_store_teximage3d;
- ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
- ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
- ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
- ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
- ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
- ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
- ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
- ctx->Driver.TexParameter = sisDDTexParameter;
- ctx->Driver.BindTexture = sisDDBindTexture;
- ctx->Driver.DeleteTexture = sisDDDeleteTexture;
- ctx->Driver.IsTextureResident = sisDDIsTextureResident;
- ctx->Driver.PrioritizeTexture = NULL;
+ functions->TexEnv = sisTexEnv;
+ functions->ChooseTextureFormat = sisChooseTextureFormat;
+ functions->TexImage1D = sisTexImage1D;
+ functions->TexSubImage1D = sisTexSubImage1D;
+ functions->TexImage2D = sisTexImage2D;
+ functions->TexSubImage2D = sisTexSubImage2D;
+ functions->TexParameter = sisTexParameter;
+ functions->BindTexture = sisBindTexture;
+ functions->NewTextureObject = sisNewTextureObject;
+ functions->DeleteTexture = sisDeleteTexture;
+ functions->IsTextureResident = sisIsTextureResident;
}
diff --git a/src/mesa/drivers/dri/sis/sis_tex.h b/src/mesa/drivers/dri/sis/sis_tex.h
index b2f2ba0cbd6..2349824885a 100644
--- a/src/mesa/drivers/dri/sis/sis_tex.h
+++ b/src/mesa/drivers/dri/sis/sis_tex.h
@@ -34,7 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
-extern void sisDDInitTextureFuncs( GLcontext *ctx );
+extern void sisInitTextureFuncs( struct dd_function_table *table );
extern void sisUpdateTextureState( GLcontext *ctx );
#endif /* GLX_DIRECT_RENDERING */