📄 atidri.c
字号:
/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- *//* * Copyright 2000 Gareth Hughes * 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, 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL * GARETH HUGHES 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. */#ifdef HAVE_CONFIG_H#include "config.h"#endif/* * Authors: * Gareth Hughes <gareth@valinux.com> * Leif Delgass <ldelgass@retinalburn.net> */#include <string.h>#include <stdio.h>#include <unistd.h>/* Driver data structures */#include "ati.h"#include "atibus.h"#include "atidri.h"#include "atiregs.h"#include "atistruct.h"#include "ativersion.h"#include "atimach64io.h"#include "mach64_dri.h"#include "mach64_common.h"#include "mach64_sarea.h"/* X and server generic header files */#include "xf86.h"#include "windowstr.h"/* GLX/DRI/DRM definitions */#define _XF86DRI_SERVER_#include "GL/glxtokens.h"#include "sarea.h"static char ATIKernelDriverName[] = "mach64";static char ATIClientDriverName[] = "mach64";/* Initialize the visual configs that are supported by the hardware. * These are combined with the visual configs that the indirect * rendering core supports, and the intersection is exported to the * client. */static Bool ATIInitVisualConfigs( ScreenPtr pScreen ){ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); int numConfigs = 0; __GLXvisualConfig *pConfigs = NULL; ATIConfigPrivPtr pATIConfigs = NULL; ATIConfigPrivPtr *pATIConfigPtrs = NULL; int i, accum, stencil, db; switch ( pATI->bitsPerPixel ) { case 8: /* 8bpp mode is not support */ case 15: /* FIXME */ case 24: /* FIXME */ xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] ATIInitVisualConfigs failed (%d bpp not supported). " "Disabling DRI.\n", pATI->bitsPerPixel); return FALSE;#define ATI_USE_ACCUM 1#define ATI_USE_STENCIL 1 case 16: if ( pATI->depth != 16) { xf86DrvMsg(pScreen->myNum, X_ERROR, "[dri] ATIInitVisualConfigs failed (depth %d at 16 bpp not supported). " "Disabling DRI.\n", pATI->depth); return FALSE; } numConfigs = 1; if ( ATI_USE_ACCUM ) numConfigs *= 2; if ( ATI_USE_STENCIL ) numConfigs *= 2; numConfigs *= 2; /* single- and double-buffered */ pConfigs = (__GLXvisualConfig*) xnfcalloc( sizeof(__GLXvisualConfig), numConfigs ); if ( !pConfigs ) { return FALSE; } pATIConfigs = (ATIConfigPrivPtr) xnfcalloc( sizeof(ATIConfigPrivRec), numConfigs ); if ( !pATIConfigs ) { xfree( pConfigs ); return FALSE; } pATIConfigPtrs = (ATIConfigPrivPtr*) xnfcalloc( sizeof(ATIConfigPrivPtr), numConfigs ); if ( !pATIConfigPtrs ) { xfree( pConfigs ); xfree( pATIConfigs ); return FALSE; } i = 0; for (db = 0; db <= 1; db++) { for ( accum = 0 ; accum <= ATI_USE_ACCUM ; accum++ ) { for ( stencil = 0 ; stencil <= ATI_USE_STENCIL ; stencil++ ) { pATIConfigPtrs[i] = &pATIConfigs[i]; pConfigs[i].vid = -1; pConfigs[i].class = -1; pConfigs[i].rgba = TRUE; pConfigs[i].redSize = 5; pConfigs[i].greenSize = 6; pConfigs[i].blueSize = 5; pConfigs[i].alphaSize = 0; pConfigs[i].redMask = 0x0000F800; pConfigs[i].greenMask = 0x000007E0; pConfigs[i].blueMask = 0x0000001F; pConfigs[i].alphaMask = 0x00000000; if ( accum ) { /* Simulated in software */ pConfigs[i].accumRedSize = 16; pConfigs[i].accumGreenSize = 16; pConfigs[i].accumBlueSize = 16; pConfigs[i].accumAlphaSize = 0; } else { pConfigs[i].accumRedSize = 0; pConfigs[i].accumGreenSize = 0; pConfigs[i].accumBlueSize = 0; pConfigs[i].accumAlphaSize = 0; } pConfigs[i].doubleBuffer = db ? TRUE : FALSE; pConfigs[i].stereo = FALSE; pConfigs[i].bufferSize = 16; pConfigs[i].depthSize = 16; if ( stencil ) { /* Simulated in software */ pConfigs[i].stencilSize = 8; } else { pConfigs[i].stencilSize = 0; } pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; if ( accum || stencil ) { pConfigs[i].visualRating = GLX_SLOW_CONFIG; } else { pConfigs[i].visualRating = GLX_NONE; } pConfigs[i].transparentPixel = GLX_NONE; pConfigs[i].transparentRed = 0; pConfigs[i].transparentGreen = 0; pConfigs[i].transparentBlue = 0; pConfigs[i].transparentAlpha = 0; pConfigs[i].transparentIndex = 0; i++; } } } break; case 32: numConfigs = 1; if ( ATI_USE_ACCUM ) numConfigs *= 2; if ( ATI_USE_STENCIL ) numConfigs *= 2; numConfigs *= 2; /* single- and double-buffered */ pConfigs = (__GLXvisualConfig*) xnfcalloc( sizeof(__GLXvisualConfig), numConfigs ); if ( !pConfigs ) { return FALSE; } pATIConfigs = (ATIConfigPrivPtr) xnfcalloc( sizeof(ATIConfigPrivRec), numConfigs ); if ( !pATIConfigs ) { xfree( pConfigs ); return FALSE; } pATIConfigPtrs = (ATIConfigPrivPtr*) xnfcalloc( sizeof(ATIConfigPrivPtr), numConfigs ); if ( !pATIConfigPtrs ) { xfree( pConfigs ); xfree( pATIConfigs ); return FALSE; } i = 0; for (db = 0; db <= 1; db++) { for ( accum = 0 ; accum <= ATI_USE_ACCUM ; accum++ ) { for ( stencil = 0 ; stencil <= ATI_USE_STENCIL ; stencil++ ) { pATIConfigPtrs[i] = &pATIConfigs[i]; pConfigs[i].vid = -1; pConfigs[i].class = -1; pConfigs[i].rgba = TRUE; pConfigs[i].redSize = 8; pConfigs[i].greenSize = 8; pConfigs[i].blueSize = 8; pConfigs[i].alphaSize = 0; pConfigs[i].redMask = 0x00FF0000; pConfigs[i].greenMask = 0x0000FF00; pConfigs[i].blueMask = 0x000000FF; pConfigs[i].alphaMask = 0x00000000; if ( accum ) { /* Simulated in software */ pConfigs[i].accumRedSize = 16; pConfigs[i].accumGreenSize = 16; pConfigs[i].accumBlueSize = 16; pConfigs[i].accumAlphaSize = 0; } else { pConfigs[i].accumRedSize = 0; pConfigs[i].accumGreenSize = 0; pConfigs[i].accumBlueSize = 0; pConfigs[i].accumAlphaSize = 0; } pConfigs[i].doubleBuffer = db ? TRUE : FALSE; pConfigs[i].stereo = FALSE; pConfigs[i].bufferSize = 24; if ( stencil ) { /* Simulated in software */ pConfigs[i].depthSize = 16; pConfigs[i].stencilSize = 8; } else { pConfigs[i].depthSize = 16; pConfigs[i].stencilSize = 0; } pConfigs[i].auxBuffers = 0; pConfigs[i].level = 0; if ( accum || stencil ) { pConfigs[i].visualRating = GLX_SLOW_CONFIG; } else { pConfigs[i].visualRating = GLX_NONE; } pConfigs[i].transparentPixel = GLX_NONE; pConfigs[i].transparentRed = 0; pConfigs[i].transparentGreen = 0; pConfigs[i].transparentBlue = 0; pConfigs[i].transparentAlpha = 0; pConfigs[i].transparentIndex = 0; i++; } } } break; } pATI->numVisualConfigs = numConfigs; pATI->pVisualConfigs = pConfigs; pATI->pVisualConfigsPriv = pATIConfigs; GlxSetVisualConfigs( numConfigs, pConfigs, (void**)pATIConfigPtrs ); return TRUE;}/* Create the ATI-specific context information */static Bool ATICreateContext( ScreenPtr pScreen, VisualPtr visual, drm_context_t hwContext, void *pVisualConfigPriv, DRIContextType contextStore ){ /* Nothing yet */ return TRUE;}/* Destroy the ATI-specific context information */static void ATIDestroyContext( ScreenPtr pScreen, drm_context_t hwContext, DRIContextType contextStore ){ /* Nothing yet */}/* Called when the X server is woken up to allow the last client's * context to be saved and the X server's context to be loaded. * The client detects when it's context is not currently loaded and * then loads it itself. The X server's context is loaded in the * XAA Sync callback if NeedDRISync is set. */static void ATIEnterServer( ScreenPtr pScreen ){ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); if ( pATI->directRenderingEnabled ) { ATIDRIMarkSyncInt(pScreenInfo); ATIDRIMarkSyncExt(pScreenInfo); }}/* Called when the X server goes to sleep to allow the X server's * context to be saved and the last client's context to be loaded. * The client detects when it's context is not currently loaded and * then loads it itself. The X server keeps track of it's own state. */static void ATILeaveServer( ScreenPtr pScreen ){ /* Nothing yet */}/* Contexts can be swapped by the X server if necessary. This callback * is currently only used to perform any functions necessary when * entering or leaving the X server, and in the future might not be * necessary. */static void ATIDRISwapContext( ScreenPtr pScreen, DRISyncType syncType, DRIContextType oldContextType, void *oldContext, DRIContextType newContextType, void *newContext ){ if ( ( syncType == DRI_3D_SYNC ) && ( oldContextType == DRI_2D_CONTEXT ) && ( newContextType == DRI_2D_CONTEXT ) ) { /* Entering from Wakeup */ ATIEnterServer( pScreen ); } if ( ( syncType == DRI_2D_SYNC ) && ( oldContextType == DRI_NO_CONTEXT ) && ( newContextType == DRI_2D_CONTEXT ) ) { /* Exiting from Block Handler */ ATILeaveServer( pScreen ); }}#ifdef USE_XAAstatic void ATIDRITransitionTo2d(ScreenPtr pScreen){ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); if (pATI->backArea) { xf86FreeOffscreenArea(pATI->backArea); pATI->backArea = NULL; } if (pATI->depthTexArea) { xf86FreeOffscreenArea(pATI->depthTexArea); pATI->depthTexArea = NULL; } pATI->have3DWindows = FALSE;}static void ATIDRITransitionTo3d(ScreenPtr pScreen){ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); FBAreaPtr fbArea; int width, height; xf86PurgeUnlockedOffscreenAreas(pScreen); xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0); xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, "Largest offscreen area available: %d x %d\n", width, height); fbArea = xf86AllocateOffscreenArea(pScreen, pScreenInfo->displayWidth, height - pATI->depthTexLines - pATI->backLines, pScreenInfo->displayWidth, NULL, NULL, NULL); if (!fbArea) xf86DrvMsg(pScreen->myNum, X_ERROR, "Unable to reserve placeholder " "offscreen area, you might experience screen corruption\n"); if (!pATI->backArea) { pATI->backArea = xf86AllocateOffscreenArea(pScreen, pScreenInfo->displayWidth, pATI->backLines, pScreenInfo->displayWidth, NULL, NULL, NULL); } if (!pATI->backArea) xf86DrvMsg(pScreen->myNum, X_ERROR, "Unable to reserve offscreen area " "for back buffer, you might experience screen corruption\n"); if (!pATI->depthTexArea) { pATI->depthTexArea = xf86AllocateOffscreenArea(pScreen, pScreenInfo->displayWidth, pATI->depthTexLines, pScreenInfo->displayWidth, NULL, NULL, NULL); } if (!pATI->depthTexArea) xf86DrvMsg(pScreen->myNum, X_ERROR, "Unable to reserve offscreen area " "for depth buffer and textures, you might experience screen corruption\n"); if (fbArea) xf86FreeOffscreenArea(fbArea);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -