i965: Remove brw->attribs now that we can just always look in the GLcontext.
[mesa.git] / src / mesa / drivers / dri / i965 / brw_context.c
index de0b74a8cbb5249dbb8e7c09b38155351aed4610..eaac6224f6ed6ee1d529b4ca58168dec76bc706d 100644 (file)
   */
 
 
+#include "main/imports.h"
+#include "main/api_noop.h"
+#include "main/macros.h"
+#include "main/vtxfmt.h"
+#include "main/simple_list.h"
+#include "shader/shader_api.h"
+
 #include "brw_context.h"
 #include "brw_defines.h"
 #include "brw_draw.h"
+#include "brw_state.h"
 #include "brw_vs.h"
-#include "imports.h"
 #include "intel_tex.h"
 #include "intel_blit.h"
 #include "intel_batchbuffer.h"
 #include "tnl/t_pipeline.h"
 
 #include "utils.h"
-#include "api_noop.h"
-#include "vtxfmt.h"
 
-#include "shader/shader_api.h"
 
 /***************************************
  * Mesa's Driver Functions
  ***************************************/
 
-static const struct dri_extension brw_extensions[] =
-{
-    { "GL_ARB_depth_texture",              NULL },
-    { "GL_ARB_fragment_program",           NULL },
-    { "GL_ARB_shadow",                     NULL },
-    { "GL_EXT_shadow_funcs",               NULL },
-    /* ARB extn won't work if not enabled */
-    { "GL_SGIX_depth_texture",             NULL },
-    { "GL_ARB_texture_env_crossbar",       NULL },
-    { NULL,                                NULL }
-};
-
 static void brwUseProgram(GLcontext *ctx, GLuint program)
 {
-        struct brw_context *brw = brw_context(ctx);
-        struct gl_shader_program *sh_prog;
-        _mesa_use_program(ctx, program);
-        sh_prog = ctx->Shader.CurrentProgram;
-        if (sh_prog) {
-           if (sh_prog->VertexProgram) {
-               brw->attribs.VertexProgram->Current = sh_prog->VertexProgram;
-               sh_prog->VertexProgram->Base.RefCount++;
-               ctx->VertexProgram.Enabled = GL_TRUE;
-           }else
-               ctx->VertexProgram.Enabled = GL_FALSE;
-               
-           if (sh_prog->FragmentProgram) {
-               brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram;
-               sh_prog->FragmentProgram->Base.RefCount++;
-               ctx->FragmentProgram.Enabled = GL_TRUE;
-           } else
-               ctx->FragmentProgram.Enabled = GL_FALSE;
-       }
+   _mesa_use_program(ctx, program);
 }
 
 static void brwInitProgFuncs( struct dd_function_table *functions )
@@ -95,42 +69,13 @@ static void brwInitDriverFunctions( struct dd_function_table *functions )
 {
    intelInitDriverFunctions( functions );
 
-   /* CopyPixels can be accelerated even with the current memory
-    * manager:
-    */
-   if (!getenv("INTEL_NO_BLIT")) {
-      functions->CopyPixels = intelCopyPixels;
-      functions->Bitmap = intelBitmap;
-   }
-
    brwInitFragProgFuncs( functions );
    brwInitProgFuncs( functions );
-}
-
+   brw_init_queryobj_functions(functions);
 
-static void brw_init_attribs( struct brw_context *brw )
-{
-   GLcontext *ctx = &brw->intel.ctx;
-
-   brw->attribs.Color = &ctx->Color;
-   brw->attribs.Depth = &ctx->Depth;
-   brw->attribs.Fog = &ctx->Fog;
-   brw->attribs.Hint = &ctx->Hint;
-   brw->attribs.Light = &ctx->Light;
-   brw->attribs.Line = &ctx->Line;
-   brw->attribs.Point = &ctx->Point;
-   brw->attribs.Polygon = &ctx->Polygon;
-   brw->attribs.Scissor = &ctx->Scissor;
-   brw->attribs.Stencil = &ctx->Stencil;
-   brw->attribs.Texture = &ctx->Texture;
-   brw->attribs.Transform = &ctx->Transform;
-   brw->attribs.Viewport = &ctx->Viewport;
-   brw->attribs.VertexProgram = &ctx->VertexProgram;
-   brw->attribs.FragmentProgram = &ctx->FragmentProgram;
-   brw->attribs.PolygonStipple = &ctx->PolygonStipple[0];
+   functions->Viewport = intel_viewport;
 }
 
-
 GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
                            __DRIcontextPrivate *driContextPriv,
                            void *sharedContextPrivate)
@@ -160,27 +105,24 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
 
    TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
 
-   ctx->Const.MaxTextureUnits = BRW_MAX_TEX_UNIT;
    ctx->Const.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
-   ctx->Const.MaxTextureCoordUnits = BRW_MAX_TEX_UNIT;
-
+   ctx->Const.MaxTextureCoordUnits = 8; /* Mesa limit */
+   ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits,
+                                     ctx->Const.MaxTextureImageUnits);
+   ctx->Const.MaxVertexTextureImageUnits = 0; /* no vertex shader textures */
 
-   /* Advertise the full hardware capabilities.  The new memory
-    * manager should cope much better with overload situations:
+   /* Mesa limits textures to 4kx4k; it would be nice to fix that someday
     */
-   ctx->Const.MaxTextureLevels = 12;
+   ctx->Const.MaxTextureLevels = 13;
    ctx->Const.Max3DTextureLevels = 9;
    ctx->Const.MaxCubeTextureLevels = 12;
-   ctx->Const.MaxTextureRectSize = (1<<11);
-   ctx->Const.MaxTextureUnits = BRW_MAX_TEX_UNIT;
+   ctx->Const.MaxTextureRectSize = (1<<12);
    
-/*    ctx->Const.MaxNativeVertexProgramTemps = 32; */
-
+   /* if conformance mode is set, swrast can handle any size AA point */
+   ctx->Const.MaxPointSizeAA = 255.0;
 
-   driInitExtensions( ctx, brw_extensions, GL_FALSE );
+/*    ctx->Const.MaxNativeVertexProgramTemps = 32; */
 
-   brw_init_attribs( brw );
-   brw_init_metaops( brw );
    brw_init_state( brw );
 
    brw->state.dirty.mesa = ~0;
@@ -188,13 +130,12 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
 
    brw->emit_state_always = 0;
 
-   ctx->FragmentProgram._MaintainTexEnvProgram = 1;
-
-   brw_draw_init( brw );
+   ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
+   ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
 
-   brw_ProgramCacheInit( ctx );
+   make_empty_list(&brw->query.active_head);
 
-   brw_FrameBufferTexInit( brw );
+   brw_draw_init( brw );
 
    return GL_TRUE;
 }