X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fr200%2Fr200_context.c;h=e3ae839235ed94e3666af045d5dd81646799bb2a;hb=0ea575d721821262a862ceef010db9b1a8b4a6d9;hp=1f5a9f2427b8a0a0b2d8454d65c83af8647e4927;hpb=1090d206de011a67d236d8c4ae32d2d42b2f6337;p=mesa.git diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 1f5a9f2427b..e3ae839235e 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -60,23 +60,22 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r200_tcl.h" #include "r200_maos.h" #include "r200_vertprog.h" +#include "radeon_queryobj.h" #include "radeon_span.h" -#define need_GL_ARB_multisample -#define need_GL_ARB_texture_compression -#define need_GL_ARB_vertex_buffer_object +#define need_GL_ARB_occlusion_query #define need_GL_ARB_vertex_program #define need_GL_ATI_fragment_shader #define need_GL_EXT_blend_minmax #define need_GL_EXT_fog_coord -#define need_GL_EXT_multi_draw_arrays #define need_GL_EXT_secondary_color #define need_GL_EXT_blend_equation_separate #define need_GL_EXT_blend_func_separate #define need_GL_NV_vertex_program #define need_GL_ARB_point_parameters -#include "extension_helper.h" +#define need_GL_EXT_framebuffer_object +#include "main/remap_helper.h" #define DRIVER_DATE "20060602" @@ -116,22 +115,20 @@ static const GLubyte *r200GetString( GLcontext *ctx, GLenum name ) /* Extension strings exported by the R200 driver. */ -const struct dri_extension card_extensions[] = +static const struct dri_extension card_extensions[] = { - { "GL_ARB_multisample", GL_ARB_multisample_functions }, { "GL_ARB_multitexture", NULL }, + { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, { "GL_ARB_texture_border_clamp", 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_dot3", 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_blend_minmax", GL_EXT_blend_minmax_functions }, { "GL_EXT_blend_subtract", NULL }, { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, - { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions }, + { "GL_EXT_packed_depth_stencil", NULL}, { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions }, { "GL_EXT_stencil_wrap", NULL }, { "GL_EXT_texture_edge_clamp", NULL }, @@ -149,30 +146,35 @@ const struct dri_extension card_extensions[] = { NULL, NULL } }; -const struct dri_extension blend_extensions[] = { +static const struct dri_extension blend_extensions[] = { { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions }, { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions }, { NULL, NULL } }; -const struct dri_extension ARB_vp_extension[] = { +static const struct dri_extension ARB_vp_extension[] = { { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions } }; -const struct dri_extension NV_vp_extension[] = { +static const struct dri_extension NV_vp_extension[] = { { "GL_NV_vertex_program", GL_NV_vertex_program_functions } }; -const struct dri_extension ATI_fs_extension[] = { +static const struct dri_extension ATI_fs_extension[] = { { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions } }; -const struct dri_extension point_extensions[] = { +static const struct dri_extension point_extensions[] = { { "GL_ARB_point_sprite", NULL }, { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions }, { NULL, NULL } }; +static const struct dri_extension mm_extensions[] = { + { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, + { NULL, NULL } +}; + extern const struct tnl_pipeline_stage _r200_render_stage; extern const struct tnl_pipeline_stage _r200_tcl_stage; @@ -219,32 +221,11 @@ static void r200InitDriverFuncs( struct dd_function_table *functions ) functions->GetString = r200GetString; } -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 }, - { NULL, 0 } -}; static void r200_get_lock(radeonContextPtr radeon) { r200ContextPtr rmesa = (r200ContextPtr)radeon; drm_radeon_sarea_t *sarea = radeon->sarea; - int i; R200_STATECHANGE( rmesa, ctx ); if (rmesa->radeon.sarea->tiling_enabled) { @@ -254,25 +235,39 @@ static void r200_get_lock(radeonContextPtr radeon) if ( sarea->ctx_owner != rmesa->radeon.dri.hwContext ) { sarea->ctx_owner = rmesa->radeon.dri.hwContext; + if (!radeon->radeonScreen->kernel_mm) + radeon_bo_legacy_texture_age(radeon->radeonScreen->bom); } - for ( i = 0 ; i < rmesa->radeon.nr_heaps ; i++ ) { - DRI_AGE_TEXTURES( rmesa->radeon.texture_heaps[ i ] ); - } } static void r200_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa) { } +static void r200_emit_query_finish(radeonContextPtr radeon) +{ + BATCH_LOCALS(radeon); + struct radeon_query_object *query = radeon->query.current; + + BEGIN_BATCH_NO_AUTOSTATE(4); + OUT_BATCH(CP_PACKET0(RADEON_RB3D_ZPASS_ADDR, 0)); + OUT_BATCH_RELOC(0, query->bo, query->curr_offset, 0, RADEON_GEM_DOMAIN_GTT, 0); + END_BATCH(); + query->curr_offset += sizeof(uint32_t); + assert(query->curr_offset < RADEON_QUERY_PAGE_SIZE); + query->emitted_begin = GL_FALSE; +} static void r200_init_vtbl(radeonContextPtr radeon) { radeon->vtbl.get_lock = r200_get_lock; radeon->vtbl.update_viewport_offset = r200UpdateViewportOffset; - radeon->vtbl.update_draw_buffer = r200UpdateDrawBuffer; radeon->vtbl.emit_cs_header = r200_vtbl_emit_cs_header; radeon->vtbl.swtcl_flush = r200_swtcl_flush; + radeon->vtbl.fallback = r200Fallback; + radeon->vtbl.update_scissor = r200_vtbl_update_scissor; + radeon->vtbl.emit_query_finish = r200_emit_query_finish; } @@ -312,7 +307,8 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, rmesa->radeon.initialMaxAnisotropy = driQueryOptionf(&rmesa->radeon.optionCache, "def_max_anisotropy"); - if ( driQueryOptionb( &rmesa->radeon.optionCache, "hyperz" ) ) { + if ( sPriv->drm_version.major == 1 + && driQueryOptionb( &rmesa->radeon.optionCache, "hyperz" ) ) { if ( sPriv->drm_version.minor < 13 ) fprintf( stderr, "DRM version 1.%d too old to support HyperZ, " "disabling.\n", sPriv->drm_version.minor ); @@ -329,9 +325,10 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, _mesa_init_driver_functions(&functions); r200InitDriverFuncs(&functions); r200InitIoctlFuncs(&functions); - r200InitStateFuncs(&functions); + r200InitStateFuncs(&functions, screen->kernel_mm); r200InitTextureFuncs(&functions); r200InitShaderFuncs(&functions); + radeonInitQueryObjFunctions(&functions); if (!radeonInitContext(&rmesa->radeon, &functions, glVisual, driContextPriv, @@ -340,31 +337,6 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, return GL_FALSE; } - - (void) memset( rmesa->radeon.texture_heaps, 0, sizeof( rmesa->radeon.texture_heaps ) ); - make_empty_list( & rmesa->radeon.swapped ); - - rmesa->radeon.nr_heaps = 1 /* screen->numTexHeaps */ ; - assert(rmesa->radeon.nr_heaps < RADEON_NR_TEX_HEAPS); -#if 0 - for ( i = 0 ; i < rmesa->radeon.nr_heaps ; i++ ) { - rmesa->radeon.texture_heaps[i] = driCreateTextureHeap( i, rmesa, - screen->texSize[i], - 12, - RADEON_NR_TEX_REGIONS, - (drmTextureRegionPtr)rmesa->radeon.sarea->tex_list[i], - & rmesa->radeon.sarea->tex_age[i], - & rmesa->radeon.swapped, - sizeof( radeonTexObj ), - (destroy_texture_object_t *) r200DestroyTexObj ); - } -#endif - rmesa->radeon.texture_depth = driQueryOptioni (&rmesa->radeon.optionCache, - "texture_depth"); - if (rmesa->radeon.texture_depth == DRI_CONF_TEXTURE_DEPTH_FB) - rmesa->radeon.texture_depth = ( screen->cpp == 4 ) ? - DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16; - rmesa->radeon.swtcl.RenderIndex = ~0; rmesa->radeon.hw.all_dirty = 1; @@ -382,21 +354,12 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, i = driQueryOptioni( &rmesa->radeon.optionCache, "allow_large_textures"); - driCalculateMaxTextureLevels( rmesa->radeon.texture_heaps, - rmesa->radeon.nr_heaps, - & ctx->Const, - 4, - 11, /* max 2D texture size is 2048x2048 */ -#if ENABLE_HW_3D_TEXTURE - 8, /* max 3D texture size is 256^3 */ -#else - 0, /* 3D textures unsupported */ -#endif - 11, /* max cube texture size is 2048x2048 */ - 11, /* max texture rectangle size is 2048x2048 */ - 12, - GL_FALSE, - i ); + /* FIXME: When no memory manager is available we should set this + * to some reasonable value based on texture memory pool size */ + ctx->Const.MaxTextureLevels = 12; + ctx->Const.Max3DTextureLevels = 9; + ctx->Const.MaxCubeTextureLevels = 12; + ctx->Const.MaxTextureRectSize = 2048; ctx->Const.MaxTextureMaxAnisotropy = 16.0; @@ -426,6 +389,10 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, ctx->Const.VertexProgram.MaxNativeParameters = R200_VSF_MAX_PARAM; ctx->Const.VertexProgram.MaxNativeAddressRegs = 1; + ctx->Const.MaxDrawBuffers = 1; + + _mesa_set_mvp_with_dp4( ctx, GL_TRUE ); + /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); @@ -460,6 +427,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, _math_matrix_set_identity( &rmesa->tmpmat ); driInitExtensions( ctx, card_extensions, GL_TRUE ); + + if (rmesa->radeon.radeonScreen->kernel_mm) + driInitExtensions(ctx, mm_extensions, GL_FALSE); if (!(rmesa->radeon.radeonScreen->chip_flags & R200_CHIPSET_YCBCR_BROKEN)) { /* yuv textures don't work with some chips - R200 / rv280 okay so far others get the bit ordering right but don't actually do YUV-RGB conversion */ @@ -487,6 +457,9 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, driInitSingleExtension( ctx, ATI_fs_extension ); if (rmesa->radeon.radeonScreen->drmSupportsPointSprites) driInitExtensions( ctx, point_extensions, GL_FALSE ); + + if (!rmesa->radeon.radeonScreen->kernel_mm) + _mesa_disable_extension(ctx, "GL_ARB_occlusion_query"); #if 0 r200InitDriverFuncs( ctx ); r200InitIoctlFuncs( ctx ); @@ -495,6 +468,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, #endif /* plug in a few more device driver functions */ /* XXX these should really go right after _mesa_init_driver_functions() */ + radeon_fbo_init(&rmesa->radeon); radeonInitSpanFuncs( ctx ); r200InitPixelFuncs( ctx ); r200InitTnlFuncs( ctx ); @@ -504,13 +478,6 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, rmesa->prefer_gart_client_texturing = (getenv("R200_GART_CLIENT_TEXTURES") != 0); -#if DO_DEBUG - R200_DEBUG = driParseDebugString( getenv( "R200_DEBUG" ), - debug_control ); - R200_DEBUG |= driParseDebugString( getenv( "RADEON_DEBUG" ), - debug_control ); -#endif - tcl_mode = driQueryOptioni(&rmesa->radeon.optionCache, "tcl_mode"); if (driQueryOptionb(&rmesa->radeon.optionCache, "no_rast")) { fprintf(stderr, "disabling 3D acceleration\n"); @@ -529,78 +496,15 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, } -/* Destroy the device specific context. - */ -/* Destroy the Mesa and driver specific context data. - */ void r200DestroyContext( __DRIcontextPrivate *driContextPriv ) { - GET_CURRENT_CONTEXT(ctx); - r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate; - r200ContextPtr current = ctx ? R200_CONTEXT(ctx) : NULL; - - /* check if we're deleting the currently bound context */ - if (rmesa == current) { - radeon_firevertices(&rmesa->radeon); - _mesa_make_current(NULL, NULL, NULL); - } - - /* Free r200 context resources */ - assert(rmesa); /* should never be null */ - if ( rmesa ) { - GLboolean release_texture_heaps; - - - release_texture_heaps = (rmesa->radeon.glCtx->Shared->RefCount == 1); - _swsetup_DestroyContext( rmesa->radeon.glCtx ); - _tnl_DestroyContext( rmesa->radeon.glCtx ); - _vbo_DestroyContext( rmesa->radeon.glCtx ); - _swrast_DestroyContext( rmesa->radeon.glCtx ); - - r200DestroySwtcl( rmesa->radeon.glCtx ); - r200ReleaseArrays( rmesa->radeon.glCtx, ~0 ); - - if (rmesa->radeon.dma.current) { - rcommonFlushCmdBuf( &rmesa->radeon, __FUNCTION__ ); - } - - if (rmesa->radeon.state.scissor.pClipRects) { - FREE(rmesa->radeon.state.scissor.pClipRects); - rmesa->radeon.state.scissor.pClipRects = NULL; - } - - - if ( release_texture_heaps ) { - /* This share group is about to go away, free our private - * texture object data. - */ - int i; - - for ( i = 0 ; i < rmesa->radeon.nr_heaps ; i++ ) { - driDestroyTextureHeap( rmesa->radeon.texture_heaps[ i ] ); - rmesa->radeon.texture_heaps[ i ] = NULL; - } - - assert( is_empty_list( & rmesa->radeon.swapped ) ); - } - - radeonCleanupContext(&rmesa->radeon); - - FREE( rmesa ); - } -} - - - -/* Force the context `c' to be unbound from its buffer. - */ -GLboolean -r200UnbindContext( __DRIcontextPrivate *driContextPriv ) -{ - r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate; - - if (R200_DEBUG & DEBUG_DRI) - fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)rmesa->radeon.glCtx); - - return GL_TRUE; + int i; + r200ContextPtr rmesa = (r200ContextPtr)driContextPriv->driverPrivate; + if (rmesa) + { + for ( i = 0 ; i < R200_MAX_TEXTURE_UNITS ; i++ ) { + _math_matrix_dtr( &rmesa->TexGenMatrix[i] ); + } + } + radeonDestroyContext(driContextPriv); }