r300: move firevertices out into the main place its needed.
[mesa.git] / src / mesa / drivers / dri / r200 / r200_context.c
index 9f1edd39d3db8c844d25f494f62daf425939439b..10a6362afd2820417d86f1780d62f8786ac52396 100644 (file)
@@ -54,7 +54,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_context.h"
 #include "r200_ioctl.h"
 #include "r200_state.h"
-#include "r200_span.h"
 #include "r200_pixel.h"
 #include "r200_tex.h"
 #include "r200_swtcl.h"
@@ -62,14 +61,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "r200_maos.h"
 #include "r200_vertprog.h"
 
-#define need_GL_ARB_multisample
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
+#include "radeon_span.h"
+
 #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
@@ -117,20 +114,16 @@ static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
  */
 const struct dri_extension card_extensions[] =
 {
-    { "GL_ARB_multisample",                GL_ARB_multisample_functions },
     { "GL_ARB_multitexture",               NULL },
     { "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_secondary_color",            GL_EXT_secondary_color_functions },
     { "GL_EXT_stencil_wrap",               NULL },
     { "GL_EXT_texture_edge_clamp",         NULL },
@@ -253,50 +246,24 @@ 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_flush(GLcontext *ctx)
-{
-   R200_FIREVERTICES(R200_CONTEXT(ctx));
-}
-
-static void r200_vtbl_flush_vertices(radeonContextPtr rmesa)
-{
-  R200_FIREVERTICES(((r200ContextPtr)rmesa));
-}
-
-static void r200_vtbl_set_all_dirty(GLcontext *ctx)
-{
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   rmesa->hw.all_dirty = GL_TRUE;
 }
 
 static void r200_vtbl_emit_cs_header(struct radeon_cs *cs, radeonContextPtr rmesa)
 {
 }
 
-static void r200_vtbl_emit_state(radeonContextPtr rmesa)
-{
-       r200EmitState((r200ContextPtr)rmesa);
-}
-
 
 static void r200_init_vtbl(radeonContextPtr radeon)
 {
    radeon->vtbl.get_lock = r200_get_lock;
    radeon->vtbl.update_viewport_offset = r200UpdateViewportOffset;
-   radeon->vtbl.flush = r200_vtbl_flush;
-   radeon->vtbl.flush_vertices = r200_vtbl_flush_vertices;
-   radeon->vtbl.set_all_dirty = r200_vtbl_set_all_dirty;
-   radeon->vtbl.update_draw_buffer = r200UpdateDrawBuffer;
    radeon->vtbl.emit_cs_header = r200_vtbl_emit_cs_header;
-   radeon->vtbl.emit_state = r200_vtbl_emit_state;
+   radeon->vtbl.swtcl_flush = r200_swtcl_flush;
+   radeon->vtbl.fallback = r200Fallback;
 }
 
 
@@ -364,36 +331,14 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
      return GL_FALSE;
    }
 
-
-   if (!rmesa->radeon.radeonScreen->kernel_mm)
-       rmesa->dma.buf0_address = rmesa->radeon.radeonScreen->buffers->list[0].address;
-
-   (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->swtcl.RenderIndex = ~0;
-   rmesa->hw.all_dirty = 1;
+   rmesa->radeon.swtcl.RenderIndex = ~0;
+   rmesa->radeon.hw.all_dirty = 1;
 
    /* Set the maximum texture size small enough that we can guarentee that
     * all texture units can bind a maximal texture and have all of them in
@@ -409,22 +354,6 @@ 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 );
-
    ctx->Const.MaxTextureMaxAnisotropy = 16.0;
 
    /* No wide AA points.
@@ -453,6 +382,8 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
    ctx->Const.VertexProgram.MaxNativeParameters = R200_VSF_MAX_PARAM;
    ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
 
+   ctx->Const.MaxDrawBuffers = 1;
+
    /* Initialize the software rasterizer and helper modules.
     */
    _swrast_CreateContext( ctx );
@@ -522,8 +453,8 @@ 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() */
+   radeonInitSpanFuncs( ctx );
    r200InitPixelFuncs( ctx );
-   r200InitSpanFuncs( ctx );
    r200InitTnlFuncs( ctx );
    r200InitState( rmesa );
    r200InitSwtcl( ctx );
@@ -568,17 +499,14 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
 
    /* check if we're deleting the currently bound context */
    if (rmesa == current) {
-      R200_FIREVERTICES( rmesa );
+      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 );
@@ -587,8 +515,8 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
       r200DestroySwtcl( rmesa->radeon.glCtx );
       r200ReleaseArrays( rmesa->radeon.glCtx, ~0 );
 
-      if (rmesa->dma.current.buf) {
-       //       r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
+      if (rmesa->radeon.dma.current) {
+        radeonReleaseDmaRegion( &rmesa->radeon );
         rcommonFlushCmdBuf( &rmesa->radeon, __FUNCTION__ );
       }
 
@@ -597,21 +525,6 @@ void r200DestroyContext( __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 );