📄 i810context.c
字号:
/**************************************************************************Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.All Rights Reserved.Permission is hereby granted, free of charge, to any person obtaining acopy 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, sub license, 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 substantial portionsof the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FORANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************//* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810context.c,v 1.3 2002/10/30 12:51:33 alanh Exp $ *//* * Authors: * Keith Whitwell <keith@tungstengraphics.com> * */#include "glheader.h"#include "context.h"#include "matrix.h"#include "simple_list.h"#include "extensions.h"#include "framebuffer.h"#include "imports.h"#include "points.h"#include "swrast/swrast.h"#include "swrast_setup/swrast_setup.h"#include "tnl/tnl.h"#include "vbo/vbo.h"#include "tnl/t_pipeline.h"#include "drivers/common/driverfuncs.h"#include "i810screen.h"#include "i810_dri.h"#include "i810state.h"#include "i810tex.h"#include "i810span.h"#include "i810tris.h"#include "i810vb.h"#include "i810ioctl.h"#include "drirenderbuffer.h"#include "utils.h"#define need_GL_ARB_multisample#define need_GL_ARB_texture_compression#define need_GL_ARB_vertex_buffer_object#include "extension_helper.h"#ifndef I810_DEBUGint I810_DEBUG = (0);#endifPUBLIC const char __driConfigOptions[] = { 0 };const GLuint __driNConfigOptions = 0;#define DRIVER_DATE "20050821"static const GLubyte *i810GetString( GLcontext *ctx, GLenum name ){ static char buffer[128]; switch (name) { case GL_VENDOR: return (GLubyte *)"Keith Whitwell"; case GL_RENDERER: { i810ContextPtr imesa = I810_CONTEXT(ctx); const char * chipset; switch (imesa->i810Screen->deviceID) { case PCI_CHIP_I810: chipset = "i810"; break; case PCI_CHIP_I810_DC100: chipset = "i810 DC-100"; break; case PCI_CHIP_I810_E: chipset = "i810E"; break; case PCI_CHIP_I815: chipset = "i815"; break; default: chipset = "Unknown i810-class Chipset"; break; } (void) driGetRendererString( buffer, chipset, DRIVER_DATE, 0 ); return (GLubyte *) buffer; } default: return 0; }}static void i810BufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height){ GET_CURRENT_CONTEXT(ctx); i810ContextPtr imesa = I810_CONTEXT(ctx); /* Need to lock to make sure the driDrawable is uptodate. This * information is used to resize Mesa's software buffers, so it has * to be correct. */ LOCK_HARDWARE(imesa); *width = imesa->driDrawable->w; *height = imesa->driDrawable->h; UNLOCK_HARDWARE(imesa);}/* Extension strings exported by the i810 driver. */const struct dri_extension card_extensions[] ={ { "GL_ARB_multisample", GL_ARB_multisample_functions }, { "GL_ARB_multitexture", NULL }, { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, { "GL_ARB_texture_env_add", NULL }, { "GL_ARB_texture_env_combine", NULL }, { "GL_ARB_texture_env_crossbar", NULL }, { "GL_ARB_texture_mirrored_repeat", NULL }, { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions }, { "GL_EXT_stencil_wrap", NULL }, { "GL_EXT_texture_edge_clamp", NULL }, { "GL_EXT_texture_env_combine", NULL }, { "GL_EXT_texture_lod_bias", NULL }, { "GL_EXT_texture_rectangle", NULL }, { "GL_MESA_ycbcr_texture", NULL }, { "GL_NV_blend_square", NULL }, { "GL_SGIS_generate_mipmap", NULL }, { NULL, NULL }};extern const struct tnl_pipeline_stage _i810_render_stage;static const struct tnl_pipeline_stage *i810_pipeline[] = { &_tnl_vertex_transform_stage, &_tnl_normal_transform_stage, &_tnl_lighting_stage, &_tnl_fog_coordinate_stage, &_tnl_texgen_stage, &_tnl_texture_transform_stage, /* REMOVE: point attenuation stage */#if 1 &_i810_render_stage, /* ADD: unclipped rastersetup-to-dma */#endif &_tnl_render_stage, 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 }, { "verb", DEBUG_VERBOSE }, { "dri", DEBUG_DRI }, { "dma", DEBUG_DMA }, { "san", DEBUG_SANITY }, { "sync", DEBUG_SYNC }, { "sleep", DEBUG_SLEEP }, { NULL, 0 }};GLbooleani810CreateContext( const __GLcontextModes *mesaVis, __DRIcontextPrivate *driContextPriv, void *sharedContextPrivate ){ GLcontext *ctx, *shareCtx; i810ContextPtr imesa; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private; I810SAREAPtr saPriv = (I810SAREAPtr) (((GLubyte *)sPriv->pSAREA) + i810Screen->sarea_priv_offset); struct dd_function_table functions; /* Allocate i810 context */ imesa = (i810ContextPtr) CALLOC_STRUCT(i810_context_t); if (!imesa) { return GL_FALSE; } driContextPriv->driverPrivate = imesa; imesa->i810Screen = i810Screen; imesa->driScreen = sPriv; imesa->sarea = saPriv; imesa->glBuffer = NULL; /* Init default driver functions then plug in our I810-specific functions * (the texture functions are especially important) */ _mesa_init_driver_functions( &functions ); i810InitIoctlFuncs( &functions ); i810InitTextureFuncs( &functions ); /* Allocate the Mesa context */ if (sharedContextPrivate) shareCtx = ((i810ContextPtr) sharedContextPrivate)->glCtx; else shareCtx = NULL; imesa->glCtx = _mesa_create_context(mesaVis, shareCtx, &functions, (void*) imesa); if (!imesa->glCtx) { FREE(imesa); return GL_FALSE; } (void) memset( imesa->texture_heaps, 0, sizeof( imesa->texture_heaps ) ); make_empty_list( & imesa->swapped ); imesa->nr_heaps = 1; imesa->texture_heaps[0] = driCreateTextureHeap( 0, imesa, i810Screen->textureSize, 12, I810_NR_TEX_REGIONS, imesa->sarea->texList, (unsigned *) & imesa->sarea->texAge, /* XXX we shouldn't cast! */ & imesa->swapped, sizeof( struct i810_texture_object_t ), (destroy_texture_object_t *) i810DestroyTexObj ); /* Set the maximum texture size small enough that we can guarentee * that both texture units can bind a maximal texture and have them * in memory at once. */ ctx = imesa->glCtx; ctx->Const.MaxTextureUnits = 2; ctx->Const.MaxTextureImageUnits = 2; ctx->Const.MaxTextureCoordUnits = 2; /* FIXME: driCalcualteMaxTextureLevels assumes that mipmaps are tightly * FIXME: packed, but they're not in Intel graphics hardware. */ driCalculateMaxTextureLevels( imesa->texture_heaps, imesa->nr_heaps, & ctx->Const, 4, 11, /* max 2D texture size is 2048x2048 */ 0, /* 3D textures unsupported */ 0, /* cube textures unsupported. */ 0, /* texture rectangles unsupported. */ 12, GL_FALSE, 0 ); ctx->Const.MinLineWidth = 1.0; ctx->Const.MinLineWidthAA = 1.0; ctx->Const.MaxLineWidth = 3.0; ctx->Const.MaxLineWidthAA = 3.0; ctx->Const.LineWidthGranularity = 1.0; ctx->Const.MinPointSize = 1.0; ctx->Const.MinPointSizeAA = 1.0; ctx->Const.MaxPointSize = 3.0; ctx->Const.MaxPointSizeAA = 3.0; ctx->Const.PointSizeGranularity = 1.0; /* reinitialize the context point state. * It depend on constants in __GLcontextRec::Const */ _mesa_init_point(ctx); ctx->Driver.GetBufferSize = i810BufferSize; ctx->Driver.GetString = i810GetString; /* Who owns who? */ ctx->DriverCtx = (void *) imesa; imesa->glCtx = ctx;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -