raedon/r200/r300: mega-FBO commits.
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_context.c
index f562876db4b02365b14405986f8efcdf20728d17..ac945ecc4d37d0ab5b7c130c32f944faa847ed40 100644 (file)
@@ -66,6 +66,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define need_GL_EXT_blend_minmax
 #define need_GL_EXT_fog_coord
 #define need_GL_EXT_secondary_color
+#define need_GL_EXT_framebuffer_object
 #include "extension_helper.h"
 
 #define DRIVER_DATE    "20061018"
@@ -88,6 +89,7 @@ const struct dri_extension card_extensions[] =
     { "GL_EXT_blend_logic_op",             NULL },
     { "GL_EXT_blend_subtract",             GL_EXT_blend_minmax_functions },
     { "GL_EXT_fog_coord",                  GL_EXT_fog_coord_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 },
@@ -104,6 +106,11 @@ const struct dri_extension card_extensions[] =
     { NULL,                                NULL }
 };
 
+const struct dri_extension mm_extensions[] = {
+  { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
+  { NULL, NULL }
+};
+
 extern const struct tnl_pipeline_stage _radeon_render_stage;
 extern const struct tnl_pipeline_stage _radeon_tcl_stage;
 
@@ -161,7 +168,6 @@ static void r100_get_lock(radeonContextPtr radeon)
    }
    
    if (sarea->ctx_owner != rmesa->radeon.dri.hwContext) {
-      int i;
       sarea->ctx_owner = rmesa->radeon.dri.hwContext;
       
       if (!radeon->radeonScreen->kernel_mm)
@@ -187,10 +193,10 @@ static void r100_init_vtbl(radeonContextPtr radeon)
 {
    radeon->vtbl.get_lock = r100_get_lock;
    radeon->vtbl.update_viewport_offset = radeonUpdateViewportOffset;
-   radeon->vtbl.update_draw_buffer = radeonUpdateDrawBuffer;
    radeon->vtbl.emit_cs_header = r100_vtbl_emit_cs_header;
    radeon->vtbl.swtcl_flush = r100_swtcl_flush;
    radeon->vtbl.pre_emit_state = r100_vtbl_pre_emit_state;
+   radeon->vtbl.fallback = radeonFallback;
 }
 
 /* Create the device specific context.
@@ -255,26 +261,6 @@ radeonCreateContext( const __GLcontextModes *glVisual,
      return GL_FALSE;
    }
 
-   (void) memset( rmesa->radeon.texture_heaps, 0, sizeof( rmesa->radeon.texture_heaps ) );
-   make_empty_list( & rmesa->radeon.swapped );
-
-#if 0
-   rmesa->radeon.nr_heaps = screen->numTexHeaps;
-   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 *) radeonDestroyTexObj );
-
-      driSetTextureSwapCounterLocation( rmesa->radeon.texture_heaps[i],
-                                       & rmesa->c_textureSwaps );
-   }
-#endif
    rmesa->radeon.texture_depth = driQueryOptioni (&rmesa->radeon.optionCache,
                                           "texture_depth");
    if (rmesa->radeon.texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
@@ -298,19 +284,6 @@ radeonCreateContext( 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 */
-                                8,  /* 256^3 */
-                                9,  /* \todo: max cube texture size seems to be 512x512(x6) */
-                                11, /* max rect texture size is 2048x2048. */
-                                12,
-                                GL_FALSE,
-                                i );
-
-
    ctx->Const.MaxTextureMaxAnisotropy = 16.0;
 
    /* No wide points.
@@ -372,6 +345,8 @@ radeonCreateContext( const __GLcontextModes *glVisual,
    }
 
    driInitExtensions( ctx, card_extensions, GL_TRUE );
+   if (rmesa->radeon.radeonScreen->kernel_mm)
+     driInitExtensions(ctx, mm_extensions, GL_FALSE);
    if (rmesa->radeon.radeonScreen->drmSupportsCubeMapsR100)
       _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
    if (rmesa->radeon.glCtx->Mesa_DXTn) {
@@ -386,6 +361,7 @@ radeonCreateContext( const __GLcontextModes *glVisual,
       _mesa_enable_extension( ctx, "GL_NV_texture_rectangle");
 
    /* XXX these should really go right after _mesa_init_driver_functions() */
+   radeon_fbo_init(&rmesa->radeon);
    radeonInitSpanFuncs( ctx );
    radeonInitIoctlFuncs( ctx );
    radeonInitStateFuncs( ctx );
@@ -403,8 +379,6 @@ radeonCreateContext( const __GLcontextModes *glVisual,
 
    rmesa->radeon.do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
 
-   (*sPriv->systemTime->getUST)( & rmesa->radeon.swap_ust );
-
 
 #if DO_DEBUG
    RADEON_DEBUG = driParseDebugString( getenv( "RADEON_DEBUG" ),
@@ -450,10 +424,7 @@ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
    /* Free radeon 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 );
@@ -473,20 +444,6 @@ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
         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 );