From 3d06dc75816ef7f1c6e2c3f24a98dd2934c4c385 Mon Sep 17 00:00:00 2001 From: Daniel Borca Date: Fri, 23 Jan 2004 15:57:52 +0000 Subject: accomodated new driver_func initialization added DMesaGetProcAddress some other minor fixes updated documentation --- src/mesa/Makefile.DJ | 4 +- src/mesa/Makefile.mgw | 4 +- src/mesa/drivers/dos/dmesa.c | 177 +++++++++++++++++---------------------- src/mesa/drivers/glide/fxapi.c | 3 +- src/mesa/drivers/glide/fxdd.c | 27 ++---- src/mesa/drivers/glide/fxddtex.c | 4 - src/mesa/drivers/glide/fxdrv.h | 2 - src/mesa/drivers/glide/fxtris.c | 4 +- src/mesa/drivers/glide/fxwgl.c | 15 +++- 9 files changed, 103 insertions(+), 137 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/Makefile.DJ b/src/mesa/Makefile.DJ index 517e24b3b4..bd8e6f039d 100644 --- a/src/mesa/Makefile.DJ +++ b/src/mesa/Makefile.DJ @@ -20,7 +20,7 @@ # 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. -# DOS/DJGPP core makefile v1.5 for Mesa +# DOS/DJGPP core makefile v1.6 for Mesa # # Copyright (C) 2002 - Borca Daniel # Email : dborca@users.sourceforge.net @@ -174,7 +174,7 @@ DRIVER_SOURCES += \ drivers/dos/dpmi.c endif -SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES) +SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES) OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw index 2068667c60..bb370d86b4 100644 --- a/src/mesa/Makefile.mgw +++ b/src/mesa/Makefile.mgw @@ -20,7 +20,7 @@ # 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. -# MinGW core makefile v1.1 for Mesa +# MinGW core makefile v1.2 for Mesa # # Copyright (C) 2002 - Borca Daniel # Email : dborca@users.sourceforge.net @@ -170,7 +170,7 @@ DRIVER_SOURCES = \ drivers/windows/gdi/wgl.c endif -SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES) +SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES) OBJECTS = $(addsuffix .o,$(basename $(SOURCES))) diff --git a/src/mesa/drivers/dos/dmesa.c b/src/mesa/drivers/dos/dmesa.c index 5432371386..c8fd91864b 100644 --- a/src/mesa/drivers/dos/dmesa.c +++ b/src/mesa/drivers/dos/dmesa.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,7 +23,7 @@ */ /* - * DOS/DJGPP device driver v1.5 for Mesa + * DOS/DJGPP device driver v1.6 for Mesa * * Copyright (c) 2003 - Borca Daniel * Email : dborca@users.sourceforge.net @@ -53,6 +53,7 @@ #include "tnl/tnl.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" +#include "drivers/common/driverfuncs.h" #include "video.h" #else /* FX */ #include "GL/fxmesa.h" @@ -868,76 +869,45 @@ static void dmesa_register_swrast_functions (GLcontext *ctx) +static void dmesa_update_state (GLcontext *ctx, GLuint new_state) +{ + /* Propagate statechange information to swrast and swrast_setup + * modules. The DMesa driver has no internal GL-dependent state. + */ + _swrast_InvalidateState( ctx, new_state ); + _ac_InvalidateState( ctx, new_state ); + _tnl_InvalidateState( ctx, new_state ); + _swsetup_InvalidateState( ctx, new_state ); +} + + + +/* Initialize the device driver function table with the functions + * we implement in this driver. + */ +static void dmesa_init_driver_functions (DMesaVisual visual, + struct dd_function_table *driver) +{ + driver->UpdateState = dmesa_update_state; + driver->GetString = get_string; + driver->GetBufferSize = get_buffer_size; + driver->Flush = flush; + driver->Finish = finish; + driver->Clear = clear; + driver->ClearColor = clear_color; + driver->ClearIndex = clear_index; +} + + + /* Setup pointers and other driver state that is constant for the life * of a context. */ static void dmesa_init_pointers (GLcontext *ctx) { - TNLcontext *tnl; struct swrast_device_driver *dd = _swrast_GetDeviceDriverReference(ctx); - ctx->Driver.GetString = get_string; - ctx->Driver.GetBufferSize = get_buffer_size; - ctx->Driver.Flush = flush; - ctx->Driver.Finish = finish; - - /* Software rasterizer pixel paths: - */ - ctx->Driver.Accum = _swrast_Accum; - ctx->Driver.Bitmap = _swrast_Bitmap; - ctx->Driver.Clear = clear; - ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; - ctx->Driver.CopyPixels = _swrast_CopyPixels; - ctx->Driver.DrawPixels = _swrast_DrawPixels; - ctx->Driver.ReadPixels = _swrast_ReadPixels; - ctx->Driver.DrawBuffer = _swrast_DrawBuffer; - - /* Software texture functions: - */ - ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format; - ctx->Driver.TexImage1D = _mesa_store_teximage1d; - ctx->Driver.TexImage2D = _mesa_store_teximage2d; - ctx->Driver.TexImage3D = _mesa_store_teximage3d; - ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d; - ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d; - ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; - ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage; - - 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.CompressedTexImage1D = _mesa_store_compressed_teximage1d; - ctx->Driver.CompressedTexImage2D = _mesa_store_compressed_teximage2d; - ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d; - ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; - ctx->Driver.CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d; - ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; - - /* Swrast hooks for imaging extensions: - */ - ctx->Driver.CopyColorTable = _swrast_CopyColorTable; - ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable; - ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; - ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; - - /* Statechange callbacks: - */ - ctx->Driver.ClearColor = clear_color; - ctx->Driver.ClearIndex = clear_index; - - /* Initialize the TNL driver interface: - */ - tnl = TNL_CONTEXT(ctx); - tnl->Driver.RunPipeline = _tnl_run_pipeline; - dd->SetBuffer = set_buffer; - - /* Install swsetup for tnl->Driver.Render.*: - */ - _swsetup_Wakeup(ctx); /* The span functions should be in `dmesa_update_state', but I'm * pretty sure they will never change during the life of the Visual @@ -961,19 +931,6 @@ static void dmesa_init_pointers (GLcontext *ctx) dd->ReadRGBASpan = read_rgba_span; dd->ReadRGBAPixels = read_rgba_pixels; } - - - -static void dmesa_update_state (GLcontext *ctx, GLuint new_state) -{ - /* Propagate statechange information to swrast and swrast_setup - * modules. The DMesa driver has no internal GL-dependent state. - */ - _swrast_InvalidateState( ctx, new_state ); - _ac_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); -} #endif /* FX */ @@ -1188,36 +1145,46 @@ DMesaContext DMesaCreateContext (DMesaVisual visual, DMesaContext share) { #ifndef FX - DMesaContext c; - GLboolean direct = GL_FALSE; + GLcontext *c; + TNLcontext *tnl; + struct dd_function_table functions; - if ((c=(DMesaContext)CALLOC_STRUCT(dmesa_context)) != NULL) { - _mesa_initialize_context((GLcontext *)c, + if ((c=(GLcontext *)CALLOC_STRUCT(dmesa_context)) != NULL) { + /* Initialize device driver function table */ + _mesa_init_driver_functions(&functions); + /* override with our functions */ + dmesa_init_driver_functions(visual, &functions); + + _mesa_initialize_context(c, (GLvisual *)visual, (GLcontext *)share, - (void *)c, direct); - - _mesa_enable_sw_extensions((GLcontext *)c); - _mesa_enable_1_3_extensions((GLcontext *)c); - _mesa_enable_1_4_extensions((GLcontext *)c); - _mesa_enable_1_5_extensions((GLcontext *)c); + &functions, + (void *)c); + + _mesa_enable_sw_extensions(c); + _mesa_enable_1_3_extensions(c); + _mesa_enable_1_4_extensions(c); + _mesa_enable_1_5_extensions(c); /* you probably have to do a bunch of other initializations here. */ - c->visual = visual; - - ((GLcontext *)c)->Driver.UpdateState = dmesa_update_state; + ((DMesaContext)c)->visual = visual; /* Initialize the software rasterizer and helper modules. */ - _swrast_CreateContext((GLcontext *)c); - _ac_CreateContext((GLcontext *)c); - _tnl_CreateContext((GLcontext *)c); - _swsetup_CreateContext((GLcontext *)c); - if (visual->rgb_flag) dmesa_register_swrast_functions((GLcontext *)c); - dmesa_init_pointers((GLcontext *)c); + _swrast_CreateContext(c); + _ac_CreateContext(c); + _tnl_CreateContext(c); + _swsetup_CreateContext(c); + /* tnl setup */ + tnl = TNL_CONTEXT(c); + tnl->Driver.RunPipeline = _tnl_run_pipeline; + /* swrast setup */ + if (visual->rgb_flag) dmesa_register_swrast_functions(c); + dmesa_init_pointers(c); + _swsetup_Wakeup(c); } - return c; + return (DMesaContext)c; #else /* FX */ return (DMesaContext)visual; @@ -1350,6 +1317,20 @@ void *DMesaGetCurrentContext (void) +void *DMesaGetProcAddress (const char *name) +{ + void *p = (void *)_glapi_get_proc_address(name); + +/* TODO: handle DMesa* namespace + if (p == NULL) { + } +*/ + + return p; +} + + + int DMesaGetIntegerv (GLenum pname, GLint *params) { switch (pname) { diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c index 75629cbd3f..50f783f3b2 100644 --- a/src/mesa/drivers/glide/fxapi.c +++ b/src/mesa/drivers/glide/fxapi.c @@ -42,6 +42,8 @@ #if defined(FX) #include "fxdrv.h" +#include "drivers/common/driverfuncs.h" + #ifndef TDFX_DEBUG int TDFX_DEBUG = (0 /* | VERBOSE_VARRAY */ @@ -653,7 +655,6 @@ fxMesaCreateContext(GLuint win, } _mesa_init_driver_functions(&functions); - ctx->Driver. ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx, &functions, (void *) fxMesa); if (!ctx) { diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c index 6e66f599aa..a07a27bad4 100644 --- a/src/mesa/drivers/glide/fxdd.c +++ b/src/mesa/drivers/glide/fxdd.c @@ -1498,6 +1498,11 @@ fxDDInitExtensions(GLcontext * ctx) if (fxMesa->HaveMirExt) { _mesa_enable_extension(ctx, "GL_ARB_texture_mirrored_repeat"); } + + /* core-level extensions */ +#if 1 + _mesa_enable_extension(ctx, "GL_ARB_vertex_buffer_object"); +#endif } @@ -1666,9 +1671,6 @@ fxSetupDDPointers(GLcontext * ctx) ctx->Driver.Clear = fxDDClear; ctx->Driver.DrawBuffer = fxDDSetDrawBuffer; ctx->Driver.GetBufferSize = fxDDBufferSize; - ctx->Driver.Accum = _swrast_Accum; - ctx->Driver.CopyPixels = _swrast_CopyPixels; - ctx->Driver.DrawPixels = _swrast_DrawPixels; switch (fxMesa->colDepth) { case 15: ctx->Driver.ReadPixels = fxDDReadPixels555; @@ -1684,34 +1686,15 @@ fxSetupDDPointers(GLcontext * ctx) ctx->Driver.Bitmap = fxDDDrawBitmap4; break; } - ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; ctx->Driver.Finish = fxDDFinish; ctx->Driver.Flush = NULL; ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat; - ctx->Driver.TexImage1D = _mesa_store_teximage1d; ctx->Driver.TexImage2D = fxDDTexImage2D; - ctx->Driver.TexImage3D = _mesa_store_teximage3d; - ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d; ctx->Driver.TexSubImage2D = fxDDTexSubImage2D; - ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d; - ctx->Driver.CompressedTexImage1D = _mesa_store_compressed_teximage1d; ctx->Driver.CompressedTexImage2D = fxDDCompressedTexImage2D; - ctx->Driver.CompressedTexImage3D = _mesa_store_compressed_teximage3d; - ctx->Driver.CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d; ctx->Driver.CompressedTexSubImage2D = fxDDCompressedTexSubImage2D; - ctx->Driver.CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d; ctx->Driver.IsCompressedFormat = fxDDIsCompressedFormat; ctx->Driver.CompressedTextureSize = fxDDCompressedTextureSize; - 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.CopyColorTable = _swrast_CopyColorTable; - ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable; - ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D; - ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D; ctx->Driver.TexEnv = fxDDTexEnv; ctx->Driver.TexParameter = fxDDTexParam; ctx->Driver.BindTexture = fxDDTexBind; diff --git a/src/mesa/drivers/glide/fxddtex.c b/src/mesa/drivers/glide/fxddtex.c index 62f4ad15ee..a6a5dc5aa7 100644 --- a/src/mesa/drivers/glide/fxddtex.c +++ b/src/mesa/drivers/glide/fxddtex.c @@ -148,7 +148,6 @@ fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj) tObj->DriverData = fxAllocTexObjData(fxMesa); } ti = fxTMGetTexInfo(tObj); - assert(ti); fxMesa->texBindNumber++; ti->lastTimeUsed = fxMesa->texBindNumber; @@ -203,7 +202,6 @@ fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj, if (!tObj->DriverData) tObj->DriverData = fxAllocTexObjData(fxMesa); ti = fxTMGetTexInfo(tObj); - assert(ti); switch (pname) { case GL_TEXTURE_MIN_FILTER: @@ -482,7 +480,6 @@ fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj) if (!tObj->DriverData) tObj->DriverData = fxAllocTexObjData(fxMesa); ti = fxTMGetTexInfo(tObj); - assert(ti); ti->paltype = convertPalette(fxMesa, ti->palette.data, &tObj->Palette); fxTexInvalidate(ctx, tObj); } @@ -519,7 +516,6 @@ fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state) struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current; if (!tObj->DriverData) tObj->DriverData = fxAllocTexObjData(fxMesa); - assert(tObj->DriverData); fxTexInvalidate(ctx, tObj); } } diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h index 1f31f62160..1b42be8e7b 100644 --- a/src/mesa/drivers/glide/fxdrv.h +++ b/src/mesa/drivers/glide/fxdrv.h @@ -59,8 +59,6 @@ #include "math/m_vector.h" -#include "drivers/common/driverfuncs.h" - /* Define some shorter names for these things. */ diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c index a5165684a3..3b82b570eb 100644 --- a/src/mesa/drivers/glide/fxtris.c +++ b/src/mesa/drivers/glide/fxtris.c @@ -1215,14 +1215,14 @@ static void fxRunPipeline( GLcontext *ctx ) struct gl_texture_unit *t0 = &ctx->Texture.Unit[fxMesa->tmu_source[0]]; struct gl_texture_unit *t1 = &ctx->Texture.Unit[fxMesa->tmu_source[1]]; - if (t0 && t0->_Current && FX_TEXTURE_DATA(t0)) { + if (t0->_Current && FX_TEXTURE_DATA(t0)) { fxMesa->s0scale = FX_TEXTURE_DATA(t0)->sScale; fxMesa->t0scale = FX_TEXTURE_DATA(t0)->tScale; fxMesa->inv_s0scale = 1.0 / fxMesa->s0scale; fxMesa->inv_t0scale = 1.0 / fxMesa->t0scale; } - if (t1 && t1->_Current && FX_TEXTURE_DATA(t1)) { + if (t1->_Current && FX_TEXTURE_DATA(t1)) { fxMesa->s1scale = FX_TEXTURE_DATA(t1)->sScale; fxMesa->t1scale = FX_TEXTURE_DATA(t1)->tScale; fxMesa->inv_s1scale = 1.0 / fxMesa->s1scale; diff --git a/src/mesa/drivers/glide/fxwgl.c b/src/mesa/drivers/glide/fxwgl.c index adf88a485c..ae1d913f3b 100644 --- a/src/mesa/drivers/glide/fxwgl.c +++ b/src/mesa/drivers/glide/fxwgl.c @@ -218,7 +218,6 @@ struct __pixelformat__ pix[] = { FXMESA_NONE} } }; -static int qt_pix = sizeof(pix) / sizeof(pix[0]); static fxMesaContext ctx = NULL; static WNDPROC hWNDOldProc; @@ -676,6 +675,14 @@ wglSwapLayerBuffers(HDC hdc, UINT fuPlanes) return (FALSE); } +static int pfd_tablen (void) +{ + /* we should take an envvar for `fxMesaSelectCurrentBoard' */ + return (fxMesaSelectCurrentBoard(0) < GR_SSTTYPE_Voodoo4) + ? 2 /* only 16bit entries */ + : sizeof(pix) / sizeof(pix[0]); /* full table */ +} + GLAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR * ppfd) { @@ -723,7 +730,7 @@ wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR * ppfd) } #endif - qt_valid_pix = qt_pix; + qt_valid_pix = pfd_tablen(); if (ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) { SetLastError(0); @@ -787,7 +794,7 @@ wglDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, { int qt_valid_pix; - qt_valid_pix = qt_pix; + qt_valid_pix = pfd_tablen(); if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix || ((nBytes != sizeof(PIXELFORMATDESCRIPTOR)) && (nBytes != 0))) { @@ -830,7 +837,7 @@ wglSetPixelFormat(HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR * ppfd) { int qt_valid_pix; - qt_valid_pix = qt_pix; + qt_valid_pix = pfd_tablen(); if (iPixelFormat < 1 || iPixelFormat > qt_valid_pix) { if (ppfd == NULL) { -- cgit v1.2.3