mesa: move max texture image unit constants to gl_program_constants
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_context.c
index 2b99e36b2a3b83da20c668bb060d3dd3f2c9f65f..7dd9109cca785e44242d8348a159291f64b809f1 100644 (file)
@@ -37,12 +37,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <stdbool.h>
 #include "main/glheader.h"
 #include "main/api_arrayelt.h"
+#include "main/api_exec.h"
 #include "main/context.h"
 #include "main/simple_list.h"
 #include "main/imports.h"
 #include "main/extensions.h"
-#include "main/mfeatures.h"
 #include "main/version.h"
+#include "main/vtxfmt.h"
 
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
@@ -179,7 +180,7 @@ r100CreateContext( gl_api api,
    int tcl_mode, fthrottle_mode;
 
    switch (api) {
-   case API_OPENGL:
+   case API_OPENGL_COMPAT:
       if (major_version > 1 || minor_version > 3) {
          *error = __DRI_CTX_ERROR_BAD_VERSION;
          return GL_FALSE;
@@ -201,7 +202,7 @@ r100CreateContext( gl_api api,
    assert(screen);
 
    /* Allocate the Radeon context */
-   rmesa = (r100ContextPtr) calloc(1, sizeof(*rmesa));
+   rmesa = calloc(1, sizeof(*rmesa));
    if ( !rmesa ) {
       *error = __DRI_CTX_ERROR_NO_MEMORY;
       return GL_FALSE;
@@ -251,16 +252,24 @@ r100CreateContext( gl_api api,
    rmesa->radeon.swtcl.RenderIndex = ~0;
    rmesa->radeon.hw.all_dirty = GL_TRUE;
 
+   ctx = &rmesa->radeon.glCtx;
+   /* Initialize the software rasterizer and helper modules.
+    */
+   _swrast_CreateContext( ctx );
+   _vbo_CreateContext( ctx );
+   _tnl_CreateContext( ctx );
+   _swsetup_CreateContext( ctx );
+   _ae_create_context( ctx );
+
    /* 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
     * texturable memory at once. Depending on the allow_large_textures driconf
     * setting allow larger textures.
     */
 
-   ctx = rmesa->radeon.glCtx;
    ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->radeon.optionCache,
                                                 "texture_units");
-   ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
+   ctx->Const.FragmentProgram.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
    ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
    ctx->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxTextureUnits;
 
@@ -307,14 +316,6 @@ r100CreateContext( gl_api api,
 
    _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
 
-   /* Initialize the software rasterizer and helper modules.
-    */
-   _swrast_CreateContext( ctx );
-   _vbo_CreateContext( ctx );
-   _tnl_CreateContext( ctx );
-   _swsetup_CreateContext( ctx );
-   _ae_create_context( ctx );
-
    /* Install the customized pipeline:
     */
    _tnl_destroy_pipeline( ctx );
@@ -353,20 +354,17 @@ r100CreateContext( gl_api api,
    ctx->Extensions.ATI_texture_mirror_once = true;
    ctx->Extensions.MESA_ycbcr_texture = true;
    ctx->Extensions.NV_blend_square = true;
-#if FEATURE_OES_EGL_image
    ctx->Extensions.OES_EGL_image = true;
-#endif
-
    ctx->Extensions.EXT_framebuffer_object = true;
-
    ctx->Extensions.ARB_texture_cube_map = true;
 
-   if (rmesa->radeon.glCtx->Mesa_DXTn) {
+   if (rmesa->radeon.glCtx.Mesa_DXTn) {
       ctx->Extensions.EXT_texture_compression_s3tc = true;
-      ctx->Extensions.S3_s3tc = true;
+      ctx->Extensions.ANGLE_texture_compression_dxt = true;
    }
    else if (driQueryOptionb (&rmesa->radeon.optionCache, "force_s3tc_enable")) {
       ctx->Extensions.EXT_texture_compression_s3tc = true;
+      ctx->Extensions.ANGLE_texture_compression_dxt = true;
    }
 
    ctx->Extensions.NV_texture_rectangle = true;
@@ -407,7 +405,7 @@ r100CreateContext( gl_api api,
         rmesa->radeon.radeonScreen->chip_flags &= ~RADEON_CHIPSET_TCL;
         fprintf(stderr, "Disabling HW TCL support\n");
       }
-      TCL_FALLBACK(rmesa->radeon.glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
+      TCL_FALLBACK(&rmesa->radeon.glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
    }
 
    if (rmesa->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) {
@@ -416,6 +414,10 @@ r100CreateContext( gl_api api,
 
    _mesa_compute_version(ctx);
 
+   /* Exec table initialization requires the version to be computed */
+   _mesa_initialize_dispatch_tables(ctx);
+   _mesa_initialize_vbo_vtxfmt(ctx);
+
    *error = __DRI_CTX_ERROR_SUCCESS;
    return GL_TRUE;
 }