📄 radeon_screen.c
字号:
/* $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 VA Linux Systems Inc., Fremont, California.All Rights Reserved.Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice (including thenext paragraph) shall be included in all copies or substantialportions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BELIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIONOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIONWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************//** * \file radeon_screen.c * Screen initialization functions for the Radeon driver. * * \author Kevin E. Martin <martin@valinux.com> * \author Gareth Hughes <gareth@valinux.com> */#include "glheader.h"#include "imports.h"#include "mtypes.h"#include "framebuffer.h"#include "renderbuffer.h"#define STANDALONE_MMIO#include "radeon_chipset.h"#include "radeon_macros.h"#include "radeon_screen.h"#if !RADEON_COMMON#include "radeon_context.h"#include "radeon_span.h"#include "radeon_tex.h"#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)#include "r200_context.h"#include "r200_ioctl.h"#include "r200_span.h"#include "r200_tex.h"#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)#include "r300_context.h"#include "r300_fragprog.h"#include "r300_tex.h"#include "radeon_span.h"#endif#include "utils.h"#include "context.h"#include "vblank.h"#include "drirenderbuffer.h"#include "GL/internal/dri_interface.h"/* Radeon configuration */#include "xmlpool.h"#if !RADEON_COMMON /* R100 */PUBLIC 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_MAX_TEXTURE_UNITS(3,2,3) DRI_CONF_HYPERZ(false) DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0") DRI_CONF_NO_NEG_LOD_BIAS(false) DRI_CONF_FORCE_S3TC_ENABLE(false) DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC) DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF) DRI_CONF_ALLOW_LARGE_TEXTURES(2) DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG DRI_CONF_NO_RAST(false) DRI_CONF_SECTION_ENDDRI_CONF_END;static const GLuint __driNConfigOptions = 14;#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)PUBLIC 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_MAX_TEXTURE_UNITS(6,2,6) DRI_CONF_HYPERZ(false) DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0") DRI_CONF_NO_NEG_LOD_BIAS(false) DRI_CONF_FORCE_S3TC_ENABLE(false) DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC) DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF) DRI_CONF_ALLOW_LARGE_TEXTURES(2) DRI_CONF_TEXTURE_BLEND_QUALITY(1.0,"0.0:1.0") DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG DRI_CONF_NO_RAST(false) DRI_CONF_SECTION_END DRI_CONF_SECTION_SOFTWARE DRI_CONF_NV_VERTEX_PROGRAM(false) DRI_CONF_SECTION_ENDDRI_CONF_END;static const GLuint __driNConfigOptions = 16;extern const struct dri_extension blend_extensions[];extern const struct dri_extension ARB_vp_extension[];extern const struct dri_extension NV_vp_extension[];extern const struct dri_extension ATI_fs_extension[];extern const struct dri_extension point_extensions[];#elif RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)/* TODO: integrate these into xmlpool.h! */#define DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(def,min,max) \DRI_CONF_OPT_BEGIN_V(texture_image_units,int,def, # min ":" # max ) \ DRI_CONF_DESC(en,"Number of texture image units") \ DRI_CONF_DESC(de,"Anzahl der Textureinheiten") \DRI_CONF_OPT_END#define DRI_CONF_MAX_TEXTURE_COORD_UNITS(def,min,max) \DRI_CONF_OPT_BEGIN_V(texture_coord_units,int,def, # min ":" # max ) \ DRI_CONF_DESC(en,"Number of texture coordinate units") \ DRI_CONF_DESC(de,"Anzahl der Texturkoordinateneinheiten") \DRI_CONF_OPT_END#define DRI_CONF_COMMAND_BUFFER_SIZE(def,min,max) \DRI_CONF_OPT_BEGIN_V(command_buffer_size,int,def, # min ":" # max ) \ DRI_CONF_DESC(en,"Size of command buffer (in KB)") \ DRI_CONF_DESC(de,"Grösse des Befehlspuffers (in KB)") \DRI_CONF_OPT_END#define DRI_CONF_DISABLE_S3TC(def) \DRI_CONF_OPT_BEGIN(disable_s3tc,bool,def) \ DRI_CONF_DESC(en,"Disable S3TC compression") \DRI_CONF_OPT_END#define DRI_CONF_DISABLE_FALLBACK(def) \DRI_CONF_OPT_BEGIN(disable_lowimpact_fallback,bool,def) \ DRI_CONF_DESC(en,"Disable Low-impact fallback") \DRI_CONF_OPT_END#define DRI_CONF_DISABLE_DOUBLE_SIDE_STENCIL(def) \DRI_CONF_OPT_BEGIN(disable_stencil_two_side,bool,def) \ DRI_CONF_DESC(en,"Disable GL_EXT_stencil_two_side") \DRI_CONF_OPT_END#define DRI_CONF_FP_OPTIMIZATION(def) \DRI_CONF_OPT_BEGIN_V(fp_optimization,enum,def,"0:1") \ DRI_CONF_DESC_BEGIN(en,"Fragment Program optimization") \ DRI_CONF_ENUM(0,"Optimize for Speed") \ DRI_CONF_ENUM(1,"Optimize for Quality") \ DRI_CONF_DESC_END \DRI_CONF_OPT_ENDPUBLIC 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_MAX_TEXTURE_IMAGE_UNITS(8, 2, 8) DRI_CONF_MAX_TEXTURE_COORD_UNITS(8, 2, 8) DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32) DRI_CONF_DISABLE_FALLBACK(true) DRI_CONF_DISABLE_DOUBLE_SIDE_STENCIL(false) DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) DRI_CONF_DEF_MAX_ANISOTROPY(1.0, "1.0,2.0,4.0,8.0,16.0") DRI_CONF_FORCE_S3TC_ENABLE(false) DRI_CONF_DISABLE_S3TC(false) DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC) DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF) DRI_CONF_FP_OPTIMIZATION(DRI_CONF_FP_OPTIMIZATION_SPEED) DRI_CONF_SECTION_END DRI_CONF_SECTION_DEBUG DRI_CONF_NO_RAST(false) DRI_CONF_SECTION_ENDDRI_CONF_END;static const GLuint __driNConfigOptions = 17;#ifndef RADEON_DEBUGint RADEON_DEBUG = 0;static const struct dri_debug_control debug_control[] = { {"fall", DEBUG_FALLBACKS}, {"tex", DEBUG_TEXTURE}, {"ioctl", DEBUG_IOCTL}, {"prim", DEBUG_PRIMS}, {"vert", DEBUG_VERTS}, {"state", DEBUG_STATE}, {"code", DEBUG_CODEGEN}, {"vfmt", DEBUG_VFMT}, {"vtxf", DEBUG_VFMT}, {"verb", DEBUG_VERBOSE}, {"dri", DEBUG_DRI}, {"dma", DEBUG_DMA}, {"san", DEBUG_SANITY}, {"sync", DEBUG_SYNC}, {"pix", DEBUG_PIXEL}, {"mem", DEBUG_MEMORY}, {"allmsg", ~DEBUG_SYNC}, /* avoid the term "sync" because the parser uses strstr */ {NULL, 0}};#endif /* RADEON_DEBUG */#endif /* RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) */extern const struct dri_extension card_extensions[];static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );static intradeonGetParam(int fd, int param, void *value){ int ret; drm_radeon_getparam_t gp; gp.param = param; gp.value = value; ret = drmCommandWriteRead( fd, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); return ret;}static const __DRIconfig **radeonFillInModes( __DRIscreenPrivate *psp, unsigned pixel_bits, unsigned depth_bits, unsigned stencil_bits, GLboolean have_back_buffer ){ __DRIconfig **configs; __GLcontextModes *m; unsigned depth_buffer_factor; unsigned back_buffer_factor; GLenum fb_format; GLenum fb_type; int i; /* 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. */ static const GLenum back_buffer_modes[] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ }; u_int8_t depth_bits_array[2]; u_int8_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; if ( pixel_bits == 16 ) { fb_format = GL_RGB; fb_type = GL_UNSIGNED_SHORT_5_6_5; } else { fb_format = GL_BGRA; fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; } configs = driCreateConfigs(fb_format, fb_type, depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, back_buffer_factor); if (configs == NULL) { fprintf( stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__ ); return NULL; } /* Mark the visual as slow if there are "fake" stencil bits. */ for (i = 0; configs[i]; i++) { m = &configs[i]->modes; if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { m->visualRating = GLX_SLOW_CONFIG; } } return (const __DRIconfig **) configs;}#if !RADEON_COMMONstatic const __DRItexOffsetExtension radeonTexOffsetExtension = { { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION }, radeonSetTexOffset,};#endif#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)static const __DRIallocateExtension r200AllocateExtension = { { __DRI_ALLOCATE, __DRI_ALLOCATE_VERSION }, r200AllocateMemoryMESA, r200FreeMemoryMESA, r200GetMemoryOffsetMESA};static const __DRItexOffsetExtension r200texOffsetExtension = { { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION }, r200SetTexOffset,};#endif#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R300)static const __DRItexOffsetExtension r300texOffsetExtension = { { __DRI_TEX_OFFSET, __DRI_TEX_OFFSET_VERSION }, r300SetTexOffset,};#endif/* Create the device specific screen private data struct. */static radeonScreenPtrradeonCreateScreen( __DRIscreenPrivate *sPriv ){ radeonScreenPtr screen; RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv; unsigned char *RADEONMMIO; int i; int ret; uint32_t temp; if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) { fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n"); return GL_FALSE; } /* Allocate the private area */ screen = (radeonScreenPtr) CALLOC( sizeof(*screen) ); if ( !screen ) { __driUtilMessage("%s: Could not allocate memory for screen structure", __FUNCTION__); return NULL; }#if DO_DEBUG && RADEON_COMMON && defined(RADEON_COMMON_FOR_R300) RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);#endif /* parse information in __driConfigOptions */ driParseOptionInfo (&screen->optionCache, __driConfigOptions, __driNConfigOptions); /* This is first since which regions we map depends on whether or * not we are using a PCI card. */ screen->card_type = (dri_priv->IsPCI ? RADEON_CARD_PCI : RADEON_CARD_AGP); { int ret; ret = radeonGetParam( sPriv->fd, RADEON_PARAM_GART_BUFFER_OFFSET, &screen->gart_buffer_offset); if (ret) { FREE( screen ); fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret); return NULL; } ret = radeonGetParam( sPriv->fd, RADEON_PARAM_GART_BASE, &screen->gart_base); if (ret) { FREE( screen ); fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BASE): %d\n", ret); return NULL; } ret = radeonGetParam( sPriv->fd, RADEON_PARAM_IRQ_NR, &screen->irq); if (ret) { FREE( screen ); fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret); return NULL; } screen->drmSupportsCubeMapsR200 = (sPriv->drm_version.minor >= 7); screen->drmSupportsBlendColor = (sPriv->drm_version.minor >= 11); screen->drmSupportsTriPerf = (sPriv->drm_version.minor >= 16); screen->drmSupportsFragShader = (sPriv->drm_version.minor >= 18); screen->drmSupportsPointSprites = (sPriv->drm_version.minor >= 13); screen->drmSupportsCubeMapsR100 = (sPriv->drm_version.minor >= 15); screen->drmSupportsVertexProgram = (sPriv->drm_version.minor >= 25); } screen->mmio.handle = dri_priv->registerHandle; screen->mmio.size = dri_priv->registerSize;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -