From: Felix Kuehling Date: Sun, 22 Aug 2004 20:31:40 +0000 (+0000) Subject: Converted the Savage driver to the new DRI interface and enabled compilation X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c2530b573076fe0b257710a456a2b8cd714c0d0a;p=mesa.git Converted the Savage driver to the new DRI interface and enabled compilation in the Mesa tree. --- diff --git a/configs/linux-dri b/configs/linux-dri index 2386906db3d..10b318c9eb1 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -30,8 +30,8 @@ DRIVER_DIRS = dri PROGRAM_DIRS = WINDOW_SYSTEM=dri -# Savage is missing. ffb, gamma, and sis are also missing because they have +# ffb, gamma, and sis are missing because they have # not be converted to use the new interface. # -DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon tdfx unichrome +DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon tdfx unichrome savage diff --git a/configs/linux-dri-x86 b/configs/linux-dri-x86 index dc03769a504..83dbe4d9bcc 100644 --- a/configs/linux-dri-x86 +++ b/configs/linux-dri-x86 @@ -28,8 +28,8 @@ DRIVER_DIRS = dri PROGRAM_DIRS = WINDOW_SYSTEM=dri -# Savage is missing. ffb, gamma, and sis are also missing because they have +# ffb, gamma, and sis are missing because they have # not be converted to use the new interface. # -DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon tdfx unichrome +DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon tdfx unichrome savage diff --git a/configs/linux-dri-x86-64 b/configs/linux-dri-x86-64 index 6db0530c75c..dbb3d84d2d5 100644 --- a/configs/linux-dri-x86-64 +++ b/configs/linux-dri-x86-64 @@ -28,9 +28,9 @@ DRIVER_DIRS = dri PROGRAM_DIRS = WINDOW_SYSTEM=dri -# Savage is missing. ffb, gamma, and sis are also missing because they have +# ffb, gamma, and sis are missing because they have # not be converted to use the new interface. Do i810 & i830 really # need to be included here? # -DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon tdfx unichrome +DRI_DIRS = dri_client i810 i830 i915 mach64 mga r128 r200 radeon tdfx unichrome savage diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index fa1bc2993fb..75c62af0f78 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -37,6 +37,7 @@ SHARED_INCLUDES = \ -I$(TOP)/src/mesa/drivers/dri/common \ -Iserver \ -I$(DRM_SOURCE_PATH)/shared \ + -I$(DRM_SOURCE_PATH)/linux \ -I$(TOP)/include \ -I$(TOP)/include/GL/internal \ -I$(TOP)/src/mesa \ diff --git a/src/mesa/drivers/dri/savage/Makefile b/src/mesa/drivers/dri/savage/Makefile new file mode 100644 index 00000000000..d662cb06d8d --- /dev/null +++ b/src/mesa/drivers/dri/savage/Makefile @@ -0,0 +1,40 @@ +# src/mesa/drivers/dri/r128/Makefile + +TOP = ../../../../.. +include $(TOP)/configs/current + +LIBNAME = savage_dri.so + +# Doesn't exist yet. +#MINIGLX_SOURCES = server/savage_dri.c + +COMMON_SOURCES = \ + ../../common/driverfuncs.c \ + ../common/mm.c \ + ../common/utils.c \ + ../common/texmem.c \ + ../common/vblank.c \ + ../common/xmlconfig.c \ + ../common/dri_util.c \ + ../common/glcontextmodes.c + +DRIVER_SOURCES = \ + savage_xmesa.c \ + savagedd.c \ + savagestate.c \ + savagetex.c \ + savagetris.c \ + savageioctl.c \ + savagespan.c \ + savagedma.c + +C_SOURCES = \ + $(COMMON_SOURCES) \ + $(DRIVER_SOURCES) + +ASM_SOURCES = + + +include ../Makefile.template + +symlinks: diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c index c6163ff5984..f1fd5eacf0b 100644 --- a/src/mesa/drivers/dri/savage/savage_xmesa.c +++ b/src/mesa/drivers/dri/savage/savage_xmesa.c @@ -34,6 +34,8 @@ #include "simple_list.h" +#include "utils.h" + #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" #include "tnl/tnl.h" @@ -55,6 +57,10 @@ #include "savagedma.h" +#ifdef USE_NEW_INTERFACE +static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; +#endif /* USE_NEW_INTERFACE */ + #ifndef SAVAGE_DEBUG int SAVAGE_DEBUG = (0 /* | DEBUG_ALWAYS_SYNC */ @@ -88,31 +94,6 @@ savageInitDriver(__DRIscreenPrivate *sPriv) SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv; - /* Check the DRI version */ - { - int major, minor, patch; - if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { - if (major != 4 || minor < 0) { - __driUtilMessage("savage DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch); - return GL_FALSE; - } - } - } - - /* Check that the DDX driver version is compatible */ - if (sPriv->ddxMajor != 1 || - sPriv->ddxMinor < 0) { - __driUtilMessage("savage DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); - return GL_FALSE; - } - - /* Check that the DRM driver version is compatible */ - if (sPriv->drmMajor != 1 || - sPriv->drmMinor < 0) { - __driUtilMessage("savage DRI driver expected DRM driver version 1.1.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); - return GL_FALSE; - } - /* Allocate the private area */ savageScreen = (savageScreenPrivate *)Xmalloc(sizeof(savageScreenPrivate)); if (!savageScreen) @@ -813,8 +794,9 @@ static const struct __DriverAPIRec savageAPI = { +#ifndef DRI_NEW_INTERFACE_ONLY /* - * This is the bootstrap function for the driver. + * This is the (old) bootstrap function for the driver. * The __driCreateScreen name is the symbol that libGL.so fetches. * Return: pointer to a __DRIscreenPrivate. */ @@ -825,6 +807,147 @@ void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &savageAPI); return (void *) psp; } +#endif /* DRI_NEW_INTERFACE_ONLY */ + + + +#ifdef USE_NEW_INTERFACE +static __GLcontextModes * +savageFillInModes( unsigned pixel_bits, unsigned depth_bits, + unsigned stencil_bits, GLboolean have_back_buffer ) +{ + __GLcontextModes * modes; + __GLcontextModes * m; + unsigned num_modes; + unsigned depth_buffer_factor; + unsigned back_buffer_factor; + GLenum fb_format; + GLenum fb_type; + + /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy + * enough to add support. Basically, if a context is created with an + * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping + * will never be used. + * + * FK: What about drivers that don't use page flipping? Could they + * just expose GLX_SWAP_COPY_OML? + */ + static const GLenum back_buffer_modes[] = { + GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ + }; + + uint8_t depth_bits_array[2]; + uint8_t stencil_bits_array[2]; + + + depth_bits_array[0] = depth_bits; + depth_bits_array[1] = depth_bits; + + /* Just like with the accumulation buffer, always provide some modes + * with a stencil buffer. It will be a sw fallback, but some apps won't + * care about that. + */ + stencil_bits_array[0] = 0; + stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; + + depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; + back_buffer_factor = (have_back_buffer) ? 2 : 1; + + num_modes = depth_buffer_factor * back_buffer_factor * 4; + + if ( pixel_bits == 16 ) { + fb_format = GL_RGB; + fb_type = GL_UNSIGNED_SHORT_5_6_5; + } + else { + fb_format = GL_BGR; + fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; + } + + modes = (*create_context_modes)( num_modes, sizeof( __GLcontextModes ) ); + m = modes; + if ( ! driFillInModes( & m, fb_format, fb_type, + depth_bits_array, stencil_bits_array, depth_buffer_factor, + back_buffer_modes, back_buffer_factor, + GLX_TRUE_COLOR ) ) { + fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", + __func__, __LINE__ ); + return NULL; + } + + if ( ! driFillInModes( & m, fb_format, fb_type, + depth_bits_array, stencil_bits_array, depth_buffer_factor, + back_buffer_modes, back_buffer_factor, + GLX_DIRECT_COLOR ) ) { + fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", + __func__, __LINE__ ); + return NULL; + } + + /* Mark the visual as slow if there are "fake" stencil bits. + */ + for ( m = modes ; m != NULL ; m = m->next ) { + if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) { + m->visualRating = GLX_SLOW_CONFIG; + } + } + + return modes; +} + + +/** + * This is the bootstrap function for the driver. libGL supplies all of the + * requisite information about the system, and the driver initializes itself. + * This routine also fills in the linked list pointed to by \c driver_modes + * with the \c __GLcontextModes that the driver can support for windows or + * pbuffers. + * + * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on + * failure. + */ +void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, + const __GLcontextModes * modes, + const __DRIversion * ddx_version, + const __DRIversion * dri_version, + const __DRIversion * drm_version, + const __DRIframebuffer * frame_buffer, + drmAddress pSAREA, int fd, + int internal_api_version, + __GLcontextModes ** driver_modes ) + +{ + __DRIscreenPrivate *psp; + static const __DRIversion ddx_expected = { 1, 0, 0 }; + static const __DRIversion dri_expected = { 4, 0, 0 }; + static const __DRIversion drm_expected = { 1, 0, 0 }; + + if ( ! driCheckDriDdxDrmVersions2( "Savage", + dri_version, & dri_expected, + ddx_version, & ddx_expected, + drm_version, & drm_expected ) ) { + return NULL; + } + + psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL, + ddx_version, dri_version, drm_version, + frame_buffer, pSAREA, fd, + internal_api_version, &savageAPI); + if ( psp != NULL ) { + create_context_modes = (PFNGLXCREATECONTEXTMODES) + glXGetProcAddress( (const GLubyte *) "__glXCreateContextModes" ); + if ( create_context_modes != NULL ) { + SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv; + *driver_modes = savageFillInModes( dri_priv->cpp*8, + (dri_priv->cpp == 2) ? 16 : 24, + (dri_priv->cpp == 2) ? 0 : 8, + (dri_priv->backOffset != dri_priv->depthOffset) ); + } + } + + return (void *) psp; +} +#endif /* USE_NEW_INTERFACE */ #endif diff --git a/src/mesa/drivers/dri/savage/savagecontext.h b/src/mesa/drivers/dri/savage/savagecontext.h index a50d6b0518d..370bceb7531 100644 --- a/src/mesa/drivers/dri/savage/savagecontext.h +++ b/src/mesa/drivers/dri/savage/savagecontext.h @@ -37,7 +37,6 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr; #include "xf86drm.h" #include "drm.h" #include "savage_drm.h" -#include "savage_sarea.h" #include "savage_init.h" #include "mm.h" #include "tnl/t_vertex.h" @@ -237,7 +236,7 @@ struct savage_context_t { unsigned int texAge[SAVAGE_NR_TEX_HEAPS]; drm_context_t hHWContext; - drmLock *driHwLock; + drm_hw_lock_t *driHwLock; GLuint driFd; __DRIdrawablePrivate *driDrawable; diff --git a/src/mesa/drivers/dri/savage/server/savage_dri.h b/src/mesa/drivers/dri/savage/server/savage_dri.h new file mode 100644 index 00000000000..af62e761c43 --- /dev/null +++ b/src/mesa/drivers/dri/savage/server/savage_dri.h @@ -0,0 +1,184 @@ +/* + * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved. + * Copyright 2001-2003 S3 Graphics, Inc. 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sub license, + * 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 (including the + * next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS 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. + */ + + +#ifndef __SAVAGE_DRI_H__ +#define __SAVAGE_DRI_H__ + +#include "xf86drm.h" +#include "drm.h" + +#define SAVAGE_DEFAULT_AGP_MODE 1 +#define SAVAGE_MAX_AGP_MODE 4 + +/* Buffer are aligned on 4096 byte boundaries. + */ +/* this is used for backbuffer, depthbuffer, etc..*/ +/* alignment */ + +#define SAVAGE_BUFFER_ALIGN 0x00000fff + +typedef struct{ + drm_context_t ctxOwner; + unsigned long agp_offset; + unsigned long agp_handle; + unsigned long map_handle; + int flags; +} savageAgpBuffer , *savageAgpBufferPtr; + +typedef struct _server{ + int reserved_map_agpstart; + int reserved_map_idx; + +#if 0 + int buffer_map_idx; +#endif + + int sarea_priv_offset; + +#if 0 + int primary_size; + int warp_ucode_size; +#endif + + int chipset; + int sgram; /* seems no use */ + + unsigned int frontOffset; + unsigned int frontPitch; + unsigned int frontbufferSize; + + unsigned int backOffset; + unsigned int backPitch; + unsigned int backbufferSize; + + unsigned int depthOffset; + unsigned int depthPitch; + unsigned int depthbufferSize; + + unsigned int textureOffset; + int textureSize; + int logTextureGranularity; + + drmRegion agp; + + /* PCI mappings */ + drmRegion aperture; + drmRegion registers; + drmRegion status; + + /* AGP mappings */ +#if 0 + drmRegion warp; + drmRegion primary; + drmRegion buffers; +#endif + + drmRegion agpTextures; + int logAgpTextureGranularity; + +#if 0 + drmBufMapPtr drmBuffers; +#endif + /*for agp*/ + int numBuffer; + savageAgpBufferPtr agpBuffer; +} SAVAGEDRIServerPrivateRec, *SAVAGEDRIServerPrivatePtr; + +typedef struct { + int chipset; + int width; + int height; + int mem; + int cpp; + int zpp; + + int agpMode; + + drm_handle_t frontbuffer; + unsigned int frontbufferSize; + unsigned int frontOffset; + unsigned int frontPitch; + unsigned int frontBitmapDesc; /*Bitmap Descriptior*/ + unsigned int IsfrontTiled; + + drm_handle_t backbuffer; + unsigned int backbufferSize; + unsigned int backOffset; + unsigned int backPitch; + unsigned int backBitmapDesc; /*Bitmap Descriptior*/ + + drm_handle_t depthbuffer; + unsigned int depthbufferSize; + unsigned int depthOffset; + unsigned int depthPitch; + unsigned int depthBitmapDesc; /*Bitmap Descriptior*/ + + + + drm_handle_t textures; + drm_handle_t xvmcSurfHandle; + unsigned int textureOffset; + unsigned int textureSize; + int logTextureGranularity; + + /* Allow calculation of setup dma addresses. + */ + unsigned int agpBufferOffset; + + unsigned int agpTextureOffset; + unsigned int agpTextureSize; + drmRegion agpTextures; + int logAgpTextureGranularity; + +/* unsigned int mAccess;*/ + + drmRegion aperture; + unsigned int aperturePitch; /* in byte */ + + + drmRegion registers; + drmRegion BCIcmdBuf; + drmRegion status; + +#if 0 + drmRegion primary; + drmRegion buffers; +#endif + /*For shadow status*/ + unsigned long sareaPhysAddr; + + unsigned int sarea_priv_offset; + int shadowStatus; +} SAVAGEDRIRec, *SAVAGEDRIPtr; + +#endif + + + + + + + +